use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshaller method marshall.
@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
LOG.debug("Starting diagram marshalling...");
Bpmn2Resource resource = createBpmn2Resource();
// we start converting from the root, then pull out the result
DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
Definitions definitions = definitionsConverter.toDefinitions();
resource.getContents().add(definitions);
LOG.debug("Diagram marshalling completed successfully.");
String outputString = renderToString(resource);
LOG.trace(outputString);
return outputString;
}
use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.
the class BaseDirectDiagramMarshaller method createBpmn2Resource.
private Bpmn2Resource createBpmn2Resource() {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactory());
Bpmn2Resource resource = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(resource);
return resource;
}
use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method unmarshall.
/**
* NOTE: This method has been set protected for Stunner support. Stunner bpmn implementation provides a custom JsonParser that
* is used instead of the one used in jbpm-designer-backend.
* <p>
* Start unmarshalling using the parser.
* @param parser
* @param preProcessingData
* @return the root element of a bpmn2 document.
* @throws JsonParseException
* @throws IOException
*/
protected Bpmn2Resource unmarshall(JsonParser parser, String preProcessingData) throws JsonParseException, IOException {
try {
// open the object
parser.nextToken();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(bpmn2);
_currentResource = bpmn2;
if (preProcessingData == null || preProcessingData.length() < 1) {
preProcessingData = "ReadOnlyService";
}
// do the unmarshalling now:
Definitions def = (Definitions) unmarshallItem(parser, preProcessingData);
def.setExporter("jBPM Designer");
def.setExporterVersion("6.2.0");
revisitUserTasks(def);
revisitServiceTasks(def);
revisitMessages(def);
revisitCatchEvents(def);
revisitThrowEvents(def);
revisitLanes(def);
revisitSubProcessItemDefs(def);
revisitArtifacts(def);
revisitGroups(def);
revisitTaskAssociations(def);
revisitSendReceiveTasks(def);
reconnectFlows();
revisitGateways(def);
revisitCatchEventsConvertToBoundary(def);
revisitBoundaryEventsPositions(def);
createDiagram(def);
updateIDs(def);
revisitDataObjects(def);
revisitAssociationsIoSpec(def);
revisitWsdlImports(def);
revisitMultiInstanceTasks(def);
addSimulation(def);
revisitItemDefinitions(def);
revisitProcessDoc(def);
revisitDI(def);
revisitSignalRef(def);
orderDiagramElements(def);
// return def;
_currentResource.getContents().add(def);
return _currentResource;
} catch (Exception e) {
_logger.error(e.getMessage());
return _currentResource;
} finally {
parser.close();
_objMap.clear();
_idMap.clear();
_outgoingFlows.clear();
_sequenceFlowTargets.clear();
_bounds.clear();
_currentResource = null;
}
}
use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshaller method createBpmn2Resource.
private Bpmn2Resource createBpmn2Resource() {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
Bpmn2Resource resource = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(resource);
return resource;
}
use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.
the class BaseDirectDiagramMarshaller method marshall.
@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
LOG.debug("Starting diagram marshalling...");
Bpmn2Resource resource = createBpmn2Resource();
// we start converting from the root, then pull out the result
PropertyWriterFactory propertyWriterFactory = new PropertyWriterFactory();
DefinitionsConverter definitionsConverter = new DefinitionsConverter(new ConverterFactory(new DefinitionsBuildingContext(diagram.getGraph(), getDiagramClass()), propertyWriterFactory), propertyWriterFactory);
Definitions definitions = definitionsConverter.toDefinitions();
resource.getContents().add(definitions);
LOG.debug("Diagram marshalling completed successfully.");
String outputString = renderToString(resource);
LOG.trace(outputString);
return outputString;
}
Aggregations