Search in sources :

Example 1 with Entity

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

the class TransformationTreeContentProvider method getElements.

/**
 * @see ArrayContentProvider#getElements(Object)
 */
@SuppressWarnings("unchecked")
@Override
public Object[] getElements(Object inputElement) {
    if (inputElement instanceof TransformationTree)
        return collectNodes((TransformationTree) inputElement).toArray();
    Collection<Instance> instances = null;
    if (inputElement instanceof Pair<?, ?>) {
        Pair<?, ?> pair = (Pair<?, ?>) inputElement;
        inputElement = pair.getFirst();
        if (pair.getSecond() instanceof Collection<?>) {
            instances = (Collection<Instance>) pair.getSecond();
        }
    }
    if (inputElement instanceof Alignment) {
        Alignment alignment = (Alignment) inputElement;
        // input contained specific instances
        if (instances != null && !instances.isEmpty()) {
            Collection<Object> result = new ArrayList<Object>();
            // create transformation trees for each instance
            for (Instance instance : instances) {
                // find type cells matching the instance
                Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
                Collection<Cell> associatedTypeCells = new LinkedList<Cell>();
                for (Cell typeCell : typeCells) for (Entity entity : typeCell.getSource().values()) {
                    TypeEntityDefinition type = (TypeEntityDefinition) entity.getDefinition();
                    if (type.getDefinition().equals(instance.getDefinition()) && (type.getFilter() == null || type.getFilter().match(instance))) {
                        associatedTypeCells.add(typeCell);
                        break;
                    }
                }
                // for each type cell one tree
                for (Cell cell : associatedTypeCells) {
                    TransformationTree tree = createInstanceTree(instance, cell, alignment);
                    if (tree != null)
                        result.addAll(collectNodes(tree));
                }
            }
            return result.toArray();
        }
        // input was alignment only, show trees for all type cells
        Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
        Collection<Object> result = new ArrayList<Object>(typeCells.size());
        for (Cell typeCell : typeCells) {
            // create tree and add nodes for each cell
            result.addAll(collectNodes(new TransformationTreeImpl(alignment, typeCell)));
        }
        return result.toArray();
    }
    return super.getElements(inputElement);
}
Also used : TransformationTreeImpl(eu.esdihumboldt.hale.common.align.model.transformation.tree.impl.TransformationTreeImpl) Entity(eu.esdihumboldt.hale.common.align.model.Entity) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) ArrayList(java.util.ArrayList) TransformationTree(eu.esdihumboldt.hale.common.align.model.transformation.tree.TransformationTree) LinkedList(java.util.LinkedList) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Collection(java.util.Collection) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Pair(eu.esdihumboldt.util.Pair)

Example 2 with Entity

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

the class GraphLabelProvider method getText.

/**
 * @see LabelProvider#getText(Object)
 */
@Override
public String getText(Object element) {
    if (element instanceof Entity) {
        element = ((Entity) element).getDefinition();
    }
    if (element instanceof EntityDefinition) {
        // use definition text
        return definitionLabels.getText(element);
    }
    if (element instanceof Definition<?>) {
        // use definition text
        return definitionLabels.getText(element);
    }
    if (element instanceof Cell) {
        // use function name if possible
        Cell cell = (Cell) element;
        String functionId = cell.getTransformationIdentifier();
        FunctionDefinition<?> function = FunctionUtil.getFunction(functionId, serviceProvider);
        if (function != null) {
            return functionLabels.getText(function);
        }
        return functionId;
    }
    if (element instanceof FunctionDefinition) {
        return functionLabels.getText(element);
    }
    return super.getText(element);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 3 with Entity

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

the class GraphLabelProvider method getImage.

/**
 * @see LabelProvider#getImage(Object)
 */
@Override
public Image getImage(Object element) {
    if (element instanceof Entity) {
        element = ((Entity) element).getDefinition();
    }
    if (element instanceof EntityDefinition || element instanceof Definition<?>) {
        // use definition image
        return definitionLabels.getImage(element);
    }
    if (element instanceof Cell) {
        // use function image if possible
        Cell cell = (Cell) element;
        String functionId = cell.getTransformationIdentifier();
        FunctionDefinition<?> function = FunctionUtil.getFunction(functionId, serviceProvider);
        if (function != null) {
            Image image = functionLabels.getImage(function);
            if (image == null) {
                // use a default image if none is available
                image = CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_FUNCTION);
            }
            if (cell.isBaseCell()) {
                Image baseAlignmentImage = baseAlignmentFunctionImages.get(functionId);
                if (baseAlignmentImage == null) {
                    baseAlignmentImage = new Image(image.getDevice(), image.getBounds());
                    GC gc = new GC(baseAlignmentImage);
                    try {
                        gc.drawImage(image, 0, 0);
                        gc.drawImage(baseAlignmentFunctionOverlay, 0, 0);
                    } finally {
                        gc.dispose();
                    }
                    baseAlignmentFunctionImages.put(functionId, baseAlignmentImage);
                }
                image = baseAlignmentImage;
            }
            return image;
        }
        return null;
    }
    if (element instanceof FunctionDefinition) {
        return functionLabels.getImage(element);
    }
    return super.getImage(element);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) Image(org.eclipse.swt.graphics.Image) GC(org.eclipse.swt.graphics.GC) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 4 with Entity

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

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

the class SourceListParameterPage method onShowPage.

/**
 * @see HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    Cell cell = getWizard().getUnfinishedCell();
    // update variables as they could have changed
    variables.clear();
    List<? extends Entity> sourceEntities = cell.getSource().get(getSourcePropertyName());
    for (Entity entity : sourceEntities) {
        variables.add(entity.getDefinition());
    }
    Map<EntityDefinition, String> varsAndNames = determineDefaultVariableNames(variables);
    varTable.setInput(varsAndNames.entrySet());
    // Update project variables content provider
    projectVariablesProposalsProvider.reload();
    // inform subclasses
    sourcePropertiesChanged(varsAndNames.keySet());
    ((Composite) getControl()).layout();
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Composite(org.eclipse.swt.widgets.Composite) Cell(eu.esdihumboldt.hale.common.align.model.Cell) ViewerCell(org.eclipse.jface.viewers.ViewerCell)

Aggregations

Entity (eu.esdihumboldt.hale.common.align.model.Entity)64 Cell (eu.esdihumboldt.hale.common.align.model.Cell)25 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)21 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)14 ArrayList (java.util.ArrayList)12 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)9 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)9 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)9 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)9 List (java.util.List)9 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)8 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)7 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)6 HashSet (java.util.HashSet)6 Locale (java.util.Locale)6 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)5 FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)4 CellUtil (eu.esdihumboldt.hale.common.align.model.CellUtil)4 CellLog (eu.esdihumboldt.hale.common.align.model.annotations.messages.CellLog)4 AbstractCellExplanation (eu.esdihumboldt.hale.common.align.model.impl.AbstractCellExplanation)4