Search in sources :

Example 31 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class OgrRecordWriter method setGeometries.

private void setGeometries(final FeatureDefn featureDefinition, final Record record, final Feature feature) {
    final RecordDefinition recordDefinition = record.getRecordDefinition();
    final int geometryFieldCount = featureDefinition.GetGeomFieldCount();
    for (int fieldIndex = 0; fieldIndex < geometryFieldCount; fieldIndex++) {
        final GeomFieldDefn fieldDefinition = featureDefinition.GetGeomFieldDefn(fieldIndex);
        final String name = fieldDefinition.GetName();
        Geometry geometry = record.getValue(name);
        if (geometry != null) {
            final FieldDefinition attribute = recordDefinition.getField(name);
            final GeometryFactory geometryFactory = attribute.getProperty(FieldProperties.GEOMETRY_FACTORY);
            geometry = geometry.convertGeometry(geometryFactory);
            final int geometryType = fieldDefinition.GetFieldType();
            final int axisCount = geometryFactory.getAxisCount();
            final org.gdal.ogr.Geometry ogrGeometry = toOgrGeometry(geometry, geometryType, axisCount);
            feature.SetGeomField(fieldIndex, ogrGeometry);
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) FieldDefinition(com.revolsys.record.schema.FieldDefinition) GeomFieldDefn(org.gdal.ogr.GeomFieldDefn) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 32 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordPseudoNodeRemovalVisitor method processPseudoNodes.

private void processPseudoNodes(final Node<Record> node) {
    for (final RecordDefinition recordDefinition : NodeProperties.getEdgeRecordDefinitions(node)) {
        final PseudoNodeProperty property = PseudoNodeProperty.getProperty(recordDefinition);
        final PseudoNodeAttribute pseudoNodeAttribute = property.getProperty(node);
        processPseudoNodesForType(node, pseudoNodeAttribute);
    }
}
Also used : PseudoNodeProperty(com.revolsys.geometry.graph.attribute.PseudoNodeProperty) PseudoNodeAttribute(com.revolsys.geometry.graph.attribute.PseudoNodeAttribute) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 33 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class CopyValues method process.

@Override
public void process(final Record source, final Record target) {
    for (final Entry<String, String> entry : this.fieldNames.entrySet()) {
        final String sourceName = entry.getKey();
        final String targetName = entry.getValue();
        final Object value;
        if (sourceName.startsWith("~")) {
            value = sourceName.substring(1);
        } else {
            value = source.getValueByPath(sourceName);
        }
        if (value != null) {
            final RecordDefinition targetRecordDefinition = target.getRecordDefinition();
            final CodeTable codeTable = targetRecordDefinition.getCodeTableByFieldName(targetName);
            if (codeTable == null) {
                target.setValue(targetName, value);
            } else {
                final Object codeId = codeTable.getIdentifier(value);
                target.setValue(targetName, codeId);
            }
        }
    }
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 34 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class SetCodeTableId method process.

@Override
public void process(final Record source, final Record target) {
    final Map<String, Object> codeTableValues = new HashMap<>();
    for (final Entry<String, Converter<Record, Object>> entry : this.codeTableValueConverters.entrySet()) {
        String codeTableFieldName = entry.getKey();
        final Converter<Record, Object> sourceAttributeConverter = entry.getValue();
        Object sourceValue = sourceAttributeConverter.convert(source);
        if (sourceValue != null) {
            final RecordDefinition targetRecordDefinition = target.getRecordDefinition();
            String codeTableValueName = null;
            final int dotIndex = codeTableFieldName.indexOf(".");
            if (dotIndex != -1) {
                codeTableValueName = codeTableFieldName.substring(dotIndex + 1);
                codeTableFieldName = codeTableFieldName.substring(0, dotIndex);
            }
            final CodeTable targetCodeTable = targetRecordDefinition.getCodeTableByFieldName(codeTableFieldName);
            if (targetCodeTable != null) {
                if (codeTableValueName == null) {
                    sourceValue = targetCodeTable.getIdentifier(sourceValue);
                } else {
                    sourceValue = targetCodeTable.getIdentifier(Collections.singletonMap(codeTableValueName, sourceValue));
                }
            }
        }
        codeTableValues.put(codeTableFieldName, sourceValue);
    }
    final Object codeId = this.codeTable.getIdentifier(codeTableValues);
    target.setValue(this.targetFieldName, codeId);
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) HashMap(java.util.HashMap) Converter(org.springframework.core.convert.converter.Converter) Record(com.revolsys.record.Record) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 35 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class MapValues method process.

@Override
public void process(final Record source, final Record target) {
    final Object sourceValue = Records.getFieldByPath(source, this.sourceFieldName);
    if (sourceValue != null) {
        final Object targetValue = this.valueMap.get(sourceValue);
        if (targetValue != null) {
            final RecordDefinition targetRecordDefinition = target.getRecordDefinition();
            final CodeTable codeTable = targetRecordDefinition.getCodeTableByFieldName(this.targetFieldName);
            if (codeTable == null) {
                target.setValue(this.targetFieldName, targetValue);
            } else {
                final Object codeId = codeTable.getIdentifier(targetValue);
                target.setValue(this.targetFieldName, codeId);
            }
        }
    }
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordDefinition (com.revolsys.record.schema.RecordDefinition)189 FieldDefinition (com.revolsys.record.schema.FieldDefinition)38 Record (com.revolsys.record.Record)34 Geometry (com.revolsys.geometry.model.Geometry)20 CodeTable (com.revolsys.record.code.CodeTable)19 Query (com.revolsys.record.query.Query)18 LineString (com.revolsys.geometry.model.LineString)17 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)16 PathName (com.revolsys.io.PathName)13 ArrayList (java.util.ArrayList)12 DataType (com.revolsys.datatype.DataType)11 Identifier (com.revolsys.identifier.Identifier)11 RecordReader (com.revolsys.record.io.RecordReader)11 RecordStore (com.revolsys.record.schema.RecordStore)11 HashMap (java.util.HashMap)9 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)8 ArrayRecord (com.revolsys.record.ArrayRecord)8 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)6 Table (com.revolsys.gis.esri.gdb.file.capi.swig.Table)5 RecordWriter (com.revolsys.record.io.RecordWriter)5