Class Persistencer
- java.lang.Object
-
- net.ssehub.easy.producer.core.persistence.standard.Persistencer
-
- All Implemented Interfaces:
IPersistencer,PersistenceConstants
public class Persistencer extends java.lang.Object implements IPersistencer, PersistenceConstants
This class represents an interlayer between persistency-layer and model. It provides functions for loading a model from the storage or saving it to storage. Therefore it performs a conversion between the persistency model and the application model. UsesUrlResolver.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private static net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLoggerLOGGERprivate net.ssehub.easy.basics.progress.ProgressObserverobserverprivate java.io.FileprojectFolderprivate DataStoragestorage-
Fields inherited from interface net.ssehub.easy.producer.core.persistence.standard.PersistenceConstants
CONFIG_FILE, EASY_FILES_DEFAULT, INSTANTIATOR_ENGINE, INSTANTIATOR_FILE, INSTANTIATOR_INHERITED, INSTANTIATOR_PATH_REGEX, INSTANTIATOR_PATHS, INSTANTIATOR_UUID, PLP_LOCATION, PLP_VERSION, PRESUCCESSOR_LOCATION, PRESUCCESSOR_MEMEBERNAME, PRESUCCESSOR_UUID, PRESUCCESSOR_VERSION, PTN_PROJECTNAME, PTN_UUID, REASONER_ATTRIBUTE, REASONER_TIMEOUT, REASONER_VALUE_SEPARATOR, REASONER_VALUES, SETTINGS_DEBUG
-
-
Constructor Summary
Constructors Constructor Description Persistencer(PathEnvironment pathEnv, java.io.File projectFolder, java.lang.String storageFile, net.ssehub.easy.basics.progress.ProgressObserver observer)Sole constructor for this class for saving/reading persistence information out of a xml file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IProjectCreationResultcreateProject(java.lang.String projectName, java.io.File parentFolder, java.lang.String projectID, boolean lazy)Creates an empty EASy project without any eclipse specific stuff.PathEnvironmentgetPathEnvironment()Returns the path environment for making absolute paths relative and vice versa.java.lang.StringgetProjectID()Returns the ID of a given EASy project.PersistentProjectload()Loads a PersistentProject, which is an EASy project representation, from a storage (file system).private voidloadDefaultModels()Loads the default models if existent.PLPInfoloadPLP()Loads aPLPInfofrom a storage (file system).voidsave(PLPInfo plp)Saves given EASy to storage.private voidsave(PersistentProject project)Saves given EASy to storage.voidupdate()Updates the models in the given project.private voidwriteDebugData(PLPInfo plp)Writes debug data to file system, if and only ifPLPInfo.getSaveDebugInformation()was set to true.
-
-
-
Field Detail
-
LOGGER
private static final net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger LOGGER
-
storage
private DataStorage storage
-
observer
private net.ssehub.easy.basics.progress.ProgressObserver observer
-
projectFolder
private java.io.File projectFolder
-
-
Constructor Detail
-
Persistencer
public Persistencer(PathEnvironment pathEnv, java.io.File projectFolder, java.lang.String storageFile, net.ssehub.easy.basics.progress.ProgressObserver observer)
Sole constructor for this class for saving/reading persistence information out of a xml file.- Parameters:
pathEnv- a path environment for making files and paths relativeprojectFolder- The location of the product line project.storageFile- The absolute path of the file, which should be read/be written. for loading (nested) ivml models.observer- a progress observer, may beProgressObserver.NO_OBSERVER
-
-
Method Detail
-
loadDefaultModels
private void loadDefaultModels()
Loads the default models if existent.
-
load
public PersistentProject load() throws PersistenceException
Description copied from interface:IPersistencerLoads a PersistentProject, which is an EASy project representation, from a storage (file system).- Specified by:
loadin interfaceIPersistencer- Returns:
- The PersistentProject of the project which should be loaded.
- Throws:
PersistenceException- In case of an incorrect data format of the configuration file, this exception will be thrown.
-
loadPLP
public PLPInfo loadPLP() throws PersistenceException
Loads aPLPInfofrom a storage (file system).- Returns:
- The
PLPInfowhich should be loaded. - Throws:
PersistenceException- In case of an incorrect data format of the configuration file, this exception will be thrown.
-
createProject
public IProjectCreationResult createProject(java.lang.String projectName, java.io.File parentFolder, java.lang.String projectID, boolean lazy) throws PersistenceException
Description copied from interface:IPersistencerCreates an empty EASy project without any eclipse specific stuff.- Specified by:
createProjectin interfaceIPersistencer- Parameters:
projectName- The name of the project, which should be created.parentFolder- The parentFolder, where the project should be created.projectID- The unique ID of the project which should be created.lazy- iftrue, create only required parts, else assume that project does not exist before- Returns:
- IProjectCreationResult Information of newly created items.
- Throws:
PersistenceException- Will be thrown if the System cannot create folders and files in the parentFolder.
-
save
public void save(PLPInfo plp) throws PersistenceException
Saves given EASy to storage.- Specified by:
savein interfaceIPersistencer- Parameters:
plp- the information, which should be saved.- Throws:
PersistenceException- If the file cannot be written to the file system.
-
writeDebugData
private void writeDebugData(PLPInfo plp) throws PersistenceException
Writes debug data to file system, if and only ifPLPInfo.getSaveDebugInformation()was set to true. Part of thesave(PLPInfo)method.- Parameters:
plp- the information, which should be saved.- Throws:
PersistenceException- If the file cannot be written to the file system.
-
save
private void save(PersistentProject project) throws PersistenceException
Saves given EASy to storage.- Parameters:
project- the information, which should be saved.- Throws:
PersistenceException- If the file cannot be written to the file system.
-
getProjectID
public java.lang.String getProjectID()
Returns the ID of a given EASy project.- Specified by:
getProjectIDin interfaceIPersistencer- Returns:
- the id or null if the specified project has no configuration file.
-
update
public void update() throws PersistenceExceptionDescription copied from interface:IPersistencerUpdates the models in the given project.- Specified by:
updatein interfaceIPersistencer- Throws:
PersistenceException- if errors during the update occur
-
getPathEnvironment
public PathEnvironment getPathEnvironment()
Description copied from interface:IPersistencerReturns the path environment for making absolute paths relative and vice versa.- Specified by:
getPathEnvironmentin interfaceIPersistencer- Returns:
- the path environment
-
-