Search in sources :

Example 1 with ProcessEngineConfigurationImpl

use of org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl in project Activiti by Activiti.

the class DisabledDefinitionInfoCacheTest method initializeProcessEngine.

protected void initializeProcessEngine() {
    if (cachedProcessEngine == null) {
        ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/engine/test/bpmn/usertask/activiti.cfg.xml");
        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
    }
    processEngine = cachedProcessEngine;
}
Also used : ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 2 with ProcessEngineConfigurationImpl

use of org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl in project Activiti by Activiti.

the class BpmnParse method execute.

public BpmnParse execute() {
    try {
        ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
        BpmnXMLConverter converter = new BpmnXMLConverter();
        boolean enableSafeBpmnXml = false;
        String encoding = null;
        if (processEngineConfiguration != null) {
            enableSafeBpmnXml = processEngineConfiguration.isEnableSafeBpmnXml();
            encoding = processEngineConfiguration.getXmlEncoding();
        }
        if (encoding != null) {
            bpmnModel = converter.convertToBpmnModel(streamSource, validateSchema, enableSafeBpmnXml, encoding);
        } else {
            bpmnModel = converter.convertToBpmnModel(streamSource, validateSchema, enableSafeBpmnXml);
        }
        // XSD validation goes first, then process/semantic validation
        if (validateProcess) {
            ProcessValidator processValidator = processEngineConfiguration.getProcessValidator();
            if (processValidator == null) {
                LOGGER.warn("Process should be validated, but no process validator is configured on the process engine configuration!");
            } else {
                List<ValidationError> validationErrors = processValidator.validate(bpmnModel);
                if (validationErrors != null && !validationErrors.isEmpty()) {
                    StringBuilder warningBuilder = new StringBuilder();
                    StringBuilder errorBuilder = new StringBuilder();
                    for (ValidationError error : validationErrors) {
                        if (error.isWarning()) {
                            warningBuilder.append(error.toString());
                            warningBuilder.append("\n");
                        } else {
                            errorBuilder.append(error.toString());
                            errorBuilder.append("\n");
                        }
                    }
                    // Throw exception if there is any error
                    if (errorBuilder.length() > 0) {
                        throw new ActivitiException("Errors while parsing:\n" + errorBuilder.toString());
                    }
                    // Write out warnings (if any)
                    if (warningBuilder.length() > 0) {
                        LOGGER.warn("Following warnings encountered during process validation: " + warningBuilder.toString());
                    }
                }
            }
        }
        // Validation successfull (or no validation)
        createImports();
        createItemDefinitions();
        createMessages();
        createOperations();
        transformProcessDefinitions();
    } catch (Exception e) {
        if (e instanceof ActivitiException) {
            throw (ActivitiException) e;
        } else if (e instanceof XMLException) {
            throw (XMLException) e;
        } else {
            throw new ActivitiException("Error parsing XML", e);
        }
    }
    return this;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) XMLException(org.activiti.bpmn.exceptions.XMLException) ValidationError(org.activiti.validation.ValidationError) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessValidator(org.activiti.validation.ProcessValidator) ActivitiException(org.activiti.engine.ActivitiException) XMLException(org.activiti.bpmn.exceptions.XMLException) MalformedURLException(java.net.MalformedURLException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 3 with ProcessEngineConfigurationImpl

use of org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl in project Activiti by Activiti.

the class DefaultHistoryManager method endHistoricActivityInstance.

protected void endHistoricActivityInstance(HistoricActivityInstanceEntity historicActivityInstance) {
    historicActivityInstance.markEnded(null);
    // Fire event
    ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
    if (config != null && config.getEventDispatcher().isEnabled()) {
        config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstance));
    }
}
Also used : ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 4 with ProcessEngineConfigurationImpl

use of org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl in project Activiti by Activiti.

the class DefaultHistoryManager method recordProcessInstanceStart.

/* (non-Javadoc)
   * @see org.activiti.engine.impl.history.HistoryManagerInterface#recordProcessInstanceStart(org.activiti.engine.impl.persistence.entity.ExecutionEntity)
   */
@Override
public void recordProcessInstanceStart(ExecutionEntity processInstance) {
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance);
        // Insert historic process-instance
        getDbSqlSession().insert(historicProcessInstance);
        // Fire event
        ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
        if (config != null && config.getEventDispatcher().isEnabled()) {
            config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
        }
        // Also record the start-event manually, as there is no "start" activity history listener for this
        IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator();
        String processDefinitionId = processInstance.getProcessDefinitionId();
        String processInstanceId = processInstance.getProcessInstanceId();
        String executionId = processInstance.getId();
        HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity();
        historicActivityInstance.setId(idGenerator.getNextId());
        historicActivityInstance.setProcessDefinitionId(processDefinitionId);
        historicActivityInstance.setProcessInstanceId(processInstanceId);
        historicActivityInstance.setExecutionId(executionId);
        historicActivityInstance.setActivityId(processInstance.getActivityId());
        historicActivityInstance.setActivityName((String) processInstance.getActivity().getProperty("name"));
        historicActivityInstance.setActivityType((String) processInstance.getActivity().getProperty("type"));
        Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
        historicActivityInstance.setStartTime(now);
        // Inherit tenant id (if applicable)
        if (processInstance.getTenantId() != null) {
            historicActivityInstance.setTenantId(processInstance.getTenantId());
        }
        getDbSqlSession().insert(historicActivityInstance);
        // Fire event
        if (config != null && config.getEventDispatcher().isEnabled()) {
            config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance));
        }
    }
}
Also used : HistoricActivityInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity) HistoricProcessInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity) IdGenerator(org.activiti.engine.impl.cfg.IdGenerator) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) Date(java.util.Date)

Example 5 with ProcessEngineConfigurationImpl

use of org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl in project Activiti by Activiti.

the class WebServiceActivityBehavior method execute.

/**
   * {@inheritDoc}
   */
public void execute(ActivityExecution execution) throws Exception {
    MessageInstance message;
    try {
        if (ioSpecification != null) {
            this.ioSpecification.initialize(execution);
            ItemInstance inputItem = (ItemInstance) execution.getVariable(this.ioSpecification.getFirstDataInputName());
            message = new MessageInstance(this.operation.getInMessage(), inputItem);
        } else {
            message = this.operation.getInMessage().createInstance();
        }
        execution.setVariable(CURRENT_MESSAGE, message);
        this.fillMessage(message, execution);
        ProcessEngineConfigurationImpl processEngineConfig = Context.getProcessEngineConfiguration();
        MessageInstance receivedMessage = this.operation.sendMessage(message, processEngineConfig.getWsOverridenEndpointAddresses());
        execution.setVariable(CURRENT_MESSAGE, receivedMessage);
        if (ioSpecification != null) {
            String firstDataOutputName = this.ioSpecification.getFirstDataOutputName();
            if (firstDataOutputName != null) {
                ItemInstance outputItem = (ItemInstance) execution.getVariable(firstDataOutputName);
                outputItem.getStructureInstance().loadFrom(receivedMessage.getStructureInstance().toArray());
            }
        }
        this.returnMessage(receivedMessage, execution);
        execution.setVariable(CURRENT_MESSAGE, null);
        leave(execution);
    } catch (Exception exc) {
        Throwable cause = exc;
        BpmnError error = null;
        while (cause != null) {
            if (cause instanceof BpmnError) {
                error = (BpmnError) cause;
                break;
            }
            cause = cause.getCause();
        }
        if (error != null) {
            ErrorPropagation.propagateError(error, execution);
        } else {
            throw exc;
        }
    }
}
Also used : MessageInstance(org.activiti.engine.impl.bpmn.webservice.MessageInstance) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ItemInstance(org.activiti.engine.impl.bpmn.data.ItemInstance) BpmnError(org.activiti.engine.delegate.BpmnError)

Aggregations

ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)36 ThreadLocalClock (org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock)5 Clock (org.activiti.engine.runtime.Clock)5 ActivitiException (org.activiti.engine.ActivitiException)4 ProcessEngine (org.activiti.engine.ProcessEngine)4 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)4 HistoricActivityInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 IdGenerator (org.activiti.engine.impl.cfg.IdGenerator)3 StandaloneInMemProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)3 HistoricProcessInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity)3 DefaultClockImpl (org.activiti.engine.impl.util.DefaultClockImpl)3 EntityManagerSession (org.activiti.engine.impl.variable.EntityManagerSession)3 EntityManagerSessionFactory (org.activiti.engine.impl.variable.EntityManagerSessionFactory)3 Task (org.activiti.engine.task.Task)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 DefaultClockFactory (org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory)2