public static CmmnResourceEntityManager getCmmnResourceEntityManager() { return getCmmnResourceEntityManager(getCommandContext()); }
@Override public Map<String, EngineResource> getResources() { if (resources == null && id != null) { List<CmmnResourceEntity> resourcesList = CommandContextUtil.getCmmnResourceEntityManager().findResourcesByDeploymentId(id); resources = new HashMap<>(); for (CmmnResourceEntity resource : resourcesList) { resources.put(resource.getName(), resource); } } return resources; }
@Override public InputStream execute(CommandContext commandContext) { if (deploymentId == null) { throw new FlowableIllegalArgumentException("deploymentId is null"); } if (resourceName == null) { throw new FlowableIllegalArgumentException("resourceName is null"); } CmmnResourceEntity resource = CommandContextUtil.getCmmnResourceEntityManager(commandContext) .findResourceByDeploymentIdAndResourceName(deploymentId, resourceName); if (resource == null) { if (CommandContextUtil.getCmmnDeploymentEntityManager(commandContext).findById(deploymentId) == null) { throw new FlowableObjectNotFoundException("deployment does not exist: " + deploymentId, CmmnDeploymentEntity.class); } else { throw new FlowableObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", CmmnResourceEntity.class); } } return new ByteArrayInputStream(resource.getBytes()); }
/** * Creates new diagrams for case definitions if the deployment is new, the case definition in question supports it, and the engine is configured to make new diagrams. * * When this method creates a new diagram, it also persists it via the ResourceEntityManager and adds it to the resources of the deployment. */ protected void createAndPersistNewDiagramsIfNeeded(CmmnParseResult parseResult) { for (CaseDefinitionEntity caseDefinition : parseResult.getAllCaseDefinitions()) { if (caseDefinitionDiagramHelper.shouldCreateDiagram(caseDefinition, parseResult.getDeployment())) { CmmnResourceEntity resource = caseDefinitionDiagramHelper.createDiagramForCaseDefinition( caseDefinition, parseResult.getCmmnModelForCaseDefinition(caseDefinition)); if (resource != null) { CommandContextUtil.getCmmnResourceEntityManager().insert(resource, false); ((CmmnDeploymentEntity) parseResult.getDeployment()).addResource(resource); // now we'll find it if we look for the diagram name later. } } } }