コード例 #1
0
  @Override
  protected long searchGroupEntriesCount(long groupId, long creatorUserId) throws Exception {

    Hits hits =
        JournalArticleServiceUtil.search(
            groupId,
            creatorUserId,
            WorkflowConstants.STATUS_APPROVED,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    return hits.getLength();
  }
コード例 #2
0
  @Override
  protected BaseModel<?> moveBaseModelFromTrash(
      ClassedModel classedModel, Group group, ServiceContext serviceContext) throws Exception {

    BaseModel<?> parentBaseModel = getParentBaseModel(group, serviceContext);

    JournalArticleServiceUtil.moveArticleFromTrash(
        group.getGroupId(),
        getAssetClassPK(classedModel),
        (Long) parentBaseModel.getPrimaryKeyObj(),
        serviceContext);

    return parentBaseModel;
  }
コード例 #3
0
  public ArticleSearch getSearchContainer() throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    ArticleSearch articleSearchContainer =
        new ArticleSearch(_liferayPortletRequest, getPortletURL());

    OrderByComparator<JournalArticle> orderByComparator =
        JournalPortletUtil.getArticleOrderByComparator(getOrderByCol(), getOrderByType());

    articleSearchContainer.setOrderByCol(getOrderByCol());
    articleSearchContainer.setOrderByComparator(orderByComparator);
    articleSearchContainer.setOrderByType(getOrderByType());

    EntriesChecker entriesChecker =
        new EntriesChecker(_liferayPortletRequest, _liferayPortletResponse);

    entriesChecker.setCssClass("entry-selector");

    articleSearchContainer.setRowChecker(entriesChecker);

    EntriesMover entriesMover = new EntriesMover(themeDisplay.getScopeGroupId());

    articleSearchContainer.setRowMover(entriesMover);

    if (isNavigationMine() || isNavigationRecent()) {
      boolean includeOwner = true;

      if (isNavigationMine()) {
        includeOwner = false;
      }

      if (isNavigationRecent()) {
        articleSearchContainer.setOrderByCol("create-date");
        articleSearchContainer.setOrderByType(getOrderByType());
      }

      int total =
          JournalArticleServiceUtil.getGroupArticlesCount(
              themeDisplay.getScopeGroupId(),
              themeDisplay.getUserId(),
              getFolderId(),
              getStatus(),
              includeOwner);

      articleSearchContainer.setTotal(total);

      List results =
          JournalArticleServiceUtil.getGroupArticles(
              themeDisplay.getScopeGroupId(),
              themeDisplay.getUserId(),
              getFolderId(),
              getStatus(),
              includeOwner,
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              articleSearchContainer.getOrderByComparator());

      articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMStructureKey())) {
      int total =
          JournalArticleServiceUtil.getArticlesCountByStructureId(
              themeDisplay.getScopeGroupId(), getDDMStructureKey(), getStatus());

      articleSearchContainer.setTotal(total);

      List results =
          JournalArticleServiceUtil.getArticlesByStructureId(
              themeDisplay.getScopeGroupId(),
              getDDMStructureKey(),
              getStatus(),
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              articleSearchContainer.getOrderByComparator());

      articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMTemplateKey())) {
      List<Long> folderIds = new ArrayList<>(1);

      if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        folderIds.add(getFolderId());
      }

      int total =
          JournalArticleServiceUtil.searchCount(
              themeDisplay.getCompanyId(),
              themeDisplay.getScopeGroupId(),
              folderIds,
              JournalArticleConstants.CLASSNAME_ID_DEFAULT,
              getKeywords(),
              -1.0,
              getDDMStructureKey(),
              getDDMTemplateKey(),
              null,
              null,
              getStatus(),
              null);

      articleSearchContainer.setTotal(total);

      List results =
          JournalArticleServiceUtil.search(
              themeDisplay.getCompanyId(),
              themeDisplay.getScopeGroupId(),
              folderIds,
              JournalArticleConstants.CLASSNAME_ID_DEFAULT,
              getKeywords(),
              -1.0,
              getDDMStructureKey(),
              getDDMTemplateKey(),
              null,
              null,
              getStatus(),
              null,
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              articleSearchContainer.getOrderByComparator());

      articleSearchContainer.setResults(results);
    } else if (isSearch()) {
      List<Long> folderIds = new ArrayList<>(1);

      if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        folderIds.add(getFolderId());
      }

      JournalWebConfiguration journalWebConfiguration =
          (JournalWebConfiguration) _request.getAttribute(JournalWebConfiguration.class.getName());

      if (journalWebConfiguration.journalArticlesSearchWithIndex()) {
        boolean orderByAsc = false;

        if (Validator.equals(getOrderByType(), "asc")) {
          orderByAsc = true;
        }

        Sort sort = null;

        if (Validator.equals(getOrderByCol(), "display-date")) {
          sort = new Sort("displayDate", Sort.LONG_TYPE, orderByAsc);
        } else if (Validator.equals(getOrderByCol(), "modified-date")) {
          sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc);
        }

        LinkedHashMap<String, Object> params = new LinkedHashMap<>();

        params.put("expandoAttributes", getKeywords());

        BaseModelSearchResult<JournalArticle> baseModelSearchResult =
            JournalArticleLocalServiceUtil.searchJournalArticles(
                themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(),
                folderIds,
                JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getDDMStructureKey(),
                getDDMTemplateKey(),
                getKeywords(),
                params,
                articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(),
                sort);

        int total = baseModelSearchResult.getLength();

        articleSearchContainer.setTotal(total);

        List results = baseModelSearchResult.getBaseModels();

        articleSearchContainer.setResults(results);
      } else {
        int total =
            JournalArticleServiceUtil.searchCount(
                themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(),
                folderIds,
                JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(),
                -1.0,
                getDDMStructureKey(),
                getDDMTemplateKey(),
                null,
                null,
                getStatus(),
                null);

        articleSearchContainer.setTotal(total);

        List results =
            JournalArticleServiceUtil.search(
                themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(),
                folderIds,
                JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(),
                -1.0,
                getDDMStructureKey(),
                getDDMTemplateKey(),
                null,
                null,
                getStatus(),
                null,
                articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
      }
    } else {
      int total =
          JournalFolderServiceUtil.getFoldersAndArticlesCount(
              themeDisplay.getScopeGroupId(), 0, getFolderId(), getStatus());

      articleSearchContainer.setTotal(total);

      OrderByComparator<Object> folderOrderByComparator = null;

      boolean orderByAsc = false;

      if (Validator.equals(getOrderByType(), "asc")) {
        orderByAsc = true;
      }

      if (Validator.equals(getOrderByCol(), "display-date")) {
        folderOrderByComparator = new FolderArticleDisplayDateComparator(orderByAsc);
      } else if (Validator.equals(getOrderByCol(), "modified-date")) {
        folderOrderByComparator = new FolderArticleModifiedDateComparator(orderByAsc);
      }

      List results =
          JournalFolderServiceUtil.getFoldersAndArticles(
              themeDisplay.getScopeGroupId(),
              0,
              getFolderId(),
              getStatus(),
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              folderOrderByComparator);

      articleSearchContainer.setResults(results);
    }

    return articleSearchContainer;
  }
コード例 #4
0
  @Override
  public String getRowCheckBox(
      HttpServletRequest request, boolean checked, boolean disabled, String primaryKey) {

    if (!_journalDisplayContext.isShowEditActions()) {
      return StringPool.BLANK;
    }

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

    JournalArticle article = null;
    JournalFolder folder = null;

    String articleId = GetterUtil.getString(primaryKey);

    try {
      article = JournalArticleServiceUtil.getArticle(themeDisplay.getScopeGroupId(), articleId);
    } catch (Exception e1) {
      if (e1 instanceof NoSuchArticleException) {
        try {
          long folderId = GetterUtil.getLong(primaryKey);

          folder = JournalFolderServiceUtil.getFolder(folderId);
        } catch (Exception e2) {
          return StringPool.BLANK;
        }
      }
    }

    String name = null;
    boolean showInput = false;

    if (article != null) {
      name = JournalArticle.class.getSimpleName();

      try {
        if (JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.DELETE)
            || JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.EXPIRE)
            || JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.UPDATE)) {

          showInput = true;
        }
      } catch (Exception e) {
      }
    } else if (folder != null) {
      name = JournalFolder.class.getSimpleName();

      try {
        if (JournalFolderPermission.contains(_permissionChecker, folder, ActionKeys.DELETE)) {

          showInput = true;
        }
      } catch (Exception e) {
      }
    }

    if (!showInput) {
      return StringPool.BLANK;
    }

    StringBundler sb = new StringBundler(9);

    sb.append("['");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalFolder.class.getSimpleName());
    sb.append("', '");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalArticle.class.getSimpleName());
    sb.append("']");

    String checkBoxRowIds = sb.toString();

    return getRowCheckBox(
        request,
        checked,
        disabled,
        _liferayPortletResponse.getNamespace() + RowChecker.ROW_IDS + name + "",
        primaryKey,
        checkBoxRowIds,
        "'#" + getAllRowIds() + "'",
        StringPool.BLANK);
  }
コード例 #5
0
 @Override
 protected int getRecentBaseModelsCount(long groupId) throws Exception {
   return JournalArticleServiceUtil.getGroupArticlesCount(
       groupId, 0, JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID);
 }