Search in sources :

Example 1 with WFSCapabilities

use of eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities in project hale by halestudio.

the class WFSDescribeFeatureWizard method addPages.

@Override
public void addPages() {
    super.addPages();
    /**
     * Page for specifying the WFS capabilities URL.
     */
    AbstractWFSCapabilitiesPage<WFSDescribeFeatureConfig> capPage = new AbstractWFSCapabilitiesPage<WFSDescribeFeatureConfig>(this) {

        @Override
        protected boolean updateConfiguration(WFSDescribeFeatureConfig configuration, URL capabilitiesUrl, WFSCapabilities capabilities) {
            if (capabilities != null && capabilities.getDescribeFeatureOp() != null) {
                WFSOperation op = capabilities.getDescribeFeatureOp();
                configuration.setDescribeFeatureUri(URI.create(op.getHttpGetUrl()));
                configuration.setVersion(capabilities.getVersion());
                return true;
            }
            setErrorMessage("Invalid capabilities or WFS does not support DescribeFeatureType KVP");
            return false;
        }
    };
    addPage(capPage);
    addPage(new AbstractFeatureTypesPage<WFSDescribeFeatureConfig>(this, capPage, "Optionally request schema for specific feature types only") {

        @Override
        protected void updateState(Set<QName> selected) {
            // any selection allowed
            setPageComplete(true);
        }

        @Override
        protected boolean updateConfiguration(WFSDescribeFeatureConfig configuration, Set<QName> selected) {
            configuration.getTypeNames().clear();
            configuration.getTypeNames().addAll(selected);
            return true;
        }
    });
}
Also used : QName(javax.xml.namespace.QName) WFSOperation(eu.esdihumboldt.hale.io.wfs.capabilities.WFSOperation) AbstractWFSCapabilitiesPage(eu.esdihumboldt.hale.io.wfs.ui.capabilities.AbstractWFSCapabilitiesPage) WFSCapabilities(eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities) URL(java.net.URL)

Example 2 with WFSCapabilities

use of eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities in project hale by halestudio.

the class WFSGetFeatureWizard method addPages.

@Override
public void addPages() {
    super.addPages();
    /**
     * Page for specifying the WFS capabilities URL.
     */
    AbstractWFSCapabilitiesPage<WFSGetFeatureConfig> capPage = new AbstractWFSCapabilitiesPage<WFSGetFeatureConfig>(this) {

        @Override
        protected boolean updateConfiguration(WFSGetFeatureConfig configuration, URL capabilitiesUrl, WFSCapabilities capabilities) {
            if (capabilities != null && capabilities.getGetFeatureOp() != null) {
                WFSOperation op = capabilities.getGetFeatureOp();
                configuration.setGetFeatureUri(URI.create(op.getHttpGetUrl()));
                configuration.setVersion(capabilities.getVersion());
                return true;
            }
            setErrorMessage("Invalid capabilities or WFS does not support GetFeature KVP");
            return false;
        }
    };
    addPage(capPage);
    addPage(new AbstractFeatureTypesPage<WFSGetFeatureConfig>(this, capPage, "Please specify the feature types to request") {

        private boolean selectAll = false;

        @Override
        protected void updateState(Set<QName> selected) {
            // at least one type must be specified
            setPageComplete(!selected.isEmpty());
        }

        @Override
        protected Collection<? extends QName> initialSelection(Set<QName> types) {
            // select all by default
            if (selectAll) {
                return types;
            }
            return super.initialSelection(types);
        }

        @Override
        protected Set<QName> filterTypes(Set<QName> types) {
            // relevant types
            if (schemaSpaceID != null) {
                SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
                if (ss != null) {
                    Set<QName> relevantElements = new HashSet<>();
                    SchemaSpace schemas = ss.getSchemas(schemaSpaceID);
                    for (TypeDefinition type : schemas.getMappingRelevantTypes()) {
                        XmlElements elms = type.getConstraint(XmlElements.class);
                        for (XmlElement elm : elms.getElements()) {
                            relevantElements.add(elm.getName());
                        }
                    }
                    Set<QName> selection = new HashSet<>(types);
                    selection.retainAll(relevantElements);
                    // don't filter if we have no match at all
                    if (!selection.isEmpty()) {
                        selectAll = true;
                        return selection;
                    }
                }
            }
            selectAll = false;
            return super.filterTypes(types);
        }

        @Override
        protected boolean updateConfiguration(WFSGetFeatureConfig configuration, Set<QName> selected) {
            configuration.getTypeNames().clear();
            configuration.getTypeNames().addAll(selected);
            return true;
        }
    });
    // bounding box
    addPage(new BBOXPage(this, capPage));
    // additional params
    addPage(new GetFeatureParamsPage(this));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) QName(javax.xml.namespace.QName) SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) WFSOperation(eu.esdihumboldt.hale.io.wfs.capabilities.WFSOperation) AbstractWFSCapabilitiesPage(eu.esdihumboldt.hale.io.wfs.ui.capabilities.AbstractWFSCapabilitiesPage) WFSCapabilities(eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities) URL(java.net.URL) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) XmlElements(eu.esdihumboldt.hale.io.xsd.constraint.XmlElements) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) Collection(java.util.Collection) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement)

Example 3 with WFSCapabilities

use of eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities in project hale by halestudio.

the class BBOXPage method onShowPage.

@Override
protected void onShowPage() {
    String capUrl = capabilitiesPage.getCapabilitiesURL();
    if (!Objects.equals(capUrl, lastCapUrl)) {
        // capabilities changed
        // update map
        WFSCapabilities caps = capabilitiesPage.getCapabilities();
        bboxTool.reset();
        updateMap(caps);
    } else {
    // capabilities stayed the same
    }
    lastCapUrl = capUrl;
    updateState();
}
Also used : WFSCapabilities(eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities)

Aggregations

WFSCapabilities (eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities)3 WFSOperation (eu.esdihumboldt.hale.io.wfs.capabilities.WFSOperation)2 AbstractWFSCapabilitiesPage (eu.esdihumboldt.hale.io.wfs.ui.capabilities.AbstractWFSCapabilitiesPage)2 URL (java.net.URL)2 QName (javax.xml.namespace.QName)2 SchemaSpace (eu.esdihumboldt.hale.common.schema.model.SchemaSpace)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 XmlElements (eu.esdihumboldt.hale.io.xsd.constraint.XmlElements)1 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)1 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1