Search in sources :

Example 1 with TNotification

use of org.wso2.carbon.humantask.TNotification 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 TNotification

use of org.wso2.carbon.humantask.TNotification 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 3 with TNotification

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

Aggregations

QName (javax.xml.namespace.QName)2 TNotification (org.wso2.carbon.humantask.TNotification)2 TTask (org.wso2.carbon.humantask.TTask)2 ArrayList (java.util.ArrayList)1 OrganizationalEntityProvider (org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.provider.OrganizationalEntityProvider)1 HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)1 NotificationConfiguration (org.wso2.carbon.humantask.core.store.NotificationConfiguration)1 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)1