Example usage for com.liferay.portal.kernel.dao.orm RestrictionsFactoryUtil between

List of usage examples for com.liferay.portal.kernel.dao.orm RestrictionsFactoryUtil between

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm RestrictionsFactoryUtil between.

Prototype

public static Criterion between(String propertyName, Object lo, Object hi) 

Source Link

Usage

From source file:com.hitss.layer.service.impl.PostulacionLocalServiceImpl.java

License:Open Source License

private DynamicQuery query(SolicitudRequerimiento solicitudRequerimiento, Date fechaRegistroInicio,
        Date fechaRegistrFin, String orden, String campoOrden) {
    //      SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    DynamicQuery subQuery = DynamicQueryFactoryUtil.forClass(SolicitudRequerimiento.class, "child");
    subQuery.setProjection(ProjectionFactoryUtil.property("child.solicitudRequerimientoId"));
    if (Validator.isNotNull(solicitudRequerimiento)) {
        if (Validator.isNotNull(solicitudRequerimiento.getCategoriaPuestoId())) {
            subQuery.add(PropertyFactoryUtil.forName("child.categoriaPuestoId")
                    .eq(solicitudRequerimiento.getCategoriaPuestoId()));
        }/*from   w w  w .  j  a  v a 2 s. co m*/
        if (Validator.isNotNull(solicitudRequerimiento.getEstado())) {
            subQuery.add(PropertyFactoryUtil.forName("child.estado").eq(solicitudRequerimiento.getEstado()));
        }

        if (Validator.isNotNull(solicitudRequerimiento.getResponsableRRHH())) {
            subQuery.add(PropertyFactoryUtil.forName("child.responsableRRHH")
                    .eq(solicitudRequerimiento.getResponsableRRHH()));
        }

        if (Validator.isNotNull(solicitudRequerimiento.getTiempoContrato())) {
            subQuery.add(PropertyFactoryUtil.forName("child.tiempoContrato")
                    .eq(Long.valueOf(solicitudRequerimiento.getTiempoContrato())));
        }
    }
    if (Validator.isNotNull(fechaRegistroInicio) && Validator.isNotNull(fechaRegistrFin)) {
        if (Validator.isNotNull(fechaRegistroInicio) && Validator.isNotNull(fechaRegistrFin)) {
            subQuery.add(
                    RestrictionsFactoryUtil.between("child.fechacrea", fechaRegistroInicio, fechaRegistrFin));
        }
    }
    subQuery.add(PropertyFactoryUtil.forName("child.activo").eq(true));

    DynamicQuery query = DynamicQueryFactoryUtil.forClass(Postulacion.class);
    query.add(PropertyFactoryUtil.forName("primaryKey.solicitudRequerimientoId").in(subQuery));
    query.add(PropertyFactoryUtil.forName("seleccionado").eq(false));
    query.addOrder(OrderFactoryUtil.desc("fechamodifica"));
    return query;
}

From source file:com.hitss.layer.service.impl.SolicitudEvaluacionDesempennoLocalServiceImpl.java

License:Open Source License

private DynamicQuery query(SolicitudEvaluacionDesempenno solicitudEvaluacion, Date fechaEvaluacionInicio,
        Date fechaEvaluacionFin, String orden, String campoOrden) {
    DynamicQuery query = DynamicQueryFactoryUtil.forClass(SolicitudEvaluacionDesempenno.class);
    if (Validator.isNotNull(solicitudEvaluacion)) {
        if (Validator.isNotNull(solicitudEvaluacion.getDescripcion())) {
            query.add(PropertyFactoryUtil.forName("descripcion")
                    .like(StringPool.PERCENT + solicitudEvaluacion.getDescripcion() + StringPool.PERCENT));
        }/* www . j a v a  2 s  .  c o m*/
        if (Validator.isNotNull(solicitudEvaluacion.getEstado())) {
            query.add(PropertyFactoryUtil.forName("estado").eq(solicitudEvaluacion.getEstado()));
        }

    }
    if (Validator.isNotNull(solicitudEvaluacion) && Validator.isNotNull(fechaEvaluacionFin)) {
        if (Validator.isNotNull(fechaEvaluacionInicio) && Validator.isNotNull(fechaEvaluacionFin)) {
            query.add(
                    RestrictionsFactoryUtil.between("fechaInicio", fechaEvaluacionInicio, fechaEvaluacionFin));
        }
    }
    query.add(PropertyFactoryUtil.forName("activo").eq(true));
    query.addOrder(OrderFactoryUtil.desc("fechamodifica"));
    return query;
}

From source file:com.hitss.layer.service.impl.SolicitudRequerimientoLocalServiceImpl.java

License:Open Source License

private DynamicQuery query(SolicitudRequerimiento solicitudRequerimiento, Date fechaRegistroInicio,
        Date fechaRegistrFin, String orden, String campoOrden) {
    //      SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    DynamicQuery query = DynamicQueryFactoryUtil.forClass(SolicitudRequerimiento.class);
    if (Validator.isNotNull(solicitudRequerimiento)) {
        if (Validator.isNotNull(solicitudRequerimiento.getCategoriaPuestoId())) {
            query.add(PropertyFactoryUtil.forName("categoriaPuestoId")
                    .eq(solicitudRequerimiento.getCategoriaPuestoId()));
        }/*  ww w.j  a v  a  2s.co  m*/
        if (Validator.isNotNull(solicitudRequerimiento.getEstado())) {
            query.add(PropertyFactoryUtil.forName("estado").eq(solicitudRequerimiento.getEstado()));
        }

        if (Validator.isNotNull(solicitudRequerimiento.getResponsableRRHH())) {
            query.add(PropertyFactoryUtil.forName("responsableRRHH")
                    .eq(solicitudRequerimiento.getResponsableRRHH()));
        }

        if (Validator.isNotNull(solicitudRequerimiento.getTiempoContrato())) {
            query.add(PropertyFactoryUtil.forName("tiempoContrato")
                    .eq(Long.valueOf(solicitudRequerimiento.getTiempoContrato())));
        }
    }
    if (Validator.isNotNull(fechaRegistroInicio) && Validator.isNotNull(fechaRegistrFin)) {
        if (Validator.isNotNull(fechaRegistroInicio) && Validator.isNotNull(fechaRegistrFin)) {
            query.add(RestrictionsFactoryUtil.between("fechacrea", fechaRegistroInicio, fechaRegistrFin));
        }
    }
    query.add(PropertyFactoryUtil.forName("activo").eq(true));
    query.addOrder(OrderFactoryUtil.desc("fechamodifica"));
    return query;
}

From source file:com.inikah.slayer.service.impl.MatchCriteriaLocalServiceImpl.java

License:Open Source License

/**
 * /*from  w w w  .  java  2s  .  com*/
 */
@SuppressWarnings("unchecked")
public List<Profile> getMatches(long profileId) {

    List<Profile> matches = new ArrayList<Profile>();

    Profile profile = null;
    try {
        profile = profileLocalService.fetchProfile(profileId);
    } catch (SystemException e) {
        e.printStackTrace();
    }

    MatchCriteria matchCriteria = null;
    try {
        matchCriteria = fetchMatchCriteria(profileId);
    } catch (SystemException e) {
        e.printStackTrace();
    }

    if (Validator.isNull(matchCriteria)) {
        return matches;
    }

    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Profile.class,
            PortletClassLoaderUtil.getClassLoader());

    // bride or grooms
    dynamicQuery.add(RestrictionsFactoryUtil.ne("bride", profile.isBride()));

    // minAge and maxAge
    int minValue = AgeUtil.getBornOnFigure(matchCriteria.getMaxAge(), AgeUtil.MAX);
    int maxValue = AgeUtil.getBornOnFigure(matchCriteria.getMinAge(), AgeUtil.MIN);
    dynamicQuery.add(RestrictionsFactoryUtil.between("bornOn", minValue, maxValue));

    // exclude the profiles of the same user
    dynamicQuery.add(RestrictionsFactoryUtil.ne("userId", profile.getUserId()));

    // only pull profiles that are currently 'ACTIVE'
    dynamicQuery.add(RestrictionsFactoryUtil.eq("status", IConstants.PROFILE_STATUS_ACTIVE));

    // marital status
    String maritalStatusCSV = matchCriteria.getMaritalStatus();
    if (Validator.isNotNull(maritalStatusCSV)) {
        List<Integer> maritalStatusList = MyListUtil.getIntegers(maritalStatusCSV);
        dynamicQuery.add(RestrictionsFactoryUtil.in("maritalStatus", maritalStatusList));

        int married = BridgeServiceUtil.getListTypeId(IConstants.LIST_MARITAL_STATUS, "married");
        int divorced = BridgeServiceUtil.getListTypeId(IConstants.LIST_MARITAL_STATUS, "divorced");
        int widow = BridgeServiceUtil.getListTypeId(IConstants.LIST_MARITAL_STATUS, "widow");

        if ((maritalStatusList.contains(married) || maritalStatusList.contains(divorced)
                || maritalStatusList.contains(widow)) && matchCriteria.isWithNoChildren()) {

            dynamicQuery.add(RestrictionsFactoryUtil.eq("sons", 0));
            dynamicQuery.add(RestrictionsFactoryUtil.eq("daughters", 0));
        }
    }

    // mother tongue
    String motherTongueCSV = matchCriteria.getMotherTongue();
    if (Validator.isNotNull(motherTongueCSV)) {
        dynamicQuery.add(RestrictionsFactoryUtil.in("motherTongue", MyListUtil.getIntegers(motherTongueCSV)));
    }

    // NEVER show "Single" profiles for Non-Single Profiles. 
    if (!profile.isSingle()) {
        dynamicQuery.add(RestrictionsFactoryUtil.eq("allowNonSingleProposals", true));
    }

    // exclude profiles that are "blocked" for this profile
    List<Long> blockedIds = InteractionLocalServiceUtil.getTargetIds(profileId, IConstants.INT_ACTION_BLOCKED);
    for (long targetId : blockedIds) {
        dynamicQuery.add(RestrictionsFactoryUtil.ne("profileId", targetId));
    }

    try {
        matches = dynamicQuery(dynamicQuery);
    } catch (SystemException e) {
        e.printStackTrace();
    }

    return matches;
}

From source file:com.vietnamobile.service.impl.OnlinetestEntryLocalServiceImpl.java

License:Open Source License

private DynamicQuery buildDynamicQuery(String title, String userName, Date fromDate, Date toDate,
        Class<?> clazz, boolean andSearch) {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(clazz, getClassLoader());
    Junction junction = null;//from   w w w .  jav a2 s  .co m
    if (andSearch) {
        junction = RestrictionsFactoryUtil.conjunction();
    } else {
        junction = RestrictionsFactoryUtil.disjunction();
    }

    if (Validator.isNotNull(userName)) {
        Property property = PropertyFactoryUtil.forName("userName");
        String value = (new StringBuilder("%")).append(userName).append("%").toString();
        junction.add(property.like(value));

    }
    if (Validator.isNotNull(title)) {
        Property property = PropertyFactoryUtil.forName("title");
        String value = (new StringBuilder("%")).append(title).append("%").toString();
        junction.add(property.like(value));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.ge("createDate", fromDate));
    }
    if (Validator.isNotNull(toDate) && Validator.isNull(fromDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.le("createDate", toDate));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNotNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.between("createDate", fromDate, toDate));
    }

    return dynamicQuery.add(junction);
}

From source file:com.vietnamobile.service.impl.OnlinetestResultEntryLocalServiceImpl.java

License:Open Source License

private DynamicQuery buildDynamicQuery(long userId, long onlinetestEntryId, String userName, double score,
        Date fromDate, Date toDate, String examType, Class<?> clazz, boolean andSearch) {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(clazz, getClassLoader());
    Junction junction = null;/*  w w w .  j  a v  a 2  s. c  o m*/
    if (andSearch) {
        junction = RestrictionsFactoryUtil.conjunction();
    } else {
        junction = RestrictionsFactoryUtil.disjunction();
    }

    if (userId > 0) {
        Property property = PropertyFactoryUtil.forName("userId");
        junction.add(property.eq(Long.valueOf(userId)));
    }
    if (onlinetestEntryId > 0) {
        Property property = PropertyFactoryUtil.forName("onlineTestEntryId");
        junction.add(property.eq(Long.valueOf(onlinetestEntryId)));
    }
    if (Validator.isNotNull(userName)) {
        Property property = PropertyFactoryUtil.forName("userName");
        String value = (new StringBuilder("%")).append(userName).append("%").toString();
        junction.add(property.like(value));

    }
    if (Validator.isNotNull(examType)) {
        Property property = PropertyFactoryUtil.forName("examType");
        String value = (new StringBuilder("")).append(examType).toString();
        junction.add(property.eq(value));
    }
    if (score > 0) {
        Property property = PropertyFactoryUtil.forName("score");
        junction.add(property.eq(score));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.ge("createDate", fromDate));
    }
    if (Validator.isNotNull(toDate) && Validator.isNull(fromDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.le("createDate", toDate));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNotNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.between("createDate", fromDate, toDate));
    }

    return dynamicQuery.add(junction);
}

From source file:com.vietnamobile.service.impl.VnmArticleReportEntryLocalServiceImpl.java

License:Open Source License

private DynamicQuery buildDynamicQuery(String title, String userName, String action, int status, Date fromDate,
        Date toDate, Class<?> clazz, boolean andSearch) {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(clazz, getClassLoader());
    Junction junction = null;//  ww  w.  j av  a 2 s  .c  om
    if (andSearch) {
        junction = RestrictionsFactoryUtil.conjunction();
    } else {
        junction = RestrictionsFactoryUtil.disjunction();
    }

    if (Validator.isNotNull(title)) {
        Property property = PropertyFactoryUtil.forName("title");
        String value = (new StringBuilder("%")).append(title).append("%").toString();
        junction.add(property.like(value));

    }
    if (Validator.isNotNull(userName)) {
        Property property = PropertyFactoryUtil.forName("userName");
        String value = (new StringBuilder("%")).append(userName).append("%").toString();
        junction.add(property.like(value));
    }
    if (Validator.isNotNull(action)) {
        Property property = PropertyFactoryUtil.forName("action");
        String value = (new StringBuilder("%")).append(action).append("%").toString();
        junction.add(property.like(value));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNotNull(toDate)) {
        Criterion dateRangeCriterion = RestrictionsFactoryUtil.between("modifiedDate", fromDate, toDate);
        dynamicQuery.add(dateRangeCriterion);
    }
    if (status >= 0) {
        Property property = PropertyFactoryUtil.forName("status");
        junction.add(property.eq(status));
    }
    return dynamicQuery.add(junction);
}