Skip to content

Commit

Permalink
Another round of workflow schema improvements/additions (work item op…
Browse files Browse the repository at this point in the history
…eration cause, escalation level info).
  • Loading branch information
mederly committed Feb 6, 2017
1 parent 167fccd commit eab3fef
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 30 deletions.
Expand Up @@ -21,6 +21,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -128,15 +129,16 @@ public static ItemApprovalWorkItemPartType getItemApprovalWorkItemInfo(WorkItemT
(ItemApprovalWorkItemPartType) workItem.getProcessSpecificPart() : null;
}

public static SchemaAttachedPolicyRuleType getAttachedPolicyRule(WfContextType workflowContext, int order) {
@NotNull
public static List<SchemaAttachedPolicyRuleType> getAttachedPolicyRules(WfContextType workflowContext, int order) {
ItemApprovalProcessStateType info = getItemApprovalProcessInfo(workflowContext);
if (info == null || info.getPolicyRules() == null) {
return null;
return Collections.emptyList();
}
return info.getPolicyRules().getEntry().stream()
.filter(e -> e.getLevelMax() != null && e.getLevelMax() != null
&& order >= e.getLevelMin() && order <= e.getLevelMax())
.findFirst().orElse(null);
.collect(Collectors.toList());
}

public static ApprovalLevelType getCurrentApprovalLevel(WfContextType wfc) {
Expand Down
Expand Up @@ -213,7 +213,7 @@
<xsd:sequence>
<xsd:element name="name" type="xsd:string" minOccurs="0"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
<xsd:element name="time" type="xsd:duration" minOccurs="0" maxOccurs="unbounded">
<xsd:element name="time" type="tns:WfTimeSpecificationType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Time(s) at which these actions are to be executed. No time or zero time means
Expand All @@ -231,6 +231,27 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="condition" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Should this action be scheduled?
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalationFrom" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Apply only for escalation levels greater or equal to this value.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalationTo" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Apply only for escalation levels not greater than this value.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down Expand Up @@ -263,7 +284,14 @@
<xsd:element name="delegate" type="tns:DelegateWorkItemActionType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Delegate (escalate) this work item.
Delegate this work item.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalate" type="tns:EscalateWorkItemActionType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Escalate this work item. Basically the same as "delegate" but increases the escalation level.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -303,6 +331,13 @@
<xsd:sequence>
<xsd:element name="name" type="xsd:string" minOccurs="0"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
<xsd:element name="condition" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Should this action be executed?
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand All @@ -321,6 +356,15 @@
<xsd:extension base="tns:AbstractWorkItemActionType">
<xsd:sequence>
<xsd:element name="outcome" type="tns:WorkItemOutcomeType" minOccurs="0" />
<xsd:element name="notifyBeforeAction" type="xsd:duration" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
If specified, sends a standard "action to be executed" notifications at given times.
(Unlike timed action interval, here specify a positive time: just like for
notifyBeforeDeadline in certification.)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down Expand Up @@ -372,6 +416,7 @@
<p>
What relation(s) to use when determining approvers? E.g. "approver", "owner",
"securityApprover", and so on.
NOT SUPPORTED YET.
</p>
</xsd:documentation>
</xsd:annotation>
Expand Down Expand Up @@ -411,15 +456,49 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!--<xsd:element name="timedActions" type="tns:WorkItemTimedActionsType" minOccurs="0" maxOccurs="unbounded">-->
<!--<xsd:annotation>-->
<!--<xsd:documentation>-->
<!--What actions are to be applied to work items when given timer(s) occur; they are relative-->
<!--to the moment of delegation (positive ones) and to the new deadline (zero or negative ones).-->
<!--EXPERIMENTAL-->
<!--</xsd:documentation>-->
<!--</xsd:annotation>-->
<!--</xsd:element>-->
<xsd:element name="notifyBeforeAction" type="xsd:duration" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
If specified, sends a standard "action to be executed" notifications at given times.
(Unlike timed action interval, here specify a positive time: just like for
notifyBeforeDeadline in certification.)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="EscalateWorkItemActionType">
<xsd:annotation>
<xsd:documentation>
TODO
EXPERIMENTAL
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
<a:container/>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:DelegateWorkItemActionType">
<xsd:sequence>
<xsd:element name="escalationLevelName" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Name for the new escalation level.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalationLevelDisplayName" type="xsd:string" minOccurs="0" >
<xsd:annotation>
<xsd:documentation>
Display name for the new escalation level.
NOT SUPPORTED YET.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down Expand Up @@ -1307,6 +1386,53 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="WorkItemEventCauseInformationType">
<xsd:annotation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="cause" type="tns:WorkItemEventCauseType" minOccurs="0" />
<xsd:element name="causeName" type="xsd:string" minOccurs="0" />
<xsd:element name="causeDisplayName" type="xsd:string" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="WorkItemEventCauseType">
<xsd:annotation>
<xsd:documentation>
Reason for automated decision.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="userAction">
<xsd:annotation>
<xsd:documentation>
This event was caused by a user action.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="USER_ACTION"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="timedAction">
<xsd:annotation>
<xsd:documentation>
This event was caused by a timed action.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="TIMED_ACTION"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="WorkItemEventType">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -1338,6 +1464,35 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalationLevelNumber" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Escalation level number (if applicable). Zero or null means no escalation.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalationLevelName" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Escalation level name (if applicable).
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="escalationLevelDisplayName" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Escalation level display name (if applicable).
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="cause" type="tns:WorkItemEventCauseInformationType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Cause of the event occurring. E.g. user action, timed action (and which one).
EXPERIMENTAL; TO BE DECIDED ABOUT THIS BEFORE 3.6 RELEASE
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- TODO reason? e.g. when doing escalation? -->
</xsd:sequence>
</xsd:extension>
Expand Down Expand Up @@ -1374,13 +1529,34 @@
<xsd:complexContent>
<xsd:extension base="tns:WorkItemEventType">
<xsd:sequence>
<xsd:element name="originalAssignee" type="tns:ObjectReferenceType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="delegatedTo" type="tns:ObjectReferenceType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="delegationMethod" type="tns:WorkItemDelegationMethodType" minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="WorkItemEscalationEventType">
<xsd:annotation>
<xsd:documentation>
Event describing the fact of escalation.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:WorkItemDelegationEventType">
<xsd:sequence>
<xsd:element name="newEscalationLevelNumber" type="xsd:string" />
<xsd:element name="newEscalationLevelName" type="xsd:string" minOccurs="0" />
<xsd:element name="newEscalationLevelDisplayName" type="xsd:string" minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="WfStageCompletionEventType">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -1860,4 +2036,54 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="WfTimeSpecificationType">
<xsd:annotation>
<xsd:documentation>
TODO
EXPERIMENTAL
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="value" type="xsd:duration" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="base" type="tns:WfTimeBaseType" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="WfTimeBaseType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="deadline">
<xsd:annotation>
<xsd:documentation>
Time will be taken relative to the deadline. (This is the default for zero or negative values.)
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="DEADLINE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="workItemCreation">
<xsd:annotation>
<xsd:documentation>
Time will be taken relative to the work item creation timestamp. (This is the default for positive values.)
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="WORK_ITEM_CREATION"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<!-- TODO process instance creation -->
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Expand Up @@ -1996,7 +1996,7 @@ private void authorizeNodeCollectionOperation(ModelAuthorizationAction action, C
public void approveOrRejectWorkItem(String workItemId, boolean decision, String comment, ObjectDelta additionalDelta,
OperationResult parentResult)
throws SecurityViolationException, SchemaException {
getWorkflowManagerChecked().approveOrRejectWorkItem(workItemId, decision, comment, additionalDelta, parentResult);
getWorkflowManagerChecked().approveOrRejectWorkItem(workItemId, decision, comment, additionalDelta, null, parentResult);
}

@Override
Expand Down
Expand Up @@ -64,14 +64,15 @@ <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, Ob

/**
* Approves or rejects a work item (without supplying any further information).
* @param taskId identifier of activiti task backing the work item
* @param taskId identifier of activiti task backing the work item
* @param decision true = approve, false = reject
* @param comment
* @param additionalDelta
* @param causeInformation
* @param parentResult
*/
void approveOrRejectWorkItem(String taskId, boolean decision, String comment, ObjectDelta additionalDelta,
OperationResult parentResult) throws SecurityViolationException, SchemaException;
WorkItemEventCauseInformationType causeInformation, OperationResult parentResult) throws SecurityViolationException, SchemaException;

void claimWorkItem(String workItemId, OperationResult result) throws ObjectNotFoundException, SecurityViolationException;

Expand Down
Expand Up @@ -152,9 +152,10 @@ public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> t

@Override
public void approveOrRejectWorkItem(String taskId, boolean decision, String comment, ObjectDelta additionalDelta,
OperationResult parentResult)
WorkItemEventCauseInformationType causeInformation, OperationResult parentResult)
throws SecurityViolationException, SchemaException {
workItemManager.completeWorkItem(taskId, ApprovalUtils.approvalStringValue(decision), comment, additionalDelta, parentResult);
workItemManager.completeWorkItem(taskId, ApprovalUtils.approvalStringValue(decision), comment, additionalDelta,
causeInformation, parentResult);
}

@Override
Expand Down

0 comments on commit eab3fef

Please sign in to comment.