Search in sources :

Example 1 with DEFeatureDataset

use of com.revolsys.record.io.format.esri.gdb.xml.model.DEFeatureDataset in project com.revolsys.open by revolsys.

the class FileGdbRecordStore method newSchema.

private RecordStoreSchema newSchema(final PathName schemaPath, final SpatialReference spatialReference) {
    synchronized (this.apiSync) {
        synchronized (API_SYNC) {
            final Geodatabase geodatabase = getGeodatabase();
            if (geodatabase == null) {
                return null;
            } else {
                try {
                    String parentCatalogPath = "\\";
                    RecordStoreSchema schema = getRootSchema();
                    for (final PathName childSchemaPath : schemaPath.getPaths()) {
                        if (childSchemaPath.length() > 1) {
                            RecordStoreSchema childSchema = schema.getSchema(childSchemaPath);
                            final String childCatalogPath = toCatalogPath(childSchemaPath);
                            if (!hasChildDataset(getGeodatabase(), parentCatalogPath, "Feature Dataset", childCatalogPath)) {
                                if (spatialReference != null) {
                                    final DEFeatureDataset dataset = EsriXmlRecordDefinitionUtil.newDEFeatureDataset(childCatalogPath, spatialReference);
                                    final String datasetDefinition = EsriGdbXmlSerializer.toString(dataset);
                                    try {
                                        geodatabase.createFeatureDataset(datasetDefinition);
                                    } catch (final Throwable t) {
                                        Logs.debug(this, datasetDefinition);
                                        throw new RuntimeException("Unable to create feature dataset " + childCatalogPath, t);
                                    }
                                }
                            }
                            if (childSchema == null) {
                                childSchema = newFeatureDatasetSchema(schema, childSchemaPath);
                                schema.addElement(childSchema);
                            }
                            schema = childSchema;
                            parentCatalogPath = childCatalogPath;
                        }
                    }
                    return schema;
                } finally {
                    releaseGeodatabase();
                }
            }
        }
    }
}
Also used : Geodatabase(com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase) RecordStoreSchema(com.revolsys.record.schema.RecordStoreSchema) DEFeatureDataset(com.revolsys.record.io.format.esri.gdb.xml.model.DEFeatureDataset) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) PathName(com.revolsys.io.PathName)

Aggregations

Geodatabase (com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase)1 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)1 PathName (com.revolsys.io.PathName)1 DEFeatureDataset (com.revolsys.record.io.format.esri.gdb.xml.model.DEFeatureDataset)1 RecordStoreSchema (com.revolsys.record.schema.RecordStoreSchema)1