Class EclipsePersistencer

java.lang.Object
net.ssehub.easy.producer.eclipse.persistency.eclipse.EclipsePersistencer
All Implemented Interfaces:
net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer

public class EclipsePersistencer extends Object implements net.ssehub.easy.producer.core.persistence.datatypes.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 Details

    • WORKSPACE_FOLDER

      public static final File WORKSPACE_FOLDER
    • persistencer

      private net.ssehub.easy.producer.core.persistence.standard.Persistencer persistencer
    • monitor

      private org.eclipse.core.runtime.IProgressMonitor monitor
    • project

      private org.eclipse.core.resources.IProject project
    • projectFolder

      private File projectFolder
  • Constructor Details

    • EclipsePersistencer

      public EclipsePersistencer(String projectName, EclipseProgressObserver obs, org.eclipse.core.resources.IProject project)
      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).
      obs - progress observer
      project - the project instance to operate on , may be null then a default one may be obtained
    • EclipsePersistencer

      public EclipsePersistencer(File projectFolder, EclipseProgressObserver obs, org.eclipse.core.resources.IProject project)
      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.
      obs - progress observer
      project - the project instance to operate on , may be null then a default one may be obtained
  • Method Details

    • createEASyEclipseProject

      private EclipseProjectCreationResult createEASyEclipseProject(String projectID, boolean lazy, String... natures) throws net.ssehub.easy.producer.core.persistence.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:
      net.ssehub.easy.producer.core.persistence.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(String projectID, boolean lazy, String... natures) throws net.ssehub.easy.producer.core.persistence.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:
      net.ssehub.easy.producer.core.persistence.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(String projectID, net.ssehub.easy.varModel.model.Project varModel, String... natures) throws net.ssehub.easy.producer.core.persistence.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:
      net.ssehub.easy.producer.core.persistence.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 net.ssehub.easy.producer.core.persistence.datatypes.PersistentProject load() throws net.ssehub.easy.producer.core.persistence.PersistenceException
      Specified by:
      load in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException
    • save

      public void save(net.ssehub.easy.producer.core.mgmt.PLPInfo plp) throws net.ssehub.easy.producer.core.persistence.PersistenceException
      Specified by:
      save in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException
    • createProject

      public net.ssehub.easy.producer.core.persistence.datatypes.IProjectCreationResult createProject(String projectName, File parentFolder, String projectID, boolean lazy) throws net.ssehub.easy.producer.core.persistence.PersistenceException
      Specified by:
      createProject in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException
    • getProjectID

      public String getProjectID()
      Specified by:
      getProjectID in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
    • update

      public void update() throws net.ssehub.easy.producer.core.persistence.PersistenceException
      Specified by:
      update in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException
    • getPathEnvironment

      public net.ssehub.easy.producer.core.persistence.datatypes.PathEnvironment getPathEnvironment()
      Specified by:
      getPathEnvironment in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
    • getProjectFolder

      public File getProjectFolder()
      Specified by:
      getProjectFolder in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
    • getEasyConfigFile

      public File getEasyConfigFile()
      Specified by:
      getEasyConfigFile in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer
    • setStorageFolder

      public void setStorageFolder(File folder)
      Specified by:
      setStorageFolder in interface net.ssehub.easy.producer.core.persistence.datatypes.IPersistencer