use of org.jbpm.casemgmt.api.model.CaseDefinition in project jbpm by kiegroup.
the class CaseServiceImpl method newCaseFileInstance.
@Override
public CaseFileInstance newCaseFileInstance(String deploymentId, String caseDefinition, Map<String, Object> data, Map<String, OrganizationalEntity> rolesAssignment) {
CaseDefinition def = caseRuntimeDataService.getCase(deploymentId, caseDefinition);
if (def == null) {
throw new CaseDefinitionNotFoundException("Case definition " + caseDefinition + " does not exist in deployment " + deploymentId);
}
CaseFileInstanceImpl caseFile = new CaseFileInstanceImpl(caseDefinition, data);
caseFile.setupRoles(def.getCaseRoles());
caseFile.setAccessRestrictions(def.getDataAccessRestrictions());
rolesAssignment.entrySet().stream().forEach(entry -> caseFile.assign(entry.getKey(), entry.getValue()));
return caseFile;
}
use of org.jbpm.casemgmt.api.model.CaseDefinition in project jbpm by kiegroup.
the class CaseServiceImpl method startCase.
@Override
public String startCase(String deploymentId, String caseDefinitionId, CaseFileInstance caseFile) {
CaseDefinition caseDef = caseRuntimeDataService.getCase(deploymentId, caseDefinitionId);
if (caseDef == null) {
throw new CaseNotFoundException("Case definition " + caseDefinitionId + " not found");
}
String caseId = caseIdGenerator.generate(caseDef.getIdentifierPrefix(), (caseFile == null ? new HashMap<>() : caseFile.getData()));
logger.debug("Generated case id {} for case definition id {}", caseId, caseDefinitionId);
if (caseFile == null) {
caseFile = new CaseFileInstanceImpl(caseId, caseDefinitionId);
((CaseFileInstanceImpl) caseFile).setupRoles(caseDef.getCaseRoles());
logger.debug("CaseFile was not given, creating new empty one.");
} else {
((CaseFileInstanceImpl) caseFile).setCaseId(caseId);
logger.debug("CaseFile {} was given, associating it with case {}", caseFile, caseId);
}
// If owner is provided in the case file use that, otherwise default to current logged in user.
boolean hasOwner = ((CaseFileInstanceImpl) caseFile).getAssignments().stream().anyMatch(role -> role.getRoleName().equals(AuthorizationManager.OWNER_ROLE));
if (hasOwner == false) {
((CaseFileInstanceImpl) caseFile).assignOwner(newUser(identityProvider.getName()));
}
processService.execute(deploymentId, CaseContext.get(caseId), new StartCaseCommand(identityProvider, caseId, deploymentId, caseDefinitionId, caseFile, processService));
return caseId;
}
Aggregations