Esempio n. 1
0
  /** {@inheritDoc} */
  @SuppressWarnings("unchecked")
  @Override
  public Music toObject(DBObject doc) {

    List<DBObject> commentDocs = (List<DBObject>) doc.get("comments");
    SortedSet<Comment> comments = new TreeSet<Comment>();
    String fileId;

    for (DBObject commentDoc : commentDocs) {
      comments.add(commentConv.toObject(commentDoc));
    }

    if (doc.get("fileId") != null) {
      fileId = ((ObjectId) doc.get("fileId")).toString();
    } else {
      fileId = "";
    }

    Music music =
        new Music(
            ((ObjectId) doc.get("_id")).toString(),
            (Integer) doc.get("trackNumber"),
            (String) doc.get("title"),
            (String) doc.get("artistName"),
            (String) doc.get("albumName"),
            fileId,
            (List<String>) doc.get("tags"),
            comments);

    return music;
  }