public void AddSelectVariable(string variableName, string entityType, bool isCollection) { if (!SelectVariables.Contains(variableName)) { SelectVariables.Add(variableName); VariableType[variableName] = new SparqlVariableInfo { EntityType = entityType, IsCollection = isCollection }; } }
public string GetSparqlRepresentation() { if (!String.IsNullOrEmpty(DescribeResource)) { return(String.Format("CONSTRUCT {{ <{0}> ?p ?o }} WHERE {{ <{0}> ?p ?o }}", DescribeResource)); } var queryBuilder = new StringBuilder(); bool inSubquery = false; if (SelectVariables.Count > 0) { if (IsDescribe) { queryBuilder.Append("CONSTRUCT {"); foreach (var sv in SelectVariables) { queryBuilder.AppendFormat("?{0} ?{0}_p ?{0}_o . ", sv); queryBuilder.AppendFormat( "?{0} <http://brightstardb.com/odata-sparql/variable-binding> \"{0}\"", sv); } queryBuilder.Append("} WHERE { "); foreach (var sv in SelectVariables.Distinct()) { queryBuilder.AppendFormat("?{0} ?{0}_p ?{0}_o . ", sv); } queryBuilder.Append("{"); inSubquery = true; } queryBuilder.Append("SELECT "); foreach (string sv in SelectVariables) { queryBuilder.AppendFormat("?{0} ", sv); } } else { queryBuilder.Append("SELECT * "); } queryBuilder.Append("WHERE { "); queryBuilder.Append(RootGraphPattern.GetSparqlRepresentation()); queryBuilder.Append("} "); if (Ordering != null) { queryBuilder.Append("ORDER BY "); queryBuilder.Append(Ordering.GetSparqlRepresentation()); queryBuilder.Append(" "); } if (Offset.HasValue) { queryBuilder.AppendFormat("OFFSET {0} ", Offset); } if (Limit.HasValue) { queryBuilder.AppendFormat("LIMIT {0} ", Limit); } if (inSubquery) { queryBuilder.Append("} }"); } return(queryBuilder.ToString()); }
/// <summary> /// Run scenario with variables. /// </summary> private void RunScenarioWithVariables(object sender, EventArgs e) { TreePosition tmp = CurrentServer.SelectedRow; if (tmp == null) return; var data = ServerStore.GetNavigatorAt(tmp).GetValue(ColumnType); if (data is Scenario) { if (WorkingThread != null) { MessageDialog.ShowError(Director.Properties.Resources.CanNotStartScenario); return; } Scenario s = (Scenario)data; // Show dialog var variableDialog = new SelectVariables (s); // Status var stat = variableDialog.Run(); // Save and run | Ok - save variables if (stat != null && stat != Command.Cancel) s.customVariables = variableDialog.NewVariableList(); // Run if (stat == Command.Ok) { WorkingThread = new Thread(ThreadWorker); WorkingThread.IsBackground = true; WorkingThread.Start(s); } // Update view UpdateControlView(sender, e); variableDialog.Dispose (); } }