Search in sources :

Example 1 with Activity

use of org.alfresco.rest.workflow.api.model.Activity in project alfresco-remote-api by Alfresco.

the class ActivitiesImpl method getActivities.

@Override
public CollectionWithPagingInfo<Activity> getActivities(String processId, Parameters parameters) {
    Paging paging = parameters.getPaging();
    String status = parameters.getParameter("status");
    validateIfUserAllowedToWorkWithProcess(processId);
    HistoricActivityInstanceQuery query = activitiProcessEngine.getHistoryService().createHistoricActivityInstanceQuery();
    if (STATUS_ACTIVE.equals(status))
        query.unfinished();
    else if (STATUS_COMPLETED.equals(status))
        query.finished();
    query.processInstanceId(processId);
    query.orderByExecutionId().asc();
    List<HistoricActivityInstance> activities = query.listPage(paging.getSkipCount(), paging.getMaxItems());
    List<Activity> page = new ArrayList<Activity>(activities.size());
    for (HistoricActivityInstance activityInstance : activities) {
        Activity activity = new Activity(activityInstance);
        page.add(activity);
    }
    return CollectionWithPagingInfo.asPaged(paging, page, false, page.size());
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) Paging(org.alfresco.rest.framework.resource.parameters.Paging) ArrayList(java.util.ArrayList) Activity(org.alfresco.rest.workflow.api.model.Activity) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Aggregations

ArrayList (java.util.ArrayList)1 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)1 HistoricActivityInstanceQuery (org.activiti.engine.history.HistoricActivityInstanceQuery)1 Paging (org.alfresco.rest.framework.resource.parameters.Paging)1 Activity (org.alfresco.rest.workflow.api.model.Activity)1