Java Code Examples for org.flowable.engine.repository.Deployment#getParentDeploymentId()

The following examples show how to use org.flowable.engine.repository.Deployment#getParentDeploymentId() . 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: GetDecisionsForProcessDefinitionCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addDecisionToCollection(List<DmnDecision> decisions, String decisionKey, ProcessDefinition processDefinition) {
    DmnDecisionQuery definitionQuery = dmnRepositoryService.createDecisionQuery().decisionKey(decisionKey);
    Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(processDefinition.getDeploymentId());
    if (deployment.getParentDeploymentId() != null) {
        List<DmnDeployment> dmnDeployments = dmnRepositoryService.createDeploymentQuery().parentDeploymentId(deployment.getParentDeploymentId()).list();
        
        if (dmnDeployments != null && dmnDeployments.size() > 0) {
            definitionQuery.deploymentId(dmnDeployments.get(0).getId());
        } else {
            definitionQuery.latestVersion();
        }
        
    } else {
        definitionQuery.latestVersion();
    }
    
    DmnDecision decision = definitionQuery.singleResult();
    
    if (decision != null) {
        decisions.add(decision);
    }
}
 
Example 2
Source File: GetFormDefinitionsForProcessDefinitionCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addFormDefinitionToCollection(List<FormDefinition> formDefinitions, String formKey, ProcessDefinition processDefinition) {
    FormDefinitionQuery formDefinitionQuery = formRepositoryService.createFormDefinitionQuery().formDefinitionKey(formKey);
    Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(processDefinition.getDeploymentId());
    if (deployment.getParentDeploymentId() != null) {
        List<FormDeployment> formDeployments = formRepositoryService.createDeploymentQuery().parentDeploymentId(deployment.getParentDeploymentId()).list();
        
        if (formDeployments != null && formDeployments.size() > 0) {
            formDefinitionQuery.deploymentId(formDeployments.get(0).getId());
        } else {
            formDefinitionQuery.latestVersion();
        }
        
    } else {
        formDefinitionQuery.latestVersion();
    }
    
    FormDefinition formDefinition = formDefinitionQuery.singleResult();
    
    if (formDefinition != null) {
        formDefinitions.add(formDefinition);
    }
}
 
Example 3
Source File: BaseDynamicSubProcessInjectUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected static void processUserTask(FlowElement flowElement, ProcessDefinition originalProcessDefinitionEntity, 
                DeploymentEntity newDeploymentEntity, CommandContext commandContext) {
    
    if (flowElement instanceof UserTask) {
        FormRepositoryService formRepositoryService = CommandContextUtil.getFormRepositoryService();
        if (formRepositoryService != null) {
            UserTask userTask = (UserTask) flowElement;
            if (StringUtils.isNotEmpty(userTask.getFormKey())) {
                Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(originalProcessDefinitionEntity.getDeploymentId());
                if (deployment.getParentDeploymentId() != null) {
                    List<FormDeployment> formDeployments = formRepositoryService.createDeploymentQuery().parentDeploymentId(deployment.getParentDeploymentId()).list();
                    
                    if (formDeployments != null && formDeployments.size() > 0) {
                    
                        FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery()
                                .formDefinitionKey(userTask.getFormKey()).deploymentId(formDeployments.get(0).getId()).latestVersion().singleResult();
                        if (formDefinition != null) {
                            String name = formDefinition.getResourceName();
                            InputStream inputStream = formRepositoryService.getFormDefinitionResource(formDefinition.getId());
                            addResource(commandContext, newDeploymentEntity, name, IoUtil.readInputStream(inputStream, name));
                            IoUtil.closeSilently(inputStream);
                        }
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: BaseDynamicSubProcessInjectUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected static void processDecisionTask(FlowElement flowElement, ProcessDefinition originalProcessDefinitionEntity, 
                DeploymentEntity newDeploymentEntity, CommandContext commandContext) {
    
    if (flowElement instanceof ServiceTask && ServiceTask.DMN_TASK.equals(((ServiceTask) flowElement).getType())) {
                
        DmnRepositoryService dmnRepositoryService = CommandContextUtil.getDmnRepositoryService();
        if (dmnRepositoryService != null) {
            ServiceTask serviceTask = (ServiceTask) flowElement;
            if (serviceTask.getFieldExtensions() != null && serviceTask.getFieldExtensions().size() > 0) {
                String decisionTableReferenceKey = null;
                for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) {
                    if ("decisionTableReferenceKey".equals(fieldExtension.getFieldName())) {
                        decisionTableReferenceKey = fieldExtension.getStringValue();
                        break;
                    }
                }

                if (decisionTableReferenceKey != null) {
                    Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(originalProcessDefinitionEntity.getDeploymentId());
                    if (deployment.getParentDeploymentId() != null) {
                        List<DmnDeployment> dmnDeployments = dmnRepositoryService.createDeploymentQuery().parentDeploymentId(deployment.getParentDeploymentId()).list();
                        
                        if (dmnDeployments != null && dmnDeployments.size() > 0) {
                            DmnDecision definition = dmnRepositoryService.createDecisionQuery()
                                    .decisionKey(decisionTableReferenceKey).deploymentId(dmnDeployments.get(0).getId()).latestVersion().singleResult();
                            if (definition != null) {
                                String name = definition.getResourceName();
                                InputStream inputStream = dmnRepositoryService.getDmnResource(definition.getId());
                                addResource(commandContext, newDeploymentEntity, name, IoUtil.readInputStream(inputStream, name));
                                IoUtil.closeSilently(inputStream);
                            }
                        }
                    }
                }
            }
        }
    }
}