Search in sources :

Example 1 with NotificationConfiguration

use of org.wso2.carbon.humantask.core.store.NotificationConfiguration in project carbon-business-process by wso2.

the class HumanTaskStore method deploy.

/**
 * This will simply deploy the new task and will not perform removal of existing tasks, which should be done prior to
 * deploying this task
 * @param humanTaskDU
 * @return List of task configuration Qnames deployed
 * @throws HumanTaskDeploymentException
 */
public List<QName> deploy(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException {
    List<QName> taskConfigsInPackage = new ArrayList<QName>();
    TTask[] tasks = humanTaskDU.getTasks();
    List<HumanTaskBaseConfiguration> configurations = new ArrayList<HumanTaskBaseConfiguration>();
    if (tasks != null) {
        for (TTask task : tasks) {
            QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
            if (log.isDebugEnabled()) {
                log.debug(" Adding task " + task.getName() + "to task configuration");
            }
            TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            taskConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(taskConf);
            if (!taskConf.isErroneous()) {
                createCallBackService(taskConf);
                if (taskConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(taskConf);
                // activeTaskConfigurationQNameMap.put(taskQName, taskConf.getName());
                }
            }
        }
    }
    TNotification[] notifications = humanTaskDU.getNotifications();
    if (notifications != null) {
        for (TNotification notification : notifications) {
            QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
            NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(notificationConf);
            if (!notificationConf.isErroneous()) {
                // Deploy the axis2 service only for the active version of the task/notification
                if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(notificationConf);
                // activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
                }
            }
        }
    }
    // condition if a service name is deployed with same name outside of this task package
    for (HumanTaskBaseConfiguration configuration : configurations) {
        taskConfigurations.add(configuration);
        taskBaseConfigurationHashMap.put(configuration.getName(), configuration);
        taskConfigsInPackage.add(configuration.getName());
        if (configuration.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(configuration.getDefinitionName(), configuration.getName());
        }
    }
    for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
        QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
        NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
        notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
        taskConfigurations.add(notificationConf);
        taskConfigsInPackage.add(notificationConf.getName());
        taskBaseConfigurationHashMap.put(notificationConf.getName(), notificationConf);
        if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
        }
    }
    taskConfigurationsInTaskPackage.put(humanTaskDU.getName(), taskConfigsInPackage);
    return taskConfigsInPackage;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 2 with NotificationConfiguration

use of org.wso2.carbon.humantask.core.store.NotificationConfiguration in project carbon-business-process by wso2.

the class HumanTaskPackageManagementSkeleton method getTaskConfigInfo.

/**
 * +     * Check the configuration type and return the configuration information for a given task ID
 * +     * @param taskId
 * +     * @return  TaskConfigInfoResponse response
 * +     * @throws  PackageManagementException
 * +
 */
public TaskConfigInfoResponse getTaskConfigInfo(QName taskId) throws PackageManagementException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    TaskConfigInfoResponse response = null;
    HumanTaskBaseConfiguration taskConf = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getTaskConfiguration(taskId);
    if (taskConf != null) {
        response = new TaskConfigInfoResponse();
        if (taskConf.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
            response.setTaskName(taskConf.getName());
            response.setServiceName(taskConf.getServiceName());
            response.setPortName(taskConf.getPortName());
            response.setCallbackServiceName(((TaskConfiguration) taskConf).getCallbackServiceName());
            response.setCallbackPortName(((TaskConfiguration) taskConf).getCallbackPortName());
        } else if (taskConf.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.NOTIFICATION) {
            response.setTaskName(((NotificationConfiguration) taskConf).getName());
            response.setServiceName(taskConf.getServiceName());
            response.setPortName(taskConf.getPortName());
        }
    }
    return response;
}
Also used : NotificationConfiguration(org.wso2.carbon.humantask.core.store.NotificationConfiguration) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)

Example 3 with NotificationConfiguration

use of org.wso2.carbon.humantask.core.store.NotificationConfiguration in project carbon-business-process by wso2.

the class JPATaskUtil method processGenericHumanRoles.

public static void processGenericHumanRoles(TaskDAO task, HumanTaskBaseConfiguration taskConfiguration, PeopleQueryEvaluator peopleQueryEvaluator, EvaluationContext evaluationContext) throws HumanTaskException {
    if (taskConfiguration.isTask()) {
        // Task
        TTask tTask = ((TaskConfiguration) taskConfiguration).getTask();
        // TODO move the reading of configuration file in to the TaskConfiguration class
        // Reading Excluded users
        TGenericHumanRoleAssignment[] tExcludedOwners = tTask.getPeopleAssignments().getExcludedOwnersArray();
        if (tExcludedOwners != null && tExcludedOwners.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tExcludedOwners[0], GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS, evaluationContext);
        }
        // Reading potential owners
        TPotentialOwnerAssignment[] tPotentialOwners = tTask.getPeopleAssignments().getPotentialOwnersArray();
        if (tPotentialOwners != null && tPotentialOwners.length > 0) {
            TPotentialOwnerAssignment tPotentialOwner = tPotentialOwners[0];
            OrganizationalEntityProvider provider = OrganizationalEntityProviderFactory.getOrganizationalEntityProvider(tPotentialOwner.getFrom());
            List<OrganizationalEntityDAO> orgEntities = provider.getOrganizationalEntities(peopleQueryEvaluator, tPotentialOwner.getFrom(), evaluationContext);
            if (tExcludedOwners != null && tExcludedOwners.length > 0) {
                GenericHumanRoleDAO excludedOwners = task.getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS);
                for (OrganizationalEntityDAO excludedEntity : excludedOwners.getOrgEntities()) {
                    for (OrganizationalEntityDAO ownerEntity : orgEntities) {
                        if (excludedEntity.getOrgEntityType() == ownerEntity.getOrgEntityType() && excludedEntity.getName().equals(ownerEntity.getName())) {
                            orgEntities.remove(ownerEntity);
                            break;
                        }
                    }
                }
            }
            GenericHumanRole potentialOwnersGHRole = new GenericHumanRole();
            potentialOwnersGHRole.setType(GenericHumanRole.GenericHumanRoleType.POTENTIAL_OWNERS);
            potentialOwnersGHRole.setOrgEntities(orgEntities);
            potentialOwnersGHRole.setTask(task);
            for (OrganizationalEntityDAO oe : orgEntities) {
                oe.addGenericHumanRole(potentialOwnersGHRole);
            }
            task.addHumanRole(potentialOwnersGHRole);
        }
        // Reading Stake holders
        TGenericHumanRoleAssignment[] tStakeHolders = tTask.getPeopleAssignments().getTaskStakeholdersArray();
        if (tStakeHolders != null && tStakeHolders.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tStakeHolders[0], GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS, evaluationContext);
        }
        // Reading Business administrators
        TGenericHumanRoleAssignment[] tBusinessAdministrators = tTask.getPeopleAssignments().getBusinessAdministratorsArray();
        if (tBusinessAdministrators != null && tBusinessAdministrators.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tBusinessAdministrators[0], GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS, evaluationContext);
        }
    } else {
        // Notification
        TNotification tNotification = ((NotificationConfiguration) taskConfiguration).getNotificationDefinition();
        // Reading Notification recipients
        TGenericHumanRoleAssignment[] tRecipients = tNotification.getPeopleAssignments().getRecipientsArray();
        if (tRecipients != null && tRecipients.length > 0) {
            assignHumanRoles(task, peopleQueryEvaluator, tRecipients[0], GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS, evaluationContext);
        }
    }
}
Also used : OrganizationalEntityProvider(org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.provider.OrganizationalEntityProvider) NotificationConfiguration(org.wso2.carbon.humantask.core.store.NotificationConfiguration) TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration)

Example 4 with NotificationConfiguration

use of org.wso2.carbon.humantask.core.store.NotificationConfiguration in project carbon-business-process by wso2.

the class HumanTaskStore method validateTaskConfig.

/**
 * Performance a test deployment of the task in order to avoid deployment issues due to invalid task packages
 * @param humanTaskDU
 * @return
 * @throws HumanTaskDeploymentException
 */
public void validateTaskConfig(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException, AxisFault {
    boolean validateTask = HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().getEnableTaskValidationBeforeDeployment();
    if (validateTask) {
        TTask[] tasks = humanTaskDU.getTasks();
        if (tasks != null) {
            for (TTask task : tasks) {
                QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
                TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
                if (taskConf.isErroneous()) {
                    throw new HumanTaskDeploymentException(taskConf.getDeploymentError());
                }
                validateServiceCreationForTaskConfig(taskConf);
            }
        }
        TNotification[] notifications = humanTaskDU.getNotifications();
        if (notifications != null) {
            for (TNotification notification : notifications) {
                QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
                NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
                if (notificationConf.isErroneous()) {
                    throw new HumanTaskDeploymentException(notificationConf.getDeploymentError());
                }
                validateServiceCreationForTaskConfig(notificationConf);
            }
        }
        for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
            QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
            NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            if (notificationConf.isErroneous()) {
                throw new HumanTaskDeploymentException(notificationConf.getDeploymentError());
            }
            validateServiceCreationForTaskConfig(notificationConf);
        }
    }
    return;
}
Also used : QName(javax.xml.namespace.QName) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 5 with NotificationConfiguration

use of org.wso2.carbon.humantask.core.store.NotificationConfiguration 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)

Aggregations

QName (javax.xml.namespace.QName)3 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)3 NotificationConfiguration (org.wso2.carbon.humantask.core.store.NotificationConfiguration)3 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)3 TNotification (org.wso2.carbon.humantask.TNotification)2 TTask (org.wso2.carbon.humantask.TTask)2 ArrayList (java.util.ArrayList)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 OrganizationalEntityProvider (org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.provider.OrganizationalEntityProvider)1 HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)1 ExpressionEvaluationContext (org.wso2.carbon.humantask.core.engine.runtime.ExpressionEvaluationContext)1 EvaluationContext (org.wso2.carbon.humantask.core.engine.runtime.api.EvaluationContext)1 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)1 UserStoreException (org.wso2.carbon.user.api.UserStoreException)1