Class CaseServiceImpl

    • Constructor Detail

      • CaseServiceImpl

        public CaseServiceImpl()
    • Method Detail

      • setProcessService

        public void setProcessService​(ProcessService processService)
      • setRuntimeDataService

        public void setRuntimeDataService​(RuntimeDataService runtimeDataService)
      • setDeploymentService

        public void setDeploymentService​(DeploymentService deploymentService)
      • setCaseRuntimeDataService

        public void setCaseRuntimeDataService​(CaseRuntimeDataService caseRuntimeDataService)
      • setCaseIdGenerator

        public void setCaseIdGenerator​(CaseIdGenerator caseIdGenerator)
      • setAuthorizationManager

        public void setAuthorizationManager​(AuthorizationManager authorizationManager)
      • setIdentityProvider

        public void setIdentityProvider​(org.kie.internal.identity.IdentityProvider identityProvider)
      • startCase

        public String startCase​(String deploymentId,
                                String caseDefinitionId)
        Description copied from interface: CaseService
        Starts a new case for given definition with empty case file.
        Case id is generated based on case id prefix (defined on case definition) and generated value.
        CASE-XXXXXXXXX where XXXXXXX is generated value for the prefix
        Examples:
        • CASE-0000000123
        • HR-0000000321
        • LOAN-0000000099
        Specified by:
        startCase in interface CaseService
        Parameters:
        deploymentId - deployment id of project that case definition belongs to
        caseDefinitionId - id of case definition
        Returns:
        returns unique case id in the format PREFIX-GENERATED_ID as described above
      • startCase

        public String startCase​(String deploymentId,
                                String caseDefinitionId,
                                CaseFileInstance caseFile)
        Description copied from interface: CaseService
        Starts a new case for given definition with given case file.
        Case id is generated based on case id prefix (defined on case definition) and generated value.
        CASE-XXXXXXXXX where XXXXXXX is generated value for the prefix
        Examples:
        • CASE-0000000123
        • HR-0000000321
        • LOAN-0000000099
        Specified by:
        startCase in interface CaseService
        Parameters:
        deploymentId - deployment id of project that case definition belongs to
        caseDefinitionId - id of case definition
        caseFile - initial case file to be used for this case
        Returns:
        returns unique case id in the format PREFIX-GENERATED_ID as described above
      • getCaseInstance

        public CaseInstance getCaseInstance​(String caseId,
                                            boolean withData,
                                            boolean withRoles,
                                            boolean withMilestones,
                                            boolean withStages)
                                     throws CaseNotFoundException
        Description copied from interface: CaseService
        Returns case instance (only if it's active) identified by given case id with options on what should be fetched
        Specified by:
        getCaseInstance in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        withData - determines if case file should be loaded
        withRoles - determines if role assignments should be loaded
        withMilestones - determines if milestones should be loaded
        withStages - determines with stages should be loaded
        Returns:
        returns current snapshot of CaseInstance
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • closeCase

        public void closeCase​(String caseId,
                              String comment)
                       throws CaseNotFoundException
        Description copied from interface: CaseService
        Closes case with given case id (including all attached process instances if any). Does not affect case file so in case it can still be used to reopen the case by starting new instances.
        Specified by:
        closeCase in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • cancelCase

        public void cancelCase​(String caseId)
                        throws CaseNotFoundException
        Description copied from interface: CaseService
        Cancels case with given case id (including all attached process instances if any). Does not affect case file so in case it can still be used to reopen the case by starting new instances.
        Specified by:
        cancelCase in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • destroyCase

        public void destroyCase​(String caseId)
                         throws CaseNotFoundException
        Description copied from interface: CaseService
        Permanently destroys case identified by given case id. It performs the same operation as abortCase and destroys the case file and other attached information.
        Specified by:
        destroyCase in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • reopenCase

        public void reopenCase​(String caseId,
                               String deploymentId,
                               String caseDefinitionId)
                        throws CaseNotFoundException
        Description copied from interface: CaseService
        Reopens case given by case id by starting another instance of case definition. It will inherit all data from case file that was available in before case was closed/canceled.
        Specified by:
        reopenCase in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        deploymentId - deployment id of project that case definition belongs to
        caseDefinitionId - id of case definition
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • reopenCase

        public void reopenCase​(String caseId,
                               String deploymentId,
                               String caseDefinitionId,
                               Map<String,​Object> data)
                        throws CaseNotFoundException
        Description copied from interface: CaseService
        Reopens case given by case id by starting another instance of case definition. It will inherit all data from case file that was available in before case was closed/canceled.
        Specified by:
        reopenCase in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        deploymentId - deployment id of project that case definition belongs to
        caseDefinitionId - id of case definition
        data - additional data to be set on case file
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDynamicTask

        public void addDynamicTask​(String caseId,
                                   TaskSpecification taskSpecification)
                            throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds new user task to specified case. Should be used when user task should be added to the main process instance of the case. If there are more process instances for given case and user task should be added to specific process instance CaseService.addDynamicTask(Long, TaskSpecification) should be used
        Specified by:
        addDynamicTask in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        taskSpecification - complete specification that defines the type of a task to be added
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDynamicSubprocess

        public Long addDynamicSubprocess​(String caseId,
                                         String processId,
                                         Map<String,​Object> parameters)
                                  throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds new subprocess (identified by process id) to given process instance. Should be used when subprocess should be added to the main process instance of the case. If there are more process instances for given case and subprocess should be added to specific process instance
        Specified by:
        addDynamicSubprocess in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        processId - identifier of the process to be added
        parameters - optional parameters for the subprocess
        Returns:
        returns process instance id of the subprocess
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDynamicSubprocess

        public Long addDynamicSubprocess​(Long processInstanceId,
                                         String processId,
                                         Map<String,​Object> parameters)
                                  throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds new subprocess (identified by process id) to case.
        Specified by:
        addDynamicSubprocess in interface CaseService
        Parameters:
        processInstanceId - unique process instance id
        processId - identifier of the process to be added
        parameters - optional parameters for the subprocess
        Returns:
        returns process instance id of the subprocess
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDynamicSubprocessToStage

        public Long addDynamicSubprocessToStage​(String caseId,
                                                String stage,
                                                String processId,
                                                Map<String,​Object> parameters)
                                         throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds new subprocess (identified by process id) to given process instance. Should be used when subprocess should be added to the main process instance of the case. If there are more process instances for given case and subprocess should be added to specific process instance
        Specified by:
        addDynamicSubprocessToStage in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method CaseService.addDynamicSubprocess(Long, String, Map) method should be used instead.
        stage - id or name of the stage there the task should be added
        processId - identifier of the process to be added
        parameters - optional parameters for the subprocess
        Returns:
        returns process instance id of the subprocess
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDynamicSubprocessToStage

        public Long addDynamicSubprocessToStage​(Long processInstanceId,
                                                String stage,
                                                String processId,
                                                Map<String,​Object> parameters)
                                         throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds new subprocess (identified by process id) to case.
        Specified by:
        addDynamicSubprocessToStage in interface CaseService
        Parameters:
        processInstanceId - unique process instance id
        stage - id or name of the stage there the task should be added
        processId - identifier of the process to be added
        parameters - optional parameters for the subprocess
        Returns:
        returns process instance id of the subprocess
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • triggerAdHocFragment

        public void triggerAdHocFragment​(String caseId,
                                         String fragmentName,
                                         Object data)
                                  throws CaseNotFoundException
        Description copied from interface: CaseService
        Triggers given by fragmentName adhoc element (such as task, milestone) within given case. Should be used when fragment should be triggered on the main process instance of the case. If there are more process instances for given case and fragment should be triggered on specific process instance CaseService.triggerAdHocFragment(Long, String, Object) method should be used instead
        Specified by:
        triggerAdHocFragment in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        fragmentName - name of the element that can be triggered
        data - optional data to be given when triggering the node
        Throws:
        CaseNotFoundException
      • triggerAdHocFragment

        public void triggerAdHocFragment​(Long processInstanceId,
                                         String fragmentName,
                                         Object data)
                                  throws CaseNotFoundException
        Description copied from interface: CaseService
        Triggers given by fragmentName adhoc element (such as task, milestone) within given process instance
        Specified by:
        triggerAdHocFragment in interface CaseService
        Parameters:
        processInstanceId - unique process instance id
        fragmentName - name of the element that can be triggered
        data - optional data to be given when triggering the node
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • triggerAdHocFragment

        public void triggerAdHocFragment​(String caseId,
                                         String stage,
                                         String fragmentName,
                                         Object data)
                                  throws CaseNotFoundException
        Description copied from interface: CaseService
        Triggers given by fragmentName adhoc element (such as task, milestone) within given case and stage. Should be used when fragment should be triggered on the main process instance of the case. If there are more process instances for given case and fragment should be triggered on specific process instance CaseService.triggerAdHocFragment(Long, String, String, Object) method should be used instead
        Specified by:
        triggerAdHocFragment in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        stage - id or name of the stage there the task should be added
        fragmentName - name of the element that can be triggered
        data - optional data to be given when triggering the node
        Throws:
        CaseNotFoundException
      • triggerAdHocFragment

        public void triggerAdHocFragment​(Long processInstanceId,
                                         String stage,
                                         String fragmentName,
                                         Object data)
                                  throws CaseNotFoundException
        Description copied from interface: CaseService
        Triggers given by fragmentName adhoc element (such as task, milestone) within given process instance and stage
        Specified by:
        triggerAdHocFragment in interface CaseService
        Parameters:
        processInstanceId - unique process instance id
        stage - id or name of the stage there the task should be added
        fragmentName - name of the element that can be triggered
        data - optional data to be given when triggering the node
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDataToCaseFile

        public void addDataToCaseFile​(String caseId,
                                      String name,
                                      Object value,
                                      String... restrictedTo)
                               throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds given named value into case file of given case.
        Specified by:
        addDataToCaseFile in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        name - unique name for given value to be put into case file
        value - actual value to be added to case file
        restrictedTo - optional case roles that this data should be restricted to
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addDataToCaseFile

        public void addDataToCaseFile​(String caseId,
                                      Map<String,​Object> data,
                                      String... restrictedTo)
                               throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds complete map to case file of given case. Replaces any existing value that is registered under same name.
        Specified by:
        addDataToCaseFile in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        data - key value representing data to be added to case file
        restrictedTo - optional case roles that this data should be restricted to
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • removeDataFromCaseFile

        public void removeDataFromCaseFile​(String caseId,
                                           String name)
                                    throws CaseNotFoundException
        Description copied from interface: CaseService
        Removes given variable (stored under name) from case file of given case.
        Specified by:
        removeDataFromCaseFile in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        name - variable name that should be removed from case file
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • removeDataFromCaseFile

        public void removeDataFromCaseFile​(String caseId,
                                           List<String> variableNames)
                                    throws CaseNotFoundException
        Description copied from interface: CaseService
        Removes given variables (stored under variableNames) from case file of given case.
        Specified by:
        removeDataFromCaseFile in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        variableNames - list of variables to be removed from the case file
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • assignToCaseRole

        public void assignToCaseRole​(String caseId,
                                     String role,
                                     org.kie.api.task.model.OrganizationalEntity entity)
                              throws CaseNotFoundException
        Description copied from interface: CaseService
        Assigns given entity (user or group) to case role for a given case. Case roles can be used for user task assignments.
        Specified by:
        assignToCaseRole in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        role - name of the role entity should be assigned to
        entity - user or group to be assigned to given role
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • removeFromCaseRole

        public void removeFromCaseRole​(String caseId,
                                       String role,
                                       org.kie.api.task.model.OrganizationalEntity entity)
                                throws CaseNotFoundException
        Description copied from interface: CaseService
        Removes given entity (user or group) from the case role for a given case.
        Specified by:
        removeFromCaseRole in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        role - name of the role entity should be assigned to
        entity - entity user or group to be assigned to given role
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • getCaseComments

        public Collection<CommentInstance> getCaseComments​(String caseId,
                                                           org.kie.api.runtime.query.QueryContext queryContext)
                                                    throws CaseNotFoundException
        Description copied from interface: CaseService
        Returns all case comments sorted by date
        Specified by:
        getCaseComments in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        Returns:
        returns all comments added to given case
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • addCaseComment

        public String addCaseComment​(String caseId,
                                     String author,
                                     String comment,
                                     String... restrictedTo)
                              throws CaseNotFoundException
        Description copied from interface: CaseService
        Adds new comment to the case
        Specified by:
        addCaseComment in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        author - author of the comment
        comment - actual comment (text)
        restrictedTo - optional case roles that this data should be restricted to
        Returns:
        unique id of the comment that has been added
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • updateCaseComment

        public void updateCaseComment​(String caseId,
                                      String commentId,
                                      String author,
                                      String text,
                                      String... restrictedTo)
                               throws CaseNotFoundException
        Description copied from interface: CaseService
        Updated given comment with entire text provided
        Specified by:
        updateCaseComment in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        commentId - unique id of the comment
        author - author of the comment
        text - updated text of the comment
        restrictedTo - optional case roles that this data should be restricted to
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • removeCaseComment

        public void removeCaseComment​(String caseId,
                                      String commentId)
                               throws CaseNotFoundException
        Description copied from interface: CaseService
        Removes given comment from the case comments list
        Specified by:
        removeCaseComment in interface CaseService
        Parameters:
        caseId - unique case id in the format PREFIX-GENERATED_ID as described on startCase method
        commentId - unique id of the comment
        Throws:
        CaseNotFoundException - thrown in case case was not found with given id
      • newCaseFileInstance

        public CaseFileInstance newCaseFileInstance​(String deploymentId,
                                                    String caseDefinition,
                                                    Map<String,​Object> data)
        Description copied from interface: CaseService
        Builds and returns new CaseFileInstance with given data. Not yet associated with any case
        Specified by:
        newCaseFileInstance in interface CaseService
        Parameters:
        deploymentId - deployment that case belongs to
        caseDefinition - id of the case definition to be able to properly setup case file
        data - initial data for case file
        Returns:
        returns new instance (not associated with case) of CaseFileInstance populated with given data
      • newCaseFileInstanceWithRestrictions

        public CaseFileInstance newCaseFileInstanceWithRestrictions​(String deploymentId,
                                                                    String caseDefinition,
                                                                    Map<String,​Object> data,
                                                                    Map<String,​List<String>> accessRestrictions)
        Description copied from interface: CaseService
        Builds and returns new CaseFileInstance with given data. Not yet associated with any case
        Specified by:
        newCaseFileInstanceWithRestrictions in interface CaseService
        Parameters:
        deploymentId - deployment that case belongs to
        caseDefinition - id of the case definition to be able to properly setup case file
        data - initial data for case file
        accessRestrictions - access restrictions to data that defines what case roles are allowed to add and manipulate given data
        Returns:
        returns new instance (not associated with case) of CaseFileInstance populated with given data
      • newCaseFileInstance

        public CaseFileInstance newCaseFileInstance​(String deploymentId,
                                                    String caseDefinition,
                                                    Map<String,​Object> data,
                                                    Map<String,​org.kie.api.task.model.OrganizationalEntity> rolesAssignment)
        Description copied from interface: CaseService
        Builds and returns new CaseFileInstance with given data and roles assignments. Not yet associated with any case
        Specified by:
        newCaseFileInstance in interface CaseService
        Parameters:
        deploymentId - deployment that case belongs to
        caseDefinition - id of the case definition to be able to properly setup case file
        data - initial data for case file
        rolesAssignment - initial role assignment
        Returns:
        returns new instance (not associated with case) of CaseFileInstance populated with given data
      • newCaseFileInstanceWithRestrictions

        public CaseFileInstance newCaseFileInstanceWithRestrictions​(String deploymentId,
                                                                    String caseDefinition,
                                                                    Map<String,​Object> data,
                                                                    Map<String,​org.kie.api.task.model.OrganizationalEntity> rolesAssignment,
                                                                    Map<String,​List<String>> accessRestrictions)
        Description copied from interface: CaseService
        Builds and returns new CaseFileInstance with given data and roles assignments. Not yet associated with any case
        Specified by:
        newCaseFileInstanceWithRestrictions in interface CaseService
        Parameters:
        deploymentId - deployment that case belongs to
        caseDefinition - id of the case definition to be able to properly setup case file
        data - initial data for case file
        rolesAssignment - initial role assignment
        accessRestrictions - access restrictions to data that defines what case roles are allowed to add and manipulate given data
        Returns:
        returns new instance (not associated with case) of CaseFileInstance populated with given data
      • newHumanTaskSpec

        public TaskSpecification newHumanTaskSpec​(String taskName,
                                                  String description,
                                                  String actorIds,
                                                  String groupIds,
                                                  Map<String,​Object> parameters)
        Description copied from interface: CaseService
        Returns new TaskSpecification describing user task so it can be created as dynamic task. All string based attributes support variable expressions (#{variable-name})
        Specified by:
        newHumanTaskSpec in interface CaseService
        Parameters:
        taskName - - mandatory name of the task
        description - - optional description of the task
        actorIds - - optional list (comma separated) of actors to be assigned
        groupIds - - optional list (comma separated) of groups to be assigned
        parameters - - optional parameters (task inputs)
        Returns:
      • newTaskSpec

        public TaskSpecification newTaskSpec​(String nodeType,
                                             String nodeName,
                                             Map<String,​Object> parameters)
        Description copied from interface: CaseService
        Returns new TaskSpecification describing generic (work item based) task so it can be added as dynamic task.
        Specified by:
        newTaskSpec in interface CaseService
        Parameters:
        nodeType - - type of a node (same as used for registering work item handler)
        nodeName - - name of the node to be assigned on task
        parameters - - optional parameters (task inputs)
        Returns:
      • newUser

        public org.kie.api.task.model.User newUser​(String userId)
        Description copied from interface: CaseService
        Creates new user with given id;
        Specified by:
        newUser in interface CaseService
        Parameters:
        userId - user id to be used when creating User instance
        Returns:
        new instance for userId
      • newGroup

        public org.kie.api.task.model.Group newGroup​(String groupId)
        Description copied from interface: CaseService
        Creates new group with given id;
        Specified by:
        newGroup in interface CaseService
        Parameters:
        groupId - group id to be used when creating Group instance
        Returns:
        new instance for groupId
      • isEmpty

        protected boolean isEmpty​(Collection<?> data)