use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class AbstractActivitiTestCase method createOneTaskTestProcess.
/**
* Since the 'one task process' is used everywhere the actual process content
* doesn't matter, instead of copying around the BPMN 2.0 xml one could use
* this method which gives a {@link BpmnModel} version of the same process back.
*/
public BpmnModel createOneTaskTestProcess() {
BpmnModel model = new BpmnModel();
org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
model.addProcess(process);
process.setId("oneTaskProcess");
process.setName("The one task process");
StartEvent startEvent = new StartEvent();
startEvent.setId("start");
process.addFlowElement(startEvent);
UserTask userTask = new UserTask();
userTask.setName("The Task");
userTask.setId("theTask");
userTask.setAssignee("kermit");
process.addFlowElement(userTask);
EndEvent endEvent = new EndEvent();
endEvent.setId("theEnd");
process.addFlowElement(endEvent);
process.addFlowElement(new SequenceFlow("start", "theTask"));
process.addFlowElement(new SequenceFlow("theTask", "theEnd"));
return model;
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class AbstractActivitiTestCase method deployOneTaskTestProcess.
/**
* Creates and deploys the one task process. See {@link #createOneTaskTestProcess()}.
*
* @return The process definition id (NOT the process definition key) of deployed one task process.
*/
public String deployOneTaskTestProcess() {
BpmnModel bpmnModel = createOneTaskTestProcess();
Deployment deployment = repositoryService.createDeployment().addBpmnModel("oneTasktest.bpmn20.xml", bpmnModel).deploy();
// For auto-cleanup
deploymentIdsForAutoCleanup.add(deployment.getId());
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
return processDefinition.getId();
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class DelegateHelper method getFlowElement.
/**
* Returns the current {@link FlowElement} where the {@link DelegateExecution} is currently at.
*/
public static FlowElement getFlowElement(DelegateExecution execution) {
BpmnModel bpmnModel = getBpmnModel(execution);
FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
if (flowElement == null) {
throw new ActivitiException("Could not find a FlowElement for activityId " + execution.getCurrentActivityId());
}
return flowElement;
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class ProcessDefinitionInfoComponent method initImage.
protected void initImage() {
processImageContainer = new VerticalLayout();
Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
processTitle.addStyleName(ExplorerLayout.STYLE_H3);
processImageContainer.addComponent(processTitle);
boolean didDrawImage = false;
if (ExplorerApp.get().isUseJavascriptDiagram()) {
try {
final InputStream definitionStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
if (!bpmnModel.getFlowLocationMap().isEmpty()) {
int maxX = 0;
int maxY = 0;
for (String key : bpmnModel.getLocationMap().keySet()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
double elementX = graphicInfo.getX() + graphicInfo.getWidth();
if (maxX < elementX) {
maxX = (int) elementX;
}
double elementY = graphicInfo.getY() + graphicInfo.getHeight();
if (maxY < elementY) {
maxY = (int) elementY;
}
}
// using panel for scrollbars
Panel imagePanel = new Panel();
imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
imagePanel.setWidth(100, UNITS_PERCENTAGE);
imagePanel.setHeight(100, UNITS_PERCENTAGE);
URL explorerURL = ExplorerApp.get().getURL();
URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId());
Embedded browserPanel = new Embedded("", new ExternalResource(url));
browserPanel.setType(Embedded.TYPE_BROWSER);
browserPanel.setWidth(maxX + 350 + "px");
browserPanel.setHeight(maxY + 220 + "px");
HorizontalLayout panelLayout = new HorizontalLayout();
panelLayout.setSizeUndefined();
imagePanel.setContent(panelLayout);
imagePanel.addComponent(browserPanel);
processImageContainer.addComponent(imagePanel);
didDrawImage = true;
}
} catch (Exception e) {
LOGGER.error("Error loading process diagram component", e);
}
}
if (didDrawImage == false) {
StreamResource diagram = null;
// Try generating process-image stream
if (processDefinition.getDiagramResourceName() != null) {
diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processDefinition, repositoryService);
}
if (diagram != null) {
Embedded embedded = new Embedded(null, diagram);
embedded.setType(Embedded.TYPE_IMAGE);
embedded.setSizeUndefined();
// using panel for scrollbars
Panel imagePanel = new Panel();
imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
imagePanel.setWidth(100, UNITS_PERCENTAGE);
imagePanel.setHeight(100, UNITS_PERCENTAGE);
HorizontalLayout panelLayout = new HorizontalLayout();
panelLayout.setSizeUndefined();
imagePanel.setContent(panelLayout);
imagePanel.addComponent(embedded);
processImageContainer.addComponent(imagePanel);
didDrawImage = true;
}
}
if (didDrawImage == false) {
Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
processImageContainer.addComponent(noImageAvailable);
}
addComponent(processImageContainer);
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class CallActivityTest method testInstantiateSuspendedChildProcess.
public void testInstantiateSuspendedChildProcess() throws Exception {
BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
suspendProcessDefinitions(childDeployment);
try {
ProcessInstance childProcessInstance = runtimeService.startProcessInstanceByKey("childProcess");
fail("Exception expected");
} catch (ActivitiException ae) {
assertTextPresent("Cannot start process instance. Process definition Child Process", ae.getMessage());
}
}
Aggregations