Examples of Junction


Examples of org.hibernate.criterion.Junction

       
        try {
            Session session = ((HibernatePersistenceStrategy)strategy).getSession();
            Criteria criteria = session.createCriteria(RefererData.class);
           
            Junction conjunction = Expression.conjunction();
            conjunction.add(Expression.eq("website", website));
            conjunction.add(Expression.eq("requestUrl", requestUrl));
           
            Junction disjunction = Expression.conjunction();
            disjunction.add(Expression.eq("title", title));
            disjunction.add(Expression.eq("excerpt", excerpt));
           
            criteria.add(conjunction);
            criteria.add(disjunction);
           
            return criteria.list();
View Full Code Here

Examples of org.hibernate.criterion.Junction

       
    public List getNextPrevEntries(WeblogEntryData current, String catName,
                                   String locale, int maxEntries, boolean next)
            throws RollerException {
       
        Junction conjunction = Expression.conjunction();
        conjunction.add(Expression.eq("website", current.getWebsite()));
        conjunction.add(Expression.eq("status", WeblogEntryData.PUBLISHED));
       
        if (next) {
            conjunction.add(Expression.gt("pubTime", current.getPubTime()));
        } else {
            conjunction.add(Expression.lt("pubTime", current.getPubTime()));
        }
       
        if (catName != null && !catName.trim().equals("/")) {
            WeblogCategoryData category =
                    getWeblogCategoryByPath(current.getWebsite(), null, catName);
            if (category != null) {
                conjunction.add(Expression.eq("category", category));
            } else {
                throw new RollerException("Cannot find category: "+catName);
            }
        }
       
        if(locale != null) {
            conjunction.add(Expression.ilike("locale", locale, MatchMode.START));
        }
       
        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(WeblogEntryData.class);
View Full Code Here

Examples of org.hibernate.criterion.Junction

       
        if(website == null) {
            throw new RollerException("Website cannot be NULL.");
        }
                       
        Junction conjunction = Expression.conjunction();
        conjunction.add(Expression.eq("name", name));
        conjunction.add(Expression.eq("weblog", website));

        // The reason why add order lastUsed desc is to make sure we keep picking the most recent
        // one in the case where we have multiple rows (clustered environment)
        // eventually that second entry will have a very low total (most likely 1) and
        // won't matter
       
        Criteria criteria = session.createCriteria(WeblogEntryTagAggregateData.class)
            .add(conjunction).addOrder(Order.desc("lastUsed")).setMaxResults(1);
       
        WeblogEntryTagAggregateData weblogTagData = (WeblogEntryTagAggregateData) criteria.uniqueResult();

        conjunction = Expression.conjunction();
        conjunction.add(Restrictions.eq("name", name));
        conjunction.add(Restrictions.isNull("weblog"));
       
        criteria = session.createCriteria(WeblogEntryTagAggregateData.class)
            .add(conjunction).addOrder(Order.desc("lastUsed")).setMaxResults(1);
   
        WeblogEntryTagAggregateData siteTagData = (WeblogEntryTagAggregateData) criteria.uniqueResult();
View Full Code Here

Examples of org.hibernate.criterion.Junction

   */
  protected static Junction dataScopeFilter(User user, String officeAlias, String userAlias) {

    // 进行权限过滤,多个角色权限范围之间为或者关系。
    List<String> dataScope = Lists.newArrayList();
    Junction junction = Restrictions.disjunction();
   
    // 超级管理员,跳过权限过滤
    if (!user.isAdmin()){
      for (Role r : user.getRoleList()){
        if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(officeAlias)){
          boolean isDataScopeAll = false;
          if (Role.DATA_SCOPE_ALL.equals(r.getDataScope())){
            isDataScopeAll = true;
          }
          else if (Role.DATA_SCOPE_COMPANY_AND_CHILD.equals(r.getDataScope())){
            junction.add(Restrictions.eq(officeAlias+".id", user.getCompany().getId()));
            junction.add(Restrictions.like(officeAlias+".parentIds", user.getCompany().getParentIds()+user.getCompany().getId()+",%"));
          }
          else if (Role.DATA_SCOPE_COMPANY.equals(r.getDataScope())){
            junction.add(Restrictions.eq(officeAlias+".id", user.getCompany().getId()));
            junction.add(Restrictions.and(Restrictions.eq(officeAlias+".parent.id", user.getCompany().getId()),
                Restrictions.eq(officeAlias+".type", "2"))); // 包括本公司下的部门
          }
          else if (Role.DATA_SCOPE_OFFICE_AND_CHILD.equals(r.getDataScope())){
            junction.add(Restrictions.eq(officeAlias+".id", user.getOffice().getId()));
            junction.add(Restrictions.like(officeAlias+".parentIds", user.getOffice().getParentIds()+user.getOffice().getId()+",%"));
          }
          else if (Role.DATA_SCOPE_OFFICE.equals(r.getDataScope())){
            junction.add(Restrictions.eq(officeAlias+".id", user.getOffice().getId()));
          }
          else if (Role.DATA_SCOPE_CUSTOM.equals(r.getDataScope())){
            junction.add(Restrictions.in(officeAlias+".id", r.getOfficeIdList()));
          }
          //else if (Role.DATA_SCOPE_SELF.equals(r.getDataScope())){
          if (!isDataScopeAll){
            if (StringUtils.isNotBlank(userAlias)){
              junction.add(Restrictions.eq(userAlias+".id", user.getId()));
            }else {
              junction.add(Restrictions.isNull(officeAlias+".id"));
            }
          }else{
            // 如果包含全部权限,则去掉之前添加的所有条件,并跳出循环。
            junction = Restrictions.disjunction();
            break;
View Full Code Here

Examples of org.hibernate.criterion.Junction

   * @param officeAlias 机构表别名,例如:dc.createAlias("office", "office");
   * @param userAlias 用户表别名,传递空,忽略此参数
   * @return ql查询字符串
   */
  protected static String dataScopeFilterString(User user, String officeAlias, String userAlias) {
    Junction junction = dataScopeFilter(user, officeAlias, userAlias);
    Iterator<Criterion> it = junction.conditions().iterator();
    StringBuilder ql = new StringBuilder();
    ql.append(" and (");
    if (it.hasNext()){
      ql.append(it.next());
    }
View Full Code Here

Examples of org.hibernate.criterion.Junction

   
    public List getNextPrevEntries(WeblogEntryData current, String catName,
                                   String locale, int maxEntries, boolean next)
            throws RollerException {
       
        Junction conjunction = Expression.conjunction();
        conjunction.add(Expression.eq("website", current.getWebsite()));
        conjunction.add(Expression.eq("status", WeblogEntryData.PUBLISHED));
       
        if (next) {
            conjunction.add(Expression.gt("pubTime", current.getPubTime()));
        } else {
            conjunction.add(Expression.lt("pubTime", current.getPubTime()));
        }
       
        if (catName != null && !catName.trim().equals("/")) {
            WeblogCategoryData category =
                    getWeblogCategoryByPath(current.getWebsite(), null, catName);
            if (category != null) {
                conjunction.add(Expression.eq("category", category));
            } else {
                throw new RollerException("Cannot find category: "+catName);
            }
        }
       
        if(locale != null) {
            conjunction.add(Expression.ilike("locale", locale, MatchMode.START));
        }
       
        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(WeblogEntryData.class);
View Full Code Here

Examples of org.hibernate.criterion.Junction

           
            String spamwords = RollerRuntimeConfig.getProperty("spam.blacklist");
           
            String[] blacklist = StringUtils.split(
                    StringUtils.deleteWhitespace(spamwords),",");
            Junction or = Expression.disjunction();
            for (int i=0; i<blacklist.length; i++) {
                String ignoreWord = blacklist[i].trim();
                //log.debug("including ignore word - "+ignoreWord);
                or.add(Expression.ilike("refererUrl","%"+ignoreWord+"%"));
            }
            criteria.add(Expression.conjunction()
            .add(Expression.disjunction().add(Expression.isNull("excerpt")).add(Expression.eq("excerpt", "")))
            .add(or)
            );
View Full Code Here

Examples of org.hibernate.criterion.Junction

           
            String[] blacklist = StringUtils.split(
                    StringUtils.deleteWhitespace(website.getBlacklist()),",");
            if (blacklist.length == 0) return;
           
            Junction or = Expression.disjunction();
            for (int i=0; i<blacklist.length; i++) {
                String ignoreWord = blacklist[i].trim();
                or.add(Expression.ilike("refererUrl","%"+ignoreWord+"%"));
            }
            criteria.add(Expression.conjunction()
            .add(Expression.disjunction().add(Expression.isNull("excerpt")).add(Expression.eq("excerpt", "")))
            .add(Expression.eq("website",website))
            .add(or)
View Full Code Here

Examples of org.hibernate.criterion.Junction

       
        try {
            Session session = ((HibernatePersistenceStrategy)strategy).getSession();
            Criteria criteria = session.createCriteria(RefererData.class);
           
            Junction conjunction = Expression.conjunction();
            conjunction.add(Expression.eq("website", website));
            conjunction.add(Expression.eq("requestUrl", requestUrl));
           
            Junction disjunction = Expression.conjunction();
            disjunction.add(Expression.eq("title", title));
            disjunction.add(Expression.eq("excerpt", excerpt));
           
            criteria.add(conjunction);
            criteria.add(disjunction);
           
            return criteria.list();
View Full Code Here

Examples of uk.gov.nationalarchives.droid.core.interfaces.filter.expressions.Junction

        if (filter.isNarrowed()) {
            for (FilterCriterion criterion : filter.getCriteria()) {
                queryBuilder.add(RestrictionFactory.forFilterCriterion(criterion));
            }
        } else {
            Junction disjunction = Restrictions.disjunction();
            for (FilterCriterion criterion : filter.getCriteria()) {
                disjunction.add(RestrictionFactory.forFilterCriterion(criterion));
            }
            queryBuilder.add(disjunction);
        }
        return queryBuilder;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.