Package com.ikanow.infinit.e.data_model.store.document

Examples of com.ikanow.infinit.e.data_model.store.document.DocumentPojo.toDb()


      boolean bAssocs = (null != doc.getAssociations()) && !doc.getAssociations().isEmpty();
     
      if (bEnts || bAssocs) {       
        dummy.setEntities(doc.getEntities());
        dummy.setAssociations(doc.getAssociations());
        DBObject toWrite = dummy.toDb();
        BasicDBObject updateQuery = new BasicDBObject(DocumentPojo.sourceKey_, doc.getSourceKey());
        updateQuery.put(DocumentPojo._id_, doc.getId());
        MongoDbManager.getDocument().getMetadata().update(updateQuery, new BasicDBObject(MongoDbManager.set_, toWrite));
      }//TESTED
     
View Full Code Here


    else {
      newDoc.setScore(100.0);
      newDoc.setAggregateSignif(100.0);
    }
    if (null != docs) {
      docs.add(0, (BasicDBObject) newDoc.toDb());
    }
    response.getStats().found++;
  }

}
View Full Code Here

    BasicDBObject query = new BasicDBObject("metadata", new BasicDBObject("$exists", true)); // (complex query so can't represent using pojos)
    query.put("entities", new BasicDBObject("$size", 3));
    ////////////////////////////////////////////////
    //CANONICAL EXAMPLE:
    DocumentPojo doc = DocumentPojo.fromDb(documentDb.findOne(query), DocumentPojo.class);
    System.out.println("DOC1="+doc.toDb());
    BasicDBList dblTest = (BasicDBList) doc.toDb().get("entities");
    BasicDBObject dboTest = (BasicDBObject) dblTest.get(0);
    if (!dboTest.get("doccount").getClass().toString().equals("class java.lang.Long")) {
      throw new RuntimeException(dboTest.get("doccount").getClass().toString() + " SHOULD BE LONG");
    }
View Full Code Here

    query.put("entities", new BasicDBObject("$size", 3));
    ////////////////////////////////////////////////
    //CANONICAL EXAMPLE:
    DocumentPojo doc = DocumentPojo.fromDb(documentDb.findOne(query), DocumentPojo.class);
    System.out.println("DOC1="+doc.toDb());
    BasicDBList dblTest = (BasicDBList) doc.toDb().get("entities");
    BasicDBObject dboTest = (BasicDBObject) dblTest.get(0);
    if (!dboTest.get("doccount").getClass().toString().equals("class java.lang.Long")) {
      throw new RuntimeException(dboTest.get("doccount").getClass().toString() + " SHOULD BE LONG");
    }
    ////////////////////////////////////////////////
View Full Code Here

      throw new RuntimeException(dboTest.get("doccount").getClass().toString() + " SHOULD BE LONG");
    }
    ////////////////////////////////////////////////
    System.out.println("DOC2="+new Gson().toJson(doc));
    doc = DocumentPojo.fromDb(documentDb.findOne(query), new TypeToken<DocumentPojo>(){}); // (alternative to the prettier DocumentPojo.class, needed for container classes)
    System.out.println("DOC3="+doc.toDb());
    //DB: list example for doc
    Set<DocumentPojo> docset = DocumentPojo.listFromDb(documentDb.find(query).limit(3), new TypeToken<Set<DocumentPojo>>(){});
    System.out.println("DOCSET="+DocumentPojo.listToDb(docset, new TypeToken<Set<DocumentPojo>>(){}));
   
    // Shares - demonstrate mapping of _ids across to the API (and that binary data is discarded):
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.