public DecisionDefinitionEntity getPreviousDefinition() { DecisionDefinitionEntity previousDecisionDefinition = null; String previousDecisionDefinitionId = getPreviousDecisionDefinitionId(); if (previousDecisionDefinitionId != null) { previousDecisionDefinition = loadDecisionDefinition(previousDecisionDefinitionId); if (previousDecisionDefinition == null) { resetPreviousDecisionDefinitionId(); previousDecisionDefinitionId = getPreviousDecisionDefinitionId(); if (previousDecisionDefinitionId != null) { previousDecisionDefinition = loadDecisionDefinition(previousDecisionDefinitionId); } } } return previousDecisionDefinition; }
public void checkReadDecisionDefinition(DecisionDefinitionEntity decisionDefinition) { if (decisionDefinition != null && !getTenantManager().isAuthenticatedTenant(decisionDefinition.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("get the decision definition '"+ decisionDefinition.getId() + "'"); } }
@Override protected DmnDecisionImpl createDmnElement() { return new DecisionDefinitionEntity(); }
@Override protected DmnDecisionImpl createFromDecision(DmnElementTransformContext context, Decision decision) { DecisionDefinitionEntity decisionDefinition = (DecisionDefinitionEntity) super.createFromDecision(context, decision); String category = context.getModelInstance().getDefinitions().getNamespace(); decisionDefinition.setCategory(category); decisionDefinition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(decision.getCamundaHistoryTimeToLiveString())); decisionDefinition.setVersionTag(decision.getVersionTag()); return decisionDefinition; }
@Override protected List<DecisionDefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { List<DecisionDefinitionEntity> decisions = new ArrayList<DecisionDefinitionEntity>(); // get the decisions from the deployed drd instead of parse the DMN again DecisionRequirementsDefinitionEntity deployedDrd = findDeployedDrdForResource(deployment, resource.getName()); if (deployedDrd == null) { throw LOG.exceptionNoDrdForResource(resource.getName()); } Collection<DmnDecision> decisionsOfDrd = deployedDrd.getDecisions(); for (DmnDecision decisionOfDrd : decisionsOfDrd) { DecisionDefinitionEntity decisionEntity = (DecisionDefinitionEntity) decisionOfDrd; if (DecisionRequirementsDefinitionDeployer.isDecisionRequirementsDefinitionPersistable(deployedDrd)) { decisionEntity.setDecisionRequirementsDefinitionId(deployedDrd.getId()); decisionEntity.setDecisionRequirementsDefinitionKey(deployedDrd.getKey()); } decisions.add(decisionEntity); } if (!DecisionRequirementsDefinitionDeployer.isDecisionRequirementsDefinitionPersistable(deployedDrd)) { deployment.removeArtifact(deployedDrd); } return decisions; }
public void checkUpdateDecisionDefinition(DecisionDefinitionEntity decisionDefinition) { getAuthorizationManager().checkAuthorization(UPDATE, DECISION_DEFINITION, decisionDefinition.getKey()); }
@Test public void getPreviousDecisionDefinitionWithTenantId() { testRule.deployForTenant(TENANT_ONE, DMN); testRule.deployForTenant(TENANT_ONE, DMN); testRule.deployForTenant(TENANT_ONE, DMN); testRule.deployForTenant(TENANT_TWO, DMN); testRule.deployForTenant(TENANT_TWO, DMN); List<DecisionDefinition> latestDefinitions = repositoryService.createDecisionDefinitionQuery() .latestVersion() .orderByTenantId() .asc() .list(); DecisionDefinitionEntity previousDefinitionTenantOne = getPreviousDefinition((DecisionDefinitionEntity) latestDefinitions.get(0)); DecisionDefinitionEntity previousDefinitionTenantTwo = getPreviousDefinition((DecisionDefinitionEntity) latestDefinitions.get(1)); assertThat(previousDefinitionTenantOne.getVersion(), is(2)); assertThat(previousDefinitionTenantOne.getTenantId(), is(TENANT_ONE)); assertThat(previousDefinitionTenantTwo.getVersion(), is(1)); assertThat(previousDefinitionTenantTwo.getTenantId(), is(TENANT_TWO)); }
@Override public void checkUpdateDecisionDefinitionById(String decisionDefinitionId) { if (getTenantManager().isTenantCheckEnabled()) { DecisionDefinitionEntity decisionDefinition = findLatestDecisionDefinitionById(decisionDefinitionId); if (decisionDefinition != null && !getTenantManager().isAuthenticatedTenant(decisionDefinition.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("update the decision definition '"+ decisionDefinitionId + "'"); } } }
public String getPreviousDecisionDefinitionId() { ensurePreviousDecisionDefinitionIdInitialized(); return previousDecisionDefinitionId; }
@Statement public String selectPreviousDecisionDefinitionId(OPersistenceSession session, ListQueryParameterObject parameter) { Map<String, String> params = (Map<String, String>) parameter.getParameter(); String key = params.get("key"); String tenantId = params.get("tenantId"); String version = params.get("version"); String query = "select distinct RES.* from " + getSchemaClass() + " where RES.key = " + key; query += tenantId != null ? " and tenantId = " + tenantId : " and tenantId is null"; query += " and RES.version = (select max(version) from " + getSchemaClass() + " where key = " + key; query += tenantId != null ? " and tenantId = " + tenantId : " and tenantId is null"; query += " and version < " + version + ")"; return querySingle(session, query).getPreviousDecisionDefinitionId(); }
@Override protected DmnDecisionImpl createFromDecision(DmnElementTransformContext context, Decision decision) { DecisionDefinitionEntity decisionDefinition = (DecisionDefinitionEntity) super.createFromDecision(context, decision); String category = context.getModelInstance().getDefinitions().getNamespace(); decisionDefinition.setCategory(category); decisionDefinition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(decision.getCamundaHistoryTimeToLiveString())); decisionDefinition.setVersionTag(decision.getVersionTag()); return decisionDefinition; }
@Override protected List<DecisionDefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { List<DecisionDefinitionEntity> decisions = new ArrayList<DecisionDefinitionEntity>(); // get the decisions from the deployed drd instead of parse the DMN again DecisionRequirementsDefinitionEntity deployedDrd = findDeployedDrdForResource(deployment, resource.getName()); if (deployedDrd == null) { throw LOG.exceptionNoDrdForResource(resource.getName()); } Collection<DmnDecision> decisionsOfDrd = deployedDrd.getDecisions(); for (DmnDecision decisionOfDrd : decisionsOfDrd) { DecisionDefinitionEntity decisionEntity = (DecisionDefinitionEntity) decisionOfDrd; if (DecisionRequirementsDefinitionDeployer.isDecisionRequirementsDefinitionPersistable(deployedDrd)) { decisionEntity.setDecisionRequirementsDefinitionId(deployedDrd.getId()); decisionEntity.setDecisionRequirementsDefinitionKey(deployedDrd.getKey()); } decisions.add(decisionEntity); } if (!DecisionRequirementsDefinitionDeployer.isDecisionRequirementsDefinitionPersistable(deployedDrd)) { deployment.removeArtifact(deployedDrd); } return decisions; }
public void checkReadDecisionDefinition(DecisionDefinitionEntity decisionDefinition) { getAuthorizationManager().checkAuthorization(READ, DECISION_DEFINITION, decisionDefinition.getKey()); }
@Test public void getPreviousDecisionDefinitionWithTenantId() { testRule.deployForTenant(TENANT_ONE, DMN); testRule.deployForTenant(TENANT_ONE, DMN); testRule.deployForTenant(TENANT_ONE, DMN); testRule.deployForTenant(TENANT_TWO, DMN); testRule.deployForTenant(TENANT_TWO, DMN); List<DecisionDefinition> latestDefinitions = repositoryService.createDecisionDefinitionQuery() .latestVersion() .orderByTenantId() .asc() .list(); DecisionDefinitionEntity previousDefinitionTenantOne = getPreviousDefinition((DecisionDefinitionEntity) latestDefinitions.get(0)); DecisionDefinitionEntity previousDefinitionTenantTwo = getPreviousDefinition((DecisionDefinitionEntity) latestDefinitions.get(1)); assertThat(previousDefinitionTenantOne.getVersion(), is(2)); assertThat(previousDefinitionTenantOne.getTenantId(), is(TENANT_ONE)); assertThat(previousDefinitionTenantTwo.getVersion(), is(1)); assertThat(previousDefinitionTenantTwo.getTenantId(), is(TENANT_TWO)); }
@Override public void checkUpdateDecisionDefinitionById(String decisionDefinitionId) { if (getTenantManager().isTenantCheckEnabled()) { DecisionDefinitionEntity decisionDefinition = findLatestDecisionDefinitionById(decisionDefinitionId); if (decisionDefinition != null && !getTenantManager().isAuthenticatedTenant(decisionDefinition.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("update the decision definition '"+ decisionDefinitionId + "'"); } } }
public String getPreviousDecisionDefinitionId() { ensurePreviousDecisionDefinitionIdInitialized(); return previousDecisionDefinitionId; }
public DecisionDefinitionEntity getPreviousDefinition() { DecisionDefinitionEntity previousDecisionDefinition = null; String previousDecisionDefinitionId = getPreviousDecisionDefinitionId(); if (previousDecisionDefinitionId != null) { previousDecisionDefinition = loadDecisionDefinition(previousDecisionDefinitionId); if (previousDecisionDefinition == null) { resetPreviousDecisionDefinitionId(); previousDecisionDefinitionId = getPreviousDecisionDefinitionId(); if (previousDecisionDefinitionId != null) { previousDecisionDefinition = loadDecisionDefinition(previousDecisionDefinitionId); } } } return previousDecisionDefinition; }
@Override protected DmnDecisionImpl createFromDecision(DmnElementTransformContext context, Decision decision) { DecisionDefinitionEntity decisionDefinition = (DecisionDefinitionEntity) super.createFromDecision(context, decision); String category = context.getModelInstance().getDefinitions().getNamespace(); decisionDefinition.setCategory(category); decisionDefinition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(decision.getCamundaHistoryTimeToLiveString())); decisionDefinition.setVersionTag(decision.getVersionTag()); return decisionDefinition; }
public void checkReadDecisionDefinition(DecisionDefinitionEntity decisionDefinition) { if (decisionDefinition != null && !getTenantManager().isAuthenticatedTenant(decisionDefinition.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("get the decision definition '"+ decisionDefinition.getId() + "'"); } }
@Override protected List<DecisionDefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { List<DecisionDefinitionEntity> decisions = new ArrayList<DecisionDefinitionEntity>(); // get the decisions from the deployed drd instead of parse the DMN again DecisionRequirementsDefinitionEntity deployedDrd = findDeployedDrdForResource(deployment, resource.getName()); if (deployedDrd == null) { throw LOG.exceptionNoDrdForResource(resource.getName()); } Collection<DmnDecision> decisionsOfDrd = deployedDrd.getDecisions(); for (DmnDecision decisionOfDrd : decisionsOfDrd) { DecisionDefinitionEntity decisionEntity = (DecisionDefinitionEntity) decisionOfDrd; if (DecisionRequirementsDefinitionDeployer.isDecisionRequirementsDefinitionPersistable(deployedDrd)) { decisionEntity.setDecisionRequirementsDefinitionId(deployedDrd.getId()); decisionEntity.setDecisionRequirementsDefinitionKey(deployedDrd.getKey()); } decisions.add(decisionEntity); } if (!DecisionRequirementsDefinitionDeployer.isDecisionRequirementsDefinitionPersistable(deployedDrd)) { deployment.removeArtifact(deployedDrd); } return decisions; }