use of com.revolsys.properties.ObjectWithProperties in project com.revolsys.open by revolsys.
the class DirectoryRecordStore method insertRecord.
@Override
public synchronized void insertRecord(final Record record) {
final RecordDefinition recordDefinition = record.getRecordDefinition();
final String typePath = recordDefinition.getPath();
RecordWriter writer = this.writers.get(typePath);
if (writer == null) {
final String schemaName = PathUtil.getPath(typePath);
final File subDirectory = FileUtil.getDirectory(getDirectory(), schemaName);
final String fileExtension = getFileExtension();
final File file = new File(subDirectory, recordDefinition.getName() + "." + fileExtension);
final Resource resource = new PathResource(file);
writer = RecordWriter.newRecordWriter(recordDefinition, resource);
if (writer == null) {
throw new RuntimeException("Cannot create writer for: " + typePath);
} else if (writer instanceof ObjectWithProperties) {
final ObjectWithProperties properties = writer;
properties.setProperties(getProperties());
}
this.writers.put(typePath, writer);
}
writer.write(record);
addStatistic("Insert", record);
}
Aggregations