Search in sources :

Example 1 with PropertyEntityDefinition

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

the class RegexAnalysisParameterPage method setDefaultData.

private void setDefaultData(Cell unfinishedCell) {
    InstanceTestValues instanceTestValues = new InstanceTestValues();
    Entity entity = CellUtil.getFirstEntity(unfinishedCell.getSource());
    if (entity != null) {
        EntityDefinition edef = entity.getDefinition();
        if (edef instanceof PropertyEntityDefinition) {
            PropertyEntityDefinition property = (PropertyEntityDefinition) edef;
            Object object = instanceTestValues.get(property);
            if (object != null) {
                String sampleData = object.toString();
                _inputText.setText(sampleData);
            }
        }
    }
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) InstanceTestValues(eu.esdihumboldt.hale.ui.scripting.groovy.InstanceTestValues) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)

Example 2 with PropertyEntityDefinition

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

the class UserMigration method entityReplacement.

@Override
public Optional<EntityDefinition> entityReplacement(EntityDefinition entity, SimpleLog log) {
    // use functionality from entity resolver
    if (entity instanceof TypeEntityDefinition) {
        EntityDefinition candidate = entity;
        Type type = UserFallbackEntityResolver.resolveType((TypeEntityDefinition) entity, candidate, schemaSpace);
        return Optional.ofNullable(type).map(e -> e.getDefinition());
    } else if (entity instanceof PropertyEntityDefinition) {
        EntityDefinition candidate = entity;
        candidate = EntityCandidates.find((PropertyEntityDefinition) entity);
        Property property = UserFallbackEntityResolver.resolveProperty((PropertyEntityDefinition) entity, candidate, schemaSpace);
        return Optional.ofNullable(property).map(e -> e.getDefinition());
    } else {
        log.error("Unrecognised entity type: " + entity.getClass());
        return Optional.empty();
    }
}
Also used : Property(eu.esdihumboldt.hale.common.align.model.Property) SimpleLog(eu.esdihumboldt.hale.common.core.report.SimpleLog) Type(eu.esdihumboldt.hale.common.align.model.Type) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) Optional(java.util.Optional) UserFallbackEntityResolver(eu.esdihumboldt.hale.ui.service.align.resolver.UserFallbackEntityResolver) EntityCandidates(eu.esdihumboldt.hale.ui.service.align.resolver.internal.EntityCandidates) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) AlignmentMigration(eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration) SchemaSpaceID(eu.esdihumboldt.hale.common.schema.SchemaSpaceID) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Type(eu.esdihumboldt.hale.common.align.model.Type) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) Property(eu.esdihumboldt.hale.common.align.model.Property)

Example 3 with PropertyEntityDefinition

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

the class UserFallbackEntityResolver method resolveProperty.

/**
 * Ask the user to select a replacement for a property.
 *
 * @param original the original entity
 * @param candidate a candidate for the replacement
 * @param schemaSpace the schema space
 * @return the resolved property (may be the original)
 */
public static Property resolveProperty(PropertyEntityDefinition original, @Nullable EntityDefinition candidate, SchemaSpaceID schemaSpace) {
    ResolveCache cache = getCache();
    PropertyEntityDefinition replacement = cache.getReplacement(original);
    if (replacement != null) {
        // use cached replacement
        return new DefaultProperty(replacement);
    }
    ProjectService ps = HaleUI.getServiceProvider().getService(ProjectService.class);
    final AtomicBoolean canceled;
    final AtomicBoolean skipped = new AtomicBoolean(false);
    if (ps.getTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(false)).as(Boolean.class)) {
        canceled = new AtomicBoolean(true);
    } else {
        canceled = new AtomicBoolean(false);
    }
    final AtomicReference<EntityDefinition> result = new AtomicReference<>();
    if (!canceled.get()) {
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

            @Override
            public void run() {
                PropertyEntityResolverDialog dlg = new PropertyEntityResolverDialog(Display.getCurrent().getActiveShell(), schemaSpace, null, "Cell entity could not be resolved", candidate) {

                    @Override
                    public void create() {
                        super.create();
                        openTray(new ViewerEntityTray(original));
                    }
                };
                switch(dlg.open()) {
                    case Window.OK:
                        result.set(dlg.getObject());
                        break;
                    case Window.CANCEL:
                        // Don't try to resolve further entities
                        ps.setTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(true));
                        canceled.set(true);
                        break;
                    case PropertyEntityResolverDialog.SKIP:
                        // skip this entity
                        skipped.set(true);
                        break;
                    default:
                        canceled.set(true);
                }
            }
        });
    }
    EntityDefinition def = result.get();
    if (canceled.get() || skipped.get()) {
        // return the original so the cell is not lost
        return new DefaultProperty(original);
    } else if (def == null) {
        // caller must take care about this
        return null;
    } else {
        PropertyEntityDefinition propDef = (PropertyEntityDefinition) def;
        cache.put(original, propDef);
        return new DefaultProperty(propDef);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) 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) ResolveCache(eu.esdihumboldt.hale.ui.service.align.resolver.internal.ResolveCache) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) PropertyEntityResolverDialog(eu.esdihumboldt.hale.ui.service.align.resolver.internal.PropertyEntityResolverDialog) ViewerEntityTray(eu.esdihumboldt.hale.ui.service.align.resolver.internal.ViewerEntityTray) AtomicReference(java.util.concurrent.atomic.AtomicReference) DefaultProperty(eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)

Example 4 with PropertyEntityDefinition

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

the class GenericParameterPage method onShowPage.

/**
 * @see HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    Cell cell = getWizard().getUnfinishedCell();
    // update variables as they could have changed
    if (!AlignmentUtil.isTypeCell(cell)) {
        Set<PropertyEntityDefinition> variables = new HashSet<PropertyEntityDefinition>();
        for (Entity e : cell.getSource().values()) {
            // Cell is no type cell, so entities are Properties.
            variables.add(((Property) e).getDefinition());
        }
        for (Pair<AttributeEditor<?>, Button> pair : inputFields.values()) pair.getFirst().setVariables(variables);
    }
    updateState();
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) Button(org.eclipse.swt.widgets.Button) AttributeEditor(eu.esdihumboldt.hale.ui.common.AttributeEditor) Cell(eu.esdihumboldt.hale.common.align.model.Cell) HashSet(java.util.HashSet)

Example 5 with PropertyEntityDefinition

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

the class MathEditor method createPropertyValues.

/**
 * Returns an {@link Iterable} for the current variables for use with the
 * {@link Script}.
 *
 * @return an {@link Iterable} for the current variables for use with the
 *         {@link Script}
 */
protected Iterable<PropertyValue> createPropertyValues() {
    Collection<PropertyValue> result = new ArrayList<PropertyValue>(variables.size());
    // using double results in no /0 exceptions because of stuff like
    // 1/(a-b)
    Double one = Double.valueOf(1);
    for (PropertyEntityDefinition property : variables) result.add(new PropertyValueImpl(one, property));
    return result;
}
Also used : PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) ArrayList(java.util.ArrayList) PropertyValue(eu.esdihumboldt.hale.common.align.transformation.function.PropertyValue) PropertyValueImpl(eu.esdihumboldt.hale.common.align.transformation.function.impl.PropertyValueImpl)

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