Search in sources :

Example 1 with RecordDefinitionFactoryImpl

use of com.revolsys.record.schema.RecordDefinitionFactoryImpl 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 2 with RecordDefinitionFactoryImpl

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

the class SaifSchemaReader method loadSchema.

private RecordDefinitionFactory loadSchema(final CsnIterator iterator) throws IOException {
    if (this.schema == null) {
        this.schema = new RecordDefinitionFactoryImpl();
        this.schema.addRecordDefinition(new RecordDefinitionImpl(PathName.newPathName("/AggregateType")));
        this.schema.addRecordDefinition(new RecordDefinitionImpl(PathName.newPathName("/PrimitiveType")));
        addExportedObjects();
    }
    while (iterator.next() != CsnIterator.END_DOCUMENT) {
        this.currentSuperClasses.clear();
        this.currentClass = null;
        final Object definition = getDefinition(iterator);
        if (definition instanceof RecordDefinition) {
            final RecordDefinitionImpl recordDefinition = (RecordDefinitionImpl) definition;
            setRecordDefinitionProperties(recordDefinition);
            recordDefinition.setRecordDefinitionFactory(this.schema);
            this.schema.addRecordDefinition(recordDefinition);
        }
    }
    return this.schema;
}
Also used : RecordDefinitionFactoryImpl(com.revolsys.record.schema.RecordDefinitionFactoryImpl) RecordDefinitionImpl(com.revolsys.record.schema.RecordDefinitionImpl) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordDefinition (com.revolsys.record.schema.RecordDefinition)2 RecordDefinitionFactoryImpl (com.revolsys.record.schema.RecordDefinitionFactoryImpl)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)1 IOException (java.io.IOException)1 ZipFile (java.util.zip.ZipFile)1