Search in sources :

Example 1 with PropertyParameterDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition in project hale by halestudio.

the class FunctionGraphContentProvider method getElements.

/**
 * @see ArrayContentProvider#getElements(Object)
 */
@Override
public Object[] getElements(Object inputElement) {
    Collection<Object> collection = new ArrayList<Object>();
    if (inputElement instanceof FunctionDefinition<?>) {
        FunctionDefinition<?> function = (FunctionDefinition<?>) inputElement;
        collection.add(function);
        if (inputElement instanceof TypeFunctionDefinition) {
            for (TypeParameterDefinition type : ((TypeFunctionDefinition) function).getSource()) {
                collection.add(new Pair<Object, Object>(type, function));
            }
            for (TypeParameterDefinition type : ((TypeFunctionDefinition) function).getTarget()) {
                collection.add(type);
            }
        }
        if (inputElement instanceof PropertyFunctionDefinition) {
            for (PropertyParameterDefinition prop : ((PropertyFunctionDefinition) function).getSource()) {
                collection.add(new Pair<Object, Object>(prop, function));
            }
            for (PropertyParameterDefinition prop : ((PropertyFunctionDefinition) function).getTarget()) {
                collection.add(prop);
            }
        }
        return collection.toArray();
    }
    return super.getElements(inputElement);
}
Also used : TypeFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition) TypeParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeParameterDefinition) ArrayList(java.util.ArrayList) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) TypeFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) PropertyParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)

Example 2 with PropertyParameterDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition in project hale by halestudio.

the class GeoJSONConfigurationPage method createContent.

/**
 * @see HaleWizardPage#createContent(Composite)
 */
@Override
protected void createContent(final Composite page) {
    page.setLayout(new GridLayout(1, false));
    Label explanation = new Label(page, SWT.NONE);
    explanation.setText("If a geometry is set to \"none\", instances will still be included as GeoJSON features,\nbut without default geometries.");
    final DynamicScrolledComposite sc = new DynamicScrolledComposite(page, SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    Composite parent = new Composite(sc, SWT.NONE);
    sc.setExpandHorizontal(true);
    GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).spacing(6, 12).applyTo(parent);
    InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
    GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
    Set<TypeDefinition> types = is.getInstanceTypes(DataSet.TRANSFORMED);
    for (final TypeDefinition type : types) {
        Label label = new Label(parent, SWT.NONE);
        label.setText(type.getDisplayName() + ":");
        PropertyCondition condition = new PropertyOrChildrenTypeCondition(new GeometryCondition());
        PropertyParameterDefinition param = new PropertyParameter("", 0, 1, "Geometry", null, Collections.singletonList(condition), false);
        PropertyEntitySelector selector = new PropertyEntitySelector(SchemaSpaceID.TARGET, param, parent, new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null));
        selector.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
                    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                    PropertyEntityDefinition property = (PropertyEntityDefinition) selection.getFirstElement();
                    config.addDefaultGeometry(type, property);
                } else {
                    config.addDefaultGeometry(type, null);
                }
            }
        });
        selector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
        // initial selection
        List<QName> path = gss.getDefaultGeometry(type);
        if (path != null) {
            EntityDefinition entityDef = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
            for (QName child : path) entityDef = AlignmentUtil.getChild(entityDef, child);
            selector.setSelection(new StructuredSelection(entityDef));
        }
    }
    sc.setContent(parent);
}
Also used : Label(org.eclipse.swt.widgets.Label) PropertyEntitySelector(eu.esdihumboldt.hale.ui.function.common.PropertyEntitySelector) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) PropertyParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) GridLayout(org.eclipse.swt.layout.GridLayout) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyCondition(eu.esdihumboldt.hale.common.align.model.condition.PropertyCondition) PropertyOrChildrenTypeCondition(eu.esdihumboldt.hale.common.align.model.condition.PropertyOrChildrenTypeCondition) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) QName(javax.xml.namespace.QName) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) GridData(org.eclipse.swt.layout.GridData) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) GeometryCondition(eu.esdihumboldt.hale.common.align.model.condition.impl.GeometryCondition) PropertyParameter(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)

Example 3 with PropertyParameterDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition in project hale by halestudio.

the class TransformationTreeUtil method isEager.

/**
 * Determines if a cell is connected to a source node with eager source
 * parameters.
 *
 * @param cell the cell node
 * @param source the source node
 * @param log the transformation log, may be <code>null</code>
 * @param serviceProvider the service provider
 * @return if the cell contained in the cell node has eager source
 *         parameters connected to the source node
 */
public static boolean isEager(CellNode cell, SourceNode source, TransformationLog log, ServiceProvider serviceProvider) {
    // get all entity names the cell is associated to the source node with
    Set<String> names = cell.getSourceNames(source);
    PropertyFunctionDefinition function = FunctionUtil.getPropertyFunction(cell.getCell().getTransformationIdentifier(), serviceProvider);
    if (function != null) {
        Set<? extends PropertyParameterDefinition> defSources = function.getSource();
        Set<String> eager = new HashSet<String>();
        for (PropertyParameterDefinition sourceDef : defSources) {
            String name = sourceDef.getName();
            if (sourceDef.isEager() && names.contains(name)) {
                eager.add(name);
            }
        }
        if (!eager.isEmpty()) {
            if (log != null && eager.size() != names.size()) {
                log.warn(new TransformationMessageImpl(cell.getCell(), "Source node with a mix of eager and non-eager connections to a cell, treating as eager.", null));
            }
            return true;
        }
    }
    return false;
}
Also used : PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) PropertyParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition) TransformationMessageImpl(eu.esdihumboldt.hale.common.align.transformation.report.impl.TransformationMessageImpl) HashSet(java.util.HashSet)

Aggregations

PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)3 PropertyFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)2 FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)1 PropertyParameter (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)1 TypeFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition)1 TypeParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeParameterDefinition)1 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 PropertyCondition (eu.esdihumboldt.hale.common.align.model.condition.PropertyCondition)1 PropertyOrChildrenTypeCondition (eu.esdihumboldt.hale.common.align.model.condition.PropertyOrChildrenTypeCondition)1 GeometryCondition (eu.esdihumboldt.hale.common.align.model.condition.impl.GeometryCondition)1 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 TransformationMessageImpl (eu.esdihumboldt.hale.common.align.transformation.report.impl.TransformationMessageImpl)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 PropertyEntitySelector (eu.esdihumboldt.hale.ui.function.common.PropertyEntitySelector)1 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)1 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)1 DynamicScrolledComposite (eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1