Class EclipsePersistencer
- java.lang.Object
-
- net.ssehub.easy.producer.eclipse.persistency.eclipse.EclipsePersistencer
-
- All Implemented Interfaces:
IPersistencer
public class EclipsePersistencer extends java.lang.Object implements IPersistencer
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. This EclipsePersistencer can be used if the whole eclipse infrastructure is available. The another Persistencer can be used if Eclipse shall not be loaded/used.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.core.runtime.IProgressMonitormonitorprivate Persistencerpersistencerprivate org.eclipse.core.resources.IProjectprojectprivate java.io.FileprojectFolderstatic java.io.FileWORKSPACE_FOLDER
-
Constructor Summary
Constructors Constructor Description EclipsePersistencer(java.io.File projectFolder, org.eclipse.core.runtime.IProgressMonitor monitor)This constructor can be used if a project shall be/is stored outside the workspace (e.g.EclipsePersistencer(java.lang.String projectName, org.eclipse.core.runtime.IProgressMonitor monitor)Creates a new Persistencer instance for a project with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private EclipseProjectCreationResultcreateEASyEclipseProject(java.lang.String projectID, boolean lazy, java.lang.String... natures)Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.IEclipseProjectCreationResultcreateEASyProject(java.lang.String projectID, boolean lazy, java.lang.String... natures)Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.IEclipseProjectCreationResultcreateEASyProject(java.lang.String projectID, Project varModel, java.lang.String... natures)Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.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).voidsave(PLPInfo plp)Saves given PersistentProject to storage.voidupdate()Updates the models in the given project.
-
-
-
Field Detail
-
WORKSPACE_FOLDER
public static final java.io.File WORKSPACE_FOLDER
-
persistencer
private Persistencer persistencer
-
monitor
private org.eclipse.core.runtime.IProgressMonitor monitor
-
project
private org.eclipse.core.resources.IProject project
-
projectFolder
private java.io.File projectFolder
-
-
Constructor Detail
-
EclipsePersistencer
public EclipsePersistencer(java.lang.String projectName, org.eclipse.core.runtime.IProgressMonitor monitor)Creates a new Persistencer instance for a project with the specified name. This project must/will be stored directly into the workspace (no linking supported). If the project shall not be stored directly into the workspace, than please use the other constructor.- Parameters:
projectName- The name of the project (which must be stored inside the workspace).monitor- A progress monitor, or null if progress reporting is not desired
-
EclipsePersistencer
public EclipsePersistencer(java.io.File projectFolder, org.eclipse.core.runtime.IProgressMonitor monitor)This constructor can be used if a project shall be/is stored outside the workspace (e.g. is only linked).- Parameters:
projectFolder- The top level folder of the project.monitor- A progress monitor, or null if progress reporting is not desired
-
-
Method Detail
-
createEASyEclipseProject
private EclipseProjectCreationResult createEASyEclipseProject(java.lang.String projectID, boolean lazy, java.lang.String... natures) throws PersistenceException, org.eclipse.core.runtime.CoreException
Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.- Parameters:
projectID- The unique ID of the project which should be created. If null is inserted, a random ID will be generatednatures- Additional natures which shall be added to the newly created IProject.lazy- iftrue, create only required parts, else assume that project does not exist before- Returns:
- An data object which holds information about newly created files, folders, and the IProject.
- Throws:
PersistenceException- Will be thrown if the System cannot create folders and files in the parentFolder.org.eclipse.core.runtime.CoreException- If Eclipse cannot create a new IProject, e.g. because a project with the desired name already exists
-
createEASyProject
public IEclipseProjectCreationResult createEASyProject(java.lang.String projectID, boolean lazy, java.lang.String... natures) throws PersistenceException, org.eclipse.core.runtime.CoreException
Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.- Parameters:
projectID- The unique ID of the project which should be created. If null is inserted, a random ID will be generatedlazy- iftrue, create only required parts, else assume that project does not exist beforenatures- Additional natures which shall be added to the newly created IProject.- Returns:
- An data object which holds information about newly created files, folders, and the IProject.
- Throws:
PersistenceException- Will be thrown if the System cannot create folders and files in the parentFolder.org.eclipse.core.runtime.CoreException- If Eclipse cannot create a new IProject, e.g. because a project with the desired name already exists
-
createEASyProject
public IEclipseProjectCreationResult createEASyProject(java.lang.String projectID, Project varModel, java.lang.String... natures) throws PersistenceException, org.eclipse.core.runtime.CoreException
Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.- Parameters:
projectID- The unique ID of the project which should be created. If null is inserted, a random ID will be generatedvarModel- An already existing varmodel, which should be integrated into the newly created project.natures- Additional natures which shall be added to the newly created IProject.- Returns:
- An data object which holds information about newly created files, folders, and the IProject.
Contrary to the
createEASyProject(String, boolean, String...)method, theIProjectCreationResult.getVarModelProjectPath()will return the location of the created file for the given varModel. - Throws:
PersistenceException- Will be thrown if the System cannot create folders and files in the parentFolder.org.eclipse.core.runtime.CoreException- If Eclipse cannot create a new IProject, e.g. because a project with the desired name already exists
-
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.
-
save
public void save(PLPInfo plp) throws PersistenceException
Description copied from interface:IPersistencerSaves given PersistentProject to storage.- Specified by:
savein interfaceIPersistencer- Parameters:
plp- The project which should be saved- Throws:
PersistenceException- If files cannot be written to the file system.
-
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.
-
getProjectID
public java.lang.String getProjectID()
Description copied from interface:IPersistencerReturns 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
-
-