use of org.wso2.carbon.bpmn.rest.model.stats.ProcessInstanceStatInfo in project carbon-business-process by wso2.
the class ProcessStatisticsService method taskVariationOverTime.
/**
* Task variation of user over time i.e. tasks started and completed by the user -- User Performance
*
* @param assignee taskAssignee/User selected to view the user performance of task completion over time
* @return array with the tasks started and completed of the selected user
*/
@GET
@Path("/user-performance/variation/{assignee}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ResponseHolder taskVariationOverTime(@PathParam("assignee") String assignee) throws UserStoreException {
if (!validateCurrentUser(assignee)) {
throw new ActivitiObjectNotFoundException("User with user id " + assignee + "not defined in the system");
}
ResponseHolder response = new ResponseHolder();
List list = new ArrayList();
SimpleDateFormat ft = new SimpleDateFormat("M");
ProcessInstanceStatInfo[] taskStatPerMonths = new ProcessInstanceStatInfo[12];
for (int i = 0; i < taskStatPerMonths.length; i++) {
taskStatPerMonths[i] = new ProcessInstanceStatInfo(MONTHS[i], 0, 0);
}
// Get completed tasks
List<HistoricTaskInstance> taskList = BPMNOSGIService.getHistoryService().createHistoricTaskInstanceQuery().taskTenantId(getTenantIdStr()).taskAssignee(assignee).finished().list();
for (HistoricTaskInstance instance : taskList) {
int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
int endTime = Integer.parseInt(ft.format(instance.getEndTime()));
taskStatPerMonths[startTime - 1].setInstancesStarted(taskStatPerMonths[startTime - 1].getInstancesStarted() + 1);
taskStatPerMonths[endTime - 1].setInstancesCompleted(taskStatPerMonths[endTime - 1].getInstancesCompleted() + 1);
}
// Get active/started tasks
List<Task> taskActive = BPMNOSGIService.getTaskService().createTaskQuery().taskTenantId(getTenantIdStr()).taskAssignee(assignee).active().list();
for (Task instance : taskActive) {
int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
taskStatPerMonths[startTime - 1].setInstancesStarted(taskStatPerMonths[startTime - 1].getInstancesStarted() + 1);
}
// Get suspended tasks
List<Task> taskSuspended = BPMNOSGIService.getTaskService().createTaskQuery().taskTenantId(getTenantIdStr()).taskAssignee(assignee).suspended().list();
for (Task instance : taskSuspended) {
int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
taskStatPerMonths[startTime - 1].setInstancesStarted(taskStatPerMonths[startTime - 1].getInstancesStarted() + 1);
}
for (int i = 0; i < taskStatPerMonths.length; i++) {
list.add(taskStatPerMonths[i]);
}
response.setData(list);
return response;
}
use of org.wso2.carbon.bpmn.rest.model.stats.ProcessInstanceStatInfo in project carbon-business-process by wso2.
the class ProcessStatisticsService method taskVariationOverTime.
/**
* Task variation over time i.e. tasks started and completed over the months
*
* @return array with the no. of tasks started and completed over the months
*/
@GET
@Path("/task-instances/count/variation")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ResponseHolder taskVariationOverTime() {
ResponseHolder response = new ResponseHolder();
List list = new ArrayList();
SimpleDateFormat ft = new SimpleDateFormat("M");
ProcessInstanceStatInfo[] taskStatPerMonths = new ProcessInstanceStatInfo[12];
for (int i = 0; i < taskStatPerMonths.length; i++) {
taskStatPerMonths[i] = new ProcessInstanceStatInfo(MONTHS[i], 0, 0);
}
// Get completed tasks
List<HistoricTaskInstance> taskList = BPMNOSGIService.getHistoryService().createHistoricTaskInstanceQuery().taskTenantId(getTenantIdStr()).finished().list();
for (HistoricTaskInstance instance : taskList) {
int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
int endTime = Integer.parseInt(ft.format(instance.getEndTime()));
taskStatPerMonths[startTime - 1].setInstancesStarted(taskStatPerMonths[startTime - 1].getInstancesStarted() + 1);
taskStatPerMonths[endTime - 1].setInstancesCompleted(taskStatPerMonths[endTime - 1].getInstancesCompleted() + 1);
}
// Get active/started tasks
List<Task> taskActive = BPMNOSGIService.getTaskService().createTaskQuery().taskTenantId(getTenantIdStr()).active().list();
for (Task instance : taskActive) {
int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
taskStatPerMonths[startTime - 1].setInstancesStarted(taskStatPerMonths[startTime - 1].getInstancesStarted() + 1);
}
// Get suspended tasks
List<Task> taskSuspended = BPMNOSGIService.getTaskService().createTaskQuery().taskTenantId(getTenantIdStr()).suspended().list();
for (Task instance : taskSuspended) {
int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
taskStatPerMonths[startTime - 1].setInstancesStarted(taskStatPerMonths[startTime - 1].getInstancesStarted() + 1);
}
Collections.addAll(list, taskStatPerMonths);
response.setData(list);
return response;
}
use of org.wso2.carbon.bpmn.rest.model.stats.ProcessInstanceStatInfo in project carbon-business-process by wso2.
the class ProcessStatisticsService method processVariationOverTime.
/**
* Process variation over time i.e. tasks started and completed over the months
*
* @return array with the no. of processes started and completed over the months
*/
@GET
@Path("/process-instances/count/variation")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ResponseHolder processVariationOverTime() {
ResponseHolder response = new ResponseHolder();
List list = new ArrayList();
SimpleDateFormat ft = new SimpleDateFormat("M");
ProcessInstanceStatInfo[] processStatPerMonths = new ProcessInstanceStatInfo[12];
for (int i = 0; i < processStatPerMonths.length; i++) {
processStatPerMonths[i] = new ProcessInstanceStatInfo(MONTHS[i], 0, 0);
}
// Get completed process instances
List<HistoricProcessInstance> completedProcesses = BPMNOSGIService.getHistoryService().createHistoricProcessInstanceQuery().processInstanceTenantId(getTenantIdStr()).finished().list();
for (HistoricProcessInstance instance : completedProcesses) {
int startTime = Integer.parseInt(ft.format(instance.getStartTime()));
int endTime = Integer.parseInt(ft.format(instance.getEndTime()));
processStatPerMonths[startTime - 1].setInstancesStarted(processStatPerMonths[startTime - 1].getInstancesStarted() + 1);
processStatPerMonths[endTime - 1].setInstancesCompleted(processStatPerMonths[endTime - 1].getInstancesCompleted() + 1);
}
// Get active process instances
List<HistoricProcessInstance> activeProcesses = BPMNOSGIService.getHistoryService().createHistoricProcessInstanceQuery().processInstanceTenantId(getTenantIdStr()).unfinished().list();
for (HistoricProcessInstance instance : activeProcesses) {
int startTime = Integer.parseInt(ft.format(instance.getStartTime()));
processStatPerMonths[startTime - 1].setInstancesStarted(processStatPerMonths[startTime - 1].getInstancesStarted() + 1);
}
Collections.addAll(list, processStatPerMonths);
response.setData(list);
return response;
}
Aggregations