cz.cuni.mff.procasor.core.helper
Class EntityHelper

java.lang.Object
  extended bycz.cuni.mff.procasor.core.helper.EntityHelper

public final class EntityHelper
extends java.lang.Object

Helper class for Entity.

Author:
Jirka

Method Summary
static void addChidren(Entity entity, Entity child)
          Add children entity to EntityList and sets parent of that entity to its new parent.
static Entity createEntity(java.lang.String name, java.lang.String description)
          Creates new entity.
static boolean isAcronymCorrect(Entity entity, java.lang.String name, Project project)
          Check if the acronym of entity is correct.(if is unique and contains possible chars)
static boolean isNameCorrect(Entity entity, java.lang.String name, Project project)
          Check if the name of entity is correct.
static void remove(Entity entity, Project project)
          Remove entity from project.
static void save(Entity entity, Project project)
          Generate new id for entity and add entity to the project.
static void setParent(Entity entity, Entity parent)
          Set parent and check all children if parent isn't among children (in this case parent is removed from children).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createEntity

public static Entity createEntity(java.lang.String name,
                                  java.lang.String description)
Creates new entity. Sets all its attributes. Find id.

Parameters:
name - name of the entity
description - description of the entity
Returns:
newly created entity

save

public static void save(Entity entity,
                        Project project)
Generate new id for entity and add entity to the project.

Parameters:
entity - entity without id
project - project entity is setted to

remove

public static void remove(Entity entity,
                          Project project)
Remove entity from project. Also remove entity from children and parent of other entities in project.

Parameters:
entity - entity to be removed
project - project entity is removed from

addChidren

public static void addChidren(Entity entity,
                              Entity child)
Add children entity to EntityList and sets parent of that entity to its new parent.

Parameters:
entity - entity children is added to
child - entity that is children

setParent

public static void setParent(Entity entity,
                             Entity parent)
Set parent and check all children if parent isn't among children (in this case parent is removed from children).

Parameters:
entity - entity parent is setted to
parent - entity that is a parent for previous entity

isNameCorrect

public static boolean isNameCorrect(Entity entity,
                                    java.lang.String name,
                                    Project project)
Check if the name of entity is correct. (isis unique)

Parameters:
entity - entity which name is checked
project - project with other entities
Returns:
true if name is correct, false otherwise

isAcronymCorrect

public static boolean isAcronymCorrect(Entity entity,
                                       java.lang.String name,
                                       Project project)
Check if the acronym of entity is correct.(if is unique and contains possible chars)

Parameters:
entity - entity which acronym is checked
project - project with other entities
Returns:
true if acronym is correct, false otherwise