protected static Comment fillCommentEntity(JsonNode jn, Comment comment) { // don't read id from given JsonNode, if needed it is read from path comment.setParentId(jn.get(COMMENT_PARENT_ID_FIELD).textValue()); comment.setAuthor(jn.get(COMMENT_AUTHOR_FIELD).textValue()); comment.setText(jn.get(COMMENT_TEXT_FIELD).textValue()); JsonNode creationDateNode = jn.get(COMMENT_CREATION_DATE_FIELD); Instant creationDate = creationDateNode != null && !creationDateNode.isNull() ? Instant.parse(creationDateNode.textValue()) : null; comment.setCreationDate(creationDate); JsonNode modificationDateNode = jn.get(COMMENT_MODIFICATION_DATE_FIELD); Instant modificationDate = modificationDateNode != null && !modificationDateNode.isNull() ? Instant.parse(modificationDateNode.textValue()) : null; comment.setModificationDate(modificationDate); if (jn.has(EXTERNAL_ENTITY_ID)) { ExternalEntity externalEntity = (ExternalEntity) comment; externalEntity.setEntityId(jn.get(EXTERNAL_ENTITY_ID).textValue()); externalEntity.setOrigin(jn.get(EXTERNAL_ENTITY_ORIGIN).textValue()); externalEntity.setEntity(jn.get(EXTERNAL_ENTITY).textValue()); } return comment; } }
public static void documentModelToExternalEntity(DocumentModel documentModel, ExternalEntity entity) { if (documentModel.hasFacet(EXTERNAL_ENTITY_FACET)) { entity.setEntityId((String) documentModel.getPropertyValue(EXTERNAL_ENTITY_ID_PROPERTY)); entity.setOrigin((String) documentModel.getPropertyValue(EXTERNAL_ENTITY_ORIGIN_PROPERTY)); entity.setEntity((String) documentModel.getPropertyValue(EXTERNAL_ENTITY_PROPERTY)); } }