Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
JBPM-4020 - A Data Object associated with a Sequence Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Tihomir Surdilovic committed Jun 11, 2013
1 parent 9d4f2d0 commit 65017f4
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 15 deletions.
Expand Up @@ -2037,13 +2037,13 @@ protected void marshallDataObject(DataObject dataObject, BPMNPlane plane, JsonGe
}
}

if(outgoingAssociaton != null && incomingAssociation == null) {
properties.put("input_output", "Input");
}

if(outgoingAssociaton == null && incomingAssociation != null) {
properties.put("input_output", "Output");
}
// if(outgoingAssociaton != null && incomingAssociation == null) {
// properties.put("input_output", "Input");
// }
//
// if(outgoingAssociaton == null && incomingAssociation != null) {
// properties.put("input_output", "Output");
// }

marshallProperties(properties, generator);

Expand Down Expand Up @@ -2650,7 +2650,21 @@ protected void marshallAssociation(Association association, BPMNPlane plane, Jso
generator.writeEndArray();

Bounds sourceBounds = ((BPMNShape) findDiagramElement(plane, association.getSourceRef())).getBounds();
Bounds targetBounds = ((BPMNShape) findDiagramElement(plane, association.getTargetRef())).getBounds();

Bounds targetBounds = null;
float tbx = 0;
float tby = 0;
if(findDiagramElement(plane, association.getTargetRef()) instanceof BPMNShape) {
targetBounds = ((BPMNShape) findDiagramElement(plane, association.getTargetRef())).getBounds();
} else if(findDiagramElement(plane, association.getTargetRef()) instanceof BPMNEdge) {
// connect it to first waypoint on edge
List<Point> waypoints = ((BPMNEdge) findDiagramElement(plane, association.getTargetRef())).getWaypoint();
if(waypoints != null && waypoints.size() > 0) {
tbx = waypoints.get(0).getX();
tby = waypoints.get(0).getY();
}

}
generator.writeArrayFieldStart("dockers");
generator.writeStartObject();
generator.writeObjectField("x", sourceBounds.getWidth() / 2);
Expand All @@ -2664,11 +2678,19 @@ protected void marshallAssociation(Association association, BPMNPlane plane, Jso
generator.writeObjectField("y", waypoint.getY());
generator.writeEndObject();
}
generator.writeStartObject();
generator.writeObjectField("x", targetBounds.getWidth() / 2);
generator.writeObjectField("y", targetBounds.getHeight() / 2);
generator.writeEndObject();
generator.writeEndArray();
if(targetBounds != null) {
generator.writeStartObject();
generator.writeObjectField("x", targetBounds.getWidth() / 2);
generator.writeObjectField("y", targetBounds.getHeight() / 2);
generator.writeEndObject();
generator.writeEndArray();
} else {
generator.writeStartObject();
generator.writeObjectField("x", tbx);
generator.writeObjectField("y", tby);
generator.writeEndObject();
generator.writeEndArray();
}
}

protected void marshallTextAnnotation(TextAnnotation textAnnotation, BPMNPlane plane, JsonGenerator generator, int xOffset, int yOffset, String preProcessingData, Definitions def) throws JsonGenerationException, IOException{
Expand Down
Expand Up @@ -622,7 +622,77 @@ public void revisitDataObjects(Definitions def) {
ce.getDataOutputAssociation().add(dia);
}
}
}
}
if(as.getSourceRef() != null && as.getSourceRef() instanceof DataObject
&& as.getTargetRef() != null && (as.getTargetRef() instanceof SequenceFlow)) {
SequenceFlow sf = (SequenceFlow) as.getTargetRef();
if(sf.getSourceRef() != null && sf.getSourceRef() instanceof Activity && sf.getTargetRef() != null && sf.getTargetRef() instanceof Activity) {
Activity sourceElement = (Activity) sf.getSourceRef();
Activity targetElement = (Activity) sf.getTargetRef();
DataObject da = (DataObject) as.getSourceRef();


if(targetElement.getIoSpecification() == null) {
InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
targetElement.setIoSpecification(iospec);
}
if(targetElement.getIoSpecification().getInputSets() == null || targetElement.getIoSpecification().getInputSets().size() < 1) {
InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
targetElement.getIoSpecification().getInputSets().add(inset);
}
InputSet inSet = targetElement.getIoSpecification().getInputSets().get(0);
boolean foundDataInput = false;
for(DataInput dataInput : inSet.getDataInputRefs()) {
if(dataInput.getId().equals(targetElement.getId() + "_" + da.getId() + "Input")) {
foundDataInput = true;
}
}
if(!foundDataInput) {
DataInput d = Bpmn2Factory.eINSTANCE.createDataInput();
d.setId(targetElement.getId() + "_" + da.getId() + "Input");
d.setName(da.getId() + "Input");
targetElement.getIoSpecification().getDataInputs().add(d);
targetElement.getIoSpecification().getInputSets().get(0).getDataInputRefs().add(d);

DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
dia.setTargetRef(d);
dia.getSourceRef().add(da);
targetElement.getDataInputAssociations().add(dia);
}

if(sourceElement.getIoSpecification() == null) {
InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
sourceElement.setIoSpecification(iospec);
}

if(sourceElement.getIoSpecification().getOutputSets() == null || sourceElement.getIoSpecification().getOutputSets().size() < 1) {
OutputSet outSet = Bpmn2Factory.eINSTANCE.createOutputSet();
sourceElement.getIoSpecification().getOutputSets().add(outSet);
}

boolean foundDataOutput = false;
OutputSet outSet = sourceElement.getIoSpecification().getOutputSets().get(0);
for(DataOutput dataOut : outSet.getDataOutputRefs()) {
if(dataOut.getId().equals(sourceElement.getId() + "_" + da.getId() + "Output")) {
foundDataOutput = true;
}
}

if(!foundDataOutput) {
DataOutput d = Bpmn2Factory.eINSTANCE.createDataOutput();
d.setId(sourceElement.getId() + "_" + da.getId() + "Output");
d.setName(da.getId() + "Output");
sourceElement.getIoSpecification().getDataOutputs().add(d);
sourceElement.getIoSpecification().getOutputSets().get(0).getDataOutputRefs().add(d);

DataOutputAssociation doa = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
doa.getSourceRef().add(d);
doa.setTargetRef(da);
sourceElement.getDataOutputAssociations().add(doa);
}
}
}

}
}
}
Expand Down Expand Up @@ -1588,7 +1658,12 @@ private void reconnectFlows() {
for (Entry<Object, List<String>> entry : _outgoingFlows.entrySet()) {
for (String flowId : entry.getValue()) {
if (entry.getKey() instanceof SequenceFlow) { // if it is a sequence flow, we can tell its targets
((SequenceFlow) entry.getKey()).setTargetRef((FlowNode) _idMap.get(flowId));
if(_idMap.get(flowId) instanceof FlowNode) {
((SequenceFlow) entry.getKey()).setTargetRef((FlowNode) _idMap.get(flowId));
}
if(_idMap.get(flowId) instanceof Association) {
((Association) _idMap.get(flowId)).setTargetRef((SequenceFlow) entry.getKey());
}
} else if (entry.getKey() instanceof Association) {
((Association) entry.getKey()).setTargetRef((BaseElement) _idMap.get(flowId));
} else { // if it is a node, we can map it to its outgoing sequence flows
Expand Down

0 comments on commit 65017f4

Please sign in to comment.