Search in sources :

Example 41 with ChildContext

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

the class SourceListParameterPage method getVariableName.

/**
 * This gets called for all variables.<br>
 * Subclasses can change how they are displayed here.<br>
 * The default format is like "part1.part2.name".
 *
 * @param variable the variable
 * @return the modified name
 */
protected String getVariableName(EntityDefinition variable) {
    if (variable.getPropertyPath() != null && !variable.getPropertyPath().isEmpty()) {
        List<String> names = new ArrayList<String>();
        for (ChildContext context : variable.getPropertyPath()) {
            names.add(context.getChild().getName().getLocalPart());
        }
        String longName = Joiner.on('.').join(names);
        return longName;
    } else
        return variable.getDefinition().getDisplayName();
}
Also used : ArrayList(java.util.ArrayList) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext)

Example 42 with ChildContext

use of eu.esdihumboldt.hale.common.align.model.ChildContext 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 43 with ChildContext

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

the class AppSchemaMappingGenerator method createNamespacesForPath.

private void createNamespacesForPath(List<ChildContext> propertyPath) {
    if (propertyPath != null) {
        for (ChildContext childContext : propertyPath) {
            PropertyDefinition child = childContext.getChild().asProperty();
            if (child != null) {
                String namespaceURI = child.getName().getNamespaceURI();
                String prefix = child.getName().getPrefix();
                context.getOrCreateNamespace(namespaceURI, prefix);
            }
        }
    }
}
Also used : ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)

Example 44 with ChildContext

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

the class AppSchemaMappingGenerator method createNamespaceForEntity.

private void createNamespaceForEntity(Entity entity) {
    QName typeName = entity.getDefinition().getType().getName();
    String namespaceURI = typeName.getNamespaceURI();
    String prefix = typeName.getPrefix();
    context.getOrCreateNamespace(namespaceURI, prefix);
    List<ChildContext> propertyPath = entity.getDefinition().getPropertyPath();
    createNamespacesForPath(propertyPath);
}
Also used : QName(javax.xml.namespace.QName) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext)

Example 45 with ChildContext

use of eu.esdihumboldt.hale.common.align.model.ChildContext 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)

Aggregations

ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)63 ArrayList (java.util.ArrayList)32 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)29 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)24 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)16 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)15 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)12 QName (javax.xml.namespace.QName)11 Property (eu.esdihumboldt.hale.common.align.model.Property)7 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)7 List (java.util.List)7 Condition (eu.esdihumboldt.hale.common.align.model.Condition)6 Entity (eu.esdihumboldt.hale.common.align.model.Entity)6 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)5 ChildDefinition (eu.esdihumboldt.hale.common.schema.model.ChildDefinition)5 Cell (eu.esdihumboldt.hale.common.align.model.Cell)4 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)4 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)3 Type (eu.esdihumboldt.hale.common.align.model.Type)3 DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)3