use of org.activiti.engine.impl.util.io.InputStreamSource in project Activiti by Activiti.
the class ImportExportTest method exportAndReadXMLFile.
protected BpmnModel exportAndReadXMLFile(BpmnModel bpmnModel) throws Exception {
byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel, processEngineConfiguration.getXmlEncoding());
StreamSource xmlSource = new InputStreamSource(new ByteArrayInputStream(xml));
BpmnModel parsedModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
return parsedModel;
}
use of org.activiti.engine.impl.util.io.InputStreamSource in project Activiti by Activiti.
the class ImportExportTest method readXMLFile.
protected BpmnModel readXMLFile() throws Exception {
InputStream xmlStream = this.getClass().getClassLoader().getResourceAsStream(getResource());
StreamSource xmlSource = new InputStreamSource(xmlStream);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
return bpmnModel;
}
use of org.activiti.engine.impl.util.io.InputStreamSource in project Activiti by Activiti.
the class EventJavaTest method testStartEventWithExecutionListener.
public void testStartEventWithExecutionListener() throws Exception {
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId("simpleProcess");
process.setName("Very simple process");
bpmnModel.getProcesses().add(process);
StartEvent startEvent = new StartEvent();
startEvent.setId("startEvent1");
TimerEventDefinition timerDef = new TimerEventDefinition();
timerDef.setTimeDuration("PT5M");
startEvent.getEventDefinitions().add(timerDef);
ActivitiListener listener = new ActivitiListener();
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
listener.setImplementation("${test}");
listener.setEvent("end");
startEvent.getExecutionListeners().add(listener);
process.addFlowElement(startEvent);
UserTask task = new UserTask();
task.setId("reviewTask");
task.setAssignee("kermit");
process.addFlowElement(task);
SequenceFlow flow1 = new SequenceFlow();
flow1.setId("flow1");
flow1.setSourceRef("startEvent1");
flow1.setTargetRef("reviewTask");
process.addFlowElement(flow1);
EndEvent endEvent = new EndEvent();
endEvent.setId("endEvent1");
process.addFlowElement(endEvent);
byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));
Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
repositoryService.deleteDeployment(deployment.getId());
}
use of org.activiti.engine.impl.util.io.InputStreamSource in project Activiti by Activiti.
the class CallActivityTest method loadBPMNModel.
protected BpmnModel loadBPMNModel(String bpmnModelFilePath) throws Exception {
InputStream xmlStream = this.getClass().getClassLoader().getResourceAsStream(bpmnModelFilePath);
StreamSource xmlSource = new InputStreamSource(xmlStream);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
return bpmnModel;
}
use of org.activiti.engine.impl.util.io.InputStreamSource in project Activiti by Activiti.
the class AbstractAutoDeploymentStrategy method validateModel.
protected boolean validateModel(Resource resource, final RepositoryService repositoryService) {
String resourceName = determineResourceName(resource);
if (isProcessDefinitionResource(resourceName)) {
try {
BpmnXMLConverter converter = new BpmnXMLConverter();
BpmnModel bpmnModel = converter.convertToBpmnModel(new InputStreamSource(resource.getInputStream()), true, false);
List<ValidationError> validationErrors = repositoryService.validateProcess(bpmnModel);
if (validationErrors != null && !validationErrors.isEmpty()) {
StringBuilder warningBuilder = new StringBuilder();
StringBuilder errorBuilder = new StringBuilder();
for (ValidationError error : validationErrors) {
if (error.isWarning()) {
warningBuilder.append(error.toString());
warningBuilder.append("\n");
} else {
errorBuilder.append(error.toString());
errorBuilder.append("\n");
}
// Write out warnings (if any)
if (warningBuilder.length() > 0) {
LOGGER.warn("Following warnings encountered during process validation: " + warningBuilder.toString());
}
if (errorBuilder.length() > 0) {
LOGGER.error("Errors while parsing:\n" + errorBuilder.toString());
return false;
}
}
}
} catch (Exception e) {
LOGGER.error("Error parsing XML", e);
return false;
}
}
return true;
}
Aggregations