Search in sources :

Example 71 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class BPELMessageReceiver method createAttachmentDTO.

private TAttachment createAttachmentDTO(DataHandler attachmentHandler) {
    TAttachment attachment = new TAttachment();
    String attachmentName = attachmentHandler.getName();
    attachment.setName(attachmentName);
    log.warn("Couldn't determine the name of BPEL client. So the owner of the attachment:" + attachmentName + " " + "will be the default bpel client" + org.wso2.carbon.bpel.core.BPELConstants.DAFAULT_BPEL_CLIENT);
    attachment.setCreatedBy(org.wso2.carbon.bpel.core.BPELConstants.DAFAULT_BPEL_CLIENT);
    attachment.setContentType(attachmentHandler.getContentType());
    // As well there are some other parameters to be set.
    attachment.setContent(attachmentHandler);
    return attachment;
}
Also used : TAttachment(org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)

Example 72 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class RestResponseFactory method createGroupResponse.

public GroupResponse createGroupResponse(Group group, String baseUrl) {
    RestUrlBuilder urlBuilder = createUrlBuilder(baseUrl);
    GroupResponse response = new GroupResponse();
    response.setId(group.getId());
    response.setName(group.getName());
    response.setType(group.getType());
    response.setUrl(urlBuilder.buildUrl(org.wso2.carbon.bpmn.rest.common.RestUrls.URL_GROUP, group.getId()));
    return response;
}
Also used : GroupResponse(org.wso2.carbon.bpmn.rest.model.identity.GroupResponse)

Example 73 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class TransformerUtils method generateAttachmentDAOFromID.

/**
 * Generate an {@code AttachmentDAO} for a given attachment-id
 *
 * @param task task to be associated with the particular attachment
 * @param attachmentID id of the attachment, so this will be used to extract attachment information from the
 * attachment-mgt OSGi service
 *
 * @return reference to the created {@code AttachmentDAO}
 * @throws HumanTaskException If if was failed to retrieve data from the attachment-mgt OSGi service
 */
public static AttachmentDAO generateAttachmentDAOFromID(TaskDAO task, String attachmentID) throws HumanTaskException {
    try {
        org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment attachment = HumanTaskServerHolder.getInstance().getAttachmentService().getAttachmentService().getAttachmentInfo(attachmentID);
        AttachmentDAO dao = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getDaoConnectionFactory().getConnection().createAttachment();
        // Constructing the attachment DAO from the DTO
        dao.setName(attachment.getName());
        dao.setContentType(attachment.getContentType());
        dao.setTask((Task) task);
        String attachmentURL = attachment.getUrl().toString();
        // Extracting the attachment uri
        String attachmentUniqueID = attachmentURL.substring(attachmentURL.lastIndexOf("/") + 1);
        dao.setValue(attachmentUniqueID);
        dao.setAttachedAt(attachment.getCreatedTime().getTime());
        OrganizationalEntityDAO orgEntityDAO = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getDaoConnectionFactory().getConnection().createNewOrgEntityObject(attachment.getCreatedBy(), OrganizationalEntityDAO.OrganizationalEntityType.USER);
        dao.setAttachedBy((OrganizationalEntity) orgEntityDAO);
        // TODO : "AccessType is not supported by Attachment-Mgt DTOs. So using a dummy value: " + HumanTaskConstants.DEFAULT_ATTACHMENT_ACCESS_TYPE);
        dao.setAccessType(HumanTaskConstants.DEFAULT_ATTACHMENT_ACCESS_TYPE);
        return dao;
    } catch (AttachmentMgtException e) {
        String errorMsg = "Attachment Data retrieval operation failed for attachment id:" + attachmentID + ". " + "Reason:";
        log.error(e.getLocalizedMessage(), e);
        throw new HumanTaskException(errorMsg + e.getLocalizedMessage(), e);
    }
}
Also used : AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException) org.wso2.carbon.humantask.client.api.types(org.wso2.carbon.humantask.client.api.types) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException)

Example 74 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class HumanTaskJPQLQueryBuilder method buildAllTasksCountQuery.

private Query buildAllTasksCountQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query allTasksQuery = em.createQuery(" SELECT COUNT(DISTINCT t) FROM org.wso2.carbon.humantask.core.dao.jpa" + ".openjpa.model.Task t " + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + (hasStatus ? T_STATUS_IN_TASK_STATUSES + AND : "") + T_TYPE_TASK_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + AND + T_TENANT_ID_TENANT_ID);
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    allTasksQuery.setParameter(NAMES, rolesAndNamesList);
    allTasksQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    allTasksQuery.setParameter(TASK_TYPE, TaskType.TASK);
    if (hasStatus) {
        allTasksQuery.setParameter(TASK_STATUSES, statuses);
    }
    if (hasTaskName) {
        allTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return allTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 75 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class HumanTaskJPQLQueryBuilder method buildAllTasksQuery.

private Query buildAllTasksQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query allTasksQuery = em.createQuery(" SELECT DISTINCT t FROM org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task t " + JOIN_HUMAN_ROLES_JOIN_ORG_ENTITIES + OE_NAME_IN_NAMES + AND + (hasStatus ? T_STATUS_IN_TASK_STATUSES + AND : "") + T_TYPE_TASK_TYPE + (hasTaskName ? AND + FILTER_BY_TASKNAME : "") + AND + T_TENANT_ID_TENANT_ID + generateOrderedByQuery()).setMaxResults(queryCriteria.getPageSize()).setFirstResult(queryCriteria.getPageSize() * queryCriteria.getPageNumber());
    List<String> rolesAndNamesList = getNameListForUser(queryCriteria.getCaller(), true);
    allTasksQuery.setParameter(NAMES, rolesAndNamesList);
    allTasksQuery.setParameter(TENANT_ID, queryCriteria.getCallerTenantId());
    allTasksQuery.setParameter(TASK_TYPE, TaskType.TASK);
    if (hasStatus) {
        allTasksQuery.setParameter(TASK_STATUSES, statuses);
    }
    if (hasTaskName) {
        allTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return allTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)18 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)13 HashMap (java.util.HashMap)12 Query (javax.persistence.Query)9 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)9 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)5 TAttachment (org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)5 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)4 AttachmentDAO (org.wso2.carbon.attachment.mgt.core.dao.AttachmentDAO)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)4 Test (org.testng.annotations.Test)3 ConfigurationException (org.wso2.carbon.config.ConfigurationException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2 Connection (java.sql.Connection)2 List (java.util.List)2