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;
}
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;
}
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);
}
}
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);
}
Aggregations