use of com.revolsys.gis.esri.gdb.file.capi.swig.Table in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method releaseTableAndWriteLock.
protected void releaseTableAndWriteLock(final String catalogPath) {
synchronized (this.apiSync) {
final Geodatabase geodatabase = getGeodatabase();
if (geodatabase != null) {
try {
final Table table = this.tableByCatalogPath.get(catalogPath);
if (table != null) {
final Integer count = Maps.decrementCount(this.tableWriteLockCountsByCatalogPath, catalogPath);
if (count == 0) {
try {
table.setLoadOnlyMode(false);
table.freeWriteLock();
} catch (final Exception e) {
Logs.error(this, "Unable to free write lock for table: " + catalogPath, e);
}
}
}
releaseTable(catalogPath);
} finally {
releaseGeodatabase();
}
}
}
}
use of com.revolsys.gis.esri.gdb.file.capi.swig.Table in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method deleteRecord.
@Override
public boolean deleteRecord(final Record record) {
if (record == null) {
return false;
} else {
final RecordDefinition recordDefinition = record.getRecordDefinition();
final Table table = getTableWithWriteLock(recordDefinition);
try {
return deleteRecord(table, record);
} finally {
releaseTableAndWriteLock(recordDefinition);
}
}
}
use of com.revolsys.gis.esri.gdb.file.capi.swig.Table in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method closeTable.
public boolean closeTable(final PathName typePath) {
synchronized (this.apiSync) {
final String path = getCatalogPath(typePath);
int count = Maps.getInteger(this.tableReferenceCountsByCatalogPath, path, 0);
count--;
if (count <= 0) {
this.tableReferenceCountsByCatalogPath.remove(path);
final Table table = this.tableByCatalogPath.remove(path);
synchronized (API_SYNC) {
if (table != null) {
try {
final Geodatabase geodatabase = getGeodatabase();
if (geodatabase != null) {
try {
geodatabase.closeTable(table);
} finally {
releaseGeodatabase();
}
}
} catch (final Throwable e) {
Logs.error(this, "Cannot close Table " + typePath, e);
} finally {
try {
table.delete();
} catch (final Throwable t) {
}
}
}
}
return true;
} else {
this.tableReferenceCountsByCatalogPath.put(path, count);
return false;
}
}
}
use of com.revolsys.gis.esri.gdb.file.capi.swig.Table in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method newTableRecordDefinition.
private RecordDefinitionImpl newTableRecordDefinition(final DETable deTable) {
synchronized (this.apiSync) {
synchronized (API_SYNC) {
final Geodatabase geodatabase = getGeodatabase();
if (geodatabase == null) {
return null;
} else {
try {
String schemaCatalogPath = deTable.getParentCatalogPath();
SpatialReference spatialReference;
if (deTable instanceof DEFeatureClass) {
final DEFeatureClass featureClass = (DEFeatureClass) deTable;
spatialReference = featureClass.getSpatialReference();
} else {
spatialReference = null;
}
PathName schemaPath = toPath(schemaCatalogPath);
final RecordStoreSchema schema = newSchema(schemaPath, spatialReference);
if (schemaPath.equals(this.defaultSchemaPath)) {
if (!(deTable instanceof DEFeatureClass)) {
schemaCatalogPath = "\\";
deTable.setCatalogPath("\\" + deTable.getName());
}
} else if (schemaPath.equals("")) {
schemaPath = this.defaultSchemaPath;
}
for (final Field field : deTable.getFields()) {
final String fieldName = field.getName();
final CodeTable codeTable = getCodeTableByFieldName(fieldName);
if (codeTable instanceof FileGdbDomainCodeTable) {
final FileGdbDomainCodeTable domainCodeTable = (FileGdbDomainCodeTable) codeTable;
field.setDomain(domainCodeTable.getDomain());
}
}
final String tableDefinition = EsriGdbXmlSerializer.toString(deTable);
try {
final Table table = geodatabase.createTable(tableDefinition, schemaCatalogPath);
geodatabase.closeTable(table);
table.delete();
final RecordDefinitionImpl recordDefinition = getRecordDefinition(PathName.newPathName(schemaPath), schemaCatalogPath, tableDefinition);
initRecordDefinition(recordDefinition);
schema.addElement(recordDefinition);
return recordDefinition;
} catch (final Throwable t) {
throw new RuntimeException("Unable to create table " + deTable.getCatalogPath(), t);
}
} finally {
releaseGeodatabase();
}
}
}
}
}
use of com.revolsys.gis.esri.gdb.file.capi.swig.Table in project com.revolsys.open by revolsys.
the class FileGdbWriter method getTable.
private Table getTable(final Record record) {
final RecordDefinition recordDefinition = record.getRecordDefinition();
final String catalogPath = this.recordStore.getCatalogPath(recordDefinition);
Table table = this.tablesByCatalogPath.get(catalogPath);
if (table == null) {
table = this.recordStore.getTableWithWriteLock(recordDefinition);
if (table != null) {
this.tablesByCatalogPath.put(catalogPath, table);
}
}
return table;
}
Aggregations