コード例 #1
1
 @RequestMapping(value = "/search")
 public ModelAndView search(
     HttpServletRequest request,
     @PathVariable String orgi,
     @ModelAttribute("data") SinoLocation data) {
   String key = "%" + data.getProvince() + "%";
   ResponseData responseData = new ResponseData("/pages/manage/sinosig/location/list");
   String pro = request.getParameter("result");
   if (pro == null || "".equals(pro) || "0".equals(pro)) {
     responseData.setDataList(
         super.getService()
             .findPageByCriteria(
                 DetachedCriteria.forClass(SinoLocation.class)
                     .add(
                         Restrictions.and(
                             Restrictions.eq("orgi", orgi),
                             Restrictions.eq("type", data.getType())))
                     .add(
                         Restrictions.or(
                             Restrictions.or(
                                 Restrictions.like("province", key),
                                 Restrictions.like("city", key)),
                             Restrictions.or(
                                 Restrictions.like("address", key),
                                 Restrictions.like("dept", key))))));
   } else {
     responseData.setDataList(
         super.getService()
             .findPageByCriteria(
                 DetachedCriteria.forClass(SinoLocation.class)
                     .add(
                         Restrictions.and(
                             Restrictions.and(
                                 Restrictions.eq("orgi", orgi), Restrictions.eq("province", pro)),
                             Restrictions.eq("type", data.getType())))
                     .add(
                         Restrictions.or(
                             Restrictions.or(
                                 Restrictions.like("province", key),
                                 Restrictions.like("city", key)),
                             Restrictions.or(
                                 Restrictions.like("address", key),
                                 Restrictions.like("dept", key))))));
   }
   return request(responseData, orgi, null);
 }
コード例 #2
0
  @Override
  public Long verificarConflitoHorario(Horario model) {
    Criteria criteria = getSession().createCriteria(Horario.class);

    // Removendo da pesquisa o proprio registro quando for edição
    if (model.getId() != null && !model.getId().equals(0)) {
      List<Integer> listaIds = new ArrayList<Integer>();
      listaIds.add(model.getId());
      criteria.add(Restrictions.not(Restrictions.in("id", listaIds)));
    }

    criteria.add(Restrictions.eq("curso.id", model.getCurso().getId()));
    criteria.add(
        Restrictions.or(
            Restrictions.or(
                Restrictions.between(
                    "datHoraInicio", model.getDatHoraInicio(), model.getDatHoraFim()),
                Restrictions.between(
                    "datHoraFim", model.getDatHoraInicio(), model.getDatHoraFim())),
            Restrictions.and(
                Restrictions.and(
                    Restrictions.le("datHoraInicio", model.getDatHoraInicio()),
                    Restrictions.ge("datHoraFim", model.getDatHoraInicio())),
                Restrictions.and(
                    Restrictions.le("datHoraInicio", model.getDatHoraFim()),
                    Restrictions.ge("datHoraFim", model.getDatHoraFim())))));
    criteria.setProjection(Projections.rowCount());

    Long result = (Long) criteria.list().get(0);
    return result;
  }
コード例 #3
0
 @RequestMapping(value = "/rm/{id}")
 public ModelAndView rm(
     HttpServletRequest request,
     @PathVariable String orgi,
     @PathVariable String id,
     @ModelAttribute("data") SinoLocation data) {
   data.setId(id);
   data.setStatus("3"); // 删除
   super.getService().deleteIObject(data);
   // 发消息给GW,在GW更新百度信息
   APIContext.getRpcServer()
       .sendMessageToServer(
           new Message(
               EapDataContext.HANDLER,
               JSON.toJSONString(
                   new SystemMessage(SINOSIG_LOCATION, data), SerializerFeature.WriteClassName)));
   ResponseData responseData = new ResponseData("/pages/manage/sinosig/location/list");
   responseData.setDataList(
       super.getService()
           .findPageByCriteria(
               DetachedCriteria.forClass(SinoLocation.class)
                   .add(
                       Restrictions.and(
                           Restrictions.eq("orgi", orgi),
                           Restrictions.and(
                               Restrictions.eq("type", data.getType()),
                               Restrictions.eq("province", data.getProvince()))))));
   return request(responseData, orgi, null);
 }
  @Override
  public Criterion toCriterion(SearchQueryPart searchQueryPart) {

    if (!canHandleSearchQueryPart(searchQueryPart)) {
      LOGGER.error("Can't handle QueryPart : " + searchQueryPart);
      return null;
    }

    SearchableField searchableField = searchQueryPart.getSearchableField();
    List<String> valueList = searchQueryPart.getValueList();
    Object parsedValueMin =
        searchQueryPart.getParsedValue(valueList.get(0), searchableField.getRelatedFields().get(0));

    switch (searchQueryPart.getOp()) {
      case EQ:
        return Restrictions.and(
            Restrictions.le(searchableField.getRelatedFields().get(0), parsedValueMin),
            Restrictions.ge(searchableField.getRelatedFields().get(1), parsedValueMin));
      case BETWEEN:
        Object parsedValueMax =
            searchQueryPart.getParsedValue(
                valueList.get(1), searchableField.getRelatedFields().get(1));
        return Restrictions.or(
            Restrictions.and(
                Restrictions.ge(searchableField.getRelatedFields().get(0), parsedValueMin),
                Restrictions.le(searchableField.getRelatedFields().get(0), parsedValueMax)),
            Restrictions.and(
                Restrictions.ge(searchableField.getRelatedFields().get(1), parsedValueMin),
                Restrictions.le(searchableField.getRelatedFields().get(1), parsedValueMax)));
      default:
        LOGGER.fatal("Impossible to interpret " + searchQueryPart);
        return null;
    }
  }
コード例 #5
0
  private Criterion parseConjuction(Conjunction conjunction) {

    Criterion leftRestricitions = parseRestriction(conjunction.getLeft());
    Restrictions[] restrictions = conjunction.getRight();
    Criterion[] criterias = new Criterion[restrictions.length];
    for (int i = 0; i < criterias.length; i++) {
      criterias[i] = parseRestriction(restrictions[i]);
    }

    Criterion crit;
    switch (conjunction.getType()) {
      case AND:
        crit = leftRestricitions;
        for (int i = 0; i < criterias.length; i++) {
          crit = org.hibernate.criterion.Restrictions.and(crit, criterias[i]);
        }
        return crit;
      case OR:
        crit = leftRestricitions;
        for (int i = 0; i < criterias.length; i++) {
          crit = org.hibernate.criterion.Restrictions.or(crit, criterias[i]);
        }
        return crit;
      case NOT:
        return org.hibernate.criterion.Restrictions.not(leftRestricitions);
      default:
        ConjunctionTypes type = conjunction.getType();
        if (LOG.isErrorEnabled()) {
          LOG.error("Query conjuction " + type.name() + " cannot be recognized!");
        }
        throw new IllegalStateException("Unknown conjunction type: " + type.name());
    }
  }
コード例 #6
0
 public BudgetItem getBudgetItem(Date date, Account account) {
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(BudgetItem.class);
   criteria.add(Restrictions.eq("account", account));
   criteria.add(
       Restrictions.and(Restrictions.le("startDate", date), Restrictions.ge("endDate", date)));
   return (BudgetItem) criteria.uniqueResult();
 }
コード例 #7
0
 // TODO add fromData-toDate
 public IncomeBalance findAccountPeriod(Account account, Date date) {
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(IncomeBalance.class);
   criteria.add(Restrictions.eq("account", account));
   criteria.add(
       Restrictions.and(Restrictions.ge("startDate", date), Restrictions.le("endDate", date)));
   return (IncomeBalance) criteria.uniqueResult();
 }
コード例 #8
0
  @Override
  public List<ThesaurusConcept> getPaginatedAvailableConceptsOfGroup(
      Integer startIndex,
      Integer limit,
      String groupId,
      String thesaurusId,
      Boolean onlyValidatedConcepts,
      String like) {

    DetachedCriteria dc = DetachedCriteria.forClass(ThesaurusConceptGroup.class, "gr");
    dc.createCriteria("concepts", "tc", JoinType.RIGHT_OUTER_JOIN);
    dc.setProjection(Projections.projectionList().add(Projections.property("tc.identifier")));
    dc.add(Restrictions.eq("gr.identifier", groupId));

    Criteria criteria = selectPaginatedConceptsByAlphabeticalOrder(startIndex, limit);
    criteria.add(Subqueries.propertyNotIn("tc.identifier", dc));

    selectThesaurus(criteria, thesaurusId);
    criteria.add(
        Restrictions.not(
            Restrictions.and(
                Restrictions.eq("topConcept", false),
                Restrictions.or(
                    Restrictions.isNull("tc.parentConcepts"),
                    Restrictions.isEmpty("tc.parentConcepts")))));

    if (null != like) {
      conceptNameIsLike(criteria, like);
    }
    onlyValidatedConcepts(criteria, onlyValidatedConcepts);

    return criteria.list();
  }
コード例 #9
0
  @Override
  public Long countConceptsAlignedToExtThes(String idThesaurus) {
    DetachedCriteria alignmentCriteria =
        DetachedCriteria.forClass(Alignment.class, "al")
            .add(Restrictions.isNotNull("al.externalTargetThesaurus"))
            .setProjection(
                Projections.projectionList()
                    .add(Projections.property(AL_SOURCE_CONCEPT_IDENTIFIER)));

    DetachedCriteria conceptCriteria =
        DetachedCriteria.forClass(ThesaurusConcept.class, "stc")
            .add(Restrictions.eq("stc.thesaurus.identifier", idThesaurus))
            .setProjection(
                Projections.projectionList().add(Projections.property("stc.identifier")));

    Criteria criteria =
        getCurrentSession()
            .createCriteria(ThesaurusConcept.class, "tc")
            .add(
                Restrictions.and(
                    Subqueries.propertyIn(TC_IDENTIFIER, alignmentCriteria),
                    Subqueries.propertyIn(TC_IDENTIFIER, conceptCriteria)))
            .setProjection(Projections.rowCount());
    return (Long) criteria.list().get(0);
  }
コード例 #10
0
ファイル: SampleDAO.java プロジェクト: singhindresh/ometa
 public Sample getSample(Long projectId, String sampleName, Session session) throws DAOException {
   Sample retVal = null;
   try {
     Criteria crit = session.createCriteria(Sample.class);
     crit.add(
         Restrictions.and(
             Restrictions.eq("sampleName", sampleName), Restrictions.eq("projectId", projectId)));
     List results = crit.list();
     if (results != null) {
       if (results.size() == 1) {
         retVal = (Sample) results.get(0);
       } else if (results.size() > 1) {
         throw new DAOException(
             "Found "
                 + results.size()
                 + " samples for sample name "
                 + sampleName
                 + " but expected only 1.");
       }
     }
   } catch (Exception ex) {
     throw new DAOException(ex);
   }
   return retVal;
 }
コード例 #11
0
 /*
  *  check budgetitem start date and end date overlap
  *
  */
 public boolean isBudgetItemOverlap(Account account, Date startDate, Date endDate) {
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(BudgetItem.class);
   criteria.add(Restrictions.eq("account", account));
   criteria.add(
       Restrictions.and(
           Restrictions.lt("startDate", endDate), Restrictions.gt("endDate", startDate)));
   return criteria.list().isEmpty() ? false : true;
 }
コード例 #12
0
 /**
  * Check if given date range is overlap with existing fiscal years (StartA <= EndB) and (EndA >=
  * StartB)
  *
  * @param from
  * @param to
  * @return
  */
 @SuppressWarnings("unchecked")
 public List<FiscalYear> getOverlapFiscalYears(Integer fiscalYearId, Date from, Date to) {
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(FiscalYear.class);
   criteria.add(
       Restrictions.and(Restrictions.lt("startDate", to), Restrictions.gt("endDate", from)));
   criteria.add(Restrictions.ne("status", GeneralStatus.DELETED));
   return criteria.list();
 }
コード例 #13
0
 @Override
 public int countFinishedUsers(Context context, XmlWorkflowItem workflowItem) throws SQLException {
   Criteria criteria = createCriteria(context, InProgressUser.class);
   criteria.add(
       Restrictions.and(
           Restrictions.eq("workflowItem", workflowItem), Restrictions.eq("finished", true)));
   return count(criteria);
 }
コード例 #14
0
 public SelfAssessmentResult findByAssessmentQuestion(
     SelfAssessment selfAssessment, Question question) {
   // TODO Auto-generated method stub
   return findUniqueByCriteria(
       Restrictions.and(
           Restrictions.eq("selfAssessment", selfAssessment),
           Restrictions.eq("question", question)));
 }
コード例 #15
0
 @Override
 public Position findByNameAndUser(String name, User user) {
   return (Position)
       getSession()
           .createCriteria(getEntityClass())
           .add(Restrictions.and(Restrictions.eq("user", user), Restrictions.eq("name", name)))
           .uniqueResult();
 }
コード例 #16
0
  protected void addSearchByUserRolesCriterion(
      Criteria criteria, Boolean searchByUserRoles, ServiceContext serviceContext)
      throws SystemException {

    if (searchByUserRoles == null) {
      return;
    }

    Criteria assigneesCriteria = criteria.createCriteria("assignees");

    if (!searchByUserRoles) {
      assigneesCriteria.add(Restrictions.eq("assigneeClassName", User.class.getName()));
      assigneesCriteria.add(Restrictions.eq("assigneeClassPK", serviceContext.getUserId()));

      return;
    }

    List<Long> roleIds = RoleRetrievalUtil.getRoleIds(serviceContext);

    List<UserGroupRole> userGroupRoles =
        UserGroupRoleLocalServiceUtil.getUserGroupRoles(serviceContext.getUserId());

    if (userGroupRoles.isEmpty()) {
      assigneesCriteria.add(Restrictions.eq("assigneeClassName", Role.class.getName()));
      assigneesCriteria.add(
          Restrictions.in("assigneeClassPK", roleIds.toArray(new Long[roleIds.size()])));
    } else {
      Junction junction = Restrictions.disjunction();

      junction.add(
          Restrictions.and(
              Restrictions.eq("assigneeClassName", Role.class.getName()),
              Restrictions.in("assigneeClassPK", roleIds.toArray(new Long[roleIds.size()]))));

      for (UserGroupRole userGroupRole : userGroupRoles) {
        junction.add(
            Restrictions.and(
                Restrictions.eq("groupId", userGroupRole.getGroupId()),
                Restrictions.and(
                    Restrictions.eq("assigneeClassName", Role.class.getName()),
                    Restrictions.eq("assigneeClassPK", userGroupRole.getRoleId()))));
      }

      assigneesCriteria.add(junction);
    }
  }
コード例 #17
0
ファイル: Restrict.java プロジェクト: joeantony4u/Sm
  @SuppressWarnings("rawtypes")
  public List<Criterion> restrict(Object[]... values) {

    List<Criterion> criterions = new ArrayList<Criterion>();
    switch (valueOf(type)) {
      case IN:
        for (Object[] value : values)
          criterions.add(Restrictions.in((String) value[0], (Collection) value[1]));

        break;
      case NOTIN:
        for (Object[] value : values)
          criterions.add(
              Restrictions.not(Restrictions.in((String) value[0], (Collection) value[1])));
        break;
      case EQ:
        for (Object[] value : values) criterions.add(Restrictions.eq((String) value[0], value[1]));
        break;
      case NOTEQ:
        for (Object[] value : values) criterions.add(Restrictions.ne((String) value[0], value[1]));
        break;
      case GE:
        for (Object[] value : values) criterions.add(Restrictions.ge((String) value[0], value[1]));
        break;
      case LE:
        for (Object[] value : values) criterions.add(Restrictions.le((String) value[0], value[1]));
        break;
      case BETWEEN:
        for (Object[] value : values)
          criterions.add(Restrictions.between((String) value[0], value[1], value[2]));
        break;
      case GT:
        for (Object[] value : values) criterions.add(Restrictions.gt((String) value[0], value[1]));
        break;
      case LT:
        for (Object[] value : values) criterions.add(Restrictions.lt((String) value[0], value[1]));
        break;
      case AND:
        for (Object[] value : values)
          criterions.add(Restrictions.and((Criterion) value[0], (Criterion) value[1]));
        break;
      case OR:
        for (Object[] value : values)
          criterions.add(Restrictions.or((Criterion) value[0], (Criterion) value[1]));
        break;
      case NULL:
        for (Object[] value : values) criterions.add(Restrictions.isNull((String) value[0]));
        break;
      case NOTNULL:
        for (Object[] value : values) criterions.add(Restrictions.isNotNull((String) value[0]));
        break;
      case LIKE:
        for (Object[] value : values)
          criterions.add(Restrictions.like((String) value[0], value[1]));
        break;
    }
    return criterions;
  }
コード例 #18
0
 @Override
 public InProgressUser findByWorkflowItemAndEPerson(
     Context context, XmlWorkflowItem workflowItem, EPerson ePerson) throws SQLException {
   Criteria criteria = createCriteria(context, InProgressUser.class);
   criteria.add(
       Restrictions.and(
           Restrictions.eq("workflowItem", workflowItem), Restrictions.eq("ePerson", ePerson)));
   return uniqueResult(criteria);
 }
コード例 #19
0
  @Override
  public BoundaryCategory getBoundaryCategoryByBoundaryAndCategory(Criterion criterion) {
    Criteria criteria = getCurrentSession().createCriteria(BoundaryCategory.class);
    BoundaryCategory boundaryCategory = null;
    if (criterion != null) {
      Criterion dateCondn1 =
          Restrictions.and(Restrictions.le("fromDate", new Date()), Restrictions.isNull("toDate"));
      Criterion dateCondn2 =
          Restrictions.and(
              Restrictions.le("fromDate", new Date()), Restrictions.ge("toDate", new Date()));
      Criterion dateCondn = Restrictions.or(dateCondn1, dateCondn2);

      criteria.add(criterion);
      criteria.add(dateCondn);
      criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
      boundaryCategory = (BoundaryCategory) criteria.uniqueResult();
    }
    return boundaryCategory;
  }
コード例 #20
0
 public static Organisation getOrganisation(
     Organisation organisation, String name, Session session) {
   Criteria crit = session.createCriteria(Organisation.class);
   crit.setCacheable(true);
   crit.add(
       Restrictions.and(
           Restrictions.eq("organisation", organisation), Restrictions.eq("name", name)));
   Organisation org = (Organisation) crit.uniqueResult();
   return org;
 }
コード例 #21
0
ファイル: PrenotazioneDAO.java プロジェクト: lucaPedro/backup
 @SuppressWarnings("unchecked")
 public List<Prenotazione> getStanzeOccupate(long start, long end) {
   // definisci un nuovo criterio
   Criteria criteria = createCriteria();
   // criteria.add(Restrictions.lt("to",  new Date(start)));
   criteria.add(
       Restrictions.and(
           Restrictions.gt("to", new Date(start)), Restrictions.lt("from", new Date(end))));
   // criteria.add(Restrictions.gt("from", new Date(end)));
   return criteria.list();
 }
コード例 #22
0
 @SuppressWarnings("unchecked")
 public List<IncomeReceiptItem> getListIncomeReceiptItemByDate(String startDate, String endDate) {
   Date dStartDate = DateUtils.getDateFromStr(startDate);
   Date dEndDate = DateUtils.getDateFromStr(endDate);
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(IncomeReceiptItem.class);
   criteria.add(
       Restrictions.and(
           Restrictions.le("receiptDate", dStartDate),
           Restrictions.lt("receiptDate", DateUtils.addDate(dEndDate, 1))));
   return criteria.list();
 }
コード例 #23
0
  private Criteria buildCondition(Retirement r, String ks, String js, String eq, String type) {
    Criteria c = getSession().createCriteria(Retirement.class);
    if (r != null) {
      if (r.getSfsc() != null && r.getSfsc().length() > 0)
        c.add(Restrictions.eq("sfsc", r.getSfsc()));
      else c.add(Restrictions.eq("sfsc", Constants.HASNO));
      if (r.getSfzh() != null && r.getSfzh().length() > 0)
        c.add(Restrictions.eq("sfzh", r.getSfzh()));
      if (r.getXm() != null && r.getXm().length() > 0)
        c.add(Restrictions.like("xm", r.getXm(), MatchMode.ANYWHERE));
      if (r.getGzzh() != null && r.getGzzh().length() > 0)
        c.add(Restrictions.eq("gzzh", r.getGzzh()));
      if (r.getXb() != null && r.getXb().length() > 0) c.add(Restrictions.eq("xb", r.getXb()));
      if (r.getDwb() != null && r.getDwb().getId() != null)
        c.add(Restrictions.eq("dwb", r.getDwb()));
      if (r.getLxb() != null && r.getLxb().getId() != null)
        c.add(Restrictions.eq("lxb", r.getLxb()));
      if (r.getZjb() != null && r.getZjb().getId() != null)
        c.add(Restrictions.eq("zjb", r.getZjb()));
      if (r.getZwb() != null && r.getZwb().getId() != null)
        c.add(Restrictions.eq("zwb", r.getZwb()));
      if (r.getMzb() != null && r.getMzb().getId() != null)
        c.add(Restrictions.eq("mzb", r.getMzb()));
      if (r.getZzmm() != null && r.getZzmm().getId() != null)
        c.add(Restrictions.eq("zzmm", r.getZzmm()));
      if (r.getJg() != null && r.getJg().length() > 0) c.add(Restrictions.eq("jg", r.getJg()));

      if (r.getCsrq() != null && r.getCsrq().length() > 0)
        c.add(Restrictions.eq("csrq", r.getCsrq())); // 类型为空表是查出生日期,不为空是查是否为党员

      if (StringUtils.isNotEmpty(ks) || StringUtils.isNotBlank(js)) {
        if (StringUtils.isNotEmpty(ks) && StringUtils.isNotBlank(js)) {
          c.add(Restrictions.and(Restrictions.gt("csrq", js), Restrictions.lt("csrq", ks)));
        }
        if (StringUtils.isNotEmpty(ks)) {
          c.add(Restrictions.lt("csrq", ks));
        }
        if (StringUtils.isNotEmpty(js)) {
          c.add(Restrictions.gt("csrq", js));
        }
      }
      if (StringUtils.isNotBlank(eq)) {
        c.add(Restrictions.like("csrq", "%" + eq + "%"));
      }

      if (r.getParty() != null && r.getParty().getId() != null)
        c.add(Restrictions.eq("party", r.getParty()));
    }
    c.addOrder(Order.asc("sfzh")).addOrder(Order.desc("csrq"));
    return c;
  }
コード例 #24
0
  /**
   * See Interface for functional description.
   *
   * @param attributes set of key/value pairs
   * @see UserAccountDaoInterface #retrieveAttributes(java.lang.String)
   */
  @Override
  public List<UserAttribute> retrieveAttributes(final Set<HashMap<String, String>> attributes)
      throws SqlDatabaseSystemException {

    if (attributes == null) {
      throw new SqlDatabaseSystemException("attributes may not be null");
    }

    final DetachedCriteria detachedCriteria =
        DetachedCriteria.forClass(UserAttribute.class, "userAttribute");

    Criterion criterion = null;
    for (final Map<String, String> attribute : attributes) {
      for (final Entry<String, String> entry : attribute.entrySet()) {
        if (criterion == null) {
          criterion =
              Restrictions.and(
                  Restrictions.eq("name", entry.getKey()),
                  Restrictions.eq("value", entry.getValue()));
        } else {
          final Criterion criterion1 =
              Restrictions.and(
                  Restrictions.eq("name", entry.getKey()),
                  Restrictions.eq("value", entry.getValue()));
          criterion = Restrictions.or(criterion, criterion1);
        }
      }
    }

    detachedCriteria.add(criterion);
    final List<UserAttribute> result;
    try {
      result = getHibernateTemplate().findByCriteria(detachedCriteria);
    } catch (final DataAccessException e) {
      throw new SqlDatabaseSystemException(e);
    }
    return result;
  }
コード例 #25
0
 /*
  * Creates date filtering criteria to for checking if an entitlement has any overlap
  * with a "modifying" entitlement that has just been granted.
  */
 private Criteria createModifiesDateFilteringCriteria(
     Consumer consumer, Date startDate, Date endDate) {
   Criteria criteria =
       currentSession()
           .createCriteria(Entitlement.class)
           .add(Restrictions.eq("consumer", consumer))
           .add(
               Restrictions.or(
                   // Checks start date overlap:
                   Restrictions.and(
                       Restrictions.le("startDate", startDate),
                       Restrictions.ge("endDate", startDate)),
                   Restrictions.or(
                       // Checks end date overlap:
                       Restrictions.and(
                           Restrictions.le("startDate", endDate),
                           Restrictions.ge("endDate", endDate)),
                       // Checks total overlap:
                       Restrictions.and(
                           Restrictions.ge("startDate", startDate),
                           Restrictions.le("endDate", endDate)))));
   return criteria;
 }
コード例 #26
0
 public List<GovernedVelocity> getGovernedVelocity() {
   List<GovernedVelocity> list;
   session = HibernateUtil.getSessionFactory().openSession();
   Criterion cr1 = Restrictions.le("startCoordinate", ii.getKmE() * 1000 + ii.getmE());
   Criterion cr2 = Restrictions.ge("endCoordinate", ii.getKmS() * 1000 + ii.getmS());
   list =
       session
           .createCriteria(GovernedVelocity.class)
           .add(Restrictions.eq("direction", ii.getDirection()))
           .add(Restrictions.eq("line", ii.getLine()))
           .add(Restrictions.and(cr1, cr2))
           .list();
   session.close();
   return list;
 }
コード例 #27
0
  public List<Entitlement> listModifying(
      Consumer consumer, String productId, Date startDate, Date endDate) {

    /*
     * Essentially the opposite of the above query which searches for entitlement
     * overlap with a "modifying" entitlement being granted. This query is used to
     * search for modifying entitlements which overlap with a regular entitlement
     * being granted. As such the logic is basically reversed.
     *
     */
    Criteria criteria =
        currentSession()
            .createCriteria(Entitlement.class)
            .add(Restrictions.eq("consumer", consumer))
            .add(
                Restrictions.or(
                    Restrictions.and(
                        Restrictions.ge("startDate", startDate),
                        Restrictions.le("startDate", endDate)),
                    Restrictions.or(
                        Restrictions.and(
                            Restrictions.ge("endDate", startDate),
                            Restrictions.le("endDate", endDate)),
                        Restrictions.and(
                            Restrictions.le("startDate", startDate),
                            Restrictions.ge("endDate", endDate)))));
    List<Entitlement> finalResults = new LinkedList<Entitlement>();
    List<Entitlement> entsWithOverlap = criteria.list();
    for (Entitlement existingEnt : entsWithOverlap) {
      if (modifies(existingEnt, productId)) {
        finalResults.add(existingEnt);
      }
    }

    return finalResults;
  }
コード例 #28
0
 public List<RailsStrings> getRailsStrings() {
   List<RailsStrings> list = null;
   session = HibernateUtil.getSessionFactory().openSession();
   Criterion cr1 = Restrictions.le("startCoordinate", ii.getKmE() * 1000 + ii.getmE());
   Criterion cr2 = Restrictions.ge("endCoordinate", ii.getKmS() * 1000 + ii.getmS());
   list =
       session
           .createCriteria(RailsStrings.class)
           .add(Restrictions.eq("direction", ii.getDirection()))
           .add(Restrictions.eq("line", ii.getLine()))
           .add(Restrictions.eq("railThread", ii.getRailThread()))
           .add(Restrictions.and(cr1, cr2))
           .list();
   session.close();
   return list;
 }
コード例 #29
0
ファイル: SampleDAO.java プロジェクト: singhindresh/ometa
 public List<Sample> getSamplesByPublicFlag(Long projectId, boolean isPublic, Session session)
     throws Exception {
   List<Sample> sampleList = new ArrayList<Sample>();
   try {
     Criteria crit = session.createCriteria(Sample.class);
     crit.add(
         Restrictions.and(
             Restrictions.eq("projectId", projectId),
             Restrictions.eq("isPublic", isPublic ? 1 : 0)));
     List<Sample> results = crit.list();
     sampleList.addAll(results);
   } catch (Exception ex) {
     throw new DAOException(ex);
   }
   return sampleList;
 }
コード例 #30
0
  @SuppressWarnings("unchecked")
  public List<IncomeReceipt> getListIncomeReceiptByDate(
      String startDate, String endDate, boolean includeVoided) {
    Date dStartDate = DateUtils.getDateFromStr(startDate);
    Date dEndDate = DateUtils.getDateFromStr(endDate);

    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(IncomeReceipt.class);

    criteria.add(
        Restrictions.and(
            Restrictions.ge("receiptDate", dStartDate),
            Restrictions.lt("receiptDate", DateUtils.addDate(dEndDate, 1))));

    if (!includeVoided) criteria.add(Restrictions.eq("voided", false));

    return criteria.list();
  }