Search in sources :

Example 1 with Activity

use of org.eclipse.bpmn2.Activity in project ORCID-Source by ORCID.

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(ActivitiesContainer actContainerRc2) {
    Date latestAct = null;
    Collection<? extends Activity> activities = actContainerRc2.retrieveActivities();
    if (activities != null && !activities.isEmpty()) {
        Iterator<? extends Activity> activitiesIterator = activities.iterator();
        XMLGregorianCalendar latest = activitiesIterator.next().getLastModifiedDate().getValue();
        while (activitiesIterator.hasNext()) {
            Activity activity = activitiesIterator.next();
            if (latest.compare(activity.getLastModifiedDate().getValue()) == -1) {
                latest = activity.getLastModifiedDate().getValue();
            }
        }
        actContainerRc2.setLastModifiedDate(new LastModifiedDate(latest));
        latestAct = latest.toGregorianCalendar().getTime();
    }
    return latestAct;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) GroupableActivity(org.orcid.jaxb.model.record_rc2.GroupableActivity) Activity(org.orcid.jaxb.model.record_rc2.Activity) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

Example 2 with Activity

use of org.eclipse.bpmn2.Activity in project ORCID-Source by ORCID.

the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(ActivitiesContainer actContainerRc3) {
    Collection<? extends Activity> activities = actContainerRc3.retrieveActivities();
    if (activities != null && !activities.isEmpty()) {
        Iterator<? extends Activity> activitiesIterator = activities.iterator();
        XMLGregorianCalendar latest = activitiesIterator.next().getLastModifiedDate().getValue();
        while (activitiesIterator.hasNext()) {
            Activity activity = activitiesIterator.next();
            if (latest.compare(activity.getLastModifiedDate().getValue()) == -1) {
                latest = activity.getLastModifiedDate().getValue();
            }
        }
        actContainerRc3.setLastModifiedDate(new LastModifiedDate(latest));
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) Activity(org.orcid.jaxb.model.record_rc3.Activity) GroupableActivity(org.orcid.jaxb.model.record_rc3.GroupableActivity)

Example 3 with Activity

use of org.eclipse.bpmn2.Activity in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method setCatchEventProperties.

private void setCatchEventProperties(CatchEvent event, Map<String, Object> properties, Definitions def) {
    if (event.getOutputSet() != null) {
        List<DataOutput> dataOutputs = event.getOutputSet().getDataOutputRefs();
        StringBuffer doutbuff = new StringBuffer();
        for (DataOutput dout : dataOutputs) {
            doutbuff.append(dout.getName());
            String dtype = getAnyAttributeValue(dout, "dtype");
            if (dtype != null && !dtype.isEmpty()) {
                doutbuff.append(":").append(dtype);
            }
            doutbuff.append(",");
        }
        if (doutbuff.length() > 0) {
            doutbuff.setLength(doutbuff.length() - 1);
        }
        String dataoutput = doutbuff.toString();
        properties.put(DATAOUTPUT, dataoutput);
        List<DataOutputAssociation> outputAssociations = event.getDataOutputAssociation();
        StringBuffer doutassociationbuff = new StringBuffer();
        for (DataOutputAssociation doa : outputAssociations) {
            String doaName = ((DataOutput) doa.getSourceRef().get(0)).getName();
            if (doaName != null && doaName.length() > 0) {
                doutassociationbuff.append("[dout]" + ((DataOutput) doa.getSourceRef().get(0)).getName());
                doutassociationbuff.append("->");
                doutassociationbuff.append(doa.getTargetRef().getId());
                doutassociationbuff.append(",");
            }
        }
        if (doutassociationbuff.length() > 0) {
            doutassociationbuff.setLength(doutassociationbuff.length() - 1);
        }
        String assignments = doutassociationbuff.toString();
        properties.put(DATAOUTPUTASSOCIATIONS, assignments);
        setAssignmentsInfoProperty(null, null, dataoutput, null, assignments, properties);
    }
    // event definitions
    List<EventDefinition> eventdefs = event.getEventDefinitions();
    for (EventDefinition ed : eventdefs) {
        if (ed instanceof TimerEventDefinition) {
            setTimerEventProperties((TimerEventDefinition) ed, properties);
        } else if (ed instanceof SignalEventDefinition) {
            if (((SignalEventDefinition) ed).getSignalRef() != null) {
                // find signal with the corresponding id
                boolean foundSignalRef = false;
                List<RootElement> rootElements = def.getRootElements();
                for (RootElement re : rootElements) {
                    if (re instanceof Signal) {
                        if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) {
                            properties.put("signalref", ((Signal) re).getName());
                            foundSignalRef = true;
                        }
                    }
                }
                if (!foundSignalRef) {
                    properties.put(SIGNALREF, "");
                }
            } else {
                properties.put(SIGNALREF, "");
            }
        } else if (ed instanceof ErrorEventDefinition) {
            if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) {
                properties.put(ERRORREF, ((ErrorEventDefinition) ed).getErrorRef().getErrorCode());
            } else {
                properties.put(ERRORREF, "");
            }
        } else if (ed instanceof ConditionalEventDefinition) {
            FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed).getCondition();
            if (conditionalExp != null) {
                setConditionExpressionProperties(conditionalExp, properties, "drools");
            }
        } else if (ed instanceof EscalationEventDefinition) {
            if (((EscalationEventDefinition) ed).getEscalationRef() != null) {
                Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef();
                if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) {
                    properties.put(ESCALATIONCODE, esc.getEscalationCode());
                } else {
                    properties.put(ESCALATIONCODE, "");
                }
            }
        } else if (ed instanceof MessageEventDefinition) {
            if (((MessageEventDefinition) ed).getMessageRef() != null) {
                Message msg = ((MessageEventDefinition) ed).getMessageRef();
                properties.put(MESSAGEREF, msg.getName());
            }
        } else if (ed instanceof CompensateEventDefinition) {
            if (((CompensateEventDefinition) ed).getActivityRef() != null) {
                Activity act = ((CompensateEventDefinition) ed).getActivityRef();
                properties.put(ACTIVITYREF, act.getName());
            }
        }
    }
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) Message(org.eclipse.bpmn2.Message) Escalation(org.eclipse.bpmn2.Escalation) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) TerminateEventDefinition(org.eclipse.bpmn2.TerminateEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) CancelEventDefinition(org.eclipse.bpmn2.CancelEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) FormalExpression(org.eclipse.bpmn2.FormalExpression) Signal(org.eclipse.bpmn2.Signal) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Example 4 with Activity

use of org.eclipse.bpmn2.Activity in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallDataOutputSet.

private String marshallDataOutputSet(Activity activity, Map<String, Object> properties, List<String> disallowedNames) {
    if (activity.getIoSpecification() != null) {
        List<OutputSet> outputSetList = activity.getIoSpecification().getOutputSets();
        StringBuilder dataOutBuffer = new StringBuilder();
        for (OutputSet outset : outputSetList) {
            List<DataOutput> dataOutputList = outset.getDataOutputRefs();
            marshallItemAwareElements(activity, dataOutputList, dataOutBuffer, disallowedNames);
        }
        if (dataOutBuffer.length() > 0) {
            dataOutBuffer.setLength(dataOutBuffer.length() - 1);
        }
        String dataoutputset = dataOutBuffer.toString();
        properties.put(DATAOUTPUTSET, dataoutputset);
        return dataoutputset;
    } else {
        return null;
    }
}
Also used : OutputSet(org.eclipse.bpmn2.OutputSet) DataOutput(org.eclipse.bpmn2.DataOutput)

Example 5 with Activity

use of org.eclipse.bpmn2.Activity in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallItemAwareElements.

private void marshallItemAwareElements(Activity activity, List<? extends ItemAwareElement> elements, StringBuilder buffer, List<String> disallowedNames) {
    for (ItemAwareElement element : elements) {
        String name = null;
        if (element instanceof DataInput) {
            name = ((DataInput) element).getName();
        }
        if (element instanceof DataOutput) {
            name = ((DataOutput) element).getName();
        }
        if (name != null && !name.isEmpty() && !disallowedNames.contains(name)) {
            buffer.append(name);
            if (element.getItemSubjectRef() != null && element.getItemSubjectRef().getStructureRef() != null && !element.getItemSubjectRef().getStructureRef().isEmpty()) {
                buffer.append(":").append(element.getItemSubjectRef().getStructureRef());
            } else if (activity.eContainer() instanceof SubProcess) {
                // BZ1247105: for Outputs on Tasks inside sub-processes
                String dtype = getAnyAttributeValue(element, "dtype");
                if (dtype != null && !dtype.isEmpty()) {
                    buffer.append(":").append(dtype);
                }
            }
            buffer.append(",");
        }
    }
}
Also used : DataInput(org.eclipse.bpmn2.DataInput) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement)

Aggregations

CallActivity (org.eclipse.bpmn2.CallActivity)10 Activity (org.eclipse.bpmn2.Activity)9 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)9 Entry (java.util.Map.Entry)7 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)7 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)7 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)7 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)7 EventDefinition (org.eclipse.bpmn2.EventDefinition)7 FlowElement (org.eclipse.bpmn2.FlowElement)7 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)7 RootElement (org.eclipse.bpmn2.RootElement)7 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)7 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)7 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)7 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 DataInput (org.eclipse.bpmn2.DataInput)6 DataOutput (org.eclipse.bpmn2.DataOutput)6 Escalation (org.eclipse.bpmn2.Escalation)6 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)6