use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class RecordDefinitionConvertRecordReader method next.
@Override
public Record next() {
if (hasNext()) {
final Record source = this.iterator.next();
final Record target = new ArrayRecord(this.recordDefinition);
for (final FieldDefinition attribute : this.recordDefinition.getFields()) {
final String name = attribute.getName();
final Object value = source.getValue(name);
if (value != null) {
final DataType dataType = this.recordDefinition.getFieldType(name);
final Object convertedValue = dataType.toObject(value);
target.setValue(name, convertedValue);
}
}
return target;
} else {
throw new NoSuchElementException();
}
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class MapReaderRecordReader method next.
@Override
public Record next() {
if (hasNext()) {
final MapEx source = this.mapIterator.next();
final Record target = new ArrayRecord(this.recordDefinition);
for (final FieldDefinition field : this.recordDefinition.getFields()) {
final String name = field.getName();
final Object value = source.get(name);
if (value != null) {
final DataType dataType = this.recordDefinition.getFieldType(name);
final Object convertedValue;
try {
convertedValue = dataType.toObject(value);
} catch (final Throwable e) {
throw new FieldValueInvalidException(name, value, e);
}
target.setValue(name, convertedValue);
}
}
return target;
} else {
throw new NoSuchElementException();
}
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class RecordStore method insertRecord.
default Record insertRecord(final PathName pathName, final Object... values) {
final RecordDefinition recordDefinition = getRecordDefinition(pathName);
final Record record = new ArrayRecord(recordDefinition, values);
insertRecord(record);
return record;
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class GeometryTest method writeTestFile.
public static void writeTestFile(final GeometryFactory geometryFactory, final String wkt) {
final Geometry geometry = geometryFactory.geometry(wkt);
final DataType geometryDataType = DataTypes.getDataType(geometry);
String name = "/" + geometryDataType.getName();
if (geometryFactory.hasZ()) {
name += "Z";
}
final File file = new File("target/test-data/" + name + ".gdb");
FileUtil.deleteDirectory(file);
final PathName pathName = PathName.newPathName(name);
RecordDefinitionImpl recordDefinition = new RecordDefinitionImpl(pathName);
recordDefinition.addField("ID", DataTypes.INT, true);
final FieldDefinition geometryField = recordDefinition.addField("Geometry", geometryDataType, true);
geometryField.setProperty(FieldProperties.GEOMETRY_FACTORY, geometryFactory);
recordDefinition.setIdFieldName("ID");
final FileGdbRecordStore recordStore = FileGdbRecordStoreFactory.newRecordStore(file);
recordStore.initialize();
recordDefinition = (RecordDefinitionImpl) recordStore.getRecordDefinition(recordDefinition);
final Record object = new ArrayRecord(recordDefinition);
object.setIdentifier(Identifier.newIdentifier(1));
object.setGeometryValue(geometry);
recordStore.insertRecord(object);
final Record object2 = recordStore.getRecord(pathName, Identifier.newIdentifier(1));
if (!DataType.equal(object, object2)) {
System.out.println("Not Equal");
System.out.println(object);
System.out.println(object2);
}
recordStore.close();
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class CopyProcess method copy.
protected Record copy(final Record object) {
Record targetObject;
if (this.recordDefinition == null) {
targetObject = object;
} else {
targetObject = new ArrayRecord(this.recordDefinition);
for (final String fieldName : this.recordDefinition.getFieldNames()) {
copyAttribute(object, fieldName, targetObject, fieldName);
}
if (this.attributeMap != null) {
for (final Entry<String, String> mapping : this.attributeMap.entrySet()) {
final String sourceFieldName = mapping.getKey();
final String targetFieldName = mapping.getValue();
copyAttribute(object, sourceFieldName, targetObject, targetFieldName);
}
}
}
return targetObject;
}
Aggregations