Search in sources :

Example 1 with Task_type0

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);
    }
}
Also used : SimpleTaskDefinitionInfo(org.wso2.carbon.humantask.core.deployment.SimpleTaskDefinitionInfo) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException)

Example 2 with Task_type0

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;
}
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)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 CarbonApplication (org.wso2.carbon.application.deployer.CarbonApplication)1 Artifact (org.wso2.carbon.application.deployer.config.Artifact)1 SimpleTaskDefinitionInfo (org.wso2.carbon.humantask.core.deployment.SimpleTaskDefinitionInfo)1 HumanTaskPackageManagementSkeleton (org.wso2.carbon.humantask.skeleton.mgt.services.HumanTaskPackageManagementSkeleton)1 PackageManagementException (org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException)1 Task_type0 (org.wso2.carbon.humantask.skeleton.mgt.services.types.Task_type0)1