Search in sources :

Example 11 with Resource

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);
}
Also used : DirectoryRecordStore(com.revolsys.record.io.format.directory.DirectoryRecordStore) Resource(com.revolsys.spring.resource.Resource) File(java.io.File)

Example 12 with Resource

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;
    }
}
Also used : ZipRecordReader(com.revolsys.record.io.format.zip.ZipRecordReader) Resource(com.revolsys.spring.resource.Resource)

Example 13 with Resource

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;
    }
}
Also used : Resource(com.revolsys.spring.resource.Resource)

Example 14 with Resource

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);
            }
        }
    }
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Resource(com.revolsys.spring.resource.Resource) IOException(java.io.IOException) File(java.io.File)

Example 15 with Resource

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);
}
Also used : Resource(com.revolsys.spring.resource.Resource)

Aggregations

Resource (com.revolsys.spring.resource.Resource)78 PathResource (com.revolsys.spring.resource.PathResource)23 MapEx (com.revolsys.collection.map.MapEx)9 File (java.io.File)9 IOException (java.io.IOException)8 InputStream (java.io.InputStream)6 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)5 UrlResource (com.revolsys.spring.resource.UrlResource)5 Writer (java.io.Writer)5 Record (com.revolsys.record.Record)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)4 DataType (com.revolsys.datatype.DataType)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Geometry (com.revolsys.geometry.model.Geometry)3 AbstractRecordWriter (com.revolsys.io.AbstractRecordWriter)3 ArrayRecord (com.revolsys.record.ArrayRecord)3 RecordReader (com.revolsys.record.io.RecordReader)3 RecordWriter (com.revolsys.record.io.RecordWriter)3 Blob (java.sql.Blob)3