Exemple #1
0
 public static User getUserfromDBObject(BasicDBObject obj) {
   // return new User(obj.getString(ID), Name.getNamefromDBObject((BasicDBObject)obj.get(NAME)),
   // com.qpeka.db.book.store.tuples.Constants.GENDER.valueOf(obj.getString(GENDER)), identities,
   // address, interests, type, bookMarks, age, dob, nationality, imageFile)
   BasicDBObject name = (BasicDBObject) obj.get("name");
   return new User(
       obj.getString(USERNAME),
       obj.getString(ID),
       new Name(
           name.getString(Name.FIRSTNAME),
           name.getString(Name.MIDDLENAME),
           name.getString(Name.LASTNAME)),
       com.qpeka.db.book.store.tuples.Constants.GENDER.valueOf(obj.getString(GENDER)),
       new Address("", "", "", "", "", ""),
       new HashSet<CATEGORY>(),
       com.qpeka.db.book.store.tuples.Constants.USERLEVEL.valueOf(obj.getString(USERLEVEL)),
       com.qpeka.db.book.store.tuples.Constants.USERTYPE.valueOf(obj.getString(USERTYPE)),
       new ArrayList(),
       obj.getInt(AGE),
       new Date(obj.getLong(DOB)),
       obj.getString(NATIONALITY),
       obj.getString(IMAGEFILE),
       obj.getString(EMAIL),
       obj.getString(PHONE),
       obj.getString(PENNAME),
       LANGUAGES.valueOf(obj.getString(RLANG)),
       LANGUAGES.valueOf(obj.getString(WLANG)),
       obj.getString(DESC));
 }
Exemple #2
0
  public DBObject toDBObject(boolean insert) {
    BasicDBObject dbObj = new BasicDBObject();

    if (!insert) dbObj.put(ID, new ObjectId(_id));

    dbObj.put(USERNAME, this.userName);
    dbObj.put(NAME, name.toDBObject());
    dbObj.put(DOB, dob.getTime());
    dbObj.put(USERTYPE, type.toString());
    dbObj.put(USERLEVEL, userlevel.toString());
    dbObj.put(GENDER, gender.toString());
    dbObj.put(NATIONALITY, nationality);
    dbObj.put(IMAGEFILE, imageFile);
    dbObj.put(ADDRESS, address.toDBObject());
    dbObj.put(INTERESTS, interests.toString());
    dbObj.put(EMAIL, email);
    dbObj.put(AGE, age);
    dbObj.put(DESC, desc);
    dbObj.put(RLANG, rLang.toString());
    dbObj.put(WLANG, wLang.toString());
    dbObj.put(PENNAME, penName);

    Set<BasicDBObject> bookMarkSet = new HashSet<BasicDBObject>();
    for (BookMark mark : bookMarks) {
      bookMarkSet.add((BasicDBObject) mark.toDBObject());
    }

    dbObj.put(BOOKMARKS, bookMarkSet);
    dbObj.put(PHONE, phone);

    return dbObj;
  }