/// <summary> /// make new graph /// https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/UserGuide/Triple%20Store%20Integration /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newGraphToolStripMenuItem_Click(object sender, EventArgs e) { try { var form = new SingleForm { Title = "New Graph", Label = "URI", Content = config.GlobalPrefix + Config.GetRandomString(6) }; if (form.ShowDialog() != DialogResult.OK) { return; } var uri = form.Content; var g = new Graph { BaseUri = new Uri(uri) }; SetNewGraphTriple(g, uri); fuseki.SaveGraph(g); UpdateListViewGraph(); } catch (Exception ex) { MessageBox.Show("error during creating new graph. " + ex); } }
private void fromURIToolStripMenuItem_Click_1(object sender, EventArgs e) { if (listViewGraph.SelectedItems.Count != 1) { MessageBox.Show("no graph is selected"); return; } var graphUri = (string)listViewGraph.SelectedItems[0].Tag; var tabPage = GetTabPage(graphUri); if (tabPage != null) { var graphEditor = (GraphEditor)tabPage.Tag; if (graphEditor.RequestSave()) { if ( MessageBox.Show(string.Format("save graph before closing graph {0}", graphEditor.GraphUri), "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { graphEditor.SaveGraph(); } } tabControlGraph.TabPages.Remove(tabPage); } var form = new SingleForm { Title = "Set URI", Label = "URI" }; if (form.ShowDialog() != DialogResult.OK) { return; } var ng = new Graph(); try { UriLoader.Load(ng, new Uri(form.Content)); } catch (Exception ex) { MessageBox.Show("Invalid format. " + ex); return; } var g = new Graph(); fuseki.LoadGraph(g, graphUri); var cnt = ng.Triples.Count(g.Assert); fuseki.SaveGraph(g); MessageBox.Show(string.Format("successfully insert {0} triples", cnt)); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { var item = listViewPredicate.SelectedItems[0]; var form = new SingleForm { Title = "New Graph", Label = "URI", Content = item.Text }; if (form.ShowDialog() != DialogResult.OK) { return; } item.Text = form.Content; }
public static void LoadConfig() { if (File.Exists(DocumentRoot + @"\config.xml")) { try { var m = new XmlSerializer(config.GetType()); TextReader r = new StreamReader(DocumentRoot + @"\config.xml"); config = (Config)m.Deserialize(r); r.Close(); } catch { if ( MessageBox.Show("Warning", "config.xml is invalid. Do you recreate the config.xml?", MessageBoxButtons.OKCancel) == DialogResult.OK) { SaveConfig(); } } } else { var randomString = Config.GetRandomString(6); var form = new SingleForm { Title = "Set unique userid", Label = "userid", Content = randomString }; if (form.ShowDialog() == DialogResult.OK) { config.GlobalPrefix = string.Format("http://ah.withcat.net/{0}/", form.Content); } else { config.GlobalPrefix = string.Format("http://ah.withcat.net/{0}/", randomString); } SaveConfig(); } if (config.FusekiServer == null || config.FusekiServer == "" || config.PredicateList.Count == 0) { SaveConfig(); } }
private void insertToolStripMenuItem_Click(object sender, EventArgs e) { var form = new SingleForm { Title = "New Predicate", Label = "URL", Content = "" }; if (form.ShowDialog() != DialogResult.OK) { return; } var item = new ListViewItem(form.Content) { Checked = true }; listViewPredicate.Items.Add(item); }
/// <summary> /// make new graph /// https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/UserGuide/Triple%20Store%20Integration /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newGraphToolStripMenuItem_Click(object sender, EventArgs e) { try { var form = new SingleForm { Title = "New Graph", Label = "URI", Content = config.GlobalPrefix + Config.GetRandomString(6) }; if (form.ShowDialog() != DialogResult.OK) return; var uri = form.Content; var g = new Graph {BaseUri = new Uri(uri)}; SetNewGraphTriple(g, uri); fuseki.SaveGraph(g); UpdateListViewGraph(); } catch (Exception ex) { MessageBox.Show("error during creating new graph. " + ex); } }
private void fromURIToolStripMenuItem_Click_1(object sender, EventArgs e) { if (listViewGraph.SelectedItems.Count != 1) { MessageBox.Show("no graph is selected"); return; } var graphUri = (string) listViewGraph.SelectedItems[0].Tag; var tabPage = GetTabPage(graphUri); if (tabPage != null) { var graphEditor = (GraphEditor) tabPage.Tag; if (graphEditor.RequestSave()) { if ( MessageBox.Show(string.Format("save graph before closing graph {0}", graphEditor.GraphUri), "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { graphEditor.SaveGraph(); } } tabControlGraph.TabPages.Remove(tabPage); } var form = new SingleForm {Title = "Set URI", Label = "URI"}; if (form.ShowDialog() != DialogResult.OK) return; var ng = new Graph(); try { UriLoader.Load(ng, new Uri(form.Content)); } catch (Exception ex) { MessageBox.Show("Invalid format. " + ex); return; } var g = new Graph(); fuseki.LoadGraph(g, graphUri); var cnt = ng.Triples.Count(g.Assert); fuseki.SaveGraph(g); MessageBox.Show(string.Format("successfully insert {0} triples", cnt)); }
private void duplicateToolStripMenuItem_Click(object sender, EventArgs e) { if (listViewGraph.SelectedItems.Count != 1) { MessageBox.Show("no graph is selected"); return; } var graphUri = (string) listViewGraph.SelectedItems[0].Tag; var g = new Graph(); fuseki.LoadGraph(g, graphUri); var form = new SingleForm {Title = "Set New Graph URI", Label = "URI", Content = graphUri}; if (form.ShowDialog() != DialogResult.OK) return; var srcUri = graphUri; var srcGraphBase64 = GraphEditor.Base64Encode(srcUri); var dstUri = form.Content; var dstGraphLabel = dstUri.Split(new[] {'/', '#'}).Last(); var dstGraphBase64 = GraphEditor.Base64Encode(dstUri); var newg = new Graph {BaseUri = new Uri(dstUri)}; var nLabel = newg.CreateUriNode(UriFactory.Create("http://www.w3.org/2000/01/rdf-schema#label")); newg.Assert(new Triple(newg.CreateUriNode(UriFactory.Create(dstUri)), nLabel, newg.CreateLiteralNode(dstGraphLabel))); var cnt = 0; foreach (var triple in g.Triples) { INode news = newg.CreateUriNode(UriFactory.Create(triple.Subject.ToString().Replace(srcUri, dstUri))); INode newp = newg.CreateUriNode(UriFactory.Create(triple.Predicate.ToString().Replace(srcUri, dstUri))); INode newo = null; if (triple.Object.NodeType == NodeType.Uri) newo = newg.CreateUriNode(UriFactory.Create(triple.Object.ToString().Replace(srcUri, dstUri))); else if (triple.Object.NodeType == NodeType.Literal) newo = newg.CreateLiteralNode(triple.Object.ToString().Replace(srcUri, dstUri)); var asserted = newg.Assert(new Triple(news, newp, newo)); if (asserted) cnt++; } var srcPath = string.Format(@"{0}\{1}.txt", DocumentRoot, srcGraphBase64); var dstPath = string.Format(@"{0}\{1}.txt", DocumentRoot, dstGraphBase64); File.Copy(srcPath, dstPath); fuseki.SaveGraph(newg); UpdateListViewGraph(); MessageBox.Show(string.Format("total {0} triples cloned", cnt)); }
public static void LoadConfig() { if (File.Exists(DocumentRoot + @"\config.xml")) { try { var m = new XmlSerializer(config.GetType()); TextReader r = new StreamReader(DocumentRoot + @"\config.xml"); config = (Config) m.Deserialize(r); r.Close(); } catch { if ( MessageBox.Show("Warning", "config.xml is invalid. Do you recreate the config.xml?", MessageBoxButtons.OKCancel) == DialogResult.OK) { SaveConfig(); } } } else { var randomString = Config.GetRandomString(6); var form = new SingleForm {Title = "Set unique userid", Label = "userid", Content = randomString}; if (form.ShowDialog() == DialogResult.OK) { config.GlobalPrefix = string.Format("http://ah.withcat.net/{0}/", form.Content); } else { config.GlobalPrefix = string.Format("http://ah.withcat.net/{0}/", randomString); } SaveConfig(); } if (config.FusekiServer == null || config.FusekiServer == "" || config.PredicateList.Count == 0) { SaveConfig(); } }
private void duplicateToolStripMenuItem_Click(object sender, EventArgs e) { if (listViewGraph.SelectedItems.Count != 1) { MessageBox.Show("no graph is selected"); return; } var graphUri = (string)listViewGraph.SelectedItems[0].Tag; var g = new Graph(); fuseki.LoadGraph(g, graphUri); var form = new SingleForm { Title = "Set New Graph URI", Label = "URI", Content = graphUri }; if (form.ShowDialog() != DialogResult.OK) { return; } var srcUri = graphUri; var srcGraphBase64 = GraphEditor.Base64Encode(srcUri); var dstUri = form.Content; var dstGraphLabel = dstUri.Split(new[] { '/', '#' }).Last(); var dstGraphBase64 = GraphEditor.Base64Encode(dstUri); var newg = new Graph { BaseUri = new Uri(dstUri) }; var nLabel = newg.CreateUriNode(UriFactory.Create("http://www.w3.org/2000/01/rdf-schema#label")); newg.Assert(new Triple(newg.CreateUriNode(UriFactory.Create(dstUri)), nLabel, newg.CreateLiteralNode(dstGraphLabel))); var cnt = 0; foreach (var triple in g.Triples) { INode news = newg.CreateUriNode(UriFactory.Create(triple.Subject.ToString().Replace(srcUri, dstUri))); INode newp = newg.CreateUriNode(UriFactory.Create(triple.Predicate.ToString().Replace(srcUri, dstUri))); INode newo = null; if (triple.Object.NodeType == NodeType.Uri) { newo = newg.CreateUriNode(UriFactory.Create(triple.Object.ToString().Replace(srcUri, dstUri))); } else if (triple.Object.NodeType == NodeType.Literal) { newo = newg.CreateLiteralNode(triple.Object.ToString().Replace(srcUri, dstUri)); } var asserted = newg.Assert(new Triple(news, newp, newo)); if (asserted) { cnt++; } } var srcPath = string.Format(@"{0}\{1}.txt", DocumentRoot, srcGraphBase64); var dstPath = string.Format(@"{0}\{1}.txt", DocumentRoot, dstGraphBase64); File.Copy(srcPath, dstPath); fuseki.SaveGraph(newg); UpdateListViewGraph(); MessageBox.Show(string.Format("total {0} triples cloned", cnt)); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { var item = listViewPredicate.SelectedItems[0]; var form = new SingleForm {Title = "New Graph", Label = "URI", Content = item.Text}; if (form.ShowDialog() != DialogResult.OK) return; item.Text = form.Content; }
private void insertToolStripMenuItem_Click(object sender, EventArgs e) { var form = new SingleForm {Title = "New Predicate", Label = "URL", Content = ""}; if (form.ShowDialog() != DialogResult.OK) return; var item = new ListViewItem(form.Content) {Checked = true}; listViewPredicate.Items.Add(item); }