use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.
the class AtlasMappingBaseTest method printAudit.
protected String printAudit(AtlasSession session) {
StringBuilder buf = new StringBuilder("Audits: ");
for (Audit a : session.getAudits().getAudit()) {
buf.append('[');
buf.append(a.getStatus());
buf.append(", message=");
buf.append(a.getMessage());
buf.append(", path=");
buf.append(a.getPath());
buf.append("], ");
}
return buf.toString();
}
use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method printAudit.
protected String printAudit(AtlasSession session) {
StringBuilder buf = new StringBuilder("Audits: ");
for (Audit a : session.getAudits().getAudit()) {
buf.append('[');
buf.append(a.getStatus());
buf.append(", message=");
buf.append(a.getMessage());
buf.append("], ");
}
return buf.toString();
}
use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.
the class AtlasUtil method addAudit.
/**
* Converts from the Validation to the Audit and add into the session.
* @param session session
* @param validation validation
*/
public static void addAudit(AtlasSession session, Validation validation) {
Audit audit = new Audit();
audit.setDocId(validation.getDocId());
audit.setDocName(validation.getDocName());
audit.setMessage(validation.getMessage());
audit.setStatus(AtlasUtil.toAuditStatus(validation.getStatus()));
session.getAudits().getAudit().add(audit);
}
use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.
the class DefaultAtlasContext method process.
@Override
public void process(AtlasSession userSession) throws AtlasException {
if (!(userSession instanceof DefaultAtlasSession)) {
throw new AtlasException(String.format("Unsupported session class '%s'", userSession.getClass().getName()));
}
if (!this.equals(userSession.getAtlasContext())) {
throw new AtlasException("Cannot execute AtlasSession created by the other AtlasContext");
}
DefaultAtlasSession session = (DefaultAtlasSession) userSession;
if (LOG.isDebugEnabled()) {
LOG.debug("Begin process {}", (session == null ? null : session.toString()));
}
session.head().unset();
session.getAudits().getAudit().clear();
session.getValidations().getValidation().clear();
// TODO https://github.com/atlasmap/atlasmap/issues/863 - Add an option to enable/disable runtime validation
processValidation(session);
for (Validation v : session.getValidations().getValidation()) {
AtlasUtil.addAudit(session, v);
}
// Additional runtime only audit
Mappings mappings = session.getMapping().getMappings();
if (mappings != null && mappings.getMapping().isEmpty()) {
AtlasUtil.addAudit(session, (String) null, String.format("Field mappings should not be empty"), AuditStatus.WARN, null);
}
session.getValidations().getValidation().clear();
if (session.hasErrors()) {
if (LOG.isDebugEnabled()) {
LOG.error("Aborting due to {} errors in pre-validation", session.errorCount());
}
return;
}
for (AtlasModule module : getSourceModules().values()) {
module.processPreSourceExecution(session);
}
for (AtlasModule module : getTargetModules().values()) {
module.processPreTargetExecution(session);
}
if (session.hasErrors()) {
if (LOG.isDebugEnabled()) {
LOG.error("Aborting due to {} errors in pre-execution", session.errorCount());
}
return;
}
for (BaseMapping baseMapping : session.getMapping().getMappings().getMapping()) {
for (BaseMapping innerMapping : unwrapCollectionMappings(session, baseMapping)) {
if (innerMapping instanceof CustomMapping) {
DefaultAtlasCustomMappingProcessor.getInstance().process(session, (CustomMapping) innerMapping);
continue;
}
Mapping mapping = (Mapping) innerMapping;
session.head().setMapping(mapping).setLookupTable(lookupTables.get(mapping.getLookupTableName()));
if (mapping.getOutputField() == null || mapping.getOutputField().isEmpty()) {
AtlasUtil.addAudit(session, (String) null, String.format("Mapping does not contain at least one target field: alias=%s desc=%s", mapping.getAlias(), mapping.getDescription()), AuditStatus.WARN, null);
continue;
}
processSourceFieldMapping(session);
if (!session.head().hasError()) {
processTargetFieldMapping(session, mapping);
}
session.getAudits().getAudit().addAll(session.head().getAudits());
session.head().unset();
}
}
for (AtlasModule module : getSourceModules().values()) {
module.processPostValidation(session);
}
for (AtlasModule module : getTargetModules().values()) {
module.processPostValidation(session);
}
for (AtlasModule module : getSourceModules().values()) {
module.processPostSourceExecution(session);
}
for (AtlasModule module : getTargetModules().values()) {
module.processPostTargetExecution(session);
}
if (LOG.isDebugEnabled()) {
LOG.debug("End process {}", session == null ? null : session.toString());
}
}
use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.
the class JavaJavaSeparateTest method testProcessSeparateNotEnoughSource.
@Test
public void testProcessSeparateNotEnoughSource() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-inputshort.json").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
assertNotNull(targetContact);
assertEquals("Ozzie", targetContact.getFirstName());
assertEquals(null, targetContact.getLastName());
assertTrue(session.hasWarns());
assertEquals(8, session.getAudits().getAudit().size());
boolean found = false;
for (Audit a : session.getAudits().getAudit()) {
if ("Separate returned fewer segments count=3 when targetField.path=/lastName requested index=3".equals(a.getMessage())) {
found = true;
}
}
assertTrue(found, printAudit(session));
}
Aggregations