use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method findOutgoingAssociation.
protected Association findOutgoingAssociation(BPMNPlane plane, BaseElement baseElement) {
Association result = _diagramAssociations.get(baseElement.getId());
if (result != null) {
return result;
}
if (!(plane.getBpmnElement() instanceof Process)) {
throw new IllegalArgumentException("Don't know how to get associations from a non-Process Diagram");
}
Process process = (Process) plane.getBpmnElement();
for (Artifact artifact : process.getArtifacts()) {
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getSourceRef() == baseElement) {
_diagramAssociations.put(baseElement.getId(), association);
return association;
}
}
}
return null;
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method findOutgoingAssociations.
protected List<Association> findOutgoingAssociations(BPMNPlane plane, BaseElement baseElement) {
List<Association> retList = new ArrayList<Association>();
if (!(plane.getBpmnElement() instanceof Process)) {
throw new IllegalArgumentException("Don't know how to get associations from a non-Process Diagram");
}
Process process = (Process) plane.getBpmnElement();
for (Artifact artifact : process.getArtifacts()) {
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getSourceRef() == baseElement) {
retList.add(association);
}
}
}
return retList;
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyOnEntryActions.
protected void applyOnEntryActions(BaseElement element, Map<String, String> properties) {
if (properties.get("onentryactions") != null && properties.get("onentryactions").length() > 0) {
ScriptTypeListValue onEntryActions = new ScriptTypeListTypeSerializer().parse(properties.get("onentryactions"));
if (!onEntryActions.isEmpty()) {
ScriptTypeValue onEntryAction = onEntryActions.getValues().get(0);
if (onEntryAction.getScript() != null && !onEntryAction.getScript().isEmpty()) {
OnEntryScriptType onEntryScript = DroolsFactory.eINSTANCE.createOnEntryScriptType();
onEntryScript.setScript(wrapInCDATABlock(onEntryAction.getScript()));
String scriptLanguage = Utils.getScriptLanguageFormat(onEntryAction.getLanguage());
if (scriptLanguage == null) {
// default to java
scriptLanguage = "http://www.java.com/java";
}
onEntryScript.setScriptFormat(scriptLanguage);
if (element.getExtensionValues() == null || element.getExtensionValues().size() < 1) {
ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
element.getExtensionValues().add(extensionElement);
}
FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, onEntryScript);
element.getExtensionValues().get(0).getValue().add(extensionElementEntry);
}
}
}
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method updateEdgeBoundsInLanes.
public void updateEdgeBoundsInLanes(Definitions def, BPMNPlane plane, BPMNEdge edge, BaseElement ele) {
if (ele instanceof SequenceFlow) {
SequenceFlow sq = (SequenceFlow) ele;
// update the source and target on BPMNEdge
if (sq.getSourceRef() != null) {
edge.setSourceElement(getBPMNShapeForElement(sq.getSourceRef(), plane));
}
if (sq.getTargetRef() != null) {
edge.setTargetElement(getBPMNShapeForElement(sq.getTargetRef(), plane));
}
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
if (sq.getSourceRef() != null && sq.getTargetRef() != null) {
if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
for (LaneSet ls : process.getLaneSets()) {
for (Lane newLane : ls.getLanes()) {
List<FlowNode> laneFlowNodes = newLane.getFlowNodeRefs();
Bounds laneBounds = getBoundsForElement(newLane, plane);
for (FlowNode newFlowNode : laneFlowNodes) {
if (newFlowNode.getId().equals(sq.getSourceRef().getId())) {
List<DiagramElement> diagramElements = plane.getPlaneElement();
for (DiagramElement dia : diagramElements) {
if (dia instanceof BPMNShape) {
BPMNShape shape = (BPMNShape) dia;
if (shape.getBpmnElement().getId().equals(sq.getSourceRef().getId())) {
Bounds eleBounds = shape.getBounds();
List<Point> edgePoints = edge.getWaypoint();
if (edgePoints != null && edgePoints.size() > 1) {
if (eleBounds != null) {
Point first = edgePoints.get(0);
first.setX(first.getX() + laneBounds.getX());
first.setY(first.getY() + laneBounds.getY());
}
}
}
}
}
} else if (newFlowNode.getId().equals(sq.getTargetRef().getId())) {
List<DiagramElement> diagramElements = plane.getPlaneElement();
for (DiagramElement dia : diagramElements) {
if (dia instanceof BPMNShape) {
BPMNShape shape = (BPMNShape) dia;
if (shape.getBpmnElement().getId().equals(sq.getTargetRef().getId())) {
Bounds eleBounds = shape.getBounds();
List<Point> edgePoints = edge.getWaypoint();
if (edgePoints != null && edgePoints.size() > 1) {
if (eleBounds != null) {
Point last = edgePoints.get(edgePoints.size() - 1);
last.setX(last.getX() + laneBounds.getX());
last.setY(last.getY() + laneBounds.getY());
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocess.
public void updateShapeBoundsInSubprocess(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
boolean foundInSubprocess = false;
for (FlowElement subEle : sub.getFlowElements()) {
if (subEle.getId().equals(ele.getId())) {
foundInSubprocess = true;
Bounds subEleBounds = getBoundsForElement(subEle, plane);
if (subEleBounds != null) {
subEleBounds.setX(subEleBounds.getX() + parentX);
subEleBounds.setY(subEleBounds.getY() + parentY);
}
}
}
if (!foundInSubprocess) {
for (FlowElement subEle : sub.getFlowElements()) {
if (subEle instanceof SubProcess) {
Bounds subEleBounds = getBoundsForElement(subEle, plane);
updateShapeBoundsInSubprocess(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
}
}
}
}
Aggregations