Interface TemplateManager
-
public interface TemplateManager
This sub-interface of the process manager handles all runtime issues of process templates. It allows to store process templates, retrieve specific process templates and manages the status of templates, for instance, outdate a template or disallow instantiation.
Template status objects use a simple lock mechanism when manipulated. They are locked when retrieved for changing and unlocked when the changes are committed. If a template status object is locked when accessed or unlocked although the commit is called, aLockException
will be thrown.
If the designated template ID on any method expecting one does not exist, anIllegalArgumentException
will be thrown.Methods not throwing a
LockException
do not synchronise that is the retrieved data may be slightly out of date.Implementors of this interface should take special care of synchronising template locks with instance locks. When locking a template status, instances should neither be created nor changed on the corresponding template since the template status change may allow/disallow this in the future.
The template manager needs to handle embedded templates appropriately. This means they need to be stored separately just like referenced templates, they need to be retrieved separately. Additionally, since an embedded template has no status of its own, a request for the status of an embedded template is replied with the status of the corresponding parent template.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TemplateManager.TemplateKind
A template can be of different kind: normal (top-level or referenced subprocess), embedded (as subprocess), specific for one instance (modified template), an embedded template that is specific to one instance (but itself unmodified) or an embedded and modified template.
-
Field Summary
Fields Modifier and Type Field Description static String
SUCCESSFULLY_STORED
The (prefix for the) check report message for the entry that all templates have been successfully stored.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SerialisablePair<Collection<UUID>,Map<UUID,UUID>>
archiveTemplate(SessionToken session, UUID templateID)
Archives the designated template, which removes: the template itself, modified templates based on this template, its embedded templates, all corresponding template statuses, all of its instances (including the ones from the modified and embedded templates based on the designated template, all corresponding instance statuses, This alsoarchives all corresponding instances
.Set<TemplateReference>
findTemplates(SessionToken session, Filter templateFilter, Filter templateStatusFilter)
Finds all templates (except embedded and instance-specific ones) matching the two filters onTemplate
andTemplateStatus
and returns their template references.RemoteIterator<List<TemplateReference>>
findTemplatesIterator(SessionToken session, Filter templateFilter, Filter templateStatusFilter)
The same asfindTemplates(SessionToken, Filter, Filter)
but with partial retrieval of the template references.Set<UUID>
getAllTemplateIDs(SessionToken session)
Gets the IDs of all process templates managed by this process manager except IDs of separated embedded process templates and instance-specific templates.Set<UUID>
getAllTemplateIDs(SessionToken session, TemplateManager.TemplateKind kind)
Gets the IDs of all process templates managed by this process manager of the designated kind.RemoteIterator<List<UUID>>
getAllTemplateIDsIterator(SessionToken session)
The same asgetAllTemplateIDs(SessionToken)
but with partial retrieval of the template IDs.RemoteIterator<List<UUID>>
getAllTemplateIDsIterator(SessionToken session, TemplateManager.TemplateKind kind)
The same asgetAllTemplateIDs(SessionToken, TemplateKind)
but with partial retrieval of the template IDs.Set<TemplateReference>
getAllTemplateReferences(SessionToken session)
Gets the lightweight representations of all process templates managed by this process manager except the ones for embedded and instance-specific process templates.RemoteIterator<List<TemplateReference>>
getAllTemplateReferencesIterator(SessionToken session)
The same asgetAllTemplateReferences(SessionToken)
but with partial retrieval of the template references.TemplateStatus
getAndLockTemplateStatus(SessionToken session, UUID templateID)
Gets an object containing the status of the designated process template and locks the template for further manipulation, for instance, another status change, a schema-evolution or a new instantiation.Template
getTemplate(SessionToken session, UUID templateID)
Gets the designated process template conforming to the ADEPT2-process model.TemplateManager.TemplateKind
getTemplateKind(SessionToken session, UUID templateID)
Gets the kind of the template with the designated ID, that is whether the template is embedded and/or instance-specific.TemplateReference
getTemplateReference(SessionToken session, UUID templateID)
Gets the lightweight representation of the designated process template.TemplateStatus
getTemplateStatus(SessionToken session, UUID templateID)
Gets an object containing the status of the designated process template, that is, whether the template is outdated, may be derived, may be instantiated, whether instances may be migrated to the process template and whether instances are changeable.TemplateNode
getTemplateTree(SessionToken session, TemplateReference root)
Gets a template (sub-)tree of the designatedTemplate
.Map<UUID,TemplateNode>
getTemplateTrees(SessionToken session, String procType)
Gets trees for allTemplate
s belonging to the designated process type.void
setTemplateStatus(SessionToken session, TemplateStatus templateStatus)
Sets the status of the template (identified by the template status object), to the new status.CheckReport
storeNewTemplate(SessionToken session, Template template, TemplateStatus templateStatus, Locale... locales)
Stores the designated template and the corresponding status object in the process manager.CheckReport
storeNewTemplates(SessionToken session, Template[] templates, TemplateStatus[] templateStatuses, Locale... locales)
Stores the designated templates and the corresponding status objects in the process manager.void
unlockTemplateStatus(SessionToken session, UUID templateID)
Unlocks the status of the designated template, ignores made changes and and releases the lock on the process template status.
-
-
-
Field Detail
-
SUCCESSFULLY_STORED
static final String SUCCESSFULLY_STORED
The (prefix for the) check report message for the entry that all templates have been successfully stored. This allows to have check reports withCheckReport.ResultType.WARNING
as final result type yet storing the templates succeeded since the warning does not prevent instantiating and running these templates.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTemplate
Template getTemplate(SessionToken session, UUID templateID)
Gets the designated process template conforming to the ADEPT2-process model. The returned template can not be changed.
This method also returns embedded templates as stand-alone.- Parameters:
session
- The session which is used to check for access rights on this method.templateID
- The ID of the process template to retrieve.- Returns:
- An object representing the designated process template.
-
getTemplateReference
TemplateReference getTemplateReference(SessionToken session, UUID templateID)
Gets the lightweight representation of the designated process template. This method also returns lightweight representations of embedded templates.- Parameters:
session
- The session which is used to check for access rights on this method.templateID
- The ID of the process template to retrieve the lightweight representation of.- Returns:
- The lightweight representation of the designated process template.
-
getTemplateKind
TemplateManager.TemplateKind getTemplateKind(SessionToken session, UUID templateID)
Gets the kind of the template with the designated ID, that is whether the template is embedded and/or instance-specific.- Parameters:
session
- The session which is used to check for access rights on this method and to identify the unlocking agent and the corresponding organisational position.templateID
- The ID of the template to get the kind of.- Returns:
- The kind of the designated template, that is, normal, embedded, instance-specific for embedded instance-specific.
-
getAllTemplateReferences
Set<TemplateReference> getAllTemplateReferences(SessionToken session)
Gets the lightweight representations of all process templates managed by this process manager except the ones for embedded and instance-specific process templates.- Parameters:
session
- The session which is used to check for access rights on this method.- Returns:
- The lightweight representations of all (top-level) process templates managed by this process manager.
-
getAllTemplateReferencesIterator
RemoteIterator<List<TemplateReference>> getAllTemplateReferencesIterator(SessionToken session)
The same asgetAllTemplateReferences(SessionToken)
but with partial retrieval of the template references.- Parameters:
session
- The session which is used to check for access rights on this method.- Returns:
- The lightweight representations of all (top-level) process templates managed by this process manager as iterator. The caller is responsible for closing.
-
getAllTemplateIDs
Set<UUID> getAllTemplateIDs(SessionToken session)
Gets the IDs of all process templates managed by this process manager except IDs of separated embedded process templates and instance-specific templates.- Parameters:
session
- The session which is used to check for access rights on this method.- Returns:
- The IDs of all (top-level) process templates managed by this process manager.
-
getAllTemplateIDs
Set<UUID> getAllTemplateIDs(SessionToken session, TemplateManager.TemplateKind kind)
Gets the IDs of all process templates managed by this process manager of the designated kind.- Parameters:
session
- The session which is used to check for access rights on this method.kind
- The kind of templates to retrieve the IDs of.- Returns:
- The IDs of all process templates managed by this process manager of the designated kind.
-
getAllTemplateIDsIterator
RemoteIterator<List<UUID>> getAllTemplateIDsIterator(SessionToken session)
The same asgetAllTemplateIDs(SessionToken)
but with partial retrieval of the template IDs.- Parameters:
session
- The session which is used to check for access rights on this method.- Returns:
- The IDs of all (top-level) process templates managed by this process manager as iterator. The caller is responsible for closing.
-
getAllTemplateIDsIterator
RemoteIterator<List<UUID>> getAllTemplateIDsIterator(SessionToken session, TemplateManager.TemplateKind kind)
The same asgetAllTemplateIDs(SessionToken, TemplateKind)
but with partial retrieval of the template IDs.- Parameters:
session
- The session which is used to check for access rights on this method.kind
- The kind of templates to retrieve the IDs of.- Returns:
- The IDs of all process templates managed by this process manager of the designated kind as iterator. The caller is responsible for closing.
-
findTemplates
Set<TemplateReference> findTemplates(SessionToken session, Filter templateFilter, Filter templateStatusFilter)
Finds all templates (except embedded and instance-specific ones) matching the two filters onTemplate
andTemplateStatus
and returns their template references.- Parameters:
session
- The session which is used to check for access rights on this method.templateFilter
- the filter on the theTemplate
s (optional)templateStatusFilter
- the filter on the template's status (optional)- Returns:
- a set of
TemplateReference
s that match the filters
-
findTemplatesIterator
RemoteIterator<List<TemplateReference>> findTemplatesIterator(SessionToken session, Filter templateFilter, Filter templateStatusFilter)
The same asfindTemplates(SessionToken, Filter, Filter)
but with partial retrieval of the template references.- Parameters:
session
- The session which is used to check for access rights on this method.templateFilter
- the filter on the theTemplate
s (optional)templateStatusFilter
- the filter on the template's status (optional)- Returns:
- A set of
TemplateReference
s that match the filters as iterator. The caller is responsible for closing.
-
storeNewTemplate
CheckReport storeNewTemplate(SessionToken session, Template template, TemplateStatus templateStatus, Locale... locales)
Stores the designated template and the corresponding status object in the process manager. It is checked whether the template already exists. If it does, it will not be stored again.
A check report will be provided. Please refer to it for determining whether the storage was successful (CheckReport.getCheckResult()
is notCheckReport.ResultType.FAILURE
and the message of the last report entry starts withSUCCESSFULLY_STORED
).- Parameters:
session
- The session which is used to check for access rights on this method.template
- The representation of a process template conforming to the ADEPT2-process model.templateStatus
- The status object for the designated template.locales
- The locales the check report should provide (or at least a fallback of each). If this isnull
,Locale.ROOT
will be used.- Returns:
- A check report containing the result of the checks. Please refer to it for determining
whether the storage was successful (
CheckReport.getCheckResult()
is notCheckReport.ResultType.FAILURE
and the message of the last report entry starts withSUCCESSFULLY_STORED
).
-
storeNewTemplates
CheckReport storeNewTemplates(SessionToken session, Template[] templates, TemplateStatus[] templateStatuses, Locale... locales)
Stores the designated templates and the corresponding status objects in the process manager. Every template is checked whether it already exists. If it does, it will not be stored again.
To allow for process template hierarchies, this method accepts multiple templates. Be sure to store dependent templates after storing the template they depend on (from subprocess to top-level-process).
A check report will be provided. Please refer to it for determining whether the storage was successful (CheckReport.getCheckResult()
is notCheckReport.ResultType.FAILURE
and the message of the last report entry starts withSUCCESSFULLY_STORED
).- Parameters:
session
- The session which is used to check for access rights on this method.templates
- The representations of process templates conforming to the ADEPT2-process model. Process hierarchies have to be ordered so that the top-level-process template is at the end.templateStatuses
- The status objects corresponding to the templates at the same index in the array.locales
- The locales the check report should provide (or at least a fallback of each). If this isnull
,Locale.ROOT
will be used.- Returns:
- A check report containing the result of the checks. Please refer to it for determining
whether the storage was successful (
CheckReport.getCheckResult()
is notCheckReport.ResultType.FAILURE
and the message of the last report entry starts withSUCCESSFULLY_STORED
).
-
getTemplateStatus
TemplateStatus getTemplateStatus(SessionToken session, UUID templateID)
Gets an object containing the status of the designated process template, that is, whether the template is outdated, may be derived, may be instantiated, whether instances may be migrated to the process template and whether instances are changeable. The returnedTemplateStatus
-object does not allow to change the status (set-methods and release). For changing the status, the corresponding template has to be locked.- Parameters:
session
- The session which is used to check for access rights on this method.templateID
- The ID of the template to get the status of.- Returns:
- An object containing the status of the designated process template.
- See Also:
getAndLockTemplateStatus(SessionToken, UUID)
-
getAndLockTemplateStatus
TemplateStatus getAndLockTemplateStatus(SessionToken session, UUID templateID) throws LockException
Gets an object containing the status of the designated process template and locks the template for further manipulation, for instance, another status change, a schema-evolution or a new instantiation. The returned object allows to change whether the template is outdated, may be derived, may be instantiated, whether instances may be migrated to and whether instances are changeable. The template is locked by the designated user.
Neither a process template nor its status may be retrieved when it has been locked, except by the user who locked it (reentrant lock).- Parameters:
session
- The session which is used to check for access rights on this method and to identify the locking agent and the corresponding organisational position.templateID
- The ID of the template to get and manipulate the status of.- Returns:
- An object containing the status of the designated process template.
- Throws:
LockException
- If the corresponding status object is subject to change and therefore already locked (except by the designated user), aLockException
will be thrown.
-
setTemplateStatus
void setTemplateStatus(SessionToken session, TemplateStatus templateStatus) throws LockException, InvalidTemplateStateException
Sets the status of the template (identified by the template status object), to the new status. The caller needs to have the lock on the template status.- Parameters:
session
- The session which is used to check for access rights on this method and to identify the setting agent and the corresponding organisational position.templateStatus
- The object containing the new status of the process template.- Throws:
LockException
- If the corresponding status object is not locked by the designated user, aLockException
will be thrown.InvalidTemplateStateException
- If the template of the designated status cannot be changed accordingly (set to outdated or not usable as referenced subprocess any more) since it is currently used as reference subprocess, aTemplateStateException
will be thrown.
-
unlockTemplateStatus
void unlockTemplateStatus(SessionToken session, UUID templateID) throws LockException
Unlocks the status of the designated template, ignores made changes and and releases the lock on the process template status. Unlocking will fail, if the designated user does not have the lock on the template status.- Parameters:
session
- The session which is used to check for access rights on this method and to identify the unlocking agent and the corresponding organisational position.templateID
- The ID of the template to unlock the status of.- Throws:
LockException
- If the corresponding status object is not locked by the designated user, aLockException
will be thrown.
-
archiveTemplate
SerialisablePair<Collection<UUID>,Map<UUID,UUID>> archiveTemplate(SessionToken session, UUID templateID) throws InvalidTemplateStateException, InvalidInstanceStateException, LockException, DataConsistencyException
Archives the designated template, which removes:- the template itself,
- modified templates based on this template,
- its embedded templates,
- all corresponding template statuses,
- all of its instances (including the ones from the modified and embedded templates based on the designated template,
- all corresponding instance statuses,
archives all corresponding instances
. For this to work, none of the templates, template statuses and instances (as well as their status) may be locked. Additionally, all templates may not be instantiable and they need to be outdated for top-level as well as subprocess usage (TemplateStatus.isInstantiable(boolean)
andTemplateStatus.isOutdated(boolean)
), all of their instances have to beIE_FINISHED
orIE_ABORTED
. The designated template must neither be an embedded one nor a modified one. The latter can be archived by archiving the corresponding instance.Use this method carefully! Archiving one template will also archive a lot of dependent data. When archiving distributed template hierarchies (parent or child templates are handled by different template managers), one has to take care of the consistency manually.
- Parameters:
session
- The session which is used to check for access rights on this method.templateID
- The ID of the template which to remove from this template manager.- Returns:
- The IDs of all archived templates (first element of the pair) and a map of all archived instances (second element of the pair. The instances provide the logical ID (key) and the log ID (value). The template IDs will contain normal and embedded templates but no IDs of modified templates.
- Throws:
InvalidTemplateStateException
- If one of the templates to be removed is instantiable or not outdated for top-level or subprocess usage, anInvalidTemplateStateException
will be thrown.InvalidInstanceStateException
- If one of the instances of the designated template is notIE_FINISHED
orIE_ABORTED
, anInvalidInstanceStateException
will be thrown.LockException
- If the designated template can not be removed since a lock is held on either the template, its status, or one of its instances or instance status, aLockException
will be thrown.DataConsistencyException
- If removing the template leads to inconsistencies, that is, the prerequisites (other than the template status) are not fulfilled, aDataConsistencyException
will be thrown.
-
getTemplateTrees
Map<UUID,TemplateNode> getTemplateTrees(SessionToken session, String procType)
Gets trees for allTemplate
s belonging to the designated process type. The map contains the roots of the template trees indexed by the root template IDs.- Parameters:
session
- The session which is used to check for access rights on this method.procType
- The name of the process type for which to create the template trees.- Returns:
- The roots of the template trees indexed by the corresponding root template ID.
-
getTemplateTree
TemplateNode getTemplateTree(SessionToken session, TemplateReference root)
Gets a template (sub-)tree of the designatedTemplate
.- Parameters:
session
- The session which is used to check for access rights on this method.root
- The template for which to create a template (sub-)tree.- Returns:
- The template node of the designated template.
-
-