Search in sources :

Example 51 with RecordDefinition

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);
    }
}
Also used : ArrayRecord(com.revolsys.record.ArrayRecord) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 52 with RecordDefinition

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);
        }
    }
}
Also used : ObjectPropertyException(com.revolsys.beans.ObjectPropertyException) AbstractFileGdbFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.AbstractFileGdbFieldDefinition) OidFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.OidFieldDefinition) DoubleFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.DoubleFieldDefinition) FloatFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.FloatFieldDefinition) AreaFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.AreaFieldDefinition) StringFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.StringFieldDefinition) AbstractFileGdbFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.AbstractFileGdbFieldDefinition) FieldDefinition(com.revolsys.record.schema.FieldDefinition) GlobalIdFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.GlobalIdFieldDefinition) IntegerFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.IntegerFieldDefinition) GuidFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.GuidFieldDefinition) XmlFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.XmlFieldDefinition) ShortFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.ShortFieldDefinition) LengthFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.LengthFieldDefinition) BinaryFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.BinaryFieldDefinition) DateFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.DateFieldDefinition) GeometryFieldDefinition(com.revolsys.gis.esri.gdb.file.capi.type.GeometryFieldDefinition) PathName(com.revolsys.io.PathName) Row(com.revolsys.gis.esri.gdb.file.capi.swig.Row) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) ObjectException(com.revolsys.beans.ObjectException) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 53 with RecordDefinition

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();
                }
            }
        }
    }
}
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 54 with RecordDefinition

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);
        }
    }
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) DETable(com.revolsys.record.io.format.esri.gdb.xml.model.DETable) Table(com.revolsys.gis.esri.gdb.file.capi.swig.Table) FileGdbDomainCodeTable(com.revolsys.gis.esri.gdb.file.capi.FileGdbDomainCodeTable) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 55 with 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;
}
Also used : Table(com.revolsys.gis.esri.gdb.file.capi.swig.Table) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordDefinition (com.revolsys.record.schema.RecordDefinition)189 FieldDefinition (com.revolsys.record.schema.FieldDefinition)38 Record (com.revolsys.record.Record)34 Geometry (com.revolsys.geometry.model.Geometry)20 CodeTable (com.revolsys.record.code.CodeTable)19 Query (com.revolsys.record.query.Query)18 LineString (com.revolsys.geometry.model.LineString)17 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)16 PathName (com.revolsys.io.PathName)13 ArrayList (java.util.ArrayList)12 DataType (com.revolsys.datatype.DataType)11 Identifier (com.revolsys.identifier.Identifier)11 RecordReader (com.revolsys.record.io.RecordReader)11 RecordStore (com.revolsys.record.schema.RecordStore)11 HashMap (java.util.HashMap)9 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)8 ArrayRecord (com.revolsys.record.ArrayRecord)8 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)6 Table (com.revolsys.gis.esri.gdb.file.capi.swig.Table)5 RecordWriter (com.revolsys.record.io.RecordWriter)5