Search in sources :

Example 41 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class BpmnParseTest method testParseDiagramInterchangeElements.

@Deployment
public void testParseDiagramInterchangeElements() {
    // Graphical information is not yet exposed publicly, so we need to do some plumbing
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
    ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {

        public ProcessDefinitionEntity execute(CommandContext commandContext) {
            return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("myProcess");
        }
    });
    assertNotNull(processDefinitionEntity);
    assertEquals(7, processDefinitionEntity.getActivities().size());
    // Check if diagram has been created based on Diagram Interchange when it's not a headless instance
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
    assertEquals(2, resourceNames.size());
    for (ActivityImpl activity : processDefinitionEntity.getActivities()) {
        if (activity.getId().equals("theStart")) {
            assertActivityBounds(activity, 70, 255, 30, 30);
        } else if (activity.getId().equals("task1")) {
            assertActivityBounds(activity, 176, 230, 100, 80);
        } else if (activity.getId().equals("gateway1")) {
            assertActivityBounds(activity, 340, 250, 40, 40);
        } else if (activity.getId().equals("task2")) {
            assertActivityBounds(activity, 445, 138, 100, 80);
        } else if (activity.getId().equals("gateway2")) {
            assertActivityBounds(activity, 620, 250, 40, 40);
        } else if (activity.getId().equals("task3")) {
            assertActivityBounds(activity, 453, 304, 100, 80);
        } else if (activity.getId().equals("theEnd")) {
            assertActivityBounds(activity, 713, 256, 28, 28);
        }
        for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
            assertTrue(((TransitionImpl) sequenceFlow).getWaypoints().size() >= 4);
            TransitionImpl transitionImpl = (TransitionImpl) sequenceFlow;
            if (transitionImpl.getId().equals("flowStartToTask1")) {
                assertSequenceFlowWayPoints(transitionImpl, 100, 270, 176, 270);
            } else if (transitionImpl.getId().equals("flowTask1ToGateway1")) {
                assertSequenceFlowWayPoints(transitionImpl, 276, 270, 340, 270);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask2")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 250, 360, 178, 445, 178);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask3")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 290, 360, 344, 453, 344);
            } else if (transitionImpl.getId().equals("flowTask2ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 545, 178, 640, 178, 640, 250);
            } else if (transitionImpl.getId().equals("flowTask3ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 553, 344, 640, 344, 640, 290);
            } else if (transitionImpl.getId().equals("flowGateway2ToEnd")) {
                assertSequenceFlowWayPoints(transitionImpl, 660, 270, 713, 270);
            }
        }
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition) Deployment(org.activiti.engine.test.Deployment)

Example 42 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class JsonProcessDefinitionConverter method toJsonObject.

public JSONObject toJsonObject(ProcessDefinition processDefinition) {
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition;
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("id", processDefinitionEntity.getId());
    if (processDefinitionEntity.getKey() != null) {
        jsonObject.put("key", processDefinitionEntity.getKey());
    }
    if (processDefinitionEntity.getDeploymentId() != null) {
        jsonObject.put("deploymentId", processDefinitionEntity.getDeploymentId());
    }
    return jsonObject;
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 43 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class JobRetryCmd method getCurrentActivity.

private ActivityImpl getCurrentActivity(CommandContext commandContext, JobEntity job) {
    String type = job.getJobHandlerType();
    ActivityImpl activity = null;
    if (TimerExecuteNestedActivityJobHandler.TYPE.equals(type) || TimerCatchIntermediateEventJobHandler.TYPE.equals(type)) {
        ExecutionEntity execution = fetchExecutionEntity(commandContext, job.getExecutionId());
        if (execution != null) {
            activity = execution.getProcessDefinition().findActivity(job.getJobHandlerConfiguration());
        }
    } else if (TimerStartEventJobHandler.TYPE.equals(type)) {
        DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
        if (TimerEventHandler.hasRealActivityId(job.getJobHandlerConfiguration())) {
            ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId());
            String activityId = TimerEventHandler.getActivityIdFromConfiguration(job.getJobHandlerConfiguration());
            activity = processDefinition.findActivity(activityId);
        } else {
            String processId = job.getJobHandlerConfiguration();
            if (job instanceof TimerEntity) {
                processId = TimerEventHandler.getActivityIdFromConfiguration(job.getJobHandlerConfiguration());
            }
            ProcessDefinitionEntity processDefinition = null;
            if (job.getTenantId() != null && job.getTenantId().length() > 0) {
                processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processId, job.getTenantId());
            } else {
                processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processId);
            }
            if (processDefinition != null) {
                activity = processDefinition.getInitial();
            }
        }
    } else if (AsyncContinuationJobHandler.TYPE.equals(type)) {
        ExecutionEntity execution = fetchExecutionEntity(commandContext, job.getExecutionId());
        if (execution != null) {
            activity = execution.getActivity();
        }
    } else {
    // nop, because activity type is not supported
    }
    return activity;
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) TimerEntity(org.activiti.engine.impl.persistence.entity.TimerEntity) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 44 with ProcessDefinitionEntity

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;
}
Also used : DefaultFormHandler(org.activiti.engine.impl.form.DefaultFormHandler) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 45 with ProcessDefinitionEntity

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);
}
Also used : StartFormHandler(org.activiti.engine.impl.form.StartFormHandler) ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)64 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)12 ActivitiException (org.activiti.engine.ActivitiException)11 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)9 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)8 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)8 BpmnModel (org.activiti.bpmn.model.BpmnModel)7 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)6 RepositoryService (org.activiti.engine.RepositoryService)6 ProcessDefinitionEntityManager (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager)6 StreamResource (com.vaadin.terminal.StreamResource)5 HashMap (java.util.HashMap)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 Deployment (org.activiti.engine.test.Deployment)4 Embedded (com.vaadin.ui.Embedded)3 Label (com.vaadin.ui.Label)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2