List of usage examples for com.mongodb BasicDBObjectBuilder get
public DBObject get()
From source file:ezbake.services.centralPurge.helpers.EzCentralPurgeServiceHelpers.java
License:Apache License
public static DBObject encodeServicePurgeState(ServicePurgeState servicePurgeState) { BasicDBObjectBuilder servicePurgeStateBuilder = BasicDBObjectBuilder.start() .add(PurgeStateString, encodePurgeState(servicePurgeState.getPurgeState())) .add(TimeInitiated, encodeDateTime(servicePurgeState.getTimeInitiated())) .add(TimeLastPoll, encodeDateTime(servicePurgeState.getTimeLastPoll())); return servicePurgeStateBuilder.get(); }
From source file:ezbake.services.centralPurge.helpers.EzCentralPurgeServiceHelpers.java
License:Apache License
public static DBObject encodeAgeOffEventInfo(AgeOffEventInfo ageOffEventInfo) { BasicDBObjectBuilder ageOffEventInfoBuilder = BasicDBObjectBuilder.start() .add(User, ageOffEventInfo.getUser()) .add(CompletelyPurged, encodeURISet(ageOffEventInfo.getCompletelyPurgedSet())) .add(AgeOffEventId, ageOffEventInfo.getId()) .add(PurgeBitVector, encodeURISet(ageOffEventInfo.getPurgeSet())) .add(TimeCreated, encodeDateTime(ageOffEventInfo.getTimeCreated())) .add(Description, ageOffEventInfo.getDescription()).add(Resolved, ageOffEventInfo.isResolved()); return ageOffEventInfoBuilder.get(); }
From source file:ezbake.services.centralPurge.helpers.EzCentralPurgeServiceHelpers.java
License:Apache License
public static DBObject encodeCentralAgeOffEventState(CentralAgeOffEventState centralAgeOffEventState) { BasicDBObjectBuilder centralAgeOffEventStateBuilder = BasicDBObjectBuilder.start() .add(AgeOffEventInfoString, encodeAgeOffEventInfo(centralAgeOffEventState.getAgeOffEventInfo())) .add(AppStates, encodeApplicationStateMap(centralAgeOffEventState.getApplicationStates())) .add(CentralPurgeStatusString, centralAgeOffEventState.getCentralStatus().getValue()) .add(AgeOffRuleId, centralAgeOffEventState.getAgeOffRuleId()); return centralAgeOffEventStateBuilder.get(); }
From source file:ezbake.services.centralPurge.helpers.EzCentralPurgeServiceHelpers.java
License:Apache License
public static DBObject encodePurgeInfo(PurgeInfo purgeInfo) { BasicDBList basicDBListUris = new BasicDBList(); for (String uri : purgeInfo.getDocumentUris()) { BasicDBObject dbURI = new BasicDBObject(); dbURI.append(URI, uri);// w w w . java2 s . co m basicDBListUris.add(dbURI); } BasicDBList basicDBListUrisNotFound = new BasicDBList(); for (String uriNotFound : purgeInfo.getDocumentUrisNotFound()) { BasicDBObject dbURINotFound = new BasicDBObject(); dbURINotFound.append(URI, uriNotFound); basicDBListUris.add(dbURINotFound); } BasicDBObjectBuilder purgeInfoBuilder = BasicDBObjectBuilder.start().add(PurgeId, purgeInfo.getId()) .add(PurgeBitVector, encodeURISet(purgeInfo.getPurgeDocumentIds())) .add(Description, purgeInfo.getDescription()).add(PurgeName, purgeInfo.getName()) .add(User, purgeInfo.getUser()) .add(CompletelyPurged, encodeURISet(purgeInfo.getCompletelyPurgedDocumentIds())) .add(Resolved, purgeInfo.isResolved()).add(URIsFoundSet, basicDBListUris) .add(URIsNotFoundSet, basicDBListUrisNotFound) .add(TimeStampString, encodeDateTime(purgeInfo.getTimeStamp())); return purgeInfoBuilder.get(); }
From source file:ezbake.services.centralPurge.helpers.EzCentralPurgeServiceHelpers.java
License:Apache License
public static DBObject encodeCentralPurgeState(CentralPurgeState centralPurgeState) { BasicDBObjectBuilder centralPurgeStateBuilder = BasicDBObjectBuilder.start() .add(PurgeInfo, encodePurgeInfo(centralPurgeState.getPurgeInfo())) .add(AppStates, encodeApplicationStateMap(centralPurgeState.getApplicationStates())) .add(CentralPurgeStatusString, centralPurgeState.getCentralStatus().getValue()) .add(CentralPurgeTypeString, centralPurgeState.getCentralPurgeType().getValue()); return centralPurgeStateBuilder.get(); }
From source file:fr.ensimag.biblio.converter.UserConverter.java
public static DBObject toDBObject(User user) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().append("lastName", user.getLastName()) .append("firstName", user.getFirstName()).append("login", user.getLogin()) .append("password", user.getPassword()).append("isMale", user.getIsMale()) .append("age", user.getAge()).append("town", user.getTown()); if (user.getId() != null) builder = builder.append("_id", new ObjectId(user.getId())); return builder.get(); }
From source file:mongocrud.AddWindow.java
private static DBObject create(Student s) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); builder.append("name", s.getName()); builder.append("age", s.getAge()); builder.append("_id", s.getId()); return builder.get(); }
From source file:mongofx.js.api.Collection.java
License:Open Source License
public ObjectListPresentation distinct(String key, Bindings query) { BasicDBObjectBuilder command = new BasicDBObjectBuilder() // .add("distinct", name) // .add("key", key); // if (query != null) { command.add("query", query); }/*from ww w . java2s. com*/ return singletonIter(mongoDatabase.getMongoDb().runCommand((Bson) command.get())); }
From source file:mongofx.js.api.Collection.java
License:Open Source License
public ObjectListPresentation mapReduce(String map, String reduce, Bindings options) { BasicDBObjectBuilder command = new BasicDBObjectBuilder(); command.add("mapReduce", name); command.add("map", map); command.add("reduce", reduce); putObject("query", options, command); putObject("out", options, command); putObject("scope", options, command); putSimpleField("field", options, command); putSimpleField("jsMode", options, command); putSimpleField("finilize", options, command); putSimpleField("verbose", options, command); return singletonIter(mongoDatabase.getMongoDb().runCommand((Bson) command.get())); }
From source file:net.tbnr.gearz.arena.ArenaManager.java
License:Open Source License
/** * Converts an Arena object into a DB Object that can be reversed using the other method (which is not static) * * @param arena The arena to convert into a DBObject * @return The DBObject version of this Arena. *//*from ww w. j ava2 s . c o m*/ public static DBObject objectFromArena(Arena arena) { BasicDBObjectBuilder objectBuilder = new BasicDBObjectBuilder(); //Start building the database object for this arena for (Field field : arena.getClass().getFields()) { //Get all the fields ... if (!field.isAnnotationPresent(ArenaField.class)) { continue; //... that we can access, and are annotated by ArenaField ... } ArenaField annotation = field.getAnnotation(ArenaField.class); //Get the Annotation from the field as an object ArenaIterator iterator; //Setup an object to put the iterator in try { iterator = (ArenaIterator) field.get(arena); //Try to getSetting the arena iterator } catch (IllegalAccessException e) { continue; //Didn't work :o } BasicDBList list = new BasicDBList(); //Pour our list into the DB List object while (iterator.hasNext()) { Object next = iterator.next(); ArenaFieldSerializer.SerializationDelegate<?> serializerFor = ArenaFieldSerializer .getSerializerFor(next.getClass()); if (serializerFor == null) continue; list.add(serializerFor.getObjectFor(next)); //Add whatever "next" is now. Depending on code above, it could be a DBObject, or whatever the iterator has in store. } objectBuilder.append(annotation.key(), list); //Put that in the database } objectBuilder.append("name", arena.getName()); //Meta for a bit. objectBuilder.append("description", arena.getDescription()); objectBuilder.append("worldId", arena.getWorldId()); objectBuilder.append("last-updated", Calendar.getInstance().getTimeInMillis()); objectBuilder.append("author", arena.getAuthors()); if (arena.getId() != null) { objectBuilder.append("_id", new ObjectId(arena.getId())); //Good for replacing/updating } return objectBuilder.get(); //Finish the object off! :D }