Class ModelCommentsPersistencer
- java.lang.Object
-
- net.ssehub.easy.varModel.management.ModelCommentsPersistencer
-
public class ModelCommentsPersistencer extends java.lang.ObjectImplements (internationalized) comment persistence mechanisms on model level. Instances of this class cannot be created directly rather than being obtained fromVarModel.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private IModelManagementRepository<Project>repository
-
Constructor Summary
Constructors Constructor Description ModelCommentsPersistencer(IModelManagementRepository<Project> repository)Prevents creating instances from outside this package.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidassignComment(ContainableModelElement elt, CommentResource props)Assigns a comment fromprops(if exists) toelt.private voidassignComments(IDecisionVariableContainer container, CommentResource props)Assign the comments stored inpropsto the model elements incontainer.private voidassignCommentsToProject(Project project, CommentResource props)Assign the comments stored inpropsto the containable model elements inproject.private static CommentResourcegetComments(ModelInfo<Project> info)Determines the comment resource for the specified model information object/project.static CommentResourcegetComments(Project project)Returns the comment resource for the given project.static java.lang.StringgetKey(Constraint cons)Returns the key for a constraint.(package private) voidloadComments(ModelInfo<Project> info)Loads comments from the resolved project ofinfo.private static voidreadResourceFromFile(CommentResource resource, java.io.File file)Reads the comment resource from the given file.booleanstoreComments(ModelInfo<Project> info)Stores the comments stored in the resolved project ofinfo.booleanstoreComments(ModelInfo<Project> info, boolean considerImports)Stores the comments stored in the resolved project ofinfoand optionally for all imported projects.
-
-
-
Field Detail
-
repository
private IModelManagementRepository<Project> repository
-
-
Constructor Detail
-
ModelCommentsPersistencer
ModelCommentsPersistencer(IModelManagementRepository<Project> repository)
Prevents creating instances from outside this package.- Parameters:
repository- the repository instance for callbacks
-
-
Method Detail
-
storeComments
public boolean storeComments(ModelInfo<Project> info) throws java.io.IOException
Stores the comments stored in the resolved project ofinfo. Existing data will be overwritten. Currently, this method considers only containable model elements.- Parameters:
info- the project information the comments shall be stored for- Returns:
trueif the comments have been stored,falseif no exception occurred but also the data was not stored, e.g. becauseinfois not resolved orModelInfo.getCommentsResource()is invalid- Throws:
java.io.IOException- in case that writing of the comments resource caused an error
-
storeComments
public boolean storeComments(ModelInfo<Project> info, boolean considerImports) throws java.io.IOException
Stores the comments stored in the resolved project ofinfoand optionally for all imported projects. Existing data will be overwritten. Currently, this method considers only containable model elements.- Parameters:
info- the project information the comments shall be stored forconsiderImports- consider also (resolved) imported projects- Returns:
trueif the comments have been stored,falseif no exception occurred but also the data was not stored, e.g. becauseinfois not resolved orModelInfo.getCommentsResource()is invalid- Throws:
java.io.IOException- in case that writing of the comments resource caused an error
-
loadComments
void loadComments(ModelInfo<Project> info) throws java.io.IOException
Loads comments from the resolved project ofinfo. Existing comments in the related project will be overridden. This method affects only the directly related project!- Parameters:
info- the information object to load comments for- Throws:
java.io.IOException- in case that reading the comments resource caused an error
-
getComments
public static CommentResource getComments(Project project) throws java.io.IOException
Returns the comment resource for the given project.- Parameters:
project- the project- Returns:
- the comment resource, may be null
- Throws:
java.io.IOException- in case of I/O problems
-
getComments
private static CommentResource getComments(ModelInfo<Project> info) throws java.io.IOException
Determines the comment resource for the specified model information object/project.- Parameters:
info- the model information object- Returns:
- the comment resource, may be null
- Throws:
java.io.IOException- in case of I/O problems
-
readResourceFromFile
private static void readResourceFromFile(CommentResource resource, java.io.File file) throws java.io.IOException
Reads the comment resource from the given file.- Parameters:
resource- the resource to be modifiedfile- the file- Throws:
java.io.IOException- in case of I/O problems
-
assignCommentsToProject
private void assignCommentsToProject(Project project, CommentResource props)
Assign the comments stored inpropsto the containable model elements inproject.- Parameters:
project- the project to assign the comments to (may be modified as a side effect)props- the properties containing the comments (fqn-comment mapping)
-
assignComments
private void assignComments(IDecisionVariableContainer container, CommentResource props)
Assign the comments stored inpropsto the model elements incontainer.- Parameters:
container- the container to assign the comments to (may be modified as a side effect)props- the properties containing the comments (fqn-comment mapping)
-
assignComment
private void assignComment(ContainableModelElement elt, CommentResource props)
Assigns a comment fromprops(if exists) toelt.- Parameters:
elt- the element to assign to (modified as a side effect)props- the comment resource containing the comments
-
getKey
public static java.lang.String getKey(Constraint cons)
Returns the key for a constraint.- Parameters:
cons- the key- Returns:
- the constraint key, may be empty for none, e.g., if
consis null
-
-