Search in sources :

Example 1 with WorkflowProcess

use of org.jbpm.workflow.core.WorkflowProcess in project jbpm by kiegroup.

the class CaseRuntimeDataServiceImpl method onDeploy.

/*
     * Deploy and undeploy handling
     */
@Override
public void onDeploy(DeploymentEvent event) {
    AbstractRuntimeManager runtimeManager = (AbstractRuntimeManager) event.getDeployedUnit().getRuntimeManager();
    KieBase kieBase = runtimeManager.getEnvironment().getKieBase();
    Collection<Process> processes = kieBase.getProcesses();
    Map<String, DeployedAsset> mapProcessById = event.getDeployedUnit().getDeployedAssets().stream().collect(toMap(DeployedAsset::getId, asset -> asset));
    for (Process process : processes) {
        if (((WorkflowProcess) process).isDynamic()) {
            String caseIdPrefix = collectCaseIdPrefix(process);
            Collection<CaseMilestone> caseMilestones = collectMilestoness(process);
            Collection<CaseStage> caseStages = collectCaseStages(event.getDeploymentId(), process.getId(), ((WorkflowProcess) process));
            Collection<CaseRole> caseRoles = collectCaseRoles(process);
            Collection<AdHocFragment> adHocFragments = collectAdHocFragments((WorkflowProcess) process);
            Map<String, List<String>> dataAccessRestrictions = collectDataAccessRestrictions(process);
            CaseDefinitionImpl caseDef = new CaseDefinitionImpl((ProcessAssetDesc) mapProcessById.get(process.getId()), caseIdPrefix, caseStages, caseMilestones, caseRoles, adHocFragments, dataAccessRestrictions);
            availableCases.add(caseDef);
            caseIdGenerator.register(caseIdPrefix);
        }
    }
    // collect role information
    Collection<DeployedAsset> assets = event.getDeployedUnit().getDeployedAssets();
    List<String> roles = null;
    for (DeployedAsset asset : assets) {
        if (asset instanceof ProcessAssetDesc) {
            // if it's not dynamic it's considered as not case definition
            if (!((ProcessAssetDesc) asset).isDynamic()) {
                availableProcesses.add((ProcessAssetDesc) asset);
            }
            if (roles == null) {
                roles = ((ProcessAssetDesc) asset).getRoles();
            }
        }
    }
    if (roles == null) {
        roles = Collections.emptyList();
    }
    deploymentRolesManager.addRolesForDeployment(event.getDeploymentId(), roles);
}
Also used : TaskSummary(org.kie.api.task.model.TaskSummary) Arrays(java.util.Arrays) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) StartNode(org.jbpm.workflow.core.node.StartNode) CaseRuntimeDataService(org.jbpm.casemgmt.api.CaseRuntimeDataService) CaseDefinitionComparator(org.jbpm.casemgmt.impl.model.CaseDefinitionComparator) Collectors.toMap(java.util.stream.Collectors.toMap) NodeInstanceDesc(org.jbpm.kie.services.impl.model.NodeInstanceDesc) Map(java.util.Map) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) KieInternalServices(org.kie.internal.KieInternalServices) AuthorizationManager(org.jbpm.casemgmt.api.auth.AuthorizationManager) CaseMilestoneInstance(org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance) CaseMilestone(org.jbpm.casemgmt.api.model.CaseMilestone) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Process(org.kie.api.definition.process.Process) FILTER(org.kie.internal.query.QueryParameterIdentifiers.FILTER) Set(java.util.Set) DeploymentRolesManager(org.jbpm.kie.services.impl.security.DeploymentRolesManager) QueryContext(org.kie.api.runtime.query.QueryContext) Collectors(java.util.stream.Collectors) CaseMilestoneInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseMilestoneInstanceImpl) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ProcessAssetDesc(org.jbpm.kie.services.impl.model.ProcessAssetDesc) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem) List(java.util.List) DeployedAsset(org.jbpm.services.api.model.DeployedAsset) MilestoneNode(org.jbpm.workflow.core.node.MilestoneNode) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) ServiceRegistry(org.jbpm.services.api.service.ServiceRegistry) CorrelationKeyFactory(org.kie.internal.process.CorrelationKeyFactory) Status(org.kie.api.task.model.Status) NodeContainer(org.kie.api.definition.process.NodeContainer) AdHocFragmentImpl(org.jbpm.casemgmt.impl.model.AdHocFragmentImpl) CaseDefinitionImpl(org.jbpm.casemgmt.impl.model.CaseDefinitionImpl) CaseRole(org.jbpm.casemgmt.api.model.CaseRole) CaseRoleImpl(org.jbpm.casemgmt.impl.model.CaseRoleImpl) CaseStageInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseStageInstanceImpl) CaseNotFoundException(org.jbpm.casemgmt.api.CaseNotFoundException) HashMap(java.util.HashMap) DeploymentEventListener(org.jbpm.services.api.DeploymentEventListener) TransactionalCommandService(org.jbpm.shared.services.impl.TransactionalCommandService) ArrayList(java.util.ArrayList) ProcessDefinitionComparator(org.jbpm.casemgmt.impl.model.ProcessDefinitionComparator) HashSet(java.util.HashSet) CaseStageInstance(org.jbpm.casemgmt.api.model.instance.CaseStageInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeploymentEvent(org.jbpm.services.api.DeploymentEvent) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) StageStatus(org.jbpm.casemgmt.api.model.instance.StageStatus) CaseStage(org.jbpm.casemgmt.api.model.CaseStage) CaseStageImpl(org.jbpm.casemgmt.impl.model.CaseStageImpl) KieBase(org.kie.api.KieBase) IdentityProvider(org.kie.internal.identity.IdentityProvider) QueryManager(org.jbpm.shared.services.impl.QueryManager) CorrelationKey(org.kie.internal.process.CorrelationKey) QueryNameCommand(org.jbpm.shared.services.impl.commands.QueryNameCommand) CaseIdGenerator(org.jbpm.casemgmt.api.generator.CaseIdGenerator) Collectors.toList(java.util.stream.Collectors.toList) Node(org.kie.api.definition.process.Node) RuntimeDataService(org.jbpm.services.api.RuntimeDataService) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus) CaseMilestoneImpl(org.jbpm.casemgmt.impl.model.CaseMilestoneImpl) CommonUtils.getAuthenticatedUserRoles(org.jbpm.kie.services.impl.CommonUtils.getAuthenticatedUserRoles) Collections(java.util.Collections) DeployedAsset(org.jbpm.services.api.model.DeployedAsset) CaseMilestone(org.jbpm.casemgmt.api.model.CaseMilestone) CaseStage(org.jbpm.casemgmt.api.model.CaseStage) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) CaseDefinitionImpl(org.jbpm.casemgmt.impl.model.CaseDefinitionImpl) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) Process(org.kie.api.definition.process.Process) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) ProcessAssetDesc(org.jbpm.kie.services.impl.model.ProcessAssetDesc) KieBase(org.kie.api.KieBase) CaseRole(org.jbpm.casemgmt.api.model.CaseRole) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 2 with WorkflowProcess

use of org.jbpm.workflow.core.WorkflowProcess in project jbpm by kiegroup.

the class SubProcessNodeBuilder method build.

@Override
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    WorkflowProcess wfProcess = (WorkflowProcess) process;
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("imports", wfProcess.getImports());
    parameters.put("classloader", context.getConfiguration().getClassLoader());
    for (DataAssociation dataAssociation : ((SubProcessNode) node).getInAssociations()) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
    }
    for (DataAssociation dataAssociation : ((SubProcessNode) node).getOutAssociations()) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) DataAssociation(org.jbpm.workflow.core.node.DataAssociation) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 3 with WorkflowProcess

use of org.jbpm.workflow.core.WorkflowProcess in project jbpm by kiegroup.

the class WorkItemNodeBuilder method build.

public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    WorkflowProcess wfProcess = (WorkflowProcess) process;
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("imports", wfProcess.getImports());
    parameters.put("classloader", context.getConfiguration().getClassLoader());
    for (DataAssociation dataAssociation : ((WorkItemNode) node).getInAssociations()) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
        List<Assignment> assignments = dataAssociation.getAssignments();
        if (assignments != null) {
            for (Assignment assignment : assignments) {
                ProcessDialect dialect = ProcessDialectRegistry.getDialect(assignment.getDialect());
                dialect.getAssignmentBuilder().build(context, assignment, dataAssociation.getSources().get(0), dataAssociation.getTarget(), ((WorkItemNode) node), true);
            }
        }
    }
    for (DataAssociation dataAssociation : ((WorkItemNode) node).getOutAssociations()) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
        List<Assignment> assignments = dataAssociation.getAssignments();
        if (assignments != null) {
            for (Assignment assignment : assignments) {
                ProcessDialect dialect = ProcessDialectRegistry.getDialect(assignment.getDialect());
                dialect.getAssignmentBuilder().build(context, assignment, dataAssociation.getSources().get(0), dataAssociation.getTarget(), ((WorkItemNode) node), false);
            }
        }
    }
}
Also used : Assignment(org.jbpm.workflow.core.node.Assignment) Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) DataAssociation(org.jbpm.workflow.core.node.DataAssociation) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 4 with WorkflowProcess

use of org.jbpm.workflow.core.WorkflowProcess in project jbpm by kiegroup.

the class ActionNodeBuilder method build.

public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    ActionNode actionNode = (ActionNode) node;
    DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
    ActionDescr actionDescr = new ActionDescr();
    actionDescr.setText(action.getConsequence());
    actionDescr.setResource(processDescr.getResource());
    ProcessDialect dialect = ProcessDialectRegistry.getDialect(action.getDialect());
    dialect.getActionBuilder().build(context, action, actionDescr, (NodeImpl) node);
    Transformation transformation = (Transformation) node.getMetaData().get("Transformation");
    if (transformation != null) {
        WorkflowProcess wfProcess = (WorkflowProcess) process;
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("imports", wfProcess.getImports());
        parameters.put("classloader", context.getConfiguration().getClassLoader());
        DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
        transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) ActionDescr(org.drools.compiler.lang.descr.ActionDescr) ActionNode(org.jbpm.workflow.core.node.ActionNode) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 5 with WorkflowProcess

use of org.jbpm.workflow.core.WorkflowProcess in project jbpm by kiegroup.

the class EventNodeBuilder method build.

@Override
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    Transformation transformation = (Transformation) node.getMetaData().get("Transformation");
    if (transformation != null) {
        WorkflowProcess wfProcess = (WorkflowProcess) process;
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("imports", wfProcess.getImports());
        parameters.put("classloader", context.getConfiguration().getClassLoader());
        DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
        transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Aggregations

HashMap (java.util.HashMap)7 WorkflowProcess (org.jbpm.workflow.core.WorkflowProcess)7 Transformation (org.jbpm.workflow.core.node.Transformation)6 DataTransformer (org.kie.api.runtime.process.DataTransformer)6 DataAssociation (org.jbpm.workflow.core.node.DataAssociation)3 ProcessDialect (org.jbpm.process.builder.dialect.ProcessDialect)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 ActionDescr (org.drools.compiler.lang.descr.ActionDescr)1 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)1