Search in sources :

Example 1 with TypeTransformationHandler

use of eu.esdihumboldt.hale.io.appschema.writer.internal.TypeTransformationHandler in project hale by halestudio.

the class AppSchemaMappingGenerator method createTypeMappings.

private void createTypeMappings(AppSchemaMappingContext context, IOReporter reporter) {
    Collection<? extends Cell> typeCells = alignment.getTypeCells();
    for (Cell typeCell : typeCells) {
        String typeTransformId = typeCell.getTransformationIdentifier();
        TypeTransformationHandler typeTransformHandler = null;
        try {
            typeTransformHandler = TypeTransformationHandlerFactory.getInstance().createTypeTransformationHandler(typeTransformId);
            FeatureTypeMapping ftMapping = typeTransformHandler.handleTypeTransformation(typeCell, context);
            if (ftMapping != null) {
                Collection<? extends Cell> propertyCells = alignment.getPropertyCells(typeCell);
                for (Cell propertyCell : propertyCells) {
                    String propertyTransformId = propertyCell.getTransformationIdentifier();
                    PropertyTransformationHandler propertyTransformHandler = null;
                    try {
                        propertyTransformHandler = PropertyTransformationHandlerFactory.getInstance().createPropertyTransformationHandler(propertyTransformId);
                        propertyTransformHandler.handlePropertyTransformation(typeCell, propertyCell, context);
                    } catch (UnsupportedTransformationException e) {
                        String errMsg = MessageFormat.format("Error processing property cell {0}", propertyCell.getId());
                        log.warn(errMsg, e);
                        if (reporter != null) {
                            reporter.warn(new IOMessageImpl(errMsg, e));
                        }
                    }
                }
            }
        } catch (UnsupportedTransformationException e) {
            String errMsg = MessageFormat.format("Error processing type cell{0}", typeCell.getId());
            log.warn(errMsg, e);
            if (reporter != null) {
                reporter.warn(new IOMessageImpl(errMsg, e));
            }
        }
    }
}
Also used : UnsupportedTransformationException(eu.esdihumboldt.hale.io.appschema.writer.internal.UnsupportedTransformationException) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) PropertyTransformationHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.PropertyTransformationHandler) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Cell(eu.esdihumboldt.hale.common.align.model.Cell) TypeTransformationHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.TypeTransformationHandler)

Aggregations

Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 FeatureTypeMapping (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping)1 PropertyTransformationHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.PropertyTransformationHandler)1 TypeTransformationHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.TypeTransformationHandler)1 UnsupportedTransformationException (eu.esdihumboldt.hale.io.appschema.writer.internal.UnsupportedTransformationException)1