use of org.wso2.carbon.humantask.core.api.event.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;
}
use of org.wso2.carbon.humantask.core.api.event.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;
}
use of org.wso2.carbon.humantask.core.api.event.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;
}
use of org.wso2.carbon.humantask.core.api.event.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;
}
use of org.wso2.carbon.humantask.core.api.event.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);
}
}
}
Aggregations