Search in sources :

Example 31 with PropertyEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.

the class FilterEditor method setValue.

/**
 * @see Editor#setValue(Object)
 */
@Override
public void setValue(final Filter filter) {
    filterEnabled.setSelection(false);
    setControlsEnabled(false);
    if (filter != null) {
        filter.accept(new FilterVisitor() {

            @Override
            protected void visitFilter(FilterIdentifier id, String propertyName, String value) {
                Boolean invalidProperty = false;
                List<ChildContext> path = new ArrayList<ChildContext>();
                // set the correct selected name for the property selector
                List<QName> qNames = PropertyResolver.getQNamesFromPath(propertyName);
                ChildDefinition<?> child = typeDefinition.getChild(qNames.get(0));
                if (child != null) {
                    path.add(new ChildContext(child));
                    for (int i = 1; i < qNames.size(); i++) {
                        child = DefinitionUtil.getChild(child, qNames.get(i));
                        if (child != null) {
                            path.add(new ChildContext(child));
                        } else {
                            invalidProperty = true;
                            break;
                        }
                    }
                } else {
                    invalidProperty = true;
                }
                if (!invalidProperty && !path.isEmpty()) {
                    PropertyEntityDefinition entity = new PropertyEntityDefinition(typeDefinition, path, null, null);
                    propertySelect.setSelection(new StructuredSelection(entity));
                } else {
                    propertySelect.setSelection(new StructuredSelection());
                }
                // set filter
                filterSelect.setSelection(new StructuredSelection(id));
                // set value
                literal.getDocument().set(value);
                filterEnabled.setSelection(true);
                setControlsEnabled(true);
            }
        }, null);
    }
}
Also used : PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext) ArrayList(java.util.ArrayList) List(java.util.List)

Example 32 with PropertyEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.

the class AppSchemaMappingTest method buildJoinCell.

@SuppressWarnings("null")
private DefaultCell buildJoinCell(FeatureChaining chainingConf) {
    boolean withChaining = chainingConf != null;
    DefaultCell joinCell = new DefaultCell();
    joinCell.setTransformationIdentifier(JoinFunction.ID);
    if (withChaining) {
        // set cell ID from feature chaining configuration
        // WARNING: this code assumes only one join is configured
        joinCell.setId(chainingConf.getJoins().keySet().iterator().next());
    }
    TypeEntityDefinition datasetEntityDef = new TypeEntityDefinition(datasetType, SchemaSpaceID.SOURCE, null);
    TypeEntityDefinition unitEntityDef = null;
    TypeEntityDefinition observationEntityDef = null;
    if (!withChaining) {
        unitEntityDef = new TypeEntityDefinition(unitDenormType, SchemaSpaceID.SOURCE, null);
    } else {
        unitEntityDef = new TypeEntityDefinition(unitType, SchemaSpaceID.SOURCE, null);
        observationEntityDef = new TypeEntityDefinition(observationType, SchemaSpaceID.SOURCE, null);
    }
    ListMultimap<String, Type> source = ArrayListMultimap.create();
    source.put(JoinFunction.JOIN_TYPES, new DefaultType(datasetEntityDef));
    source.put(JoinFunction.JOIN_TYPES, new DefaultType(unitEntityDef));
    if (observationEntityDef != null) {
        source.put(JoinFunction.JOIN_TYPES, new DefaultType(observationEntityDef));
        assertEquals(3, source.get(JoinFunction.JOIN_TYPES).size());
    } else {
        assertEquals(2, source.get(JoinFunction.JOIN_TYPES).size());
    }
    ListMultimap<String, Type> target = ArrayListMultimap.create();
    target.put(null, new DefaultType(new TypeEntityDefinition(landCoverDatasetType, SchemaSpaceID.TARGET, null)));
    List<TypeEntityDefinition> types = new ArrayList<TypeEntityDefinition>(Arrays.asList(datasetEntityDef, unitEntityDef));
    Set<JoinCondition> conditions = new HashSet<JoinCondition>();
    // join dataset and unit
    PropertyEntityDefinition baseProperty = getDatasetIdSourceProperty().values().iterator().next().getDefinition();
    PropertyEntityDefinition joinProperty = getUnitDatasetIdSourceProperty(unitEntityDef.getType()).values().iterator().next().getDefinition();
    conditions.add(new JoinCondition(baseProperty, joinProperty));
    if (withChaining) {
        // add observation type
        types.add(observationEntityDef);
        // join unit and observation
        baseProperty = getUnitIdSourceProperty(unitEntityDef.getType()).values().iterator().next().getDefinition();
        joinProperty = getObservationUnitIdSourceProperty().values().iterator().next().getDefinition();
        conditions.add(new JoinCondition(baseProperty, joinProperty));
    }
    JoinParameter joinParam = new JoinParameter(types, conditions);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(JoinFunction.PARAMETER_JOIN, new ParameterValue(new ComplexValue(joinParam)));
    joinCell.setSource(source);
    joinCell.setTarget(target);
    joinCell.setTransformationParameters(parameters);
    return joinCell;
}
Also used : ComplexValue(eu.esdihumboldt.hale.common.core.io.impl.ComplexValue) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) ArrayList(java.util.ArrayList) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Type(eu.esdihumboldt.hale.common.align.model.Type) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) HashSet(java.util.HashSet)

Example 33 with PropertyEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.

the class FeatureChainingComplexType method toDOM.

/**
 * @see eu.esdihumboldt.hale.common.core.io.ComplexValueType#toDOM(java.lang.Object)
 */
@Override
public Element toDOM(FeatureChaining value) {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    try {
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        Element featureChainingEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "FeatureChaining");
        featureChainingEl.setPrefix(APP_SCHEMA_PREFIX);
        if (value != null && value.joins != null) {
            for (JoinConfiguration joinConf : value.joins.values()) {
                Element joinEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "join");
                joinEl.setAttribute("id", joinConf.getJoinCellId());
                featureChainingEl.appendChild(joinEl);
                if (joinConf.chains != null) {
                    for (ChainConfiguration chainConf : joinConf.chains.values()) {
                        Element chainEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "chain");
                        chainEl.setAttribute("index", Integer.toString(chainConf.getChainIndex()));
                        chainEl.setAttribute("prevChainIndex", Integer.toString(chainConf.getPrevChainIndex()));
                        joinEl.appendChild(chainEl);
                        PropertyEntityDefinition nestedTypeTarget = chainConf.getNestedTypeTarget();
                        Element nestedTargetEl = DOMEntityDefinitionHelper.propertyToDOM(nestedTypeTarget);
                        if (nestedTargetEl != null) {
                            Node nestedTargetAdopted = doc.adoptNode(nestedTargetEl);
                            if (nestedTargetAdopted == null) {
                                nestedTargetAdopted = doc.importNode(nestedTargetEl, true);
                            }
                            chainEl.appendChild(nestedTargetAdopted);
                        }
                        if (chainConf.mappingName != null && !chainConf.mappingName.trim().isEmpty()) {
                            Element mappingEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "mapping");
                            mappingEl.setAttribute("name", chainConf.mappingName);
                            chainEl.appendChild(mappingEl);
                        }
                    }
                }
            }
        }
        return featureChainingEl;
    } catch (ParserConfigurationException e) {
        throw new IllegalStateException(e);
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Document(org.w3c.dom.Document)

Example 34 with PropertyEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.

the class AbstractPropertyTransformationHandler method findChainConfiguration.

/**
 * @param context the mapping context
 * @return the chain configuration that applies to the current property
 *         mapping
 */
private ChainConfiguration findChainConfiguration(AppSchemaMappingContext context) {
    ChainConfiguration chainConf = null;
    PropertyEntityDefinition targetPropertyEntityDef = targetProperty.getDefinition();
    FeatureChaining featureChaining = context.getFeatureChaining();
    if (featureChaining != null) {
        List<ChildContext> targetPropertyPath = targetPropertyEntityDef.getPropertyPath();
        List<ChainConfiguration> chains = featureChaining.getChains(typeCell.getId());
        chainConf = findLongestNestedPath(targetPropertyPath, chains);
    }
    return chainConf;
}
Also used : FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) ChainConfiguration(eu.esdihumboldt.hale.io.appschema.model.ChainConfiguration) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext)

Example 35 with PropertyEntityDefinition

use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.

the class AbstractPropertyTransformationHandler method createGeometryAttributeMapping.

private void createGeometryAttributeMapping(TypeDefinition featureType, String mappingName, PropertyEntityDefinition geometry, AppSchemaMappingContext context) {
    EntityDefinition geometryProperty = getGeometryPropertyEntity(geometry);
    // use geometry property path to create / retrieve attribute mapping
    attributeMapping = context.getOrCreateAttributeMapping(featureType, mappingName, geometryProperty.getPropertyPath());
}
Also used : PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition)

Aggregations

PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)55 ArrayList (java.util.ArrayList)26 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)19 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)19 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)16 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)16 List (java.util.List)15 Entity (eu.esdihumboldt.hale.common.align.model.Entity)12 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)12 QName (javax.xml.namespace.QName)11 Cell (eu.esdihumboldt.hale.common.align.model.Cell)10 HashSet (java.util.HashSet)10 Property (eu.esdihumboldt.hale.common.align.model.Property)9 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)7 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)6 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)6 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)6 Collectors (java.util.stream.Collectors)6 Type (eu.esdihumboldt.hale.common.align.model.Type)5 JoinCondition (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)5