public int getFolderUnreadMessagesCount(long folderId) throws SystemException {

    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Message.class, getClassLoader());

    dynamicQuery.add(RestrictionsFactoryUtil.eq("folderId", folderId));
    dynamicQuery.add(
        RestrictionsFactoryUtil.not(
            RestrictionsFactoryUtil.like("flags", "%" + MailConstants.FLAG_SEEN + ",%")));

    return (int) dynamicQueryCount(dynamicQuery);
  }
예제 #2
0
  @SuppressWarnings("unchecked")
  public List<Asset> getAssets(String pattern, boolean ticker) {
    List<Asset> results = new ArrayList<Asset>();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(AssetImpl.class);

    dynamicQuery.add(
        RestrictionsFactoryUtil.like(
            ticker ? "security_ticker" : "id_isin",
            StringPool.PERCENT + pattern + StringPool.PERCENT));
    dynamicQuery.addOrder(OrderFactoryUtil.asc(ticker ? "security_ticker" : "id_isin"));

    try {
      results = assetLocalService.dynamicQuery(dynamicQuery);
    } catch (SystemException e) {
      e.printStackTrace();
    }

    return results;
  }