Search in sources :

Example 1 with ByCaseIdContainerLocator

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));
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) ByCaseIdContainerLocator(org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator)

Example 2 with ByCaseIdContainerLocator

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()]));
}
Also used : ByCaseIdContainerLocator(org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator)

Example 3 with ByCaseIdContainerLocator

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.");
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) ByCaseIdContainerLocator(org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator) KieContainerInstanceImpl(org.kie.server.services.impl.KieContainerInstanceImpl) CaseNotFoundException(org.jbpm.casemgmt.api.CaseNotFoundException)

Example 4 with ByCaseIdContainerLocator

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);
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ByCaseIdContainerLocator(org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator)

Example 5 with ByCaseIdContainerLocator

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);
    }
}
Also used : TaskSpecification(org.jbpm.casemgmt.api.dynamic.TaskSpecification) ByCaseIdContainerLocator(org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ByCaseIdContainerLocator (org.kie.server.services.casemgmt.locator.ByCaseIdContainerLocator)13 HashMap (java.util.HashMap)2 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Variant (javax.ws.rs.core.Variant)1 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)1 TaskSpecification (org.jbpm.casemgmt.api.dynamic.TaskSpecification)1 CaseDefinition (org.jbpm.casemgmt.api.model.CaseDefinition)1 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)1 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)1 MarshallingFormat (org.kie.server.api.marshalling.MarshallingFormat)1 CaseInstance (org.kie.server.api.model.cases.CaseInstance)1 CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)1 KieContainerInstanceImpl (org.kie.server.services.impl.KieContainerInstanceImpl)1 MarshallerHelper (org.kie.server.services.impl.marshal.MarshallerHelper)1