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