private static int CompareElements(QualitySpecificationElement e1,
                                    QualitySpecificationElement e2)
 {
     return(string.Compare(e1.QualityCondition.Name,
                           e2.QualityCondition.Name,
                           StringComparison.CurrentCulture));
 }
        void IExceptionEvaluationStatistics.AddUsedException(
            ExceptionObject exceptionObject, QualitySpecificationElement element,
            QaError qaError)
        {
            ExceptionCount++;

            var issueGroupKey = new IssueGroupKey(new Issue(element, qaError));

            List <ExceptionObject> usedExceptionObjects;

            if (!_usedExceptions.TryGetValue(issueGroupKey, out usedExceptionObjects))
            {
                usedExceptionObjects           = new List <ExceptionObject>();
                _usedExceptions[issueGroupKey] = usedExceptionObjects;
            }

            usedExceptionObjects.Add(exceptionObject);

            string key = exceptionObject.ExceptionCategory?.Trim() ?? string.Empty;

            int count;

            count = _usedExceptionsByExceptionCategory.TryGetValue(key, out count)
                                        ? count + 1
                                        : 1;
            _usedExceptionsByExceptionCategory[key] = count;

            GetStatistics(element.QualityCondition).AddUsedException(exceptionObject);
        }
Example #3
0
 public static int GetDefaultSortIndex(
     [CanBeNull] QualitySpecificationElement element)
 {
     return(element == null
                                ? 0
                                : GetDefaultSortIndex(GetImageKey(element)));
 }
        public bool ExistsExceptionFor(QaError qaError,
                                       QualitySpecificationElement element,
                                       out ExceptionObject exceptionObject)
        {
            var uuid = new Guid(element.QualityCondition.Uuid);

            // TODO if the error exceeds the verification extent, compare with envelope by "contained envelope" criterion instead of "equal envelope"
            // Reason: some tests cut off the error geometry at the verification extent

            QualityConditionExceptions qualityConditionExceptions;

            if (_qualityConditionExceptions.TryGetValue(uuid, out qualityConditionExceptions))
            {
                if (qualityConditionExceptions.ExistsExceptionFor(qaError, out exceptionObject))
                {
                    _exceptionEvaluationStatistics.AddUsedException(
                        exceptionObject, element, qaError);
                    return(true);
                }

                return(false);
            }

            // no exceptions exist for this quality condition
            exceptionObject = null;
            return(false);
        }
 private void AddToBuffer([NotNull] QaError qaError,
                          [NotNull] QualitySpecificationElement element)
 {
     _pendingQaErrors.Add(new PendingQaError(qaError, element, qaError.Geometry));
     _errorGeometryVertexCount = _errorGeometryVertexCount +
                                 GeometryUtils.GetPointCount(qaError.Geometry);
 }
        public void WriteIssue(QaError qaError, QualitySpecificationElement element)
        {
            var errorRequiresIdLookup = false;

            foreach (InvolvedRow involvedRow in qaError.InvolvedRows)
            {
                TableKeyLookup tableKeyLookup =
                    GetTableRequiringIdLookup(involvedRow, element);

                if (tableKeyLookup != null)
                {
                    tableKeyLookup.AddObjectId(involvedRow.OID);
                    errorRequiresIdLookup = true;
                }
            }

            if (errorRequiresIdLookup)
            {
                AddToBuffer(qaError, element);

                if (IsBufferCapacityExceeded())
                {
                    Flush();
                }
            }
            else
            {
                var issue = new Issue(element, qaError);

                WriteIssueCore(issue, qaError.Geometry);
            }
        }
Example #7
0
 public void AddVerifiedQualityCondition(
     QualitySpecificationElement qualitySpecificationElement)
 {
     foreach (IVerificationReportBuilder builder in _reportBuilders)
     {
         builder.AddVerifiedQualityCondition(qualitySpecificationElement);
     }
 }
 public PendingQaError(
     [NotNull] QaError error,
     [NotNull] QualitySpecificationElement qualitySpecificationElement,
     [CanBeNull] IGeometry errorGeometry)
 {
     Error         = error;
     ErrorGeometry = errorGeometry;
     QualitySpecificationElement = qualitySpecificationElement;
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Issue"/> class.
 /// </summary>
 /// <param name="qualitySpecificationElement">The quality condition.</param>
 /// <param name="qaError">The QA error.</param>
 public Issue([NotNull] QualitySpecificationElement qualitySpecificationElement,
              [NotNull] QaError qaError)
     : this(qualitySpecificationElement,
            qaError.Description,
            IssueUtils.GetInvolvedTables(qaError.InvolvedRows),
            qaError.IssueCode,
            qaError.AffectedComponent,
            qaError.Values)
 {
 }
        private Issue CreateIssue([NotNull] PendingQaError pendingQaError)
        {
            QualitySpecificationElement element = pendingQaError.QualitySpecificationElement;

            QaError error = pendingQaError.Error;

            return(new Issue(element,
                             error.Description,
                             GetInvolvedTables(pendingQaError.Error.InvolvedRows, element),
                             error.IssueCode,
                             error.AffectedComponent,
                             error.Values));
        }
Example #11
0
        private bool ExistsExceptionFor([NotNull] QaError qaError,
                                        [NotNull] QualitySpecificationElement element)
        {
            if (_exceptionObjectEvaluator == null)
            {
                return(false);
            }

            ExceptionObject exceptionObject;

            return(_exceptionObjectEvaluator.ExistsExceptionFor(qaError, element,
                                                                out exceptionObject));
        }
Example #12
0
        internal HtmlQualitySpecificationElement(
            [NotNull] HtmlQualityCondition htmlQualityCondition,
            [NotNull] QualitySpecificationElement element)
        {
            Assert.ArgumentNotNull(htmlQualityCondition, nameof(htmlQualityCondition));
            Assert.ArgumentNotNull(element, nameof(element));

            _htmlQualityCondition = htmlQualityCondition;
            _element = element;

            IssueType = _element.AllowErrors
                                            ? LocalizableStrings.IssueType_Warning
                                            : LocalizableStrings.IssueType_Error;
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrderedQualitySpecificationElement"/> class.
        /// </summary>
        /// <param name="qualitySpecificationElement">The quality condition.</param>
        /// <param name="listOrder">The list order.</param>
        public OrderedQualitySpecificationElement(
            [NotNull] QualitySpecificationElement qualitySpecificationElement,
            int listOrder)
        {
            Assert.ArgumentNotNull(qualitySpecificationElement,
                                   nameof(qualitySpecificationElement));

            QualitySpecificationElement = qualitySpecificationElement;
            _listOrder = listOrder;

            _executionPriority =
                qualitySpecificationElement.QualityCondition.TestDescriptor.ExecutionPriority ??
                int.MaxValue;
            _stopOnError = qualitySpecificationElement.StopOnError;
        }
Example #14
0
        public void Process([NotNull] QaErrorEventArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            QaError qaError = args.QaError;

            QualitySpecificationElement element = _elementsByTest[qaError.Test];

            QualityCondition qualityCondition = element.QualityCondition;

            if (element.StopOnError)
            {
                foreach (InvolvedRow involvedRow in qaError.InvolvedRows)
                {
                    var stopInfo = new StopInfo(qualityCondition, qaError.Description);
                    _rowsWithStopConditions.Add(involvedRow.TableName, involvedRow.OID,
                                                stopInfo);
                }
            }

            if (IsIssueGeometryOutsideTestPerimeter(qaError, qualityCondition))
            {
                args.Cancel = true;
                return;
            }

            IssueStats issueStats = GetIssueStats(qualityCondition);

            if (ExistsExceptionFor(qaError, element))
            {
                issueStats.AddException();
                return;
            }

            issueStats.AddIssue();

            if (element.AllowErrors)
            {
                WarningCount++;
            }
            else
            {
                ErrorCount++;
                Fulfilled = false;
            }

            _issueWriter.WriteIssue(qaError, element);
        }
        public IssueFoundEventArgs(
            [NotNull] QualitySpecificationElement qualitySpecificationElement,
            [NotNull] QaError qaError,
            bool isAllowable,
            string involvedObjectsString)
        {
            Assert.ArgumentNotNull(qualitySpecificationElement,
                                   nameof(qualitySpecificationElement));
            Assert.ArgumentNotNull(qaError, nameof(qaError));

            QualitySpecificationElement = qualitySpecificationElement;
            _qaError      = qaError;
            ErrorGeometry = qaError.Geometry;
            IsAllowable   = isAllowable;

            LegacyInvolvedObjectsString = involvedObjectsString;
        }
        private TableKeyLookup GetTableRequiringIdLookup(
            [NotNull] InvolvedRow involvedRow,
            [NotNull] QualitySpecificationElement element)
        {
            if (involvedRow.RepresentsEntireTable)
            {
                return(null);
            }

            IObjectDataset objectDataset = _datasetResolver.GetDatasetByInvolvedRowTableName(
                involvedRow.TableName, element.QualityCondition);

            Assert.NotNull(objectDataset,
                           "Unable to resolve object dataset for table name {0} and quality condition {1}",
                           involvedRow.TableName, element.QualityCondition.Name);

            return(GetTableRequiringIdLookup(objectDataset));
        }
        private SpecificationDataset(
            [NotNull] QualitySpecificationElement qualitySpecificationElement,
            [NotNull] DatasetTestParameterValue datasetTestParameterValue)
        {
            QualitySpecificationElement = qualitySpecificationElement;
            _datasetTestParameterValue  = datasetTestParameterValue;

            _allowImage.Tag    = QualityConditionType.Allowed;
            _continueImage.Tag = QualityConditionType.ContinueOnError;
            _stopImage.Tag     = QualityConditionType.StopOnError;

            Dataset dataset = datasetTestParameterValue.DatasetValue;

            if (dataset != null)
            {
                string datasetImageKey = DatasetTypeImageLookup.GetImageKey(dataset);
                DatasetType = _datasetImageList[datasetImageKey];
            }
        }
Example #18
0
        private List <QualityConditionVerification> GetQualityConditionVerifications(
            [NotNull] QualityVerificationMsg msg)
        {
            List <QualityConditionVerification> conditionVerifications =
                new List <QualityConditionVerification>();

            Dictionary <int, QualityCondition> conditionsById =
                new Dictionary <int, QualityCondition>();

            foreach (var conditionVerificationMsg in msg.ConditionVerifications)
            {
                int qualityConditionId = conditionVerificationMsg.QualityConditionId;

                QualityCondition qualityCondition = GetQualityCondition(
                    qualityConditionId, conditionsById);

                Assert.NotNull(qualityCondition, $"Condition {qualityConditionId} not found");

                // TODO: AllowError/StopOnError
                QualitySpecificationElement element =
                    new QualitySpecificationElement(qualityCondition);

                var conditionVerification = new QualityConditionVerification(element);

                conditionVerification.Fulfilled  = conditionVerificationMsg.Fulfilled;
                conditionVerification.ErrorCount = conditionVerificationMsg.ErrorCount;

                conditionVerification.ExecuteTime     = conditionVerificationMsg.ExecuteTime;
                conditionVerification.RowExecuteTime  = conditionVerificationMsg.RowExecuteTime;
                conditionVerification.TileExecuteTime = conditionVerificationMsg.TileExecuteTime;

                if (conditionVerificationMsg.StopConditionId >= 0)
                {
                    conditionVerification.StopCondition = GetQualityCondition(
                        conditionVerificationMsg.StopConditionId, conditionsById);
                }

                conditionVerifications.Add(conditionVerification);
            }

            return(conditionVerifications);
        }
Example #19
0
        private static TreeNode AddNode([NotNull] TreeNodeCollection nodes,
                                        [NotNull] SpecificationDataset specificationDataset)
        {
            Assert.NotNull(specificationDataset.QualityCondition);

            TreeNode node = nodes.Add(specificationDataset.QualityCondition.Name);

            QualitySpecificationElement element =
                specificationDataset.QualitySpecificationElement;

            if (element != null)
            {
                node.Tag     = element;
                node.Checked = element.Enabled;

                if (element.AllowErrors)
                {
                    node.ImageKey         = _allowErrors;
                    node.SelectedImageKey = _allowErrors;
                }
                else if (element.StopOnError == false)
                {
                    node.ImageKey         = _continueOnErrors;
                    node.SelectedImageKey = _continueOnErrors;
                }
                else
                {
                    node.ImageKey         = _stopOnErrors;
                    node.SelectedImageKey = _stopOnErrors;
                }
            }

            QualityConditionVerification verification =
                specificationDataset.QualityConditionVerification;

            if (verification != null)
            {
                ConfigureVerificationNode(node, verification);
            }

            return(node);
        }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Issue"/> class.
        /// </summary>
        /// <param name="qualitySpecificationElement">The quality condition.</param>
        /// <param name="description">The description.</param>
        /// <param name="involvedRows">The involved rows.</param>
        /// <param name="issueCode">The issue code.</param>
        /// <param name="affectedComponent">The affected component.</param>
        /// <param name="values"></param>
        public Issue([NotNull] QualitySpecificationElement qualitySpecificationElement,
                     [NotNull] string description,
                     [NotNull] IEnumerable <InvolvedTable> involvedRows,
                     [CanBeNull] IssueCode issueCode         = null,
                     [CanBeNull] string affectedComponent    = null,
                     [CanBeNull] IEnumerable <object> values = null)
        {
            Assert.ArgumentNotNull(qualitySpecificationElement,
                                   nameof(qualitySpecificationElement));
            Assert.ArgumentNotNullOrEmpty(description, nameof(description));
            Assert.ArgumentNotNull(involvedRows, nameof(involvedRows));

            QualitySpecificationElement = qualitySpecificationElement;
            Description       = description;
            IssueCode         = issueCode;
            Values            = values?.ToList();
            AffectedComponent = StringUtils.IsNullOrEmptyOrBlank(affectedComponent)
                                                    ? null
                                                    : affectedComponent;
            _involvedTables = new List <InvolvedTable>(involvedRows);
        }
        private IEnumerable <InvolvedTable> GetInvolvedTables(
            [NotNull] IEnumerable <InvolvedRow> involvedRows,
            [NotNull] QualitySpecificationElement element)
        {
            var result = new List <InvolvedTable>();

            foreach (KeyValuePair <string, List <InvolvedRow> > tableRows in
                     InvolvedRowUtils.GroupByTableName(involvedRows))
            {
                string             tableName            = tableRows.Key;
                List <InvolvedRow> involvedRowsForTable = tableRows.Value;

                IObjectDataset dataset = _datasetResolver.GetDatasetByInvolvedRowTableName(
                    tableName, element.QualityCondition);
                Assert.NotNull(dataset, "unable to resolve dataset");

                result.Add(CreateInvolvedTable(dataset, involvedRowsForTable));
            }

            return(result);
        }
        public void AddDependency([NotNull] QualitySpecificationElement element,
                                  [NotNull] Dataset fromDataset,
                                  [NotNull] Dataset toDataset,
                                  [NotNull] string fromParameterName,
                                  [NotNull] string toParameterName,
                                  [CanBeNull] string fromFilterExpression = null,
                                  [CanBeNull] string toFilterExpression   = null,
                                  bool directed = true)
        {
            DatasetNode fromNode = _datasetNodes[fromDataset];
            DatasetNode toNode   = _datasetNodes[toDataset];

            var dependency = new DatasetDependency(element,
                                                   fromNode, toNode,
                                                   fromParameterName, toParameterName,
                                                   fromFilterExpression, toFilterExpression,
                                                   directed);

            fromNode.AddOutgoingDependency(dependency);
            toNode.AddIncomingDependency(dependency);

            _datasetDependencies.Add(dependency);
        }
Example #23
0
        public void AddVerifiedQualityCondition(
            QualitySpecificationElement qualitySpecificationElement)
        {
            if (_verifiedQualityConditions.Contains(qualitySpecificationElement))
            {
                return;
            }

            _verifiedQualityConditions.Add(qualitySpecificationElement);

            QualityCondition qualityCondition = qualitySpecificationElement.QualityCondition;

            foreach (Dataset dataset in qualityCondition.GetDatasetParameterValues())
            {
                List <QualitySpecificationElement> list;
                if (!_qualitySpecificationElementsByDataset.TryGetValue(dataset, out list))
                {
                    list = new List <QualitySpecificationElement>();
                    _qualitySpecificationElementsByDataset.Add(dataset, list);
                }

                list.Add(qualitySpecificationElement);
            }
        }
        public static List <SpecificationDataset> CreateList(
            [NotNull] QualitySpecificationElement qualitySpecificationElement)
        {
            Assert.ArgumentNotNull(qualitySpecificationElement,
                                   nameof(qualitySpecificationElement));

            var datasetNames = new List <string>();
            var result       = new List <SpecificationDataset>();

            foreach (
                TestParameterValue param in
                qualitySpecificationElement.QualityCondition.ParameterValues)
            {
                if (param is DatasetTestParameterValue == false)
                {
                    continue;
                }

                var dsParam = (DatasetTestParameterValue)param;
                if (dsParam.DatasetValue == null)
                {
                    continue;
                }

                if (datasetNames.Contains(dsParam.StringValue))
                {
                    continue;
                }

                datasetNames.Add(dsParam.StringValue);

                result.Add(new SpecificationDataset(qualitySpecificationElement, dsParam));
            }

            return(result);
        }
Example #25
0
        public DatasetDependency([NotNull] QualitySpecificationElement element,
                                 [NotNull] DatasetNode fromDatasetNode,
                                 [NotNull] DatasetNode toDatasetNode,
                                 [NotNull] string fromParameterName,
                                 [NotNull] string toParameterName,
                                 [CanBeNull] string fromFilterExpression = null,
                                 [CanBeNull] string toFilterExpression   = null,
                                 bool directed = true)
        {
            Assert.ArgumentNotNull(element, nameof(element));
            Assert.ArgumentNotNull(fromDatasetNode, nameof(fromDatasetNode));
            Assert.ArgumentNotNull(toDatasetNode, nameof(toDatasetNode));
            Assert.ArgumentNotNullOrEmpty(fromParameterName, nameof(fromParameterName));
            Assert.ArgumentNotNullOrEmpty(toParameterName, nameof(toParameterName));

            _element              = element;
            _fromDatasetNode      = fromDatasetNode;
            _toDatasetNode        = toDatasetNode;
            _fromParameterName    = fromParameterName;
            _toParameterName      = toParameterName;
            _fromFilterExpression = fromFilterExpression;
            _toFilterExpression   = toFilterExpression;
            _directed             = directed;
        }
Example #26
0
        private static XmlVerifiedQualityCondition CreateVerifiedQualityCondition(
            [NotNull] QualitySpecificationElement element,
            [NotNull] ICollection <XmlIssue> issues,
            [CanBeNull] IQualityConditionExceptionStatistics exceptionStatistics,
            bool reportIssues,
            bool reportParameters,
            bool reportDescription)
        {
            QualityCondition qualityCondition = element.QualityCondition;

            var result =
                new XmlVerifiedQualityCondition
            {
                Name        = Escape(qualityCondition.Name),
                Guid        = qualityCondition.Uuid,
                VersionGuid = qualityCondition.VersionUuid,
                Type        = element.AllowErrors
                                                       ? XmlQualityConditionType.Soft
                                                       : XmlQualityConditionType.Hard,
                StopCondition = element.StopOnError,
                Category      = qualityCondition.Category
            };

            if (issues.Count > 0)
            {
                if (reportIssues)
                {
                    result.AddIssues(issues, element.ReportIndividualErrors);
                }
                else
                {
                    result.IssueCount = issues.Count;
                }
            }

            if (reportParameters)
            {
                result.TestDescriptor = GetTestDescriptor(qualityCondition.TestDescriptor);
                result.AddParameters(GetParameters(qualityCondition));
            }

            if (reportDescription)
            {
                if (StringUtils.IsNotEmpty(qualityCondition.Description))
                {
                    result.Description = Escape(qualityCondition.Description);
                }

                if (StringUtils.IsNotEmpty(qualityCondition.Url))
                {
                    result.Url = Escape(qualityCondition.Url);
                }
            }

            if (exceptionStatistics != null)
            {
                result.ExceptionCount = exceptionStatistics.ExceptionCount;
            }

            return(result);
        }
Example #27
0
 private IQualityConditionExceptionStatistics GetQualityConditionExceptionStatistics(
     [NotNull] QualitySpecificationElement element)
 {
     return(_exceptionStatistics?.GetQualityConditionStatistics(
                element.QualityCondition));
 }
Example #28
0
 public static string GetImageKey([CanBeNull] QualitySpecificationElement element)
 {
     return(element == null
                                ? null
                                : GetImageKey(GetImage(element)));
 }
Example #29
0
 public static Image GetImage([CanBeNull] QualitySpecificationElement element)
 {
     return(element == null
                                ? null
                                : GetImage(element.AllowErrors, element.StopOnError));
 }
 public void AddVerifiedQualityCondition(
     QualitySpecificationElement qualitySpecificationElement)
 {
 }