java.lang.Objectucot.model.object.ObjectAnalyzeModelEditor
public class ObjectAnalyzeModelEditor
Editor for the ObjectAnalyzeModel.
Field Summary | |
---|---|
(package private) ObjectAnalyzeModel |
model
|
static long |
serialVersionUID
|
(package private) java.util.List<Updation> |
updations
|
Constructor Summary | |
---|---|
ObjectAnalyzeModelEditor(ObjectAnalyzeModel model)
|
Method Summary | |
---|---|
void |
addAttribute(java.lang.String entityName,
java.lang.String attributeName)
Adds attribute to the entity. |
void |
addChild(java.lang.String entityName,
java.lang.String childEntity)
Adds child to the entity. |
void |
addEntity(java.lang.String name)
Adds an entity to the model. |
void |
addEntityInfluenceByMethod(java.lang.String entityName,
java.lang.String methodName,
java.lang.String influencedEntity)
Adds an influence between entity's method and the given entity. |
void |
addMethod(java.lang.String entityName,
java.lang.String methodName)
Add method to the entity. |
void |
addParent(java.lang.String entityName,
java.lang.String parentEntity)
Adds parent to the entity. |
void |
changeEntityName(java.lang.String oldName,
java.lang.String newName)
Changes the name of the entity. |
void |
changeMethodName(java.lang.String entityName,
java.lang.String methodOldName,
java.lang.String methodNewName)
Changes method name. |
void |
clearModel()
Clears model and makes it empty. |
boolean |
containsAttribute(java.lang.String entityName,
java.lang.String attributeName)
Checks wheter the entity contains the attribute or not. |
boolean |
containsEntity(java.lang.String entityName)
Does the model contain the entity? |
boolean |
containsMethod(java.lang.String entityName,
java.lang.String methodName)
Checks if the given method exists in the entity. |
boolean |
execute(Updation updation)
Executes action defined by updaton object. |
java.lang.String |
getAttributeFromCardinal(java.lang.String entityName,
java.lang.String attributeName)
Gets from part of the cardinality of the attribute relation. |
java.util.Set<java.lang.String> |
getAttributeNames(java.lang.String entityName)
Returns the attributes of the entity. |
java.lang.String |
getAttributeToCardinal(java.lang.String entityName,
java.lang.String attributeName)
Gets to part of the cardinality of the attribute relation. |
java.util.Set<java.lang.String> |
getChildren(java.lang.String entityName)
Returns the names of the entity's children. |
java.util.Set<java.lang.String> |
getEntitiesInfluencedByMethod(java.lang.String entityName,
java.lang.String methodName)
Returns set of entities that are refered by methods in the model. |
java.util.Set<java.lang.String> |
getEntityNames()
Returns the names of the entities that the model contains. |
java.lang.String |
getEntityType(java.lang.String name)
Returns the type of the entity. |
java.util.Set<java.lang.String> |
getMethodNames(java.lang.String entityName)
Returns the names of the entity's methods. |
java.util.Set<java.lang.String> |
getParents(java.lang.String entityName)
Returns the parents of the entity. |
java.util.List<Updation> |
getUpdations()
Get updations done to this analyzemodel. |
void |
merge(AnalyzeModel fromModel)
Merges given AnalyzeModel to the editors model. |
void |
mergeEntity(java.lang.String targetEntityName,
java.util.Set<java.lang.String> mergeSet)
Merges entities to other entity. |
void |
readySignal()
Signals all observers that this model is ready. |
void |
removeAllChildren(java.lang.String entityName)
Removes all the children from the entity. |
void |
removeAllParents(java.lang.String entityName)
Removes all the parents of the entity. |
void |
removeAttribute(java.lang.String entityName,
java.lang.String attributeName)
Removes attribute from the entity. |
void |
removeChild(java.lang.String entityName,
java.lang.String childEntity)
Removes given child from the entity. |
void |
removeEntity(java.lang.String name)
Removes entity from model. |
void |
removeEntityInfluenceByMethod(java.lang.String entityName,
java.lang.String methodName,
java.lang.String influencedEntity)
Removes influnce between entity's method and the given entity. |
void |
removeMethod(java.lang.String entityName,
java.lang.String methodName)
Removes method from the entity. |
void |
removeParent(java.lang.String entityName,
java.lang.String parentEntity)
Removes given parent from the entity. |
void |
saveUpdationsToFile(java.io.File target)
Saves the updations (modification log) to the given file. |
private void |
sendUpdation(Updation updation)
|
void |
setAttributeFromCardinal(java.lang.String entityName,
java.lang.String attributeName,
java.lang.String cardinal)
Sets the cardinality on the entitys side. |
void |
setAttributeToCardinal(java.lang.String entityName,
java.lang.String attributeName,
java.lang.String cardinal)
Sets the cardinality on attributes side. |
void |
setEntityType(java.lang.String name,
java.lang.String entityType)
Sets the type of the entity. |
void |
stepBack(int steps)
Undoes some edition steps. |
void |
updationStartedSignal()
Signals all observers that this model is beign modified. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long serialVersionUID
ObjectAnalyzeModel model
java.util.List<Updation> updations
Constructor Detail |
---|
public ObjectAnalyzeModelEditor(ObjectAnalyzeModel model)
Method Detail |
---|
private void sendUpdation(Updation updation)
public void clearModel()
ModelEditor
Clears model and makes it empty.
If cleared MUST send Updation message:
Type: UpdationType.CLEAR
clearModel
in interface ModelEditor
Updation.UpdationType.CLEAR
public java.util.Set<java.lang.String> getEntityNames()
ModelEditor
Returns the names of the entities that the model contains.
getEntityNames
in interface ModelEditor
public java.lang.String getEntityType(java.lang.String name)
ModelEditor
Returns the type of the entity.
getEntityType
in interface ModelEditor
name
- The name of the entity.
public void setEntityType(java.lang.String name, java.lang.String entityType)
ModelEditor
Sets the type of the entity.
If type is set MUST send Updation message:
Type: UpdationType.MODIFY
DataType: UpdationDataType.ENTITY_TYPE
Parameters: name of the entity, the type string
setEntityType
in interface ModelEditor
name
- The name of the entity.entityType
- The typeUpdation.UpdationType.MODIFY
,
Updation.UpdationDataType.ENTITY_TYPE
public void addEntity(java.lang.String name)
ModelEditor
Adds an entity to the model. If entity exists nothing is done.
If addition occurs MUST send Updation message:
Type: UpdationType.ADD
DataType: UpdationDataType.ENTITY
Parameters: name of the entity.
addEntity
in interface ModelEditor
name
- The name of the entity.Updation.UpdationDataType.ENTITY
public void removeEntity(java.lang.String name)
ModelEditor
Removes entity from model. If no such entity is found nothing is done.
If removing occurs MUST send Updation message:
Type: UpdationType.DELETE
DataType: UpdationDataType.ENTITY
Parameters: name of the entity.
removeEntity
in interface ModelEditor
name
- The name of the entity.Updation.UpdationDataType.ENTITY
public void changeEntityName(java.lang.String oldName, java.lang.String newName) throws NoSuchEntityException
ModelEditor
Changes the name of the entity.
If change occurs MUST send Updation message:
Type: UpdationType.MODIFY
DataType: UpdationDataType.ENTITY
Parameters: old name of the entity, new name of the entity
changeEntityName
in interface ModelEditor
oldName
- The entity name that is going to be changed.newName
- The new name for that entity.
NoSuchEntityException
- If given entity is not found.Updation.UpdationType.MODIFY
,
Updation.UpdationDataType.ENTITY
public boolean containsEntity(java.lang.String entityName)
ModelEditor
Does the model contain the entity?
containsEntity
in interface ModelEditor
entityName
- The name of the entity which existence is checked.
public void addParent(java.lang.String entityName, java.lang.String parentEntity) throws NoSuchEntityException
ModelEditor
Adds parent to the entity. If entity is not found
if adding occurs MUST send Updation message:
Type: UpdationType.ADD
DataType: UpdationDataType.ENTITY_PARENT
Parameters: name of the entity, the name of the parent
addParent
in interface ModelEditor
entityName
- The name of the child entity.parentEntity
- The name of the parent entity.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.ENTITY_PARENT
public void removeParent(java.lang.String entityName, java.lang.String parentEntity) throws AnalyzeModelException
ModelEditor
Removes given parent from the entity.
If removing occurs MUST send Updation message:
Type: UpdationType.DELETE
DataType: UpdationDataType.ENTITY_PARENT
Parameters: name of the entity, the name of the parent
removeParent
in interface ModelEditor
entityName
- The name of the child entity.parentEntity
- The name of the parent entity.
NoSuchEntityException
- If given entity is not found.
AnalyzeModelException
Updation.UpdationDataType.ENTITY_PARENT
public void removeAllParents(java.lang.String entityName) throws NoSuchEntityException
ModelEditor
Removes all the parents of the entity. This does same thing than calling removeParent(String,String) for every parent.
removeAllParents
in interface ModelEditor
entityName
- The name of the entity which parents are cleared.
NoSuchEntityException
- If given entity is not found.public java.util.Set<java.lang.String> getParents(java.lang.String entityName)
ModelEditor
Returns the parents of the entity.
getParents
in interface ModelEditor
entityName
- The name of the entity.
public void addChild(java.lang.String entityName, java.lang.String childEntity) throws NoSuchEntityException
ModelEditor
Adds child to the entity. This is same than calling addParent(childEntity, entityName) and same kind of updation message is expected.
if adding occurs MUST send Updation message:
Type: UpdationType.ADD
DataType: UpdationDataType.ENTITY_PARENT
Parameters: name of the entity, the name of the parent
addChild
in interface ModelEditor
entityName
- The name of parent entity.childEntity
- The name of the child.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.ENTITY_PARENT
public void removeChild(java.lang.String entityName, java.lang.String childEntity) throws AnalyzeModelException
ModelEditor
Removes given child from the entity. This is same than calling removeParent(childEntity, entityName) and same kind of updation message is expected.
If removing occurs MUST send Updation message:
Type: UpdationType.DELETE
DataType: UpdationDataType.ENTITY_PARENT
Parameters: name of the entity, the name of the parent
removeChild
in interface ModelEditor
entityName
- The entity.childEntity
- The child to be removed.
NoSuchEntityException
- If given entity is not found.
AnalyzeModelException
Updation.UpdationDataType.ENTITY_PARENT
public void removeAllChildren(java.lang.String entityName) throws AnalyzeModelException
ModelEditor
Removes all the children from the entity. This is same than calling removeChild(String, String) for all the childs.
removeAllChildren
in interface ModelEditor
entityName
- The name of the entity which childs are cleared.
NoSuchEntityException
- If given entity is not found.
AnalyzeModelException
public java.util.Set<java.lang.String> getChildren(java.lang.String entityName)
ModelEditor
Returns the names of the entity's children.
getChildren
in interface ModelEditor
entityName
- The name of the entity.
public void addMethod(java.lang.String entityName, java.lang.String methodName) throws NoSuchEntityException
ModelEditor
Add method to the entity.
If adding occurs MUST send Updation message:
Type: UpdationType.ADD
DataType: UpdationDataType.METHOD
Parameters: name of the entity, the name of the method
addMethod
in interface ModelEditor
entityName
- The name of the entity.methodName
- The name of the method.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.METHOD
public void removeMethod(java.lang.String entityName, java.lang.String methodName) throws NoSuchEntityException
ModelEditor
Removes method from the entity.
If remove occurs MUST send Updation message:
Type: UpdationType.REMOVE
DataType: UpdationDataType.METHOD
Parameters: name of the entity, the name of the method
removeMethod
in interface ModelEditor
entityName
- The entity which owns the method.methodName
- The name of the method.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.METHOD
public void changeMethodName(java.lang.String entityName, java.lang.String methodOldName, java.lang.String methodNewName) throws AnalyzeModelException
ModelEditor
Changes method name.
If change occurs MUST send Updation message:
Type: UpdationType.MODIFY
DataType: UpdationDataType.METHOD
Parameters: name of the entity, the old name of the method, the new name of the method.
changeMethodName
in interface ModelEditor
entityName
- The name of the entity.
NoSuchEntityException
- If given entity is not found.
NoSuchMethodException
- If given method is not found.
AnalyzeModelException
Updation.UpdationType.MODIFY
,
Updation.UpdationDataType.METHOD
public boolean containsMethod(java.lang.String entityName, java.lang.String methodName)
ModelEditor
Checks if the given method exists in the entity.
containsMethod
in interface ModelEditor
entityName
- The name of the entitymethodName
- The name of the method.
public java.util.Set<java.lang.String> getMethodNames(java.lang.String entityName)
ModelEditor
Returns the names of the entity's methods.
getMethodNames
in interface ModelEditor
entityName
- The name of the entity
public java.util.Set<java.lang.String> getEntitiesInfluencedByMethod(java.lang.String entityName, java.lang.String methodName)
ModelEditor
Returns set of entities that are refered by methods in the model.
getEntitiesInfluencedByMethod
in interface ModelEditor
entityName
- The name of the entity that owns the method.methodName
- The methods name.
public void addEntityInfluenceByMethod(java.lang.String entityName, java.lang.String methodName, java.lang.String influencedEntity) throws AnalyzeModelException
ModelEditor
Adds an influence between entity's method and the given entity.
If addition occurs MUST send Updation message:
Type: UpdationType.ADD
DataType: UpdationDataType.METHOD_INFLUENCE
Parameters: name of the entity, the name of the method, the name of entity influenced.
addEntityInfluenceByMethod
in interface ModelEditor
entityName
- The name of the entity that owns the method.methodName
- The methods name.
NoSuchEntityException
- If given entity is not found.
NoSuchMethodException
- If given method is not found.
AnalyzeModelException
Updation.UpdationDataType.METHOD_INFLUENCE
public void removeEntityInfluenceByMethod(java.lang.String entityName, java.lang.String methodName, java.lang.String influencedEntity) throws AnalyzeModelException
ModelEditor
Removes influnce between entity's method and the given entity.
If deletion occurs MUST send Updation message:
Type: UpdationType.DELETE
DataType: UpdationDataType.METHOD_INFLUENCE
Parameters: name of the entity, the name of the method, the name of entity influenced.
removeEntityInfluenceByMethod
in interface ModelEditor
entityName
- The name of the entity that owns the method.methodName
- The methods name.influencedEntity
- The name of the method that is influenced by the given method.
NoSuchEntityException
- If given entity is not found.
NoSuchMethodException
- If given method is not found.
AnalyzeModelException
Updation.UpdationDataType.METHOD_INFLUENCE
public void addAttribute(java.lang.String entityName, java.lang.String attributeName) throws NoSuchEntityException
ModelEditor
Adds attribute to the entity.
If addition occurs MUST send Updation message:
Type: UpdationType.ADD
DataType: UpdationDataType.ATTRIBUTE
Parameters: name of the entity, the name of the attribute
addAttribute
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attribute.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.ATTRIBUTE
public void removeAttribute(java.lang.String entityName, java.lang.String attributeName) throws AnalyzeModelException
ModelEditor
Removes attribute from the entity.
If deletion occurs MUST send Updation message:
Type: UpdationType.DELETE
DataType: UpdationDataType.ATTRIBUTE
Parameters: name of the entity, the name of the attribute
removeAttribute
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attribute.
NoSuchEntityException
- If given entity is not found.
NoSuchAttributeException
- If given attribute is not found.
AnalyzeModelException
Updation.UpdationDataType.ATTRIBUTE
public boolean containsAttribute(java.lang.String entityName, java.lang.String attributeName) throws NoSuchEntityException
ModelEditor
Checks wheter the entity contains the attribute or not.
containsAttribute
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attribute.
NoSuchEntityException
- If given entity is not found.public java.lang.String getAttributeFromCardinal(java.lang.String entityName, java.lang.String attributeName) throws AnalyzeModelException
ModelEditor
Gets from part of the cardinality of the attribute relation. From part means the cardinality on the entity's side that owns the attribute. For example in one-to-many relation the 'one' is from cardinality.
getAttributeFromCardinal
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attibute.
AnalyzeModelException
public java.lang.String getAttributeToCardinal(java.lang.String entityName, java.lang.String attributeName) throws AnalyzeModelException
ModelEditor
Gets to part of the cardinality of the attribute relation. To part means the cardinality on the attributes side. For example in one-to-many relation the 'many' is to cardinality.
getAttributeToCardinal
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attibute.
AnalyzeModelException
public void setAttributeFromCardinal(java.lang.String entityName, java.lang.String attributeName, java.lang.String cardinal) throws AnalyzeModelException
ModelEditor
Sets the cardinality on the entitys side.
If change occurs MUST send Updation message:
Type: UpdationType.MODIFY
DataType: UpdationDataType.ATTRIBUTE_FROM_CARDINALITY
Parameters: name of the entity, the name of the attribute, the from cardinality
setAttributeFromCardinal
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attibute.cardinal
- The cardinality value.
NoSuchEntityException
- If given entity is not found.
NoSuchAttributeException
- If given attribute is not found.
AnalyzeModelException
Updation.UpdationType.MODIFY
,
Updation.UpdationDataType.ATTRIBUTE_FROM_CARDINALITY
public void setAttributeToCardinal(java.lang.String entityName, java.lang.String attributeName, java.lang.String cardinal) throws AnalyzeModelException
ModelEditor
Sets the cardinality on attributes side.
If change occurs MUST send Updation message:
Type: UpdationType.MODIFY
DataType: UpdationDataType.ATTRIBUTE_TO_CARDINALITY
Parameters: name of the entity, the name of the attribute, the to cardinality
setAttributeToCardinal
in interface ModelEditor
entityName
- The name of the entity.attributeName
- The name of the attibute.cardinal
- The cardinality value.
NoSuchEntityException
- If given entity is not found.
NoSuchAttributeException
- If given attribute is not found.
AnalyzeModelException
Updation.UpdationType.MODIFY
,
Updation.UpdationDataType.ATTRIBUTE_TO_CARDINALITY
public java.util.Set<java.lang.String> getAttributeNames(java.lang.String entityName)
ModelEditor
Returns the attributes of the entity.
getAttributeNames
in interface ModelEditor
entityName
- The name of the entity.
public void merge(AnalyzeModel fromModel) throws AnalyzeModelException
ModelEditor
Merges given AnalyzeModel to the editors model. Merge only adds things that do not yet exist in the current model. Nothing is delted or modified. For example attribute's cardinalities are not modified even if there is same attribute with different cardinalities.
All proper updation messages should be sended for every action made. It might be good idea to send AnalydeModel.signalModificationStarted() when starting modifications and AnalzydeMode.signalReady() when done.
merge
in interface ModelEditor
fromModel
- The analyze model beign merged.
AnalyzeModelException
public java.util.List<Updation> getUpdations()
ModelEditor
Get updations done to this analyzemodel.
getUpdations
in interface ModelEditor
public void stepBack(int steps)
ModelEditor
Undoes some edition steps.
stepBack
in interface ModelEditor
steps
- to undopublic boolean execute(Updation updation) throws AnalyzeModelException
ModelEditor
Executes action defined by updaton object.
execute
in interface ModelEditor
AnalyzeModelException
public void mergeEntity(java.lang.String targetEntityName, java.util.Set<java.lang.String> mergeSet)
ModelEditor
Merges entities to other entity. If given target entity (called targetEntityName) does not exists it is created.
All the methods, attributes, and parents are added to one entity and the sources are removed afterwards. If there are same attributes it depens on the underlaying implementation which one of them will remain in the final entity.
mergeEntity
in interface ModelEditor
targetEntityName
- The name of the entity after merge.mergeSet
- The set of entity names that are going to be merged.public void readySignal()
ModelEditor
Signals all observers that this model is ready.
Sends observers Updation-message which type is Updation.UpdationType.READY.
readySignal
in interface ModelEditor
ModelEditor.updationStartedSignal()
public void updationStartedSignal()
ModelEditor
Signals all observers that this model is beign modified.
This method should be called before the model is going to trough lots of changes. All observers receive updation signal that is from this model and the argument is instance of Updation which type is Updation.UpdationType.MODIFICATION_STARTED.
Example of Observer listening the model:
new Observable(){ void update(Observable o, Object arg){ // Check that we know how to handle the parameters. if (! (o instanceof AnalyzeModel)) return; if (! (arg instanceof Updation)) return; Updation updation = (Updation) arg; // Check updation type switch(updation.getType()){ case Update.MODIFICATION_STARTED: drawUpdates = false; // Dont draw updates. break; case Update.READY: drawUpdates = true; // Start drawing updates. break; } // Draw updates if we are not in midle of updation. if (drawUpdates){ doDrawUpdates(); } } }
updationStartedSignal
in interface ModelEditor
public void saveUpdationsToFile(java.io.File target) throws java.io.IOException
ModelEditor
Saves the updations (modification log) to the given file.
saveUpdationsToFile
in interface ModelEditor
target
- Defines the target filename for the modification
log file.
java.io.IOException