/// <summary>
        /// Initializes a new instance of the <see cref="QualityVerification"/> class.
        /// </summary>
        /// <param name="qualitySpecification">The quality specification that was verified.</param>
        public QualityVerification([NotNull] QualitySpecification qualitySpecification)
        {
            Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification));

            _operator          = EnvironmentUtils.UserDisplayName;
            _specificationName = qualitySpecification.Name;
            _specificationId   = !qualitySpecification.IsUnion
                                                   ? qualitySpecification.Id
                                                   : -1;

            _specificationDescription = qualitySpecification.Description;

            var datasets = new HashSet <Dataset>();

            foreach (QualitySpecificationElement element in qualitySpecification.Elements)
            {
                if (!element.Enabled)
                {
                    continue;
                }

                _conditionVerifications.Add(new QualityConditionVerification(element));

                foreach (Dataset dataset in element.QualityCondition.GetDatasetParameterValues())
                {
                    datasets.Add(dataset);
                }
            }

            foreach (Dataset dataset in datasets)
            {
                _verificationDatasets.Add(new QualityVerificationDataset(dataset));
            }
        }
Example #2
0
        /// <summary>
        /// Compares the quality specification to another quality specification.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns>bitwise result:
        /// 1 : this has specification not existing in other;
        /// 2 : other has specifications not existing in this
        /// </returns>
        public int Compare([NotNull] QualitySpecification other)
        {
            int equal;

            Union(other, out equal);

            return(equal);
        }
Example #3
0
        private QualitySpecification CreateEmptyCopy(
            [CanBeNull] string name)
        {
            var result = new QualitySpecification(name);

            CopyPropertiesTo(result);

            return(result);
        }
        public void UpdateFrom([NotNull] QualitySpecification source,
                               [NotNull] HashSet <Dataset> verifiedDatasets)
        {
            Assert.ArgumentNotNull(source, nameof(source));

            IDictionary <string, QualitySpecificationElement> updatedElements =
                Elements.Where(x => x.QualityCondition.Updated &&
                               StringUtils.IsNotEmpty(x.QualityCondition.Uuid))
                .ToDictionary(x => x.QualityCondition.Uuid);

            var disabledElements = new HashSet <string>(
                GetDisabledConditions().Select(q => q.Uuid));

            Clear();

            foreach (QualitySpecificationElement sourceElement in source.Elements)
            {
                if (!IsQualityConditionApplicable(sourceElement.QualityCondition,
                                                  verifiedDatasets))
                {
                    continue;
                }

                string key = sourceElement.QualityCondition.Uuid;

                QualitySpecificationElement updated;
                if (updatedElements.TryGetValue(key, out updated))
                {
                    AddElement(updated.QualityCondition,
                               updated.StopOnErrorOverride,
                               updated.AllowErrorsOverride,
                               !updated.Enabled);

                    updatedElements.Remove(key);
                }
                else
                {
                    // not an updated element - check if it was disabled
                    bool disabled = disabledElements.Contains(key) || !sourceElement.Enabled;

                    AddElement(sourceElement.QualityCondition.Clone(),
                               sourceElement.StopOnErrorOverride,
                               sourceElement.AllowErrorsOverride,
                               disabled);
                }
            }

            // re-add updated elements that are no longer part of source specification
            foreach (QualitySpecificationElement updated in updatedElements.Values)
            {
                AddElement(updated.QualityCondition,
                           updated.StopOnErrorOverride,
                           updated.AllowErrorsOverride,
                           !updated.Enabled);
            }
        }
Example #5
0
 protected internal void CopyPropertiesTo([NotNull] QualitySpecification target)
 {
     target._listOrder   = _listOrder;
     target._description = _description;
     target._tileSize    = _tileSize;
     target._url         = _url;
     target._notes       = _notes;
     target._hidden      = _hidden;
     target._category    = _category;
 }
        public CustomQualitySpecification(
            [NotNull] QualitySpecification customizedSpecification,
            [NotNull] string name,
            bool assignUuid = true)
            : base(name, assignUuid)
        {
            Assert.ArgumentNotNull(customizedSpecification, nameof(customizedSpecification));
            Assert.ArgumentNotNullOrEmpty(name, nameof(name));

            CustomizedSpecification = customizedSpecification;

            customizedSpecification.CopyPropertiesTo(this);
        }
Example #7
0
        public QualitySpecification CreateCopy()
        {
            QualitySpecification result = CreateEmptyCopy(string.Format("Copy of {0}", Name));

            foreach (QualitySpecificationElement element in _elements)
            {
                result.AddElement(element.QualityCondition,
                                  element.StopOnErrorOverride,
                                  element.AllowErrorsOverride);
            }

            return(result);
        }
Example #8
0
        public QualitySpecification Union([NotNull] QualitySpecification other,
                                          out int equal)
        {
            Assert.ArgumentNotNull(other, nameof(other));

            var result = new QualitySpecification(Name + "*" + other.Name)
            {
                _isUnion = true
            };

            equal = 0;
            var minOther = 0;

            // index des minimalen other elements, das noch nicht geprueft wurde, ob es in die union gehoert
            foreach (QualitySpecificationElement thisElement in _elements)
            {
                bool stopOnError = thisElement.StopOnError;
                bool allowErrors = thisElement.AllowErrors;
                bool enabled     = thisElement.Enabled;

                int otherIndex = other.IndexOf(thisElement.QualityCondition);
                if (otherIndex >= 0)
                {
                    QualitySpecificationElement otherElement;
                    for (int idxOther = minOther; idxOther < otherIndex; idxOther++)
                    {
                        otherElement = other._elements[idxOther];
                        QualityCondition otherCond = otherElement.QualityCondition;

                        if (IndexOf(otherCond) >= 0 || result.IndexOf(otherCond) >= 0)
                        {
                            continue;
                        }

                        result.AddElement(otherElement.QualityCondition,
                                          otherElement.StopOnError,
                                          otherElement.AllowErrors,
                                          !otherElement.Enabled);
                        equal |= 2;
                        // == equal = equal | 2; Beispiel equal = 1 --> nachher equal = 1 | 2 = 3
                    }

                    minOther = otherIndex;

                    otherElement = other._elements[otherIndex];
                    if (stopOnError != otherElement.StopOnError)
                    {
                        equal |= stopOnError
                                                                 ? 1
                                                                 : 2;
                        stopOnError = true;
                    }

                    if (allowErrors != otherElement.AllowErrors)
                    {
                        equal |= allowErrors
                                                                 ? 1
                                                                 : 2;
                        allowErrors = true;
                    }
                }
                else
                {
                    equal |= 1;
                }

                result.AddElement(thisElement.QualityCondition, stopOnError,
                                  allowErrors, !enabled);
            }

            foreach (QualitySpecificationElement otherElement in other._elements)
            {
                int unionIndex = result.IndexOf(otherElement.QualityCondition);
                if (unionIndex >= 0)
                {
                    continue;
                }

                equal |= 2;
                result.AddElement(otherElement.QualityCondition,
                                  otherElement.StopOnError,
                                  otherElement.AllowErrors,
                                  !otherElement.Enabled);
            }

            return(result);
        }
Example #9
0
        public QualitySpecification Union([NotNull] QualitySpecification other)
        {
            int equal;

            return(Union(other, out equal));
        }