List of usage examples for com.mongodb DBObject toMap
Map toMap();
From source file:com.jim.im.offline.repo.MessageConverter.java
License:Open Source License
private static ImMessage convert(DBObject dbObject) { ImMessage imMessage = new ImMessage(); imMessage.setCreateTime(0L);/*from w w w . j ava 2 s . c o m*/ Map map = dbObject.toMap(); for (String key : FIELD_KEYS) { Field field = FIELD_MAP.get(key); org.springframework.data.mongodb.core.mapping.Field annotation = field.getAnnotation(ALIAS_NAME); if (annotation != null) key = annotation.value(); field.setAccessible(true); Object value = getValue(field, map.get(key)); if (value == null) continue; ReflectionUtils.setField(field, imMessage, value); } return imMessage; }
From source file:com.kurniakue.trxreader.data.CustomerD.java
public <T extends Record> T find(String customerName, T result) { DBCursor cursor = customers.find(new BasicDBObject(F.CustomerName.name(), customerName)); if (!cursor.hasNext()) { return result; }// ww w. j a v a 2 s . c om DBObject dbobject = cursor.next(); result.putAll(dbobject.toMap()); return result; }
From source file:com.kurniakue.trxreader.data.CustomerD.java
public List<Customer> getAllCustomers() { List<Customer> list = new ArrayList<>(); DBCursor cursor = customers.find();//w w w . j a v a 2s .c o m while (cursor.hasNext()) { DBObject dbobject = cursor.next(); Customer customer = new Customer(String.valueOf(dbobject.get(F.CustomerName.name()))); customer.putAll(dbobject.toMap()); list.add(customer); } return list; }
From source file:com.kurniakue.trxreader.data.CustomerD.java
public Customer delete(String customerName) { DBObject dbobject = customers.findOne(new BasicDBObject(F.CustomerName.name(), customerName)); if (dbobject == null) { return new Customer(); }// w w w. j a v a2 s . c o m Customer result = new Customer(); result.putAll(dbobject.toMap()); customers.remove(dbobject); return result; }
From source file:com.kurniakue.trxreader.data.ItemD.java
public Item find(String itemNo, Item result) { DBCursor cursor = items.find(new BasicDBObject(F.ItemNo.name(), itemNo)); if (!cursor.hasNext()) { return result; }//from w ww.j a v a 2 s . c om DBObject dbobject = cursor.next(); result.putAll(dbobject.toMap()); return result; }
From source file:com.kurniakue.trxreader.data.PropD.java
public Prop find(String propertyName, Prop result) { DBCursor cursor = props.find(new BasicDBObject(F.PropertyName.name(), propertyName)); if (!cursor.hasNext()) { return result; }/*from w w w . ja v a 2 s . co m*/ DBObject dbobject = cursor.next(); result.putAll(dbobject.toMap()); return result; }
From source file:com.kurniakue.trxreader.data.Record.java
public static Record r(DBObject dbObject) { final Record record = new Record(); record.putAll(dbObject.toMap()); return record; }
From source file:com.kurniakue.trxreader.data.TransactionD.java
public Transaction delete(int transactionId) { DBObject dbobject = transactions.findOne(new BasicDBObject(F.TransactionID.name(), transactionId)); if (dbobject == null) { return new Transaction(); }/* w w w .ja v a 2 s .co m*/ Transaction result = new Transaction(); result.putAll(dbobject.toMap()); transactions.remove(dbobject); return result; }
From source file:com.kurniakue.trxreader.data.TransactionD.java
public Transaction find(int transactionId, Transaction result) { DBObject dbobject = transactions.findOne(new BasicDBObject(F.TransactionID.name(), transactionId)); if (dbobject == null) { return result; }// w w w . java 2 s. co m result.putAll(dbobject.toMap()); return result; }
From source file:com.kurniakue.trxreader.data.TransactionD.java
public List<Transaction> getTransactionsByDate(String dateStr) { List<Transaction> list = new ArrayList<>(); if (dateStr == null) { return list; }/*from w w w.j a v a2 s. co m*/ DBCursor cursor; if ("".equals(dateStr)) { cursor = transactions.find(); } else { cursor = transactions.find(new BasicDBObject(F.Date.name(), dateStr)); } while (cursor.hasNext()) { DBObject dbobject = cursor.next(); Transaction transaction = new Transaction(); transaction.putAll(dbobject.toMap()); list.add(transaction); } return list; }