Example usage for com.mongodb BasicDBObject getString

List of usage examples for com.mongodb BasicDBObject getString

Introduction

In this page you can find the example usage for com.mongodb BasicDBObject getString.

Prototype

public String getString(final String key) 

Source Link

Document

Returns the value of a field as a string

Usage

From source file:org.keycloak.connections.mongo.updater.impl.updates.Update2_3_0.java

License:Apache License

@Override
public void update(KeycloakSession session) {

    DBCollection realms = db.getCollection("realms");
    DBCursor cursor = realms.find();/*from  w w w  .jav  a  2s . c o m*/
    while (cursor.hasNext()) {
        BasicDBObject realm = (BasicDBObject) cursor.next();

        String realmId = realm.getString("_id");

        String privateKeyPem = realm.getString("privateKeyPem");
        String certificatePem = realm.getString("certificatePem");

        BasicDBList entities = (BasicDBList) realm.get("componentEntities");

        BasicDBObject component = new BasicDBObject();
        component.put("id", KeycloakModelUtils.generateId());
        component.put("name", "rsa");
        component.put("providerType", KeyProvider.class.getName());
        component.put("providerId", "rsa");
        component.put("parentId", realmId);

        BasicDBObject config = new BasicDBObject();
        config.put("priority", Collections.singletonList("100"));
        config.put("privateKey", Collections.singletonList(privateKeyPem));
        config.put("certificate", Collections.singletonList(certificatePem));

        component.put("config", config);

        entities.add(component);

        realm.remove("privateKeyPem");
        realm.remove("certificatePem");
        realm.remove("publicKeyPem");
        realm.remove("codeSecret");

        realms.update(new BasicDBObject().append("_id", realmId), realm);
    }
}

From source file:org.mongoste.core.impl.mongodb.MongoStatsEngine.java

License:Open Source License

private List<StatAction> getTargetStats(DBObject query) throws StatsEngineException {
    List<StatAction> result = new ArrayList<StatAction>();
    DBCursor dbc = null;/*from www. j  a va2 s . co m*/
    try {
        log.debug("Querying targets");
        DBCollection targets = getTargetCollection();
        long t = System.currentTimeMillis();
        DBObject fields = MongoUtil.createDoc(EVENT_ACTION, 1, FIELD_COUNT, 1, EVENT_DATE, 1);
        dbc = targets.find(query, fields);
        t = System.currentTimeMillis() - t;
        if (t > 1000) {
            log.warn("getTargetStats query: {}\n took {}s", debugTrim(query), t / 1000.0);
        }
        BasicDBObject resultDoc;
        Map<String, StatAction> actions = new HashMap<String, StatAction>();
        Map<String, Map<DateTime, StatCounter>> actionsDate = new HashMap<String, Map<DateTime, StatCounter>>();
        Map<DateTime, StatCounter> dateCount;
        StatAction action;
        StatCounter dateCounter;
        String actionName;
        Long count;
        MutableDateTime dateTime = DateUtil.getDateTimeUTC(true).toMutableDateTime();
        DateTime date;
        Date eventYearMonthTargetDate;
        int processed = 0;
        t = System.currentTimeMillis();
        while (dbc.hasNext()) {
            resultDoc = (BasicDBObject) dbc.next();
            actionName = resultDoc.getString(EVENT_ACTION);
            count = resultDoc.getLong(FIELD_COUNT);
            eventYearMonthTargetDate = (Date) resultDoc.get(EVENT_DATE);
            dateTime.setDate(eventYearMonthTargetDate.getTime());
            date = dateTime.toDateTime();
            action = actions.get(actionName);
            if (action == null) {
                actions.put(actionName, action = new StatAction(actionName, 0));
            }
            action.add(count);
            dateCount = actionsDate.get(actionName);
            if (dateCount == null) {
                dateCount = new TreeMap<DateTime, StatCounter>();
                actionsDate.put(actionName, dateCount);
            }
            dateCounter = dateCount.get(date);
            if (dateCounter == null) {
                dateCount.put(date, dateCounter = new StatCounter(actionName, 0, date.toDate()));
            }
            dateCounter.add(count);
            processed++;
        }
        //Build result list
        for (Entry<String, StatAction> entry : actions.entrySet()) {
            action = entry.getValue();
            dateCount = actionsDate.get(action.getName());
            List<StatCounter> targetList = action.getTargets();
            for (Entry<DateTime, StatCounter> entryDate : dateCount.entrySet()) {
                StatCounter counter = entryDate.getValue();
                targetList.add(counter);
            }
            result.add(action);
        }
        t = System.currentTimeMillis() - t;
        //TODO add warning level to X ms:
        if (t > 1000) {
            log.warn("getTargetStats query fetch: {}\n took {}s", debugTrim(query), t / 1000.0);
        } else {
            log.info("getTargetStats processed {} results in {}ms", processed, t);
        }
    } catch (Exception ex) {
        log.error("getTargetStats", ex);
        if (ex instanceof StatsEngineException) {
            throw (StatsEngineException) ex;
        }
        throw new StatsEngineException("getTargetStats", ex);
    } finally {
        MongoUtil.close(dbc);
    }
    return result;
}

From source file:org.mybatis.jpetstore.domain.Item.java

License:Apache License

public static Item fromDBObject(@Nonnull final DBObject dbObj) {

    checkNotNull(dbObj, "Argument[dbObj] must not be null");

    BasicDBObject itemObj = (BasicDBObject) dbObj;

    DBObject productObj = (DBObject) itemObj.get("product");
    ItemBuilder builder = new ItemBuilder(itemObj.getString("item_id"), Product.fromDBObject(productObj));
    if (itemObj.get("supplier_id") != null) {
        builder.supplierId(itemObj.getInt("supplier_id"));
    }/*w  ww .j a va  2s .com*/
    String listPrice = itemObj.getString("list_price");
    if (!isNullOrEmpty(listPrice)) {
        builder.listPrice(decodeRealNumber(listPrice));
    }
    String unitCost = itemObj.getString("unit_cost");
    if (!isNullOrEmpty(unitCost)) {
        builder.unitCost(decodeRealNumber(unitCost));
    }

    builder.status(itemObj.getString("status")).quantity(itemObj.getInt("quantity"))
            .attribute1(itemObj.getString("attribute_1")).attribute2(itemObj.getString("attribute_2"))
            .attribute3(itemObj.getString("attribute_3")).attribute4(itemObj.getString("attribute_4"))
            .attribute5(itemObj.getString("attribute_5"));

    return builder.build();
}

From source file:org.mybatis.jpetstore.domain.LineItem.java

License:Apache License

public static LineItem fromDBObject(@Nonnull final DBObject dbObj) {

    checkNotNull(dbObj, "Argument[dbObj] must not be null");

    BasicDBObject lineItemObj = (BasicDBObject) dbObj;
    LineItem lineItem = new LineItem();

    lineItem.setLineNumber(lineItemObj.getInt("line_number"));
    lineItem.setItemId(lineItemObj.getString("item_id"));

    String unitPrice = lineItemObj.getString("unit_price");
    if (!isNullOrEmpty(unitPrice)) {
        lineItem.setUnitPrice(new BigDecimal(unitPrice));
    }//  w ww.jav  a2  s  . c  o  m
    lineItem.setQuantity(lineItemObj.getInt("quantity"));

    return lineItem;
}

From source file:org.mybatis.jpetstore.domain.Order.java

License:Apache License

public static Order fromDBObject(@Nonnull final DBObject dbObj) {

    checkNotNull(dbObj, "Argument[dbObj] must not be null");

    BasicDBObject orderObj = (BasicDBObject) dbObj;
    Order order = new Order();

    order.setOrderId(orderObj.getInt("order_id"));
    order.setUsername(orderObj.getString("username"));
    order.setOrderDate(orderObj.getDate("order_date"));
    order.setCourier(orderObj.getString("courier"));

    String totalPrice = orderObj.getString("total_price");
    if (!isNullOrEmpty(totalPrice)) {
        order.setTotalPrice(new BigDecimal(totalPrice));
    }//from w w  w  .  ja  v a 2s  .co  m
    order.setLocale(orderObj.getString("locale"));
    order.setStatus(orderObj.getString("status"));

    BasicDBObject shipToObj = (BasicDBObject) orderObj.get("shipping_address");
    order.setShipToFirstName(shipToObj.getString("ship_to_firstname"));
    order.setShipToLastName(shipToObj.getString("ship_to_lastname"));
    order.setShipAddress1(shipToObj.getString("ship_address_1"));
    order.setShipAddress2(shipToObj.getString("ship_address_2"));
    order.setShipCity(shipToObj.getString("ship_city"));
    order.setShipState(shipToObj.getString("ship_state"));
    order.setShipZip(shipToObj.getString("ship_zip"));
    order.setShipCountry(shipToObj.getString("ship_country"));

    BasicDBObject billToObj = (BasicDBObject) orderObj.get("billing_address");
    order.setBillToFirstName(billToObj.getString("bill_to_firstname"));
    order.setBillToLastName(billToObj.getString("bill_to_lastname"));
    order.setBillAddress1(billToObj.getString("bill_address_1"));
    order.setBillAddress2(billToObj.getString("bill_address_2"));
    order.setBillCity(billToObj.getString("bill_city"));
    order.setBillState(billToObj.getString("bill_state"));
    order.setBillZip(billToObj.getString("bill_zip"));
    order.setBillCountry(billToObj.getString("bill_country"));

    BasicDBObject paymentInfoObj = (BasicDBObject) orderObj.get("payment_info");
    order.setCreditCard(paymentInfoObj.getString("credit_card"));
    order.setExpiryDate(paymentInfoObj.getString("expiry_date"));
    order.setCardType(paymentInfoObj.getString("card_type"));

    List<DBObject> lineItemObjs = (ArrayList<DBObject>) orderObj.get("line_items");
    List<LineItem> lineItems = new ArrayList<>();

    for (DBObject lineItemObj : lineItemObjs) {
        LineItem lineItem = LineItem.fromDBObject(lineItemObj);
        lineItem.setOrderId(order.getOrderId());
        lineItems.add(lineItem);
    }
    order.setLineItems(lineItems);
    return order;
}

From source file:org.mybatis.jpetstore.domain.Sequence.java

License:Apache License

public static Sequence fromDBObject(@Nullable final BasicDBObject sequenceObj) {

    Sequence sequence = null;//w ww. j av a  2  s .  co  m

    if (sequenceObj != null) {
        String name = sequenceObj.getString("name");
        Integer nextId = sequenceObj.getInt("next_id");
        sequence = new Sequence(name, nextId);
    }
    return sequence;
}

From source file:org.opencb.cellbase.mongodb.db.ConservationMongoDBAdaptor.java

License:Apache License

@Deprecated
@Override//from w  ww  .j  av  a2  s .  c  o m
public List<QueryResult> getAllByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<String> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        /****/
        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), this.chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            ////                    integerChunkIds.add(chunkId);
            //                    integerChunkIds.add(region.getChromosome() + "_" + chunkId + "_" + this.chunkSize/1000 + "k");
            //                }
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.info(builder.get().toString());
    }

    List<QueryResult> queryResults = executeQueryList(ids, queries, options);

    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        BasicDBList list = (BasicDBList) queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                //                    System.out.println("valuesList SIZE = " + valuesList.size());
                //                    System.out.println("pos = " + pos);
                //                    System.out.println("DIV " + (chunk.getInt("start") - region.getStart()));
                //                    System.out.println("valuesChunk = " + valuesChunk.get(pos));
                //                    System.out.println("indexFinal = " + (pos + chunk.getInt("start") - region.getStart()));
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }
        //
        BasicDBList resultList = new BasicDBList();
        ConservedRegionFeature conservedRegionChunk;
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            conservedRegionChunk = new ConservedRegionFeature(region.getChromosome(), region.getStart(),
                    region.getEnd(), elem.getKey(), elem.getValue());
            resultList.add(conservedRegionChunk);
        }
        queryResult.setResult(resultList);
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.ConservationMongoDBAdaptor.java

License:Apache License

@Override
public List<QueryResult> getAllScoresByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<Integer> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);//from  ww  w. j a  va 2  s .c om
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        /****/
        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            //                    integerChunkIds.add(chunkId);
            //                }
            //    //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.info(builder.get().toString());

    }
    List<QueryResult> queryResults = executeQueryList2(ids, queries, options);
    //        List<QueryResult> queryResults = executeQueryList(ids, queries, options);

    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        List<BasicDBObject> list = (List<BasicDBObject>) queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }

        BasicDBList resultList = new BasicDBList();
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            for (Float value : elem.getValue()) {
                resultList.add(value != null ? (new Score(new Double(value), elem.getKey())) : null);
            }
        }
        queryResult.setResult(resultList);
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.core.ConservationMongoDBAdaptor.java

License:Apache License

@Deprecated
@Override/* w  w  w  . j  a va2s  . c  om*/
public List<QueryResult> getAllByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<String> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        // Max region size is 10000bp
        if (region.getEnd() - region.getStart() > 10000) {
            region.setEnd(region.getStart() + 10000);
        }

        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), this.chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            ////                    integerChunkIds.add(chunkId);
            //                    integerChunkIds.add(region.getChromosome() + "_" + chunkId + "_" + this.chunkSize/1000 + "k");
            //                }
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.debug(builder.get().toString());
    }

    List<QueryResult> queryResults = executeQueryList2(ids, queries, options);
    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        //            BasicDBList list = (BasicDBList) queryResult.getResult();
        List list = queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                //                    System.out.println("valuesList SIZE = " + valuesList.size());
                //                    System.out.println("pos = " + pos);
                //                    System.out.println("DIV " + (chunk.getInt("start") - region.getStart()));
                //                    System.out.println("valuesChunk = " + valuesChunk.get(pos));
                //                    System.out.println("indexFinal = " + (pos + chunk.getInt("start") - region.getStart()));
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }
        //
        BasicDBList resultList = new BasicDBList();
        ConservedRegionFeature conservedRegionChunk;
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            conservedRegionChunk = new ConservedRegionFeature(region.getChromosome(), region.getStart(),
                    region.getEnd(), elem.getKey(), elem.getValue());
            resultList.add(conservedRegionChunk);
        }
        queryResult.setResult(resultList);
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.core.ConservationMongoDBAdaptor.java

License:Apache License

@Override
public List<QueryResult> getAllScoresByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<Integer> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);//from  w  w  w . j a  v a2 s .  c o m
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        /****/
        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            //                    integerChunkIds.add(chunkId);
            //                }
            //    //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.debug(builder.get().toString());

    }
    List<QueryResult> queryResults = executeQueryList2(ids, queries, options);
    //        List<QueryResult> queryResults = executeQueryList(ids, queries, options);

    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        List<BasicDBObject> list = (List<BasicDBObject>) queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }

        BasicDBList resultList = new BasicDBList();
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            for (Float value : elem.getValue()) {
                if (value != null) {
                    resultList.add(new Score(new Double(value), elem.getKey()));
                }
            }
        }
        if (!resultList.isEmpty()) {
            queryResult.setResult(resultList);
        } else {
            queryResult.setResult(null);
        }
    }

    return queryResults;
}