Exemplo n.º 1
0
 public Comment saveComment(Comment comment) {
   try (ODatabaseDocumentTx database = getODatabaseDocumentTx()) {
     ODocument doc = new ODocument("Comment");
     doc.field("body", comment.getBody());
     doc.field("parent", comment.getParent() != null ? new ORecordId(comment.getParent()) : null);
     doc.field("case", comment.getCase() != null ? new ORecordId(comment.getCase()) : null);
     doc.field("task", comment.getTask() != null ? new ORecordId(comment.getTask()) : null);
     doc.field("createDate", new Date());
     doc.field("creator", user.getId());
     doc = doc.save();
     database.commit();
     return oDocumentToComment(doc);
   }
 }
Exemplo n.º 2
0
 private Comment oDocumentToComment(ODocument doc) {
   Comment comment = new Comment();
   comment.setId(doc.getIdentity().toString());
   comment.setBody(doc.field("body").toString());
   comment.setParent(
       doc.field("parent") != null
           ? ((OIdentifiable) doc.field("parent")).getIdentity().toString()
           : null);
   comment.setTask(
       doc.field("task") != null
           ? ((OIdentifiable) doc.field("task")).getIdentity().toString()
           : null);
   comment.setCase(
       doc.field("case") != null
           ? ((OIdentifiable) doc.field("case")).getIdentity().toString()
           : null);
   comment.setCreator(
       doc.field("creator") != null
           ? ((OIdentifiable) doc.field("creator")).getIdentity().toString()
           : null);
   comment.setCreateDate(
       doc.field("createDate") != null ? (Date) doc.field("createDate", Date.class) : null);
   return comment;
 }