Search in sources :

Example 1 with SimpleRecordConveter

use of com.revolsys.gis.converter.SimpleRecordConveter in project com.revolsys.open by revolsys.

the class RecordConverterProcess method preRun.

@Override
protected void preRun(final Channel<Record> in, final Channel<Record> out) {
    this.labelCountMap.connect();
    // ignoredStatistics.connect();
    if (this.simpleMapping != null) {
        for (final Entry<Object, Map<String, Object>> entry : this.simpleMapping.entrySet()) {
            final Object key = entry.getKey();
            String sourceTypeName;
            if (key instanceof String) {
                sourceTypeName = (String) key;
            } else {
                sourceTypeName = String.valueOf(key.toString());
            }
            final Map<String, Object> map = entry.getValue();
            final Object targetName = map.get("typePath");
            String targetTypeName;
            if (key instanceof String) {
                targetTypeName = (String) targetName;
            } else {
                targetTypeName = String.valueOf(targetName.toString());
            }
            @SuppressWarnings("unchecked") final Map<String, String> attributeMapping = (Map<String, String>) map.get("attributeMapping");
            final RecordDefinition targetRecordDefinition = getTargetRecordDefinition(targetTypeName);
            final SimpleRecordConveter converter = new SimpleRecordConveter(targetRecordDefinition);
            converter.addProcessor(new CopyValues(attributeMapping));
            addTypeConverter(sourceTypeName, converter);
        }
    }
}
Also used : SimpleRecordConveter(com.revolsys.gis.converter.SimpleRecordConveter) CopyValues(com.revolsys.gis.converter.process.CopyValues) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LabelCountMap(com.revolsys.util.count.LabelCountMap) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

SimpleRecordConveter (com.revolsys.gis.converter.SimpleRecordConveter)1 CopyValues (com.revolsys.gis.converter.process.CopyValues)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 LabelCountMap (com.revolsys.util.count.LabelCountMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1