Class 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
    • 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 EclipseProjectCreationResult createEASyEclipseProject​(java.lang.String projectID, boolean lazy, java.lang.String... natures)
      Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.
      IEclipseProjectCreationResult createEASyProject​(java.lang.String projectID, boolean lazy, java.lang.String... natures)
      Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.
      IEclipseProjectCreationResult createEASyProject​(java.lang.String projectID, Project varModel, java.lang.String... natures)
      Creates an empty IProject inside the Eclipse workspace which is suitable for EASy.
      IProjectCreationResult createProject​(java.lang.String projectName, java.io.File parentFolder, java.lang.String projectID, boolean lazy)
      Creates an empty EASy project without any eclipse specific stuff.
      PathEnvironment getPathEnvironment()
      Returns the path environment for making absolute paths relative and vice versa.
      java.lang.String getProjectID()
      Returns the ID of a given EASy project.
      PersistentProject load()
      Loads a PersistentProject, which is an EASy project representation, from a storage (file system).
      void save​(PLPInfo plp)
      Saves given PersistentProject to storage.
      void update()
      Updates the models in the given project.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • WORKSPACE_FOLDER

        public static final java.io.File WORKSPACE_FOLDER
      • 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 generated
        natures - Additional natures which shall be added to the newly created IProject.
        lazy - if true, 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 generated
        lazy - if true, create only required parts, else assume that project does not exist before
        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.
        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 generated
        varModel - 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, the IProjectCreationResult.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: IPersistencer
        Loads a PersistentProject, which is an EASy project representation, from a storage (file system).
        Specified by:
        load in interface IPersistencer
        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.
      • createProject

        public IProjectCreationResult createProject​(java.lang.String projectName,
                                                    java.io.File parentFolder,
                                                    java.lang.String projectID,
                                                    boolean lazy)
                                             throws PersistenceException
        Description copied from interface: IPersistencer
        Creates an empty EASy project without any eclipse specific stuff.
        Specified by:
        createProject in interface IPersistencer
        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 - if true, 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: IPersistencer
        Returns the ID of a given EASy project.
        Specified by:
        getProjectID in interface IPersistencer
        Returns:
        the ID or null if the specified project has no configuration file.