Search in sources :

Example 1 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace 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 2 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.

the class StyleServiceImpl method getStyle.

private Style getStyle(final DataSet dataset, boolean selected) {
    SchemaSpace schemas = schemaService.getSchemas((dataset == DataSet.SOURCE) ? (SchemaSpaceID.SOURCE) : (SchemaSpaceID.TARGET));
    Style style = styleFactory.createStyle();
    for (TypeDefinition type : schemas.getMappingRelevantTypes()) {
        if (!type.getConstraint(AbstractFlag.class).isEnabled()) {
            // only add styles for non-abstract feature types
            FeatureTypeStyle fts = styles.get(type);
            if (fts == null) {
                if (fbStyle != null) {
                    fts = fbStyle;
                } else {
                    fts = StyleHelper.getDefaultStyle(type, dataset);
                }
            }
            if (selected) {
                fts = getSelectedStyle(fts);
            }
            style.featureTypeStyles().add(fts);
        }
    }
    return style;
}
Also used : SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 3 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.

the class RootElementPage method updateList.

private void updateList() {
    if (// during enable if content not yet created
    list != null && getWizard().getProvider() != null) {
        // TODO instead of showing all elements allow filtering for elements
        // that can hold the type in some form?
        SchemaSpace schemas = getWizard().getProvider().getTargetSchema();
        XmlIndex index = StreamGmlWriter.getXMLIndex(schemas);
        // FIXME use filtered table for selection?
        list.setInput(index.getElements().values());
        setPageComplete(!list.getSelection().isEmpty());
    }
}
Also used : SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) XmlIndex(eu.esdihumboldt.hale.io.xsd.model.XmlIndex)

Example 4 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.

the class AbstractTargetAction method run.

@Override
public void run() {
    // if Display not the active Thread
    if (Display.getCurrent() == null) {
        // execute in display thread
        PlatformUI.getWorkbench().getDisplay().asyncExec(this);
        return;
    }
    if (params == null || params.isEmpty()) {
        return;
    }
    // retrieve the target schema
    SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
    SchemaSpace targetSchema = ss.getSchemas(SchemaSpaceID.TARGET);
    // find type
    QName typeName = QName.valueOf(params.get(0));
    TypeDefinition type = targetSchema.getType(typeName);
    if (type == null) {
        // check all mapping relevant types for local name only
        for (TypeDefinition candidate : targetSchema.getMappingRelevantTypes()) {
            if (candidate.getName().getLocalPart().equals(params.get(0))) {
                // use the first found
                type = candidate;
                break;
            }
        }
    }
    if (type != null) {
        EntityDefinition entity = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
        if (params.size() > 1) {
            // determine property entity
            EntityAccessor accessor = new EntityAccessor(entity);
            for (int i = 1; i < params.size(); i++) {
                QName propertyName = QName.valueOf(params.get(i));
                String namespace = propertyName.getNamespaceURI();
                if (namespace != null && namespace.isEmpty()) {
                    // treat empty namespace as ignoring namespace
                    namespace = null;
                }
                accessor = accessor.findChildren(propertyName.getLocalPart(), namespace);
            }
            entity = accessor.toEntityDefinition();
        }
        if (entity != null) {
            run(entity, manager);
        } else {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", "The schema element was not found in the target schema, please make sure the correct schema is loaded.");
        }
    } else {
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", MessageFormat.format("The type {0} was not found in the target schema, please make sure the correct schema is loaded.", typeName.getLocalPart()));
    }
}
Also used : EntityAccessor(eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) QName(javax.xml.namespace.QName) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 5 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.

the class OmlReader method findElementType.

private QName findElementType(TypeIndex schema, QName elementName) {
    if (schema instanceof SchemaSpace) {
        SchemaSpace ss = (SchemaSpace) schema;
        for (Schema schem : ss.getSchemas()) {
            if (schem instanceof XmlIndex) {
                XmlElement xmlelem = ((XmlIndex) schem).getElements().get(elementName);
                if (xmlelem != null) {
                    return xmlelem.getType().getName();
                }
                // if there is no element try to find one with an extra "/"
                // sign in the namespace because in earlier version this
                // case can occur
                xmlelem = ((XmlIndex) schem).getElements().get(new QName(elementName.getNamespaceURI() + "/", elementName.getLocalPart()));
                if (xmlelem != null) {
                    return xmlelem.getType().getName();
                }
            }
        }
    } else {
        for (TypeDefinition typedef : schema.getTypes()) {
            XmlElements xmlelem = typedef.getConstraint(XmlElements.class);
            for (XmlElement elem : xmlelem.getElements()) {
                if (elem.getName().equals(elementName) || elem.getName().equals(new QName(elementName.getNamespaceURI() + "/", elementName.getLocalPart()))) {
                    return typedef.getName();
                }
            }
        }
    }
    return elementName;
}
Also used : XmlElements(eu.esdihumboldt.hale.io.xsd.constraint.XmlElements) SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) QName(javax.xml.namespace.QName) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) XmlIndex(eu.esdihumboldt.hale.io.xsd.model.XmlIndex) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

SchemaSpace (eu.esdihumboldt.hale.common.schema.model.SchemaSpace)7 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)5 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)4 XmlIndex (eu.esdihumboldt.hale.io.xsd.model.XmlIndex)4 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)3 QName (javax.xml.namespace.QName)3 XmlElements (eu.esdihumboldt.hale.io.xsd.constraint.XmlElements)2 EntityAccessor (eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor)1 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 SchemaSpaceID (eu.esdihumboldt.hale.common.schema.SchemaSpaceID)1 DefinitionAccessor (eu.esdihumboldt.hale.common.schema.groovy.DefinitionAccessor)1 Definition (eu.esdihumboldt.hale.common.schema.model.Definition)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)1 WFSCapabilities (eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities)1 WFSOperation (eu.esdihumboldt.hale.io.wfs.capabilities.WFSOperation)1 AbstractWFSCapabilitiesPage (eu.esdihumboldt.hale.io.wfs.ui.capabilities.AbstractWFSCapabilitiesPage)1 AttributeEditorFactory (eu.esdihumboldt.hale.ui.common.definition.AttributeEditorFactory)1 DefinitionLabelFactory (eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory)1