use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class EventOverviewPanel method initProcessInstances.
protected void initProcessInstances() {
HorizontalLayout instancesHeader = new HorizontalLayout();
instancesHeader.setSpacing(false);
instancesHeader.setMargin(false);
instancesHeader.setWidth(100, UNITS_PERCENTAGE);
instancesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
addDetailComponent(instancesHeader);
initProcessInstanceTitle(instancesHeader);
HorizontalLayout selectLayout = new HorizontalLayout();
selectLayout.setSpacing(true);
selectLayout.setMargin(true);
selectLayout.setWidth(50, UNITS_PERCENTAGE);
addDetailComponent(selectLayout);
definitionSelect = new NativeSelect(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS));
definitionSelect.setImmediate(true);
for (ProcessDefinition definition : definitionList) {
definitionSelect.addItem(definition.getId());
definitionSelect.setItemCaption(definition.getId(), definition.getName());
}
definitionSelect.addListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void valueChange(ValueChangeEvent event) {
if (definitionSelect.getValue() != null) {
String selectedDefinitionId = (String) definitionSelect.getValue();
ExplorerApp.get().setCrystalBallCurrentDefinitionId(selectedDefinitionId);
refreshInstances(selectedDefinitionId);
}
}
});
selectLayout.addComponent(definitionSelect);
replayButton = new Button(i18nManager.getMessage(Messages.CRYSTALBALL_BUTTON_REPLAY));
replayButton.setEnabled(false);
replayButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
if (instanceTable.getValue() != null) {
String processInstanceId = (String) instanceTable.getValue();
ExplorerApp.get().setCrystalBallCurrentInstanceId(processInstanceId);
List<EventLogEntry> eventLogEntries = managementService.getEventLogEntriesByProcessInstanceId(processInstanceId);
if (eventLogEntries == null || eventLogEntries.isEmpty())
return;
EventLogTransformer transformer = new EventLogTransformer(getTransformers());
simulationEvents = transformer.transform(eventLogEntries);
ExplorerApp.get().setCrystalBallSimulationEvents(simulationEvents);
SimpleEventCalendar eventCalendar = new SimpleEventCalendar(ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
eventCalendar.addEvents(simulationEvents);
// replay process instance run
simulationDebugger = new ReplaySimulationRun(ProcessEngines.getDefaultProcessEngine(), eventCalendar, getReplayHandlers(processInstanceId));
ExplorerApp.get().setCrystalBallSimulationDebugger(simulationDebugger);
simulationDebugger.init(new NoExecutionVariableScope());
simulationDebugger.step();
// replay process was started
List<HistoricProcessInstance> replayProcessInstanceList = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(SIMULATION_BUSINESS_KEY).orderByProcessInstanceStartTime().desc().list();
if (replayProcessInstanceList != null && !replayProcessInstanceList.isEmpty()) {
replayHistoricInstance = replayProcessInstanceList.get(0);
}
refreshEvents();
}
}
});
selectLayout.addComponent(replayButton);
selectLayout.setComponentAlignment(replayButton, Alignment.MIDDLE_LEFT);
instanceLayout = new HorizontalLayout();
instanceLayout.setWidth(100, UNITS_PERCENTAGE);
addDetailComponent(instanceLayout);
initInstancesTable();
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionFormPropertyRenderer method getPropertyField.
public Field getPropertyField(FormProperty formProperty) {
ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty));
comboBox.setRequired(formProperty.isRequired());
comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
comboBox.setEnabled(formProperty.isWritable());
List<ProcessDefinition> processDefinitions = ProcessEngines.getDefaultProcessEngine().getRepositoryService().createProcessDefinitionQuery().orderByProcessDefinitionName().asc().orderByProcessDefinitionVersion().asc().list();
for (ProcessDefinition processDefinition : processDefinitions) {
comboBox.addItem(processDefinition.getId());
String name = processDefinition.getName() + " (v" + processDefinition.getVersion() + ")";
comboBox.setItemCaption(processDefinition.getId(), name);
}
// Select first
if (!processDefinitions.isEmpty()) {
comboBox.setNullSelectionAllowed(false);
comboBox.select(processDefinitions.get(0).getId());
}
return comboBox;
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class IntegrationAutoConfigurationTest method testLaunchingGatewayProcessDefinition.
@Test
public void testLaunchingGatewayProcessDefinition() throws Exception {
AnnotationConfigApplicationContext applicationContext = this.context(InboundGatewayConfiguration.class);
RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class);
ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
Assert.assertNotNull("the process engine should not be null", processEngine);
Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
String integrationGatewayProcess = "integrationGatewayProcess";
List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery().processDefinitionKey(integrationGatewayProcess).list();
ProcessDefinition processDefinition = processDefinitionList.iterator().next();
Assert.assertEquals(processDefinition.getKey(), integrationGatewayProcess);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("customerId", 232);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(integrationGatewayProcess, vars);
Assert.assertNotNull("the processInstance should not be null", processInstance);
org.junit.Assert.assertTrue(applicationContext.getBean(InboundGatewayConfiguration.AnalysingService.class).getStringAtomicReference().get().equals(projectId));
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessEngineMvcEndpoint method processDefinitionDiagram.
/**
* Look up the process definition by key. For example,
* this is <A href="http://localhost:8080/activiti/processes/fulfillmentProcess">process-diagram for</A>
* a process definition named {@code fulfillmentProcess}.
*/
@RequestMapping(value = "/processes/{processDefinitionKey:.*}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public ResponseEntity processDefinitionDiagram(@PathVariable String processDefinitionKey) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).latestVersion().singleResult();
if (processDefinition == null) {
return ResponseEntity.status(NOT_FOUND).body(null);
}
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
if (bpmnModel.getLocationMap().size() == 0) {
BpmnAutoLayout autoLayout = new BpmnAutoLayout(bpmnModel);
autoLayout.execute();
}
InputStream is = processDiagramGenerator.generateJpgDiagram(bpmnModel);
return ResponseEntity.ok(new InputStreamResource(is));
}
use of org.activiti.engine.repository.ProcessDefinition in project alfresco-remote-api by Alfresco.
the class ProcessesImpl method createProcessInfo.
protected ProcessInfo createProcessInfo(HistoricProcessInstance processInstance) {
ProcessInfo processInfo = new ProcessInfo(processInstance);
ProcessDefinition definitionEntity = activitiProcessEngine.getRepositoryService().getProcessDefinition(processInstance.getProcessDefinitionId());
processInfo.setProcessDefinitionKey(getLocalProcessDefinitionKey(definitionEntity.getKey()));
return processInfo;
}
Aggregations