public final class ModelRepository extends Object
This class gives you access to the different models under processing. This class is a thread-safe singleton.
The usage is simple, at a given moment only one document is under use, to work with another one you have to switch to another opened document.
This model repository offers workspaces. To each identified workspace is
attached an independent ModelRepositoryUnit
with an (independent) id
generator. A ModelRepositoryUnit
holds one Petri Net Document,
identified by the PetriNetDoc class of its corresponding Petri net type.
Unless you set the parallel property to true, there is a current active workspace, the most recent one that was created. This enables the mode where you could directly get the current workspace id, delete it, switch between workspaces, etc.
If you set the parallel property to true, you will mostly get null
when
trying to retrieve the current workspace id, or nothing will happen if you
try to delete the current workspace, or switch between workspaces, since all
are now active, by the virtue of setting that property to true. Please read the javadoc of
each method which deals with workspaces matter in order to know how it behaves in this case.
Modifier and Type | Method and Description |
---|---|
boolean |
areWorkspacesParallel()
Returns whether all workspaces are set to be simultaneously active by
default (true), or if just one workspace is active at a time (false).
|
void |
changeCurrentDocWorkspace(String documentWSId)
Sets the current selected document workspace.
|
String |
createDocumentWorkspace(String docWorkspaceId)
Creates a new model workspace into the repository, with no PetriNetDoc
associated (as
HLAPIRootClass ). |
void |
createDocumentWorkspace(String docWorkspaceId,
org.eclipse.emf.ecore.EObject petriNetDoc)
Same as
createModelWorkspace(String, HLAPIRootClass) , but this
time with the root PetriNetDoc object typed as an EObject (EMF). |
String |
createDocumentWorkspace(String docWorkspaceId,
HLAPIRootClass petriNetDoc)
Creates a new model workspace into the repository, with a PetriNetDoc
associated, as
HLAPIRootClass . |
String |
createModelWorkspace(String modelId)
Deprecated.
use createDocumentWorkspace(String modelId)
|
String |
createModelWorkspace(String modelId,
HLAPIRootClass petriNetDoc)
Deprecated.
use
createModelWorkspace(String, HLAPIRootClass)
instead |
int |
destroyCurrentModelWorkspace()
Deprecated.
use destroyCurrentDocumentWorkspace() instead
|
int |
destroyCurrentWorkspace()
Destroys the current model workspace data about a registered model, the
current workspace ID becomes
null . |
String |
getCurrentDocWSId()
Gives the id of the currently used document workspace.
|
org.eclipse.emf.ecore.EObject |
getCurrentEObjectRootClass()
Returns the root class associated to the current model in the current
workspace.
|
HLAPIRootClass |
getCurrentHLAPIRootClass()
Returns the root class associated to the current model in the current
workspace.
|
IdRepository |
getCurrentIdRepository()
Returns the
IdRepository associated to the current workspace. |
String |
getCurrentModelId()
Deprecated.
use getCurrentDocumentId() instead
|
static ModelRepository |
getInstance()
Returns the instance of ModelRepository.
|
PrettyPrintData |
getPrettyPrintData()
Gets Pretty Print Data, either from the current active document
workspace, or a global default (newly created) if no active workspace or
no workspace at all.
|
Set<String> |
getRegisteredModelsId()
Gives all registered workspace id's.
|
boolean |
isPrettyPrintActive()
Gets pretty print use status.
|
void |
reset()
Destroys the content of the model repository: all workspaces are removed
and there is no current workspace.
|
void |
setCurrentDocWorkspace(String documentWSId)
Deprecated.
use changeCurrentDocWorkspace instead
|
void |
setCurrentEObjectRootClass(org.eclipse.emf.ecore.EObject rc)
Sets the root class (PetriNetDoc of a PN Type) as an EMF's Eobject,
associated to the current workspace.
|
void |
setCurrentHLAPIRootClass(HLAPIRootClass hrc)
Sets the provided PetriNet Document (PetriNetDocHLAPI of a PN Type) as HLAPIRootClass
associated to the current active workspace.
|
void |
setCurrentModel(String documentWSId)
Deprecated.
use changeCurrentDocWorkspace instead
|
void |
setParallelWorkspaces(boolean mode)
Sets if the model repository should hold all workspaces as being active
in parallel.
|
void |
setPrettyPrintStatus(boolean status)
Sets pretty print use, on the current workspace.
|
int |
size()
Gives the number of currently opened Workspaces, just the total hold by
the model repository.
|
public void setCurrentModel(String documentWSId) throws InvalidIDException
documentWSId
- the id of the Document Workspace to be set as current.InvalidIDException
- if the model id doesn't existspublic void setCurrentDocWorkspace(String documentWSId) throws InvalidIDException
documentWSId
- the id of the Document Workspace to be set as current.InvalidIDException
- if the model id doesn't existspublic void changeCurrentDocWorkspace(String documentWSId) throws InvalidIDException
Sets the current selected document workspace. This change is effective only if parallel property is not set.
In the situation where the Mode Repository is in the parallel mode, there is no central notion of current document workspace, except when retrieved by the current thread, provided its associated workspace was created using the thread id.
documentWSId
- the id of the Document Workspace to be set as the current one.InvalidIDException
- if the model id doesn't existssetParallelWorkspaces(boolean)
,
getCurrentDocWSId()
public String getCurrentModelId()
public String getCurrentDocWSId()
If you set the model repository in parallel mode, you should have
created the workspace with your thread id, so that this method makes a
best effort in retrieving the workspace associated to the current thread id.
Otherwise null
will be returned.
null
if none
is active, or the ModelRepository is in parallel mode, and no workspace has been created
using the current thread id.public static ModelRepository getInstance()
new ModelRepository
. It is thread-safe.public String createModelWorkspace(String modelId) throws InvalidIDException
modelId
- the model IdInvalidIDException
- if the id is already usedpublic String createDocumentWorkspace(String docWorkspaceId) throws InvalidIDException
Creates a new model workspace into the repository, with no PetriNetDoc
associated (as HLAPIRootClass
). This workspace becomes the
current one, if parallel property is not set.
If you set the parallel property to true, you should create each document workspace using your thread id, to facilitate later a best effort retrieval of the workspace of that thread by the Model Repository.
docWorkspaceId
- the model IdInvalidIDException
- if the id is already usedgetCurrentDocWSId()
public String createModelWorkspace(String modelId, HLAPIRootClass petriNetDoc) throws InvalidIDException
createModelWorkspace(String, HLAPIRootClass)
insteadmodelId
- the model IdpetriNetDoc
- the petriNetdoc object, root of the registered model.InvalidIDException
- if the id is already usedpublic String createDocumentWorkspace(String docWorkspaceId, HLAPIRootClass petriNetDoc) throws InvalidIDException
Creates a new model workspace into the repository, with a PetriNetDoc
associated, as HLAPIRootClass
. This model (and its workspace)
becomes the current active one in the model repository, if parallel
property is not set.
If you set the parallel property to true, you should create each document workspace using your thread id, to facilitate a best effort retrieval of the workspace of that thread by the Model Repository.
docWorkspaceId
- an id to give to this document workspacepetriNetDoc
- the petriNetdoc object, root of the registered model.InvalidIDException
- if the id is already usedchangeCurrentDocWorkspace(String)
,
getCurrentDocWSId()
public void createDocumentWorkspace(String docWorkspaceId, org.eclipse.emf.ecore.EObject petriNetDoc) throws InvalidIDException
Same as createModelWorkspace(String, HLAPIRootClass)
, but this
time with the root PetriNetDoc object typed as an EObject (EMF).
If you set the parallel property to true, you should create each document workspace using your thread id, to facilitate a best effort retrieval of the workspace of that thread by the Model Repository.
docWorkspaceId
- petriNetDoc
- InvalidIDException
#getCurrentDocWSId()}
public int destroyCurrentModelWorkspace() throws VoidRepositoryException
VoidRepositoryException
- if the repository is voidpublic int destroyCurrentWorkspace() throws VoidRepositoryException
Destroys the current model workspace data about a registered model, the
current workspace ID becomes null
. This change is immediately effective only if
parallel property is not set.
If parallel property is set, this method will try to find your current workspace using your current thread id, and then remove it from the repository of workspaces. Nothing will happen otherwise. This means it could not find any workspace previously created using your current thread id.
VoidRepositoryException
- if the repository is voidreset()
,
areWorkspacesParallel()
,
getCurrentDocWSId()
public IdRepository getCurrentIdRepository() throws VoidRepositoryException
IdRepository
associated to the current workspace.
If the Model Repository in parallel model, will try to retrieve the Id Rpository using the current thread id to first find the corresponding workspace, then fetch the associated Id Repository
VoidRepositoryException
- if the repository is emptyIdRepository
public HLAPIRootClass getCurrentHLAPIRootClass() throws VoidRepositoryException
null
is all
workspaces are active simultaneously (i.e. parallel property is set), or
there is no workspace at all.VoidRepositoryException
- if the repository is voidHLAPIRootClass
,
areWorkspacesParallel()
public org.eclipse.emf.ecore.EObject getCurrentEObjectRootClass() throws VoidRepositoryException
null
is all
workspaces are active simultaneously (i.e. parallel property is set), or
there is no workspace at all.VoidRepositoryException
- if the repository is voidgetCurrentHLAPIRootClass()
,
areWorkspacesParallel()
public void setCurrentHLAPIRootClass(HLAPIRootClass hrc) throws VoidRepositoryException
Sets the provided PetriNet Document (PetriNetDocHLAPI of a PN Type) as HLAPIRootClass associated to the current active workspace. If the current active workspace already holds a reference to an existing PetriNet Document, that existing reference is replaced by the provided new one.
This change is effective is parallel property is not set, or there is no current active workspace. In the latter case, a new workspace with a random-generated id is automatically created for you and the PetriNet Document associated to it. That newly created workspace becomes the current one.
So when you are using this API, make sure you have not set parallel property to true before this invocation.
hrc
- : the root classVoidRepositoryException
- if the repository is void or there is no model repository
unit associated to the current active workspace.HLAPIRootClass
,
areWorkspacesParallel()
public void setCurrentEObjectRootClass(org.eclipse.emf.ecore.EObject rc) throws VoidRepositoryException
Sets the root class (PetriNetDoc of a PN Type) as an EMF's Eobject, associated to the current workspace.
This change is effective is parallel property is not set, or there is no current active workspace. In the latter case, a new workspace with a random-generated id is automatically created for you and the model associated to. That new workspace becomes the current one.
So when you are using this API, make sure you have not set parallel property before this invocation.
rc
- : the root classVoidRepositoryException
- if the repository is void or there is no model repository
unit associated to the current active workspace.setCurrentHLAPIRootClass(HLAPIRootClass)
,
areWorkspacesParallel()
public Set<String> getRegisteredModelsId()
public void setPrettyPrintStatus(boolean status)
status
- a boolean.public boolean isPrettyPrintActive()
public PrettyPrintData getPrettyPrintData()
public void setParallelWorkspaces(boolean mode)
Sets if the model repository should hold all workspaces as being active in parallel. In the positive case, there is no more the notion of current active workspace.
Consequently, any subsequent call to workspace-specific method will not be
effective. getCurrentDocWSId()
will look for the current workspace based
on the current thead id, and return that workspace if any, null
otherwise.
mode
- getCurrentDocWSId()
public boolean areWorkspacesParallel()
Returns whether all workspaces are set to be simultaneously active by default (true), or if just one workspace is active at a time (false).
Default behavior is false, if you have not set this property previously.
public int size()
public void reset()
Copyright © 2009–2016 Univ. Paris Ouest, and Univ. Pierre et Marie Curie / CNRS UMR 7606 (LIP6). All rights reserved.