Java Code Examples for org.activiti.engine.impl.pvm.process.ActivityImpl#getProperty()

The following examples show how to use org.activiti.engine.impl.pvm.process.ActivityImpl#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiWorkFlowServiceImpl.java    From maven-framework-project with MIT License 6 votes vote down vote up
public String findParallelGatewayId(ActivityImpl activityImpl) {  
    List<PvmTransition> incomingTransitions = activityImpl  
            .getOutgoingTransitions();  
    for (PvmTransition pvmTransition : incomingTransitions) {  
        TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;  
        activityImpl = transitionImpl.getDestination();  
        String type = (String) activityImpl.getProperty("type");  
        if ("parallelGateway".equals(type)) {// 并行路线  
            String gatewayId = activityImpl.getId();  
            String gatewayType = gatewayId.substring(gatewayId  
                    .lastIndexOf("_") + 1);  
            if ("END".equals(gatewayType.toUpperCase())) {  
                return gatewayId.substring(0, gatewayId.lastIndexOf("_"))  
                        + "_start";  
            }  
        }  
    }  
    return null;  
}
 
Example 2
Source File: ProcessCustomService.java    From maven-framework-project with MIT License 6 votes vote down vote up
/** 
 * 根据当前节点,查询输出流向是否为并行终点,如果为并行终点,则拼装对应的并行起点ID 
 *  
 * @param activityImpl 
 *            当前节点 
 * @return 
 */  
private static String findParallelGatewayId(ActivityImpl activityImpl) {  
    List<PvmTransition> incomingTransitions = activityImpl  
            .getOutgoingTransitions();  
    for (PvmTransition pvmTransition : incomingTransitions) {  
        TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;  
        activityImpl = transitionImpl.getDestination();  
        String type = (String) activityImpl.getProperty("type");  
        if ("parallelGateway".equals(type)) {// 并行路线  
            String gatewayId = activityImpl.getId();  
            String gatewayType = gatewayId.substring(gatewayId  
                    .lastIndexOf("_") + 1);  
            if ("END".equals(gatewayType.toUpperCase())) {  
                return gatewayId.substring(0, gatewayId.lastIndexOf("_"))  
                        + "_start";  
            }  
        }  
    }  
    return null;  
}
 
Example 3
Source File: ProcessExtensionServiceImpl.java    From activiti-demo with Apache License 2.0 6 votes vote down vote up
/**
 * 根据当前节点,查询输出流向是否为并行终点,如果为并行终点,则拼装对应的并行起点ID
 * @param activityImpl   当前节点
 * @return
 */
private String findParallelGatewayId(ActivityImpl activityImpl){
    List<PvmTransition> incomingTransitions = activityImpl.getOutgoingTransitions();

    for(PvmTransition pvmTransition : incomingTransitions){
        TransitionImpl transitionImpl = (TransitionImpl)pvmTransition;
        activityImpl = transitionImpl.getDestination();
        String type = (String)activityImpl.getProperty("type");
        if("parallelGateway".equals(type)){ //并行路线
            String gatewayId = activityImpl.getId();
            String gettewayType = gatewayId.substring(gatewayId.lastIndexOf("_")+1);
            if("END".equals(gettewayType.toUpperCase())){
                return gatewayId.substring(0, gatewayId.lastIndexOf("_"))+"_start";
            }
        }
    }

    return null;
}
 
Example 4
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 退回流程.
 * 
 * @return 0-退回成功 1-流程结束 2-下一结点已经通过,不能退回
 */
public Integer execute(CommandContext commandContext) {
    // 获得任务
    TaskEntity taskEntity = this.findTask(commandContext);

    // 找到想要回退到的节点
    ActivityImpl targetActivity = this.findTargetActivity(commandContext,
            taskEntity);
    logger.info("rollback to {}", this.activityId);
    logger.info("{}", targetActivity.getProperties());

    String type = (String) targetActivity.getProperty("type");

    if ("userTask".equals(type)) {
        logger.info("rollback to userTask");
        this.rollbackUserTask(commandContext);
    } else if ("startEvent".equals(type)) {
        logger.info("rollback to startEvent");
        this.rollbackStartEvent(commandContext);
    } else {
        throw new IllegalStateException("cannot rollback " + type);
    }

    return 0;
}
 
Example 5
Source File: ActivitiKit.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 查询 运行时 流程任务节点名
 *
 * @param businessKey
 * @return
 */
public static String getActivityName(String businessKey) {
    String activityName = "未知";
    ProcessInstance instance = ActivitiKit.getRuntimeService().createProcessInstanceQuery()
            .processInstanceBusinessKey(businessKey)
            .singleResult();
    if (instance != null) {
        ActivityImpl activity = ActivitiKit.getActivity(instance.getProcessDefinitionId(), instance.getActivityId());
        if (activity != null) {
            activityName = (String) activity.getProperty("name");
        }
    }
    return activityName;
}
 
Example 6
Source File: ProcessInstanceHighlightsResource.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
/**
 * getBoundaryEventOutgoingTransitions
 *
 * @param activity
 * @return
 */
private List<PvmTransition> getBoundaryEventOutgoingTransitions(ActivityImpl activity) {
    List<PvmTransition> boundaryTrans = new ArrayList<PvmTransition>();
    for (ActivityImpl subActivity : activity.getActivities()) {
        String type = (String) subActivity.getProperty("type");
        if (type != null && type.toLowerCase().indexOf("boundary") >= 0) {
            boundaryTrans.addAll(subActivity.getOutgoingTransitions());
        }
    }
    return boundaryTrans;
}
 
Example 7
Source File: AtomicOperationActivityExecute.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(InterpretableExecution execution) {
    ActivityImpl activity = (ActivityImpl) execution.getActivity();

    ActivityBehavior activityBehavior = activity.getActivityBehavior();
    if (activityBehavior == null) {
        throw new PvmException("no behavior specified in " + activity);
    }

    LOGGER.debug("{} executes {}: {}", execution, activity, activityBehavior.getClass().getName());

    try {
        if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                    ActivitiEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_STARTED,
                            execution.getActivity().getId(),
                            (String) execution.getActivity().getProperty("name"),
                            execution.getId(),
                            execution.getProcessInstanceId(),
                            execution.getProcessDefinitionId(),
                            (String) activity.getProperties().get("type"),
                            activity.getActivityBehavior().getClass().getCanonicalName()));
        }

        activityBehavior.execute(execution);

    } catch (ActivitiException e) {
        throw e;
    } catch (Throwable t) {
        LogMDC.putMDCExecution(execution);
        throw new ActivitiActivityExecutionException("couldn't execute activity <" + activity.getProperty("type") + " id=\"" + activity.getId() + "\" ...>: " + t.getMessage(), t);
    }
}
 
Example 8
Source File: ExecutionEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void setActivity(ActivityImpl activity) {
    this.activity = activity;
    if (activity != null) {
        this.activityId = activity.getId();
        this.activityName = (String) activity.getProperty("name");
    } else {
        this.activityId = null;
        this.activityName = null;
    }
}
 
Example 9
Source File: AbstractBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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());

    // an association may reference elements that are not parsed as activities (like for instance
    // text annotations so do not throw an exception if sourceActivity or targetActivity are null)
    // 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());
            }
        }
    }
}
 
Example 10
Source File: HumanTaskEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 是否会签任务.
 */
public boolean isVote(DelegateTask delegateTask) {
    ExecutionEntity executionEntity = (ExecutionEntity) delegateTask
            .getExecution();
    ActivityImpl activityImpl = executionEntity.getActivity();

    return activityImpl.getProperty("multiInstance") != null;
}
 
Example 11
Source File: HumanTaskTaskListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 是否会签任务.
 */
public boolean isVote(DelegateTask delegateTask) {
    ExecutionEntity executionEntity = (ExecutionEntity) delegateTask
            .getExecution();
    ActivityImpl activityImpl = executionEntity.getActivity();

    return activityImpl.getProperty("multiInstance") != null;
}
 
Example 12
Source File: CompensationEventHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {

    String configuration = eventSubscription.getConfiguration();
    if (configuration == null) {
        throw new ActivitiException("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId());
    }

    ExecutionEntity compensatingExecution = commandContext.getExecutionEntityManager()
            .findExecutionById(configuration);

    ActivityImpl compensationHandler = eventSubscription.getActivity();

    if ((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null
            || !(Boolean) compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION))
            && compensationHandler.isScope()) {

        // descend into scope:
        List<CompensateEventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
        ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);

    } else {
        try {

            if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
                commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                        ActivitiEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_COMPENSATE,
                                compensationHandler.getId(),
                                (String) compensationHandler.getProperty("name"),
                                compensatingExecution.getId(),
                                compensatingExecution.getProcessInstanceId(),
                                compensatingExecution.getProcessDefinitionId(),
                                (String) compensatingExecution.getActivity().getProperties().get("type"),
                                compensatingExecution.getActivity().getActivityBehavior().getClass().getCanonicalName()));
            }
            compensatingExecution.setActivity(compensationHandler);

            // executing the atomic operation makes sure activity start events are fired
            compensatingExecution.performOperation(AtomicOperation.ACTIVITY_START);

        } catch (Exception e) {
            throw new ActivitiException("Error while handling compensation event " + eventSubscription, e);
        }

    }
}