use of org.activiti.bpmn.model.BpmnModel in project tutorials-java by Artister.
the class ModelController method deployUploadedFile.
@ApiOperation(value = "上传一个已有模型")
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public void deployUploadedFile(@RequestParam("uploadfile") MultipartFile uploadfile) {
InputStreamReader in = null;
try {
try {
boolean validFile = false;
String fileName = uploadfile.getOriginalFilename();
if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
validFile = true;
XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
in = new InputStreamReader(new ByteArrayInputStream(uploadfile.getBytes()), "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
if (bpmnModel.getMainProcess() == null || bpmnModel.getMainProcess().getId() == null) {
// notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED,
// i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION));
System.out.println("err1");
} else {
if (bpmnModel.getLocationMap().isEmpty()) {
// notificationManager.showErrorNotification(Messages.MODEL_IMPORT_INVALID_BPMNDI,
// i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMNDI_EXPLANATION));
System.out.println("err2");
} else {
String processName = null;
if (StringUtils.isNotEmpty(bpmnModel.getMainProcess().getName())) {
processName = bpmnModel.getMainProcess().getName();
} else {
processName = bpmnModel.getMainProcess().getId();
}
Model modelData;
modelData = repositoryService.newModel();
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processName);
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName(processName);
repositoryService.saveModel(modelData);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
ObjectNode editorNode = jsonConverter.convertToJson(bpmnModel);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
}
}
} else {
// notificationManager.showErrorNotification(Messages.MODEL_IMPORT_INVALID_FILE,
// i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_FILE_EXPLANATION));
System.out.println("err3");
}
} catch (Exception e) {
String errorMsg = e.getMessage().replace(System.getProperty("line.separator"), "<br/>");
// notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED, errorMsg);
System.out.println("err4");
}
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
// notificationManager.showErrorNotification("Server-side error", e.getMessage());
System.out.println("err5");
}
}
}
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class CustomExtensionsConverterTest method convertXMLToModel.
@Test
public void convertXMLToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class EndEventConverterTest method convertXMLToModel.
@Test
public void convertXMLToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class EndEventConverterTest method convertModelToXML.
@Test
public void convertModelToXML() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(exportAndReadXMLFile(bpmnModel));
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class FormPropertiesConverterTest method convertJsonToModel.
@Test
public void convertJsonToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
Aggregations