use of io.atlasmap.java.inspect.ClassInspectionService in project atlasmap by atlasmap.
the class JavaModule method processPreSourceExecution.
@Override
public void processPreSourceExecution(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());
}
Object sourceDocument = atlasSession.getSourceDocument(getDocId());
if (sourceDocument == null) {
AtlasUtil.addAudit(atlasSession, getDocId(), String.format("Null source document: docId='%s'", getDocId()), null, AuditStatus.WARN, null);
} else {
DocumentJavaFieldReader reader = new DocumentJavaFieldReader();
reader.setConversionService(getConversionService());
reader.setDocument(sourceDocument);
atlasSession.setFieldReader(getDocId(), reader);
}
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processPreSourceExcution completed", getDocId());
}
}
use of io.atlasmap.java.inspect.ClassInspectionService 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());
}
}
Aggregations