public static JsonObject GetJsonLdResultsMetaData(JsonObject jsonLd) { JsonObject retval = new JsonObject(); try { String JSON_TYPE = "type"; String JSON_NODE_COUNT = "node_count"; // convert the jsonLD to a nodegroup. // note: this assumes that the results of the construct json can be transformed into a nodegroup. // this will break in the event that type info is omited, for instance. because this is intended to be // used with the dispatcher, it is a reasonable assumption for now. NodeGroup ngTemp; ngTemp = NodeGroup.FromConstructJson(jsonLd); retval.Add(JSON_TYPE, JsonValue.CreateStringValue("JSON-LD")); retval.Add(JSON_NODE_COUNT, JsonValue.CreateNumberValue(ngTemp.GetNodeCount())); return(retval); } catch (Exception e) { throw new Exception("Error assembling JSON header information for JSON-LD results: " + e.Message); } }
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()); } }
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; }
public NodeGroup GetResultsNodeGroup() { NodeGroup ng = NodeGroup.FromConstructJson(resultsContents); return(ng); }