use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class BlueprintBasicTest method exportedServices.
@Test
public void exportedServices() throws Exception {
assertNotNull(processEngine);
assertNotNull(repositoryService);
// wait for deployment to be done
Thread.sleep(5000);
Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
assertEquals("org.activiti.osgi.example", deployment.getName());
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertEquals("osgiProcess", processDefinition.getKey());
}
use of org.activiti.engine.repository.Deployment 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.repository.Deployment in project Activiti by Activiti.
the class SerializableVariablesDiabledTest method removeUsers.
@After
public void removeUsers() {
identityService.deleteMembership(testUserId, testGroupId);
identityService.deleteGroup(testGroupId);
identityService.deleteUser(testUserId);
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ProcessDefinitionCollectionResourceTest method testGetProcessDefinitions.
/**
* Test getting process definitions.
* GET repository/process-definitions
*/
public void testGetProcessDefinitions() throws Exception {
try {
Deployment firstDeployment = repositoryService.createDeployment().name("Deployment 1").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml").deploy();
Deployment secondDeployment = repositoryService.createDeployment().name("Deployment 2").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/rest/service/api/repository/twoTaskProcess.bpmn20.xml").deploy();
Deployment thirdDeployment = repositoryService.createDeployment().name("Deployment 3").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcessWithDi.bpmn20.xml").deploy();
ProcessDefinition oneTaskProcess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").deploymentId(firstDeployment.getId()).singleResult();
ProcessDefinition latestOneTaskProcess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").deploymentId(secondDeployment.getId()).singleResult();
ProcessDefinition twoTaskprocess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("twoTaskProcess").deploymentId(secondDeployment.getId()).singleResult();
ProcessDefinition oneTaskWithDiProcess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcessWithDi").deploymentId(thirdDeployment.getId()).singleResult();
// Test parameterless call
String baseUrl = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_COLLECTION);
assertResultsPresentInDataResponse(baseUrl, oneTaskProcess.getId(), twoTaskprocess.getId(), latestOneTaskProcess.getId(), oneTaskWithDiProcess.getId());
// Verify ACT-2141 Persistent isGraphicalNotation flag for process definitions
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + baseUrl), HttpStatus.SC_OK);
JsonNode dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data");
closeResponse(response);
for (int i = 0; i < dataNode.size(); i++) {
JsonNode processDefinitionJson = dataNode.get(i);
String key = processDefinitionJson.get("key").asText();
JsonNode graphicalNotationNode = processDefinitionJson.get("graphicalNotationDefined");
if (key.equals("oneTaskProcessWithDi")) {
assertTrue(graphicalNotationNode.asBoolean());
} else {
assertFalse(graphicalNotationNode.asBoolean());
}
}
// Verify
// Test name filtering
String url = baseUrl + "?name=" + encode("The Two Task Process");
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test nameLike filtering
url = baseUrl + "?nameLike=" + encode("The Two%");
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test key filtering
url = baseUrl + "?key=twoTaskProcess";
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test returning multiple versions for the same key
url = baseUrl + "?key=oneTaskProcess";
assertResultsPresentInDataResponse(url, oneTaskProcess.getId(), latestOneTaskProcess.getId());
// Test keyLike filtering
url = baseUrl + "?keyLike=" + encode("two%");
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test category filtering
url = baseUrl + "?category=TwoTaskCategory";
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test categoryLike filtering
url = baseUrl + "?categoryLike=" + encode("Two%");
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test categoryNotEquals filtering
url = baseUrl + "?categoryNotEquals=OneTaskCategory";
assertResultsPresentInDataResponse(url, twoTaskprocess.getId(), oneTaskWithDiProcess.getId());
// Test resourceName filtering
url = baseUrl + "?resourceName=org/activiti/rest/service/api/repository/twoTaskProcess.bpmn20.xml";
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test resourceNameLike filtering
url = baseUrl + "?resourceNameLike=" + encode("%twoTaskProcess%");
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test version filtering
url = baseUrl + "?version=2";
assertResultsPresentInDataResponse(url, latestOneTaskProcess.getId());
// Test latest filtering
url = baseUrl + "?latest=true";
assertResultsPresentInDataResponse(url, latestOneTaskProcess.getId(), twoTaskprocess.getId(), oneTaskWithDiProcess.getId());
url = baseUrl + "?latest=false";
assertResultsPresentInDataResponse(baseUrl, oneTaskProcess.getId(), twoTaskprocess.getId(), latestOneTaskProcess.getId(), oneTaskWithDiProcess.getId());
// Test deploymentId
url = baseUrl + "?deploymentId=" + secondDeployment.getId();
assertResultsPresentInDataResponse(url, twoTaskprocess.getId(), latestOneTaskProcess.getId());
// Test startableByUser
url = baseUrl + "?startableByUser=kermit";
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
// Test suspended
repositoryService.suspendProcessDefinitionById(twoTaskprocess.getId());
url = baseUrl + "?suspended=true";
assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
url = baseUrl + "?suspended=false";
assertResultsPresentInDataResponse(url, latestOneTaskProcess.getId(), oneTaskProcess.getId(), oneTaskWithDiProcess.getId());
} finally {
// Always cleanup any created deployments, even if the test failed
List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
for (Deployment deployment : deployments) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
}
use of org.activiti.engine.repository.Deployment in project midpoint by Evolveum.
the class ActivitiEngine method autoDeployResource.
private void autoDeployResource(Resource resource) throws IOException, XPathExpressionException {
RepositoryService repositoryService = processEngine.getRepositoryService();
URL url = resource.getURL();
String name = url.toString();
long resourceLastModified = resource.lastModified();
LOGGER.debug("Checking resource " + name + " (last modified = " + new Date(resourceLastModified) + ")");
boolean tooOld = false;
List<Deployment> existingList = repositoryService.createDeploymentQuery().deploymentName(name).orderByDeploymenTime().desc().listPage(1, 1);
Deployment existing = existingList != null && !existingList.isEmpty() ? existingList.get(0) : null;
if (existing != null) {
if (resourceLastModified >= existing.getDeploymentTime().getTime()) {
tooOld = true;
}
LOGGER.debug("Found deployment " + existing.getName() + ", last modified " + existing.getDeploymentTime() + (tooOld ? " (too old)" : " (current)"));
} else {
LOGGER.debug("Deployment with name " + name + " was not found.");
}
if (existing == null || tooOld) {
repositoryService.createDeployment().name(name).addInputStream(name, resource.getInputStream()).deploy();
// + " as deployment with id = " + deployment.getId() + ", name = " + deployment.getName());
LOGGER.info("Successfully deployed Activiti resource " + name);
}
}
Aggregations