use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class AbstractRecordIoFactory method newRecordStore.
@Override
public RecordStore newRecordStore(final Map<String, ? extends Object> connectionProperties) {
final String url = (String) connectionProperties.get("url");
final Resource resource = Resource.getResource(url);
final File directory = resource.getFile();
final List<String> fileExtensions = getFileExtensions();
return new DirectoryRecordStore(directory, fileExtensions);
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class RecordReader method newRecordReader.
static RecordReader newRecordReader(final Object source, final RecordFactory<? extends Record> recordFactory, final MapEx properties) {
final RecordReaderFactory readerFactory = IoFactory.factory(RecordReaderFactory.class, source);
if (readerFactory == null) {
return null;
} else {
final Resource resource = readerFactory.getZipResource(source);
final RecordReader reader = readerFactory.newRecordReader(resource, recordFactory, properties);
return reader;
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class RecordWriter method newRecordWriter.
static RecordWriter newRecordWriter(final RecordDefinition recordDefinition, final Object target) {
final Resource resource = Resource.getResource(target);
final RecordWriterFactory writerFactory = IoFactory.factory(RecordWriterFactory.class, resource);
if (writerFactory == null || recordDefinition == null) {
return null;
} else {
final RecordWriter writer = writerFactory.newRecordWriter(recordDefinition, resource);
return writer;
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class SaifWriter method initialize.
private void initialize() throws IOException {
if (!this.initialized) {
this.initialized = true;
if (this.schemaResource != null) {
final InputStream in = getClass().getResourceAsStream(this.schemaResource);
if (in != null) {
FileUtil.copy(in, new File(this.tempDirectory, "clasdefs.csn"));
}
}
if (this.schemaFileNames != null) {
try {
final OutputStream out = new FileOutputStream(new File(this.tempDirectory, "clasdefs.csn"));
try {
for (final Resource resource : this.schemaFileNames) {
final InputStream in = resource.getInputStream();
final SaifSchemaReader reader = new SaifSchemaReader();
setRecordDefinitionFactory(reader.loadSchemas(this.schemaFileNames));
try {
FileUtil.copy(in, out);
} finally {
in.close();
}
}
} finally {
out.close();
}
} catch (final IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class ModuleImport method setResource.
public void setResource(final String resourceUrl) {
final Resource resource = Resource.getResource(resourceUrl);
this.resources.add(resource);
}
Aggregations