Search in sources :

Example 1 with VectorOfWString

use of com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString in project com.revolsys.open by revolsys.

the class FileGdbRecordStore method refreshSchemaRecordDefinitions.

private void refreshSchemaRecordDefinitions(final Map<PathName, RecordStoreSchemaElement> elementsByPath, final PathName schemaPath, final String catalogPath, final String datasetType) {
    synchronized (this.apiSync) {
        synchronized (API_SYNC) {
            final Geodatabase geodatabase = getGeodatabase();
            if (geodatabase != null) {
                try {
                    final boolean pathExists = isPathExists(geodatabase, catalogPath);
                    if (pathExists) {
                        final VectorOfWString childFeatureClasses = getChildDatasets(geodatabase, catalogPath, datasetType);
                        if (childFeatureClasses != null) {
                            for (int i = 0; i < childFeatureClasses.size(); i++) {
                                final String childCatalogPath = childFeatureClasses.get(i);
                                final String tableDefinition = geodatabase.getTableDefinition(childCatalogPath);
                                final RecordDefinition recordDefinition = getRecordDefinition(schemaPath, childCatalogPath, tableDefinition);
                                initRecordDefinition(recordDefinition);
                                final PathName childPath = recordDefinition.getPathName();
                                elementsByPath.put(childPath, recordDefinition);
                            }
                        }
                    }
                } finally {
                    releaseGeodatabase();
                }
            }
        }
    }
}
Also used : Geodatabase(com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) PathName(com.revolsys.io.PathName) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 2 with VectorOfWString

use of com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString in project com.revolsys.open by revolsys.

the class FileGdbRecordStore method initializeDo.

@Override
public void initializeDo() {
    synchronized (this.apiSync) {
        synchronized (API_SYNC) {
            Geodatabase geodatabase = null;
            try {
                super.initialize();
                final File file = new File(this.fileName);
                if (file.exists()) {
                    if (file.isDirectory()) {
                        if (!new File(this.fileName, "gdb").exists()) {
                            throw new IllegalArgumentException(FileUtil.getCanonicalPath(file) + " is not a valid ESRI File Geodatabase");
                        }
                        geodatabase = getSingleThreadResult(() -> {
                            return EsriFileGdb.openGeodatabase(this.fileName);
                        });
                    } else {
                        throw new IllegalArgumentException(FileUtil.getCanonicalPath(file) + " ESRI File Geodatabase must be a directory");
                    }
                } else if (this.createMissingRecordStore) {
                    geodatabase = newGeodatabase();
                } else {
                    throw new IllegalArgumentException("ESRI file geodatabase not found " + this.fileName);
                }
                if (geodatabase == null) {
                    throw new IllegalArgumentException("Unable to open ESRI file geodatabase not found " + this.fileName);
                }
                final VectorOfWString domainNames = geodatabase.getDomains();
                for (int i = 0; i < domainNames.size(); i++) {
                    final String domainName = domainNames.get(i);
                    loadDomain(geodatabase, domainName);
                }
                this.exists = true;
            } catch (final Throwable e) {
                try {
                    closeDo();
                } finally {
                    Exceptions.throwUncheckedException(e);
                }
            } finally {
                if (geodatabase != null) {
                    closeGeodatabase(geodatabase);
                }
            }
        }
    }
}
Also used : Geodatabase(com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) File(java.io.File)

Example 3 with VectorOfWString

use of com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString in project com.revolsys.open by revolsys.

the class FileGdbRecordStore method refreshSchemaElements.

@Override
protected Map<PathName, ? extends RecordStoreSchemaElement> refreshSchemaElements(final RecordStoreSchema schema) {
    synchronized (this.apiSync) {
        synchronized (API_SYNC) {
            final Map<PathName, RecordStoreSchemaElement> elementsByPath = new TreeMap<>();
            final Geodatabase geodatabase = getGeodatabase();
            if (geodatabase != null) {
                try {
                    final PathName schemaPath = schema.getPathName();
                    final String schemaCatalogPath = getCatalogPath(schema);
                    final VectorOfWString childDatasets = getChildDatasets(geodatabase, schemaCatalogPath, "Feature Dataset");
                    if (childDatasets != null) {
                        for (int i = 0; i < childDatasets.size(); i++) {
                            final String childCatalogPath = childDatasets.get(i);
                            final PathName childPath = toPath(childCatalogPath);
                            RecordStoreSchema childSchema = schema.getSchema(childPath);
                            if (childSchema == null) {
                                childSchema = newFeatureDatasetSchema(schema, childPath);
                            } else {
                                if (childSchema.isInitialized()) {
                                    childSchema.refresh();
                                }
                            }
                            elementsByPath.put(childPath, childSchema);
                        }
                    }
                    if (schemaPath.isParentOf(this.defaultSchemaPath) && !elementsByPath.containsKey(this.defaultSchemaPath)) {
                        final SpatialReference spatialReference = getSpatialReference(getGeometryFactory());
                        final RecordStoreSchema childSchema = newSchema(this.defaultSchemaPath, spatialReference);
                        elementsByPath.put(this.defaultSchemaPath, childSchema);
                    }
                    if (schema.equalPath(this.defaultSchemaPath)) {
                        refreshSchemaRecordDefinitions(elementsByPath, schemaPath, "\\", "Feature Class");
                        refreshSchemaRecordDefinitions(elementsByPath, schemaPath, "\\", "Table");
                    }
                    refreshSchemaRecordDefinitions(elementsByPath, schemaPath, schemaCatalogPath, "Feature Class");
                    refreshSchemaRecordDefinitions(elementsByPath, schemaPath, schemaCatalogPath, "Table");
                } finally {
                    releaseGeodatabase();
                }
            }
            return elementsByPath;
        }
    }
}
Also used : Geodatabase(com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) RecordStoreSchema(com.revolsys.record.schema.RecordStoreSchema) SpatialReference(com.revolsys.record.io.format.esri.gdb.xml.model.SpatialReference) PathName(com.revolsys.io.PathName) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) TreeMap(java.util.TreeMap) RecordStoreSchemaElement(com.revolsys.record.schema.RecordStoreSchemaElement)

Aggregations

Geodatabase (com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase)3 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)3 PathName (com.revolsys.io.PathName)2 SpatialReference (com.revolsys.record.io.format.esri.gdb.xml.model.SpatialReference)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 RecordStoreSchema (com.revolsys.record.schema.RecordStoreSchema)1 RecordStoreSchemaElement (com.revolsys.record.schema.RecordStoreSchemaElement)1 File (java.io.File)1 TreeMap (java.util.TreeMap)1