use of com.revolsys.record.io.format.esri.gdb.xml.type.EsriGeodatabaseXmlFieldType in project com.revolsys.open by revolsys.
the class EsriXmlRecordDefinitionUtil method addField.
private static Field addField(final DETable table, final FieldDefinition attribute) {
final String fieldName = attribute.getName();
final DataType dataType = attribute.getDataType();
final EsriGeodatabaseXmlFieldType fieldType = FIELD_TYPES.getFieldType(dataType);
if (fieldType == null) {
throw new RuntimeException("Data type not supported " + dataType + " for " + table.getName() + "." + fieldName);
} else {
final Field field = new Field();
field.setName(fieldName);
field.setType(fieldType.getEsriFieldType());
field.setIsNullable(!attribute.isRequired());
field.setRequired(attribute.isRequired());
int length = fieldType.getFixedLength();
if (length < 0) {
length = attribute.getLength();
}
field.setLength(length);
final int precision;
if (fieldType.isUsePrecision()) {
precision = attribute.getLength();
} else {
precision = 0;
}
field.setPrecision(precision);
final int scale = attribute.getScale();
field.setScale(scale);
table.addField(field);
return field;
}
}
use of com.revolsys.record.io.format.esri.gdb.xml.type.EsriGeodatabaseXmlFieldType in project com.revolsys.open by revolsys.
the class EsriGeodatabaseXmlRecordWriter method write.
@Override
public void write(final Record record) {
if (!this.opened) {
writeHeader(record.getGeometry());
writeWorkspaceDataHeader();
}
this.out.startTag(RECORD);
this.out.attribute(XsiConstants.TYPE, RECORD_TYPE);
this.out.startTag(VALUES);
this.out.attribute(XsiConstants.TYPE, VALUES_TYPE);
for (final FieldDefinition field : this.recordDefinition.getFields()) {
final String fieldName = field.getName();
final Object value;
if (isWriteCodeValues()) {
value = record.getValue(fieldName);
} else {
value = record.getCodeValue(fieldName);
}
final DataType type = field.getDataType();
final EsriGeodatabaseXmlFieldType fieldType = this.fieldTypes.getFieldType(type);
if (fieldType != null) {
fieldType.writeValue(this.out, value);
}
}
if (this.recordDefinition.getField("OBJECTID") == null) {
final EsriGeodatabaseXmlFieldType fieldType = this.fieldTypes.getFieldType(DataTypes.INT);
fieldType.writeValue(this.out, this.objectId++);
}
this.out.endTag(VALUES);
this.out.endTag(RECORD);
}
use of com.revolsys.record.io.format.esri.gdb.xml.type.EsriGeodatabaseXmlFieldType in project com.revolsys.open by revolsys.
the class EsriGeodatabaseXmlRecordWriter method writeField.
private void writeField(final FieldDefinition attribute) {
final String fieldName = attribute.getName();
if (fieldName.equals("OBJECTID")) {
writeOidField();
} else {
final DataType dataType = attribute.getDataType();
final EsriGeodatabaseXmlFieldType fieldType = this.fieldTypes.getFieldType(dataType);
if (fieldType == null) {
Logs.error(this, "Data type not supported " + dataType);
} else {
this.out.startTag(FIELD);
this.out.attribute(XsiConstants.TYPE, FIELD_TYPE);
this.out.element(NAME, fieldName);
this.out.element(TYPE, fieldType.getEsriFieldType());
this.out.element(IS_NULLABLE, !attribute.isRequired());
int length = fieldType.getFixedLength();
if (length < 0) {
length = attribute.getLength();
}
this.out.element(LENGTH, length);
final int precision;
if (fieldType.isUsePrecision()) {
precision = attribute.getLength();
} else {
precision = 0;
}
this.out.element(PRECISION, precision);
this.out.element(SCALE, attribute.getScale());
final GeometryFactory geometryFactory = attribute.getProperty(FieldProperties.GEOMETRY_FACTORY);
if (geometryFactory != null) {
this.out.startTag(GEOMETRY_DEF);
this.out.attribute(XsiConstants.TYPE, GEOMETRY_DEF_TYPE);
this.out.element(AVG_NUM_POINTS, 0);
this.out.element(GEOMETRY_TYPE, this.geometryType);
this.out.element(HAS_M, false);
this.out.element(HAS_Z, geometryFactory.hasZ());
writeSpatialReference(geometryFactory);
this.out.endTag();
}
this.out.endTag(FIELD);
}
}
}
Aggregations