Search in sources :

Example 1 with DocumentJavaFieldReader

use of io.atlasmap.java.core.DocumentJavaFieldReader 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());
    }
}
Also used : DocumentJavaFieldReader(io.atlasmap.java.core.DocumentJavaFieldReader) ClassInspectionService(io.atlasmap.java.inspect.ClassInspectionService) AtlasException(io.atlasmap.api.AtlasException)

Example 2 with DocumentJavaFieldReader

use of io.atlasmap.java.core.DocumentJavaFieldReader in project atlasmap by atlasmap.

the class JavaModule method processSourceFieldMapping.

@Override
public void processSourceFieldMapping(AtlasInternalSession session) throws AtlasException {
    Field sourceField = session.head().getSourceField();
    DocumentJavaFieldReader reader = session.getFieldReader(getDocId(), DocumentJavaFieldReader.class);
    if (reader == null) {
        AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Source document '%s' doesn't exist", getDocId()), sourceField.getPath(), AuditStatus.ERROR, null);
        return;
    }
    reader.read(session);
    if (sourceField.getActions() != null && sourceField.getActions().getActions() != null) {
        getFieldActionService().processActions(sourceField.getActions(), sourceField);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("{}: processSourceFieldMapping completed: SourceField:[docId={}, path={}, type={}, value={}]", getDocId(), sourceField.getDocId(), sourceField.getPath(), sourceField.getFieldType(), sourceField.getValue());
    }
}
Also used : Field(io.atlasmap.v2.Field) JavaEnumField(io.atlasmap.java.v2.JavaEnumField) JavaField(io.atlasmap.java.v2.JavaField) DocumentJavaFieldReader(io.atlasmap.java.core.DocumentJavaFieldReader)

Aggregations

DocumentJavaFieldReader (io.atlasmap.java.core.DocumentJavaFieldReader)2 AtlasException (io.atlasmap.api.AtlasException)1 ClassInspectionService (io.atlasmap.java.inspect.ClassInspectionService)1 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)1 JavaField (io.atlasmap.java.v2.JavaField)1 Field (io.atlasmap.v2.Field)1