Example usage for org.apache.lucene.index Sorter sort

List of usage examples for org.apache.lucene.index Sorter sort

Introduction

In this page you can find the example usage for org.apache.lucene.index Sorter sort.

Prototype

Sort sort

To view the source code for org.apache.lucene.index Sorter sort.

Click Source Link

Usage

From source file:siddur.solidtrust.marktplaats.MarktplaatsService.java

public Sorter top100Sort(Fast100 f) {
    String baseJpql = "from SortedMarktplaats s, NewMarktplaats m where s.id = m.id"
            + " and m.repetition is null" + " and m.dateRegisted is not null"
            + " and m.price != 99999 and m.price != 999999 and m.price != 9999999" + " and s.brand = '"
            + f.getBrand() + "' and s.model = '" + f.getModel() + "' and s.build = '" + f.getBuild()
            + "' and s.engineSize = " + f.getEngineSize() + " and s.fuelType = '" + f.getFuelType()
            + "' and m.arrangement = '" + f.getArrangement() + "'";
    String selectSql = "select m.ownerType, m.color, m.price, m.mileage, datediff(m.dateRegisted, m.adDate)as days ";
    String jpql = selectSql + baseJpql;
    log4j.info(jpql);//from  w ww.  j  a  va2 s  .c o m

    @SuppressWarnings("unchecked")
    List<Object[]> list = em.createNativeQuery(jpql).getResultList();
    List<CarItemToSort> results = new ArrayList<CarItemToSort>(list.size());
    for (Object[] objs : list) {
        CarItemToSort car = new CarItemToSort();
        results.add(car);
        int i = 0;
        car.setOwnerType((Integer) objs[i++]);
        car.setColor((String) objs[i++]);
        car.setPrice((Integer) objs[i++]);
        car.setMileage((Integer) objs[i++]);
        car.setDays(((BigInteger) objs[i++]).intValue());
    }

    Sorter sorter = new Sorter(results);
    sorter.sort();
    return sorter;
}