org.eclipse.emf.emfstore.internal.server.core.helper
Class ResourceHelper

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.server.core.helper.ResourceHelper

public class ResourceHelper
extends Object

Helper for creating resources etc.

Author:
wesendon

Constructor Summary
ResourceHelper(ServerSpace serverSpace)
          Default constructor.
 
Method Summary
 void createResourceForChangePackage(ChangePackage changePackage, PrimaryVersionSpec versionId, ProjectId projectId)
          Creates a resource for a changepackage.
 void createResourceForProject(Project project, PrimaryVersionSpec versionId, ProjectId projectId)
          Creates a resource for a new project.
 void createResourceForProjectHistory(ProjectHistory projectHistory)
          Creates a resource for project history.
 void createResourceForVersion(Version version, ProjectId projectId)
          Creates a resource for a new version.
 void deleteProjectState(Version version, ProjectId projectId)
          Deletes a projectstate.
 String getProjectFolder(ProjectId projectId)
          Returns the file path to a given project.
 int getXFromPolicy(String policy, String defaultPolicy, boolean allowZero)
          Gets and checks a number from a given server property.
 void save(org.eclipse.emf.ecore.EObject object)
          Saves an eObject.
 void saveAll()
          Saves all modified resources in the serverspace's resource set.
 void saveWithProject(org.eclipse.emf.ecore.EObject eObject, Project project)
          Saves the given EObject and sets the IDs on the eObject's resource for all model elements contained in the given project.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceHelper

public ResourceHelper(ServerSpace serverSpace)
               throws FatalESException
Default constructor.

Parameters:
serverSpace - serverspace
Throws:
FatalESException - in case of failure
Method Detail

createResourceForProjectHistory

public void createResourceForProjectHistory(ProjectHistory projectHistory)
                                     throws FatalESException
Creates a resource for project history.

Parameters:
projectHistory - project history
Throws:
FatalESException - if saving fails

createResourceForVersion

public void createResourceForVersion(Version version,
                                     ProjectId projectId)
                              throws FatalESException
Creates a resource for a new version.

Parameters:
version - version
projectId - project id
Throws:
FatalESException - if saving fails

createResourceForProject

public void createResourceForProject(Project project,
                                     PrimaryVersionSpec versionId,
                                     ProjectId projectId)
                              throws FatalESException
Creates a resource for a new project.

Parameters:
project - project
projectId - projectid
versionId - versionid
Throws:
FatalESException - if saving fails

createResourceForChangePackage

public void createResourceForChangePackage(ChangePackage changePackage,
                                           PrimaryVersionSpec versionId,
                                           ProjectId projectId)
                                    throws FatalESException
Creates a resource for a changepackage.

Parameters:
changePackage - changepackage
versionId - versionId
projectId - projectId
Throws:
FatalESException - if saving fails

deleteProjectState

public void deleteProjectState(Version version,
                               ProjectId projectId)
Deletes a projectstate. The Resource the project is contained in will be unloaded as well as deleted.

Parameters:
version - the version to be deleted
projectId - the ID of the project to be deleted

getXFromPolicy

public int getXFromPolicy(String policy,
                          String defaultPolicy,
                          boolean allowZero)
Gets and checks a number from a given server property. This number - referred as x - describes the size of an interval between projectstates. It's needed to determine whether a projectstate should be saved or be backuped.

Parameters:
policy - policy name from server configuration
defaultPolicy - default policy name from server configuration
allowZero - allow zero for x
Returns:
x
See Also:
ServerConfiguration.PROJECTSTATE_VERSION_PERSISTENCE_EVERYXVERSIONS_X

getProjectFolder

public String getProjectFolder(ProjectId projectId)
Returns the file path to a given project.

Parameters:
projectId - the project id
Returns:
file path

saveWithProject

public void saveWithProject(org.eclipse.emf.ecore.EObject eObject,
                            Project project)
                     throws FatalESException
Saves the given EObject and sets the IDs on the eObject's resource for all model elements contained in the given project.

Parameters:
eObject - the EObject to be saved
project - the project, that is used to set the IDs of all model elements within the project on the resource
Throws:
FatalESException - in case of failure

save

public void save(org.eclipse.emf.ecore.EObject object)
          throws FatalESException
Saves an eObject.

Parameters:
object - the object
Throws:
FatalESException - in case of failure

saveAll

public void saveAll()
             throws FatalESException
Saves all modified resources in the serverspace's resource set.

Throws:
FatalESException - in case of failure


Copyright © 2015. All Rights Reserved.