Search in sources :

Example 11 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class DirectoryRecordStore method loadRecordDefinition.

protected RecordDefinition loadRecordDefinition(final RecordStoreSchema schema, final String schemaName, final Resource resource) {
    try (RecordReader recordReader = RecordReader.newRecordReader(resource)) {
        final String typePath = PathUtil.toPath(schemaName, resource.getBaseName());
        recordReader.setProperty("schema", schema);
        recordReader.setProperty("typePath", typePath);
        final RecordDefinition recordDefinition = recordReader.getRecordDefinition();
        if (recordDefinition != null) {
            this.resourcesByRecordDefinition.put(recordDefinition, resource);
            this.typePathByResource.put(resource, typePath);
        }
        return recordDefinition;
    }
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 12 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class DirectoryRecordWriter method getWriter.

private Writer<Record> getWriter(final Record record) {
    final RecordDefinition recordDefinition = record.getRecordDefinition();
    final String path = recordDefinition.getPath();
    Writer<Record> writer = this.writers.get(path);
    if (writer == null) {
        final File directory = getDirectory(recordDefinition);
        directory.mkdirs();
        final String fileName = getFileName(recordDefinition);
        final File file = new File(directory, fileName + this.nameSuffix + "." + this.fileExtension);
        final PathResource resource = new PathResource(file);
        writer = RecordWriter.newRecordWriter(recordDefinition, resource);
        if (writer == null) {
            throw new IllegalArgumentException("Unable to create writer for " + resource);
        } else {
            final Map<String, Object> properties = getProperties();
            writer.setProperties(properties);
            final Geometry geometry = record.getGeometry();
            if (geometry != null) {
                final GeometryFactory geometryFactory = geometry.getGeometryFactory();
                setProperty(IoConstants.GEOMETRY_FACTORY, geometryFactory);
            }
            this.writers.put(path, writer);
            RecordDefinition writerRecordDefinition = recordDefinition;
            if (writer instanceof AbstractRecordWriter) {
                final AbstractRecordWriter recordWriter = (AbstractRecordWriter) writer;
                writerRecordDefinition = recordWriter.getRecordDefinition();
                if (writerRecordDefinition == null) {
                    writerRecordDefinition = recordDefinition;
                }
            }
            this.recordDefinitionMap.put(path, writerRecordDefinition);
        }
    }
    return writer;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) AbstractRecordWriter(com.revolsys.io.AbstractRecordWriter) PathResource(com.revolsys.spring.resource.PathResource) Record(com.revolsys.record.Record) File(java.io.File) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 13 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordIo method copyRecords.

static void copyRecords(final RecordReader reader, final Object target) {
    if (reader != null) {
        final RecordDefinition recordDefinition = reader.getRecordDefinition();
        copyRecords(recordDefinition, reader, target);
    }
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 14 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordStoreQueryTask method run.

@Override
public void run() {
    this.objects = new ArrayList<>();
    final RecordDefinition recordDefinition = this.recordStore.getRecordDefinition(this.path);
    final Query query = Query.intersects(recordDefinition, this.boundingBox);
    try (final Reader<Record> reader = this.recordStore.getRecords(query)) {
        for (final Record object : reader) {
            try {
                this.objects.add(object);
            } catch (final NullPointerException e) {
                return;
            }
        }
    }
}
Also used : Query(com.revolsys.record.query.Query) Record(com.revolsys.record.Record) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 15 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordDirectoryReader method addRecordDefinition.

protected void addRecordDefinition(final RecordReader reader) {
    final RecordDefinition recordDefinition = reader.getRecordDefinition();
    if (recordDefinition != null) {
        final String path = recordDefinition.getPath();
        this.typePathRecordDefinitionMap.put(path, recordDefinition);
    }
}
Also used : 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