Example usage for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_GROUP_ID

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_GROUP_ID

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_GROUP_ID.

Prototype

String CONTEXT_GROUP_ID

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_GROUP_ID.

Click Source Link

Usage

From source file:com.liferay.portlet.workflowinstances.action.EditWorkflowInstanceAction.java

License:Open Source License

protected void deleteInstance(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long workflowInstanceId = ParamUtil.getLong(actionRequest, "workflowInstanceId");

    WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil
            .getWorkflowInstance(themeDisplay.getCompanyId(), workflowInstanceId);

    Map<String, Serializable> workflowContext = workflowInstance.getWorkflowContext();

    long companyId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
    long groupId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));
    String className = GetterUtil.getString(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME));
    long classPK = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));

    WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler(className);

    workflowHandler.updateStatus(WorkflowConstants.STATUS_DRAFT, workflowContext);

    WorkflowInstanceLinkLocalServiceUtil.deleteWorkflowInstanceLink(companyId, groupId, className, classPK);
}

From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPortletHelper.java

License:Open Source License

/**
 * This method prepares a Boolean filter builder with respective facet selections from Resource request object.
 *
 * @param request the request//from   ww w  .  j av  a 2s .  com
 * @return the bool filter builder
 */
private BoolFilterBuilder prepareBoolFilterBuilder(ResourceRequest request) {

    /**Set a filter to get suggestions with Status Approved (0) */
    BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter().must(
            FilterBuilders.termFilter(ElasticsearchPortletConstants.STATUS, WorkflowConstants.STATUS_APPROVED));

    /** Iterate over Suggestion excluded index types and add to Boolfilter. Since these are excluded, mustNot filter should be used */
    for (Iterator<String> iterator = propsValues.getSuggestionExcludedTypes().iterator(); iterator.hasNext();) {
        boolFilterBuilder.mustNot(FilterBuilders.typeFilter(iterator.next()));
    }

    /** Process facet selections and apply appropriate filters here
    Apply UserId filter */
    long userId = ParamUtil.getLong(request, WorkflowConstants.CONTEXT_USER_ID);
    if (userId > ElasticsearchPortletConstants.INTEGER_ZERO_VALUE) {
        boolFilterBuilder.must(FilterBuilders.termFilter(WorkflowConstants.CONTEXT_USER_ID, userId));
    }

    /** Apply modified filter */
    String selectedRange = ParamUtil.getString(request, ElasticsearchPortletConstants.FILTER_MODIFIED);
    if (Validator.isNotNull(selectedRange) && !selectedRange.isEmpty()) {
        String[] rangeArray = fetchFromToValuesInRage(selectedRange);
        boolFilterBuilder.must(FilterBuilders.rangeFilter(ElasticsearchPortletConstants.FILTER_MODIFIED_DATE)
                .from(rangeArray[0].trim()).to(rangeArray[1].trim()));
    }

    /**  Apply AssetCategoryIds filter */
    long assetCategoryIds = ParamUtil.getLong(request, ElasticsearchPortletConstants.FILTER_ASSET_CATEGORY);
    if (assetCategoryIds > ElasticsearchPortletConstants.INTEGER_ZERO_VALUE) {
        boolFilterBuilder.must(FilterBuilders.termFilter(ElasticsearchPortletConstants.FILTER_ASSET_CATEGORY,
                assetCategoryIds));
    }

    /**  Apply FolderId filter */
    long folderId = ParamUtil.getLong(request, ElasticsearchPortletConstants.FILTER_FOLDERID);
    if (folderId > ElasticsearchPortletConstants.INTEGER_ZERO_VALUE) {
        boolFilterBuilder
                .must(FilterBuilders.termFilter(ElasticsearchPortletConstants.FILTER_FOLDERID, folderId));
    }

    /** Apply Site id filter */
    long groupId = ParamUtil.getLong(request, WorkflowConstants.CONTEXT_GROUP_ID);
    if (groupId != WorkflowConstants.DEFAULT_GROUP_ID) {
        boolFilterBuilder
                .must(FilterBuilders.termFilter(ElasticsearchPortletConstants.FILTER_SCOPE_GROUPID, groupId))
                .must(FilterBuilders.termFilter(WorkflowConstants.CONTEXT_GROUP_ID, groupId));
    }

    /**  Entryclassname is a special case since object is directly mapped to Index type in Elasticsearch.
     So instead of applying a filter, we use respective Entryclassname type */
    String selectedClassName = ParamUtil.getString(request, ElasticsearchPortletConstants.ENTRY_CLASSNAME);
    if (Validator.isNotNull(selectedClassName)) {
        /** Convert selectedClassName to index type by replacing . with _*/
        selectedClassName = selectedClassName.replace(StringPool.PERIOD, StringPool.UNDERLINE);
        boolFilterBuilder.must(FilterBuilders.typeFilter(selectedClassName));
    }
    return boolFilterBuilder;
}

From source file:se.gothiaforum.actorsarticle.util.ActorsServiceUtil.java

License:Open Source License

/**
 * Add the article to workflow.//from w w  w  .  j av  a 2  s .  c  o  m
 * 
 * @param article
 * @param userId
 * @param serviceContext
 * @param groupId
 */
public void addWorkFlow(long userId, JournalArticle article, long groupId, ServiceContext serviceContext) {
    try {

        User user = userService.getUser(userId);
        WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil
                .getWorkflowHandler(JournalArticle.class.getName());
        Map<String, Serializable> workflowContext = new HashMap<String, Serializable>();
        workflowContext.put(WorkflowConstants.CONTEXT_COMPANY_ID, String.valueOf(article.getCompanyId()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME,
                String.valueOf(article.getClass().getName()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK, String.valueOf(article.getPrimaryKey()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_TYPE, String.valueOf(article.getType()));
        workflowContext.put(WorkflowConstants.CONTEXT_GROUP_ID, String.valueOf(article.getGroupId()));
        workflowContext.put(WorkflowConstants.CONTEXT_USER_ID, String.valueOf(article.getUserId()));
        workflowContext.put(WorkflowConstants.CONTEXT_SERVICE_CONTEXT, serviceContext);

        workflowHandler.startWorkflowInstance(article.getCompanyId(), groupId, user.getUserId(),
                article.getPrimaryKey(), article.getClass().getName(), workflowContext);
    } catch (PortalException e) {
        throw new RuntimeException("Unable to add workflow", e);
    } catch (SystemException e) {
        throw new RuntimeException("Unable to add workflow", e);
    }
}