use of com.revolsys.beans.ObjectPropertyException 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.beans.ObjectPropertyException in project com.revolsys.open by revolsys.
the class RecordLayerErrors method addRecord.
public void addRecord(final LayerRecord record, final Throwable exception) {
this.records.add(record);
String message;
if (exception instanceof ObjectPropertyException) {
final ObjectPropertyException objectPropertyException = (ObjectPropertyException) exception;
message = objectPropertyException.getPropertyName() + ": " + objectPropertyException.getMessage();
} else {
message = exception.getMessage();
}
if (!Property.hasValue(message)) {
message = "Null pointer";
}
this.messages.add(message);
this.exceptions.add(exception);
}
use of com.revolsys.beans.ObjectPropertyException in project com.revolsys.open by revolsys.
the class RecordLayerErrorsTableModel method addRecord.
public void addRecord(final LayerRecord record, final Throwable exception) {
super.add(record);
String message;
if (exception instanceof ObjectPropertyException) {
final ObjectPropertyException objectPropertyException = (ObjectPropertyException) exception;
message = objectPropertyException.getPropertyName() + ": " + objectPropertyException.getMessage();
} else {
message = exception.getMessage();
}
this.messages.add(message);
this.exceptions.add(exception);
}
use of com.revolsys.beans.ObjectPropertyException in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method updateRecord.
void updateRecord(final Table table, final Record record) {
final Object objectId = record.getValue("OBJECTID");
if (objectId == null) {
insertRecord(table, record);
} else {
final RecordDefinition sourceRecordDefinition = record.getRecordDefinition();
final RecordDefinition recordDefinition = getRecordDefinition(sourceRecordDefinition);
validateRequired(record, recordDefinition);
final PathName typePath = sourceRecordDefinition.getPathName();
final String whereClause = "OBJECTID=" + objectId;
try (final FileGdbEnumRowsIterator rows = search(typePath, table, "*", whereClause, false)) {
for (final Row row : rows) {
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.setUpdateValue(record, row, value);
} catch (final Throwable e) {
throw new ObjectPropertyException(record, name, e);
}
}
updateRow(typePath, table, row);
record.setState(RecordState.PERSISTED);
addStatistic("Update", 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);
}
}
}
}
}
Aggregations