use of com.revolsys.record.schema.RecordDefinitionImpl in project com.revolsys.open by revolsys.
the class SaifSchemaReader method addExportedObjects.
private void addExportedObjects() {
final RecordDefinitionImpl exportedObjectHandle = new RecordDefinitionImpl(PathName.newPathName("/ExportedObjectHandle"));
this.schema.addRecordDefinition(exportedObjectHandle);
exportedObjectHandle.addField("referenceID", DataTypes.STRING, true);
exportedObjectHandle.addField("type", DataTypes.STRING, true);
exportedObjectHandle.addField("offset", DataTypes.INT, true);
exportedObjectHandle.addField("sharable", DataTypes.BOOLEAN, true);
}
use of com.revolsys.record.schema.RecordDefinitionImpl in project com.revolsys.open by revolsys.
the class SaifSchemaReader method subclass.
public void subclass(final RecordDefinition type, final CsnIterator iterator) throws IOException {
if (iterator.next() == CsnIterator.CLASS_NAME) {
final String className = iterator.getPathValue();
this.currentClass = new RecordDefinitionImpl(PathName.newPathName(className));
for (final RecordDefinition superClassDef : this.currentSuperClasses) {
addSuperClass(this.currentClass, superClassDef);
}
// currentClass.setName(className);
this.schema.addRecordDefinition(this.currentClass);
}
}
use of com.revolsys.record.schema.RecordDefinitionImpl in project com.revolsys.open by revolsys.
the class SaifSchemaReader method loadSchema.
private RecordDefinitionFactory loadSchema(final CsnIterator iterator) throws IOException {
if (this.schema == null) {
this.schema = new RecordDefinitionFactoryImpl();
this.schema.addRecordDefinition(new RecordDefinitionImpl(PathName.newPathName("/AggregateType")));
this.schema.addRecordDefinition(new RecordDefinitionImpl(PathName.newPathName("/PrimitiveType")));
addExportedObjects();
}
while (iterator.next() != CsnIterator.END_DOCUMENT) {
this.currentSuperClasses.clear();
this.currentClass = null;
final Object definition = getDefinition(iterator);
if (definition instanceof RecordDefinition) {
final RecordDefinitionImpl recordDefinition = (RecordDefinitionImpl) definition;
setRecordDefinitionProperties(recordDefinition);
recordDefinition.setRecordDefinitionFactory(this.schema);
this.schema.addRecordDefinition(recordDefinition);
}
}
return this.schema;
}
use of com.revolsys.record.schema.RecordDefinitionImpl in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method newTableRecordDefinition.
private RecordDefinition newTableRecordDefinition(final RecordDefinition recordDefinition) {
synchronized (this.apiSync) {
synchronized (API_SYNC) {
final GeometryFactory geometryFactory = recordDefinition.getGeometryFactory();
final SpatialReference spatialReference = getSpatialReference(geometryFactory);
final DETable deTable = EsriXmlRecordDefinitionUtil.getDETable(recordDefinition, spatialReference, this.createLengthField, this.createAreaField);
final RecordDefinitionImpl tableRecordDefinition = newTableRecordDefinition(deTable);
final String idFieldName = recordDefinition.getIdFieldName();
if (idFieldName != null) {
tableRecordDefinition.setIdFieldName(idFieldName);
}
return tableRecordDefinition;
}
}
}
use of com.revolsys.record.schema.RecordDefinitionImpl in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method getRecordDefinition.
public RecordDefinitionImpl getRecordDefinition(final PathName schemaName, final String path, final String tableDefinition) {
synchronized (this.apiSync) {
synchronized (API_SYNC) {
try {
final XmlProcessor parser = new EsriGdbXmlParser();
final DETable deTable = parser.process(tableDefinition);
final String tableName = deTable.getName();
final PathName typePath = PathName.newPathName(schemaName.newChild(tableName));
final RecordStoreSchema schema = getSchema(schemaName);
final RecordDefinitionImpl recordDefinition = new RecordDefinitionImpl(schema, typePath);
recordDefinition.setPolygonRingDirection(ClockDirection.CLOCKWISE);
String lengthFieldName = null;
String areaFieldName = null;
if (deTable instanceof DEFeatureClass) {
final DEFeatureClass featureClass = (DEFeatureClass) deTable;
lengthFieldName = featureClass.getLengthFieldName();
final LengthFieldName lengthFieldNameProperty = new LengthFieldName(lengthFieldName);
lengthFieldNameProperty.setRecordDefinition(recordDefinition);
areaFieldName = featureClass.getAreaFieldName();
final LengthFieldName areaFieldNameProperty = new LengthFieldName(areaFieldName);
areaFieldNameProperty.setRecordDefinition(recordDefinition);
}
for (final Field field : deTable.getFields()) {
final String fieldName = field.getName();
AbstractFileGdbFieldDefinition fieldDefinition = null;
if (fieldName.equals(lengthFieldName)) {
fieldDefinition = new LengthFieldDefinition(field);
} else if (fieldName.equals(areaFieldName)) {
fieldDefinition = new AreaFieldDefinition(field);
} else {
final FieldType type = field.getType();
final Constructor<? extends AbstractFileGdbFieldDefinition> fieldConstructor = ESRI_FIELD_TYPE_FIELD_DEFINITION_MAP.get(type);
if (fieldConstructor != null) {
try {
fieldDefinition = JavaBeanUtil.invokeConstructor(fieldConstructor, field);
} catch (final Throwable e) {
Logs.error(this, tableDefinition);
throw new RuntimeException("Error creating field for " + typePath + "." + field.getName() + " : " + field.getType(), e);
}
} else {
Logs.error(this, "Unsupported field type " + fieldName + ":" + type);
}
}
if (fieldDefinition != null) {
final Domain domain = field.getDomain();
if (domain != null) {
CodeTable codeTable = getCodeTable(domain.getDomainName() + "_ID");
if (codeTable == null) {
codeTable = new FileGdbDomainCodeTable(this, domain);
addCodeTable(codeTable);
}
fieldDefinition.setCodeTable(codeTable);
}
fieldDefinition.setRecordStore(this);
recordDefinition.addField(fieldDefinition);
if (fieldDefinition instanceof GlobalIdFieldDefinition) {
recordDefinition.setIdFieldName(fieldName);
}
}
}
final String oidFieldName = deTable.getOIDFieldName();
recordDefinition.setProperty(EsriGeodatabaseXmlConstants.ESRI_OBJECT_ID_FIELD_NAME, oidFieldName);
if (deTable instanceof DEFeatureClass) {
final DEFeatureClass featureClass = (DEFeatureClass) deTable;
final String shapeFieldName = featureClass.getShapeFieldName();
recordDefinition.setGeometryFieldName(shapeFieldName);
}
for (final Index index : deTable.getIndexes()) {
if (index.getName().endsWith("_PK")) {
for (final Field field : index.getFields()) {
final String fieldName = field.getName();
recordDefinition.setIdFieldName(fieldName);
}
}
}
addRecordDefinitionProperties(recordDefinition);
if (recordDefinition.getIdFieldIndex() == -1) {
recordDefinition.setIdFieldName(deTable.getOIDFieldName());
}
this.catalogPathByPath.put(typePath, deTable.getCatalogPath());
return recordDefinition;
} catch (final RuntimeException e) {
Logs.debug(this, tableDefinition);
throw e;
}
}
}
}
Aggregations