提交 6a12173c 编写于 作者: T Tijs Rademakers

Task app UI cmmn improvements

上级 5d2807ff
...@@ -29,6 +29,11 @@ public interface HistoricCaseInstanceQuery extends Query<HistoricCaseInstanceQue ...@@ -29,6 +29,11 @@ public interface HistoricCaseInstanceQuery extends Query<HistoricCaseInstanceQue
*/ */
HistoricCaseInstanceQuery caseInstanceId(String caseInstanceId); HistoricCaseInstanceQuery caseInstanceId(String caseInstanceId);
/**
* Only select historic case instances with one the given identifiers.
*/
HistoricCaseInstanceQuery caseInstanceIds(Set<String> caseInstanceIds);
/** /**
* Only select historic case instances with the given business key. * Only select historic case instances with the given business key.
*/ */
......
...@@ -29,6 +29,7 @@ public interface CaseInstanceQuery extends Query<CaseInstanceQuery, CaseInstance ...@@ -29,6 +29,7 @@ public interface CaseInstanceQuery extends Query<CaseInstanceQuery, CaseInstance
CaseInstanceQuery caseDefinitionName(String caseDefinitionName); CaseInstanceQuery caseDefinitionName(String caseDefinitionName);
CaseInstanceQuery caseDefinitionVersion(Integer caseDefinitionVersion); CaseInstanceQuery caseDefinitionVersion(Integer caseDefinitionVersion);
CaseInstanceQuery caseInstanceId(String caseInstanceId); CaseInstanceQuery caseInstanceId(String caseInstanceId);
CaseInstanceQuery caseInstanceIds(Set<String> caseInstanceIds);
CaseInstanceQuery caseInstanceBusinessKey(String caseInstanceBusinessKey); CaseInstanceQuery caseInstanceBusinessKey(String caseInstanceBusinessKey);
CaseInstanceQuery caseInstanceParentId(String parentId); CaseInstanceQuery caseInstanceParentId(String parentId);
CaseInstanceQuery caseInstanceStartedBefore(Date beforeTime); CaseInstanceQuery caseInstanceStartedBefore(Date beforeTime);
......
...@@ -37,6 +37,7 @@ public class HistoricCaseInstanceQueryImpl extends AbstractQuery<HistoricCaseIns ...@@ -37,6 +37,7 @@ public class HistoricCaseInstanceQueryImpl extends AbstractQuery<HistoricCaseIns
protected String caseDefinitionCategory; protected String caseDefinitionCategory;
protected Integer caseDefinitionVersion; protected Integer caseDefinitionVersion;
protected String caseInstanceId; protected String caseInstanceId;
protected Set<String> caseInstanceIds;
protected String businessKey; protected String businessKey;
protected String caseInstanceParentId; protected String caseInstanceParentId;
protected String deploymentId; protected String deploymentId;
...@@ -117,6 +118,15 @@ public class HistoricCaseInstanceQueryImpl extends AbstractQuery<HistoricCaseIns ...@@ -117,6 +118,15 @@ public class HistoricCaseInstanceQueryImpl extends AbstractQuery<HistoricCaseIns
this.caseInstanceId = caseInstanceId; this.caseInstanceId = caseInstanceId;
return this; return this;
} }
@Override
public HistoricCaseInstanceQueryImpl caseInstanceIds(Set<String> caseInstanceIds) {
if (caseInstanceIds == null) {
throw new FlowableIllegalArgumentException("Case instance ids is null");
}
this.caseInstanceIds = caseInstanceIds;
return this;
}
@Override @Override
public HistoricCaseInstanceQueryImpl caseInstanceBusinessKey(String businessKey) { public HistoricCaseInstanceQueryImpl caseInstanceBusinessKey(String businessKey) {
......
...@@ -38,6 +38,7 @@ public class CaseInstanceQueryImpl extends AbstractQuery<CaseInstanceQuery, Case ...@@ -38,6 +38,7 @@ public class CaseInstanceQueryImpl extends AbstractQuery<CaseInstanceQuery, Case
protected Integer caseDefinitionVersion; protected Integer caseDefinitionVersion;
protected String businessKey; protected String businessKey;
protected String caseInstanceId; protected String caseInstanceId;
protected Set<String> caseInstanceIds;
protected String caseInstanceParentId; protected String caseInstanceParentId;
protected String caseInstanceParentPlanItemInstanceId; protected String caseInstanceParentPlanItemInstanceId;
protected Date startedBefore; protected Date startedBefore;
...@@ -112,6 +113,15 @@ public class CaseInstanceQueryImpl extends AbstractQuery<CaseInstanceQuery, Case ...@@ -112,6 +113,15 @@ public class CaseInstanceQueryImpl extends AbstractQuery<CaseInstanceQuery, Case
this.caseInstanceId = caseInstanceId; this.caseInstanceId = caseInstanceId;
return this; return this;
} }
@Override
public CaseInstanceQueryImpl caseInstanceIds(Set<String> caseInstanceIds) {
if (caseInstanceIds == null) {
throw new FlowableIllegalArgumentException("Case instance ids is null");
}
this.caseInstanceIds = caseInstanceIds;
return this;
}
@Override @Override
public CaseInstanceQueryImpl caseInstanceBusinessKey(String businessKey) { public CaseInstanceQueryImpl caseInstanceBusinessKey(String businessKey) {
......
...@@ -152,6 +152,12 @@ ...@@ -152,6 +152,12 @@
<if test="caseInstanceId != null"> <if test="caseInstanceId != null">
and RES.ID_ = #{caseInstanceId} and RES.ID_ = #{caseInstanceId}
</if> </if>
<if test="caseInstanceIds != null">
and RES.ID_ IN
<foreach item="caseInstanceId" index="index" collection="caseInstanceIds" open="(" separator="," close=")">
#{caseInstanceId}
</foreach>
</if>
<if test="caseDefinitionId != null"> <if test="caseDefinitionId != null">
RES.CASE_DEF_ID_ = #{caseDefinitionId} RES.CASE_DEF_ID_ = #{caseDefinitionId}
</if> </if>
......
...@@ -158,6 +158,13 @@ ...@@ -158,6 +158,13 @@
<if test="caseInstanceId != null"> <if test="caseInstanceId != null">
RES.ID_ = #{caseInstanceId} RES.ID_ = #{caseInstanceId}
</if> </if>
<if test="caseInstanceIds != null &amp;&amp; caseInstanceIds.size() &gt; 0">
and RES.ID_ IN
<foreach item="caseInstanceId" index="index" collection="caseInstanceIds"
open="(" separator="," close=")">
#{caseInstanceId}
</foreach>
</if>
<if test="caseDefinitionId != null"> <if test="caseDefinitionId != null">
and RES.CASE_DEF_ID_ = #{caseDefinitionId} and RES.CASE_DEF_ID_ = #{caseDefinitionId}
</if> </if>
...@@ -188,7 +195,7 @@ ...@@ -188,7 +195,7 @@
open="(" separator="," close=")"> open="(" separator="," close=")">
#{deploymentId} #{deploymentId}
</foreach> </foreach>
</if> </if>
<if test="businessKey != null"> <if test="businessKey != null">
and RES.BUSINESS_KEY_ = #{businessKey} and RES.BUSINESS_KEY_ = #{businessKey}
</if> </if>
......
...@@ -154,6 +154,7 @@ ...@@ -154,6 +154,7 @@
"ASSIGNEE": "Assignee", "ASSIGNEE": "Assignee",
"DUE": "Due", "DUE": "Due",
"PROCESS-INSTANCE": "Part of process", "PROCESS-INSTANCE": "Part of process",
"CASE-INSTANCE": "Part of case",
"ENDED": "Ended", "ENDED": "Ended",
"DURATION": "Duration" "DURATION": "Duration"
}, },
......
...@@ -235,11 +235,17 @@ angular.module('flowableApp') ...@@ -235,11 +235,17 @@ angular.module('flowableApp')
$scope.loadComments(); $scope.loadComments();
$scope.loadRelatedContent(); $scope.loadRelatedContent();
if($scope.model.task.processInstanceId) { if ($scope.model.task.processInstanceId) {
$scope.loadProcessInstance(); $scope.loadProcessInstance();
} else { } else {
$scope.model.processInstance = null; $scope.model.processInstance = null;
} }
if ($scope.model.task.scopeId) {
$scope.loadCaseInstance();
} else {
$scope.model.caseInstance = null;
}
$scope.refreshInvolvmentSummary(); $scope.refreshInvolvmentSummary();
...@@ -483,7 +489,6 @@ angular.module('flowableApp') ...@@ -483,7 +489,6 @@ angular.module('flowableApp')
}); });
}; };
// TODO: move process instance loading to separate service and merge with process.js
$scope.loadProcessInstance = function() { $scope.loadProcessInstance = function() {
$http({method: 'GET', url: FLOWABLE.CONFIG.contextRoot + '/app/rest/process-instances/' + $scope.model.task.processInstanceId}). $http({method: 'GET', url: FLOWABLE.CONFIG.contextRoot + '/app/rest/process-instances/' + $scope.model.task.processInstanceId}).
success(function(response, status, headers, config) { success(function(response, status, headers, config) {
...@@ -502,6 +507,25 @@ angular.module('flowableApp') ...@@ -502,6 +507,25 @@ angular.module('flowableApp')
} }
$location.path(path + "/processes"); $location.path(path + "/processes");
}; };
$scope.loadCaseInstance = function() {
$http({method: 'GET', url: FLOWABLE.CONFIG.contextRoot + '/app/rest/case-instances/' + $scope.model.task.scopeId}).
success(function(response, status, headers, config) {
$scope.model.caseInstance = response;
}).
error(function(response, status, headers, config) {
// Do nothing. User is not allowed to see the process instance
});
};
$scope.openCaseInstance = function(id) {
$rootScope.root.selectedCaseId = id;
var path='';
if($rootScope.activeAppDefinition && !FLOWABLE.CONFIG.integrationProfile) {
path = "/apps/" + $rootScope.activeAppDefinition.id;
}
$location.path(path + "/cases");
};
$scope.returnToTaskList = function() { $scope.returnToTaskList = function() {
var path=''; var path='';
......
...@@ -241,18 +241,5 @@ angular.module('flowableApp').service('TaskService', ['$http', '$q', '$rootScope ...@@ -241,18 +241,5 @@ angular.module('flowableApp').service('TaskService', ['$http', '$q', '$rootScope
var promise = deferred.promise; var promise = deferred.promise;
return promise; return promise;
}; };
this.getProcessInstanceVariables = function(taskId) {
var data = {
taskId: taskId
};
return httpAsPromise(
{
method: 'GET',
url: FLOWABLE.CONFIG.contextRoot + '/app/rest/task-forms/' + taskId + '/variables',
data: data
}
);
}
}]); }]);
...@@ -95,6 +95,10 @@ ...@@ -95,6 +95,10 @@
<span ng-if="model.processInstance"> <span ng-if="model.processInstance">
<a ng-click="openProcessInstance(model.processInstance.id)">{{model.processInstance.name && model.processInstance.name || model.processInstance.processDefinitionName}}</a> <a ng-click="openProcessInstance(model.processInstance.id)">{{model.processInstance.name && model.processInstance.name || model.processInstance.processDefinitionName}}</a>
</span> </span>
<span ng-if="model.task.scopeId && model.caseInstance" class="label">{{'TASK.FIELD.CASE-INSTANCE' | translate}}: </span>
<span ng-if="model.caseInstance">
<a ng-click="openCaseInstance(model.caseInstance.id)">{{model.caseInstance.name && model.caseInstance.name || model.caseInstance.caseDefinitionName}}</a>
</span>
<span class="label" ng-if="model.task.endDate != null && model.task.endDate != undefined">{{'TASK.FIELD.ENDED' | translate}}: </span> <span class="label" ng-if="model.task.endDate != null && model.task.endDate != undefined">{{'TASK.FIELD.ENDED' | translate}}: </span>
<span ng-if="model.task.endDate != null && model.task.endDate != undefined">{{model.task.endDate | dateformat:'fromNow'}}</span> <span ng-if="model.task.endDate != null && model.task.endDate != undefined">{{model.task.endDate | dateformat:'fromNow'}}</span>
......
...@@ -17,6 +17,7 @@ import java.util.List; ...@@ -17,6 +17,7 @@ import java.util.List;
import org.flowable.app.model.common.AbstractRepresentation; import org.flowable.app.model.common.AbstractRepresentation;
import org.flowable.app.model.common.UserRepresentation; import org.flowable.app.model.common.UserRepresentation;
import org.flowable.cmmn.engine.repository.CaseDefinition;
import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.task.service.Task; import org.flowable.task.service.Task;
import org.flowable.task.service.TaskInfo; import org.flowable.task.service.TaskInfo;
...@@ -45,6 +46,7 @@ public class TaskRepresentation extends AbstractRepresentation { ...@@ -45,6 +46,7 @@ public class TaskRepresentation extends AbstractRepresentation {
protected Integer priority; protected Integer priority;
protected String processInstanceId; protected String processInstanceId;
protected String processInstanceName; protected String processInstanceName;
protected String processDefinitionId; protected String processDefinitionId;
protected String processDefinitionName; protected String processDefinitionName;
protected String processDefinitionDescription; protected String processDefinitionDescription;
...@@ -52,6 +54,19 @@ public class TaskRepresentation extends AbstractRepresentation { ...@@ -52,6 +54,19 @@ public class TaskRepresentation extends AbstractRepresentation {
protected String processDefinitionCategory; protected String processDefinitionCategory;
protected int processDefinitionVersion; protected int processDefinitionVersion;
protected String processDefinitionDeploymentId; protected String processDefinitionDeploymentId;
protected String scopeId;
protected String scopeType;
protected String caseInstanceName;
protected String scopeDefinitionId;
protected String caseDefinitionName;
protected String caseDefinitionDescription;
protected String caseDefinitionKey;
protected String caseDefinitionCategory;
protected int caseDefinitionVersion;
protected String caseDefinitionDeploymentId;
protected String formKey; protected String formKey;
protected String processInstanceStartUserId; protected String processInstanceStartUserId;
protected boolean initiatorCanCompleteTask; protected boolean initiatorCanCompleteTask;
...@@ -67,14 +82,50 @@ public class TaskRepresentation extends AbstractRepresentation { ...@@ -67,14 +82,50 @@ public class TaskRepresentation extends AbstractRepresentation {
} }
public TaskRepresentation(Task task) { public TaskRepresentation(Task task) {
this(task, null); initializeTaskDetails(task);
} }
public TaskRepresentation(HistoricTaskInstance task) { public TaskRepresentation(HistoricTaskInstance task) {
this(task, null); initializeTaskDetails(task);
} }
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition) { public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition) {
initializeTaskDetails(taskInfo);
if (processDefinition != null) {
this.processDefinitionName = processDefinition.getName();
this.processDefinitionDescription = processDefinition.getDescription();
this.processDefinitionKey = processDefinition.getKey();
this.processDefinitionCategory = processDefinition.getCategory();
this.processDefinitionVersion = processDefinition.getVersion();
this.processDefinitionDeploymentId = processDefinition.getDeploymentId();
}
}
public TaskRepresentation(TaskInfo taskInfo, CaseDefinition caseDefinition) {
initializeTaskDetails(taskInfo);
if (caseDefinition != null) {
this.caseDefinitionName = caseDefinition.getName();
this.caseDefinitionDescription = caseDefinition.getDescription();
this.caseDefinitionKey = caseDefinition.getKey();
this.caseDefinitionCategory = caseDefinition.getCategory();
this.caseDefinitionVersion = caseDefinition.getVersion();
this.caseDefinitionDeploymentId = caseDefinition.getDeploymentId();
}
}
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition, String processInstanceName) {
this(taskInfo, processDefinition);
this.processInstanceName = processInstanceName;
}
public TaskRepresentation(TaskInfo taskInfo, CaseDefinition caseDefinition, String caseInstanceName) {
this(taskInfo, caseDefinition);
this.caseInstanceName = caseInstanceName;
}
public void initializeTaskDetails(TaskInfo taskInfo) {
this.id = taskInfo.getId(); this.id = taskInfo.getId();
this.name = taskInfo.getName(); this.name = taskInfo.getName();
this.description = taskInfo.getDescription(); this.description = taskInfo.getDescription();
...@@ -84,6 +135,9 @@ public class TaskRepresentation extends AbstractRepresentation { ...@@ -84,6 +135,9 @@ public class TaskRepresentation extends AbstractRepresentation {
this.priority = taskInfo.getPriority(); this.priority = taskInfo.getPriority();
this.processInstanceId = taskInfo.getProcessInstanceId(); this.processInstanceId = taskInfo.getProcessInstanceId();
this.processDefinitionId = taskInfo.getProcessDefinitionId(); this.processDefinitionId = taskInfo.getProcessDefinitionId();
this.scopeId = taskInfo.getScopeId();
this.scopeType = taskInfo.getScopeType();
this.scopeDefinitionId = taskInfo.getScopeDefinitionId();
if (taskInfo instanceof HistoricTaskInstance) { if (taskInfo instanceof HistoricTaskInstance) {
this.endDate = ((HistoricTaskInstance) taskInfo).getEndTime(); this.endDate = ((HistoricTaskInstance) taskInfo).getEndTime();
...@@ -93,21 +147,6 @@ public class TaskRepresentation extends AbstractRepresentation { ...@@ -93,21 +147,6 @@ public class TaskRepresentation extends AbstractRepresentation {
// Rendering of forms for historic tasks not supported currently // Rendering of forms for historic tasks not supported currently
this.formKey = taskInfo.getFormKey(); this.formKey = taskInfo.getFormKey();
} }
if (processDefinition != null) {
this.processDefinitionName = processDefinition.getName();
this.processDefinitionDescription = processDefinition.getDescription();
this.processDefinitionKey = processDefinition.getKey();
this.processDefinitionCategory = processDefinition.getCategory();
this.processDefinitionVersion = processDefinition.getVersion();
this.processDefinitionDeploymentId = processDefinition.getDeploymentId();
}
}
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition, String processInstanceName) {
// todo Once a ProcessInstanceInfo class is implemented, lets send in that as the 3rd parameter instead
this(taskInfo, processDefinition);
this.processInstanceName = processInstanceName;
} }
public void fillTask(Task task) { public void fillTask(Task task) {
...@@ -258,6 +297,86 @@ public class TaskRepresentation extends AbstractRepresentation { ...@@ -258,6 +297,86 @@ public class TaskRepresentation extends AbstractRepresentation {
public void setProcessDefinitionDeploymentId(String processDefinitionDeploymentId) { public void setProcessDefinitionDeploymentId(String processDefinitionDeploymentId) {
this.processDefinitionDeploymentId = processDefinitionDeploymentId; this.processDefinitionDeploymentId = processDefinitionDeploymentId;
} }
public String getScopeId() {
return scopeId;
}
public void setScopeId(String scopeId) {
this.scopeId = scopeId;
}
public String getScopeType() {
return scopeType;
}
public void setScopeType(String scopeType) {
this.scopeType = scopeType;
}
public String getCaseInstanceName() {
return caseInstanceName;
}
public void setCaseInstanceName(String caseInstanceName) {
this.caseInstanceName = caseInstanceName;
}
public String getScopeDefinitionId() {
return scopeDefinitionId;
}
public void setScopeDefinitionId(String scopeDefinitionId) {
this.scopeDefinitionId = scopeDefinitionId;
}
public String getCaseDefinitionName() {
return caseDefinitionName;
}
public void setCaseDefinitionName(String caseDefinitionName) {
this.caseDefinitionName = caseDefinitionName;
}
public String getCaseDefinitionDescription() {
return caseDefinitionDescription;
}
public void setCaseDefinitionDescription(String caseDefinitionDescription) {
this.caseDefinitionDescription = caseDefinitionDescription;
}
public String getCaseDefinitionKey() {
return caseDefinitionKey;
}
public void setCaseDefinitionKey(String caseDefinitionKey) {
this.caseDefinitionKey = caseDefinitionKey;
}
public String getCaseDefinitionCategory() {
return caseDefinitionCategory;
}
public void setCaseDefinitionCategory(String caseDefinitionCategory) {
this.caseDefinitionCategory = caseDefinitionCategory;
}
public int getCaseDefinitionVersion() {
return caseDefinitionVersion;
}
public void setCaseDefinitionVersion(int caseDefinitionVersion) {
this.caseDefinitionVersion = caseDefinitionVersion;
}
public String getCaseDefinitionDeploymentId() {
return caseDefinitionDeploymentId;
}
public void setCaseDefinitionDeploymentId(String caseDefinitionDeploymentId) {
this.caseDefinitionDeploymentId = caseDefinitionDeploymentId;
}
public String getFormKey() { public String getFormKey() {
return formKey; return formKey;
......
...@@ -23,6 +23,7 @@ import org.flowable.bpmn.model.BpmnModel; ...@@ -23,6 +23,7 @@ import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.ExtensionElement; import org.flowable.bpmn.model.ExtensionElement;
import org.flowable.bpmn.model.FlowElement; import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask; import org.flowable.bpmn.model.UserTask;
import org.flowable.cmmn.engine.CmmnRepositoryService;
import org.flowable.cmmn.engine.CmmnTaskService; import org.flowable.cmmn.engine.CmmnTaskService;
import org.flowable.editor.language.json.converter.util.CollectionUtils; import org.flowable.editor.language.json.converter.util.CollectionUtils;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
...@@ -42,6 +43,9 @@ public abstract class FlowableAbstractTaskService { ...@@ -42,6 +43,9 @@ public abstract class FlowableAbstractTaskService {
@Autowired @Autowired
protected RepositoryService repositoryService; protected RepositoryService repositoryService;
@Autowired
protected CmmnRepositoryService cmmnRepositoryService;
@Autowired @Autowired
protected TaskService taskService; protected TaskService taskService;
......
...@@ -12,17 +12,12 @@ ...@@ -12,17 +12,12 @@
*/ */
package org.flowable.app.service.runtime; package org.flowable.app.service.runtime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.flowable.app.model.runtime.CompleteFormRepresentation; import org.flowable.app.model.runtime.CompleteFormRepresentation;
import org.flowable.app.model.runtime.ProcessInstanceVariableRepresentation;
import org.flowable.app.model.runtime.SaveFormRepresentation; import org.flowable.app.model.runtime.SaveFormRepresentation;
import org.flowable.app.security.SecurityUtils; import org.flowable.app.security.SecurityUtils;
import org.flowable.app.service.exception.NotFoundException; import org.flowable.app.service.exception.NotFoundException;
import org.flowable.app.service.exception.NotPermittedException; import org.flowable.app.service.exception.NotPermittedException;
import org.flowable.cmmn.engine.CmmnTaskService;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
...@@ -32,7 +27,6 @@ import org.flowable.form.model.FormModel; ...@@ -32,7 +27,6 @@ import org.flowable.form.model.FormModel;
import org.flowable.idm.api.User; import org.flowable.idm.api.User;
import org.flowable.task.service.Task; import org.flowable.task.service.Task;
import org.flowable.task.service.history.HistoricTaskInstance; import org.flowable.task.service.history.HistoricTaskInstance;
import org.flowable.variable.service.history.HistoricVariableInstance;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -52,6 +46,9 @@ public class FlowableTaskFormService { ...@@ -52,6 +46,9 @@ public class FlowableTaskFormService {
@Autowired @Autowired
protected TaskService taskService; protected TaskService taskService;
@Autowired
protected CmmnTaskService cmmnTaskService;
@Autowired @Autowired
protected RepositoryService repositoryService; protected RepositoryService repositoryService;
...@@ -73,7 +70,11 @@ public class FlowableTaskFormService { ...@@ -73,7 +70,11 @@ public class FlowableTaskFormService {
public FormModel getTaskForm(String taskId) { public FormModel getTaskForm(String taskId) {
HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId); HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId);
return taskService.getTaskFormModel(task.getId()); if (task.getProcessInstanceId() != null) {
return taskService.getTaskFormModel(task.getId());
} else {
return cmmnTaskService.getTaskFormModel(task.getId());
}
} }
public void saveTaskForm(String taskId, SaveFormRepresentation saveFormRepresentation) { public void saveTaskForm(String taskId, SaveFormRepresentation saveFormRepresentation) {
...@@ -109,28 +110,16 @@ public class FlowableTaskFormService { ...@@ -109,28 +110,16 @@ public class FlowableTaskFormService {
checkCurrentUserCanModifyTask(task); checkCurrentUserCanModifyTask(task);
taskService.completeTaskWithForm(taskId, completeTaskFormRepresentation.getFormId(), if (task.getProcessInstanceId() != null) {
completeTaskFormRepresentation.getOutcome(), completeTaskFormRepresentation.getValues()); taskService.completeTaskWithForm(taskId, completeTaskFormRepresentation.getFormId(),
} completeTaskFormRepresentation.getOutcome(), completeTaskFormRepresentation.getValues());
} else {
public List<ProcessInstanceVariableRepresentation> getProcessInstanceVariables(String taskId) { cmmnTaskService.completeTaskWithForm(taskId, completeTaskFormRepresentation.getFormId(), completeTaskFormRepresentation.getOutcome(),
HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId); completeTaskFormRepresentation.getValues());
List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().processInstanceId(task.getProcessInstanceId()).list();
// Get all process-variables to extract values from
Map<String, ProcessInstanceVariableRepresentation> processInstanceVariables = new HashMap<>();
for (HistoricVariableInstance historicVariableInstance : historicVariables) {
ProcessInstanceVariableRepresentation processInstanceVariableRepresentation = new ProcessInstanceVariableRepresentation(
historicVariableInstance.getVariableName(), historicVariableInstance.getVariableTypeName(), historicVariableInstance.getValue());
processInstanceVariables.put(historicVariableInstance.getId(), processInstanceVariableRepresentation);
} }
List<ProcessInstanceVariableRepresentation> processInstanceVariableRepresenations = new ArrayList<>(processInstanceVariables.values());
return processInstanceVariableRepresenations;
} }
private void checkCurrentUserCanModifyTask(Task task) { protected void checkCurrentUserCanModifyTask(Task task) {
User currentUser = SecurityUtils.getCurrentUserObject(); User currentUser = SecurityUtils.getCurrentUserObject();
if (!permissionService.isTaskOwnerOrAssignee(currentUser, task.getId())) { if (!permissionService.isTaskOwnerOrAssignee(currentUser, task.getId())) {
if (!permissionService.validateIfUserIsInitiatorAndCanCompleteTask(currentUser, task)) { if (!permissionService.validateIfUserIsInitiatorAndCanCompleteTask(currentUser, task)) {
......
...@@ -30,6 +30,12 @@ import org.flowable.app.security.SecurityUtils; ...@@ -30,6 +30,12 @@ import org.flowable.app.security.SecurityUtils;
import org.flowable.app.service.api.UserCache; import org.flowable.app.service.api.UserCache;
import org.flowable.app.service.api.UserCache.CachedUser; import org.flowable.app.service.api.UserCache.CachedUser;
import org.flowable.app.service.exception.BadRequestException; import org.flowable.app.service.exception.BadRequestException;
import org.flowable.cmmn.engine.CmmnHistoryService;
import org.flowable.cmmn.engine.CmmnRepositoryService;
import org.flowable.cmmn.engine.CmmnRuntimeService;
import org.flowable.cmmn.engine.history.HistoricCaseInstance;
import org.flowable.cmmn.engine.repository.CaseDefinition;
import org.flowable.cmmn.engine.runtime.CaseInstance;
import org.flowable.editor.language.json.converter.util.CollectionUtils; import org.flowable.editor.language.json.converter.util.CollectionUtils;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
...@@ -71,15 +77,24 @@ public class FlowableTaskQueryService { ...@@ -71,15 +77,24 @@ public class FlowableTaskQueryService {
@Autowired @Autowired
protected RepositoryService repositoryService; protected RepositoryService repositoryService;
@Autowired
protected CmmnRepositoryService cmmnRepositoryService;
@Autowired @Autowired
protected TaskService taskService; protected TaskService taskService;
@Autowired @Autowired
protected RuntimeService runtimeService; protected RuntimeService runtimeService;
@Autowired
protected CmmnRuntimeService cmmnRuntimeService;
@Autowired @Autowired
protected HistoryService historyService; protected HistoryService historyService;
@Autowired
protected CmmnHistoryService cmmnHistoryService;
@Autowired @Autowired
protected UserCache userCache; protected UserCache userCache;
...@@ -172,13 +187,14 @@ public class FlowableTaskQueryService { ...@@ -172,13 +187,14 @@ public class FlowableTaskQueryService {
List<? extends TaskInfo> tasks = taskInfoQueryWrapper.getTaskInfoQuery().listPage(page * size, size); List<? extends TaskInfo> tasks = taskInfoQueryWrapper.getTaskInfoQuery().listPage(page * size, size);
JsonNode includeProcessInstanceNode = requestNode.get("includeProcessInstance"); JsonNode includeProcessInstanceNode = requestNode.get("includeProcessInstance");
// todo Once a ProcessInstanceInfo class has been implement use it instead rather than just the name
Map<String, String> processInstancesNames = new HashMap<>(); Map<String, String> processInstancesNames = new HashMap<>();
Map<String, String> caseInstancesNames = new HashMap<>();
if (includeProcessInstanceNode != null) { if (includeProcessInstanceNode != null) {
handleIncludeProcessInstance(taskInfoQueryWrapper, includeProcessInstanceNode, tasks, processInstancesNames); handleIncludeProcessInstance(taskInfoQueryWrapper, includeProcessInstanceNode, tasks, processInstancesNames);
handleIncludeCaseInstance(taskInfoQueryWrapper, includeProcessInstanceNode, tasks, caseInstancesNames);
} }
ResultListDataRepresentation result = new ResultListDataRepresentation(convertTaskInfoList(tasks, processInstancesNames)); ResultListDataRepresentation result = new ResultListDataRepresentation(convertTaskInfoList(tasks, processInstancesNames, caseInstancesNames));
// In case we're not on the first page and the size exceeds the page size, we need to do an additional count for the total // In case we're not on the first page and the size exceeds the page size, we need to do an additional count for the total
if (page != 0 || tasks.size() == size) { if (page != 0 || tasks.size() == size) {
...@@ -312,26 +328,58 @@ public class FlowableTaskQueryService { ...@@ -312,26 +328,58 @@ public class FlowableTaskQueryService {
} }
} }
} }
protected void handleIncludeCaseInstance(TaskInfoQueryWrapper taskInfoQueryWrapper, JsonNode includeProcessInstanceNode, List<? extends TaskInfo> tasks, Map<String, String> caseInstanceNames) {
if (includeProcessInstanceNode.asBoolean() && CollectionUtils.isNotEmpty(tasks)) {
Set<String> caseInstanceIds = new HashSet<>();
for (TaskInfo task : tasks) {
if (task.getScopeId() != null) {
caseInstanceIds.add(task.getScopeId());
}
}
if (CollectionUtils.isNotEmpty(caseInstanceIds)) {
if (taskInfoQueryWrapper.getTaskInfoQuery() instanceof HistoricTaskInstanceQuery) {
List<HistoricCaseInstance> caseInstances = cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceIds(caseInstanceIds).list();
for (HistoricCaseInstance caseInstance : caseInstances) {
caseInstanceNames.put(caseInstance.getId(), caseInstance.getName());
}
} else {
List<CaseInstance> caseInstances = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceIds(caseInstanceIds).list();
for (CaseInstance caseInstance : caseInstances) {
caseInstanceNames.put(caseInstance.getId(), caseInstance.getName());
}
}
}
}
}
protected List<TaskRepresentation> convertTaskInfoList(List<? extends TaskInfo> tasks, Map<String, String> processInstanceNames) { protected List<TaskRepresentation> convertTaskInfoList(List<? extends TaskInfo> tasks, Map<String, String> processInstanceNames, Map<String, String> caseInstancesNames) {
List<TaskRepresentation> result = new ArrayList<>(); List<TaskRepresentation> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(tasks)) { if (CollectionUtils.isNotEmpty(tasks)) {
for (TaskInfo task : tasks) { for (TaskInfo task : tasks) {
ProcessDefinitionEntity processDefinition = null;
if (task.getProcessDefinitionId() != null) { TaskRepresentation taskRepresentation = null;
processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(task.getProcessDefinitionId()); if (task.getScopeDefinitionId() != null) {
CaseDefinition caseDefinition = cmmnRepositoryService.getCaseDefinition(task.getScopeDefinitionId());
taskRepresentation = new TaskRepresentation(task, caseDefinition, caseInstancesNames.get(task.getScopeId()));
} else {
ProcessDefinitionEntity processDefinition = null;
if (task.getProcessDefinitionId() != null) {
processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(task.getProcessDefinitionId());
}
taskRepresentation = new TaskRepresentation(task, processDefinition, processInstanceNames.get(task.getProcessInstanceId()));
} }
TaskRepresentation representation = new TaskRepresentation(task, processDefinition, processInstanceNames.get(task.getProcessInstanceId()));
if (StringUtils.isNotEmpty(task.getAssignee())) { if (StringUtils.isNotEmpty(task.getAssignee())) {
CachedUser cachedUser = userCache.getUser(task.getAssignee()); CachedUser cachedUser = userCache.getUser(task.getAssignee());
if (cachedUser != null && cachedUser.getUser() != null) { if (cachedUser != null && cachedUser.getUser() != null) {
User assignee = cachedUser.getUser(); User assignee = cachedUser.getUser();
representation.setAssignee(new UserRepresentation(assignee)); taskRepresentation.setAssignee(new UserRepresentation(assignee));
} }
} }
result.add(representation); result.add(taskRepresentation);
} }
} }
return result; return result;
......
...@@ -24,6 +24,7 @@ import org.flowable.app.model.runtime.TaskUpdateRepresentation; ...@@ -24,6 +24,7 @@ import org.flowable.app.model.runtime.TaskUpdateRepresentation;
import org.flowable.app.security.SecurityUtils; import org.flowable.app.security.SecurityUtils;
import org.flowable.app.service.api.UserCache.CachedUser; import org.flowable.app.service.api.UserCache.CachedUser;
import org.flowable.app.service.exception.NotFoundException; import org.flowable.app.service.exception.NotFoundException;
import org.flowable.cmmn.engine.repository.CaseDefinition;
import org.flowable.engine.common.api.FlowableException; import org.flowable.engine.common.api.FlowableException;
import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.identitylink.service.IdentityLinkType; import org.flowable.identitylink.service.IdentityLinkType;
...@@ -50,16 +51,26 @@ public class FlowableTaskService extends FlowableAbstractTaskService { ...@@ -50,16 +51,26 @@ public class FlowableTaskService extends FlowableAbstractTaskService {
User currentUser = SecurityUtils.getCurrentUserObject(); User currentUser = SecurityUtils.getCurrentUserObject();
HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(currentUser, taskId); HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(currentUser, taskId);
ProcessDefinition processDefinition = null; TaskRepresentation rep = null;
if (StringUtils.isNotEmpty(task.getProcessDefinitionId())) { if (StringUtils.isNotEmpty(task.getProcessDefinitionId())) {
try { try {
processDefinition = repositoryService.getProcessDefinition(task.getProcessDefinitionId()); ProcessDefinition processDefinition = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
rep = new TaskRepresentation(task, processDefinition);
} catch (FlowableException e) { } catch (FlowableException e) {
LOGGER.error("Error getting process definition {}", task.getProcessDefinitionId(), e); LOGGER.error("Error getting process definition {}", task.getProcessDefinitionId(), e);
} }
} else if (StringUtils.isNotEmpty(task.getScopeDefinitionId())) {
try {
CaseDefinition caseDefinition = cmmnRepositoryService.getCaseDefinition(task.getScopeDefinitionId());
rep = new TaskRepresentation(task, caseDefinition);
} catch (FlowableException e) {
LOGGER.error("Error getting case definition {}", task.getScopeDefinitionId(), e);
}
} }
TaskRepresentation rep = new TaskRepresentation(task, processDefinition);
fillPermissionInformation(rep, task, currentUser); fillPermissionInformation(rep, task, currentUser);
// Populate the people // Populate the people
......
...@@ -24,6 +24,8 @@ import org.flowable.bpmn.model.BpmnModel; ...@@ -24,6 +24,8 @@ import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.ExtensionElement; import org.flowable.bpmn.model.ExtensionElement;
import org.flowable.bpmn.model.FlowElement; import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask; import org.flowable.bpmn.model.UserTask;
import org.flowable.cmmn.engine.CmmnHistoryService;
import org.flowable.cmmn.engine.history.HistoricCaseInstance;
import org.flowable.content.api.ContentItem; import org.flowable.content.api.ContentItem;
import org.flowable.editor.language.json.converter.util.CollectionUtils; import org.flowable.editor.language.json.converter.util.CollectionUtils;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
...@@ -63,6 +65,9 @@ public class PermissionService { ...@@ -63,6 +65,9 @@ public class PermissionService {
@Autowired @Autowired
protected HistoryService historyService; protected HistoryService historyService;
@Autowired
protected CmmnHistoryService cmmnHistoryService;
@Autowired @Autowired
protected RemoteIdmService remoteIdmService; protected RemoteIdmService remoteIdmService;
...@@ -146,6 +151,15 @@ public class PermissionService { ...@@ -146,6 +151,15 @@ public class PermissionService {
} }
} }
} }
} else if (task.getScopeId() != null) {
HistoricCaseInstance historicCaseInstance = cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceId(task.getScopeId()).singleResult();
if (historicCaseInstance != null && StringUtils.isNotEmpty(historicCaseInstance.getStartUserId())) {
String caseInstanceStartUserId = historicCaseInstance.getStartUserId();
if (String.valueOf(user.getId()).equals(caseInstanceStartUserId)) {
canCompleteTask = true;
}
}
} }
return canCompleteTask; return canCompleteTask;
} }
......
...@@ -12,10 +12,7 @@ ...@@ -12,10 +12,7 @@
*/ */
package org.flowable.app.rest.runtime; package org.flowable.app.rest.runtime;
import java.util.List;
import org.flowable.app.model.runtime.CompleteFormRepresentation; import org.flowable.app.model.runtime.CompleteFormRepresentation;
import org.flowable.app.model.runtime.ProcessInstanceVariableRepresentation;
import org.flowable.app.model.runtime.SaveFormRepresentation; import org.flowable.app.model.runtime.SaveFormRepresentation;
import org.flowable.app.service.runtime.FlowableTaskFormService; import org.flowable.app.service.runtime.FlowableTaskFormService;
import org.flowable.form.model.FormModel; import org.flowable.form.model.FormModel;
...@@ -54,9 +51,4 @@ public class TaskFormResource { ...@@ -54,9 +51,4 @@ public class TaskFormResource {
public void saveTaskForm(@PathVariable String taskId, @RequestBody SaveFormRepresentation saveFormRepresentation) { public void saveTaskForm(@PathVariable String taskId, @RequestBody SaveFormRepresentation saveFormRepresentation) {
taskFormService.saveTaskForm(taskId, saveFormRepresentation); taskFormService.saveTaskForm(taskId, saveFormRepresentation);
} }
@RequestMapping(value = "/{taskId}/variables", method = RequestMethod.GET, produces = "application/json")
public List<ProcessInstanceVariableRepresentation> getProcessInstanceVariables(@PathVariable String taskId) {
return taskFormService.getProcessInstanceVariables(taskId);
}
} }
...@@ -224,6 +224,15 @@ ...@@ -224,6 +224,15 @@
<if test="excludeTaskRelated"> <if test="excludeTaskRelated">
and RES.TASK_ID_ is NULL and RES.TASK_ID_ is NULL
</if> </if>
<if test="scopeId != null">
and RES.SCOPE_ID_ = #{scopeId}
</if>
<if test="subScopeId != null">
and RES.SUB_SCOPE_ID_ = #{subScopeId}
</if>
<if test="scopeType != null">
and RES.SCOPE_TYPE_ = #{scopeType}
</if>
<if test="variableName != null"> <if test="variableName != null">
and RES.NAME_ = #{variableName} and RES.NAME_ = #{variableName}
</if> </if>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册