Search in sources :

Example 16 with RecordDefinition

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

the class SaifReader method open.

/**
 * Open a SAIF archive, extracting compressed archives to a temporary
 * directory.
 */
@Override
public void open() {
    if (!this.opened) {
        this.opened = true;
        try {
            if (log.isDebugEnabled()) {
                log.debug("Opening SAIF archive '" + this.file.getCanonicalPath() + "'");
            }
            if (this.file.isDirectory()) {
                this.saifArchiveDirectory = this.file;
            } else if (!this.file.exists()) {
                throw new IllegalArgumentException("SAIF file " + this.file + " does not exist");
            } else {
                this.zipFile = new ZipFile(this.file);
            }
            if (log.isDebugEnabled()) {
                log.debug("  Finished opening archive");
            }
            loadSchema();
            loadExportedObjects();
            loadSrid();
            final GeometryFactory geometryFactory = GeometryFactory.fixed3d(this.srid, 1.0, 1.0, 1.0);
            for (final RecordDefinition recordDefinition : ((RecordDefinitionFactoryImpl) this.recordDefinitionFactory).getRecordDefinitions()) {
                final FieldDefinition geometryField = recordDefinition.getGeometryField();
                if (geometryField != null) {
                    geometryField.setProperty(FieldProperties.GEOMETRY_FACTORY, geometryFactory);
                }
            }
        } catch (final IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
}
Also used : RecordDefinitionFactoryImpl(com.revolsys.record.schema.RecordDefinitionFactoryImpl) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ZipFile(java.util.zip.ZipFile) FieldDefinition(com.revolsys.record.schema.FieldDefinition) IOException(java.io.IOException) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 17 with RecordDefinition

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

the class SaifWriter method write.

@Override
public void write(final Record object) {
    try {
        final RecordDefinition type = object.getRecordDefinition();
        final OsnSerializer serializer = getSerializer(type.getPath());
        if (serializer != null) {
            serializer.serializeRecord(object);
            if (this.indentEnabled) {
                serializer.endLine();
            }
        } else {
            log.error("No serializer for type '" + type.getPath() + "'");
        }
    } catch (final IOException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : OsnSerializer(com.revolsys.record.io.format.saif.util.OsnSerializer) IOException(java.io.IOException) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 18 with RecordDefinition

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

the class SaifWriter method getCompositeType.

private RecordDefinition getCompositeType(final String typePath) {
    String compositeTypeName = this.compositeTypeNames.get(typePath);
    if (compositeTypeName == null) {
        compositeTypeName = typePath + "Composite";
    }
    final RecordDefinition compisteType = this.recordDefinitionFactory.getRecordDefinition(String.valueOf(compositeTypeName));
    return compisteType;
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 19 with RecordDefinition

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

the class ShapefileDirectoryWriter method getWriter.

private Writer<Record> getWriter(final Record object) {
    final RecordDefinition recordDefinition = object.getRecordDefinition();
    final String path = recordDefinition.getPath();
    Writer<Record> writer = this.writers.get(path);
    if (writer == null) {
        final File directory = getDirectory(recordDefinition);
        directory.mkdirs();
        final File file = new File(directory, getFileName(recordDefinition) + this.nameSuffix + ".shp");
        writer = RecordWriter.newRecordWriter(recordDefinition, new PathResource(file));
        ((XbaseRecordWriter) writer).setUseZeroForNull(this.useZeroForNull);
        final Geometry geometry = object.getGeometry();
        if (geometry != null) {
            setProperty(IoConstants.GEOMETRY_FACTORY, geometry.getGeometryFactory());
        }
        this.writers.put(path, writer);
        this.recordDefinitionMap.put(path, ((ShapefileRecordWriter) writer).getRecordDefinition());
    }
    return writer;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) XbaseRecordWriter(com.revolsys.record.io.format.xbase.XbaseRecordWriter) PathResource(com.revolsys.spring.resource.PathResource) Record(com.revolsys.record.Record) File(java.io.File) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 20 with RecordDefinition

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

the class OsnSerializer method serializeStartObject.

public void serializeStartObject(final Record object) throws IOException {
    final RecordDefinition type = object.getRecordDefinition();
    final String path = type.getPath();
    startObject(path);
}
Also used : LineString(com.revolsys.geometry.model.LineString) 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