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();
}
}
}
}
}
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);
}
}
}
}
}
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;
}
}
}
Aggregations