use of io.atlasmap.java.core.DocumentJavaFieldWriter in project atlasmap by atlasmap.
the class JavaModule method processPreTargetExecution.
@Override
public void processPreTargetExecution(AtlasInternalSession atlasSession) throws AtlasException {
if (atlasSession == null || atlasSession.getMapping() == null || atlasSession.getMapping().getMappings() == null || atlasSession.getMapping().getMappings().getMapping() == null) {
throw new AtlasException("AtlasSession not properly intialized with a mapping that contains field mappings");
}
if (javaInspectionService == null) {
javaInspectionService = new ClassInspectionService();
javaInspectionService.setConversionService(getConversionService());
}
List<BaseMapping> mapping = atlasSession.getMapping().getMappings().getMapping();
Object rootObject;
String targetClassName = AtlasUtil.getUriParameterValue(getUri(), "className");
JavaClass inspectClass = getJavaInspectionService().inspectClass(targetClassName);
merge(inspectClass, mapping);
List<String> targetPaths = AtlasModuleSupport.listTargetPaths(mapping);
try {
rootObject = getJavaConstructService().constructClass(inspectClass, targetPaths);
} catch (Exception e) {
throw new AtlasException(e);
}
DocumentJavaFieldWriter writer = new DocumentJavaFieldWriter(getConversionService());
writer.setRootObject(rootObject);
writer.setTargetValueConverter(targetValueConverter);
atlasSession.setFieldWriter(getDocId(), writer);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processPreTargetExcution completed", getDocId());
}
}
use of io.atlasmap.java.core.DocumentJavaFieldWriter in project atlasmap by atlasmap.
the class JavaModule method processTargetFieldMapping.
@Override
public void processTargetFieldMapping(AtlasInternalSession session) throws AtlasException {
DocumentJavaFieldWriter writer = session.getFieldWriter(getDocId(), DocumentJavaFieldWriter.class);
writer.write(session);
if (LOG.isDebugEnabled()) {
Field sourceField = session.head().getSourceField();
Field targetField = session.head().getTargetField();
LOG.debug("{}: processTargetFieldMapping completed: SourceField:[docId={}, path={}, type={}, value={}], TargetField:[docId={}, path={}, type={}, value={}]", getDocId(), sourceField.getDocId(), sourceField.getPath(), sourceField.getFieldType(), sourceField.getValue(), targetField.getDocId(), targetField.getPath(), targetField.getFieldType(), targetField.getValue());
}
}
use of io.atlasmap.java.core.DocumentJavaFieldWriter in project atlasmap by atlasmap.
the class JavaModule method processPostTargetExecution.
@Override
public void processPostTargetExecution(AtlasInternalSession session) throws AtlasException {
DocumentJavaFieldWriter writer = session.getFieldWriter(getDocId(), DocumentJavaFieldWriter.class);
if (writer != null && writer.getRootObject() != null) {
session.setTargetDocument(getDocId(), writer.getRootObject());
} else {
AtlasUtil.addAudit(session, getDocId(), String.format("No target document created for DataSource '%s'", getDocId()), null, AuditStatus.WARN, null);
}
session.removeFieldWriter(getDocId());
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processPostTargetExecution completed", getDocId());
}
}
Aggregations