Search in sources :

Example 6 with ChildDefinition

use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.

the class InstanceValidationReportDetailsContentProvider method getChildren.

/**
 * @see ITreePathContentProvider#getChildren(TreePath)
 */
@Override
public Object[] getChildren(TreePath parentPath) {
    Set<Object> children = childCache.get(parentPath);
    if (children == null) {
        Collection<InstanceValidationMessage> ivms = messages.get(parentPath);
        if (!ivms.isEmpty()) {
            children = new HashSet<Object>();
            // count of added messages
            int messageCount = 0;
            for (InstanceValidationMessage message : ivms) {
                if (message.getPath().size() > parentPath.getSegmentCount() - 1) {
                    // path not done, add next segment
                    QName name = message.getPath().get(parentPath.getSegmentCount() - 1);
                    Object child = name;
                    Object parent = parentPath.getLastSegment();
                    if (parent instanceof Definition<?>) {
                        ChildDefinition<?> childDef = DefinitionUtil.getChild((Definition<?>) parent, name);
                        if (childDef != null)
                            child = childDef;
                    }
                    children.add(child);
                    messages.put(parentPath.createChildPath(child), message);
                } else if (message.getPath().size() == parentPath.getSegmentCount() - 1) {
                    // path done, go by category
                    String category = message.getCategory();
                    children.add(category);
                    messages.put(parentPath.createChildPath(category), message);
                } else {
                    // all done, add as child
                    if (messageCount < LIMIT) {
                        children.add(message);
                        messageCount++;
                    } else {
                        limitedPaths.add(parentPath);
                    }
                }
            }
        } else
            children = Collections.emptySet();
        childCache.put(parentPath, children);
    }
    return children.toArray();
}
Also used : QName(javax.xml.namespace.QName) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage)

Example 7 with ChildDefinition

use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.

the class InstanceValueLabelProvider method update.

/**
 * @see CellLabelProvider#update(ViewerCell)
 */
@Override
public void update(ViewerCell cell) {
    TreePath treePath = cell.getViewerRow().getTreePath();
    Object element = treePath.getLastSegment();
    Definition<?> definition = null;
    Object value = ((Pair<?, ?>) element).getSecond();
    if (((Pair<?, ?>) element).getFirst() instanceof Definition)
        definition = (Definition<?>) ((Pair<?, ?>) element).getFirst();
    InstanceValidationReport report = null;
    if (definition instanceof ChildDefinition<?>) {
        report = validator.validate(value, (ChildDefinition<?>) ((Pair<?, ?>) element).getFirst());
    } else if (definition instanceof TypeDefinition) {
        report = validator.validate((Instance) value);
    }
    boolean hasValue = false;
    if (value instanceof Instance) {
        hasValue = ((Instance) value).getValue() != null;
    }
    StyledString styledString;
    if (value == null) {
        styledString = new StyledString("no value", StyledString.DECORATIONS_STYLER);
    } else if (value instanceof Group && !hasValue) {
        styledString = new StyledString("+", StyledString.QUALIFIER_STYLER);
    } else {
        if (value instanceof Instance) {
            value = ((Instance) value).getValue();
        }
        // TODO some kind of conversion?
        String stringValue = value.toString();
        /*
			 * Values that are very large, e.g. string representations of very
			 * complex geometries lead to
			 * StyledCellLabelProvider.updateTextLayout taking a very long time,
			 * rendering the application unresponsive when the data views are
			 * displayed. As such, we reduce the string to a maximum size.
			 */
        if (stringValue.length() > MAX_STRING_LENGTH) {
            stringValue = stringValue.substring(0, MAX_STRING_LENGTH) + "...";
        }
        styledString = new StyledString(stringValue, null);
    }
    cell.setText(styledString.toString());
    cell.setStyleRanges(styledString.getStyleRanges());
    if (report != null && !report.getWarnings().isEmpty()) {
        cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
    }
    super.update(cell);
}
Also used : Group(eu.esdihumboldt.hale.common.instance.model.Group) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) InstanceValidationReport(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationReport) TreePath(org.eclipse.jface.viewers.TreePath) Pair(eu.esdihumboldt.util.Pair)

Example 8 with ChildDefinition

use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.

the class InstanceValueLabelProvider method getToolTipText.

/**
 * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
 */
@Override
public String getToolTipText(Object element) {
    InstanceValidationReport report;
    Object value = ((Pair<?, ?>) element).getSecond();
    Definition<?> definition = null;
    if (((Pair<?, ?>) element).getFirst() instanceof Definition)
        definition = (Definition<?>) ((Pair<?, ?>) element).getFirst();
    if (definition instanceof ChildDefinition<?>) {
        report = validator.validate(value, (ChildDefinition<?>) ((Pair<?, ?>) element).getFirst());
    } else if (definition instanceof TypeDefinition) {
        report = validator.validate((Instance) value);
    } else {
        return null;
    }
    Collection<InstanceValidationMessage> warnings = report.getWarnings();
    if (warnings.isEmpty())
        return null;
    StringBuilder toolTip = new StringBuilder();
    for (Message m : warnings) {
        toolTip.append(m.getFormattedMessage()).append('\n');
    }
    return toolTip.substring(0, toolTip.length() - 1);
}
Also used : InstanceValidationReport(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationReport) Message(eu.esdihumboldt.hale.common.core.report.Message) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage) Pair(eu.esdihumboldt.util.Pair) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 9 with ChildDefinition

use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.

the class AppSchemaMappingTest method getTimeInstantGmlIdTargetProperty.

private ListMultimap<String, Property> getTimeInstantGmlIdTargetProperty() {
    ChildDefinition<?> extent = DefinitionUtil.getChild(landCoverDatasetType, new QName(LANDCOVER_NS, "extent"));
    assertNotNull(extent);
    ChildDefinition<?> exExtent = DefinitionUtil.getChild(extent, new QName(GMD_NS, "EX_Extent"));
    assertNotNull(exExtent);
    ChildDefinition<?> temporalElement = DefinitionUtil.getChild(exExtent, new QName(GMD_NS, "temporalElement"));
    assertNotNull(temporalElement);
    ChildDefinition<?> exTemporalExtentChoice = DefinitionUtil.getChild(temporalElement, new QName("http://www.isotc211.org/2005/gmd/EX_TemporalExtent", "choice"));
    assertNotNull(exTemporalExtentChoice);
    ChildDefinition<?> exTemporalExtent = DefinitionUtil.getChild(exTemporalExtentChoice, new QName(GMD_NS, "EX_TemporalExtent"));
    assertNotNull(exTemporalExtent);
    ChildDefinition<?> temporalExtent = DefinitionUtil.getChild(exTemporalExtent, new QName(GMD_NS, "extent"));
    assertNotNull(temporalExtent);
    ChildDefinition<?> abstractTimePrimitive = DefinitionUtil.getChild(temporalExtent, new QName("http://www.opengis.net/gml/3.2/AbstractTimePrimitive", "choice"));
    assertNotNull(abstractTimePrimitive);
    ChildDefinition<?> timeInstant = DefinitionUtil.getChild(abstractTimePrimitive, new QName(GML_NS, "TimeInstant"));
    assertNotNull(timeInstant);
    ChildDefinition<?> timeInstantGmlId = DefinitionUtil.getChild(timeInstant, new QName(GML_NS, "id"));
    assertNotNull(timeInstantGmlId);
    List<ChildDefinition<?>> childDefs = new ArrayList<ChildDefinition<?>>();
    childDefs.add(extent);
    childDefs.add(exExtent);
    childDefs.add(temporalElement);
    childDefs.add(exTemporalExtentChoice);
    childDefs.add(exTemporalExtent);
    childDefs.add(temporalExtent);
    childDefs.add(abstractTimePrimitive);
    childDefs.add(timeInstant);
    childDefs.add(timeInstantGmlId);
    return createTargetProperty(childDefs);
}
Also used : QName(javax.xml.namespace.QName) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) ArrayList(java.util.ArrayList)

Example 10 with ChildDefinition

use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.

the class AppSchemaMappingTest method getBeginLifespanNilReasonTargetProperty.

private ListMultimap<String, Property> getBeginLifespanNilReasonTargetProperty() {
    ChildDefinition<?> beginLifeSpan = DefinitionUtil.getChild(landCoverUnitType, new QName(LANDCOVER_NS, "beginLifespanVersion"));
    assertNotNull(beginLifeSpan);
    ChildDefinition<?> nilReason = DefinitionUtil.getChild(beginLifeSpan, new QName(GML_NIL_REASON));
    assertNotNull(nilReason);
    List<ChildDefinition<?>> childDefs = new ArrayList<ChildDefinition<?>>();
    childDefs.add(beginLifeSpan);
    childDefs.add(nilReason);
    return createTargetProperty(childDefs);
}
Also used : QName(javax.xml.namespace.QName) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) ArrayList(java.util.ArrayList)

Aggregations

ChildDefinition (eu.esdihumboldt.hale.common.schema.model.ChildDefinition)32 ArrayList (java.util.ArrayList)20 QName (javax.xml.namespace.QName)19 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)11 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)6 Definition (eu.esdihumboldt.hale.common.schema.model.Definition)6 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)5 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)5 DefinitionGroup (eu.esdihumboldt.hale.common.schema.model.DefinitionGroup)5 List (java.util.List)5 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)4 Pair (eu.esdihumboldt.util.Pair)3 LinkedList (java.util.LinkedList)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 TreePath (org.eclipse.jface.viewers.TreePath)3 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)2 InstanceValidationMessage (eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage)2 InstanceValidationReport (eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationReport)2 Group (eu.esdihumboldt.hale.common.instance.model.Group)2 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)2