/** * Creates a new validator. * * @param scope {@code FEATURE} if the object to validate is a feature, or * {@code ATTRIBUTE} for an attribute, or {@code null} otherwise. */ Validator(final ScopeCode scope) { quality = new DefaultDataQuality(); if (scope != null) { quality.setScope(new DefaultScope(scope)); } }
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <gmd:DQ_DataQuality>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public DefaultDataQuality getElement() { return DefaultDataQuality.castOrCopy(metadata); }
/** * Sets the non-quantitative quality information about the lineage of the data specified by the scope. * * @param newValue the new lineage. */ public void setLineage(final Lineage newValue) { checkWritePermission(lineage); lineage = newValue; } }
final DefaultDataQuality quality = new DefaultDataQuality(ScopeCode.DATASET); quality.setLineage(lineage); addIfAbsent(metadata.getDataQualityInfo(), quality);
/** * Returns a SIS metadata implementation with the values of the given arbitrary implementation. * This method performs the first applicable action in the following choices: * * <ul> * <li>If the given object is {@code null}, then this method returns {@code null}.</li> * <li>Otherwise if the given object is already an instance of * {@code DefaultDataQuality}, then it is returned unchanged.</li> * <li>Otherwise a new {@code DefaultDataQuality} instance is created using the * {@linkplain #DefaultDataQuality(DataQuality) copy constructor} * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other * metadata contained in the given object are not recursively copied.</li> * </ul> * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultDataQuality castOrCopy(final DataQuality object) { if (object == null || object instanceof DefaultDataQuality) { return (DefaultDataQuality) object; } return new DefaultDataQuality(object); }
quality.getReports().add(report);
/** * Returns the quantitative quality information for the data specified by the scope. * * @return quantitative quality information for the data. */ @Override @XmlElement(name = "report", required = true) public Collection<Element> getReports() { return reports = nonNullCollection(reports, Element.class); }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(DataQuality) */ public DefaultDataQuality(final DataQuality object) { super(object); if (object != null) { scope = object.getScope(); reports = copyCollection(object.getReports(), Element.class); lineage = object.getLineage(); } }
/** * Evaluates the quality of this attribute with a custom rule. */ @Override public DataQuality quality() { final DefaultDataQuality quality = (DefaultDataQuality) super.quality(); final DefaultDomainConsistency report = new DefaultDomainConsistency(); final DefaultQuantitativeResult result = new DefaultQuantitativeResult(); result.setErrorStatistic(new SimpleInternationalString(ADDITIONAL_QUALITY_INFO)); report.setMeasureIdentification(NamedIdentifier.castOrCopy(getName())); report .setResults(singleton(result)); quality.setReports(singleton(report)); return quality; } }
/** * Returns a SIS metadata implementation with the values of the given arbitrary implementation. * This method performs the first applicable action in the following choices: * * <ul> * <li>If the given object is {@code null}, then this method returns {@code null}.</li> * <li>Otherwise if the given object is already an instance of * {@code DefaultDataQuality}, then it is returned unchanged.</li> * <li>Otherwise a new {@code DefaultDataQuality} instance is created using the * {@linkplain #DefaultDataQuality(DataQuality) copy constructor} * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other * metadata contained in the given object are not recursively copied.</li> * </ul> * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultDataQuality castOrCopy(final DataQuality object) { if (object == null || object instanceof DefaultDataQuality) { return (DefaultDataQuality) object; } return new DefaultDataQuality(object); }
quality.getReports().add(report);
/** * Returns the quantitative quality information for the data specified by the scope. * * @return quantitative quality information for the data. */ @Override @XmlElement(name = "report") public Collection<Element> getReports() { return reports = nonNullCollection(reports, Element.class); }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(DataQuality) */ public DefaultDataQuality(final DataQuality object) { super(object); if (object != null) { scope = object.getScope(); reports = copyCollection(object.getReports(), Element.class); lineage = object.getLineage(); } }
/** * Creates a new validator. * * @param scope {@code FEATURE} if the object to validate is a feature, or * {@code ATTRIBUTE} for an attribute, or {@code null} otherwise. */ Validator(final ScopeCode scope) { quality = new DefaultDataQuality(); if (scope != null) { quality.setScope(new DefaultScope(scope)); } }
/** * Sets the specific data to which the data quality information applies. * * @param newValue the new scope. */ public void setScope(final Scope newValue) { checkWritePermission(); scope = newValue; }
/** * Implementation of {@link AbstractFeature#quality()}, also shared by {@link Features} static method. * * @param type the type of the {@code feature} argument, provided explicitly for protecting from user overriding. * @param feature the feature to validate. */ void validate(final FeatureType type, final AbstractFeature feature) { for (final AbstractIdentifiedType pt : type.getProperties(true)) { final Object property = feature.getProperty(pt.getName().toString()); final DataQuality pq; if (property instanceof AbstractAttribute<?>) { pq = ((AbstractAttribute<?>) property).quality(); } else if (property instanceof AbstractAssociation) { pq = ((AbstractAssociation) property).quality(); } else if (property instanceof AbstractAttribute<?>) { validate(((AbstractAttribute<?>) property).getType(), ((AbstractAttribute<?>) property).getValues()); continue; } else if (property instanceof AbstractAssociation) { validate(((AbstractAssociation) property).getRole(), ((AbstractAssociation) property).getValues()); continue; } else { continue; } if (pq != null) { // Should not be null, but let be safe. quality.getReports().addAll(pq.getReports()); } } }
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <mdq:DQ_DataQuality>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public DefaultDataQuality getElement() { return DefaultDataQuality.castOrCopy(metadata); }
/** * Sets the non-quantitative quality information about the lineage of the data specified by the scope. * * @param newValue the new lineage. */ public void setLineage(final Lineage newValue) { checkWritePermission(); lineage = newValue; } }
/** * Implementation of {@link AbstractFeature#quality()}, also shared by {@link Features} static method. * * @param type the type of the {@code feature} argument, provided explicitely for protecting from user overriding. * @param feature the feature to validate. */ void validate(final FeatureType type, final AbstractFeature feature) { for (final AbstractIdentifiedType pt : type.getProperties(true)) { final Object property = feature.getProperty(pt.getName().toString()); final DataQuality pq; if (property instanceof AbstractAttribute<?>) { pq = ((AbstractAttribute<?>) property).quality(); } else if (property instanceof AbstractAssociation) { pq = ((AbstractAssociation) property).quality(); } else if (property instanceof AbstractAttribute<?>) { validate(((AbstractAttribute<?>) property).getType(), ((AbstractAttribute<?>) property).getValues()); continue; } else if (property instanceof AbstractAssociation) { validate(((AbstractAssociation) property).getRole(), ((AbstractAssociation) property).getValues()); continue; } else { continue; } if (pq != null) { // Should not be null, but let be safe. quality.getReports().addAll(pq.getReports()); } } }
/** * Sets the specific data to which the data quality information applies. * * @param newValue the new scope. */ public void setScope(final Scope newValue) { checkWritePermission(scope); scope = newValue; }