use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class ShapefileRecordStore method newRecord.
@Override
public Record newRecord(final RecordDefinition recordDefinition) {
final String typePath = recordDefinition.getPath();
final RecordDefinition savedRecordDefinition = getRecordDefinition(typePath);
if (savedRecordDefinition == null) {
return new ArrayRecord(recordDefinition);
} else {
return new ArrayRecord(savedRecordDefinition);
}
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method insertRecord.
void insertRecord(final Table table, final Record record) {
final RecordDefinition sourceRecordDefinition = record.getRecordDefinition();
final RecordDefinition recordDefinition = getRecordDefinition(sourceRecordDefinition);
validateRequired(record, recordDefinition);
final PathName typePath = recordDefinition.getPathName();
if (table == null) {
throw new ObjectException(record, "Cannot find table: " + typePath);
} else {
try {
final Row row = newRowObject(table);
try {
for (final FieldDefinition field : recordDefinition.getFields()) {
final String name = field.getName();
try {
final Object value = record.getValue(name);
final AbstractFileGdbFieldDefinition esriField = (AbstractFileGdbFieldDefinition) field;
esriField.setInsertValue(record, row, value);
} catch (final Throwable e) {
throw new ObjectPropertyException(record, name, e);
}
}
insertRow(table, row);
if (sourceRecordDefinition == recordDefinition) {
for (final FieldDefinition field : recordDefinition.getFields()) {
final AbstractFileGdbFieldDefinition esriField = (AbstractFileGdbFieldDefinition) field;
try {
esriField.setPostInsertValue(record, row);
} catch (final Throwable e) {
throw new ObjectPropertyException(record, field.getName(), e);
}
}
record.setState(RecordState.PERSISTED);
}
} finally {
row.delete();
addStatistic("Insert", record);
}
} catch (final ObjectException e) {
if (e.getObject() == record) {
throw e;
} else {
throw new ObjectException(record, e);
}
} catch (final Throwable e) {
throw new ObjectException(record, e);
}
}
}
use of com.revolsys.record.schema.RecordDefinition 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.record.schema.RecordDefinition 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.record.schema.RecordDefinition 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