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);
}
}
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations