Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BPMN 2.0 Modeler » Can't access xxxxRefs from SequenceFlow(After processing BPMN2 file SequenceFlow source and targetRef fields are empty)
Can't access xxxxRefs from SequenceFlow [message #1118675] Fri, 27 September 2013 17:01 Go to next message
Ken Hall is currently offline Ken HallFriend
Messages: 5
Registered: September 2013
Junior Member
I have a simple flow that contains a number of SequenceFlow objects. When I parse the flow I find that the sourceRef and targRef fields are empty in the SequenceFlow objects even though I can see them in the XML -

Here is the XML -

<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway2"></sequenceFlow>


(The id field is populated by the way)

And here is the code that I use to access the elements -


URI uri = URI.createURI("test.bpmn");
Bpmn2ResourceFactoryImpl resFactory = new Bpmn2ResourceFactoryImpl();
Resource resource = resFactory.createResource(uri);
resource.load(getResourceAsStream(filename), Collections.EMPTY_MAP);
// Definitions is the root element in our xml file
Definitions d = (Definitions) resource.getContents().get(0).eContents().get(0);
	
// We are only interested in the processes for the moment
List<RootElement> rootElements = d.getRootElements();
for( RootElement possibleProcessElement: rootElements) {
	if (possibleProcessElement instanceof org.eclipse.bpmn2.Process) {
			org.eclipse.bpmn2.Process process = (org.eclipse.bpmn2.Process) possibleProcessElement;
			for (FlowElement anElement : process.getFlowElements()) {		
				if (anElement instanceof SequenceFlowImpl) {
					SequenceFlow aSequence = ((SequenceFlow) anElement);
					if (aSequence!=null) {
						String source="";
						String target="";
						if (aSequence.getSourceRef() != null) source = aSequence.getSourceRef().getId();
						if (aSequence.getTargetRef() != null) target = aSequence.getTargetRef().getId();
							System.out.println(aSequence.getId()+" Flow from source "+source+" to "+target+"   "+aSequence.toString());
						}						
				}
			}
	}
}


And the output is this (all the flows are the same - with different ids of course) -

flow1 Flow from source to

Looking at my jars the classes are all in - org.eclipse.bpmn2_0.7.0.201304230617.jar
I am running in Eclipse Juno -
Eclipse SDK

Version: 4.2.1
Build id: M20120914-1800

Regards
Ken


Re: Can't access xxxxRefs from SequenceFlow [message #1118729 is a reply to message #1118675] Fri, 27 September 2013 18:21 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 624
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Hi Ken,

I think this may be related to a bug in the copy/paste code (reported here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418030)
Have you been using copy/paste?

Bob
Re: Can't access xxxxRefs from SequenceFlow [message #1119628 is a reply to message #1118729] Sat, 28 September 2013 18:08 Go to previous messageGo to next message
Ken Hall is currently offline Ken HallFriend
Messages: 5
Registered: September 2013
Junior Member
Hi Bob,

Thanks for the quick reply. I presume you mean copy/paste in the modeler. I'm actually using the Activiti modeler to generate the XML. I didn't use copy/paste to generate the nodes in that.

As I write this it occurs to me that using the output of Activiti might be the issue since it seems that the way that the parser is working is that it is finding and attaching the node with the reference and putting that in the reference field (source or target). I had assumed that I would get a String back that represented the attribute in the XML.

The other nodes are defined in the XML -

    <startEvent id="startevent1" name="Start"></startEvent>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway2"></sequenceFlow>


I know these aren't 'standard' nodes but the issue is also present for 'real' nodes e.g.
    <serviceTask id="ILMSNFA3" name="3. ILMFS Note file arrival" activiti:expression="JAVA_waitForFileArrival" activiti:resultVariableName="success_filearrival_FROM_ILM">
      <extensionElements>
        <activiti:field name="fileFromILM">
          <activiti:string>theFileFromILM</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow21" sourceRef="ILMSNFA3" targetRef="ILMSSSF44"></sequenceFlow>


flow21 Flow from source  to 


I'm basically prototyping something at present so I have chucked a lot of technologies together hoping that it will work. The Activiti people suggested that if I wanted to parse the output the Eclipse modeller would work - but maybe it won't. Really all I want to do is parse the Activiti XML and this is working successfully for everything that I need except the SequenceFlow. All I actually want from the SequenceFlow element is the text in the SourceRef and TargetRef attributes - I've looked at the objects that are returned in the SequenceFlow but I haven't been able to dig out the attribute values (i.e. the ids of the nodes) - is there a way to do that? If there was that would solve my problem.
Re: Can't access xxxxRefs from SequenceFlow [message #1120004 is a reply to message #1119628] Sun, 29 September 2013 04:25 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 624
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Sorry, I misunderstood what you were trying to do initially. I just tried the code snippet to load and scan an existing bpmn file and it appeared to work correctly. Can you post the test.bpmn process that you're working with so I can try to figure out why it's not working for you?

One thing I did change is instead of this:

resource.load(getResourceAsStream(filename), Collections.EMPTY_MAP);


I used this:

resource.load(Collections.EMPTY_MAP);


Bob
Re: Can't access xxxxRefs from SequenceFlow [message #1121121 is a reply to message #1120004] Mon, 30 September 2013 09:40 Go to previous messageGo to next message
Ken Hall is currently offline Ken HallFriend
Messages: 5
Registered: September 2013
Junior Member
Hi Bob

Thanks for taking the time to look at this. Here is the BPMN file and the code I use to analyse it. (I couldn't find how to attach files from the help). I had to take the definitions out as it seemed to think that I was using links to eclipse.org sites.

<?xml version="1.0" encoding="UTF-8"?>
  <collaboration id="Collaboration">
    <participant id="pool1" name="Location1" processRef="process_pool1"></participant>
    <participant id="pool2" name="ILM" processRef="process_pool2"></participant>
    <participant id="pool3" name="P6" processRef="process_pool3"></participant>
  </collaboration>
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="parallelgateway2" targetRef="DOG1createFile"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="parallelgateway2" targetRef="CATcreateFile"></sequenceFlow>
    <sequenceFlow id="flow18" sourceRef="startevent1" targetRef="VZMZATCreateFile"></sequenceFlow>
  </process>
  <process id="process_pool1" name="process_pool1" isExecutable="true">
    <laneSet id="laneSet_process_pool1">
      <lane id="lane1" name="ProductD">
        <flowNodeRef>Location1PDReceiveFile5</flowNodeRef>
      </lane>
      <lane id="lane2" name="ProductB">
        <flowNodeRef>parallelgateway4</flowNodeRef>
        <flowNodeRef>Location1ProductBCombineFiles7</flowNodeRef>
      </lane>
      <lane id="lane7" name="ProductA">
        <flowNodeRef>Location1ProductASendFile10</flowNodeRef>
        <flowNodeRef>Location1ProductAReceiveFile6</flowNodeRef>
        <flowNodeRef>Location1ProductAWaitForCombinedFile9</flowNodeRef>
      </lane>
    </laneSet>
    <serviceTask id="Location1ProductAReceiveFile6" name="6. [Location1] &lt;ProductA&gt; Receive file " activiti:expression="XCALL_waitForFileArrival" activiti:resultVariableName="success_waitforfile">
      <extensionElements>
        <activiti:field name="filewearewaitingfor">
          <activiti:string>Location1:filesystem:filewearewaitingfor</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow12" sourceRef="Location1ProductAReceiveFile6" targetRef="parallelgateway4"></sequenceFlow>
    <callActivity id="Location1ProductBCombineFiles7" name="7. [Location1] &lt;ProductB&gt; Combine files" activiti:async="true" calledElement="ProductB_combineFiles">
      <extensionElements>
        <activiti:in sourceExpression="filewearewaitingfor" target="filesystem"></activiti:in>
        <activiti:in sourceExpression="otherfilewearewaitingfor" target="filesystem"></activiti:in>
      </extensionElements>
    </callActivity>
    <parallelGateway id="parallelgateway4" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow14" sourceRef="parallelgateway4" targetRef="Location1ProductBCombineFiles7"></sequenceFlow>
    <callActivity id="Location1PDReceiveFile5" name="5. [Location1] &lt;ProductD&gt; Receive File"></callActivity>
    <sequenceFlow id="flow13" sourceRef="Location1PDReceiveFile5" targetRef="parallelgateway4"></sequenceFlow>
    <serviceTask id="Location1ProductASendFile10" name="10. [Location1] &lt;ProductA&gt; Send File" activiti:expression="XCALL_copyit" activiti:resultVariableName="success_file_sent">
      <extensionElements>
        <activiti:field name="sourceFile">
          <activiti:string>Location1:filesystem:combinedFile</activiti:string>
        </activiti:field>
        <activiti:field name="destinationFile">
          <activiti:string>P6:filesystem:combinedFile</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow16" sourceRef="Location1ProductASendFile10" targetRef="P6AppReceiveFile"></sequenceFlow>
    <serviceTask id="Location1ProductAWaitForCombinedFile9" name="9. [Location1] &lt;ProductA&gt; Wait for combined file " activiti:expression="XCALL_waitForFile" activiti:resultVariableName="success_fileHasArrived">
      <extensionElements>
        <activiti:field name="combinedFile">
          <activiti:string>Location1:filesystem</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow23" sourceRef="Location1ProductBCombineFiles7" targetRef="Location1ProductAWaitForCombinedFile9"></sequenceFlow>
    <sequenceFlow id="flow24" sourceRef="Location1ProductAWaitForCombinedFile9" targetRef="Location1ProductASendFile10"></sequenceFlow>
  </process>
  <process id="process_pool2" name="process_pool2" isExecutable="true">
    <laneSet id="laneSet_process_pool2">
      <lane id="lane3" name="ZAT Point">
        <flowNodeRef>VZMZATCreateFile</flowNodeRef>
      </lane>
      <lane id="lane4" name="ProductD">
        <flowNodeRef>VZMPDSEndFile</flowNodeRef>
      </lane>
      <lane id="lane5" name="Dog1">
        <flowNodeRef>DOG1createFile</flowNodeRef>
      </lane>
      <lane id="lane6" name="CAT">
        <flowNodeRef>CATcreateFile</flowNodeRef>
        <flowNodeRef>parallelgateway3</flowNodeRef>
      </lane>
      <lane id="lane8" name="ProductA">
        <flowNodeRef>ILMProductANoteFileArrival3</flowNodeRef>
        <flowNodeRef>ILMProductASendFile4</flowNodeRef>
      </lane>
    </laneSet>
    <callActivity id="VZMZATCreateFile" name="2. [VZM LocationM]   &lt;ZAT Point&gt; Create File"></callActivity>
    <sequenceFlow id="flow9" sourceRef="VZMZATCreateFile" targetRef="VZMPDSEndFile"></sequenceFlow>
    <serviceTask id="ILMProductASendFile4" name="4. [ILM] &lt;ProductA&gt; Send file" activiti:expression="XCALL_copyit" activiti:resultVariableName="success">
      <extensionElements>
        <activiti:field name="sourceFile">
          <activiti:expression>${filewearewaitingfor}</activiti:expression>
        </activiti:field>
        <activiti:field name="destinationFile">
          <activiti:string>Location1:filesystem:destinationFile</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <serviceTask id="ILMProductANoteFileArrival3" name="3. [ILM] &lt;ProductA&gt; Note file arrival" activiti:expression="XCALL_waitForFileArrival" activiti:resultVariableName="success_filearrival_at_LocationM">
      <extensionElements>
        <activiti:field name="fileFromLocationM">
          <activiti:string>Location1:filesystem:fileFromDog1OrCAT</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow21" sourceRef="ILMProductANoteFileArrival3" targetRef="ILMProductASendFile4"></sequenceFlow>
    <callActivity id="CATcreateFile" name="1. [CAT] Create File"></callActivity>
    <sequenceFlow id="flow7" sourceRef="CATcreateFile" targetRef="parallelgateway3"></sequenceFlow>
    <parallelGateway id="parallelgateway3" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow8" sourceRef="parallelgateway3" targetRef="ILMProductANoteFileArrival3"></sequenceFlow>
    <callActivity id="DOG1createFile" name="1. [DOG1] Create File"></callActivity>
    <sequenceFlow id="flow6" sourceRef="DOG1createFile" targetRef="parallelgateway3"></sequenceFlow>
    <callActivity id="VZMPDSEndFile" name="5. [VZM LocationM] &lt;ProductD&gt; Send File"></callActivity>
    <sequenceFlow id="flow25" sourceRef="ILMProductASendFile4" targetRef="Location1ProductAReceiveFile6"></sequenceFlow>
    <sequenceFlow id="flow26" sourceRef="VZMPDSEndFile" targetRef="Location1PDReceiveFile5"></sequenceFlow>
  </process>
  <process id="process_pool3" name="process_pool3" isExecutable="true">
    <laneSet id="laneSet_process_pool3">
      <lane id="lane9" name="AppZ">
        <flowNodeRef>P6AppReceiveFile</flowNodeRef>
        <flowNodeRef>terminateendevent1</flowNodeRef>
      </lane>
    </laneSet>
    <callActivity id="P6AppReceiveFile" name="[P6] &lt;AppZ&gt; Receive File"></callActivity>
    <sequenceFlow id="flow17" sourceRef="P6AppReceiveFile" targetRef="terminateendevent1"></sequenceFlow>
    <endEvent id="terminateendevent1" name="TerminateEndEvent">
      <terminateEventDefinition></terminateEventDefinition>
    </endEvent>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Collaboration">
    <bpmndi:BPMNPlane bpmnElement="Collaboration" id="BPMNPlane_Collaboration">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="-40.0" y="273.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="32.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway3" id="BPMNShape_parallelgateway3">
        <omgdc:Bounds height="40.0" width="40.0" x="314.0" y="316.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway4" id="BPMNShape_parallelgateway4">
        <omgdc:Bounds height="40.0" width="40.0" x="730.0" y="186.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="terminateendevent1" id="BPMNShape_terminateendevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="990.0" y="457.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="DOG1createFile" id="BPMNShape_DOG1createFile">
        <omgdc:Bounds height="65.0" width="105.0" x="174.0" y="209.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="CATcreateFile" id="BPMNShape_CATcreateFile">
        <omgdc:Bounds height="67.0" width="111.0" x="164.0" y="303.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="VZMZATCreateFile" id="BPMNShape_VZMZATCreateFile">
        <omgdc:Bounds height="71.0" width="161.0" x="174.0" y="19.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="VZMPDSEndFile" id="BPMNShape_VZMPDSEndFile">
        <omgdc:Bounds height="71.0" width="181.0" x="164.0" y="113.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Location1ProductASendFile10" id="BPMNShape_Location1ProductASendFile10">
        <omgdc:Bounds height="55.0" width="105.0" x="1010.0" y="283.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="P6AppReceiveFile" id="BPMNShape_P6AppReceiveFile">
        <omgdc:Bounds height="71.0" width="121.0" x="700.0" y="439.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="pool1" id="BPMNShape_pool1">
        <omgdc:Bounds height="324.0" width="500.0" x="636.0" y="33.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane1" id="BPMNShape_lane1">
        <omgdc:Bounds height="136.0" width="480.0" x="656.0" y="33.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane2" id="BPMNShape_lane2">
        <omgdc:Bounds height="94.0" width="480.0" x="656.0" y="169.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="pool2" id="BPMNShape_pool2">
        <omgdc:Bounds height="466.0" width="471.0" x="104.0" y="9.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane3" id="BPMNShape_lane3">
        <omgdc:Bounds height="95.0" width="451.0" x="124.0" y="9.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane7" id="BPMNShape_lane7">
        <omgdc:Bounds height="94.0" width="480.0" x="656.0" y="263.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane4" id="BPMNShape_lane4">
        <omgdc:Bounds height="95.0" width="451.0" x="124.0" y="103.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane5" id="BPMNShape_lane5">
        <omgdc:Bounds height="91.0" width="451.0" x="124.0" y="201.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane6" id="BPMNShape_lane6">
        <omgdc:Bounds height="91.0" width="451.0" x="124.0" y="292.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane8" id="BPMNShape_lane8">
        <omgdc:Bounds height="91.0" width="451.0" x="124.0" y="383.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="pool3" id="BPMNShape_pool3">
        <omgdc:Bounds height="111.0" width="500.0" x="636.0" y="409.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="lane9" id="BPMNShape_lane9">
        <omgdc:Bounds height="111.0" width="480.0" x="656.0" y="409.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="ILMProductASendFile4" id="BPMNShape_ILMProductASendFile4">
        <omgdc:Bounds height="76.0" width="105.0" x="434.0" y="390.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="ILMProductANoteFileArrival3" id="BPMNShape_ILMProductANoteFileArrival3">
        <omgdc:Bounds height="71.0" width="115.0" x="274.0" y="392.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Location1ProductAReceiveFile6" id="BPMNShape_Location1ProductAReceiveFile6">
        <omgdc:Bounds height="55.0" width="121.0" x="690.0" y="283.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Location1ProductBCombineFiles7" id="BPMNShape_Location1ProductBCombineFiles7">
        <omgdc:Bounds height="68.0" width="105.0" x="860.0" y="173.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Location1PDReceiveFile5" id="BPMNShape_Location1PDReceiveFile5">
        <omgdc:Bounds height="91.0" width="121.0" x="690.0" y="57.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Location1ProductAWaitForCombinedFile9" id="BPMNShape_Location1ProductAWaitForCombinedFile9">
        <omgdc:Bounds height="55.0" width="131.0" x="850.0" y="283.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="-5.0" y="290.0"></omgdi:waypoint>
        <omgdi:waypoint x="32.0" y="290.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="52.0" y="270.0"></omgdi:waypoint>
        <omgdi:waypoint x="51.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="174.0" y="241.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="52.0" y="310.0"></omgdi:waypoint>
        <omgdi:waypoint x="51.0" y="336.0"></omgdi:waypoint>
        <omgdi:waypoint x="164.0" y="336.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="279.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="334.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="334.0" y="316.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="275.0" y="336.0"></omgdi:waypoint>
        <omgdi:waypoint x="314.0" y="336.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="334.0" y="356.0"></omgdi:waypoint>
        <omgdi:waypoint x="331.0" y="392.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="254.0" y="90.0"></omgdi:waypoint>
        <omgdi:waypoint x="254.0" y="113.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="750.0" y="283.0"></omgdi:waypoint>
        <omgdi:waypoint x="750.0" y="226.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="750.0" y="148.0"></omgdi:waypoint>
        <omgdi:waypoint x="750.0" y="186.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="770.0" y="206.0"></omgdi:waypoint>
        <omgdi:waypoint x="860.0" y="207.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="1062.0" y="338.0"></omgdi:waypoint>
        <omgdi:waypoint x="1062.0" y="379.0"></omgdi:waypoint>
        <omgdi:waypoint x="911.0" y="379.0"></omgdi:waypoint>
        <omgdi:waypoint x="760.0" y="379.0"></omgdi:waypoint>
        <omgdi:waypoint x="760.0" y="439.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
        <omgdi:waypoint x="821.0" y="474.0"></omgdi:waypoint>
        <omgdi:waypoint x="990.0" y="474.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="-23.0" y="273.0"></omgdi:waypoint>
        <omgdi:waypoint x="-23.0" y="54.0"></omgdi:waypoint>
        <omgdi:waypoint x="174.0" y="54.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow21" id="BPMNEdge_flow21">
        <omgdi:waypoint x="389.0" y="427.0"></omgdi:waypoint>
        <omgdi:waypoint x="434.0" y="428.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow23" id="BPMNEdge_flow23">
        <omgdi:waypoint x="912.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="915.0" y="283.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow24" id="BPMNEdge_flow24">
        <omgdi:waypoint x="981.0" y="310.0"></omgdi:waypoint>
        <omgdi:waypoint x="1010.0" y="310.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow25" id="BPMNEdge_flow25">
        <omgdi:waypoint x="539.0" y="428.0"></omgdi:waypoint>
        <omgdi:waypoint x="605.0" y="428.0"></omgdi:waypoint>
        <omgdi:waypoint x="606.0" y="308.0"></omgdi:waypoint>
        <omgdi:waypoint x="690.0" y="310.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow26" id="BPMNEdge_flow26">
        <omgdi:waypoint x="345.0" y="148.0"></omgdi:waypoint>
        <omgdi:waypoint x="604.0" y="148.0"></omgdi:waypoint>
        <omgdi:waypoint x="604.0" y="100.0"></omgdi:waypoint>
        <omgdi:waypoint x="690.0" y="102.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>




import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl;

import org.eclipse.bpmn2.CallActivity;
import org.eclipse.bpmn2.Definitions;
import org.eclipse.bpmn2.ExtensionAttributeValue;
import org.eclipse.bpmn2.FlowElement;
import org.eclipse.bpmn2.RootElement;
import org.eclipse.bpmn2.SequenceFlow;
import org.eclipse.bpmn2.ServiceTask;
import org.eclipse.bpmn2.impl.SequenceFlowImpl;
import org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl;



public class TestBPMN {
	
	public static String EXPRESSION_VARIABLE_LIST="^sourceExpression^resultVariableName^";
	public static String TYPE1_LIST = "^text^name^target^sourceExpression^resultVariableName^"; 
	
	public static void main(String[] args) throws IOException {
		URI uri = URI.createURI("TestCase.bpmn");
		Bpmn2ResourceFactoryImpl resFactory = new Bpmn2ResourceFactoryImpl();
		Resource resource = resFactory.createResource(uri);
		resource.load(Collections.EMPTY_MAP);
		// Definitions is the root element in our xml file
		Definitions d = (Definitions) resource.getContents().get(0).eContents().get(0);
		
		// We are only interested in the processes for the moment
		List<RootElement> rootElements = d.getRootElements();
		for( RootElement possibleProcessElement: rootElements) {
			if (possibleProcessElement instanceof org.eclipse.bpmn2.Process) {
					org.eclipse.bpmn2.Process process = (org.eclipse.bpmn2.Process) possibleProcessElement;
					for (FlowElement anElement : process.getFlowElements()) {
						System.out.println(anElement.getClass()+"");
						if (anElement instanceof CallActivity) {
							CallActivity aCall = ((CallActivity) anElement);
							if (aCall!=null) {
								System.out.println("Call activity "+aCall+"  "+aCall.getAnyAttribute());
								analyse(aCall.getAnyAttribute(),aCall.getExtensionValues());
							}
						}
						if (anElement instanceof ServiceTask) {
							ServiceTask aTask = ((ServiceTask) anElement);
							if (aTask!=null) {
								System.out.println("");
								System.out.println("Service Task "+aTask.getName()+"( "+aTask.getId()+")");
								analyse(aTask.getAnyAttribute(),aTask.getExtensionValues());
								System.out.println("");
							}
						}
						if (anElement instanceof SequenceFlowImpl) {
							SequenceFlow aSequence = ((SequenceFlow) anElement);
							if (aSequence!=null) {
								String source="";
								String target="";
								System.out.println("Trying "+aSequence);
								if (aSequence.getSourceRef() != null) source = aSequence.getSourceRef().getId();
								if (aSequence.getTargetRef() != null) target = aSequence.getTargetRef().getId();
								System.out.println(aSequence.getId()+" Flow from source "+source+" to "+target);								
							}						
						}
					}

			}
		} 
	}

	public static void analyse(FeatureMap attrib, List<ExtensionAttributeValue> params) {
		analyse(attrib);
		for (ExtensionAttributeValue each: params) {
			FeatureMap values = each.getValue();
			Iterator<FeatureMap.Entry> valuesIt = values.iterator();
			FeatureMap.Entry aValue = null;
			while (valuesIt.hasNext()) {
				aValue = valuesIt.next();
				analyse(((AnyTypeImpl) aValue.getValue()),"");
			}			
		}
	}
	
	public static void analyse(FeatureMap attrib) {
		analyse(attrib,"");
	}
	
	public static void analyse(AnyTypeImpl params,String name) {
		analyse(params.getAnyAttribute(),name);
	}
	
	public static void analyse(FeatureMap fm, String name) {
		Iterator<FeatureMap.Entry> tempIt = fm.iterator();
		while(tempIt.hasNext()) {
			FeatureMap.Entry val = tempIt.next();
			analyse(val, name);
		}
	}
	
	public static void analyse(FeatureMap.Entry anEntry, String name) {
		String type = anEntry.getEStructuralFeature().getName();
		if (TYPE1_LIST.contains("^"+type+"^")) {	
			String retval = ((String) anEntry.getValue()).trim();
			if ((retval != null) && (retval.length()>0)) {
				System.out.println(" TYPE :: "+type+" NAME :: "+name+" RETVAL :: "+retval);
			}
		}
		else if ((type.equals("string")) || (type.equals("expression"))) {	
			if (anEntry.getValue() instanceof AnyTypeImpl) {
				analyse((AnyTypeImpl) anEntry.getValue(),name);
			} else {
				String retval = ((String) anEntry.getValue()).trim();
				if ((retval != null) && (retval.length()>0)) {
					System.out.println(" TYPE :: "+type+" NAME :: "+name+" RETVAL :: "+retval);
				}			
			}
		}
	}
	
	public static InputStream getResourceAsStream(String aString) throws FileNotFoundException {
		return new FileInputStream(aString);
	}
}


If you need anything more let me know

Regards
Ken
Re: Can't access xxxxRefs from SequenceFlow [message #1121126 is a reply to message #1121121] Mon, 30 September 2013 09:45 Go to previous messageGo to next message
Ken Hall is currently offline Ken HallFriend
Messages: 5
Registered: September 2013
Junior Member
These are the definitions. I've replaced all the '.' characters in the Web addresses with '_' and all the http refs with WEB

Regards
Ken

<definitions xmlns="WEB//www_omg_org/spec/BPMN/20100524/MODEL" xmlns:xsi="WEB//www_w3_org/2001/XMLSchema-instance" xmlns:activiti="WEB//activiti_org/bpmn" xmlns:bpmndi="WEB//www_omg_org/spec/BPMN/20100524/DI" xmlns:omgdc="WEB//www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="WEB//www_omg_org/spec/DD/20100524/DI" typeLanguage="WEB//www_w3_org/2001/XMLSchema" expressionLanguage="WEB//www_w3_org/1999/XPath" targetNamespace="WEB//www_activiti_org/test">
Re: Can't access xxxxRefs from SequenceFlow [message #1121339 is a reply to message #1121126] Mon, 30 September 2013 14:14 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 624
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Hi Ken,

You need to set the XML option OPTION_DEFER_IDREF_RESOLUTION true, like so:


		Map<Object, Object> options = new HashMap<Object, Object>();
		options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
		resource.load(options);



I don't fully understand the reason why EMF doesn't automatically resolve references to internal document objects by ID, but that's the way it is Wink

HTH
Bob
Re: Can't access xxxxRefs from SequenceFlow [message #1121413 is a reply to message #1121339] Mon, 30 September 2013 15:47 Go to previous messageGo to next message
Ken Hall is currently offline Ken HallFriend
Messages: 5
Registered: September 2013
Junior Member
Thanks Bob - that did the trick. I'd never have found that in a million years!

Have a great day.

Regards
Ken
Re: Can't access xxxxRefs from SequenceFlow [message #1121431 is a reply to message #1121413] Mon, 30 September 2013 16:08 Go to previous message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 624
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Glad to help Smile Let me know how your prototype works out!

Cheers,
Bob
Previous Topic:Is there only one bpmn metamodel?
Next Topic:Read the modeled diagram
Goto Forum:
  


Current Time: Thu Dec 18 10:42:34 GMT 2014

Powered by FUDForum. Page generated in 0.03110 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software