Search in sources :

Example 46 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class AddListenerUserTaskParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
    super.executeParse(bpmnParse, userTask);
    ScopeImpl scope = bpmnParse.getCurrentScope();
    ProcessDefinitionImpl processDefinition = scope.getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(userTask.getId());
    SimulatorParserUtils.setSimulationBehavior(scope, userTask);
    UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activity.getActivityBehavior();
    userTaskActivity.getTaskDefinition().addTaskListener(eventName, taskListener);
}
Also used : ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 47 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class SimulatorParserUtils method setSimulationBehavior.

static void setSimulationBehavior(ScopeImpl scope, BaseElement baseElement) {
    String behaviorClassName = getBehaviorClassName(baseElement);
    if (behaviorClassName != null) {
        ProcessDefinitionImpl processDefinition = scope.getProcessDefinition();
        ActivityImpl activity = processDefinition.findActivity(baseElement.getId());
        LOG.debug("Scripting task [" + activity.getId() + "] setting behavior to [" + behaviorClassName + "]");
        try {
            @SuppressWarnings("unchecked") Class<AbstractSimulationActivityBehavior> behaviorClass = (Class<AbstractSimulationActivityBehavior>) Class.forName(behaviorClassName);
            Constructor<AbstractSimulationActivityBehavior> constructor = behaviorClass.getDeclaredConstructor(ScopeImpl.class, ActivityImpl.class);
            activity.setActivityBehavior(constructor.newInstance(scope, activity));
        } catch (Throwable t) {
            LOG.error("unable to set simulation behavior class[" + behaviorClassName + "]", t);
            throw new ActivitiException("unable to set simulation behavior class[" + behaviorClassName + "]");
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) AbstractSimulationActivityBehavior(org.activiti.crystalball.simulator.delegate.AbstractSimulationActivityBehavior)

Example 48 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl 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 49 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class AbstractBpmnParseHandler method createAssociation.

protected void createAssociation(BpmnParse bpmnParse, Association association, ScopeImpl parentScope) {
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    if (bpmnModel.getArtifact(association.getSourceRef()) != null || bpmnModel.getArtifact(association.getTargetRef()) != null) {
        // connected to a text annotation so skipping it
        return;
    }
    ActivityImpl sourceActivity = parentScope.findActivity(association.getSourceRef());
    ActivityImpl targetActivity = parentScope.findActivity(association.getTargetRef());
    // However, we make sure they reference 'something':
    if (sourceActivity == null) {
    //bpmnModel.addProblem("Invalid reference sourceRef '" + association.getSourceRef() + "' of association element ", association.getId());
    } else if (targetActivity == null) {
    //bpmnModel.addProblem("Invalid reference targetRef '" + association.getTargetRef() + "' of association element ", association.getId());
    } else {
        if (sourceActivity.getProperty("type").equals("compensationBoundaryCatch")) {
            Object isForCompensation = targetActivity.getProperty(PROPERTYNAME_IS_FOR_COMPENSATION);
            if (isForCompensation == null || !(Boolean) isForCompensation) {
                logger.warn("compensation boundary catch must be connected to element with isForCompensation=true");
            } else {
                ActivityImpl compensatedActivity = sourceActivity.getParentActivity();
                compensatedActivity.setProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID, targetActivity.getId());
            }
        }
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 50 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class BoundaryEventParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, BoundaryEvent boundaryEvent) {
    ActivityImpl parentActivity = findActivity(bpmnParse, boundaryEvent.getAttachedToRefId());
    if (parentActivity == null) {
        logger.warn("Invalid reference in boundary event. Make sure that the referenced activity is defined in the same scope as the boundary event " + boundaryEvent.getId());
        return;
    }
    ActivityImpl nestedActivity = createActivityOnScope(bpmnParse, boundaryEvent, BpmnXMLConstants.ELEMENT_EVENT_BOUNDARY, parentActivity);
    bpmnParse.setCurrentActivity(nestedActivity);
    EventDefinition eventDefinition = null;
    if (!boundaryEvent.getEventDefinitions().isEmpty()) {
        eventDefinition = boundaryEvent.getEventDefinitions().get(0);
    }
    if (eventDefinition instanceof TimerEventDefinition || eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition || eventDefinition instanceof SignalEventDefinition || eventDefinition instanceof CancelEventDefinition || eventDefinition instanceof MessageEventDefinition || eventDefinition instanceof org.activiti.bpmn.model.CompensateEventDefinition) {
        bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
    } else {
        logger.warn("Unsupported boundary event type for boundary event " + boundaryEvent.getId());
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Aggregations

ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)70 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)12 ActivitiException (org.activiti.engine.ActivitiException)9 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)9 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)8 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)7 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)6 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)6 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)6 ArrayList (java.util.ArrayList)5 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)4 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)4 HashMap (java.util.HashMap)3 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 List (java.util.List)2 DataAssociation (org.activiti.bpmn.model.DataAssociation)2 EventDefinition (org.activiti.bpmn.model.EventDefinition)2