public class SaveModelManager
extends java.lang.Object
It is responsible for:
- Get the XMLDBModel which is the Ptolemy model wrapped in a special Data
Transfer Object (dto).
- Wrap the model object in another dto (SaveModelTask or CreateModelTask)
to either create it in the database or save the modification made on it.
- Get a database connection and run the execute method on the database
connection object to perform the saving or creation of the model.
Constructor and Description |
---|
SaveModelManager() |
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<XMLDBModel> |
getFirstLevelParents(XMLDBModel baseModel)
Return the first level parents that reference a give model.
|
XMLDBModel |
populateChildModelsList(XMLDBModel model)
Populate the referenced child models list and update the model XML by
replacing the referenced models with place holder.
|
void |
renameModel(XMLDBModel originalModel,
java.lang.String newName)
Rename an existing model in the database.
|
java.lang.String |
save(XMLDBModel xmlDBModel)
Save the changes of an existing model in the database or create a new
model in the database.
|
java.lang.String |
saveWithParents(XMLDBModelWithReferenceChanges xmlDBModelWithReferenceChanges)
Save a model but keep a list of models that reference it point to the old
model and update the rest of the models.
|
public java.util.ArrayList<XMLDBModel> getFirstLevelParents(XMLDBModel baseModel) throws DBConnectionException, DBExecutionException
baseModel
- An XMLDBModel object that represents the model for which
the first level parents are retrieved.DBConnectionException
- Thrown if there is a problem creating a
connection to the database.DBExecutionException
- Thrown if the operation fails to execute.public java.lang.String save(XMLDBModel xmlDBModel) throws DBConnectionException, DBExecutionException, java.lang.IllegalArgumentException, ModelAlreadyExistException, XMLDBModelParsingException, CircularDependencyException
xmlDBModel
- The model object that is required to be saved or
created in the database.DBConnectionException
- Thrown if there is a database connection
error.DBExecutionException
- Thrown if the execution failed.java.lang.IllegalArgumentException
- Thrown if the parameters were not
right.ModelAlreadyExistException
- Thrown if the model being created
already exists.XMLDBModelParsingException
- Thrown if the model is parsed
incorrectly.CircularDependencyException
- Thrown if there is a circular
dependency.public java.lang.String saveWithParents(XMLDBModelWithReferenceChanges xmlDBModelWithReferenceChanges) throws DBConnectionException, DBExecutionException, DBModelNotFoundException, ModelAlreadyExistException, java.lang.IllegalArgumentException, XMLDBModelParsingException, CircularDependencyException
xmlDBModelWithReferenceChanges
- An object that contains the model
to be saved, the list of parents that should have the old reference, and
the new version name that will be placed as a reference in the parents'
list.DBConnectionException
- Thrown if the connection to the database
fails.DBExecutionException
- Thrown if the operation fails to execute.DBModelNotFoundException
- Thrown if the model to be saved is
not in the database.ModelAlreadyExistException
- Thrown if the new version name matches
a name of a model that is already in the database.java.lang.IllegalArgumentException
- Thrown if the parameters passed are not
properly set.XMLDBModelParsingException
- Thrown if the MoML in the model object
is corrupted.CircularDependencyException
- Thrown if the save operation causes a
circular dependency.public XMLDBModel populateChildModelsList(XMLDBModel model) throws XMLDBModelParsingException
model
- Model with references to be resolved.XMLDBModelParsingException
- If thrown while parsing the XML.public void renameModel(XMLDBModel originalModel, java.lang.String newName) throws DBConnectionException, DBExecutionException, java.lang.IllegalArgumentException, ModelAlreadyExistException, DBModelNotFoundException
originalModel
- XMLDBModel object that represent the model that its
name needs to be changed.newName
- A string that contains the new model name.DBConnectionException
- Thrown if the connection to the database
fails.DBExecutionException
- Thrown if the operation failed during
execution.java.lang.IllegalArgumentException
- Thrown if one of the parameters is
not proper.ModelAlreadyExistException
- Thrown if the new name of the model
represent a model that already exists in the database.DBModelNotFoundException
- Thrown if the original model does not
exit in the database.