use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method getCaseFileDataByName.
public String getCaseFileDataByName(String containerId, String caseId, String name, String marshallingType) {
verifyContainerId(containerId, caseId);
CaseFileInstance caseFileInstance = caseService.getCaseFileInstance(caseId);
Object caseFileData = caseFileInstance.getData(name);
logger.debug("About to marshal case file data (name = {}) for case with id '{}' {}", name, caseId, caseFileData);
return marshallerHelper.marshal(containerId, marshallingType, caseFileData, new ByCaseIdContainerLocator(caseId));
}
use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method putCaseFileDataByName.
public void putCaseFileDataByName(String containerId, String caseId, String name, List<String> restrictions, String payload, String marshallingType) {
verifyContainerId(containerId, caseId);
logger.debug("About to unmarshal case file data from payload: '{}'", payload);
Object caseFileData = marshallerHelper.unmarshal(containerId, payload, marshallingType, Object.class, new ByCaseIdContainerLocator(caseId));
logger.debug("Unmarshalled case file data {} for case with id '{}' will be stored under {} with restrictions", caseFileData, caseId, name, restrictions);
caseService.addDataToCaseFile(caseId, name, caseFileData, restrictions.toArray(new String[restrictions.size()]));
}
use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method verifyContainerId.
private void verifyContainerId(String containerId, String caseId) {
String caseContainerId;
try {
caseContainerId = (new ByCaseIdContainerLocator(caseId)).locateContainer(containerId, null);
} catch (IllegalArgumentException e) {
throw new CaseNotFoundException(e.getMessage());
}
KieContainerInstanceImpl taskContainer = context.getContainer(caseContainerId);
List<KieContainerInstanceImpl> containersByAlias = context.getContainersForAlias(containerId);
// The container id is either a non-existent one or is not a valid alias for the container id the task is associated with. Both scenarios should raise an exception.
if (context.getContainer(containerId) == null && !containersByAlias.contains(taskContainer)) {
throw new DeploymentNotFoundException("CaseId: " + caseId + " is not associated with the provided container id: " + containerId + " or its alias.");
}
}
use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method reopenCase.
public void reopenCase(String caseId, String containerId, String caseDefinitionId, String payload, String marshallingType) {
verifyContainerId(containerId, caseId);
containerId = context.getContainerId(containerId, new ByCaseIdContainerLocator(caseId));
CaseDefinition caseDef = caseRuntimeDataService.getCase(containerId, caseDefinitionId);
if (caseDef == null) {
throw new IllegalStateException("Unable to find case '" + caseDefinitionId + "' in container " + containerId);
}
logger.debug("About to unmarshal data from payload: '{}'", payload);
Map<String, Object> data = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class);
caseService.reopenCase(caseId, containerId, caseDefinitionId, data);
logger.debug("Case {} successfully reopened", caseId);
}
use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method addDynamicTask.
public void addDynamicTask(String containerId, String caseId, String stageId, String payload, String marshallingType) {
verifyContainerId(containerId, caseId);
logger.debug("About to unmarshal task specification content from payload: '{}'", payload);
Map<String, Object> taskSpecificationMap = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class, new ByCaseIdContainerLocator(caseId));
TaskSpecification taskSpecification = null;
if (taskSpecificationMap == null || taskSpecificationMap.isEmpty()) {
throw new IllegalArgumentException("Task specification must be given");
}
String nodeType = (String) taskSpecificationMap.get(CASE_DYNAMIC_NODE_TYPE_PROP);
if (nodeType != null) {
logger.debug("Creating dynamic task of typ {} within case {}", nodeType, caseId);
taskSpecification = caseService.newTaskSpec(nodeType, (String) taskSpecificationMap.get(CASE_DYNAMIC_NAME_PROP), (Map<String, Object>) taskSpecificationMap.get(CASE_DYNAMIC_DATA_PROP));
} else {
logger.debug("Creating dynamic user task for case {}", caseId);
taskSpecification = caseService.newHumanTaskSpec((String) taskSpecificationMap.get(CASE_DYNAMIC_NAME_PROP), (String) taskSpecificationMap.get(CASE_DYNAMIC_DESC_PROP), (String) taskSpecificationMap.get(CASE_DYNAMIC_ACTORS_PROP), (String) taskSpecificationMap.get(CASE_DYNAMIC_GROUPS_PROP), (Map<String, Object>) taskSpecificationMap.get(CASE_DYNAMIC_DATA_PROP));
}
logger.debug("Complete task specification is '{}'", taskSpecification);
if (stageId != null && !stageId.isEmpty()) {
logger.debug("Adding dynamic task to stage {} within case {}", stageId, caseId);
caseService.addDynamicTaskToStage(caseId, stageId, taskSpecification);
} else {
logger.debug("Adding dynamic task to case {}", caseId);
caseService.addDynamicTask(caseId, taskSpecification);
}
}
Aggregations