List of usage examples for com.mongodb BasicDBObject getInt
public int getInt(final String key)
From source file:fr.eolya.crawler.queue.mongodb.MongoDBSourceItemsQueue.java
License:Apache License
public int getCurrentMaxDepth() { //String queryTimeStamp = "{\"" + timestampFieldName + "\": {\"$ne\": " + String.valueOf(startTime) + "}}"; //String queryMode = "{\"crawl_mode\":a}"; //String query = "{\"$and\": [" + queryTimeStamp + ", " + queryMode + "]}"; String query1 = "{\"crawl_mode\":\"a\"}"; String query2 = "{\"crawl_status\":200}"; String query = "{\"$and\": [" + query1 + ", " + query2 + "]}"; BasicDBObject docsearch = new BasicDBObject(); docsearch = MongoDBHelper.JSON2BasicDBObject(query); DBCursor cur = coll.getColl().find(docsearch).sort(new BasicDBObject("depth", -1)); if (cur.count() == 0) return 0; BasicDBObject doc = (BasicDBObject) cur.next(); return doc.getInt("depth"); }
From source file:laboratorio_2_sd.Documento.java
public Documento(BasicDBObject dBObject) { this.idDoc = dBObject.getInt("idDoc"); this.titulo = dBObject.getString("titulo"); this.usuario = dBObject.getString("usuario"); this.url = dBObject.getString("url"); this.cantPalabras = dBObject.getInt("cantPalabras"); }
From source file:laboratorio_2_sd.Frecuencia.java
public Frecuencia(BasicDBObject f) { this.idDocumento = f.getInt("idDocumento"); this.frecuencia = f.getInt("frecuencia"); }
From source file:laboratorio_2_sd.IndiceInvertido.java
public IndiceInvertido(BasicDBObject DBObject) { this.idPalabra = DBObject.getInt("idPalabra"); BasicDBList frecuenciasDB = (BasicDBList) DBObject.get("frecuencias"); this.frecuencias = new ArrayList<>(); for (Object f : frecuenciasDB) { Frecuencia fTemp = new Frecuencia((BasicDBObject) f); this.frecuencias.add(fTemp); }//from w ww. j a v a2s . co m }
From source file:laboratorio_2_sd.Vocabulario.java
public Vocabulario(BasicDBObject dBObject) { this.idPalabra = dBObject.getInt("idPalabra"); this.palabra = dBObject.getString("palabra"); this.cantDocumentos = dBObject.getInt("cantDocumentos"); }
From source file:mdb.utilMongoDB.java
public List<SimpleFeeling> getFeeling(int presentationId, int userId, boolean getPropertires, boolean getUserId) { ArrayList<SimpleFeeling> listFeeling = new ArrayList<>(); BasicDBObject query = new BasicDBObject("presentationId", presentationId); if (getUserId) { query.append("userId", userId); }//from w w w . j a va 2 s. c o m try (DBCursor cursor = getPresentationData().find(query)) { cursor.sort(new BasicDBObject("time", 1)); while (cursor.hasNext()) { DBObject feeling = cursor.next(); SimpleFeeling sFeeling = new SimpleFeeling(presentationId, (int) feeling.get("userId"), (int) feeling.get("feelingId"), (int) feeling.get("previousFeelingId"), (long) feeling.get("time")); if (getPropertires) { sFeeling.setPropertires(new ArrayList<SimpleProperty>()); for (BasicDBObject prop : (List<BasicDBObject>) feeling.get("propertires")) { sFeeling.getPropertires().add( new SimpleProperty(prop.getInt("propertireId"), prop.getString("propertireValue"))); } } listFeeling.add(sFeeling); } } return listFeeling; }
From source file:net.jurre.edutil.persistence.MongoDB.java
License:Open Source License
private int getSystemID(String systemName) { DBCollection systems = this.db.getCollection(SYSTEMS_COLLECTION); int systemID = -1; BasicDBObject system = (BasicDBObject) systems.findOne(new BasicDBObject("name", systemName)); if (system != null) systemID = system.getInt("id"); return systemID; }
From source file:no.nlf.avvik.melwinSOAPconnection.MongoOperations.java
/** * //from w ww . j a va2 s . c o m * @return */ public ArrayList<Club> getClubsFromDb() { ArrayList<Club> clubs = new ArrayList<>(); DBCollection dbCollectionClubs = db.getCollection("clubs"); DBCursor cursor = dbCollectionClubs.find(); BasicDBObject mongoObject = new BasicDBObject(); if (cursor == null) System.out.println("Cursor er null"); try { while (cursor.hasNext()) { mongoObject = (BasicDBObject) cursor.next(); clubs.add(new Club(mongoObject.getObjectId("_id"), mongoObject.getInt("id"), mongoObject.getString("melwinId"), mongoObject.getString("name"), mongoObject.getString("chiefInstructorMelwinId"))); } } finally { cursor.close(); } return clubs; }
From source file:no.nlf.avvik.melwinSOAPconnection.MongoOperations.java
/** * //from w w w . j av a2 s. c o m * @return */ public ArrayList<License> getLicensesFromDb() { ArrayList<License> licenses = new ArrayList<>(); DBCollection dbCollectionLicenses = db.getCollection("licenses"); DBCursor cursor = dbCollectionLicenses.find(); BasicDBObject mongoObject = new BasicDBObject(); if (cursor == null) System.out.println("Cursor er null, licenses"); try { while (cursor.hasNext()) { mongoObject = (BasicDBObject) cursor.next(); licenses.add(new License(mongoObject.getObjectId("_id"), mongoObject.getInt("id"), mongoObject.getString("melwinId"), mongoObject.getString("licenseName"), null, null)); } } finally { cursor.close(); } return licenses; }
From source file:no.nlf.avvik.melwinSOAPconnection.MongoOperations.java
/** * /*from w w w . j av a 2 s .c o m*/ * @param parachutistsFromMelwin */ public ArrayList<Parachutist> getParachutistsFromDB() { // HjelpeLister ArrayList<Club> clubs = getClubsFromDb(); ArrayList<License> licenses = getLicensesFromDb(); ArrayList<Parachutist> parachutistsInMongoDB = new ArrayList<>(); DBCollection dbCollectionParachutists = db.getCollection("jumpers"); DBCursor cursor = dbCollectionParachutists.find(); BasicDBObject mongoObject = new BasicDBObject(); try { int hoppteller = 0; while (cursor.hasNext()) { mongoObject = (BasicDBObject) cursor.next(); hoppteller++; ArrayList<Club> memberClubs = new ArrayList<>(); ArrayList<License> memberLicenses = new ArrayList<>(); BasicDBList referenceClubs = (BasicDBList) mongoObject.get("memberclubs"); BasicDBList referenceLicenses = (BasicDBList) mongoObject.get("licenses"); for (Object clubReference : referenceClubs) { for (Club club : clubs) { if ((int) clubReference == club.getId()) { memberClubs.add(club); } } } for (Object licenseReference : referenceLicenses) { for (License license : licenses) { if ((int) licenseReference == license.getId()) { memberLicenses.add(license); } } } Parachutist parachutist = new Parachutist(mongoObject.getObjectId("_id"), mongoObject.getInt("id"), mongoObject.getString("melwinId"), null, // nakKey new ArrayList<Club>(), // clubs new ArrayList<License>(), // licenses mongoObject.getString("firstname"), mongoObject.getString("lastname"), mongoObject.getDate("birthdate"), mongoObject.getString("gender"), mongoObject.getString("street"), mongoObject.getString("postnumber"), mongoObject.getString("postplace"), mongoObject.getString("mail"), mongoObject.getString("phone"), mongoObject.getString("password")); parachutist.setMemberclubs(memberClubs); parachutist.setLicenses(memberLicenses); parachutistsInMongoDB.add(parachutist); } } finally { cursor.close(); } return parachutistsInMongoDB; }