Package com.jeecms.common.hibernate3

Examples of com.jeecms.common.hibernate3.TreeIntercptor


  public Pagination getPageByTagIdsForTag(Integer[] tagIds,
      Integer[] siteIds, Integer[] channelIds, Integer[] typeIds,
      Integer excludeId, Boolean titleImg, Boolean recommend,
      String title, int orderBy, int pageNo, int pageSize) {
    Finder f = byTagIds(tagIds, siteIds, channelIds, typeIds, excludeId,
        titleImg, recommend, title, orderBy);
    f.setCacheable(true);
    return find(f, pageNo, pageSize);
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  public List<Content> getListByTagIdsForTag(Integer[] tagIds,
      Integer[] siteIds, Integer[] channelIds, Integer[] typeIds,
      Integer excludeId, Boolean titleImg, Boolean recommend,
      String title, int orderBy, Integer first, Integer count) {
    Finder f = byTagIds(tagIds, siteIds, channelIds, typeIds, excludeId,
        titleImg, recommend, title, orderBy);
    if (first != null) {
      f.setFirstResult(first);
    }
    if (count != null) {
      f.setMaxResults(count);
    }
    f.setCacheable(true);
    return find(f);
  }
View Full Code Here

    return find(f);
  }

  private Finder bySiteIds(Integer[] siteIds, Integer[] typeIds,
      Boolean titleImg, Boolean recommend, String title, int orderBy) {
    Finder f = Finder.create("select bean from Content bean");
    f.append(" join bean.contentExt as ext where 1=1");
    if (titleImg != null) {
      f.append(" and bean.hasTitleImg=:titleImg");
      f.setParam("titleImg", titleImg);
    }
    if (recommend != null) {
      f.append(" and bean.recommend=:recommend");
      f.setParam("recommend", recommend);
    }
    appendReleaseDate(f);
    appendTypeIds(f, typeIds);
    appendSiteIds(f, siteIds);
    f.append(" and bean.status=" + ContentCheck.CHECKED);
    if (!StringUtils.isBlank(title)) {
      f.append(" and bean.contentExt.title like :title");
      f.setParam("title", "%" + title + "%");
    }
    appendOrder(f, orderBy);
    return f;
  }
View Full Code Here

public class LuceneContentDaoImpl extends HibernateBaseDao<Content, Integer>
    implements LuceneContentDao {
  public Integer index(IndexWriter writer, Integer siteId, Integer channelId,
      Date startDate, Date endDate, Integer startId, Integer max)
      throws CorruptIndexException, IOException {
    Finder f = Finder.create("select bean from Content bean");
    if (channelId != null) {
      f.append(" join bean.channel channel, Channel parent");
      f.append(" where channel.lft between parent.lft and parent.rgt");
      f.append(" and channel.site.id=parent.site.id");
      f.append(" and parent.id=:parentId");
      f.setParam("parentId", channelId);
    } else if (siteId != null) {
      f.append(" where bean.site.id=:siteId");
      f.setParam("siteId", siteId);
    } else {
      f.append(" where 1=1");
    }
    if (startId != null) {
      f.append(" and bean.id > :startId");
      f.setParam("startId", startId);
    }
    if (startDate != null) {
      f.append(" and bean.contentExt.releaseDate >= :startDate");
      f.setParam("startDate", startDate);
    }
    if (endDate != null) {
      f.append(" and bean.contentExt.releaseDate <= :endDate");
      f.setParam("endDate", endDate);
    }
    f.append(" and bean.status=" + ContentCheck.CHECKED);
    f.append(" order by bean.id asc");
    if (max != null) {
      f.setMaxResults(max);
    }
    Session session = getSession();
    ScrollableResults contents = f.createQuery(getSession()).setCacheMode(
        CacheMode.IGNORE).scroll(ScrollMode.FORWARD_ONLY);
    int count = 0;
    Content content = null;
    while (contents.next()) {
      content = (Content) contents.get(0);
View Full Code Here

  }

  private Finder byChannelIds(Integer[] channelIds, Integer[] typeIds,
      Boolean titleImg, Boolean recommend, String title, int orderBy,
      int option) {
    Finder f = Finder.create();
    int len = channelIds.length;
    // 如果多个栏目
    if (option == 0 || len > 1) {
      f.append("select bean from Content bean");
      f.append(" join bean.contentExt as ext");
      if (len == 1) {
        f.append(" where bean.channel.id=:channelId");
        f.setParam("channelId", channelIds[0]);
      } else {
        f.append(" where bean.channel.id in (:channelIds)");
        f.setParamList("channelIds", channelIds);
      }
    } else if (option == 1) {
      // 包含子栏目
      f.append("select bean from Content bean");
      f.append(" join bean.contentExt as ext");
      f.append(" join bean.channel node,Channel parent");
      f.append(" where node.lft between parent.lft and parent.rgt");
      f.append(" and bean.site.id=parent.site.id");
      f.append(" and parent.id=:channelId");
      f.setParam("channelId", channelIds[0]);
    } else if (option == 2) {
      // 包含副栏目
      f.append("select bean from Content bean");
      f.append(" join bean.contentExt as ext");
      f.append(" join bean.channels as channel");
      f.append(" where channel.id=:channelId");
      f.setParam("channelId", channelIds[0]);
    } else {
      throw new RuntimeException("option value must be 0 or 1 or 2.");
    }
    if (titleImg != null) {
      f.append(" and bean.hasTitleImg=:titleImg");
      f.setParam("titleImg", titleImg);
    }
    if (recommend != null) {
      f.append(" and bean.recommend=:recommend");
      f.setParam("recommend", recommend);
    }
    appendReleaseDate(f);
    appendTypeIds(f, typeIds);
    f.append(" and bean.status=" + ContentCheck.CHECKED);
    if (!StringUtils.isBlank(title)) {
      f.append(" and bean.contentExt.title like :title");
      f.setParam("title", "%" + title + "%");
    }
    appendOrder(f, orderBy);
    return f;
  }
View Full Code Here

public class CmsUserDaoImpl extends HibernateBaseDao<CmsUser, Integer>
    implements CmsUserDao {
  public Pagination getPage(String username, String email, Integer siteId,
      Integer groupId, Boolean disabled, Boolean admin, Integer rank,
      int pageNo, int pageSize) {
    Finder f = Finder.create("select bean from CmsUser bean");
    if (siteId != null) {
      f.append(" join bean.userSites userSite");
      f.append(" where userSite.site.id=:siteId");
      f.setParam("siteId", siteId);
    } else {
      f.append(" where 1=1");
    }
    if (!StringUtils.isBlank(username)) {
      f.append(" and bean.username like :username");
      f.setParam("username", "%" + username + "%");
    }
    if (!StringUtils.isBlank(email)) {
      f.append(" and bean.email like :email");
      f.setParam("email", "%" + email + "%");
    }
    if (groupId != null) {
      f.append(" and bean.group.id=:groupId");
      f.setParam("groupId", groupId);
    }
    if (disabled != null) {
      f.append(" and bean.disabled=:disabled");
      f.setParam("disabled", disabled);
    }
    if (admin != null) {
      f.append(" and bean.admin=:admin");
      f.setParam("admin", admin);
    }
    if (rank != null) {
      f.append(" and bean.rank<=:rank");
      f.setParam("rank", rank);
    }
    f.append(" order by bean.id desc");
    return find(f, pageNo, pageSize);
  }
View Full Code Here

    return find(f, pageNo, pageSize);
  }
 
  public List getList(String username, String email, Integer siteId,
      Integer groupId, Boolean disabled, Boolean admin, Integer rank) {
    Finder f = Finder.create("select bean from CmsUser bean");
    if (siteId != null) {
      f.append(" join bean.userSites userSite");
      f.append(" where userSite.site.id=:siteId");
      f.setParam("siteId", siteId);
    } else {
      f.append(" where 1=1");
    }
    if (!StringUtils.isBlank(username)) {
      f.append(" and bean.username like :username");
      f.setParam("username", "%" + username + "%");
    }
    if (!StringUtils.isBlank(email)) {
      f.append(" and bean.email like :email");
      f.setParam("email", "%" + email + "%");
    }
    if (groupId != null) {
      f.append(" and bean.group.id=:groupId");
      f.setParam("groupId", groupId);
    }
    if (disabled != null) {
      f.append(" and bean.disabled=:disabled");
      f.setParam("disabled", disabled);
    }
    if (admin != null) {
      f.append(" and bean.admin=:admin");
      f.setParam("admin", admin);
    }
    if (rank != null) {
      f.append(" and bean.rank<=:rank");
      f.setParam("rank", rank);
    }
    f.append(" order by bean.id desc");
    return find(f);
  }
View Full Code Here

@Repository
public class CmsStatisticDaoImpl extends HibernateSimpleDao implements
    CmsStatisticDao {
  public long memberStatistic(TimeRange timeRange) {
    Finder f = createCacheableFinder("select count(*) from CmsUser bean where 1=1");
    if (timeRange != null) {
      f.append(" and bean.registerTime >= :begin");
      f.append(" and bean.registerTime < :end");
      f.setParam("begin", timeRange.getBegin());
      f.setParam("end", timeRange.getEnd());
    }
    return (Long) find(f).iterator().next();
  }
View Full Code Here

    return (Long) find(f).iterator().next();
  }

  public long contentStatistic(TimeRange timeRange,
      Map<String, Object> restrictions) {
    Finder f = createCacheableFinder("select count(*) from Content bean");
    Integer userId = (Integer) restrictions.get(USERID);
    Integer channelId = (Integer) restrictions.get(CHANNELID);
    if (channelId != null) {
      f.append(" join bean.channel channel,Channel parent");
      f.append(" where channel.lft between parent.lft and parent.rgt");
      f.append(" and channel.site.id=parent.site.id");
      f.append(" and parent.id=:parentId");
      f.setParam("parentId", channelId);
    } else {
      f.append(" where bean.site.id=:siteId").setParam("siteId",
          restrictions.get(SITEID));
    }
    if (timeRange != null) {
      f.append(" and bean.contentExt.releaseDate >= :begin");
      f.append(" and bean.contentExt.releaseDate < :end");
      f.setParam("begin", timeRange.getBegin());
      f.setParam("end", timeRange.getEnd());
    }
    if (userId != null) {
      f.append(" and bean.user.id=:userId").setParam("userId", userId);
    }
    return (Long) find(f).iterator().next();
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public List<CmsUser> getAdminList(Integer siteId, Boolean allChannel,
      Boolean disabled, Integer rank) {
    Finder f = Finder.create("select bean from CmsUser");
    f.append(" bean join bean.userSites us");
    f.append(" where us.site.id=:siteId");
    f.setParam("siteId", siteId);
    if (allChannel != null) {
      f.append(" and us.allChannel=:allChannel");
      f.setParam("allChannel", allChannel);
    }
    if (disabled != null) {
      f.append(" and bean.disabled=:disabled");
      f.setParam("disabled", disabled);
    }
    if (rank != null) {
      f.append(" and bean.rank<=:rank");
      f.setParam("rank", rank);
    }
    f.append(" and bean.admin=true");
    f.append(" order by bean.id asc");
    return find(f);
  }
View Full Code Here

TOP

Related Classes of com.jeecms.common.hibernate3.TreeIntercptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.