예제 #1
0
        public static graphmltype GetGraphMLDocument([NotNull] DatasetDependencyGraph graph,
                                                     bool includeModelNodes = true)
        {
            var keys = new List <keytype>
            {
                CreateKey(_keyNodeLabel, "Label", keyfortype.node),
                CreateKey(_keyGeometryType, "GeometryType", keyfortype.node),
                CreateKey(_keyModelName, "Model", keyfortype.node),
                CreateKey(_keyEdgeLabel, "Label", keyfortype.edge),
                CreateKey(_keyQualityCondition, "QualityCondition", keyfortype.edge),
                CreateKey(_keyFromDataset, "FromDataset", keyfortype.edge),
                CreateKey(_keyToDataset, "ToDataset", keyfortype.edge),
                CreateKey(_keyFromFilterExpression, "FromFilterExpression",
                          keyfortype.edge),
                CreateKey(_keyToFilterExpression, "ToFilterExpression", keyfortype.edge),
                CreateKey(_keyFromParameter, "FromParameter", keyfortype.edge),
                CreateKey(_keyToParameter, "ToParameter", keyfortype.edge),
                CreateKey(_keyIssueType, "IssueType", keyfortype.edge),
                CreateKey(_keyStopCondition, "IsStopCondition", keyfortype.edge,
                          "boolean"),
                CreateKey(_keyCategory, "Category", keyfortype.edge),
                CreateKey(_keyTest, "Test", keyfortype.edge)
            };

            var rootItems = new List <object>();

            rootItems.AddRange(graph.DatasetDependencies.Select(CreateEdge).Cast <object>());

            if (includeModelNodes)
            {
                rootItems.AddRange(graph.ModelNodes.Select(CreateModelNode).Cast <object>());
            }
            else
            {
                rootItems.AddRange(
                    graph.DatasetNodes.Select(
                        node => CreateDatasetNode(node, useQualifiedLabel: true))
                    .Cast <object>());
            }

            var mlgraph = new graphtype
            {
                edgedefault = graphedgedefaulttype.directed,
                Items       = rootItems.ToArray()
            };

            var document = new graphmltype
            {
                key   = keys.ToArray(),
                Items = new object[] { mlgraph }
            };

            document.desc = graph.Description;

            return(document);
        }
예제 #2
0
        public static DatasetDependencyGraph GetGraph(
            [NotNull] IEnumerable <QualitySpecification> qualitySpecifications,
            bool exportBidirectionalDependenciesAsUndirectedEdges = false,
            bool includeSelfDependencies = false)
        {
            Assert.ArgumentNotNull(qualitySpecifications, nameof(qualitySpecifications));

            QualitySpecification union = Union(qualitySpecifications);

            var result = new DatasetDependencyGraph(GetDatasets(union), union.Name);

            foreach (QualitySpecificationElement element in union.Elements)
            {
                QualityCondition qualityCondition = element.QualityCondition;

                List <DatasetTestParameterValue> datasetTestParameterValues =
                    GetDatasetTestParameterValues(qualityCondition).ToList();

                for (var i = 0; i < datasetTestParameterValues.Count; i++)
                {
                    DatasetTestParameterValue value1 = datasetTestParameterValues[i];

                    if (value1.DatasetValue == null)
                    {
                        continue;
                    }

                    int startIndex = exportBidirectionalDependenciesAsUndirectedEdges
                                                                 ? i + 1 // half matrix
                                                                 : 0;    // full matrix

                    for (int j = startIndex; j < datasetTestParameterValues.Count; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }

                        DatasetTestParameterValue value2 = datasetTestParameterValues[j];

                        if (value2.DatasetValue == null)
                        {
                            continue;
                        }

                        if (!includeSelfDependencies &&
                            Equals(value1.DatasetValue, value2.DatasetValue))
                        {
                            // dependency between same dataset (but different parameter indexes), ignore
                            continue;
                        }

                        if (value1.UsedAsReferenceData)
                        {
                            // no dependency from value1 to value2
                            continue;
                        }

                        if (value1.TestParameterName == value2.TestParameterName)
                        {
                            if (ExcludeDependenciesWithinMultiValuedParameter(qualityCondition,
                                                                              value1
                                                                              .TestParameterName)
                                )
                            {
                                continue;
                            }
                        }

                        bool directed;
                        if (exportBidirectionalDependenciesAsUndirectedEdges)
                        {
                            // if (value2 is used as reference data: the dependency is directed)
                            directed = value2.UsedAsReferenceData;
                        }
                        else
                        {
                            // always directed (bidirectional dependencies represented as two directed dependencies)
                            directed = true;
                        }

                        result.AddDependency(element,
                                             value1.DatasetValue, value2.DatasetValue,
                                             value1.TestParameterName, value2.TestParameterName,
                                             value1.FilterExpression, value2.FilterExpression,
                                             directed);
                    }
                }
            }

            return(result);
        }