Class ProcessModelTools
- java.lang.Object
-
- de.aristaflow.adept2.model.processmodel.tools.ProcessModelTools
-
public class ProcessModelTools extends Object
Helper methods which are based on the interfaces of the process model.
-
-
Constructor Summary
Constructors Constructor Description ProcessModelTools()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Instance
cloneInstance(Instance instance, ProcessModelFactory factory)
Clones a given instance using the given process model factory.static InstanceStatus
cloneInstanceStatus(InstanceStatus status, ProcessModelFactory factory)
Clones an instance status object using the designated factory.static Node
cloneNode(Node node, ProcessModelFactory pmf)
Clones the designated node using the designated factory.static ProcessModelParameter
cloneProcessModelParameter(ProcessModelParameter param, ProcessModelFactory pmf)
Clones the designated parameter using the designated factory.static Template
cloneTemplate(Template template, ProcessModelFactory factory)
Clones a given template using the given process model factory.static TemplateStatus
cloneTemplateStatus(TemplateStatus status, ProcessModelFactory factory)
Clones a template status object using the given factory.protected static Set<Integer>
findNodes(int first, int last, boolean includeBlocks, Template template)
Find all nodes between start and end using the topological sortingprotected static Set<Integer>
findNodesRecursive(int startID, int endID, Template template)
Recursively find all nodes between the start node and the end node, and return their IDs.protected static Set<Integer>
findNodesSlow(int first, int last, boolean includeBlocks, Template template)
Find nodes the hard way, without relying on the topological sortingstatic int
getBranchEndNode(Template template, int splitNodeID, int branchID)
Returns the ID of the last node in the branch (given by its branchID), beginning after splitNode.static int
getCommonSplitNode(Template template, int node1ID, int node2ID)
Returns the split node that both nodes have in common.static Pair<String,ProcessModelParameter>
getConnNameParameter(int connectorId, Node node, ActivityConstants.AccessType accessType)
Gets the parameter name for the designated connector ID and the corresponding process model parameter either from the designated node or its assigned EBP depending on the access type.static Set<Integer>
getDataElementIDsByName(Template template, Set<String> names)
Returns the IDs of the data elements given by their names.static Pair<Set<UUID>,Set<UUID>>
getDirectChildTemplateIDsFromDeltaLayer(Template current, Template originalTemplate, boolean embeddedOnly)
For a given instance specific template and its base template, this method will calculate the child templates that only occur in the base template or the instance specific template.static Map<UUID,Collection<Integer>>
getDirectChildTemplateNodes(Template parent, boolean embeddedOnly)
Gets a map with all child templates (direct children only) of the designated parent template mapped to the corresponding node ID in the parent template.static Set<UUID>
getDirectChildTemplates(Template parent, boolean embeddedOnly)
Deprecated.UsegetDirectChildTemplateNodes(Template, boolean)
instead.static EBPType
getEBPType(ExecutableBusinessProcess ebp)
Helper method to get the ebpType of an EBP.static List<Node>
getEmbdTmplNodesFromDeltaLayer(Template current, Template originalTemplate)
Gets a list of all nodes of the designated template having embedded templates are not also direct embedded children of the designated original template.static int[]
getNodesInArea(int first, int last, boolean includeBlocks, Template t, boolean inTransaction)
Find all nodes in an area.static ProcessModelParameter
getProcessModelParameter(int connectorId, Node node, ActivityConstants.AccessType accessType)
Gets the process model parameter for the designated connector ID either from the designated node or its assigned EBP depending on the access type.static ProcessModelParameter
getProcessModelParameter(String name, Node node, ActivityConstants.AccessType accessType)
Gets the process model parameter with the designated name either from the designated node or its assigned EBP depending on the access type.static List<Integer>
getSplitNodes(Template template, int nodeID)
Trace the path from the given node to the start node of the template, and record all split nodes along the way.static String
getSysReadParamNameFor(Node node, DataElement de, Template templ)
Gets the name for a system parameter reading (ActivityConstants.AccessType.SYSTEM_READ
the designated data element at the designated node in the designated template.static Map<Integer,String>
getWrittenDataElements(Template template, int nodeID)
Gets the IDs and the names of the data elements that are written by the designated node.static DataElement
hasDataEdge(Template templ, Node node, Parameter param, ActivityConstants.AccessType at)
Gets the data element with a data edge from designated node for the designated parameter of the designated access type.static int[]
intArrayDataElement(Set<DataElement> set)
Build integer array containing DataElement IDs for all DataElements in the Setstatic int[]
intArrayNode(Set<Node> set)
Build an int array containing the IDs of all nodes in the setstatic List<Integer>
intArrayToInteger(int[] intArray)
Converts an int array to an Integer list.static int[]
integerToIntArray(Collection<Integer> integerArray)
converts an Integer Collection to an int array.static boolean
isDecisionDataElement(Template template, int dataElementID)
Returns true, if the given data element is a decision data element, ie.static boolean
isInParallelBranch(Template template, int nodeID)
Gets whether the designated node is in a parallel branch (with respect to the designated template).static boolean
isNullNode(ProcessConstants.NodeType type)
Returns true, if the node of the given type is a null node, i.e.static boolean
isSystemDataElement(Template template, int dataElementID)
Returns true, if the data element with the given ID is a system data element, ie. it has system data access and no non-system data access.static int[]
nodesWithSyncEdgesInArea(Template template, int firstID, int lastID, boolean includingInnerSyncEdges)
Returns those nodes which are between first and last (including) and which do have sync-edges.static TemplateStatus
updateTemplateStatus(TemplateStatus status, ProcessConstants.TemplateBuildtimeState buildtimeState, ProcessModelFactory pmf)
Since the template status interface is missing a setter for the build time state, this method clones the status while changing the build time state.
-
-
-
Method Detail
-
nodesWithSyncEdgesInArea
public static int[] nodesWithSyncEdgesInArea(Template template, int firstID, int lastID, boolean includingInnerSyncEdges)
Returns those nodes which are between first and last (including) and which do have sync-edges.- Parameters:
template
- the template where the method is performed on.firstID
- the node who specifies the beginning of the arealastID
- the last node of the areaincludingInnerSyncEdges
- true if inner sync edges (i.e. sync-edges which do have source and dest between first and last) should be returned- Returns:
- the nodes which do have in- and/or outgoing sync-edges
-
intArrayNode
public static int[] intArrayNode(Set<Node> set)
Build an int array containing the IDs of all nodes in the set- Parameters:
set
- Set containing nodes- Returns:
- an array containing the node IDs
-
getSplitNodes
public static List<Integer> getSplitNodes(Template template, int nodeID)
Trace the path from the given node to the start node of the template, and record all split nodes along the way. Returned is a list containing the IDs of given node, all NT_AND_SPLIT / NT_XOR_SPLIT nodes between the node and the beginning of the graph, and finally the NT_STARTFLOW node itself.
I.e.: (nodeID, splitnode(nodeID),splitnode(splitnode(nodeID), ..., startflow)
Use this method if the order of the split nodes is important.
Complexity: - memory: O(max_branch_depth) - comparisons: " - assignments: " - visited-nodes: " Efficiency of LinkedList.add?- Parameters:
template
- the template that contains the nodenodeID
- the node to examine- Returns:
- the path from the node to the start
-
getCommonSplitNode
public static int getCommonSplitNode(Template template, int node1ID, int node2ID)
Returns the split node that both nodes have in common.- Parameters:
template
- the template that contains the nodesnode1ID
-node2ID
-- Returns:
- the ID of the (first) split node shared by both nodes
-
getBranchEndNode
public static int getBranchEndNode(Template template, int splitNodeID, int branchID)
Returns the ID of the last node in the branch (given by its branchID), beginning after splitNode.- Parameters:
template
-splitNodeID
- The split node of the branch.branchID
- The ID of the branch, whose end node will be returned.- Returns:
- The ID of the last node in the branch
- Throws:
IllegalArgumentException
- ifbranchID
is not one of the branches leavingsplitNode
-
getNodesInArea
public static int[] getNodesInArea(int first, int last, boolean includeBlocks, Template t, boolean inTransaction)
Find all nodes in an area.
Note: This function is not very implementation specific and may be shared between implementations- Parameters:
first
- ID of the first (left-most) node of the arealast
- ID of the last (right-most) node of the areaincludeBlocks
- include nodes on a different brancht
- the Template that contains the nodesinTransaction
- in transactions the topological sorting may be wrong and can't be used- Returns:
- the IDs of all nodes in the area specified, excluding the first and last node
- See Also:
Template.getNodeIDsInArea(int, int, boolean)
-
findNodes
protected static Set<Integer> findNodes(int first, int last, boolean includeBlocks, Template template)
Find all nodes between start and end using the topological sorting- Parameters:
first
- ID of the first nodelast
- ID of the last nodeincludeBlocks
- if false, subblocks are excludedtemplate
- the template containing the nodes- Returns:
- all Nodes between first and last
-
findNodesSlow
protected static Set<Integer> findNodesSlow(int first, int last, boolean includeBlocks, Template template)
Find nodes the hard way, without relying on the topological sorting- Parameters:
first
- ID of the first nodelast
- ID of the last nodeincludeBlocks
- allow nodes on other branchestemplate
- the Template containing the nodes- Returns:
- a set of node IDs
-
findNodesRecursive
protected static Set<Integer> findNodesRecursive(int startID, int endID, Template template)
Recursively find all nodes between the start node and the end node, and return their IDs.- Parameters:
startID
- ID of the first nodeendID
- ID of the last nodetemplate
- the template containing the nodes- Returns:
- the modified resultSet
-
isInParallelBranch
public static boolean isInParallelBranch(Template template, int nodeID)
Gets whether the designated node is in a parallel branch (with respect to the designated template). All branches until the top-level branch may be examined.- Parameters:
template
- The template of which to examine the structure.nodeID
- The ID of the node which to check for whether it is in a parallel branch.- Returns:
- Whether the designated node is in one parallel branch of the designated template.
-
getWrittenDataElements
public static Map<Integer,String> getWrittenDataElements(Template template, int nodeID)
Gets the IDs and the names of the data elements that are written by the designated node.- Parameters:
template
- The template of which to retrieve data elements.nodeID
- The ID of the node of which to retrieve the written data elements.- Returns:
- The IDs and the names of the data elements written by the designated node.
-
getDataElementIDsByName
public static Set<Integer> getDataElementIDsByName(Template template, Set<String> names)
Returns the IDs of the data elements given by their names.- Parameters:
template
-names
-- Returns:
- The IDs of the data elements identified by their name.
-
getConnNameParameter
public static Pair<String,ProcessModelParameter> getConnNameParameter(int connectorId, Node node, ActivityConstants.AccessType accessType)
Gets the parameter name for the designated connector ID and the corresponding process model parameter either from the designated node or its assigned EBP depending on the access type.
Note that returning a (parameter name for the) connector without a parameter (second element) usually indicates a problem in the template.- Parameters:
connectorId
- The ID of the connector of the process model parameter which to retrieve.node
- The node of which to retrieve a system related parameter.accessType
- The access type of the parameter which to retrieve.- Returns:
- The parameter name and the process model parameter for the designated connector ID
either from the designated node or its assigned EBP depending on the access type. If no
such parameter exists, the second element will be
null
. If no such connector exists,Node.getParameterName
throws anIllegalArgumentException
. Actually this cannot happen otherwise something in the calling methods went really wrong and should be fixed there.
-
getProcessModelParameter
public static ProcessModelParameter getProcessModelParameter(int connectorId, Node node, ActivityConstants.AccessType accessType)
Gets the process model parameter for the designated connector ID either from the designated node or its assigned EBP depending on the access type.- Parameters:
connectorId
- The ID of the connector of the process model parameter which to retrieve.node
- The node of which to retrieve a system related parameter.accessType
- The access type of the parameter which to retrieve.- Returns:
- The process model parameter for the designated connector ID either from the designated
node or its assigned EBP depending on the access type. If no such parameter exists,
null
will be returned.
-
getProcessModelParameter
public static ProcessModelParameter getProcessModelParameter(String name, Node node, ActivityConstants.AccessType accessType)
Gets the process model parameter with the designated name either from the designated node or its assigned EBP depending on the access type.- Parameters:
name
- The name of the process model parameter which to retrieve.node
- The node of which to retrieve a system related parameter.accessType
- The access type of the parameter which to retrieve.- Returns:
- The process model parameter with the designated name either from the designated node or
its assigned EBP depending on the access type. If no such parameter exists,
null
will be returned.
-
getSysReadParamNameFor
public static String getSysReadParamNameFor(Node node, DataElement de, Template templ)
Gets the name for a system parameter reading (ActivityConstants.AccessType.SYSTEM_READ
the designated data element at the designated node in the designated template. This is either the name of an existing similar parameter or the name of the designated data element.- Parameters:
node
- The node which (system-)reads the designated data element.de
- The data element to (system-)read.templ
- The template containing the designated node and data element.- Returns:
- The name of an existing parameter system-reading the designated data element at the designated node or the name of the designated data element to be used as name for such a parameter.
-
hasDataEdge
public static DataElement hasDataEdge(Template templ, Node node, Parameter param, ActivityConstants.AccessType at)
Gets the data element with a data edge from designated node for the designated parameter of the designated access type.- Parameters:
templ
- The template which to check for the data edge.node
- The node which is source or target of the data edge.param
- The parameter which is source or target of the data edge within the node.at
- The access type of the data edge.- Returns:
- The data element that is target or source of the data edge if one exists,
null
otherwise.
-
integerToIntArray
public static int[] integerToIntArray(Collection<Integer> integerArray)
converts an Integer Collection to an int array.- Parameters:
integerArray
-- Returns:
- an array containing all integers from the collection
-
intArrayToInteger
public static List<Integer> intArrayToInteger(int[] intArray)
Converts an int array to an Integer list.- Parameters:
intArray
-- Returns:
- A list containing all integers from the array.
-
intArrayDataElement
public static int[] intArrayDataElement(Set<DataElement> set)
Build integer array containing DataElement IDs for all DataElements in the Set- Parameters:
set
-- Returns:
- Returns a List of ID's of all DataElements in the set
-
cloneTemplate
public static Template cloneTemplate(Template template, ProcessModelFactory factory)
Clones a given template using the given process model factory.This may be used for transforming a
Template
in aChangeableTemplate
. If a changeable or a non-changeable Template is created depends on the setting of the givenfactory
(ProcessModelFactory.setCreateChangeable(boolean)
).- Parameters:
template
- The template which will be cloned.factory
- The factory which will be used for the creation of the new objects.- Returns:
- A clone of the given template.
-
cloneInstance
public static Instance cloneInstance(Instance instance, ProcessModelFactory factory)
Clones a given instance using the given process model factory.- Parameters:
instance
- The instance which will be cloned.factory
- The factory which will be used for the creation of the new objects.- Returns:
- A clone of the given instance.
-
cloneTemplateStatus
public static TemplateStatus cloneTemplateStatus(TemplateStatus status, ProcessModelFactory factory)
Clones a template status object using the given factory.- Parameters:
status
-factory
-- Returns:
- A clone of the given template status object.
-
cloneNode
public static Node cloneNode(Node node, ProcessModelFactory pmf)
Clones the designated node using the designated factory.- Parameters:
node
- The node to clone.pmf
- The factory for creating the clone.- Returns:
- A clone of the designated node created by the designated factory.
-
cloneProcessModelParameter
public static ProcessModelParameter cloneProcessModelParameter(ProcessModelParameter param, ProcessModelFactory pmf)
Clones the designated parameter using the designated factory.- Parameters:
param
- The parameter to clone.pmf
- The factory for creating the clone.- Returns:
- A clone of the designated parameter created by the designated factory.
-
isNullNode
public static boolean isNullNode(ProcessConstants.NodeType type)
Returns true, if the node of the given type is a null node, i.e. it is a node which may have an EBP assigned.- Parameters:
type
- The type of the node.- Returns:
- True, if the node with the given type is a null node.
-
updateTemplateStatus
public static TemplateStatus updateTemplateStatus(TemplateStatus status, ProcessConstants.TemplateBuildtimeState buildtimeState, ProcessModelFactory pmf)
Since the template status interface is missing a setter for the build time state, this method clones the status while changing the build time state.- Parameters:
status
-buildtimeState
-pmf
- The process model factory for creating the status object.- Returns:
- An updated template status object.
-
isSystemDataElement
public static boolean isSystemDataElement(Template template, int dataElementID)
Returns true, if the data element with the given ID is a system data element, ie. it has system data access and no non-system data access.- Parameters:
template
- The process template.dataElementID
- The ID of the data element.- Returns:
- True, if the data element with the given ID is a system data element.
-
isDecisionDataElement
public static boolean isDecisionDataElement(Template template, int dataElementID)
Returns true, if the given data element is a decision data element, ie. it is written by node but not read by a node, and all of the writers are of type NT_XOR_SPLIT or NT_ENDLOOP.- Parameters:
template
- The process template.dataElementID
- The ID of the data element.- Returns:
- True, if the data element with the given ID is a decision data element.
-
getDirectChildTemplates
@Deprecated public static Set<UUID> getDirectChildTemplates(Template parent, boolean embeddedOnly)
Deprecated.UsegetDirectChildTemplateNodes(Template, boolean)
instead.Gets a set of all child templates (direct children only) of the designated parent template which may be restricted to embedded child templates. For embedded templates, their internal ID (EmbeddedProcess.getTemplateID()
) will be returned.- Parameters:
parent
- The template from which to retrieve the IDs of the direct child templates (all or only the embedded ones).embeddedOnly
- Whether the returned child templates should only contain embedded templates.- Returns:
- A set of the UUIDs of the child templates (direct children only) of the designated template (may be restricted to embedded child templates).
-
getDirectChildTemplateNodes
public static Map<UUID,Collection<Integer>> getDirectChildTemplateNodes(Template parent, boolean embeddedOnly)
Gets a map with all child templates (direct children only) of the designated parent template mapped to the corresponding node ID in the parent template. This may be restricted to embedded child templates. For embedded templates, their internal ID (EmbeddedProcess.getTemplateID()
) will be returned. The template may be referenced at several nodes in the parent template. Therefore the returned mapping contains a list of node IDs.- Parameters:
parent
- The template from which to retrieve the IDs of the direct child templates (all or only the embedded ones).embeddedOnly
- Whether the returned child templates should only contain embedded templates.- Returns:
- The UUIDs of the child templates (direct children only) of the designated template (may be restricted to embedded child templates) mapped to the ID(s) of the corresponding node(s) referring to this child template in the designated parent template.
-
getEmbdTmplNodesFromDeltaLayer
public static List<Node> getEmbdTmplNodesFromDeltaLayer(Template current, Template originalTemplate)
Gets a list of all nodes of the designated template having embedded templates are not also direct embedded children of the designated original template.
Note that the ID of an embedded template (EmbeddedProcess.getTemplateID()
) need not be set in the current template and may benull
. In this case the template is expected to be new and therefore the corresponding node will be in the result.- Parameters:
current
- The instance-specific template from which to retrieve the nodes having embedded templates which are not also children of the designated original template.originalTemplate
- The original template of the designated template to detect the direct embedded children which are not instance-specific. Note that it is not checked whether this template really is the original template of the provided template.- Returns:
- A list of nodes of the designated template having embedded templates which are not also children of the designated original template.
-
getDirectChildTemplateIDsFromDeltaLayer
public static Pair<Set<UUID>,Set<UUID>> getDirectChildTemplateIDsFromDeltaLayer(Template current, Template originalTemplate, boolean embeddedOnly)
For a given instance specific template and its base template, this method will calculate the child templates that only occur in the base template or the instance specific template.The first set of the returned pair is a set of all child template IDs (direct children only, including embedded) of the base template which are not also children of the instance specific template.
The second set of the returned pair is a set of all child template IDs (direct children only, including embedded) of the instance specific template which are not also children of the base template.
The IDs may be restricted to the ones of embedded child templates.
Note that unlikegetEmbdTmplNodesFromDeltaLayer(Template, Template)
the internal IDs of the embedded templates (EmbeddedProcess.getTemplateID()
) needs to be set for all embedded templates.- Parameters:
current
- The instance-specific template from which to retrieve the IDs of all direct child templates which are not also children of the designated original template.originalTemplate
- The original template of the designated template to detect the children which are not instance-specific. Note that it is not checked whether this template really is the original template of the provided template.embeddedOnly
- Whether the returned child template IDs should only contain embedded template IDs.- Returns:
- A pair of sets of UUIDs, with the first set containing the child templates unique to the base template, the second one containing the child templates unique to the instance specific template.
-
getEBPType
public static EBPType getEBPType(ExecutableBusinessProcess ebp)
Helper method to get the ebpType of an EBP.- Parameters:
ebp
- The EBP the type is needed from.- Returns:
- The type of the EBP or
EBPType.NULL
, if the EBP is null.
-
cloneInstanceStatus
public static InstanceStatus cloneInstanceStatus(InstanceStatus status, ProcessModelFactory factory)
Clones an instance status object using the designated factory.- Parameters:
status
- The instance status to be cloned.factory
- The process model factory for creating the new instance status.- Returns:
- A clone of the designated instance status object.
-
-