@Test public void testRead() throws Exception { TargetTestClass source = new TargetTestClass(); source.setAddress(new TargetAddress()); source.getAddress().setAddressLine1("123 any street"); reader.setDocument(source); read("/address/addressLine1", FieldType.STRING); assertEquals("123 any street", field.getValue()); assertEquals(0, audits.size()); }
@Override public Field read(AtlasInternalSession session) throws AtlasException { try { Field field = session.head().getSourceField(); if (sourceDocument == null) { AtlasUtil.addAudit(session, field.getDocId(), String.format( "Unable to read sourceField (path=%s), document (docId=%s) is null", field.getPath(), field.getDocId()), field.getPath(), AuditStatus.ERROR, null); } AtlasPath path = new AtlasPath(field.getPath()); List<Field> fields = getFieldsForPath(session, sourceDocument, field, path, 0); if (LOG.isDebugEnabled()) { LOG.debug("Processed input field sPath=" + field.getPath() + " sV=" + field.getValue() + " sT=" + field.getFieldType() + " docId: " + field.getDocId()); } if (path.hasCollection() && !path.isIndexedCollection()) { FieldGroup fieldGroup = AtlasModelFactory.createFieldGroupFrom(field, true); fieldGroup.getField().addAll(fields); session.head().setSourceField(fieldGroup); return fieldGroup; } else if (fields.size() == 1) { field.setValue(fields.get(0).getValue()); return field; } else { return field; } } catch (Exception e) { throw new AtlasException(e); } }
JavaFieldReader implements AtlasFieldReader { @Override public Field read(AtlasInternalSession session) throws AtlasException { try { Field field = session.head().getSourceField(); if (sourceDocument == null) { AtlasUtil.addAudit(session, field.getDocId(), String.format( "Unable to read sourceField (path=%s), document (docId=%s) is null", field.getPath(), field.getDocId()), field.getPath(), AuditStatus.ERROR, null); } AtlasPath path = new AtlasPath(field.getPath()); List<Field> fields = getFieldsForPath(session, sourceDocument, field, path, 0); if (LOG.isDebugEnabled()) { LOG.debug("Processed input field sPath=" + field.getPath() + " sV=" + field.getValue() + " sT=" + field.getFieldType() + " docId: " + field.getDocId()); } if (path.hasCollection() && !path.isIndexedCollection()) { FieldGroup fieldGroup = AtlasModelFactory.createFieldGroupFrom(field, true); fieldGroup.getField().addAll(fields); session.head().setSourceField(fieldGroup); return fieldGroup; } else if (fields.size() == 1) { field.setValue(fields.get(0).getValue()); return field; } else { return field; } } catch (Exception e) { throw new AtlasException(e); } } }
JavaFieldReader implements AtlasFieldReader { @Override public Field read(AtlasInternalSession session) throws AtlasException { try { Field field = session.head().getSourceField(); if (sourceDocument == null) { AtlasUtil.addAudit(session, field.getDocId(), String.format( "Unable to read sourceField (path=%s), document (docId=%s) is null", field.getPath(), field.getDocId()), field.getPath(), AuditStatus.ERROR, null); } AtlasPath path = new AtlasPath(field.getPath()); List<Field> fields = getFieldsForPath(session, sourceDocument, field, path, 0); if (LOG.isDebugEnabled()) { LOG.debug("Processed input field sPath=" + field.getPath() + " sV=" + field.getValue() + " sT=" + field.getFieldType() + " docId: " + field.getDocId()); } if (path.hasCollection() && !path.isIndexedCollection()) { FieldGroup fieldGroup = AtlasModelFactory.createFieldGroupFrom(field, true); fieldGroup.getField().addAll(fields); session.head().setSourceField(fieldGroup); return fieldGroup; } else if (fields.size() == 1) { field.setValue(fields.get(0).getValue()); return field; } else { return field; } } catch (Exception e) { throw new AtlasException(e); } }  }
JavaFieldReader implements AtlasFieldReader { @Override public Field read(AtlasInternalSession session) throws AtlasException { try { Field field = session.head().getSourceField(); if (sourceDocument == null) { AtlasUtil.addAudit(session, field.getDocId(), String.format( "Unable to read sourceField (path=%s), document (docId=%s) is null", field.getPath(), field.getDocId()), field.getPath(), AuditStatus.ERROR, null); } AtlasPath path = new AtlasPath(field.getPath()); List<Field> fields = getFieldsForPath(session, sourceDocument, field, path, 0); if (LOG.isDebugEnabled()) { LOG.debug("Processed input field sPath=" + field.getPath() + " sV=" + field.getValue() + " sT=" + field.getFieldType() + " docId: " + field.getDocId()); } if (path.hasCollection() && !path.isIndexedCollection()) { FieldGroup fieldGroup = AtlasModelFactory.createFieldGroupFrom(field, true); fieldGroup.getField().addAll(fields); session.head().setSourceField(fieldGroup); return fieldGroup; } else if (fields.size() == 1) { field.setValue(fields.get(0).getValue()); return field; } else { return field; } } catch (Exception e) { throw new AtlasException(e); } }  @Override Field read(AtlasInternalSession session); void setDocument(Object sourceDocument); void setConversionService(AtlasConversionService conversionService); }
JavaFieldReader implements AtlasFieldReader { @Override public Field read(AtlasInternalSession session) throws AtlasException { try { Field field = session.head().getSourceField(); if (sourceDocument == null) { AtlasUtil.addAudit(session, field.getDocId(), String.format( "Unable to read sourceField (path=%s), document (docId=%s) is null", field.getPath(), field.getDocId()), field.getPath(), AuditStatus.ERROR, null); } AtlasPath path = new AtlasPath(field.getPath()); List<Field> fields = getFieldsForPath(session, sourceDocument, field, path, 0); if (LOG.isDebugEnabled()) { LOG.debug("Processed input field sPath=" + field.getPath() + " sV=" + field.getValue() + " sT=" + field.getFieldType() + " docId: " + field.getDocId()); } if (path.hasCollection() && !path.isIndexedCollection()) { FieldGroup fieldGroup = AtlasModelFactory.createFieldGroupFrom(field, true); fieldGroup.getField().addAll(fields); session.head().setSourceField(fieldGroup); return fieldGroup; } else if (fields.size() == 1) { field.setValue(fields.get(0).getValue()); return field; } else { return field; } } catch (Exception e) { throw new AtlasException(e); } }  @Override Field read(AtlasInternalSession session); void setDocument(Object sourceDocument); void setConversionService(AtlasConversionService conversionService);  }