public interface ModelEditor
ModelEditor is a interface to edit analyze models.
Edition is made trough ModelEditor enable modifications tracking and to protect the internal workings of the concrete implementation of the analyze model.
Every change to the AnalyzeModel should notify the observers of the AnalyzeModel with appropriate Updation object. See Updation object for additional information about how to inform changes.
for structure of information passed about modifications
,
for detailed explanation about the items found and editable in the 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 entity)
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 model)
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. |
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 entity,
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. |
Method Detail |
---|
void clearModel()
Clears model and makes it empty.
If cleared MUST send Updation message:
Type: UpdationType.CLEAR
Updation.UpdationType.CLEAR
java.util.Set<java.lang.String> getEntityNames()
Returns the names of the entities that the model contains.
void addEntity(java.lang.String name)
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.
name
- The name of the entity.Updation.UpdationDataType.ENTITY
void removeEntity(java.lang.String name)
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.
name
- The name of the entity.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.ENTITY
java.lang.String getEntityType(java.lang.String entity)
Returns the type of the entity.
entity
- The name of the entity.
NoSuchEntityException
- If given entity is not found.void setEntityType(java.lang.String entity, java.lang.String entityType)
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
entity
- The name of the entity.entityType
- The type
NoSuchEntityException
- If given entity is not found.Updation.UpdationType.MODIFY
,
Updation.UpdationDataType.ENTITY_TYPE
void changeEntityName(java.lang.String oldName, java.lang.String newName) throws NoSuchEntityException
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
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
boolean containsEntity(java.lang.String entityName)
Does the model contain the entity?
entityName
- The name of the entity which existence is checked.
void addParent(java.lang.String entityName, java.lang.String parentEntity) throws NoSuchEntityException
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
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
void removeParent(java.lang.String entityName, java.lang.String parentEntity) throws AnalyzeModelException
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
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
void removeAllParents(java.lang.String entityName) throws NoSuchEntityException
Removes all the parents of the entity. This does same thing than calling removeParent(String,String) for every parent.
entityName
- The name of the entity which parents are cleared.
NoSuchEntityException
- If given entity is not found.java.util.Set<java.lang.String> getParents(java.lang.String entityName)
Returns the parents of the entity.
entityName
- The name of the entity.
NoSuchEntityException
- If given entity is not found.void addChild(java.lang.String entityName, java.lang.String childEntity) throws NoSuchEntityException
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
entityName
- The name of parent entity.childEntity
- The name of the child.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.ENTITY_PARENT
void removeChild(java.lang.String entityName, java.lang.String childEntity) throws AnalyzeModelException
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
entityName
- The entity.childEntity
- The child to be removed.
NoSuchEntityException
- If given entity is not found.
AnalyzeModelException
Updation.UpdationDataType.ENTITY_PARENT
void removeAllChildren(java.lang.String entityName) throws AnalyzeModelException
Removes all the children from the entity. This is same than calling removeChild(String, String) for all the childs.
entityName
- The name of the entity which childs are cleared.
NoSuchEntityException
- If given entity is not found.
AnalyzeModelException
java.util.Set<java.lang.String> getChildren(java.lang.String entityName)
Returns the names of the entity's children.
entityName
- The name of the entity.
NoSuchEntityException
- If given entity is not found.void addMethod(java.lang.String entityName, java.lang.String methodName) throws NoSuchEntityException
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
entityName
- The name of the entity.methodName
- The name of the method.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.METHOD
void removeMethod(java.lang.String entityName, java.lang.String methodName) throws NoSuchEntityException
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
entityName
- The entity which owns the method.methodName
- The name of the method.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.METHOD
void changeMethodName(java.lang.String entityName, java.lang.String methodOldName, java.lang.String methodNewName) throws AnalyzeModelException
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.
entityName
- The name of the entity.methodOldName
- methodNewName
-
NoSuchEntityException
- If given entity is not found.
NoSuchMethodException
- If given method is not found.
AnalyzeModelException
Updation.UpdationType.MODIFY
,
Updation.UpdationDataType.METHOD
boolean containsMethod(java.lang.String entityName, java.lang.String methodName)
Checks if the given method exists in the entity.
entityName
- The name of the entitymethodName
- The name of the method.
NoSuchEntityException
- If given entity is not found.java.util.Set<java.lang.String> getMethodNames(java.lang.String entityName)
Returns the names of the entity's methods.
entityName
- The name of the entity
NoSuchEntityException
- If given entity is not found.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.
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.void addEntityInfluenceByMethod(java.lang.String entityName, java.lang.String methodName, java.lang.String influencedEntity) throws AnalyzeModelException
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.
entityName
- The name of the entity that owns the method.methodName
- The methods name.influencedEntity
-
NoSuchEntityException
- If given entity is not found.
NoSuchMethodException
- If given method is not found.
AnalyzeModelException
Updation.UpdationDataType.METHOD_INFLUENCE
void removeEntityInfluenceByMethod(java.lang.String entityName, java.lang.String methodName, java.lang.String influencedEntity) throws AnalyzeModelException
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.
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
void addAttribute(java.lang.String entityName, java.lang.String attributeName) throws NoSuchEntityException
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
entityName
- The name of the entity.attributeName
- The name of the attribute.
NoSuchEntityException
- If given entity is not found.Updation.UpdationDataType.ATTRIBUTE
void removeAttribute(java.lang.String entityName, java.lang.String attributeName) throws AnalyzeModelException
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
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
boolean containsAttribute(java.lang.String entityName, java.lang.String attributeName) throws NoSuchEntityException
Checks wheter the entity contains the attribute or not.
entityName
- The name of the entity.attributeName
- The name of the attribute.
NoSuchEntityException
- If given entity is not found.java.lang.String getAttributeFromCardinal(java.lang.String entityName, java.lang.String attributeName) throws AnalyzeModelException
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.
entityName
- The name of the entity.attributeName
- The name of the attibute.
AnalyzeModelException
java.lang.String getAttributeToCardinal(java.lang.String entityName, java.lang.String attributeName) throws AnalyzeModelException
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.
entityName
- The name of the entity.attributeName
- The name of the attibute.
AnalyzeModelException
void setAttributeFromCardinal(java.lang.String entityName, java.lang.String attributeName, java.lang.String cardinal) throws AnalyzeModelException
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
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
void setAttributeToCardinal(java.lang.String entityName, java.lang.String attributeName, java.lang.String cardinal) throws AnalyzeModelException
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
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
java.util.Set<java.lang.String> getAttributeNames(java.lang.String entityName)
Returns the attributes of the entity.
entityName
- The name of the entity.
NoSuchEntityException
- If given entity is not found.void merge(AnalyzeModel model) throws AnalyzeModelException
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.
model
- The analyze model beign merged.
AnalyzeModelException
java.util.List<Updation> getUpdations()
Get updations done to this analyzemodel.
void mergeEntity(java.lang.String targetEntityName, java.util.Set<java.lang.String> mergeSet)
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.
targetEntityName
- The name of the entity after merge.mergeSet
- The set of entity names that are going to be merged.void stepBack(int steps)
Undoes some edition steps.
steps
- to undoboolean execute(Updation updation) throws AnalyzeModelException
Executes action defined by updaton object.
AnalyzeModelException
void readySignal()
Signals all observers that this model is ready.
Sends observers Updation-message which type is Updation.UpdationType.READY.
updationStartedSignal()
void updationStartedSignal()
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(); } } }
void saveUpdationsToFile(java.io.File target) throws java.io.IOException
Saves the updations (modification log) to the given file.
target
- Defines the target filename for the modification
log file.
java.io.IOException