Class ModelCommentsPersistencer
java.lang.Object
net.ssehub.easy.varModel.management.ModelCommentsPersistencer
Implements (internationalized) comment persistence mechanisms on model level.
Instances of this class cannot be created directly rather than being obtained from
VarModel.- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate net.ssehub.easy.basics.modelManagement.IModelManagementRepository<Project> -
Constructor Summary
ConstructorsConstructorDescriptionModelCommentsPersistencer(net.ssehub.easy.basics.modelManagement.IModelManagementRepository<Project> repository) Prevents creating instances from outside this package. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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(net.ssehub.easy.basics.modelManagement.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 StringgetKey(Constraint cons) Returns the key for a constraint.(package private) voidloadComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info) Loads comments from the resolved project ofinfo.private static voidreadResourceFromFile(CommentResource resource, File file) Reads the comment resource from the given file.booleanstoreComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info) Stores the comments stored in the resolved project ofinfo.booleanstoreComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info, boolean considerImports) Stores the comments stored in the resolved project ofinfoand optionally for all imported projects.
-
Field Details
-
repository
-
-
Constructor Details
-
ModelCommentsPersistencer
ModelCommentsPersistencer(net.ssehub.easy.basics.modelManagement.IModelManagementRepository<Project> repository) Prevents creating instances from outside this package.- Parameters:
repository- the repository instance for callbacks
-
-
Method Details
-
storeComments
public boolean storeComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info) throws 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:
IOException- in case that writing of the comments resource caused an error
-
storeComments
public boolean storeComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info, boolean considerImports) throws 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:
IOException- in case that writing of the comments resource caused an error
-
loadComments
void loadComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info) throws 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:
IOException- in case that reading the comments resource caused an error
-
getComments
Returns the comment resource for the given project.- Parameters:
project- the project- Returns:
- the comment resource, may be null
- Throws:
IOException- in case of I/O problems
-
getComments
private static CommentResource getComments(net.ssehub.easy.basics.modelManagement.ModelInfo<Project> info) throws 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:
IOException- in case of I/O problems
-
readResourceFromFile
Reads the comment resource from the given file.- Parameters:
resource- the resource to be modifiedfile- the file- Throws:
IOException- in case of I/O problems
-
assignCommentsToProject
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
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
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
Returns the key for a constraint.- Parameters:
cons- the key- Returns:
- the constraint key, may be empty for none, e.g., if
consis null
-