Beispiel #1
0
        public void NodeGroupFromConstruct()
        {
            NodeGroup ngResult = new NodeGroup();

            NodeGroupExecutionClientConfig necc = new NodeGroupExecutionClientConfig("http", "fake-server.crd.ge.com", 12058);
            NodeGroupExecutionClient       nec  = new NodeGroupExecutionClient(necc);

            String nodeGroupId    = "Logging SPARQLgraph alerts";
            String connectionInfo = "{ \"name\": \"Logging SparqlGraph\", \"domain\": \"http://com.ge.research/knowledge/UsageLogging\", \"model\": [ { \"type\": \"virtuoso\", \"url\": \"http://fake-server.crd.ge.com:2420\", \"dataset\": \"http://com.ge.research/knowledge/UsageLogging/LogMaster\"} ], \"data\": [ {\"type\": \"virtuoso\", \"url\": \"http://fake-server.crd.ge.com:2420\", \"dataset\": \"http://com.ge.research/knowledge/UsageLogging/SPARQLGraph\" } ]}";

            JsonObject jObject = JsonObject.Parse(connectionInfo);

            JsonObject jsonLD = nec.ExecuteDispatchConstructByIdToJsonLd(nodeGroupId, jObject, null, null).Result;

            NodeGroupResultSet ngResultSet = new NodeGroupResultSet(true);

            ngResultSet.ReadJson(jsonLD);


            ngResult = NodeGroup.FromConstructJson(ngResultSet.GetResultsJson());

            Debug.WriteLine("total node count =" + ngResult.GetNodeCount());

            Assert.IsTrue(ngResult.GetNodeCount() > 0);

            foreach (Node nCurr in ngResult.GetNodeList())
            {
                // write some basic debug so we can see something is working.
                Debug.WriteLine("uri: " + nCurr.GetFullUriName() + " , instanceValue: " + nCurr.GetInstanceValue());
            }
        }
Beispiel #2
0
        public void NodeGroupSerializationAfterReadingFromJson()
        {
            NodeGroup ngRoot = new NodeGroup();

            ngRoot.AddJsonEncodedNodeGroup((JsonObject.Parse(jsonContent)).GetNamedObject("sNodeGroup"));

            JsonObject serialized = ngRoot.ToJson();

            NodeGroup ngAlternate = new NodeGroup();

            ngAlternate.AddJsonEncodedNodeGroup(serialized);

            Assert.AreEqual(ngRoot.GetNodeCount(), ngAlternate.GetNodeCount());

            foreach (Node nd in ngRoot.GetNodeList())
            {
                int propCount = nd.GetPropertyItems().Count;
                int nodeCount = nd.GetNodeItemList().Count;

                List <Node> compareNodes = ngAlternate.GetNodeByURI(nd.GetFullUriName());

                Boolean foundIt = false;

                Debug.WriteLine("checking node: " + nd.GetFullUriName() + " with nodeItemCount: " + nodeCount + " , and propertyCount :" + propCount);

                foreach (Node comNode in compareNodes)
                {
                    int compPropCount = comNode.GetPropertyItems().Count;
                    int compNodeCount = comNode.GetNodeItemList().Count;

                    if (propCount == compPropCount && nodeCount == compNodeCount)
                    {
                        foundIt = true;
                    }
                }

                if (!foundIt)
                {
                    Assert.Fail();
                }
            }
        }
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (this.queryNodeGroup.GetNodeCount() == 0)
            {
                return;
            }

            // try to set all the URIs to returned.

            foreach (Node nd in this.queryNodeGroup.GetNodeList())
            {
                nd.SetIsReturned(true);
            }

            // get a query?
            String query = await this.ngc.ExecuteGetConstructForInstanceManipulation(this.queryNodeGroup);

            Debug.WriteLine("requested query:");
            Debug.WriteLine(query);

            // run a job:
            Debug.WriteLine("about to run query:");

            JsonObject jOb = await ngec.ExecuteDispatchConstructForInstanceManipulationFromNodeGroupToJsonLd(this.queryNodeGroup, this.myConnection.ToJson(), null, null);

            JsonObject graphObj = jOb.GetNamedObject("NodeGroup");

            NodeGroup returnedNg = NodeGroup.FromConstructJson(graphObj);

            Debug.WriteLine("Returned results Json was: ");
            Debug.WriteLine(jOb.ToString());

            Debug.WriteLine("Some stats on the return:");
            Debug.WriteLine("node group contains " + returnedNg.GetNodeCount() + " nodes.");
            Debug.WriteLine("up to the first five node instances found had the Id of ______________ and the Type of ______________");

            int i = 0;

            foreach (Node nd in returnedNg.GetNodeList())
            {
                if (i == 5)
                {
                    break;
                }

                Debug.WriteLine("Id: " + nd.GetInstanceValue() + "  Type: " + nd.GetFullUriName());

                // increment i
                i++;
            }

            var style = new Style(typeof(FlyoutPresenter));

            style.Setters.Add(new Setter(FlyoutPresenter.MinWidthProperty, Window.Current.CoreWindow.Bounds.Width));
            fly.SetValue(Flyout.FlyoutPresenterStyleProperty, style);

            Flyout.ShowAttachedFlyout(this.Rect);


            this.resultsCanvas = new NodeGroupCanvas(returnedNg, this.NodeGroupResults);
            this.resultsCanvas.RenderCanvas();

            planer = new NodeGroupPlaner(this.queryNodeGroup, this.resultsCanvas.QueryNodeGroup, this.oInfo);

            // fill in the sparqlID view
            List <SparqlIDViewEntry> sIds = new List <SparqlIDViewEntry>();

            foreach (String s in this.planer.GetQuerySparqlIds())
            {
                SparqlIDViewEntry sNeo = new SparqlIDViewEntry(s);
                sIds.Add(sNeo);
            }

            this.sparqlID_view.ItemsSource = sIds;

            this.PlaneTest.IsEnabled = true;
        }
Beispiel #4
0
        private List <NodeGroup> PlaneNodeGroupByQuerySparqlId(String querySparqlId, NodeGroup startingState)
        {
            // get every instance of the given type.
            List <Node>      classInstances_temp = this.resultNodesBySparqlId[querySparqlId];
            List <NodeGroup> tempDisplayNgs      = new List <NodeGroup>();

            // need to check the starting state against the classinstances. otherwise, we get some weird results:
            List <Node> classInstances = new List <Node>();
            List <Node> checkList      = startingState.GetNodeList();

            foreach (Node ndCheck in classInstances_temp)
            {
                if (checkList.Contains(ndCheck))
                {
                    classInstances.Add(ndCheck);
                }
            }


            // we need to create a blackList precursor that selectively contains the proper classes. it has to remove all of the instances
            // of the class instances that does not also labeled to another query SparqlID. Any with multiple bindings may still be valid.

            List <Node> blackListPrecursor = new List <Node>();

            foreach (Node nd in classInstances)
            {   // if the node has more than one query sparqlId, leave it off the blacklist.
                if (nd.GetOriginalSparqlIdsFromInstanceData() != null && nd.GetOriginalSparqlIdsFromInstanceData().Count > 1)
                {
                    continue;
                }
                else
                {
                    blackListPrecursor.Add(nd);
                }
            }

            // create a new NodeGroup for each of the instances, as they are planed this way
            foreach (Node currInst in classInstances)
            {   // create the basics and add the base node itself
                NodeGroup nxt = new NodeGroup();
                nxt.AddOrphanedNode(currInst);

                // add this nodeGroup to the collection of ones of interest:
                tempDisplayNgs.Add(nxt);

                // get all the descentends of the current instance.
                List <Node> instDescendents = startingState.GetSubNodes(currInst);

                // get all of the parents of the current instance.
                List <Node> instAncestors = this.GetUpstreamNodes(currInst);

                // get all of the parent's descendents (except the values in the classInstances list)
                List <Node> blackList = new List <Node>();



                blackList.AddRange(classInstances);
                blackList.AddRange(instDescendents);

                List <Node> additionalFamilyTree = this.GetDescendentsNotInBlackList(instAncestors, blackList);

                // add everything to the new NodeGroup.
                foreach (Node dn in instDescendents)
                {
                    nxt.AddOrphanedNode(dn);
                }
                foreach (Node pn in instAncestors)
                {
                    nxt.AddOrphanedNode(pn);
                }
                foreach (Node fm in additionalFamilyTree)
                {
                    nxt.AddOrphanedNode(fm);
                }
            }

            tempDisplayNgs = this.PrunePlanedNodeGroups(tempDisplayNgs);

            Debug.WriteLine("Processed " + this.planedNodeGroups.Count + " islands from a total of " + startingState.GetNodeCount() + " instance nodes using " + querySparqlId + " to perform the splits.");

            // lets learn a bit about each:
            int ngCount = 0;

            foreach (NodeGroup island in tempDisplayNgs)
            {
                Debug.WriteLine("NodeGroup ID:" + ngCount + " has " + island.GetNodeCount() + " total nodes. it has " + " instances of " + querySparqlId + ". ");
                Debug.WriteLine("content was: ");
                foreach (Node nd in island.GetNodeList())
                {
                    Debug.WriteLine("-- " + nd.GetInstanceValue() + "[" + nd.GetFullUriName() + "]");
                }
                ngCount++;
            }

            return(tempDisplayNgs);
        }