Search in sources :

Example 6 with PropertyFunctionDefinition

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

the class AbstractDefaultFunctionService method getPropertyFunctions.

@Override
public Collection<? extends PropertyFunctionDefinition> getPropertyFunctions(String categoryId) {
    Collection<? extends PropertyFunctionDefinition> functions = super.getPropertyFunctions(categoryId);
    Alignment al = getCurrentAlignment();
    if (al != null) {
        List<PropertyFunctionDefinition> cfs = new ArrayList<>();
        for (CustomPropertyFunction cf : al.getAllCustomPropertyFunctions().values()) {
            PropertyFunctionDefinition descriptor = cf.getDescriptor();
            if (Objects.equal(categoryId, descriptor.getCategoryId())) {
                cfs.add(new AlignmentFunctionDescriptor(descriptor));
            }
        }
        cfs.addAll(functions);
        functions = cfs;
    }
    return functions;
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) ArrayList(java.util.ArrayList) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)

Example 7 with PropertyFunctionDefinition

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

the class GeographicalNamePage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite parent) {
    super.initializeDialogUnits(parent);
    this.parent = parent;
    setPageComplete(true);
    composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    composite.setFont(parent.getFont());
    PropertyFunctionDefinition function = FunctionUtil.getPropertyFunction(ID, HaleUI.getServiceProvider());
    createSpellingGroup(composite, function);
    createPronounciationGroup(composite, function);
    createOptionalAttributes(composite, function);
    // should not initially have error message
    setErrorMessage(null);
    super.setControl(composite);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)

Example 8 with PropertyFunctionDefinition

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

the class IdentifierParameterPage method createContent.

@Override
protected void createContent(Composite parent) {
    boolean relayout = this.parent != null;
    this.parent = parent;
    lastEntity = determineTargetEntity();
    if (lastEntity == null) {
        setPageComplete(false);
        // can't create controls
        return;
    }
    if (page != null) {
        // page was created before
        initialCountry = countryCode.getText();
        initialProvider = providerName.getText();
        initialProduct = productName.getText();
        initialVersion = version.getText();
        initialVersionNil = nilEditor.getAsText();
        page.dispose();
    }
    PropertyFunctionDefinition function = FunctionUtil.getPropertyFunction(ID, HaleUI.getServiceProvider());
    // create a composite to hold the widgets
    page = new Composite(parent, SWT.NULL);
    setControl(page);
    // create layout for this wizard page
    GridLayout gl = GridLayoutFactory.fillDefaults().create();
    page.setLayout(gl);
    AttributeEditorFactory aef = PlatformUI.getWorkbench().getService(AttributeEditorFactory.class);
    DefinitionLabelFactory dlf = PlatformUI.getWorkbench().getService(DefinitionLabelFactory.class);
    // identifier type
    TypeDefinition identifierType = null;
    Definition<?> def = lastEntity.getDefinition();
    if (def instanceof PropertyDefinition) {
        TypeDefinition typeDef = ((PropertyDefinition) def).getPropertyType();
        for (ChildDefinition<?> child : typeDef.getChildren()) {
            if (child.asProperty() != null && child.asProperty().getPropertyType().getName().getLocalPart().equals("IdentifierType")) {
                identifierType = child.asProperty().getPropertyType();
            }
        }
    }
    // Namespace group
    Group nsGroup = new Group(page, SWT.NONE);
    nsGroup.setText(Messages.IdentifierFunctionWizardPage_2);
    nsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    nsGroup.setLayout(// 
    GridLayoutFactory.swtDefaults().numColumns(// 
    2).spacing(8, // 
    4).create());
    // localId
    if (identifierType != null) {
        // $NON-NLS-1$
        PropertyDefinition propDef = null;
        for (ChildDefinition<?> child : identifierType.getChildren()) {
            String localName = child.getName().getLocalPart();
            if (localName.equals("namespace")) {
                if (child.asProperty() != null) {
                    propDef = child.asProperty();
                }
            }
        }
        if (propDef != null) {
            Control nsLabel = dlf.createLabel(nsGroup, propDef, false);
            nsLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
            Label nsDesc = new Label(nsGroup, SWT.NONE);
            nsDesc.setText(Messages.IdentifierFunctionWizardPage_4);
        }
    }
    // Country code
    Label ccLabel = new Label(nsGroup, SWT.NONE);
    ccLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    ccLabel.setText(Messages.IdentifierFunctionWizardPage_5);
    FunctionParameterDefinition param = function.getParameter(COUNTRY_PARAMETER_NAME);
    configureParameterLabel(ccLabel, param);
    this.countryCode = new Text(nsGroup, SWT.BORDER | SWT.SINGLE);
    // $NON-NLS-1$
    this.countryCode.setText(initialCountry);
    this.countryCode.setEnabled(true);
    this.countryCode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    // Provider name
    Label providerLabel = new Label(nsGroup, SWT.NONE);
    providerLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    providerLabel.setText(Messages.IdentifierFunctionWizardPage_7);
    param = function.getParameter(DATA_PROVIDER_PARAMETER_NAME);
    configureParameterLabel(providerLabel, param);
    this.providerName = new Text(nsGroup, SWT.BORDER | SWT.SINGLE);
    // $NON-NLS-1$
    this.providerName.setText(initialProvider);
    this.providerName.setEnabled(true);
    this.providerName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    // Product name
    Label productLabel = new Label(nsGroup, SWT.NONE);
    productLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    productLabel.setText(Messages.IdentifierFunctionWizardPage_9);
    param = function.getParameter(PRODUCT_PARAMETER_NAME);
    configureParameterLabel(productLabel, param);
    this.productName = new Text(nsGroup, SWT.BORDER | SWT.SINGLE);
    // $NON-NLS-1$
    this.productName.setText(initialProduct);
    this.productName.setEnabled(true);
    this.productName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    // Local ID group
    Group idGroup = new Group(page, SWT.NONE);
    idGroup.setText(Messages.IdentifierFunctionWizardPage_11);
    idGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    idGroup.setLayout(new GridLayout(2, false));
    // localId
    Control idLabel = null;
    if (identifierType != null) {
        // $NON-NLS-1$
        PropertyDefinition propDef = null;
        for (ChildDefinition<?> child : identifierType.getChildren()) {
            String LocalName = child.getName().getLocalPart();
            if (LocalName.equals("localId")) {
                if (child.asProperty() != null) {
                    propDef = child.asProperty();
                }
            }
        }
        if (propDef != null) {
            idLabel = dlf.createLabel(idGroup, propDef, false);
        }
    }
    if (idLabel == null) {
        idLabel = new Label(idGroup, SWT.NONE);
        // $NON-NLS-1$
        ((Label) idLabel).setText("localId");
    }
    idLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    Control localId = dlf.createLabel(idGroup, getWizard().getUnfinishedCell().getSource().get(null).get(0).getDefinition().getDefinition(), true);
    localId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    // Version group
    Group versGroup = new Group(page, SWT.NONE);
    versGroup.setText(Messages.IdentifierFunctionWizardPage_14);
    versGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    versGroup.setLayout(new GridLayout(2, false));
    // Version
    Control versionLabel = null;
    if (identifierType != null) {
        // $NON-NLS-1$
        PropertyDefinition propDef = null;
        for (ChildDefinition<?> child : identifierType.getChildren()) {
            String localName = child.getName().getLocalPart();
            if (localName.equals("versionId")) {
                if (child.asProperty() != null) {
                    propDef = child.asProperty();
                }
            }
        }
        if (propDef != null) {
            versionLabel = dlf.createLabel(versGroup, propDef, false);
        }
    }
    if (versionLabel == null) {
        versionLabel = new Label(versGroup, SWT.NONE);
        ((Label) versionLabel).setText(Messages.IdentifierFunctionWizardPage_16);
    }
    versionLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    this.version = new Text(versGroup, SWT.BORDER | SWT.SINGLE);
    // $NON-NLS-1$
    this.version.setText(initialVersion);
    this.version.setEnabled(true);
    this.version.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    // version nil reason
    if (identifierType != null) {
        // $NON-NLS-1$
        PropertyDefinition propDef = null;
        for (ChildDefinition<?> child : identifierType.getChildren()) {
            String localName = child.getName().getLocalPart();
            if (localName.equals("versionId")) {
                if (child.asProperty() != null) {
                    propDef = child.asProperty();
                }
            }
        }
        if (propDef != null) {
            for (ChildDefinition<?> child : propDef.getPropertyType().getChildren()) {
                String localName = child.getName().getLocalPart();
                if (localName.equals("nilReason")) {
                    if (child.asProperty() != null) {
                        propDef = child.asProperty();
                    }
                }
            }
        }
        if (propDef != null) {
            // label
            Control nilLabel = dlf.createLabel(versGroup, propDef, false);
            nilLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
            // editor
            nilEditor = aef.createEditor(versGroup, propDef, null, false);
            nilEditor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            // default to unknown
            nilEditor.setAsText(initialVersionNil);
        // //$NON-NLS-1$
        }
    }
    if (relayout) {
        parent.layout();
        getContainer().getShell().pack();
    }
    setPageComplete(true);
}
Also used : Group(org.eclipse.swt.widgets.Group) DefinitionLabelFactory(eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) FunctionParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionParameterDefinition) AttributeEditorFactory(eu.esdihumboldt.hale.ui.common.definition.AttributeEditorFactory) Text(org.eclipse.swt.widgets.Text) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)

Example 9 with PropertyFunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition 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

PropertyFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)9 ArrayList (java.util.ArrayList)4 TypeFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition)3 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)2 CustomPropertyFunction (eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)2 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)1 FunctionParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionParameterDefinition)1 TypeParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeParameterDefinition)1 Entity (eu.esdihumboldt.hale.common.align.model.Entity)1 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)1 TransformationMessageImpl (eu.esdihumboldt.hale.common.align.transformation.report.impl.TransformationMessageImpl)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 AttributeEditorFactory (eu.esdihumboldt.hale.ui.common.definition.AttributeEditorFactory)1 DefinitionLabelFactory (eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory)1 FunctionWizardDescriptor (eu.esdihumboldt.hale.ui.function.extension.FunctionWizardDescriptor)1 FunctionWizardExtension (eu.esdihumboldt.hale.ui.function.extension.FunctionWizardExtension)1