Search in sources :

Example 6 with Activity

use of com.google.api.ads.admanager.axis.v202111.Activity in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method setCatchEventsInfo.

public void setCatchEventsInfo(FlowElementsContainer container, Definitions def, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        if (fe instanceof CatchEvent) {
            if (((CatchEvent) fe).getEventDefinitions().size() > 0) {
                EventDefinition ed = ((CatchEvent) fe).getEventDefinitions().get(0);
                if (ed instanceof SignalEventDefinition) {
                    SignalEventDefinition sed = (SignalEventDefinition) ed;
                    if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
                        String signalRef = sed.getSignalRef();
                        boolean shouldAddSignal = true;
                        List<RootElement> rootElements = def.getRootElements();
                        for (RootElement re : rootElements) {
                            if (re instanceof Signal) {
                                if (((Signal) re).getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (toAddSignals != null) {
                            for (Signal s : toAddSignals) {
                                if (s.getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (shouldAddSignal) {
                            Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
                            signal.setName(signalRef);
                            toAddSignals.add(signal);
                        }
                    }
                } else if (ed instanceof ErrorEventDefinition) {
                    String errorCode = null;
                    String errorId = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("erefname")) {
                            errorId = (String) entry.getValue();
                            errorCode = (String) entry.getValue();
                        }
                    }
                    Error err = this._errors.get(errorCode);
                    if (err == null) {
                        err = Bpmn2Factory.eINSTANCE.createError();
                        err.setId(errorId);
                        err.setErrorCode(errorCode);
                        this._errors.put(errorCode, err);
                    }
                    toAddErrors.add(err);
                    ((ErrorEventDefinition) ed).setErrorRef(err);
                } else if (ed instanceof EscalationEventDefinition) {
                    String escalationCode = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("esccode")) {
                            escalationCode = (String) entry.getValue();
                            break;
                        }
                    }
                    Escalation escalation = this._escalations.get(escalationCode);
                    if (escalation == null) {
                        escalation = Bpmn2Factory.eINSTANCE.createEscalation();
                        escalation.setEscalationCode(escalationCode);
                        this._escalations.put(escalationCode, escalation);
                    }
                    toAddEscalations.add(escalation);
                    ((EscalationEventDefinition) ed).setEscalationRef(escalation);
                } else if (ed instanceof MessageEventDefinition) {
                    ((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
                } else if (ed instanceof CompensateEventDefinition) {
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("actrefname")) {
                            String activityNameRef = (String) entry.getValue();
                            // we have to iterate again through all flow elements
                            // in order to find our activity name
                            List<RootElement> re = def.getRootElements();
                            for (RootElement r : re) {
                                if (r instanceof Process) {
                                    Process p = (Process) r;
                                    List<FlowElement> fes = p.getFlowElements();
                                    for (FlowElement f : fes) {
                                        if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
                                            ((CompensateEventDefinition) ed).setActivityRef((Activity) f);
                                            ((Activity) f).setIsForCompensation(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            setCatchEventsInfo((FlowElementsContainer) fe, def, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
        }
    }
}
Also used : Escalation(org.eclipse.bpmn2.Escalation) Error(org.eclipse.bpmn2.Error) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) CatchEvent(org.eclipse.bpmn2.CatchEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Signal(org.eclipse.bpmn2.Signal) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) FlowElement(org.eclipse.bpmn2.FlowElement) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) Iterator(java.util.Iterator) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Example 7 with Activity

use of com.google.api.ads.admanager.axis.v202111.Activity in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method setCatchEventsInfoForLanes.

public void setCatchEventsInfoForLanes(Lane lane, Definitions def, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
    List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
    for (FlowElement fe : laneFlowNodes) {
        if (fe instanceof CatchEvent) {
            if (((CatchEvent) fe).getEventDefinitions().size() > 0) {
                EventDefinition ed = ((CatchEvent) fe).getEventDefinitions().get(0);
                if (ed instanceof SignalEventDefinition) {
                    SignalEventDefinition sed = (SignalEventDefinition) ed;
                    if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
                        String signalRef = sed.getSignalRef();
                        boolean shouldAddSignal = true;
                        List<RootElement> rootElements = def.getRootElements();
                        for (RootElement re : rootElements) {
                            if (re instanceof Signal) {
                                if (((Signal) re).getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (toAddSignals != null) {
                            for (Signal s : toAddSignals) {
                                if (s.getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (shouldAddSignal) {
                            Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
                            signal.setName(signalRef);
                            toAddSignals.add(signal);
                        }
                    }
                } else if (ed instanceof ErrorEventDefinition) {
                    String errorCode = null;
                    String errorId = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("erefname")) {
                            errorId = (String) entry.getValue();
                            errorCode = (String) entry.getValue();
                        }
                    }
                    Error err = this._errors.get(errorCode);
                    if (err == null) {
                        err = Bpmn2Factory.eINSTANCE.createError();
                        err.setId(errorId);
                        err.setErrorCode(errorCode);
                        this._errors.put(errorCode, err);
                    }
                    toAddErrors.add(err);
                    ((ErrorEventDefinition) ed).setErrorRef(err);
                } else if (ed instanceof EscalationEventDefinition) {
                    String escalationCode = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("esccode")) {
                            escalationCode = (String) entry.getValue();
                            break;
                        }
                    }
                    Escalation escalation = this._escalations.get(escalationCode);
                    if (escalation == null) {
                        escalation = Bpmn2Factory.eINSTANCE.createEscalation();
                        escalation.setEscalationCode(escalationCode);
                        this._escalations.put(escalationCode, escalation);
                    }
                    toAddEscalations.add(escalation);
                    ((EscalationEventDefinition) ed).setEscalationRef(escalation);
                } else if (ed instanceof MessageEventDefinition) {
                    ((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
                } else if (ed instanceof CompensateEventDefinition) {
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("actrefname")) {
                            String activityNameRef = (String) entry.getValue();
                            // we have to iterate again through all flow elements
                            // in order to find our activity name
                            List<RootElement> re = def.getRootElements();
                            for (RootElement r : re) {
                                if (r instanceof Process) {
                                    Process p = (Process) r;
                                    List<FlowElement> fes = p.getFlowElements();
                                    for (FlowElement f : fes) {
                                        if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
                                            ((CompensateEventDefinition) ed).setActivityRef((Activity) f);
                                            ((Activity) f).setIsForCompensation(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            setCatchEventsInfo((FlowElementsContainer) fe, def, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
        }
    }
}
Also used : Escalation(org.eclipse.bpmn2.Escalation) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) CatchEvent(org.eclipse.bpmn2.CatchEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) Signal(org.eclipse.bpmn2.Signal) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) Iterator(java.util.Iterator) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) Error(org.eclipse.bpmn2.Error) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) FlowElement(org.eclipse.bpmn2.FlowElement) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 8 with Activity

use of com.google.api.ads.admanager.axis.v202111.Activity in project libSBOLj by SynBioDex.

the class Provenance_SpecifyBuildOperations method specifyJoinOperation.

/**
 * specifies a join operation, which joins two linear DNA constructs
 *
 * NOTE! at this point, we do not specify any further information
 * about how to execute the join operation!
 *
 * @throws Exception
 */
public static void specifyJoinOperation() throws Exception {
    // instantiate a document
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(BUILD_PREFIX);
    // the first linear DNA construct
    ComponentDefinition cdPart1 = document.createComponentDefinition("dna_part_1", LINEAR_DOUBLE_STRANDED_DNA);
    cdPart1.setName("dna_part_1");
    // the second linear DNA construct
    ComponentDefinition cdPart2 = document.createComponentDefinition("dna_part_2", LINEAR_DOUBLE_STRANDED_DNA);
    cdPart2.setName("dna_part_2");
    // Create the generic top level entity for the join operation
    Activity joinOperation = document.createActivity("join_" + cdPart1.getName() + "_with_" + cdPart2.getName());
    joinOperation.setName("join(" + cdPart1.getName() + ", " + cdPart2.getName() + ")");
    // specify the "inputs" to the join operation
    joinOperation.createUsage("dna_part_1", cdPart1.getIdentity()).addRole(UPSTREAM);
    joinOperation.createUsage("dna_part_2", cdPart2.getIdentity()).addRole(DOWNSTREAM);
    // specify the "output" of the join operation
    ComponentDefinition cdJoinedPart = document.createComponentDefinition("joined_dna_part", LINEAR_DOUBLE_STRANDED_DNA);
    cdJoinedPart.setName("joined_dna_part");
    cdJoinedPart.addWasGeneratedBy(joinOperation.getIdentity());
    // serialize the document to a file
    SBOLWriter.write(document, System.out);
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 9 with Activity

use of com.google.api.ads.admanager.axis.v202111.Activity in project libSBOLj by SynBioDex.

the class Provenance_SpecifyBuildOperations method specifyAmplifyOperation.

/**
 * specifies the amplify operation, which amplifies a linear DNA construct using
 * 5' and 3' primers
 *
 * @throws Exception
 */
public static void specifyAmplifyOperation() throws Exception {
    // instantiate a document
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(BUILD_PREFIX);
    // the linear DNA construct
    ComponentDefinition dnaConstruct = document.createComponentDefinition("dna_construct", LINEAR_SINGLE_STRANDED_DNA);
    dnaConstruct.setName("dna_construct");
    // the 5' primer for amplification
    ComponentDefinition fivePrimer = document.createComponentDefinition("five_primer", FORWARD_PRIMER);
    fivePrimer.setName("five_primer");
    // the 3' primer for amplification
    ComponentDefinition threePrimer = document.createComponentDefinition("three_primer", REVERSE_PRIMER);
    threePrimer.setName("three_primer");
    // Create the generic top level entity for the amplify operation
    Activity amplifyOperation = document.createActivity("amplify_" + dnaConstruct.getName() + "_with_" + fivePrimer.getName() + "_and_" + threePrimer.getName());
    amplifyOperation.setName("amplify(" + dnaConstruct.getName() + ", " + fivePrimer.getName() + ", " + threePrimer.getName() + ")");
    // create the qualifiedUsage annotation to describe the inputs of the amplification operation
    // -- the amplicon
    Usage usageDNAConstruct = amplifyOperation.createUsage("dna_construct", dnaConstruct.getIdentity());
    usageDNAConstruct.addRole(URI.create("http://sbols.org/v2#source"));
    usageDNAConstruct.addRole(PCR_PRODUCT);
    // -- the forward primer
    Usage usageFwdPrimer = amplifyOperation.createUsage("forward_primer", fivePrimer.getIdentity());
    usageFwdPrimer.addRole(FORWARD_PRIMER);
    usageFwdPrimer.addRole(FORWARD_PRIMER);
    // -- the reverse primer
    Usage usageRevPrimer = amplifyOperation.createUsage("reverse_primer", threePrimer.getIdentity());
    usageRevPrimer.addRole(REVERSE_PRIMER);
    usageRevPrimer.addRole(REVERSE_PRIMER);
    // the result of the amplification operation
    ComponentDefinition amplified_construct = document.createComponentDefinition("my_amplified_dna", AMPLIFIED_CONSTRUCT);
    amplified_construct.setName("my_amplified_dna");
    amplified_construct.addWasGeneratedBy(amplifyOperation.getIdentity());
    // serialize the document to a file
    SBOLWriter.write(document, System.out);
}
Also used : Usage(org.sbolstandard.core2.Usage) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 10 with Activity

use of com.google.api.ads.admanager.axis.v202111.Activity in project libSBOLj by SynBioDex.

the class Provenance_StrainDerivation method main.

public static void main(String[] args) throws Exception {
    NamespaceBinding myAppNs = NamespaceBinding("http://myapp.com/", "myapp");
    SBOLDocument document = new SBOLDocument();
    document.addNamespace(URI.create(myAppNs.getNamespaceURI()), myAppNs.getPrefix());
    document.setDefaultURIprefix(myAppNs.getNamespaceURI());
    ComponentDefinition b168 = getCds(document, "bsubtilis168", "Bacillus subtilis 168");
    ComponentDefinition b3610 = getCds(document, "bsubtilisncimb3610", "Bacillus subtilis NCIMB 3610");
    b168.addWasDerivedFrom(b3610.getIdentity());
    // Create the agent definition to represent X-ray
    Agent agent = document.createAgent("x_ray");
    agent.setName("X-ray");
    // Create the generic top level entity for the X-ray mutagenesis activity
    Activity activity = document.createActivity("xraymutagenesis");
    activity.setName("X-ray mutagenesis");
    // Create the qualifiedUsage annotation to describe the use of the parent strain
    activity.createUsage("usage", b3610.getIdentity()).addRole(URI.create("http://sbols.org/v2#source"));
    // Create the qualifiedAssociation annotation to describe the use of the agent used in the activity
    activity.createAssociation("association", agent.getIdentity()).addRole(myAppNs.namespacedUri("mutagen"));
    b168.addWasGeneratedBy(activity.getIdentity());
    SBOLWriter.write(document, System.out);
}
Also used : Agent(org.sbolstandard.core2.Agent) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) NamespaceBinding(org.sbolstandard.core.datatree.Datatree.NamespaceBinding) NamespaceBinding(org.sbolstandard.core.datatree.NamespaceBinding) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Aggregations

Activity (org.eclipse.bpmn2.Activity)16 CallActivity (org.eclipse.bpmn2.CallActivity)9 FlowElement (org.eclipse.bpmn2.FlowElement)9 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)8 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)8 ArrayList (java.util.ArrayList)7 Entry (java.util.Map.Entry)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 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)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 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)7 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)6 Escalation (org.eclipse.bpmn2.Escalation)6 Signal (org.eclipse.bpmn2.Signal)6