예제 #1
0
  /*
   * (non-Javadoc)
   * @see com.lzcp.service.ServiceAlbum#getAlbumByCategoryId(java.lang.String)
   */
  @Override
  public List<ModelAlbum> getAlbumByCategoryId(String categoryId, String parentEntryId)
      throws ServiceException {
    // if (UtilString.isNotEmpty(categoryId))
    // {
    try {
      DetachedCriteria criteria = DetachedCriteria.forClass(ModelAlbum.class);

      if (UtilString.isNotEmpty(categoryId)) {
        criteria.createCriteria("category").add(Restrictions.eq("id", categoryId));
      }

      if (UtilString.isNotEmpty(parentEntryId)) {
        criteria.createCriteria("parentEntry").add(Restrictions.eq("id", parentEntryId));
      }

      return this.daoAlbum.getListByCriteria(criteria);
    } catch (DAOException e) {
      LOGGER.error("It failed to obtain the album with category id: " + categoryId, e);
    } catch (Exception e) {
      throw new ServiceException(
          "It failed to obtain the album with category id: " + categoryId, e);
    }
    // }

    return null;
  }
예제 #2
0
  /*
   * (non-Javadoc)
   * @see com.lzcp.service.ServiceAlbum#getAlbumByCategoryContextPath(java.lang.String)
   */
  @Override
  public List<ModelAlbum> getAlbumByCategoryContextPath(
      String categoryContextPath, String parentEntryId) throws ServiceException {
    if (UtilString.isNotEmpty(categoryContextPath)) {
      try {
        ModelCategory category = this.daoCategory.getCategoryByContextPath(categoryContextPath);

        if (category == null) {
          LOGGER.error(
              "The cateogry with context path(" + categoryContextPath + ") does not exit!");
          return null;
        }

        return this.getAlbumByCategoryId(category.getId(), parentEntryId);

      } catch (DAOException e) {
        LOGGER.error(
            "It failed to obtain the album with category context path: " + categoryContextPath, e);
      } catch (Exception e) {
        throw new ServiceException(
            "It failed to obtain the album with category context path: " + categoryContextPath, e);
      }
    }

    return null;
  }
예제 #3
0
  /*
   * (non-Javadoc)
   * @see com.lzcp.service.ServiceAlbum#getAlbumPagesByCategoryContextPath(java.lang.String, int, int, java.lang.String, java.lang.Boolean)
   */
  @Override
  public PaginationSupport<ModelAlbum> getAlbumPagesByCategoryContextPath(
      String categoryContextPath, int pageSize, int startIndex, String order, Boolean isDesc)
      throws ServiceException {
    if (UtilString.isNotEmpty(categoryContextPath)) {
      try {
        ModelCategory category = this.daoCategory.getCategoryByContextPath(categoryContextPath);
        if (category == null) {
          LOGGER.error(
              "The cateogry with context path(" + categoryContextPath + ") does not exit!");
          return null;
        }

        DetachedCriteria criteria = DetachedCriteria.forClass(ModelAlbum.class);
        criteria.createCriteria("category").add(Restrictions.eq("id", category.getId()));

        return this.daoAlbum.findPageByCriteria(criteria, pageSize, startIndex);

      } catch (DAOException e) {
        LOGGER.error(
            "It failed to obtain the album with category context path: " + categoryContextPath, e);
      } catch (Exception e) {
        throw new ServiceException(
            "It failed to obtain the album with category context path: " + categoryContextPath, e);
      }
    }

    return null;
  }