use of org.kie.workbench.common.stunner.bpmn.backend.legacy.Bpmn2JsonUnmarshaller in project kie-wb-common by kiegroup.
the class DefaultProfileImpl method createMarshaller.
public IDiagramMarshaller createMarshaller() {
return new IDiagramMarshaller() {
public String parseModel(String jsonModel, String preProcessingData) {
Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
// Definitions def;
Resource res;
try {
res = unmarshaller.unmarshall(jsonModel, preProcessingData);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Map saveMap = new HashMap();
saveMap.put(XMLResource.OPTION_ENCODING, "UTF-8");
saveMap.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
saveMap.put(XMLResource.OPTION_DISABLE_NOTIFY, true);
saveMap.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_RECORD);
res.save(outputStream, saveMap);
return outputStream.toString();
} catch (JsonParseException e) {
_logger.error(e.getMessage(), e);
} catch (IOException e) {
_logger.error(e.getMessage(), e);
}
return "";
}
public Definitions getDefinitions(String jsonModel, String preProcessingData) {
try {
Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
JBPMBpmn2ResourceImpl res = (JBPMBpmn2ResourceImpl) unmarshaller.unmarshall(jsonModel, preProcessingData);
return (Definitions) res.getContents().get(0);
} catch (JsonParseException e) {
_logger.error(e.getMessage(), e);
} catch (IOException e) {
_logger.error(e.getMessage(), e);
}
return null;
}
public Resource getResource(String jsonModel, String preProcessingData) {
try {
Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
return (JBPMBpmn2ResourceImpl) unmarshaller.unmarshall(jsonModel, preProcessingData);
} catch (JsonParseException e) {
_logger.error(e.getMessage(), e);
} catch (IOException e) {
_logger.error(e.getMessage(), e);
}
return null;
}
};
}
Aggregations