Search in sources :

Example 1 with TaskInfo

use of org.wso2.carbon.bpmn.rest.model.stats.TaskInfo in project carbon-business-process by wso2.

the class CommonTaskUtil method populateTaskInfo.

/**
 * Creates the TaskInfo object from the provided TaskDAO object.
 *
 * @param taskDAO : The original task dao object
 * @return : The representational TaskInfo.
 */
public static TaskInfo populateTaskInfo(TaskDAO taskDAO) {
    TaskInfo taskInfo = new TaskInfo();
    taskInfo.setId(taskDAO.getId());
    taskInfo.setCreatedDate(taskDAO.getCreatedOn());
    taskInfo.setName(taskDAO.getName());
    if (getDefaultPresentationDescription(taskDAO) != null) {
        taskInfo.setDescription(getDefaultPresentationDescription(taskDAO).getValue());
    }
    if (getActualOwner(taskDAO) != null) {
        taskInfo.setOwner(getActualOwner(taskDAO).getName());
    }
    if (getDefaultPresentationName(taskDAO) != null) {
        taskInfo.setName(getDefaultPresentationName(taskDAO).getValue());
    }
    if (getDefaultPresentationSubject(taskDAO) != null) {
        taskInfo.setSubject(getDefaultPresentationSubject(taskDAO).getValue());
    }
    taskInfo.setStatus(taskDAO.getStatus());
    taskInfo.setType(taskDAO.getType());
    taskInfo.setModifiedDate(taskDAO.getUpdatedOn());
    taskInfo.setStatusBeforeSuspension(taskDAO.getStatusBeforeSuspension());
    return taskInfo;
}
Also used : TaskInfo(org.wso2.carbon.humantask.core.api.event.TaskInfo)

Example 2 with TaskInfo

use of org.wso2.carbon.bpmn.rest.model.stats.TaskInfo in project carbon-business-process by wso2.

the class HumanTaskApplicationAdmin method getHumanTaskAppData.

/**
 * Gives a HumanTaskAppMetadata object with all humantask packages deployed through the
 * given app.
 *
 * @param appName - input app name
 * @return - HumanTaskAppMetadata object with found artifact info
 * @throws Exception - error on retrieving metadata
 */
public HumanTaskAppMetadata getHumanTaskAppData(String appName) throws Exception {
    HumanTaskAppMetadata data = new HumanTaskAppMetadata();
    String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
    // Check whether there is an application in the system from the given name
    ArrayList<CarbonApplication> appList = HumanTaskAppMgtServiceComponent.getAppManager().getCarbonApps(tenantId);
    CarbonApplication currentApplication = null;
    for (CarbonApplication application : appList) {
        if (appName.equals(application.getAppNameWithVersion())) {
            currentApplication = application;
            break;
        }
    }
    // If the app not found, throw an exception
    if (currentApplication == null) {
        String msg = "No Carbon Application found of the name : " + appName;
        log.error(msg);
        throw new Exception(msg);
    }
    // get all dependent artifacts of the cApp
    List<Artifact.Dependency> deps = currentApplication.getAppConfig().getApplicationArtifact().getDependencies();
    // we use the humantask backend admin service to get tasks from a humantask package
    HumanTaskPackageManagementSkeleton humantaskAdmin = new HumanTaskPackageManagementSkeleton();
    // package list to return
    List<PackageMetadata> packageList = new ArrayList<PackageMetadata>();
    String packageName;
    for (Artifact.Dependency dep : deps) {
        Artifact artifact = dep.getArtifact();
        packageName = artifact.getRuntimeObjectName();
        if (packageName == null) {
            continue;
        }
        if (HumanTaskAppDeployer.HUMANTASK_TYPE.equals(artifact.getType())) {
            PackageMetadata packageMetadata = new PackageMetadata();
            packageMetadata.setPackageName(packageName);
            // get the list of tasks
            List<String> taskList = new ArrayList<String>();
            Task_type0[] tasksInPackage = humantaskAdmin.listTasksInPackage(packageName);
            for (Task_type0 taskInfo : tasksInPackage) {
                taskList.add(taskInfo.getName());
            }
            String[] tasks = new String[taskList.size()];
            packageMetadata.setTaskList(tasks);
            packageList.add(packageMetadata);
        }
    }
    // convert the List into an array
    data.setPackages(packageList.toArray(new PackageMetadata[packageList.size()]));
    return data;
}
Also used : ArrayList(java.util.ArrayList) CarbonApplication(org.wso2.carbon.application.deployer.CarbonApplication) Artifact(org.wso2.carbon.application.deployer.config.Artifact) HumanTaskPackageManagementSkeleton(org.wso2.carbon.humantask.skeleton.mgt.services.HumanTaskPackageManagementSkeleton) Task_type0(org.wso2.carbon.humantask.skeleton.mgt.services.types.Task_type0)

Example 3 with TaskInfo

use of org.wso2.carbon.bpmn.rest.model.stats.TaskInfo in project carbon-business-process by wso2.

the class ProcessStatisticsService method getTasks.

/**
 * Return all the tasks/activities in a process
 * @param pId process instance id
 * @return all the tasks/activities in a process
 */
@GET
@Path("/task-instances/{pId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ResponseHolder getTasks(@PathParam("pId") String pId) {
    ResponseHolder response = new ResponseHolder();
    List<Object> list = new ArrayList();
    RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pId);
    if (processDefinition != null) {
        for (ActivityImpl activity : processDefinition.getActivities()) {
            TaskInfo taskInfo = new TaskInfo();
            String taskDefKey = activity.getId();
            String type = (String) activity.getProperty("type");
            String taskName = (String) activity.getProperty("name");
            taskInfo.setTaskDefinitionKey(taskDefKey);
            taskInfo.setType(type);
            taskInfo.setName(taskName);
            list.add(taskInfo);
        }
    }
    response.setData(list);
    return response;
}
Also used : TaskInfo(org.wso2.carbon.bpmn.rest.model.stats.TaskInfo) ResponseHolder(org.wso2.carbon.bpmn.rest.model.stats.ResponseHolder) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ArrayList(java.util.ArrayList) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) RepositoryService(org.activiti.engine.RepositoryService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with TaskInfo

use of org.wso2.carbon.bpmn.rest.model.stats.TaskInfo in project carbon-business-process by wso2.

the class HumanTaskPackageManagementSkeleton method getTaskInfo.

public TaskInfoType getTaskInfo(QName taskId) throws PackageManagementException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    TaskInfoType taskInfo = null;
    HumanTaskBaseConfiguration taskConf = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getTaskConfiguration(taskId);
    if (taskConf != null) {
        taskInfo = new TaskInfoType();
        taskInfo.setTaskId(taskConf.getName());
        taskInfo.setPackageName(taskConf.getPackageName());
        if (TaskPackageStatus.ACTIVE.equals(taskConf.getPackageStatus())) {
            taskInfo.setStatus(TaskStatusType.ACTIVE);
        } else if (TaskPackageStatus.RETIRED.equals(taskConf.getPackageStatus())) {
            taskInfo.setStatus(TaskStatusType.INACTIVE);
        } else if (TaskPackageStatus.UNDEPLOYING.equals(taskConf.getPackageStatus())) {
            taskInfo.setStatus(TaskStatusType.UNDEPLOYING);
        }
        taskInfo.setDeploymentError(taskConf.getDeploymentError());
        taskInfo.setErroneous(taskConf.isErroneous());
        if (taskConf instanceof TaskConfiguration) {
            taskInfo.setTaskType(TaskType.TASK);
        } else if (taskConf instanceof NotificationConfiguration) {
            taskInfo.setTaskType(TaskType.NOTIFICATION);
        }
        taskInfo.setDefinitionInfo(fillTaskDefinitionInfo(taskConf));
    }
    return taskInfo;
}
Also used : NotificationConfiguration(org.wso2.carbon.humantask.core.store.NotificationConfiguration) TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)

Example 5 with TaskInfo

use of org.wso2.carbon.bpmn.rest.model.stats.TaskInfo in project carbon-business-process by wso2.

the class TaskCleanupSchedulerUtil method initTaskCleanupJob.

/**
 * Initialises the task clean up task.
 *
 * @throws HumanTaskServerException :
 */
public static void initTaskCleanupJob() throws HumanTaskServerException {
    HumanTaskServerConfiguration serverConfig = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getServerConfig();
    if (serverConfig.isTaskCleanupEnabled()) {
        try {
            log.info("Initialising the task cleanup service.....");
            HumanTaskCleanupSchedulerServiceComponent.getTaskService().registerTaskType(HumanTaskConstants.HUMANTASK_TASK_TYPE);
            TaskManager taskManager = HumanTaskCleanupSchedulerServiceComponent.getTaskService().getTaskManager(HumanTaskConstants.HUMANTASK_TASK_TYPE);
            TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
            triggerInfo.setCronExpression(serverConfig.getTaskCleanupCronExpression());
            triggerInfo.setDisallowConcurrentExecution(true);
            Map<String, String> propertyMap = new LinkedHashMap<String, String>();
            TaskInfo taskInfo = new TaskInfo(HumanTaskConstants.HUMANTASK_CLEANUP_JOB, RemovableTaskCleanupJob.class.getName(), propertyMap, triggerInfo);
            taskManager.registerTask(taskInfo);
            taskManager.rescheduleTask(HumanTaskConstants.HUMANTASK_CLEANUP_JOB);
        } catch (TaskException ex) {
            String errMsg = "Error occurred while registering task type : " + HumanTaskConstants.HUMANTASK_TASK_TYPE;
            throw new HumanTaskServerException(errMsg, ex);
        }
    }
}
Also used : TaskInfo(org.wso2.carbon.ntask.core.TaskInfo) TaskManager(org.wso2.carbon.ntask.core.TaskManager) TaskException(org.wso2.carbon.ntask.common.TaskException) HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException) HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) RemovableTaskCleanupJob(org.wso2.carbon.humantask.cleanup.scheduler.ntask.RemovableTaskCleanupJob) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 RepositoryService (org.activiti.engine.RepositoryService)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 CarbonApplication (org.wso2.carbon.application.deployer.CarbonApplication)1 Artifact (org.wso2.carbon.application.deployer.config.Artifact)1 ResponseHolder (org.wso2.carbon.bpmn.rest.model.stats.ResponseHolder)1 TaskInfo (org.wso2.carbon.bpmn.rest.model.stats.TaskInfo)1 RemovableTaskCleanupJob (org.wso2.carbon.humantask.cleanup.scheduler.ntask.RemovableTaskCleanupJob)1 TaskInfo (org.wso2.carbon.humantask.core.api.event.TaskInfo)1 HumanTaskServerConfiguration (org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration)1 HumanTaskServerException (org.wso2.carbon.humantask.core.engine.HumanTaskServerException)1 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)1 NotificationConfiguration (org.wso2.carbon.humantask.core.store.NotificationConfiguration)1 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)1 HumanTaskPackageManagementSkeleton (org.wso2.carbon.humantask.skeleton.mgt.services.HumanTaskPackageManagementSkeleton)1