Example usage for org.hibernate.criterion Restrictions lt

List of usage examples for org.hibernate.criterion Restrictions lt

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions lt.

Prototype

public static SimpleExpression lt(String propertyName, Object value) 

Source Link

Document

Apply a "less than" constraint to the named property

Usage

From source file:org.LexGrid.LexBIG.caCore.dao.orm.translators.GridCQLToDetachedCriteria.java

License:Open Source License

private Criterion processAttribute(Attribute att, String parentAlias) {
    String attName = null;/*from w  ww  .  j a  v a  2 s  .c  o m*/

    if (prefixCastorUnderscore) {
        attName = addCastorUnderscore(att.getName());
    } else {
        attName = att.getName();
    }

    String name = parentAlias + "." + attName;
    String value = att.getValue();
    Criterion restriction = null;

    Predicate attPredicate = att.getPredicate();

    if (attPredicate.equals(Predicate.EQUAL_TO)) {
        restriction = Restrictions.eq(name, value);
    }
    if (attPredicate.equals(Predicate.LIKE)) {
        restriction = Restrictions.like(name, value);
    }
    if (attPredicate.equals(Predicate.GREATER_THAN)) {
        restriction = Restrictions.gt(name, value);
    }
    if (attPredicate.equals(Predicate.GREATER_THAN_EQUAL_TO)) {
        restriction = Restrictions.ge(name, value);
    }
    if (attPredicate.equals(Predicate.LESS_THAN)) {
        restriction = Restrictions.lt(name, value);
    }
    if (attPredicate.equals(Predicate.LESS_THAN_EQUAL_TO)) {
        restriction = Restrictions.le(name, value);
    }
    if (attPredicate.equals(Predicate.IS_NULL)) {
        restriction = Restrictions.isNull(name);
    }
    if (attPredicate.equals(Predicate.IS_NOT_NULL)) {
        restriction = Restrictions.isNotNull(name);
    }
    if (attPredicate.equals(Predicate.NOT_EQUAL_TO)) {
        restriction = Restrictions.ne(name, value);
    }
    return restriction;
}

From source file:org.LexGrid.LexBIG.caCore.dao.orm.translators.SDKCQLToDetachedCriteria.java

License:Open Source License

private Criterion processAttribute(CQLAttribute att, String parentAlias) {
    String name = parentAlias + "." + att.getName();
    String value = att.getValue();
    Criterion restriction = null;//  w w w . ja va2s.  c  o  m

    CQLPredicate attPredicate = att.getPredicate();

    if (attPredicate.equals(CQLPredicate.EQUAL_TO)) {
        restriction = Restrictions.eq(name, value);
    }
    if (attPredicate.equals(CQLPredicate.LIKE)) {
        restriction = Restrictions.like(name, value);
    }
    if (attPredicate.equals(CQLPredicate.GREATER_THAN)) {
        restriction = Restrictions.gt(name, value);
    }
    if (attPredicate.equals(CQLPredicate.GREATER_THAN_EQUAL_TO)) {
        restriction = Restrictions.ge(name, value);
    }
    if (attPredicate.equals(CQLPredicate.LESS_THAN)) {
        restriction = Restrictions.lt(name, value);
    }
    if (attPredicate.equals(CQLPredicate.LESS_THAN_EQUAL_TO)) {
        restriction = Restrictions.le(name, value);
    }
    if (attPredicate.equals(CQLPredicate.IS_NULL)) {
        restriction = Restrictions.isNull(name);
    }
    if (attPredicate.equals(CQLPredicate.IS_NOT_NULL)) {
        restriction = Restrictions.isNotNull(name);
    }
    if (attPredicate.equals(CQLPredicate.NOT_EQUAL_TO)) {
        restriction = Restrictions.ne(name, value);
    }
    return restriction;
}

From source file:org.libreplan.business.documents.daos.DocumentDAO.java

License:Open Source License

@Override
@Transactional(readOnly = true)//w  ww. j a va2 s.co m
public List<Document> findWorkDocumentBetween(Date from, Date to) {
    Criteria c = getSession().createCriteria(Document.class);
    c.add(Restrictions.eq("docType", DocumentTypeEnum.WORK))
            .add(Restrictions.not(Restrictions.like("docTitle", "WorkRoot-", MatchMode.START)))
            .createCriteria("work").add(Restrictions.ge("fromTime", from)).add(Restrictions.lt("toTime", to));

    return c.list();
}

From source file:org.libreplan.business.documents.daos.DocumentDAO.java

License:Open Source License

@Override
@Transactional(readOnly = true)//from  w w w .  jav  a2s. com
public List<Document> findWorkDocumentBetween(Date from, Date to, boolean folder) {
    Criteria c = getSession().createCriteria(Document.class);
    c.add(Restrictions.eq("docType", DocumentTypeEnum.WORK)).add(Restrictions.eq("isFolder", folder))
            .add(Restrictions.not(Restrictions.like("docTitle", "WorkRoot-", MatchMode.START)))
            .createCriteria("work").add(Restrictions.ge("fromTime", from)).add(Restrictions.lt("toTime", to));

    return c.list();
}

From source file:org.linagora.linshare.core.repository.hibernate.AnonymousShareEntryRepositoryImpl.java

License:Open Source License

@Override
public List<AnonymousShareEntry> findAllExpiredEntries() {
    List<AnonymousShareEntry> entries = findByCriteria(
            Restrictions.lt("expirationDate", Calendar.getInstance()));
    if (entries == null) {
        logger.error("the result is null ! this should not happen.");
        return new ArrayList<AnonymousShareEntry>();
    }//from w w  w  . j  a  v a 2  s  . c o m
    return entries;
}

From source file:org.linagora.linshare.core.repository.hibernate.AnonymousShareEntryRepositoryImpl.java

License:Open Source License

@Override
public List<AnonymousShareEntry> findUpcomingExpiredEntries(Integer date) {
    Calendar calMin = Calendar.getInstance();
    calMin.add(Calendar.DAY_OF_MONTH, date);

    Calendar calMax = Calendar.getInstance();
    calMax.add(Calendar.DAY_OF_MONTH, date + 1);

    return findByCriteria(Restrictions.lt("expirationDate", calMax), Restrictions.gt("expirationDate", calMin));
}

From source file:org.linagora.linshare.core.repository.hibernate.DocumentEntryRepositoryImpl.java

License:Open Source License

@Override
public List<DocumentEntry> findAllExpiredEntries() {
    List<DocumentEntry> entries = findByCriteria(Restrictions.lt("expirationDate", Calendar.getInstance()));
    if (entries == null) {
        logger.error("the result is null ! this should not happen.");
        return new ArrayList<DocumentEntry>();
    }/*from   w w w .  j  a  va2s .  co  m*/
    return entries;
}

From source file:org.linagora.linshare.core.repository.hibernate.EntryRepositoryImpl.java

License:Open Source License

@Override
public List<Entry> getOutdatedEntry() {
    return findByCriteria(Restrictions.lt("expirationDate", Calendar.getInstance()));
}

From source file:org.linagora.linshare.core.repository.hibernate.GuestRepositoryImpl.java

License:Open Source License

/**
 * Find outdated guest accounts.//from w  w  w .j av a 2 s.com
 * 
 * @return a list of outdated guests (null if no one found).
 */
public List<Guest> findOutdatedGuests() {
    DetachedCriteria criteria = DetachedCriteria.forClass(Guest.class);
    criteria.add(Restrictions.lt("expirationDate", new Date()));
    criteria.add(Restrictions.eq("destroyed", false));
    return findByCriteria(criteria);
}

From source file:org.linagora.linshare.core.repository.hibernate.LogEntryRepositoryImpl.java

License:Open Source License

public List<LogEntry> findByDate(String mail, Calendar beginDate, Calendar endDate) {

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

    criteria.add(Restrictions.eq("actorMail", mail));

    if (beginDate != null) {
        criteria.add(Restrictions.gt("actionDate", beginDate));
    }/*from  w  w w .  j ava 2 s. c o m*/

    if (endDate != null) {
        criteria.add(Restrictions.lt("actionDate", endDate));
    }
    return findBy(criteria);
}