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);
}
}
}
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);
}
}
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);
}
}
}
}
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);
}
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);
}
}
}
}
Aggregations