use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method getCaseInstance.
public String getCaseInstance(String containerId, String caseId, boolean withData, boolean withRoles, boolean withMilestones, boolean withStages, String marshallingType) {
verifyContainerId(containerId, caseId);
CaseInstance actualCaseInstance = caseService.getCaseInstance(caseId, withData, withRoles, withMilestones, withStages);
org.kie.server.api.model.cases.CaseInstance caseInstance = ConvertUtils.transformCaseInstance(actualCaseInstance);
if (actualCaseInstance.getStatus().equals(ProcessInstance.STATE_ACTIVE)) {
if (withData) {
caseInstance.setCaseFile(CaseFile.builder().data(actualCaseInstance.getCaseFile().getData()).build());
}
if (withMilestones) {
caseInstance.setMilestones(ConvertUtils.transformMilestones(actualCaseInstance.getCaseMilestones()));
}
if (withStages) {
caseInstance.setStages(ConvertUtils.transformStages(actualCaseInstance.getCaseStages()));
}
if (withRoles) {
caseInstance.setRoleAssignments(ConvertUtils.transformRoleAssignment(actualCaseInstance.getCaseRoles()));
}
}
logger.debug("About to marshal case instance with id '{}' {}", caseId, caseInstance);
return marshallerHelper.marshal(containerId, marshallingType, caseInstance, new ByCaseIdContainerLocator(caseId));
}
use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project droolsjbpm-integration by kiegroup.
the class CaseManagementServiceBase method triggerAdHocNode.
public void triggerAdHocNode(String containerId, String caseId, String stageId, String adHocName, String payload, String marshallingType) {
verifyContainerId(containerId, caseId);
logger.debug("About to unmarshal task data from payload: '{}'", payload);
Map<String, Object> adHocTaskData = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class, new ByCaseIdContainerLocator(caseId));
logger.debug("AdHoc task {} will be triggered with data = {}", adHocName, adHocTaskData);
if (stageId != null && !stageId.isEmpty()) {
caseService.triggerAdHocFragment(caseId, stageId, adHocName, adHocTaskData);
} else {
caseService.triggerAdHocFragment(caseId, adHocName, adHocTaskData);
}
}
use of org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator in project businessautomation-cop by redhat-cop.
the class GetCasesWithDataResource method getCaseInstancesWithData.
@SuppressWarnings("unchecked")
@GET
@Path("/instancesWithData")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCaseInstancesWithData(@Context HttpHeaders headers, @QueryParam("dataItem") List<String> dataItems) {
Variant v = getVariant(headers);
String contentType = getContentType(headers);
MarshallingFormat format = MarshallingFormat.fromType(contentType);
if (format == null) {
format = MarshallingFormat.valueOf(contentType);
}
MarshallerHelper marshallerHelper = new MarshallerHelper(registry);
try {
// Fetching all OPEN cases
CaseInstanceList cases = this.caseManagementRuntimeDataService.getCaseInstancesAnyRole(Arrays.asList("open"), 0, 0, "", true);
List<CaseInstance> finalList = new ArrayList<CaseInstance>();
// for every case instance found, let's fetch the case data specified in the query parameter 'dateItems'
for (CaseInstance caseInstance : cases.getItems()) {
String caseFileData = caseManagementServiceBase.getCaseFileData(caseInstance.getContainerId(), caseInstance.getCaseId(), dataItems, format.toString());
logger.debug("Following data were fetched :" + caseFileData + "\n for case instance id:" + caseInstance.getCaseId());
Map<String, Object> caseFileDataUnmarshalled = marshallerHelper.unmarshal(caseInstance.getContainerId(), caseFileData, format.toString(), Map.class, new ByCaseIdContainerLocator(caseInstance.getCaseId()));
caseInstance.setCaseFile(CaseFile.builder().data(caseFileDataUnmarshalled).build());
finalList.add(caseInstance);
}
cases.setCaseInstances(finalList.toArray(new CaseInstance[finalList.size()]));
String result = marshallerHelper.marshal(format.toString(), cases);
logger.debug("Returning OK response with content '{}'", result);
return createResponse(result, v, Response.Status.OK);
} catch (Exception e) {
// backward compatibility
String response = "Execution failed with error : " + e.getMessage();
logger.debug("Returning Failure response with content '{}'", response);
return createResponse(response, v, Response.Status.INTERNAL_SERVER_ERROR);
}
}
Aggregations