@Override
  public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(AccountCreditNote.class);

    if (isNotEmpty(filterModel.getSerial())) {
      crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getReference())) {
      crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getCode())) {
      crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
      crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
      crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (filterModel.getAccount() != null) {
      crit.add(Restrictions.le("this.account", filterModel.getAccount()));
    }

    crit.addOrder(Order.desc("serial"));
    crit.addOrder(Order.desc("date"));

    return crit;
  }
  @Override
  @Transactional(readOnly = true)
  public AnnotationView[] listAnnotationsNoReplies(
      final Long articleID,
      final Set<AnnotationType> annotationTypes,
      final AnnotationOrder order) {
    if (order == AnnotationOrder.MOST_RECENT_REPLY) {
      throw new IllegalArgumentException(
          "Cannot specify Most Recent Reply order type when replies are not being loaded up");
    }
    // Basic criteria
    DetachedCriteria criteria =
        DetachedCriteria.forClass(Annotation.class)
            .add(Restrictions.eq("articleID", articleID))
            .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    // restrict by type
    if (annotationTypes != null && !annotationTypes.isEmpty()) {
      criteria.add(Restrictions.in("type", annotationTypes));
    }
    switch (order) {
      case OLDEST_TO_NEWEST:
        criteria.addOrder(Order.asc("created"));
        break;
      case NEWEST_TO_OLDEST:
        criteria.addOrder(Order.desc("created"));
        break;
    }
    List annotationResults = hibernateTemplate.findByCriteria(criteria);
    // Don't want to call buildAnnotationView() here because that would involve finding the article
    // title and doi for each annotation,
    // when we only need to do it once. So load up the info we need to build annotation views here
    Object[] articleTitleAndDoi;
    try {
      articleTitleAndDoi =
          (Object[])
              hibernateTemplate
                  .findByCriteria(
                      DetachedCriteria.forClass(Article.class)
                          .add(Restrictions.eq("ID", articleID))
                          .setProjection(
                              Projections.projectionList()
                                  .add(Projections.property("doi"))
                                  .add(Projections.property("title"))),
                      0,
                      1)
                  .get(0);

    } catch (IndexOutOfBoundsException e) {
      throw new IllegalArgumentException("article " + articleID + " didn't exist");
    }
    String articleDoi = (String) articleTitleAndDoi[0];
    String articleTitle = (String) articleTitleAndDoi[1];

    List<AnnotationView> viewResults = new ArrayList<AnnotationView>(annotationResults.size());
    for (Object annotation : annotationResults) {
      viewResults.add(new AnnotationView((Annotation) annotation, articleDoi, articleTitle, null));
    }
    return viewResults.toArray(new AnnotationView[viewResults.size()]);
  }
 public List<DailySummary> getDailySummarys(String[] para) {
   DetachedCriteria criteria = DetachedCriteria.forClass(DailySummary.class);
   criteria.add(Restrictions.eq("stockSymbol", para[0]));
   criteria.add(Restrictions.between("date", para[1], para[2]));
   if (para[3].equalsIgnoreCase("desc")) criteria.addOrder(Order.desc("date"));
   else criteria.addOrder(Order.asc("date"));
   return (List<DailySummary>) dao.getHibernateTemplate().findByCriteria(criteria);
 }
  /*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {
    this.lawyer = this.getLoginUser();
    // TODO Auto-generated method stub
    BasicService basic = (BasicService) getBean("basicService");
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Articles.class);
    detachedCriteria.add(Restrictions.eq("type", type));

    if (type == 1) { // 重要通知才搞这个。那个什么帮助就都显示了
      // Criterion province = Restrictions.eq("provinceid",
      // this.getLoginUser().getProvinceid());

      int directunion = this.getLoginUser().getDirectunion();
      SysGroup group = (SysGroup) basic.get(SysGroup.class, directunion);

      detachedCriteria.add(Restrictions.eq("status", 0));
      // 显示我的事务所的通知,显示我的律协的通知,显示我的省律协的通知,显示系统的通只
      // detachedCriteria.add(Restrictions.in("thegroup", new Integer[] {
      // this.getLoginUser().getProvinceunion(),
      // this.getLoginUser().getDirectunion(),
      // this.getLoginUser().getTheoffice(), 0 }));

      Criterion province =
          Restrictions.in(
              "thegroup",
              new Integer[] {
                this.getLoginUser().getProvinceunion(),
                this.getLoginUser().getDirectunion(),
                this.getLoginUser().getTheoffice(),
                0
              });

      Criterion c = Restrictions.eq("provinceid", 0);
      detachedCriteria.add(Restrictions.or(c, province));

      detachedCriteria.addOrder(Order.desc("createtime"));
    }

    // 按现实顺序来
    detachedCriteria.addOrder(Order.desc("listorder"));
    detachedCriteria.addOrder(Order.desc("createtime"));

    this.page = basic.findPageByCriteria(detachedCriteria, pageSize, pageNo);

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -1); // 得到前一天
    cal.add(Calendar.MONTH, -1); // 得到前一个月
    long date = cal.getTimeInMillis();
    System.out.println(date);
    // long lastdaya=df.format(new java.util.Date(date));
    // System.out.println(lastdaya);
    lastday = new Timestamp(date);
    System.out.println(lastday);

    // TODO Auto-generated method stub
    return SUCCESS;
  }
示例#5
0
 /**
  * 设置order(排序)查询条件
  *
  * @param ordername :排序字段名
  * @param ordervalue :排序字段值("asc","desc")
  */
 public void setOrder(Map<String, Object> map) {
   for (Map.Entry<String, Object> entry : map.entrySet()) {
     judgecreateAlias(entry.getKey());
     if (SortDirection.asc.equals(entry.getValue())) {
       detachedCriteria.addOrder(Order.asc(entry.getKey()));
     } else {
       detachedCriteria.addOrder(Order.desc(entry.getKey()));
     }
   }
 }
  public String execute() {
    int to = rows * page;
    int from = to - rows;
    DetachedCriteria criteria = DetachedCriteria.forClass(Cliente.class);

    // Si el campo de busqueda es diferente de nulo
    if (searchField != null) {
      if (searchField.equals("idcliente")) {
        if (searchOper.equals("eq")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.eq("idcliente", searchValue));
        } else if (searchOper.equals("lt")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.lt("idcliente", searchValue));

        } else if (searchOper.equals("gt")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.gt("idcliente", searchValue));
        }
      } else if (searchField.equals("nombre")) {
        // contains
        if (searchOper.equals("cn")) {
          criteria.add(Restrictions.like("nombre", "%" + searchString + "%"));
        }
      } else if (searchField.equals("banco.nombre")) {
        criteria.createAlias("banco", "b");
        if (searchOper.equals("eq")) {
          criteria.add(Restrictions.eq("b.nombre", searchString));
        }
      }
    }

    // Count Customers
    records = clienteService.countByCriteria(criteria);

    // Reset count Projection
    criteria.setProjection(null);
    criteria.setResultTransformer(Criteria.ROOT_ENTITY);

    if (sidx != null && !sidx.equals("")) {
      if (sord.equals("asc")) {
        criteria.addOrder(Order.asc(sidx));
      } else {
        criteria.addOrder(Order.desc(sidx));
      }
    }

    gridModel = clienteService.findByCriteria(criteria, from, rows);

    if (to > records) to = records;

    total = (int) Math.ceil((double) records / (double) rows);

    return "success";
  }
示例#7
0
  @Override
  public List<Log> list(ListLogRequest logParam, int pageIndex, int pageSize) {

    DetachedCriteria criteria = DetachedCriteria.forClass(Log.class);

    // TODO 添加大小不敏感
    if (StringUtils.isNotBlank(logParam.getLoginName())) {
      criteria.add(Restrictions.like("loginName", "%" + logParam.getLoginName() + "%"));
    }

    if (logParam.getOperationUsers() != null && logParam.getOperationUsers().length > 0) {
      criteria.add(Restrictions.in("loginName", logParam.getOperationUsers()));
    }
    if (StringUtils.isNotBlank(logParam.getModule())) {
      criteria.add(Restrictions.eq("module", logParam.getModule()));
    }
    if (StringUtils.isNotBlank(logParam.getOperation())) {
      criteria.add(Restrictions.eq("operation", logParam.getOperation()));
    }

    if (logParam.getStartDate() != null) {
      criteria.add(Restrictions.ge("createdOn", logParam.getStartDate()));
    }
    if (logParam.getEndDate() != null) {
      criteria.add(Restrictions.le("createdOn", logParam.getEndDate()));
    }
    criteria.addOrder(Order.desc("createdOn"));

    List result = (List<Log>) findByCriteria(criteria, pageIndex, pageSize);

    return result;
  }
示例#8
0
  public Page<Log> find(Page<Log> page, Map<String, Object> paramMap) {
    DetachedCriteria dc = logDao.createDetachedCriteria();

    Long createById = StringUtils.toLong(paramMap.get("createById"));
    if (createById > 0) {
      dc.add(Restrictions.eq("createBy.id", createById));
    }

    String requestUri = ObjectUtils.toString(paramMap.get("requestUri"));
    if (StringUtils.isNotBlank(requestUri)) {
      dc.add(Restrictions.like("requestUri", "%" + requestUri + "%"));
    }

    String exception = ObjectUtils.toString(paramMap.get("exception"));
    if (StringUtils.isNotBlank(exception)) {
      dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION));
    }

    Date beginDate = DateUtils.parseDate(paramMap.get("beginDate"));
    if (beginDate == null) {
      beginDate = DateUtils.setDays(new Date(), 1);
      paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
    }
    Date endDate = DateUtils.parseDate(paramMap.get("endDate"));
    if (endDate == null) {
      endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1);
      paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd"));
    }
    dc.add(Restrictions.between("createDate", beginDate, endDate));

    dc.addOrder(Order.desc("id"));
    return logDao.find(page, dc);
  }
示例#9
0
  private List<HashMap<String, Object>> getQuestionAnswerData(ExamResult examResult) {
    DetachedCriteria criteria =
        DetachedCriteria.forClass(ExamResultAnswer.class, "examResultAnswer");
    criteria.createAlias("examResultAnswer.question", "question");
    criteria.createAlias("examResultAnswer.answer1", "answer1");
    criteria.createAlias("examResultAnswer.answer2", "answer2");
    criteria.createAlias("examResultAnswer.answer3", "answer3");
    criteria.createAlias("examResultAnswer.answer4", "answer4");

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("question.questionId"), "questionId");
    projectionList.add(Projections.property("question.questionText"), "questionText");
    projectionList.add(Projections.property("answer1.answerId"), "answer1Id");
    projectionList.add(Projections.property("answer1.answerText"), "answer1Text");
    projectionList.add(Projections.property("answer2.answerId"), "answer2Id");
    projectionList.add(Projections.property("answer2.answerText"), "answer2Text");
    projectionList.add(Projections.property("answer3.answerId"), "answer3Id");
    projectionList.add(Projections.property("answer3.answerText"), "answer3Text");
    projectionList.add(Projections.property("answer4.answerId"), "answer4Id");
    projectionList.add(Projections.property("answer4.answerText"), "answer4Text");
    projectionList.add(
        Projections.property("examResultAnswer.examResultAnswerId"), "examResultAnswerId");
    projectionList.add(Projections.property("examResultAnswer.answerId"), "answerId");
    criteria.setProjection(projectionList);
    criteria.add(Restrictions.eq("examResultAnswer.examResultId", examResult.getExamResultId()));
    criteria.addOrder(Order.asc("examResultAnswer.ordinal"));
    criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);

    return basicFinderService.findByCriteria(criteria);
  }
示例#10
0
  /**
   * Search Value2 by detached criteria Test
   *
   * @throws ApplicationException
   */
  @SuppressWarnings("unchecked")
  public void testIvlRealValue3ByDetachedCriteria() throws ApplicationException {
    DetachedCriteria criteria = DetachedCriteria.forClass(IvlRealDataType.class);
    LogicalExpression exp1 =
        Restrictions.or(
            Property.forName("value3.high.value").isNotNull(),
            Property.forName("value3.low.value").isNotNull());
    LogicalExpression exp2 =
        Restrictions.or(
            Property.forName("value3.width.value").isNotNull(),
            Property.forName("value3.width.nullFlavor").isNotNull());
    LogicalExpression exp3 = Restrictions.or(exp1, exp2);
    criteria.add(Restrictions.or(Property.forName("value3.nullFlavor").isNotNull(), exp3));

    criteria.addOrder(Order.asc("id"));

    Collection<IvlRealDataType> result =
        search(criteria, "gov.nih.nci.cacoresdk.domain.other.datatype.IvlRealDataType");
    assertEquals(10, result.size());
    List index = new ArrayList();
    index.add("13");
    index.add("14");
    index.add("15");
    index.add("16");
    index.add("17");
    index.add("18");
    index.add("19");
    index.add("20");
    index.add("21");
    index.add("22");
    assertValue3(result, index);
  }
示例#11
0
  /**
   * bar info query
   *
   * @param global
   * @return
   * @throws JSONException
   */
  public String queryBarInfo(String global) throws JSONException {
    DetachedCriteria dc = DetachedCriteria.forClass(TNavigation.class);
    dc.add(Restrictions.eq("status", 1));
    dc.addOrder(Order.asc("ordinal")).addOrder(Order.desc("updatetime"));

    List<TNavigation> list = super.findByDetachedCriteria(dc);
    List<TBar> rootList = new ArrayList<TBar>();
    for (TNavigation navtion : list) {
      if ("0".equals(navtion.getObjid())) {
        TBar bar = new TBar();
        bar.setName(ActionUtils.getLanStr(navtion.getName(), navtion.getEname(), global));
        bar.setId(navtion.getOid());
        bar.setObjid(navtion.getObjid());

        rootList.add(bar);
      }
    }
    TNavigation record = new TNavigation();
    record.getBarList().add(rootList);
    record = this.convertBar(record, rootList, list, global);

    //		JSONArray itms = (JSONArray) JSONSerializer.toJSON(record.getBarList());
    //		return itms.toString();
    return JSONUtil.serialize(record.getBarList(), null, null, false, false, true);
  }
  @SuppressWarnings("unchecked")
  public List<DeliveryOrder> getUnexportDeliveryOrderByPlant(Plant plant) {
    DetachedCriteria criteria = DetachedCriteria.forClass(DeliveryOrder.class);
    criteria.createAlias("plantSupplier", "ps");

    criteria.add(Restrictions.eq("ps.plant", plant));
    criteria.add(Restrictions.eq("isPrint", true));
    criteria.add(Restrictions.eq("isExport", false));
    criteria.add(Restrictions.eq("status", "Confirm"));
    criteria.add(Restrictions.eq("ps.needExportDo", true));
    criteria.addOrder(Order.asc("createDate"));

    List<DeliveryOrder> deliveryOrderList = this.findByCriteria(criteria);

    if (deliveryOrderList != null && deliveryOrderList.size() > 0) {
      for (int i = 0; i < deliveryOrderList.size(); i++) {
        DeliveryOrder deliveryOrder = deliveryOrderList.get(i);

        if (deliveryOrder.getDeliveryOrderDetailList() != null
            && deliveryOrder.getDeliveryOrderDetailList().size() > 0) {}
      }
    }

    return deliveryOrderList;
  }
示例#13
0
 @Override
 protected DetachedCriteria fillCriteria(
     EntityFilter<? extends State> entityFilter, DetachedCriteria criteria) {
   if (entityFilter != null) {
     List<SortCriteria> sortCriterias = entityFilter.getSortCriterias();
     if (sortCriterias != null && sortCriterias.size() > 0) {
       for (SortCriteria sortCriteria : sortCriterias) {
         if (sortCriteria.getAsc()) {
           criteria.addOrder(Order.asc(sortCriteria.getAttribute()));
         } else {
           criteria.addOrder(Order.desc(sortCriteria.getAttribute()));
         }
       }
     }
   }
   return criteria;
 }
  public List<String> getElementsOrderByWeight(User u) {
    DetachedCriteria det = DetachedCriteria.forClass(RecipientFavourite.class);
    det.add(Restrictions.eq("owner", u));
    det.addOrder(Order.asc("weight"));
    List<RecipientFavourite> listElement = findByCriteria(det);

    return transformRecipientFavouriteToRecipient(listElement);
  }
示例#15
0
 @Transactional(readOnly = false)
 public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) {
   // 更新过期的权重,间隔为“6”个小时
   Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink");
   if (updateExpiredWeightDate == null
       || (updateExpiredWeightDate != null
           && updateExpiredWeightDate.getTime() < new Date().getTime())) {
     linkDao.updateExpiredWeight();
     CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6));
   }
   DetachedCriteria dc = linkDao.createDetachedCriteria();
   dc.createAlias("category", "category");
   dc.createAlias("category.site", "category.site");
   if (link.getCategory() != null
       && StringUtils.isNotBlank(link.getCategory().getId())
       && !Category.isRoot(link.getCategory().getId())) {
     Category category = categoryDao.get(link.getCategory().getId());
     if (category != null) {
       dc.add(
           Restrictions.or(
               Restrictions.eq("category.id", category.getId()),
               Restrictions.like("category.parentIds", "%," + category.getId() + ",%")));
       dc.add(Restrictions.eq("category.site.id", category.getSite().getId()));
       link.setCategory(category);
     } else {
       dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
     }
   } else {
     dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
   }
   if (StringUtils.isNotEmpty(link.getTitle())) {
     dc.add(Restrictions.like("title", "%" + link.getTitle() + "%"));
   }
   if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) {
     dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId()));
   }
   if (isDataScopeFilter) {
     dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy");
     dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy"));
   }
   dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag()));
   dc.addOrder(Order.desc("weight"));
   dc.addOrder(Order.desc("updateDate"));
   return linkDao.find(page, dc);
 }
  public void doDownload() throws Throwable {
    if (StringUtils.isBlank(selectedDateFrom) || StringUtils.isBlank(selectedDateTo)) {
      MessageUtils.getInstance().addErrorMessage("msgDialogDL", "Please select date");
      return;
    }

    if (selectedDateFrom.compareTo(selectedDateTo) < 0) {
      try {
        Date cycleFrom = DateUtil.convStringToDate(SIMPLE_DATE_PATTERN, selectedDateFrom);
        Date cycleTo = DateUtil.convStringToDate(SIMPLE_DATE_PATTERN, selectedDateTo);

        DetachedCriteria criteria = DetachedCriteria.forClass(ConfirmationRecord.class);
        criteria.add(Restrictions.between("cycleFrom", cycleFrom, cycleTo));
        criteria.add(Restrictions.between("cycleTo", cycleFrom, cycleTo));
        criteria.addOrder(Order.asc("cycleFrom"));
        criteria.addOrder(Order.asc("id"));
        List<ConfirmationRecord> list = confirmationRecordService.findByCriteria(criteria);

        Workbook wb = createExcel(list);

        if (wb != null) {
          wb.removeSheetAt(0);
          FileTransfer ft = new FileTransfer();
          String fileName =
              EXCEL_NAME_PATTERN
                  + TEMPLATE_EXCEL_CONF_REPORT_PATH.substring(
                      TEMPLATE_EXCEL_CONF_REPORT_PATH.lastIndexOf("."),
                      TEMPLATE_EXCEL_CONF_REPORT_PATH.length());
          fileName =
              fileName.replaceAll(
                  "#fdd-MMM-yyyy", DateUtil.convDateToString(DISPLAY_DATE_PATTERN, maxCycleFrom));
          fileName =
              fileName.replaceAll(
                  "#tdd-MMM-yyyy", DateUtil.convDateToString(DISPLAY_DATE_PATTERN, maxCycleTo));
          ft.fileDownload(fileName, wb);
        }

        init();
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      MessageUtils.getInstance().addErrorMessage("msgDialogDL", "Invalid date");
    }
  }
  public List<String> reorderElementsByWeightDesc(List<String> elements, User owner) {
    DetachedCriteria det = DetachedCriteria.forClass(RecipientFavourite.class);
    det.add(Restrictions.eq("owner", owner));
    det.add(Restrictions.in("recipient", elements));
    det.addOrder(Order.desc("weight"));
    List<RecipientFavourite> recipients = findByCriteria(det);

    return reorderElement(elements, recipients);
  }
示例#18
0
 /**
  * Test all records and columns
  *
  * @throws ApplicationException
  */
 @SuppressWarnings("unchecked")
 public void testTelPhoneValue() throws ApplicationException, URISyntaxException {
   DetachedCriteria criteria = DetachedCriteria.forClass(TelPhoneDataType.class);
   criteria.addOrder(Order.asc("id"));
   Collection<TelPhoneDataType> result =
       search(criteria, "gov.nih.nci.cacoresdk.domain.other.datatype.TelPhoneDataType");
   assertValue1(result, null);
   assertValue2(result, null);
 }
示例#19
0
 public List<Label> getByExmaple(Label example) {
   DetachedCriteria criteria = newCriteria();
   if (example.getParentId() != null)
     criteria.add(Expression.eq("parentId", example.getParentId()));
   if (example.getName() != null)
     criteria.add(Expression.ilike("name", example.getName(), MatchMode.START));
   criteria.addOrder(Order.asc("name"));
   return findByCriteria(criteria);
 }
 public MyQuery getAllOutStateSreach() {
   DetachedCriteria dc = DetachedCriteria.forClass(CheckworkAbsence.class);
   String date = TimeUtil.getTheTimeStr(TimeUtil.getNowTime());
   dc.add(Restrictions.gt("endTime", TimeUtil.getTimeByStr(date, "yyyy-MM-dd HH:mm:ss")));
   dc.add(Restrictions.lt("beginTime", TimeUtil.getTimeByStr(date, "yyyy-MM-dd HH:mm:ss")));
   dc.addOrder(Order.desc("signDate"));
   MyQuery myQuery = new MyQueryImpl();
   myQuery.setDetachedCriteria(dc);
   return myQuery;
 }
  public List<ClienteTO> getClientesByZona(int idZona) {

    DetachedCriteria criteria = DetachedCriteria.forClass(ClienteTO.class);

    criteria.add(Restrictions.eq("idZona.idZona", idZona));

    criteria.addOrder(Order.asc("nombre"));

    return this.getListByCriteria(criteria);
  }
  public List<ChainRoleType> getChainUserTypes() {
    List<Integer> roleTypeIds = new ArrayList<Integer>();
    roleTypeIds.add(ChainRoleType.CHAIN_STAFF);
    roleTypeIds.add(ChainRoleType.CHAIN_LEAD);
    roleTypeIds.add(ChainRoleType.CHAIN_OWNER);

    DetachedCriteria criteria = DetachedCriteria.forClass(ChainRoleType.class);
    criteria.addOrder(Order.asc("chainRoleTypeId"));
    criteria.add(Restrictions.in("chainRoleTypeId", roleTypeIds));
    return this.getByCritera(criteria, true);
  }
 @SuppressWarnings("unchecked")
 @Override
 public List<OrganizacionAsociacion> findByOrganizacion(Organizacion organizacion)
     throws DaoException {
   if (logger.isTraceEnabled())
     logger.trace("Hibernate Searching OrganizacionAsociacion with organizacion:" + organizacion);
   DetachedCriteria criteria = DetachedCriteria.forClass(OrganizacionAsociacion.class);
   criteria.add(Restrictions.eq("organizacion", organizacion));
   criteria.addOrder(Order.asc("name"));
   return (List<OrganizacionAsociacion>) getHibernateTemplate().findByCriteria(criteria);
 }
  @RequestMapping(value = Constants.MV_URI_COMM_LIST + "/{parentId}/{from}/{pageSize}/{startIndex}")
  public ModelAndView list(
      @PathVariable Integer parentId,
      @PathVariable String from,
      @PathVariable Integer pageSize,
      @PathVariable Integer startIndex,
      @ModelAttribute AdminDept bean,
      HttpServletRequest request) {
    DetachedCriteria dc = DetachedCriteria.forClass(AdminDept.class);
    AdminDept temp = new AdminDept();
    if (from.equals(Constants.PAGE_ENTRY_TYPE_FORM)) {
      temp = bean;
      request.getSession().setAttribute(ENTITY_SESSION_BEAN, bean);
    }
    if (from.equals(Constants.PAGE_ENTRY_TYPE_PAGE)) {
      if (request.getSession().getAttribute(ENTITY_SESSION_BEAN) != null) {
        temp = (AdminDept) request.getSession().getAttribute(ENTITY_SESSION_BEAN);
      }
    }
    if (from.equals(Constants.PAGE_ENTRY_TYPE_MENU)) {}

    if (parentId != 0) {
      dc.add(Restrictions.eq("parentId", parentId));
    }
    dc.addOrder(Order.desc("addTime"));
    ModelAndView mv = new ModelAndView();
    if (pageSize == 0) {
      pageSize = Constants.DEFAULT_PAGESIZE;
    }
    Page page = adminDeptService.findPageByCriteria(dc, pageSize, startIndex);
    if (pageSize != 0) {
      page.setPageSize(pageSize);
    }
    request.getSession().setAttribute(Constants.ONLINE_DEPT_ID, parentId == 0 ? 0 : parentId);
    mv.addObject("parentId", parentId);
    String pageURI =
        request.getSession().getServletContext().getAttribute(Constants.APPLICATION_APPROOT)
            + ROOT_URI
            + Constants.MV_URI_COMM_LIST
            + Constants.SYM_PATH_SEPARATOR
            + parentId;
    initList(
        mv,
        page,
        Constants.MV_VIEW_LIST,
        pageURI,
        ROOT_URI,
        temp,
        ROOT_VIEW,
        -1,
        pageSize,
        startIndex);
    return mv;
  }
示例#25
0
 public Page<Guestbook> find(Page<Guestbook> page, Guestbook guestbook) {
   DetachedCriteria dc = guestbookDao.createDetachedCriteria();
   if (StringUtils.isNotEmpty(guestbook.getType())) {
     dc.add(Restrictions.eq("type", guestbook.getType()));
   }
   if (StringUtils.isNotEmpty(guestbook.getContent())) {
     dc.add(Restrictions.like("content", "%" + guestbook.getContent() + "%"));
   }
   dc.add(Restrictions.eq(Guestbook.FIELD_DEL_FLAG, guestbook.getDelFlag()));
   dc.addOrder(Order.desc("id"));
   return guestbookDao.find(page, dc);
 }
  /* (non-Javadoc)
   * @see com.mg.framework.api.orm.DetachedCriteria#addOrder(com.mg.framework.api.orm.Order)
   */
  @Override
  public DetachedCriteria addOrder(Order order) {
    org.hibernate.criterion.Order orderHibernate;
    if (order.isAscending())
      orderHibernate = org.hibernate.criterion.Order.asc(order.getPropertyName());
    else orderHibernate = org.hibernate.criterion.Order.desc(order.getPropertyName());

    if (order.isIgnoreCase()) orderHibernate.ignoreCase();

    delegate.addOrder(orderHibernate);
    return this;
  }
  public String getElementWithMaxWeight(User u) throws LinShareNotSuchElementException {

    DetachedCriteria det = DetachedCriteria.forClass(RecipientFavourite.class);
    det.add(Restrictions.eq("owner", u));
    det.addOrder(Order.desc("weight"));
    List<RecipientFavourite> listElement = findByCriteria(det);

    if (listElement == null || listElement.isEmpty()) {
      throw new LinShareNotSuchElementException("the owner has no recipient associated ");
    }

    return listElement.get(0).getRecipient();
  }
示例#28
0
 /** 功能:读取分页数据 */
 public PageResult readAllPages(int pageSize, int currentPage, SearchFilter filter) {
   try {
     DetachedCriteria detachedCriteria = DetachedCriteria.forClass(PhotosCover.class);
     detachedCriteria.add(Restrictions.eq("status", EntityStatus.NORMAL));
     detachedCriteria.addOrder(Order.desc("defaults"));
     detachedCriteria.addOrder(Order.desc("createDT"));
     DetachedCriteriaUtil.addSearchFilter(detachedCriteria, filter);
     return baseDAO.findByPages(detachedCriteria, pageSize, currentPage);
   } catch (Exception ex) {
     ex.printStackTrace();
     throw new BaseException("查询所有分页异常");
   }
 }
 @Override
 public Page getFixedShippingOrder(Warehouse warehouse, String status, int pageNo, int perPage) {
   DetachedCriteria criteria = DetachedCriteria.forClass(FixedShippingOrder.class);
   if (warehouse != null) {
     DetachedCriteria whCriteria = criteria.createCriteria("shippingOrder");
     whCriteria.add(Restrictions.eq("warehouse", warehouse));
   }
   if (StringUtils.isNotBlank(status)) {
     criteria.add(Restrictions.eq("status", status));
   }
   criteria.addOrder(org.hibernate.criterion.Order.desc("createDate"));
   return list(criteria, pageNo, perPage);
 }
  public List<String> findMatchElementsOrderByWeight(String matchStartWith, User owner) {
    DetachedCriteria det = DetachedCriteria.forClass(RecipientFavourite.class);
    det.add(Restrictions.eq("owner", owner));
    det.add(Restrictions.ilike("recipient", matchStartWith, MatchMode.ANYWHERE));
    det.addOrder(Order.desc("weight"));
    List<RecipientFavourite> recipients = findByCriteria(det);

    ArrayList<String> mails = new ArrayList<String>();

    for (RecipientFavourite recipientFavour : recipients) {
      mails.add(recipientFavour.getRecipient());
    }
    return mails;
  }