use of org.wso2.carbon.humantask.skeleton.mgt.services.types.Task_type0 in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method listTasksInPackage.
/**
* Lists the tasks in the given package name.
*
* @param packageName : The name of the package to list task definitions.
* @return : The Task_type0 array containing the task definition information.
*/
public Task_type0[] listTasksInPackage(String packageName) throws PackageManagementException {
if (StringUtils.isEmpty(packageName)) {
throw new IllegalArgumentException("The provided package name is empty!");
}
try {
List<SimpleTaskDefinitionInfo> taskDefsInPackage = getTenantTaskStore().getTaskConfigurationInfoListForPackage(packageName);
Task_type0[] taskDefArray = new Task_type0[taskDefsInPackage.size()];
int i = 0;
for (SimpleTaskDefinitionInfo taskDefinitionInfo : taskDefsInPackage) {
taskDefArray[i] = createTaskTypeObject(taskDefinitionInfo);
i++;
}
return taskDefArray;
} catch (Exception ex) {
String errMsg = "listTasksInPackage operation failed";
log.error(errMsg, ex);
throw new PackageManagementException(errMsg, ex);
}
}
use of org.wso2.carbon.humantask.skeleton.mgt.services.types.Task_type0 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;
}
Aggregations