org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity Java Examples
The following examples show how to use
org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity.
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: CmmnTransformerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Before public void setup() { CmmnTransformer transformerWrapper = new CmmnTransformer(null, new DefaultCmmnElementHandlerRegistry(), null); transformer = new CmmnTransform(transformerWrapper); deployment = new DeploymentEntity(); deployment.setId("aDeploymentId"); transformer.setDeployment(deployment); modelInstance = Cmmn.createEmptyModel(); definitions = modelInstance.newInstance(Definitions.class); definitions.setTargetNamespace("http://camunda.org/examples"); modelInstance.setDefinitions(definitions); caseDefinition = createElement(definitions, "aCaseDefinition", Case.class); casePlanModel = createElement(caseDefinition, "aCasePlanModel", CasePlanModel.class); }
Example #2
Source File: DefaultFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void parseConfiguration(Element activityElement, DeploymentEntity deployment, ProcessDefinitionEntity processDefinition, BpmnParse bpmnParse) { this.deploymentId = deployment.getId(); ExpressionManager expressionManager = Context .getProcessEngineConfiguration() .getExpressionManager(); Element extensionElement = activityElement.element("extensionElements"); if (extensionElement != null) { // provide support for deprecated form properties parseFormProperties(bpmnParse, expressionManager, extensionElement); // provide support for new form field metadata parseFormData(bpmnParse, expressionManager, extensionElement); } }
Example #3
Source File: DefaultStartFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void parseConfiguration(Element activityElement, DeploymentEntity deployment, ProcessDefinitionEntity processDefinition, BpmnParse bpmnParse) { super.parseConfiguration(activityElement, deployment, processDefinition, bpmnParse); ExpressionManager expressionManager = Context .getProcessEngineConfiguration() .getExpressionManager(); String formKeyAttribute = activityElement.attributeNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "formKey"); if (formKeyAttribute != null) { this.formKey = expressionManager.createExpression(formKeyAttribute); } if (formKey != null) { processDefinition.setStartFormKey(true); } }
Example #4
Source File: XlsxDeployer.java From camunda-dmn-xlsx with Apache License 2.0 | 6 votes |
public void deploy(DeploymentEntity deployment) { if (!deployment.isNew()) { // only generate dmn xml once when deploying for the first time return; } List<ResourceEntity> generatedResources = new ArrayList<ResourceEntity>(); for (ResourceEntity resource : deployment.getResources().values()) { if (canHandle(resource)) { XlsxDeploymentMetaData metaData = loadMetaData(deployment, resource.getName() + ".yaml"); DmnModelInstance dmnModel = generateDmnModel(resource, metaData); ResourceEntity dmnResource = generateDeploymentResource(deployment, dmnModel, generateDmnResourceName(resource)); generatedResources.add(dmnResource); } } addToDeployment(generatedResources, deployment); }
Example #5
Source File: XlsxDeployer.java From camunda-dmn-xlsx with Apache License 2.0 | 6 votes |
protected ResourceEntity generateDeploymentResource(DeploymentEntity deployment, DmnModelInstance dmnModel, String name) { ResourceEntity resource = new ResourceEntity(); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Dmn.writeModelToStream(byteStream, dmnModel); byte[] bytes = byteStream.toByteArray(); resource.setName(name); resource.setBytes(bytes); resource.setDeploymentId(deployment.getId()); // Mark the resource as 'generated' resource.setGenerated(true); return resource; }
Example #6
Source File: ResourceDefinitionCache.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public T resolveDefinition(T definition) { String definitionId = definition.getId(); String deploymentId = definition.getDeploymentId(); T cachedDefinition = cache.get(definitionId); if (cachedDefinition == null) { synchronized (this) { cachedDefinition = cache.get(definitionId); if (cachedDefinition == null) { DeploymentEntity deployment = Context .getCommandContext() .getDeploymentManager() .findDeploymentById(deploymentId); deployment.setNew(false); cacheDeployer.deployOnlyGivenResourcesOfDeployment(deployment, definition.getResourceName(), definition.getDiagramResourceName()); cachedDefinition = cache.get(definitionId); } } checkInvalidDefinitionWasCached(deploymentId, definitionId, cachedDefinition); } if (cachedDefinition != null) { cachedDefinition.updateModifiableFieldsFromEntity(definition); } return cachedDefinition; }
Example #7
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * create an id for the definition. The default is to ask the {@link IdGenerator} * and add the definition key and version if that does not exceed 64 characters. * You might want to hook in your own implementation here. */ protected String generateDefinitionId(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition) { String nextId = idGenerator.getNextId(); String definitionKey = newDefinition.getKey(); int definitionVersion = newDefinition.getVersion(); String definitionId = definitionKey + ":" + definitionVersion + ":" + nextId; // ACT-115: maximum id length is 64 characters if (definitionId.length() > 64) { definitionId = nextId; } return definitionId; }
Example #8
Source File: DeployCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void addResources(List<ResourceEntity> resources, DeploymentBuilderImpl deploymentBuilder) { DeploymentEntity deployment = deploymentBuilder.getDeployment(); Map<String, ResourceEntity> existingResources = deployment.getResources(); for (ResourceEntity resource : resources) { String resourceName = resource.getName(); if (existingResources != null && existingResources.containsKey(resourceName)) { String message = String.format("Cannot add resource with id '%s' and name '%s' from " + "deployment with id '%s' to new deployment because the new deployment contains " + "already a resource with same name.", resource.getId(), resourceName, resource.getDeploymentId()); throw new NotValidException(message); } ByteArrayInputStream inputStream = new ByteArrayInputStream(resource.getBytes()); deploymentBuilder.addInputStream(resourceName, inputStream); } }
Example #9
Source File: DeployCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected List<ResourceEntity> getResourcesByDeploymentId(Set<String> deploymentIds, CommandContext commandContext) { List<ResourceEntity> result = new ArrayList<>(); if (!deploymentIds.isEmpty()) { DeploymentManager deploymentManager = commandContext.getDeploymentManager(); for (String deploymentId : deploymentIds) { DeploymentEntity deployment = deploymentManager.findDeploymentById(deploymentId); Map<String, ResourceEntity> resources = deployment.getResources(); Collection<ResourceEntity> values = resources.values(); result.addAll(values); } } return result; }
Example #10
Source File: DeployCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected String[] getProcessDefinitionsFromResources(CommandContext commandContext, DeploymentEntity deploymentToRegister, Collection ignoredResources) { Set<String> processDefinitionKeys = new HashSet<>(); // get process definition keys for already available process definitions processDefinitionKeys.addAll(parseProcessDefinitionKeys(ignoredResources)); // get process definition keys for updated process definitions for (ProcessDefinition processDefinition : getDeployedProcesses(commandContext, deploymentToRegister)) { if (processDefinition.getVersion() > 1) { processDefinitionKeys.add(processDefinition.getKey()); } } return processDefinitionKeys.toArray(new String[processDefinitionKeys.size()]); }
Example #11
Source File: DeployCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void ensureDeploymentsWithIdsExists(Set<String> expected, List<DeploymentEntity> actual) { Map<String, DeploymentEntity> deploymentMap = new HashMap<>(); for (DeploymentEntity deployment : actual) { deploymentMap.put(deployment.getId(), deployment); } List<String> missingDeployments = getMissingElements(expected, deploymentMap); if (!missingDeployments.isEmpty()) { StringBuilder builder = new StringBuilder(); builder.append("The following deployments are not found by id: "); builder.append(StringUtil.join(missingDeployments.iterator())); throw new NotFoundException(builder.toString()); } }
Example #12
Source File: BpmnDeployer.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override protected List<ProcessDefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { byte[] bytes = resource.getBytes(); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); BpmnParse bpmnParse = bpmnParser .createParse() .sourceInputStream(inputStream) .deployment(deployment) .name(resource.getName()); if (!deployment.isValidatingSchema()) { bpmnParse.setSchemaResource(null); } bpmnParse.execute(); if (!properties.contains(JOB_DECLARATIONS_PROPERTY)) { properties.set(JOB_DECLARATIONS_PROPERTY, new HashMap<String, List<JobDeclaration<?, ?>>>()); } properties.get(JOB_DECLARATIONS_PROPERTY).putAll(bpmnParse.getJobDeclarations()); return bpmnParse.getProcessDefinitions(); }
Example #13
Source File: DecisionRequirementsDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override protected List<DecisionRequirementsDefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { byte[] bytes = resource.getBytes(); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); try { DecisionRequirementsDefinitionEntity drd = transformer .createTransform() .modelInstance(inputStream) .transformDecisionRequirementsGraph(); return Collections.singletonList(drd); } catch (Exception e) { throw LOG.exceptionParseDmnResource(resource.getName(), e); } }
Example #14
Source File: ProcessApplicationManager.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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; }
Example #15
Source File: DecisionRequirementsDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected void updateDefinitionByPersistedDefinition(DeploymentEntity deployment, DecisionRequirementsDefinitionEntity definition, DecisionRequirementsDefinitionEntity persistedDefinition) { // cannot update the definition if it is not persistent if (persistedDefinition != null) { super.updateDefinitionByPersistedDefinition(deployment, definition, persistedDefinition); } }
Example #16
Source File: XlsxDeployer.java From camunda-dmn-xlsx with Apache License 2.0 | 5 votes |
protected void addToDeployment(List<ResourceEntity> generatedResources, DeploymentEntity deployment) { for (ResourceEntity resource : generatedResources) { Context.getCommandContext().getResourceManager().insert(resource); deployment.addResource(resource); } }
Example #17
Source File: BpmnDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected void definitionAddedToDeploymentCache(DeploymentEntity deployment, ProcessDefinitionEntity definition, Properties properties) { List<JobDeclaration<?, ?>> declarations = properties.get(JOB_DECLARATIONS_PROPERTY).get(definition.getKey()); updateJobDeclarations(declarations, definition, deployment.isNew()); ProcessDefinitionEntity latestDefinition = findLatestDefinitionByKeyAndTenantId(definition.getKey(), definition.getTenantId()); if (deployment.isNew()) { adjustStartEventSubscriptions(definition, latestDefinition); } // add "authorizations" addAuthorizations(definition); }
Example #18
Source File: ResourceUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Parse a camunda:resource attribute and loads the resource depending on the url scheme. * Supported URL schemes are <code>classpath://</code> and <code>deployment://</code>. * If the scheme is omitted <code>classpath://</code> is assumed. * * @param resourcePath the path to the resource to load * @param deployment the deployment to load resources from * @return the resource content as {@link String} */ public static String loadResourceContent(String resourcePath, DeploymentEntity deployment) { String[] pathSplit = resourcePath.split("://", 2); String resourceType; if (pathSplit.length == 1) { resourceType = "classpath"; } else { resourceType = pathSplit[0]; } String resourceLocation = pathSplit[pathSplit.length - 1]; byte[] resourceBytes = null; if (resourceType.equals("classpath")) { InputStream resourceAsStream = null; try { resourceAsStream = ReflectUtil.getResourceAsStream(resourceLocation); if (resourceAsStream != null) { resourceBytes = IoUtil.readInputStream(resourceAsStream, resourcePath); } } finally { IoUtil.closeSilently(resourceAsStream); } } else if (resourceType.equals("deployment")) { ResourceEntity resourceEntity = deployment.getResource(resourceLocation); if (resourceEntity != null) { resourceBytes = resourceEntity.getBytes(); } } if (resourceBytes != null) { return new String(resourceBytes, Charset.forName("UTF-8")); } else { throw LOG.cannotFindResource(resourcePath); } }
Example #19
Source File: DecisionDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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; }
Example #20
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void deploy(DeploymentEntity deployment) { LOG.debugProcessingDeployment(deployment.getName()); Properties properties = new Properties(); List<DefinitionEntity> definitions = parseDefinitionResources(deployment, properties); ensureNoDuplicateDefinitionKeys(definitions); postProcessDefinitions(deployment, definitions, properties); }
Example #21
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<DefinitionEntity> parseDefinitionResources(DeploymentEntity deployment, Properties properties) { List<DefinitionEntity> definitions = new ArrayList<DefinitionEntity>(); for (ResourceEntity resource : deployment.getResources().values()) { LOG.debugProcessingResource(resource.getName()); if (isResourceHandled(resource)) { definitions.addAll(transformResource(deployment, resource, properties)); } } return definitions; }
Example #22
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected Collection<DefinitionEntity> transformResource(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { String resourceName = resource.getName(); List<DefinitionEntity> definitions = transformDefinitions(deployment, resource, properties); for (DefinitionEntity definition : definitions) { definition.setResourceName(resourceName); String diagramResourceName = getDiagramResourceForDefinition(deployment, resourceName, definition, deployment.getResources()); if (diagramResourceName != null) { definition.setDiagramResourceName(diagramResourceName); } } return definitions; }
Example #23
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void postProcessDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties) { if (deployment.isNew()) { // if the deployment is new persist the new definitions persistDefinitions(deployment, definitions, properties); } else { // if the current deployment is not a new one, // then load the already existing definitions loadDefinitions(deployment, definitions, properties); } }
Example #24
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void persistDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties) { for (DefinitionEntity definition : definitions) { String definitionKey = definition.getKey(); String tenantId = deployment.getTenantId(); DefinitionEntity latestDefinition = findLatestDefinitionByKeyAndTenantId(definitionKey, tenantId); updateDefinitionByLatestDefinition(deployment, definition, latestDefinition); persistDefinition(definition); registerDefinition(deployment, definition, properties); } }
Example #25
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void loadDefinitions(DeploymentEntity deployment, List<DefinitionEntity> definitions, Properties properties) { for (DefinitionEntity definition : definitions) { String deploymentId = deployment.getId(); String definitionKey = definition.getKey(); DefinitionEntity persistedDefinition = findDefinitionByDeploymentAndKey(deploymentId, definitionKey); handlePersistedDefinition(definition, persistedDefinition, deployment, properties); } }
Example #26
Source File: DeployCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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()); } }
Example #27
Source File: DeployCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ProcessApplicationRegistration registerProcessApplication(CommandContext commandContext, DeploymentEntity deploymentToRegister, CandidateDeployment candidateDeployment, Collection ignoredResources) { ProcessApplicationDeploymentBuilderImpl appDeploymentBuilder = (ProcessApplicationDeploymentBuilderImpl) deploymentBuilder; final ProcessApplicationReference appReference = appDeploymentBuilder.getProcessApplicationReference(); // build set of deployment ids this process app should be registered for: Set<String> deploymentsToRegister = new HashSet<>(Collections.singleton(deploymentToRegister.getId())); if (appDeploymentBuilder.isResumePreviousVersions()) { String resumePreviousBy = appDeploymentBuilder.getResumePreviousVersionsBy(); switch (resumePreviousBy) { case ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME: deploymentsToRegister.addAll(deploymentHandler .determineDeploymentsToResumeByDeploymentName(candidateDeployment)); break; case ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY: default: String[] processDefinitionKeys = getProcessDefinitionsFromResources(commandContext, deploymentToRegister, ignoredResources); // only determine deployments to resume if there are actual process definitions to look for if (processDefinitionKeys.length > 0) { deploymentsToRegister.addAll(deploymentHandler .determineDeploymentsToResumeByProcessDefinitionKey(processDefinitionKeys)); } break; } } // register process application for deployments return new RegisterProcessApplicationCmd(deploymentsToRegister, appReference).execute(commandContext); }
Example #28
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); }
Example #29
Source File: AbstractDefinitionDeployer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * per default we increment the latest definition version by one - but you * might want to hook in some own logic here, e.g. to align definition * versions with deployment / build versions. */ protected int getNextVersion(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition) { int result = 1; if (latestDefinition != null) { int latestVersion = latestDefinition.getVersion(); result = latestVersion + 1; } return result; }
Example #30
Source File: XlsxDeployer.java From camunda-dmn-xlsx with Apache License 2.0 | 5 votes |
protected XlsxDeploymentMetaData loadMetaData(DeploymentEntity deployment, String metaDataResource) { ResourceEntity resource = deployment.getResource(metaDataResource); if (resource != null) { ByteArrayInputStream inputStream = new ByteArrayInputStream(resource.getBytes()); Yaml yaml = new Yaml(); return yaml.loadAs(inputStream, XlsxDeploymentMetaData.class); } else { return null; } }