Search in sources :

Example 1 with JsonFieldReader

use of io.atlasmap.json.core.JsonFieldReader in project atlasmap by atlasmap.

the class JsonModule method processSourceFieldMapping.

@Override
public void processSourceFieldMapping(AtlasInternalSession session) throws AtlasException {
    Field sourceField = session.head().getSourceField();
    JsonFieldReader reader = session.getFieldReader(getDocId(), JsonFieldReader.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) JsonField(io.atlasmap.json.v2.JsonField) JsonFieldReader(io.atlasmap.json.core.JsonFieldReader)

Example 2 with JsonFieldReader

use of io.atlasmap.json.core.JsonFieldReader in project atlasmap by atlasmap.

the class JsonModule method processPreSourceExecution.

@Override
public void processPreSourceExecution(AtlasInternalSession session) throws AtlasException {
    Object sourceDocument = session.getSourceDocument(getDocId());
    if (sourceDocument == null || !(sourceDocument instanceof String)) {
        AtlasUtil.addAudit(session, getDocId(), String.format("Null or non-String source document: docId='%s'", getDocId()), null, AuditStatus.WARN, null);
    } else {
        String document = String.class.cast(sourceDocument);
        JsonFieldReader fieldReader = new JsonFieldReader(getConversionService());
        fieldReader.setDocument(document);
        session.setFieldReader(getDocId(), fieldReader);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("{} processPreSourceExcution completed", getDocId());
    }
}
Also used : JsonFieldReader(io.atlasmap.json.core.JsonFieldReader)

Aggregations

JsonFieldReader (io.atlasmap.json.core.JsonFieldReader)2 JsonField (io.atlasmap.json.v2.JsonField)1 Field (io.atlasmap.v2.Field)1