Example usage for org.hibernate.criterion Restrictions le

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

Introduction

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

Prototype

public static SimpleExpression le(String propertyName, Object value) 

Source Link

Document

Apply a "less than or equal" constraint to the named property

Usage

From source file:gov.nih.nci.caintegrator.data.CopyNumberAlterationCriterionConverter.java

License:BSD License

private SimpleExpression segmentStartLessThanLow(Integer chromosomeCoordinateLow) {
    return Restrictions.le(LOCATION_START_ATTRIBUTE, chromosomeCoordinateLow);
}

From source file:gov.nih.nci.caintegrator.data.CopyNumberAlterationCriterionConverter.java

License:BSD License

private SimpleExpression segmentStartLessThanHigh(Integer chromosomeCoordinateHigh) {
    return Restrictions.le(LOCATION_START_ATTRIBUTE, chromosomeCoordinateHigh);
}

From source file:gov.nih.nci.caintegrator.data.DateComparisonCriterionHandler.java

License:BSD License

/**
 * {@inheritDoc}/* w  w  w . j  a  v a 2s  .  c om*/
 */
@Override
Criterion translate() {
    if (dateComparisonCriterion.getDateComparisonOperator() != null) {
        DateComparisonOperatorEnum operator = dateComparisonCriterion.getDateComparisonOperator();
        switch (operator) {
        case EQUAL:
            return Restrictions.eq(DATE_VALUE_COLUMN, dateComparisonCriterion.getDateValue());
        case GREATER:
            return Restrictions.gt(DATE_VALUE_COLUMN, dateComparisonCriterion.getDateValue());
        case GREATEROREQUAL:
            return Restrictions.ge(DATE_VALUE_COLUMN, dateComparisonCriterion.getDateValue());
        case LESS:
            return Restrictions.lt(DATE_VALUE_COLUMN, dateComparisonCriterion.getDateValue());
        case LESSOREQUAL:
            return Restrictions.le(DATE_VALUE_COLUMN, dateComparisonCriterion.getDateValue());
        case NOTEQUAL:
            return Restrictions.ne(DATE_VALUE_COLUMN, dateComparisonCriterion.getDateValue());
        default:
            throw new IllegalStateException("Unknown DateComparisonOperator: " + operator);
        }
    } else {
        throw new IllegalStateException("DateComparisonOperator is not set");
    }

}

From source file:gov.nih.nci.caintegrator.data.NumericComparisonCriterionHandler.java

License:BSD License

/**
 * {@inheritDoc}//from   w  w w.ja  v a  2 s .co m
 */
@Override
Criterion translate() {
    if (numericComparisonCriterion.getNumericComparisonOperator() != null) {
        NumericComparisonOperatorEnum operator = numericComparisonCriterion.getNumericComparisonOperator();
        switch (operator) {
        case EQUAL:
            return Restrictions.eq(NUMERIC_VALUE_COLUMN, numericComparisonCriterion.getNumericValue());
        case GREATER:
            return Restrictions.gt(NUMERIC_VALUE_COLUMN, numericComparisonCriterion.getNumericValue());
        case GREATEROREQUAL:
            return Restrictions.ge(NUMERIC_VALUE_COLUMN, numericComparisonCriterion.getNumericValue());
        case LESS:
            return Restrictions.lt(NUMERIC_VALUE_COLUMN, numericComparisonCriterion.getNumericValue());
        case LESSOREQUAL:
            return Restrictions.le(NUMERIC_VALUE_COLUMN, numericComparisonCriterion.getNumericValue());
        case NOTEQUAL:
            return Restrictions.ne(NUMERIC_VALUE_COLUMN, numericComparisonCriterion.getNumericValue());
        default:
            throw new IllegalStateException("Unknown NumericComparisonOperator: " + operator);
        }
    } else {
        throw new IllegalStateException("NumericComparisonOperator is not set");
    }

}

From source file:gov.nih.nci.caintegrator.domain.annotation.service.AnnotationManagerImpl.java

License:BSD License

public List<SNPAnnotation> getSnpAnnotationsForGene(String geneId, Long kbUpstream, Long kbDownstream) {
    GeneBiomarker gene = getGeneForSymbol(geneId);

    String chr = gene.getChromosome();
    Long start = gene.getStartPhyscialLocation();
    Long end = gene.getEndPhysicalLocation();

    Session sess = sessionFactory.getCurrentSession();

    Criteria criteria = sess.createCriteria(SNPAnnotation.class);

    criteria.add(Restrictions.eq("chromosomeName", chr));
    criteria.add(Restrictions.ge("chromosomeLocation", start - (kbUpstream * 1000)));
    criteria.add(Restrictions.le("chromosomeLocation", end + (kbDownstream * 1000)));
    return criteria.list();
}

From source file:gov.nih.nci.protexpress.util.SearchCriteriaHelper.java

License:BSD License

/**
 * Given a Date object, returns a Calendar.
 *
 * @param crit the Criteria/*from   www  .  j a va 2 s  .c  o m*/
 * @param params the search parameters
 * @param onlyCount parameter for getting the count only
 * @param sortProperty the sort property
 * @param sortDir the sort order
 * @return the Criteria
 */
public static Criteria getCriteria(Criteria crit, SearchParameters params, boolean onlyCount,
        String sortProperty, SortOrderEnum sortDir) {

    if (onlyCount) {
        crit.setProjection(Projections.rowCount());
    }

    if (!onlyCount && sortDir != null && StringUtils.isNotBlank(sortProperty)) {
        if (SortOrderEnum.ASCENDING.equals(sortDir)) {
            crit.addOrder(Order.asc(sortProperty));
        } else {
            crit.addOrder(Order.desc(sortProperty));
        }
    }

    if ((params != null) && (StringUtils.isNotEmpty(params.getName()))) {
        crit.add(Restrictions.like("name", "%" + params.getName() + "%").ignoreCase());
    }

    // crit.createAlias("auditInfo", "audit");
    if ((params != null) && !params.getSearchAllUsers()) {
        crit.add(Restrictions.eq("auditInfo.creator", UserHolder.getUsername()));
    }

    if ((params != null) && (params.getFromDate() != null)) {
        crit.add(Restrictions.ge("auditInfo.lastModifiedDate", DateHelper.getDate(params.getFromDate())));
    }

    if ((params != null) && (params.getToDate() != null)) {
        crit.add(Restrictions.le("auditInfo.lastModifiedDate", DateHelper.getDate(params.getToDate())));
    }

    return crit;
}

From source file:GPStreet.DB.Managers.ManageTracker.java

public List<GpstTracker> getTracking(Integer id, int stateId, int userId, double latitude, double longitude,
        Date sDate, Date eDate, double deviceId) {

    List<GpstTracker> result;
    try {//w  ww  .  ja  v a  2 s . c o  m
        Criteria cr = session.createCriteria(GpstTracker.class);
        if (id != null)
            cr.add(Restrictions.eq("id", id));
        if (stateId != 0)
            cr.add(Restrictions.eq("gpstState.id", stateId));
        if (userId != 0)
            cr.add(Restrictions.eq("gpstUsers.id", userId));
        if (latitude != 0)
            cr.add(Restrictions.eq("latitude", latitude));
        if (longitude != 0)
            cr.add(Restrictions.eq("longitude", longitude));
        if (sDate != null)
            cr.add(Restrictions.ge("date", sDate));
        if (eDate != null)
            cr.add(Restrictions.le("date", eDate));
        if (deviceId != 0)
            cr.add(Restrictions.eq("deviceId", deviceId));

        cr.addOrder(Order.desc("date"));
        result = cr.list();
    } catch (HibernateException ex) {
        logger.error(ex.getMessage());
        return null;
    }
    return result;
}

From source file:grails.orm.HibernateCriteriaBuilder.java

License:Apache License

/**
 * Creates a "less than or equal to" Criterion based on the specified property name and value
 * @param propertyName The property name
 * @param propertyValue The property value
 * @return A Criterion instance/*from w  w w .j a v  a2s.  co m*/
 */
public org.grails.datastore.mapping.query.api.Criteria le(String propertyName, Object propertyValue) {
    if (!validateSimpleExpression()) {
        throwRuntimeException(new IllegalArgumentException("Call to [le] with propertyName [" + propertyName
                + "] and value [" + propertyValue + "] not allowed here."));
    }

    propertyName = calculatePropertyName(propertyName);
    propertyValue = calculatePropertyValue(propertyValue);
    addToCriteria(Restrictions.le(propertyName, propertyValue));
    return this;
}

From source file:info.interactivesystems.spade.dao.NilsimsaSimilarityDao.java

License:Apache License

public List<NilsimsaSimilarity> find(Double similarity, Boolean sameAuthor, Integer wordDistance,
        Integer limit) {/*  w  w  w  .ja  va 2 s. co m*/
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(NilsimsaSimilarity.class);
    criteria.add(Restrictions.ge(SIMILARITY, similarity)).add(Restrictions.eq("sameAuthor", sameAuthor))
            .add(Restrictions.le("wordDistance", wordDistance));
    criteria.setMaxResults(limit);

    return initialize(criteria);
}