本文整理了Java中org.camunda.bpm.engine.RepositoryService.getBpmnModelInstance
方法的一些代码示例,展示了RepositoryService.getBpmnModelInstance
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryService.getBpmnModelInstance
方法的具体详情如下:
包路径:org.camunda.bpm.engine.RepositoryService
类名称:RepositoryService
方法名:getBpmnModelInstance
[英]Returns the BpmnModelInstance for the given processDefinitionId.
[中]返回给定processDefinitionId的BpmnModelInstance。
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void getBpmnModelInstanceWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertThat(modelInstance, notNullValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void getBpmnModelInstanceDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertThat(modelInstance, notNullValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void failToGetBpmnModelInstanceNoAuthenticatedTenants() {
identityService.setAuthentication("user", null, null);
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot get the process definition");
repositoryService.getBpmnModelInstance(processDefinitionId);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testGetBpmnModelInstance() {
// given
String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
// when
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
// then
assertNotNull(modelInstance);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void shouldReturnBpmnModelInstance() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(TEST_PROCESS)
.singleResult();
BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(processDefinition.getId());
Assert.assertNotNull(bpmnModelInstance);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = "org/camunda/bpm/engine/test/repository/one.bpmn20.xml")
public void testRepositoryService() {
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_KEY).singleResult().getId();
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertNotNull(modelInstance);
Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
assertEquals(2, events.size());
Collection<ModelElementInstance> sequenceFlows = modelInstance.getModelElementsByType(modelInstance.getModel().getType(SequenceFlow.class));
assertEquals(1, sequenceFlows.size());
StartEvent startEvent = modelInstance.getModelElementById("start");
assertNotNull(startEvent);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testGetBpmnModelInstanceWithoutAuthorizations() {
// given
String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
try {
// when
repositoryService.getBpmnModelInstance(processDefinitionId);
fail("Exception expected: It should not be possible to get the bpmn model instance");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(READ.getName(), message);
assertTextPresent(ONE_TASK_PROCESS_KEY, message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
代码示例来源:origin: com.camunda.consulting.util/camunda-util-demo-data-generator
protected StatisticalDistribution createDistributionForElement(ProcessInstance pi, String id) {
try {
BaseElement taskElement = engine.getRepositoryService().getBpmnModelInstance(pi.getProcessDefinitionId()).getModelElementById(id);
// Default = 10 minutes each
double durationMean = DemoModelInstrumentator.readCamundaProperty(taskElement, "durationMean").flatMap(this::parseTime).orElse(600.0);
double durationStandardDeviation = DemoModelInstrumentator.readCamundaProperty(taskElement, "durationSd").flatMap(this::parseTime).orElse(0.0);
StatisticalDistribution distribution = new StatisticalDistribution(durationMean, durationStandardDeviation);
return distribution;
} catch (Exception ex) {
throw new RuntimeException("Could not read distribution for element '" + id + "' of process definition '" + pi.getProcessDefinitionId() + "'", ex);
}
}
代码示例来源:origin: com.camunda.consulting.util/camunda-util-demo-data-generator
public static long autoGenerateFor(ProcessEngine engine, ProcessDefinition processDefinition, ProcessApplicationReference processApplicationReference,
String... additionalModelKeys) {
log.info("check auto generation for " + processDefinition);
BpmnModelInstance modelInstance = engine.getRepositoryService().getBpmnModelInstance(processDefinition.getId());
String numberOfDaysInPast = findProperty(modelInstance, "simulateNumberOfDaysInPast").orElse("30");
String timeBetweenStartsBusinessDaysMean = findProperty(modelInstance, "simulateTimeBetweenStartsBusinessDaysMean").orElse("3600");
String timeBetweenStartsBusinessDaysSd = findProperty(modelInstance, "simulateTimeBetweenStartsBusinessDaysSd").orElse("0");
String startBusinessDayAt = findProperty(modelInstance, "simulateStartBusinessDayAt").orElse("8:00");
String endBusinessDayAt = findProperty(modelInstance, "simulateEndBusinessDayAt").orElse("18:00");
String includeWeekend = findProperty(modelInstance, "simulateIncludeWeekend").orElse("false");
boolean runAlways = findProperty(modelInstance, "simulateRunAlways").orElse("false").toLowerCase().equals("true");
log.info("simulation properties set - auto generation applied (" + numberOfDaysInPast + " days in past, time between mean: "
+ timeBetweenStartsBusinessDaysMean + " and Standard Deviation: " + timeBetweenStartsBusinessDaysSd);
return new TimeAwareDemoGenerator(engine, processApplicationReference) //
.processDefinitionKey(processDefinition.getKey()) //
.additionalModelKeys(additionalModelKeys) //
.numberOfDaysInPast(Integer.valueOf(numberOfDaysInPast)) //
.timeBetweenStartsBusinessDays(timeBetweenStartsBusinessDaysMean, timeBetweenStartsBusinessDaysSd) //
.startTimeBusinessDay(startBusinessDayAt) //
.endTimeBusinessDay(endBusinessDayAt) //
.includeWeekend(includeWeekend.toLowerCase().equals("true")) //
.runAlways(runAlways) //
.run();
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Test
public void getBpmnModelInstanceWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertThat(modelInstance, notNullValue());
}
代码示例来源:origin: org.camunda.bpm.extension/camunda-bpm-process-test-coverage
/**
* Constructor assembling a pristine process coverage object from the
* process definition and BPMN model information retrieved from the process
* engine.
*
* @param processEngine
* @param processDefinition
*/
public ProcessCoverage(ProcessEngine processEngine, ProcessDefinition processDefinition) {
this.processDefinition = processDefinition;
final BpmnModelInstance modelInstance = processEngine.getRepositoryService().getBpmnModelInstance(
getProcessDefinitionId());
definitionFlowNodes = getExecutableFlowNodes(modelInstance.getModelElementsByType(FlowNode.class));
definitionSequenceFlows = getExecutableSequenceNodes(modelInstance.getModelElementsByType(SequenceFlow.class));
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Test
public void getBpmnModelInstanceDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertThat(modelInstance, notNullValue());
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
public void testGetBpmnModelInstance() {
// given
String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
// when
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
// then
assertNotNull(modelInstance);
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Test
public void failToGetBpmnModelInstanceNoAuthenticatedTenants() {
identityService.setAuthentication("user", null, null);
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot get the process definition");
repositoryService.getBpmnModelInstance(processDefinitionId);
}
代码示例来源:origin: org.camunda.bpm.extension/camunda-bpm-process-test-coverage
/**
* Events aren't reported like SequenceFlows and Activities, so we need
* special handling. If a sequence flow has an event as the source or the
* target, we add it to the coverage. It's pretty straight forward if a
* sequence flow is active, then it's source has been covered anyway and it
* will most definitely arrive at its target.
*
* @param transitionId
* @param processDefinition
* @param repositoryService
*/
private void handleEvent(String transitionId, ProcessDefinition processDefinition,
RepositoryService repositoryService) {
final BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinition.getId());
final ModelElementInstance modelElement = modelInstance.getModelElementById(transitionId);
if (modelElement.getElementType().getInstanceType() == SequenceFlow.class) {
final SequenceFlow sequenceFlow = (SequenceFlow) modelElement;
// If there is an event at the sequence flow source add it to the
// coverage
final FlowNode source = sequenceFlow.getSource();
addEventToCoverage(processDefinition, source);
// If there is an event at the sequence flow target add it to the
// coverage
final FlowNode target = sequenceFlow.getTarget();
addEventToCoverage(processDefinition, target);
}
}
代码示例来源:origin: com.camunda.consulting.util/camunda-util-demo-data-generator
BpmnModelInstance bpmn = engine.getRepositoryService().getBpmnModelInstance(processDefinition.getId());
Process process = bpmn.getModelElementById(processDefinitionKey);
Collection<StartEvent> startEvents = process.getChildElementsByType(StartEvent.class);
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Deployment(resources = "org/camunda/bpm/engine/test/repository/one.bpmn20.xml")
public void testRepositoryService() {
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_KEY).singleResult().getId();
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertNotNull(modelInstance);
Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
assertEquals(2, events.size());
Collection<ModelElementInstance> sequenceFlows = modelInstance.getModelElementsByType(modelInstance.getModel().getType(SequenceFlow.class));
assertEquals(1, sequenceFlows.size());
StartEvent startEvent = modelInstance.getModelElementById("start");
assertNotNull(startEvent);
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
public void testGetBpmnModelInstanceWithoutAuthorizations() {
// given
String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
try {
// when
repositoryService.getBpmnModelInstance(processDefinitionId);
fail("Exception expected: It should not be possible to get the bpmn model instance");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(READ.getName(), message);
assertTextPresent(ONE_TASK_PROCESS_KEY, message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
内容来源于网络,如有侵权,请联系作者删除!