use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class GetFormKeyCmd method execute.
public String execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
DefaultFormHandler formHandler;
if (taskDefinitionKey == null) {
// TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
formHandler = (DefaultFormHandler) processDefinition.getStartFormHandler();
} else {
TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
// TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
formHandler = (DefaultFormHandler) taskDefinition.getTaskFormHandler();
}
String formKey = null;
if (formHandler.getFormKey() != null) {
formKey = formHandler.getFormKey().getExpressionText();
}
return formKey;
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class GetStartFormCmd method execute.
public StartFormData execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
throw new ActivitiException("No startFormHandler defined in process '" + processDefinitionId + "'");
}
return startFormHandler.createStartFormData(processDefinition);
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class ProcessDefinitionsTest method testGetProcessDefinitions.
@Test
public void testGetProcessDefinitions() {
when(repositoryService.createProcessDefinitionQuery()).thenReturn(processDefinitionQuery);
List<ProcessDefinition> processDefinitionList = new ArrayList<ProcessDefinition>();
ProcessDefinitionEntity pd = new ProcessDefinitionEntity();
pd.setId("testId");
pd.setName("testName");
pd.setVersion(175);
pd.setSuspensionState(1);
pd.setDescription("testDescription");
processDefinitionList.add(pd);
when(processDefinitionQuery.list()).thenReturn(processDefinitionList);
List<List<String>> result = processDefinitionsMBean.getProcessDefinitions();
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(5, result.get(0).size());
assertEquals("testId", result.get(0).get(0));
assertEquals("testName", result.get(0).get(1));
assertEquals("175", result.get(0).get(2));
assertEquals("false", result.get(0).get(3));
assertEquals("testDescription", result.get(0).get(4));
pd.setSuspensionState(2);
result = processDefinitionsMBean.getProcessDefinitions();
assertEquals("true", result.get(0).get(3));
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project carbon-business-process by wso2.
the class ProcessInstanceService method isValidUserToStartProcess.
private boolean isValidUserToStartProcess(ProcessInstanceCreateRequest processInstanceCreateRequest) {
// check whether the users/groups exist
String processDefinitionId = processInstanceCreateRequest.getProcessDefinitionId();
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
if (processDefinitionId == null) {
final String processDefinitionKey = processInstanceCreateRequest.getProcessDefinitionKey();
final String tenantId = processInstanceCreateRequest.getTenantId();
ProcessEngine processEngine = BPMNOSGIService.getBPMNEngineService().getProcessEngine();
if (processEngine != null) {
if (processDefinitionKey != null) {
if (((ProcessEngineImpl) processEngine).getProcessEngineConfiguration() != null) {
CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor();
if (commandExecutor != null) {
processDefinitionId = (String) commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
ProcessDefinitionEntityManager processDefinitionEntityManager = commandContext.getSession(ProcessDefinitionEntityManager.class);
ProcessDefinitionEntity processDefinitionEntity = processDefinitionEntityManager.findLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId);
if (processDefinitionEntity != null && processDefinitionEntity.getProcessDefinition() != null) {
return processDefinitionEntity.getProcessDefinition().getId();
}
return null;
}
});
}
}
if (processDefinitionId == null) {
return false;
}
}
String messageName = processInstanceCreateRequest.getMessage();
if (messageName != null && !messageName.isEmpty()) {
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName(messageName);
if (processDefinitionQuery != null) {
processDefinitionQuery = processDefinitionQuery.processDefinitionTenantId(processInstanceCreateRequest.getTenantId());
if (processDefinitionQuery != null && processDefinitionQuery.count() > 1) {
processDefinitionQuery = processDefinitionQuery.latestVersion();
}
}
if (processDefinitionQuery != null) {
ProcessDefinition processDefinition = processDefinitionQuery.singleResult();
if (processDefinition != null) {
processDefinitionId = processDefinition.getId();
}
}
if (processDefinitionId == null) {
return false;
}
}
}
}
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String userName = carbonContext.getUsername();
String tenantDomain = carbonContext.getTenantDomain();
String userNameWithTenantDomain = userName + "@" + tenantDomain;
BPSGroupIdentityManager bpsGroupIdentityManager = BPMNOSGIService.getGroupIdentityManager();
List<Group> groupList = bpsGroupIdentityManager.findGroupsByUser(userName);
List<IdentityLink> identityLinkList = repositoryService.getIdentityLinksForProcessDefinition(processDefinitionId);
boolean valueExistsForUserId = false;
boolean valueExistsForGroupId = false;
for (IdentityLink identityLink : identityLinkList) {
String userId = identityLink.getUserId();
if (userId != null) {
valueExistsForUserId = true;
if (userId.contains("$")) {
userId = resolveVariable(processInstanceCreateRequest, userId);
}
if (!userId.isEmpty() && (userId.equals(userName) || userId.equals(userNameWithTenantDomain))) {
return true;
}
continue;
}
String groupId = identityLink.getGroupId();
if (groupId != null) {
valueExistsForGroupId = true;
if (groupId.contains("$")) {
groupId = resolveVariable(processInstanceCreateRequest, groupId);
}
for (Group identityGroup : groupList) {
if (!groupId.isEmpty() && identityGroup.getId() != null && identityGroup.getId().equals(groupId)) {
return true;
}
}
}
}
if (!valueExistsForGroupId && !valueExistsForUserId) {
return true;
}
return false;
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project carbon-business-process by wso2.
the class ProcessStatisticsService method getTasks.
/**
* Return all the tasks/activities in a process
* @param pId process instance id
* @return all the tasks/activities in a process
*/
@GET
@Path("/task-instances/{pId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ResponseHolder getTasks(@PathParam("pId") String pId) {
ResponseHolder response = new ResponseHolder();
List<Object> list = new ArrayList();
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pId);
if (processDefinition != null) {
for (ActivityImpl activity : processDefinition.getActivities()) {
TaskInfo taskInfo = new TaskInfo();
String taskDefKey = activity.getId();
String type = (String) activity.getProperty("type");
String taskName = (String) activity.getProperty("name");
taskInfo.setTaskDefinitionKey(taskDefKey);
taskInfo.setType(type);
taskInfo.setName(taskName);
list.add(taskInfo);
}
}
response.setData(list);
return response;
}
Aggregations