Search in sources :

Example 1 with WfsBackedGmlInstanceCollection

use of eu.esdihumboldt.hale.io.gml.reader.internal.wfs.WfsBackedGmlInstanceCollection in project hale by halestudio.

the class StreamGmlReader method execute.

/**
 * @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
 */
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
    progress.begin("Prepare loading of " + getTypeName(), ProgressIndicator.UNKNOWN);
    try {
        boolean ignoreRoot = getParameter(PARAM_IGNORE_ROOT).as(Boolean.class, true);
        boolean strict = getParameter(PARAM_STRICT).as(Boolean.class, false);
        boolean ignoreNamespaces = getParameter(PARAM_IGNORE_NAMESPACES).as(Boolean.class, false);
        boolean paginateRequest = getParameter(PARAM_PAGINATE_REQUEST).as(Boolean.class, false);
        boolean ignoreNumberMatched = getParameter(PARAM_IGNORE_NUMBER_MATCHED).as(Boolean.class, false);
        int featuresPerRequest;
        if (paginateRequest) {
            featuresPerRequest = getParameter(PARAM_FEATURES_PER_WFS_REQUEST).as(Integer.class, 1000);
        } else {
            featuresPerRequest = WfsBackedGmlInstanceCollection.UNLIMITED;
        }
        LocatableInputSupplier<? extends InputStream> source = getSource();
        String scheme = null;
        String query = null;
        if (source.getLocation() != null) {
            scheme = source.getLocation().getScheme();
            query = source.getLocation().getQuery();
        }
        if (query != null && scheme != null && query.toLowerCase().contains("request=getfeature") && (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https"))) {
            // check if WFS is reachable and responds?
            instances = new WfsBackedGmlInstanceCollection(getSource(), getSourceSchema(), restrictToFeatures, ignoreRoot, strict, ignoreNamespaces, getCrsProvider(), this, featuresPerRequest, ignoreNumberMatched);
        } else {
            instances = new GmlInstanceCollection(getSource(), getSourceSchema(), restrictToFeatures, ignoreRoot, strict, ignoreNamespaces, getCrsProvider(), this);
        }
        // TODO any kind of analysis on file? e.g. types and size - would
        // also give feedback to the user if the file can be loaded
        reporter.setSuccess(true);
    } catch (Throwable e) {
        reporter.error(new IOMessageImpl(e.getMessage(), e));
        reporter.setSuccess(false);
    }
    return reporter;
}
Also used : WfsBackedGmlInstanceCollection(eu.esdihumboldt.hale.io.gml.reader.internal.wfs.WfsBackedGmlInstanceCollection) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) WfsBackedGmlInstanceCollection(eu.esdihumboldt.hale.io.gml.reader.internal.wfs.WfsBackedGmlInstanceCollection)

Aggregations

IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 WfsBackedGmlInstanceCollection (eu.esdihumboldt.hale.io.gml.reader.internal.wfs.WfsBackedGmlInstanceCollection)1