Search in sources :

Example 1 with CellExplanation

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

the class HtmlExplanationCellFilter method isFiltered.

@Override
public boolean isFiltered(Cell cell) {
    FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), HaleUI.getServiceProvider());
    if (function != null) {
        CellExplanation explanation = function.getExplanation();
        if (explanation != null) {
            String text = explanation.getExplanationAsHtml(cell, HaleUI.getServiceProvider());
            if (text != null) {
                return false;
            }
            text = explanation.getExplanation(cell, HaleUI.getServiceProvider());
            if (text != null) {
                return false;
            }
        }
    }
    return true;
}
Also used : CellExplanation(eu.esdihumboldt.hale.common.align.model.CellExplanation)

Example 2 with CellExplanation

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

the class GraphLabelProvider method getTooltip.

/**
 * @see IEntityStyleProvider#getTooltip(Object)
 */
@Override
public IFigure getTooltip(Object entity) {
    if (entity instanceof Cell) {
        Cell cell = (Cell) entity;
        FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), serviceProvider);
        if (function != null) {
            CellExplanation explanation = function.getExplanation();
            if (explanation != null) {
                String text = explanation.getExplanation(cell, serviceProvider);
                if (text != null) {
                    return new WrappedText(text, 400);
                }
            }
        }
    }
    // default
    return null;
}
Also used : CellExplanation(eu.esdihumboldt.hale.common.align.model.CellExplanation) WrappedText(eu.esdihumboldt.hale.ui.util.graph.WrappedText) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 3 with CellExplanation

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

the class HtmlExplanationCellSection method refresh.

@Override
public void refresh() {
    super.refresh();
    String text = null;
    Cell cell = getCell();
    if (cell != null) {
        FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), HaleUI.getServiceProvider());
        if (function != null) {
            CellExplanation explanation = function.getExplanation();
            if (explanation != null) {
                if (browser != null) {
                    text = explanation.getExplanationAsHtml(cell, HaleUI.getServiceProvider());
                    if (text == null) {
                        text = explanation.getExplanation(cell, HaleUI.getServiceProvider());
                    }
                } else if (textField != null) {
                    text = explanation.getExplanation(cell, HaleUI.getServiceProvider());
                }
            }
        }
    }
    if (text == null) {
        text = "Sorry, no explanation available.";
    }
    if (browser != null) {
        browser.setText(text);
    } else if (textField != null) {
        textField.setText(text);
    }
}
Also used : CellExplanation(eu.esdihumboldt.hale.common.align.model.CellExplanation) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 4 with CellExplanation

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

the class AbstractAlignmentMappingExport method addCellData.

// get the information of the cell and add them to the map
private void addCellData(Cell cell) {
    Map<CellType, CellInformation> cellInfos = new HashMap<CellType, CellInformation>();
    // create all entries
    List<CellType> cellTypes = getCellTypes();
    for (int i = 0; i < cellTypes.size(); i++) {
        cellInfos.put(cellTypes.get(i), new CellInformation());
    }
    cellInfos.get(CellType.ID).addText(cell.getId(), 0);
    if (cell.getSource() != null) {
        // save the hierarchy of the properties
        // all entries (in the same CellInfo) with the same hierarchy level
        // have to be shown on the same height
        int position = 0;
        for (Entity entity : cell.getSource().values()) {
            // column source type
            cellInfos.get(CellType.SOURCE_TYPE).addText(entity.getDefinition().getType().getName().getLocalPart(), position);
            if (includeNamespaces)
                // column source type namespace
                cellInfos.get(CellType.SOURCE_TYPE_NAMESPACE).addText(entity.getDefinition().getType().getName().getNamespaceURI(), position);
            // column source type conditions
            Filter entityFilter;
            if ((entityFilter = entity.getDefinition().getFilter()) != null) {
                cellInfos.get(CellType.SOURCE_TYPE_CONDITIONS).addText(FilterDefinitionManager.getInstance().asString(entityFilter), position);
                entity.getDefinition().getType().getName().getLocalPart();
            }
            for (ChildContext childContext : entity.getDefinition().getPropertyPath()) {
                PropertyDefinition child = childContext.getChild().asProperty();
                if (child != null) {
                    // column source properties
                    cellInfos.get(CellType.SOURCE_PROPERTIES).addText(child.getName().getLocalPart(), position);
                    if (includeNamespaces)
                        // column source properties namespace
                        cellInfos.get(CellType.SOURCE_PROPERTIES_NAMESPACE).addText(child.getName().getNamespaceURI(), position);
                    Filter contextFilter;
                    if (childContext.getCondition() != null) {
                        contextFilter = childContext.getCondition().getFilter();
                        // column source property conditions
                        cellInfos.get(CellType.SOURCE_PROPERTY_CONDITIONS).addText(FilterDefinitionManager.getInstance().asString(contextFilter), position);
                    }
                    // add dummy to adapt position of source type and source
                    // type conditions
                    cellInfos.get(CellType.SOURCE_TYPE).addText("", position);
                    cellInfos.get(CellType.SOURCE_TYPE_CONDITIONS).addText("", position);
                    position++;
                }
            }
            // next entries must have higher position
            position++;
        }
    }
    if (cell.getTarget() != null) {
        int position = 0;
        for (Entity entity : cell.getTarget().values()) {
            // column target type
            cellInfos.get(CellType.TARGET_TYPE).addText(entity.getDefinition().getType().getDisplayName(), position);
            if (includeNamespaces)
                // column target type namespace
                cellInfos.get(CellType.TARGET_TYPE_NAMESPACE).addText(entity.getDefinition().getType().getName().getNamespaceURI(), position);
            for (ChildContext childContext : entity.getDefinition().getPropertyPath()) {
                PropertyDefinition child = childContext.getChild().asProperty();
                if (child != null) {
                    // column target properties
                    cellInfos.get(CellType.TARGET_PROPERTIES).addText(child.getName().getLocalPart(), position);
                    if (includeNamespaces)
                        // column target properties namespace
                        cellInfos.get(CellType.TARGET_PROPERTIES_NAMESPACE).addText(child.getName().getNamespaceURI(), position);
                    // add dummy to adapt position of target type
                    cellInfos.get(CellType.TARGET_TYPE).addText("", position);
                    position++;
                }
            }
            position++;
        }
    }
    FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), getServiceProvider());
    if (function != null) {
        // column relation name
        cellInfos.get(CellType.RELATION_NAME).addText(function.getDisplayName(), 0);
        // column cell explanation
        CellExplanation cellExpl = function.getExplanation();
        if (cellExpl != null) {
            cellInfos.get(CellType.CELL_EXPLANATION).addText(function.getExplanation().getExplanation(cell, null), 0);
        }
    }
    // column cell notes
    List<String> docs = cell.getDocumentation().get(null);
    if (!docs.isEmpty()) {
        String notes = docs.get(0);
        if (notes != null && !notes.isEmpty()) {
            cellInfos.get(CellType.CELL_NOTES).addText(notes, 0);
        }
    }
    // cell priority
    cellInfos.get(CellType.PRIORITY).addText(cell.getPriority().value(), 0);
    // base cell
    if (cell.isBaseCell()) {
        cellInfos.get(CellType.BASE_CELL).addText("yes", 0);
    } else {
        cellInfos.get(CellType.BASE_CELL).addText("no", 0);
    }
    // column transformation/disabled
    if (transformationAndDisabledMode) {
        if (AlignmentUtil.isTypeCell(cell)) {
            currentTypeCell = cell;
            cellInfos.get(CellType.TRANSFORMATION_AND_DISABLED).addText(cell.getTransformationMode().displayName(), 0);
        } else {
            Set<String> disabledCells = cell.getDisabledFor();
            if (disabledCells.contains(currentTypeCell.getId())) {
                for (String disCell : disabledCells) {
                    cellInfos.get(CellType.TRANSFORMATION_AND_DISABLED).addText(disCell, 0);
                }
            }
        }
    }
    // add the row to the map
    allRelations.add(cellInfos);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) HashMap(java.util.HashMap) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) CellExplanation(eu.esdihumboldt.hale.common.align.model.CellExplanation) Filter(eu.esdihumboldt.hale.common.instance.model.Filter) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext)

Aggregations

CellExplanation (eu.esdihumboldt.hale.common.align.model.CellExplanation)4 Cell (eu.esdihumboldt.hale.common.align.model.Cell)2 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)1 Entity (eu.esdihumboldt.hale.common.align.model.Entity)1 Filter (eu.esdihumboldt.hale.common.instance.model.Filter)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 WrappedText (eu.esdihumboldt.hale.ui.util.graph.WrappedText)1 HashMap (java.util.HashMap)1