use of io.pravega.test.system.framework.metronome.model.v1.Artifact 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 io.pravega.test.system.framework.metronome.model.v1.Artifact in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallDataObject.
protected void marshallDataObject(DataObject dataObject, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> flowElementProperties) throws JsonGenerationException, IOException {
Map<String, Object> properties = new LinkedHashMap<String, Object>(flowElementProperties);
putDocumentationProperty(dataObject, properties);
if (dataObject.getName() != null && dataObject.getName().length() > 0) {
properties.put(NAME, StringEscapeUtils.unescapeXml(dataObject.getName()));
} else {
// we need a name, use id instead
properties.put(NAME, dataObject.getId());
}
// overwrite name if elementname extension element is present
String elementName = Utils.getMetaDataValue(dataObject.getExtensionValues(), "elementname");
if (elementName != null) {
properties.put(NAME, elementName);
}
if (dataObject.getItemSubjectRef().getStructureRef() != null && dataObject.getItemSubjectRef().getStructureRef().length() > 0) {
if (defaultTypesList.contains(dataObject.getItemSubjectRef().getStructureRef())) {
properties.put(STANDARDTYPE, dataObject.getItemSubjectRef().getStructureRef());
} else {
properties.put(CUSTOMTYPE, dataObject.getItemSubjectRef().getStructureRef());
}
}
Association outgoingAssociaton = findOutgoingAssociation(plane, dataObject);
Association incomingAssociation = null;
Process process = (Process) plane.getBpmnElement();
for (Artifact artifact : process.getArtifacts()) {
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getTargetRef() == dataObject) {
incomingAssociation = association;
}
}
}
if (outgoingAssociaton != null && incomingAssociation == null) {
properties.put(INPUT_OUTPUT, "Input");
}
if (outgoingAssociaton == null && incomingAssociation != null) {
properties.put(INPUT_OUTPUT, "Output");
}
marshallProperties(properties, generator);
generator.writeObjectFieldStart("stencil");
generator.writeObjectField("id", "DataObject");
generator.writeEndObject();
generator.writeArrayFieldStart("childShapes");
generator.writeEndArray();
generator.writeArrayFieldStart("outgoing");
List<Association> associations = findOutgoingAssociations(plane, dataObject);
if (associations != null) {
for (Association as : associations) {
generator.writeStartObject();
generator.writeObjectField("resourceId", as.getId());
generator.writeEndObject();
}
}
generator.writeEndArray();
Bounds bounds = ((BPMNShape) findDiagramElement(plane, dataObject)).getBounds();
generator.writeObjectFieldStart("bounds");
generator.writeObjectFieldStart("lowerRight");
generator.writeObjectField("x", bounds.getX() + bounds.getWidth() - xOffset);
generator.writeObjectField("y", bounds.getY() + bounds.getHeight() - yOffset);
generator.writeEndObject();
generator.writeObjectFieldStart("upperLeft");
generator.writeObjectField("x", bounds.getX() - xOffset);
generator.writeObjectField("y", bounds.getY() - yOffset);
generator.writeEndObject();
generator.writeEndObject();
}
use of io.pravega.test.system.framework.metronome.model.v1.Artifact in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallProcess.
protected void marshallProcess(Process process, Definitions def, JsonGenerator generator, String preProcessingData) throws JsonGenerationException, IOException {
BPMNPlane plane = null;
for (BPMNDiagram d : def.getDiagrams()) {
if (d != null) {
BPMNPlane p = d.getPlane();
if (p != null) {
if (p.getBpmnElement() == process) {
plane = p;
break;
}
}
}
}
if (plane == null) {
throw new IllegalArgumentException("Could not find BPMNDI information");
}
generator.writeArrayFieldStart("childShapes");
List<String> laneFlowElementsIds = new ArrayList<String>();
for (LaneSet laneSet : process.getLaneSets()) {
for (Lane lane : laneSet.getLanes()) {
// we only want to marshall lanes if we have the bpmndi info for them!
if (findDiagramElement(plane, lane) != null) {
laneFlowElementsIds.addAll(marshallLanes(lane, plane, generator, 0, 0, preProcessingData, def));
}
}
}
for (FlowElement flowElement : process.getFlowElements()) {
if (!laneFlowElementsIds.contains(flowElement.getId())) {
marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
}
}
for (Artifact artifact : process.getArtifacts()) {
marshallArtifact(artifact, plane, generator, 0, 0, preProcessingData, def);
}
generator.writeEndArray();
}
use of io.pravega.test.system.framework.metronome.model.v1.Artifact 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 io.pravega.test.system.framework.metronome.model.v1.Artifact in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method createSubProcessDiagram.
private void createSubProcessDiagram(BPMNPlane plane, FlowElement flowElement, BpmnDiFactory factory) {
SubProcess sp = (SubProcess) flowElement;
for (FlowElement subProcessFlowElement : sp.getFlowElements()) {
if (subProcessFlowElement instanceof SubProcess) {
createBpmnShapeForElement(factory, plane, subProcessFlowElement);
createSubProcessDiagram(plane, subProcessFlowElement, factory);
} else if (subProcessFlowElement instanceof FlowNode) {
createBpmnShapeForElement(factory, plane, subProcessFlowElement);
if (subProcessFlowElement instanceof BoundaryEvent) {
createDockersForBoundaryEvent((BoundaryEvent) subProcessFlowElement);
}
} else if (subProcessFlowElement instanceof SequenceFlow) {
createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) subProcessFlowElement);
}
}
if (sp.getArtifacts() != null) {
List<Association> incompleteAssociations = new ArrayList<Association>();
for (Artifact artifact : sp.getArtifacts()) {
// if (artifact instanceof TextAnnotation || artifact instanceof Group) {
if (artifact instanceof Group) {
createBpmnShapeForElement(factory, plane, artifact);
}
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getSourceRef() != null && association.getTargetRef() != null) {
createBpmnEdgeForAssociation(factory, plane, association);
} else {
incompleteAssociations.add(association);
}
}
}
if (!incompleteAssociations.isEmpty()) {
for (Association incompleteAssociation : incompleteAssociations) {
sp.getArtifacts().remove(incompleteAssociation);
}
}
}
}
Aggregations