Search in sources :

Example 1 with BpmnParseHandler

use of org.activiti.engine.parse.BpmnParseHandler in project carbon-business-process by wso2.

the class BPMNDataPublisher method configDataPublishing.

/**
 * Configure for data publishing to DAS for analytics
 *
 * @param receiverURLSet             Analytics receiver's url
 * @param username                   Analytics server's username
 * @param password                   Analytics server's password
 * @param authURLSet                 Analytics Auth URL set
 * @param type                       Bpmn Analytics Publisher Type
 * @param asyncDataPublishingEnabled is async Data Publishing Enabled
 * @param genericAnalyticsEnabled    is generic Analytics Enabled
 * @param kpiAnalyticsEnabled        is KPI Analytics Enabled
 * @throws DataEndpointAuthenticationException
 * @throws DataEndpointAgentConfigurationException
 * @throws TransportException
 * @throws DataEndpointException
 * @throws DataEndpointConfigurationException
 */
void configDataPublishing(String receiverURLSet, String username, String password, String authURLSet, String type, boolean asyncDataPublishingEnabled, boolean genericAnalyticsEnabled, boolean kpiAnalyticsEnabled) throws DataEndpointAuthenticationException, DataEndpointAgentConfigurationException, TransportException, DataEndpointException, DataEndpointConfigurationException {
    if (receiverURLSet != null && username != null && password != null) {
        // Configure data publisher to be used by all data publishing listeners
        if (log.isDebugEnabled()) {
            log.debug("Creating BPMN analytics data publisher with Receiver URL: " + receiverURLSet + ", Auth URL: " + authURLSet + " and Data publisher type: " + type);
        }
        dataPublisher = new DataPublisher(type, receiverURLSet, authURLSet, username, password);
        BPMNAnalyticsHolder.getInstance().setAsyncDataPublishingEnabled(asyncDataPublishingEnabled);
        BPMNEngineService engineService = BPMNAnalyticsHolder.getInstance().getBpmnEngineService();
        // Attach data publishing listeners to all existing processes
        if (log.isDebugEnabled()) {
            log.debug("Attaching data publishing listeners to already deployed processes...");
        }
        RepositoryService repositoryService = engineService.getProcessEngine().getRepositoryService();
        List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
        for (ProcessDefinition processDefinition : processDefinitions) {
            // Process definition returned by the query does not contain all details such as task definitions.
            // And it is also not the actual process definition, but a copy of it, so attaching listners to
            // them is useless. Therefore, we have to fetch the complete process definition from the repository
            // again.
            ProcessDefinition completeProcessDefinition = repositoryService.getProcessDefinition(processDefinition.getId());
            if (completeProcessDefinition instanceof ProcessDefinitionEntity) {
                ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) completeProcessDefinition;
                if (genericAnalyticsEnabled) {
                    processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationListener());
                }
                if (kpiAnalyticsEnabled) {
                    processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationKPIListener());
                }
                Map<String, TaskDefinition> tasks = processDefinitionEntity.getTaskDefinitions();
                List<ActivityImpl> activities = processDefinitionEntity.getActivities();
                for (ActivityImpl activity : activities) {
                    if (activity.getProperty("type").toString().equalsIgnoreCase("usertask")) {
                        tasks.get(activity.getId()).addTaskListener(TaskListener.EVENTNAME_COMPLETE, new TaskCompletionListener());
                    }
                // We are publishing analytics data of service tasks in process termination ATM.
                // else if(activity.getProperty("type").toString().equalsIgnoreCase("servicetask")){
                // activity.addExecutionListener(PvmEvent.EVENTNAME_END,new
                // ServiceTaskCompletionListener());
                // }
                }
            }
        }
        // Configure parse handlers, which attaches data publishing listeners to new processes
        if (log.isDebugEnabled()) {
            log.debug("Associating parse handlers for processes and tasks, so that data publishing listeners " + "will be attached to new processes.");
        }
        ProcessEngineConfigurationImpl engineConfig = (ProcessEngineConfigurationImpl) engineService.getProcessEngine().getProcessEngineConfiguration();
        if (engineConfig.getPostBpmnParseHandlers() == null) {
            engineConfig.setPostBpmnParseHandlers(new ArrayList<BpmnParseHandler>());
        }
        if (genericAnalyticsEnabled) {
            engineConfig.getPostBpmnParseHandlers().add(new ProcessParseHandler());
            engineConfig.getPostBpmnParseHandlers().add(new TaskParseHandler());
            engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new ProcessParseHandler());
            engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new TaskParseHandler());
        }
        if (kpiAnalyticsEnabled) {
            engineConfig.getPostBpmnParseHandlers().add(new ProcessKPIParseHandler());
            engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new ProcessKPIParseHandler());
        }
    } else {
        log.warn("Required fields for data publisher are not configured. Receiver URLs, username and password " + "are mandatory. Data publishing will not be enabled.");
    }
}
Also used : TaskCompletionListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.TaskCompletionListener) TaskParseHandler(org.wso2.carbon.bpmn.analytics.publisher.handlers.TaskParseHandler) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessParseHandler(org.wso2.carbon.bpmn.analytics.publisher.handlers.ProcessParseHandler) BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) ProcessKPIParseHandler(org.wso2.carbon.bpmn.analytics.publisher.handlers.ProcessKPIParseHandler) ProcessTerminationKPIListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationKPIListener) BPMNEngineService(org.wso2.carbon.bpmn.core.BPMNEngineService) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ProcessTerminationListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationListener) DataPublisher(org.wso2.carbon.databridge.agent.DataPublisher) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) RepositoryService(org.activiti.engine.RepositoryService)

Example 2 with BpmnParseHandler

use of org.activiti.engine.parse.BpmnParseHandler in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method getDefaultBpmnParseHandlers.

public List<BpmnParseHandler> getDefaultBpmnParseHandlers() {
    // Alphabetic list of default parse handler classes
    List<BpmnParseHandler> bpmnParserHandlers = new ArrayList<BpmnParseHandler>();
    bpmnParserHandlers.add(new BoundaryEventParseHandler());
    bpmnParserHandlers.add(new BusinessRuleParseHandler());
    bpmnParserHandlers.add(new CallActivityParseHandler());
    bpmnParserHandlers.add(new CancelEventDefinitionParseHandler());
    bpmnParserHandlers.add(new CompensateEventDefinitionParseHandler());
    bpmnParserHandlers.add(new EndEventParseHandler());
    bpmnParserHandlers.add(new ErrorEventDefinitionParseHandler());
    bpmnParserHandlers.add(new EventBasedGatewayParseHandler());
    bpmnParserHandlers.add(new ExclusiveGatewayParseHandler());
    bpmnParserHandlers.add(new InclusiveGatewayParseHandler());
    bpmnParserHandlers.add(new IntermediateCatchEventParseHandler());
    bpmnParserHandlers.add(new IntermediateThrowEventParseHandler());
    bpmnParserHandlers.add(new ManualTaskParseHandler());
    bpmnParserHandlers.add(new MessageEventDefinitionParseHandler());
    bpmnParserHandlers.add(new ParallelGatewayParseHandler());
    bpmnParserHandlers.add(new ProcessParseHandler());
    bpmnParserHandlers.add(new ReceiveTaskParseHandler());
    bpmnParserHandlers.add(new ScriptTaskParseHandler());
    bpmnParserHandlers.add(new SendTaskParseHandler());
    bpmnParserHandlers.add(new SequenceFlowParseHandler());
    bpmnParserHandlers.add(new ServiceTaskParseHandler());
    bpmnParserHandlers.add(new SignalEventDefinitionParseHandler());
    bpmnParserHandlers.add(new StartEventParseHandler());
    bpmnParserHandlers.add(new SubProcessParseHandler());
    bpmnParserHandlers.add(new EventSubProcessParseHandler());
    bpmnParserHandlers.add(new AdhocSubProcessParseHandler());
    bpmnParserHandlers.add(new TaskParseHandler());
    bpmnParserHandlers.add(new TimerEventDefinitionParseHandler());
    bpmnParserHandlers.add(new TransactionParseHandler());
    bpmnParserHandlers.add(new UserTaskParseHandler());
    // Replace any default handler if the user wants to replace them
    if (customDefaultBpmnParseHandlers != null) {
        Map<Class<?>, BpmnParseHandler> customParseHandlerMap = new HashMap<Class<?>, BpmnParseHandler>();
        for (BpmnParseHandler bpmnParseHandler : customDefaultBpmnParseHandlers) {
            for (Class<?> handledType : bpmnParseHandler.getHandledTypes()) {
                customParseHandlerMap.put(handledType, bpmnParseHandler);
            }
        }
        for (int i = 0; i < bpmnParserHandlers.size(); i++) {
            // All the default handlers support only one type
            BpmnParseHandler defaultBpmnParseHandler = bpmnParserHandlers.get(i);
            if (defaultBpmnParseHandler.getHandledTypes().size() != 1) {
                StringBuilder supportedTypes = new StringBuilder();
                for (Class<?> type : defaultBpmnParseHandler.getHandledTypes()) {
                    supportedTypes.append(" ").append(type.getCanonicalName()).append(" ");
                }
                throw new ActivitiException("The default BPMN parse handlers should only support one type, but " + defaultBpmnParseHandler.getClass() + " supports " + supportedTypes.toString() + ". This is likely a programmatic error");
            } else {
                Class<?> handledType = defaultBpmnParseHandler.getHandledTypes().iterator().next();
                if (customParseHandlerMap.containsKey(handledType)) {
                    BpmnParseHandler newBpmnParseHandler = customParseHandlerMap.get(handledType);
                    log.info("Replacing default BpmnParseHandler " + defaultBpmnParseHandler.getClass().getName() + " with " + newBpmnParseHandler.getClass().getName());
                    bpmnParserHandlers.set(i, newBpmnParseHandler);
                }
            }
        }
    }
    return bpmnParserHandlers;
}
Also used : UserTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.UserTaskParseHandler) ServiceTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ServiceTaskParseHandler) ReceiveTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ReceiveTaskParseHandler) TaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.TaskParseHandler) SendTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SendTaskParseHandler) ManualTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ManualTaskParseHandler) ScriptTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ScriptTaskParseHandler) ActivitiException(org.activiti.engine.ActivitiException) BusinessRuleParseHandler(org.activiti.engine.impl.bpmn.parser.handler.BusinessRuleParseHandler) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) BoundaryEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.BoundaryEventParseHandler) InclusiveGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.InclusiveGatewayParseHandler) ArrayList(java.util.ArrayList) AdhocSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler) SubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SubProcessParseHandler) EventSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler) AdhocSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler) ProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ProcessParseHandler) BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) ServiceTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ServiceTaskParseHandler) EventBasedGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventBasedGatewayParseHandler) UserTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.UserTaskParseHandler) MessageEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.MessageEventDefinitionParseHandler) ScriptTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ScriptTaskParseHandler) SequenceFlowParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SequenceFlowParseHandler) TimerEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.TimerEventDefinitionParseHandler) SendTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SendTaskParseHandler) EventSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler) EndEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EndEventParseHandler) CancelEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.CancelEventDefinitionParseHandler) StartEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.StartEventParseHandler) ErrorEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ErrorEventDefinitionParseHandler) SubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SubProcessParseHandler) EventSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler) AdhocSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler) ManualTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ManualTaskParseHandler) CallActivityParseHandler(org.activiti.engine.impl.bpmn.parser.handler.CallActivityParseHandler) ParallelGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ParallelGatewayParseHandler) IntermediateCatchEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.IntermediateCatchEventParseHandler) TransactionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.TransactionParseHandler) CompensateEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.CompensateEventDefinitionParseHandler) ExclusiveGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ExclusiveGatewayParseHandler) ReceiveTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ReceiveTaskParseHandler) IntermediateThrowEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.IntermediateThrowEventParseHandler) SignalEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SignalEventDefinitionParseHandler)

Example 3 with BpmnParseHandler

use of org.activiti.engine.parse.BpmnParseHandler in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method getDefaultHistoryParseHandlers.

protected List<BpmnParseHandler> getDefaultHistoryParseHandlers() {
    List<BpmnParseHandler> parseHandlers = new ArrayList<BpmnParseHandler>();
    parseHandlers.add(new FlowNodeHistoryParseHandler());
    parseHandlers.add(new ProcessHistoryParseHandler());
    parseHandlers.add(new StartEventHistoryParseHandler());
    parseHandlers.add(new UserTaskHistoryParseHandler());
    return parseHandlers;
}
Also used : ProcessHistoryParseHandler(org.activiti.engine.impl.history.parse.ProcessHistoryParseHandler) UserTaskHistoryParseHandler(org.activiti.engine.impl.history.parse.UserTaskHistoryParseHandler) FlowNodeHistoryParseHandler(org.activiti.engine.impl.history.parse.FlowNodeHistoryParseHandler) ArrayList(java.util.ArrayList) BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) StartEventHistoryParseHandler(org.activiti.engine.impl.history.parse.StartEventHistoryParseHandler)

Example 4 with BpmnParseHandler

use of org.activiti.engine.parse.BpmnParseHandler in project Activiti by Activiti.

the class SecureJavascriptConfigurator method beforeInit.

@Override
public void beforeInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
    // Initialize the Rhino context factory (needs to be done once)
    if (secureScriptContextFactory == null) {
        initSecureScriptContextFactory();
    }
    // Init parse handler that will set the secure javascript task to the activity
    List<BpmnParseHandler> customDefaultBpmnParseHandlers = processEngineConfiguration.getCustomDefaultBpmnParseHandlers();
    if (customDefaultBpmnParseHandlers == null) {
        customDefaultBpmnParseHandlers = new ArrayList<BpmnParseHandler>();
        processEngineConfiguration.setCustomDefaultBpmnParseHandlers(customDefaultBpmnParseHandlers);
    }
    customDefaultBpmnParseHandlers.add(new SecureJavascriptTaskParseHandler());
}
Also used : BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) SecureJavascriptTaskParseHandler(org.activiti.scripting.secure.behavior.SecureJavascriptTaskParseHandler)

Example 5 with BpmnParseHandler

use of org.activiti.engine.parse.BpmnParseHandler in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initBpmnParser.

public void initBpmnParser() {
    if (bpmnParser == null) {
        bpmnParser = new BpmnParser();
    }
    if (bpmnParseFactory == null) {
        bpmnParseFactory = new DefaultBpmnParseFactory();
    }
    bpmnParser.setBpmnParseFactory(bpmnParseFactory);
    bpmnParser.setActivityBehaviorFactory(activityBehaviorFactory);
    bpmnParser.setListenerFactory(listenerFactory);
    List<BpmnParseHandler> parseHandlers = new ArrayList<BpmnParseHandler>();
    if (getPreBpmnParseHandlers() != null) {
        parseHandlers.addAll(getPreBpmnParseHandlers());
    }
    parseHandlers.addAll(getDefaultBpmnParseHandlers());
    if (getPostBpmnParseHandlers() != null) {
        parseHandlers.addAll(getPostBpmnParseHandlers());
    }
    BpmnParseHandlers bpmnParseHandlers = new BpmnParseHandlers();
    bpmnParseHandlers.addHandlers(parseHandlers);
    bpmnParser.setBpmnParserHandlers(bpmnParseHandlers);
}
Also used : BpmnParser(org.activiti.engine.impl.bpmn.parser.BpmnParser) ArrayList(java.util.ArrayList) BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) BpmnParseHandlers(org.activiti.engine.impl.bpmn.parser.BpmnParseHandlers)

Aggregations

BpmnParseHandler (org.activiti.engine.parse.BpmnParseHandler)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ActivitiException (org.activiti.engine.ActivitiException)1 RepositoryService (org.activiti.engine.RepositoryService)1 BpmnParseHandlers (org.activiti.engine.impl.bpmn.parser.BpmnParseHandlers)1 BpmnParser (org.activiti.engine.impl.bpmn.parser.BpmnParser)1 AdhocSubProcessParseHandler (org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler)1 BoundaryEventParseHandler (org.activiti.engine.impl.bpmn.parser.handler.BoundaryEventParseHandler)1 BusinessRuleParseHandler (org.activiti.engine.impl.bpmn.parser.handler.BusinessRuleParseHandler)1 CallActivityParseHandler (org.activiti.engine.impl.bpmn.parser.handler.CallActivityParseHandler)1 CancelEventDefinitionParseHandler (org.activiti.engine.impl.bpmn.parser.handler.CancelEventDefinitionParseHandler)1 CompensateEventDefinitionParseHandler (org.activiti.engine.impl.bpmn.parser.handler.CompensateEventDefinitionParseHandler)1 EndEventParseHandler (org.activiti.engine.impl.bpmn.parser.handler.EndEventParseHandler)1 ErrorEventDefinitionParseHandler (org.activiti.engine.impl.bpmn.parser.handler.ErrorEventDefinitionParseHandler)1 EventBasedGatewayParseHandler (org.activiti.engine.impl.bpmn.parser.handler.EventBasedGatewayParseHandler)1 EventSubProcessParseHandler (org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler)1 ExclusiveGatewayParseHandler (org.activiti.engine.impl.bpmn.parser.handler.ExclusiveGatewayParseHandler)1 InclusiveGatewayParseHandler (org.activiti.engine.impl.bpmn.parser.handler.InclusiveGatewayParseHandler)1