Search in sources :

Example 1 with AtlasMappingBuilder

use of io.atlasmap.api.AtlasMappingBuilder in project atlasmap by atlasmap.

the class DefaultAtlasCustomMappingProcessor method process.

/**
 * Processes the {@link CustomMapping}.
 * @param session session
 * @param customMapping custom mapping
 */
public void process(DefaultAtlasSession session, CustomMapping customMapping) {
    String className = customMapping.getClassName();
    if (className == null || className.isEmpty()) {
        AtlasUtil.addAudit(session, className, "Custom mapping class must be specified", AuditStatus.ERROR, className);
        return;
    }
    DefaultAtlasContextFactory factory = session.getAtlasContext().getContextFactory();
    AtlasMappingBuilder builder;
    try {
        Class<?> clazz = factory.getClassLoader().loadClass(className);
        builder = AtlasMappingBuilder.class.cast(clazz.getDeclaredConstructor().newInstance());
        builder.setAtlasSession(session);
    } catch (Exception e) {
        AtlasUtil.addAudit(session, className, String.format("Custom mapping class '%s' could not be loaded: %s", className, e.getMessage()), AuditStatus.ERROR, className);
        if (LOG.isDebugEnabled()) {
            LOG.error("", e);
        }
        return;
    }
    builder.process();
}
Also used : AtlasMappingBuilder(io.atlasmap.api.AtlasMappingBuilder)

Aggregations

AtlasMappingBuilder (io.atlasmap.api.AtlasMappingBuilder)1