List of usage examples for com.mongodb BasicDBObjectBuilder get
public DBObject get()
From source file:converter.AtmConverter.java
public static DBObject toDBObject(Atm a) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start() .append("walk", WalkConverter.toDBObject(a.getWalk())) .append("drive", DriveConverter.toDBObject(a.getDrive())); return builder.get(); }
From source file:converter.DoctorConverter.java
public static DBObject toDBObject(Doctor d) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start() .append("walk", WalkConverter.toDBObject(d.getWalk())) .append("drive", DriveConverter.toDBObject(d.getDrive())); return builder.get(); }
From source file:converter.DriveConverter.java
public static DBObject toDBObject(Drive d) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().append("name", d.getName()) .append("lat", d.getLatitude()).append("long", d.getLongitude()).append("time", d.getTime()) .append("distance", d.getDistance()); // if (a.getId() != null) { // builder = builder.append("_id", new ObjectId(a.getId())); // }// w w w . j av a 2 s . com return builder.get(); }
From source file:converter.KindergartenConverter.java
public static DBObject toDBObject(Kindergarten k) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start() .append("walk", WalkConverter.toDBObject(k.getWalk())) .append("drive", DriveConverter.toDBObject(k.getDrive())); return builder.get(); }
From source file:converter.OfferConverter.java
public static DBObject toDBObject(Offer of) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().append("address", of.getAddress()) .append("lat", of.getLatitude()).append("long", of.getLongitude()).append("type", of.getType()) .append("price", of.getPrice()).append("link", of.getLink()).append("rooms", of.getRooms()) .append("floor", of.getFloor()).append("m2", of.getM2()); if (of.getId() != null) { builder = builder.append("_id", new ObjectId(of.getId())); }/*from ww w . j a v a 2 s . c om*/ return builder.get(); }
From source file:converter.PollutionConverter.java
public static DBObject toDBObject(Pollution p) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().append("name", p.getName()) .append("rate", p.getRate()).append("lat", p.getLatitude()).append("long", p.getLongitude()) .append("distance", p.getDistance()); return builder.get(); }
From source file:converter.SquareConverter.java
public static DBObject toDBObject(Square s) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().append("lat", s.getLatitude()) .append("long", s.getLongitude()).append("atm", AtmConverter.toDBObject(s.getNearestAtm())) .append("supermarket", SupermarketConverter.toDBObject(s.getNearestSupermarket())) .append("doctor", DoctorConverter.toDBObject(s.getNearestDoctor())) .append("kindergarten", KindergartenConverter.toDBObject(s.getNearestKindergarten())) .append("pollution", PollutionConverter.toDBObject(s.getPollution())); if (s.getId() != null) builder = builder.append("_id", new ObjectId(s.getId())); return builder.get(); }
From source file:converter.SupermarketConverter.java
public static DBObject toDBObject(Supermarket s) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start() .append("walk", WalkConverter.toDBObject(s.getWalk())) .append("drive", DriveConverter.toDBObject(s.getDrive())); return builder.get(); }
From source file:converter.WalkConverter.java
public static DBObject toDBObject(Walk w) { BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().append("name", w.getName()) .append("lat", w.getLatitude()).append("long", w.getLongitude()).append("time", w.getTime()); // if (a.getId() != null) { // builder = builder.append("_id", new ObjectId(a.getId())); // }// ww w .j a va2 s. c o m return builder.get(); }
From source file:de.belaso.mongolyn.ui.TaskDataHandler.java
License:Open Source License
@Override public RepositoryResponse postTaskData(TaskRepository repository, TaskData taskData, Set<TaskAttribute> oldAttributes, IProgressMonitor monitor) throws CoreException { DBCollection dbCollection = MongolynUtils.getDBCollection(repository); BasicDBObjectBuilder bob = BasicDBObjectBuilder.start(); for (Map.Entry<String, TaskAttribute> entry : taskData.getRoot().getAttributes().entrySet()) { String key = entry.getKey(); TaskAttribute attribute = entry.getValue(); String attributeValue = attribute.getValue(); if (attributeValue != null) { bob.add(key.replace('.', '_'), attributeValue); }/* w w w . j av a 2 s . c o m*/ } DBObject dbObject = bob.get(); try { if (taskData.isNew()) { dbCollection.insert(dbObject, WriteConcern.SAFE); return new RepositoryResponse(ResponseKind.TASK_CREATED, dbObject.get("_id").toString()); } else { dbCollection.findAndModify(new BasicDBObject("_id", new ObjectId(taskData.getTaskId())), dbObject); return new RepositoryResponse(ResponseKind.TASK_UPDATED, taskData.getTaskId()); } } catch (MongoException mongoException) { throw new CoreException(Activator.INSTANCE.getErrorStatus(mongoException)); } }