Search in sources :

Example 51 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project carbon-business-process by wso2.

the class ProcessKPIParseHandler method executeParse.

@Override
protected void executeParse(BpmnParse bpmnParse, BaseElement baseElement) {
    ProcessDefinitionEntity processDefinitionEntity = bpmnParse.getCurrentProcessDefinition();
    // We have to check if the data publishing KPI listener has already been associated at server startup.
    ExecutionListener processTerminationKPIListener = null;
    List<ExecutionListener> endListeners = processDefinitionEntity.getExecutionListeners(PvmEvent.EVENTNAME_END);
    if (endListeners != null) {
        for (ExecutionListener listener : endListeners) {
            if (listener instanceof ProcessTerminationKPIListener) {
                processTerminationKPIListener = listener;
            }
        }
    }
    if (processTerminationKPIListener == null) {
        if (log.isDebugEnabled()) {
            log.debug("Enabling data publishing for process: " + processDefinitionEntity.getName());
        }
        processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationKPIListener());
    }
}
Also used : ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessTerminationKPIListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationKPIListener) ExecutionListener(org.activiti.engine.delegate.ExecutionListener)

Example 52 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project carbon-business-process by wso2.

the class ProcessParseHandler method executeParse.

@Override
protected void executeParse(BpmnParse bpmnParse, BaseElement baseElement) {
    ProcessDefinitionEntity processDefinitionEntity = bpmnParse.getCurrentProcessDefinition();
    // We have to check if the data publishing listener has already been associated at server startup.
    ExecutionListener processTerminationListener = null;
    List<ExecutionListener> endListeners = processDefinitionEntity.getExecutionListeners(PvmEvent.EVENTNAME_END);
    if (endListeners != null) {
        for (ExecutionListener listener : endListeners) {
            if (listener instanceof ProcessTerminationListener) {
                processTerminationListener = listener;
                break;
            }
        }
    }
    if (processTerminationListener == null) {
        if (log.isDebugEnabled()) {
            log.debug("Enabling data publishing for process: " + processDefinitionEntity.getName());
        }
        processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationListener());
    }
}
Also used : ProcessTerminationListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationListener) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ExecutionListener(org.activiti.engine.delegate.ExecutionListener)

Example 53 with ProcessDefinitionEntity

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

the class DefaultWorkflowHistoricProcessInstanceService method getDiagram.

/**
 * Generate diagram for process instance. Highlight historic path (activity
 * and flows)
 */
@Override
public InputStream getDiagram(String processInstanceId) {
    if (processInstanceId == null) {
        throw new ActivitiIllegalArgumentException("No process instance id provided");
    }
    HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    if (pi == null) {
        throw new ActivitiObjectNotFoundException("Process instance with id " + processInstanceId + " could not be found", ProcessInstance.class);
    }
    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pi.getProcessDefinitionId());
    if (pde != null && pde.isGraphicalNotationDefined()) {
        BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());
        List<String> historicActivityInstanceList = new ArrayList<String>();
        List<String> highLightedFlows = new ArrayList<String>();
        historicActivityInstanceList = getHighLightedFlows(bpmnModel, processInstanceId, historicActivityInstanceList, highLightedFlows);
        ProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
        return diagramGenerator.generateDiagram(bpmnModel, "png", historicActivityInstanceList, highLightedFlows);
    } else {
        throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 54 with ProcessDefinitionEntity

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

the class AbstractSetProcessDefinitionStateCmd method changeProcessDefinitionState.

protected void changeProcessDefinitionState(CommandContext commandContext, List<ProcessDefinitionEntity> processDefinitions) {
    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
        SuspensionStateUtil.setSuspensionState(processDefinition, getProcessDefinitionSuspensionState());
        // Evict cache
        commandContext.getProcessEngineConfiguration().getDeploymentManager().getProcessDefinitionCache().remove(processDefinition.getId());
        // Suspend process instances (if needed)
        if (includeProcessInstances) {
            int currentStartIndex = 0;
            List<ProcessInstance> processInstances = fetchProcessInstancesPage(commandContext, processDefinition, currentStartIndex);
            while (!processInstances.isEmpty()) {
                for (ProcessInstance processInstance : processInstances) {
                    AbstractSetProcessInstanceStateCmd processInstanceCmd = getProcessInstanceChangeStateCmd(processInstance);
                    processInstanceCmd.execute(commandContext);
                }
                // Fetch new batch of process instances
                currentStartIndex += processInstances.size();
                processInstances = fetchProcessInstancesPage(commandContext, processDefinition, currentStartIndex);
            }
        }
    }
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 55 with ProcessDefinitionEntity

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

the class DeleteIdentityLinkForProcessDefinitionCmd method execute.

public Void execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
    }
    commandContext.getIdentityLinkEntityManager().deleteIdentityLink(processDefinition, userId, groupId);
    return null;
}
Also used : ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)67 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 TaskDefinition (org.activiti.engine.impl.task.TaskDefinition)4 Deployment (org.activiti.engine.test.Deployment)4 Embedded (com.vaadin.ui.Embedded)3 Label (com.vaadin.ui.Label)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)3