protected void registerDefinition(DeploymentEntity deployment, DefinitionEntity definition, Properties properties) { DeploymentCache deploymentCache = getDeploymentCache(); // Add to cache addDefinitionToDeploymentCache(deploymentCache, definition); definitionAddedToDeploymentCache(deployment, definition, properties); // Add to deployment for further usage deployment.addDeployedArtifact(definition); }
protected void initDeployment(final DeploymentEntity deployment, String... resourceNames) { deployment.clearResources(); for (String resourceName : resourceNames) { if (resourceName != null) { // with the given resource we prevent the deployment of querying // the database which means using all resources that were utilized during the deployment ResourceEntity resource = Context.getCommandContext().getResourceManager().findResourceByDeploymentIdAndResourceName(deployment.getId(), resourceName); deployment.addResource(resource); } } } }
protected DecisionRequirementsDefinitionEntity findDeployedDrdForResource(DeploymentEntity deployment, String resourceName) { List<DecisionRequirementsDefinitionEntity> deployedDrds = deployment.getDeployedArtifacts(DecisionRequirementsDefinitionEntity.class); if (deployedDrds != null) { for (DecisionRequirementsDefinitionEntity deployedDrd : deployedDrds) { if (deployedDrd.getResourceName().equals(resourceName)) { return deployedDrd; } } } return null; }
protected void setDeploymentName(String deploymentId, DeploymentBuilderImpl deploymentBuilder, CommandContext commandContext) { if (deploymentId != null && !deploymentId.isEmpty()) { DeploymentManager deploymentManager = commandContext.getDeploymentManager(); DeploymentEntity deployment = deploymentManager.findDeploymentById(deploymentId); deploymentBuilder.getDeployment().setName(deployment.getName()); } }
protected List<? extends ProcessDefinition> getDeployedProcesses(DeploymentEntity deployment) { List<? extends ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions(); if (deployedProcessDefinitions == null) { // existing deployment CommandContext commandContext = Context.getCommandContext(); ProcessDefinitionManager manager = commandContext.getProcessDefinitionManager(); deployedProcessDefinitions = manager.findProcessDefinitionsByDeploymentId(deployment.getId()); } return deployedProcessDefinitions; }
protected Map<String, ResourceEntity> resolveResourcesToDeploy(CommandContext commandContext, DeploymentEntity deployment) { Map<String, ResourceEntity> resourcesToDeploy = new HashMap<String, ResourceEntity>(); Map<String, ResourceEntity> containedResources = deployment.getResources(); String source = deployment.getSource(); if (source == null || source.isEmpty()) { source = ProcessApplicationDeployment.PROCESS_APPLICATION_DEPLOYMENT_SOURCE; .findLatestResourcesByDeploymentName(deployment.getName(), containedResources.keySet(), source, deployment.getTenantId());
public DelegateStartFormHandler(StartFormHandler formHandler, DeploymentEntity deployment) { super(formHandler, deployment.getId()); }
@Override public DeploymentWithDefinitions call() throws Exception { acquireExclusiveLock(commandContext); DeploymentEntity deployment = initDeployment(); Map<String, ResourceEntity> resourcesToDeploy = resolveResourcesToDeploy(commandContext, deployment); Map<String, ResourceEntity> resourcesToIgnore = new HashMap<String, ResourceEntity>(deployment.getResources()); resourcesToIgnore.keySet().removeAll(resourcesToDeploy.keySet()); if (!resourcesToDeploy.isEmpty()) { LOG.debugCreatingNewDeployment(); deployment.setResources(resourcesToDeploy); deploy(deployment); } else { LOG.usingExistingDeployment(); deployment = getExistingDeployment(commandContext, deployment.getName()); } scheduleProcessDefinitionActivation(commandContext, deployment); if(deploymentBuilder instanceof ProcessApplicationDeploymentBuilder) { // for process application deployments, job executor registration is managed by // process application manager Set<String> processesToRegisterFor = retrieveProcessKeysFromResources(resourcesToIgnore); ProcessApplicationRegistration registration = registerProcessApplication(commandContext, deployment, processesToRegisterFor); return new ProcessApplicationDeploymentImpl(deployment, registration); } else { registerWithJobExecutor(commandContext, deployment); } return deployment; } });
public Collection<String> getResourceNames() { if(deployment.getResources() == null) { return Collections.<String>emptySet(); } else { return deployment.getResources().keySet(); } }
protected void updateDefinitionByLatestDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity latestDefinition) { definition.setVersion(getNextVersion(deployment, definition, latestDefinition)); definition.setId(generateDefinitionId(deployment, definition, latestDefinition)); definition.setDeploymentId(deployment.getId()); definition.setTenantId(deployment.getTenantId()); }
protected List<CaseDefinition> getDeployedCaseDefinitionArtifacts(DeploymentEntity deployment) { CommandContext commandContext = Context.getCommandContext(); // in case deployment was created by this command List<CaseDefinition> entities = deployment.getDeployedCaseDefinitions(); if (entities == null) { String deploymentId = deployment.getId(); CaseDefinitionManager caseDefinitionManager = commandContext.getCaseDefinitionManager(); return caseDefinitionManager.findCaseDefinitionByDeploymentId(deploymentId); } return entities; }
public void insertDeployment(DeploymentEntity deployment) { getDbEntityManager().insert(deployment); createDefaultAuthorizations(deployment); for (ResourceEntity resource : deployment.getResources().values()) { resource.setDeploymentId(deployment.getId()); resource.setType(ResourceTypes.REPOSITORY.getValue()); resource.setCreateTime(ClockUtil.getCurrentTime()); getResourceManager().insertResource(resource); } Context .getProcessEngineConfiguration() .getDeploymentCache() .deploy(deployment); }
public DeploymentBuilder nameFromDeployment(String deploymentId) { String name = deployment.getName(); if (name != null && !name.isEmpty()) { String message = String.format("Cannot set the given deployment id '%s' to get the name from it, because the deployment name has been already set to '%s'.", deploymentId, name); throw new NotValidException(message); } nameFromDeployment = deploymentId; return this; }
protected DeploymentBuilder addBytes(String resourceName, byte[] bytes) { ResourceEntity resource = new ResourceEntity(); resource.setBytes(bytes); resource.setName(resourceName); deployment.addResource(resource); return this; }
protected void scheduleProcessDefinitionActivation(CommandContext commandContext, DeploymentEntity deployment) { if (deploymentBuilder.getProcessDefinitionsActivationDate() != null) { RepositoryService repositoryService = commandContext.getProcessEngineConfiguration().getRepositoryService(); for (ProcessDefinition processDefinition: deployment.getDeployedProcessDefinitions()) { // If activation date is set, we first suspend all the process definition repositoryService .updateProcessDefinitionSuspensionState() .byProcessDefinitionId(processDefinition.getId()) .suspend(); // And we schedule an activation at the provided date repositoryService .updateProcessDefinitionSuspensionState() .byProcessDefinitionId(processDefinition.getId()) .executionDate(deploymentBuilder.getProcessDefinitionsActivationDate()) .activate(); } } }
ResourceEntity resourceEntity = deployment.getResource(resourceLocation); if (resourceEntity != null) { resourceBytes = resourceEntity.getBytes();
protected Map<String, ResourceEntity> resolveResourcesToDeploy(CommandContext commandContext, DeploymentEntity deployment) { Map<String, ResourceEntity> resourcesToDeploy = new HashMap<String, ResourceEntity>(); Map<String, ResourceEntity> containedResources = deployment.getResources(); String source = deployment.getSource(); if (source == null || source.isEmpty()) { source = ProcessApplicationDeployment.PROCESS_APPLICATION_DEPLOYMENT_SOURCE; .findLatestResourcesByDeploymentName(deployment.getName(), containedResources.keySet(), source, deployment.getTenantId());
public DelegateTaskFormHandler(TaskFormHandler formHandler, DeploymentEntity deployment) { super(formHandler, deployment.getId()); }
@Override public DeploymentWithDefinitions call() throws Exception { acquireExclusiveLock(commandContext); DeploymentEntity deployment = initDeployment(); Map<String, ResourceEntity> resourcesToDeploy = resolveResourcesToDeploy(commandContext, deployment); Map<String, ResourceEntity> resourcesToIgnore = new HashMap<String, ResourceEntity>(deployment.getResources()); resourcesToIgnore.keySet().removeAll(resourcesToDeploy.keySet()); if (!resourcesToDeploy.isEmpty()) { LOG.debugCreatingNewDeployment(); deployment.setResources(resourcesToDeploy); deploy(deployment); } else { LOG.usingExistingDeployment(); deployment = getExistingDeployment(commandContext, deployment.getName()); } scheduleProcessDefinitionActivation(commandContext, deployment); if(deploymentBuilder instanceof ProcessApplicationDeploymentBuilder) { // for process application deployments, job executor registration is managed by // process application manager Set<String> processesToRegisterFor = retrieveProcessKeysFromResources(resourcesToIgnore); ProcessApplicationRegistration registration = registerProcessApplication(commandContext, deployment, processesToRegisterFor); return new ProcessApplicationDeploymentImpl(deployment, registration); } else { registerWithJobExecutor(commandContext, deployment); } return deployment; } });
protected List<? extends ProcessDefinition> getDeployedProcesses(DeploymentEntity deployment) { List<? extends ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions(); if (deployedProcessDefinitions == null) { // existing deployment CommandContext commandContext = Context.getCommandContext(); ProcessDefinitionManager manager = commandContext.getProcessDefinitionManager(); deployedProcessDefinitions = manager.findProcessDefinitionsByDeploymentId(deployment.getId()); } return deployedProcessDefinitions; }