use of org.jbpm.casemgmt.impl.model.CaseDefinitionImpl in project jbpm by kiegroup.
the class CaseRuntimeDataServiceImpl method onDeploy.
/*
* Deploy and undeploy handling
*/
@Override
public void onDeploy(DeploymentEvent event) {
AbstractRuntimeManager runtimeManager = (AbstractRuntimeManager) event.getDeployedUnit().getRuntimeManager();
KieBase kieBase = runtimeManager.getEnvironment().getKieBase();
Collection<Process> processes = kieBase.getProcesses();
Map<String, DeployedAsset> mapProcessById = event.getDeployedUnit().getDeployedAssets().stream().collect(toMap(DeployedAsset::getId, asset -> asset));
for (Process process : processes) {
if (((WorkflowProcess) process).isDynamic()) {
String caseIdPrefix = collectCaseIdPrefix(process);
Collection<CaseMilestone> caseMilestones = collectMilestoness(process);
Collection<CaseStage> caseStages = collectCaseStages(event.getDeploymentId(), process.getId(), ((WorkflowProcess) process));
Collection<CaseRole> caseRoles = collectCaseRoles(process);
Collection<AdHocFragment> adHocFragments = collectAdHocFragments((WorkflowProcess) process);
Map<String, List<String>> dataAccessRestrictions = collectDataAccessRestrictions(process);
CaseDefinitionImpl caseDef = new CaseDefinitionImpl((ProcessAssetDesc) mapProcessById.get(process.getId()), caseIdPrefix, caseStages, caseMilestones, caseRoles, adHocFragments, dataAccessRestrictions);
availableCases.add(caseDef);
caseIdGenerator.register(caseIdPrefix);
}
}
// collect role information
Collection<DeployedAsset> assets = event.getDeployedUnit().getDeployedAssets();
List<String> roles = null;
for (DeployedAsset asset : assets) {
if (asset instanceof ProcessAssetDesc) {
// if it's not dynamic it's considered as not case definition
if (!((ProcessAssetDesc) asset).isDynamic()) {
availableProcesses.add((ProcessAssetDesc) asset);
}
if (roles == null) {
roles = ((ProcessAssetDesc) asset).getRoles();
}
}
}
if (roles == null) {
roles = Collections.emptyList();
}
deploymentRolesManager.addRolesForDeployment(event.getDeploymentId(), roles);
}
Aggregations