use of org.activiti.workflow.simple.converter.WorkflowDefinitionConversion in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testTransitionProperty.
@Test
public void testTransitionProperty() throws Exception {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
AlfrescoTransitionsPropertyDefinition transition = new AlfrescoTransitionsPropertyDefinition();
transition.addEntry(new ListPropertyEntry("One", "One"));
transition.addEntry(new ListPropertyEntry("Two", "Two"));
humanStep.getForm().addFormProperty(transition);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
assertEquals(1L, model.getTypes().size());
M2Type taskType = model.getTypes().get(0);
assertEquals(1L, taskType.getPropertyOverrides().size());
assertEquals("bpm:outcomePropertyName", taskType.getPropertyOverrides().get(0).getName());
assertTrue(taskType.getPropertyOverrides().get(0).getDefaultValue().contains("step1transitions"));
assertEquals(1L, taskType.getProperties().size());
assertEquals(1L, model.getConstraints().size());
}
use of org.activiti.workflow.simple.converter.WorkflowDefinitionConversion in project Activiti by Activiti.
the class EditorProcessDefinitionDetailPanel method exportModel.
protected void exportModel() {
final FileResource stream = new FileResource(new File(""), ExplorerApp.get()) {
private static final long serialVersionUID = 1L;
@Override
public DownloadStream getStream() {
DownloadStream ds = null;
try {
byte[] bpmnBytes = null;
String filename = null;
if (SimpleTableEditorConstants.TABLE_EDITOR_CATEGORY.equals(modelData.getCategory())) {
WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter().readWorkflowDefinition(repositoryService.getModelEditorSource(modelData.getId()));
filename = workflowDefinition.getName();
WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
} else {
JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
BpmnModel model = jsonConverter.convertToBpmnModel(editorNode);
filename = model.getMainProcess().getId() + ".bpmn20.xml";
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
}
ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
ds = new DownloadStream(in, "application/xml", filename);
// Need a file download POPUP
ds.setParameter("Content-Disposition", "attachment; filename=" + filename);
} catch (Exception e) {
LOGGER.error("failed to export model to BPMN XML", e);
ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_TOXML_FAILED, e);
}
return ds;
}
};
stream.setCacheTime(0);
ExplorerApp.get().getMainWindow().open(stream);
}
use of org.activiti.workflow.simple.converter.WorkflowDefinitionConversion in project Activiti by Activiti.
the class EditorProcessDefinitionDetailPanel method deploySimpleTableEditorModel.
protected void deploySimpleTableEditorModel(final byte[] model) {
final DeployModelPopupWindow deployModelPopupWindow = new DeployModelPopupWindow(modelData);
deployModelPopupWindow.getDeployButton().addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
// Convert to simple workflow definition
WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter().readWorkflowDefinition(model);
// Update model name
modelData.setName(deployModelPopupWindow.getProcessName());
workflowDefinition.setName(deployModelPopupWindow.getProcessName());
WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
conversion.convert();
// Deploy to database
byte[] bpmnBytes = null;
try {
bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
// Generate reports
if (deployModelPopupWindow.isGenerateReports()) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
ReportingUtil.generateTaskDurationReport(processDefinition.getId());
}
// Close popup and show new deployment
deployModelPopupWindow.closePopupWindow();
ExplorerApp.get().getViewManager().showDeploymentPage(deployment.getId());
} catch (UnsupportedEncodingException e) {
ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_TOXML_FAILED, e);
deployModelPopupWindow.closePopupWindow();
}
}
});
deployModelPopupWindow.showPopupWindow();
}
Aggregations