/// <summary> /// Creates a new Write to Store Handler /// </summary> /// <param name="manager">Manager to write to</param> /// <param name="defaultGraphUri">Graph URI to write Triples from the default graph to</param> /// <param name="batchSize">Batch Size</param> public WriteToStoreHandler(IGenericIOManager manager, Uri defaultGraphUri, int batchSize) { if (manager == null) { throw new ArgumentNullException("manager", "Cannot write to a null Generic IO Manager"); } if (manager.IsReadOnly) { throw new ArgumentException("manager", "Cannot write to a Read-Only Generic IO Manager"); } if (!manager.UpdateSupported) { throw new ArgumentException("manager", "Generic IO Manager must support Triple Level updates to be used with this Handler"); } if (batchSize <= 0) { throw new ArgumentException("batchSize", "Batch Size must be >= 1"); } this._manager = manager; this._defaultGraphUri = defaultGraphUri; this._batchSize = batchSize; //Make the Actions Queue one larger than the Batch Size this._actions = new List <Triple>(this._batchSize + 1); this._bnodeActions = new List <Triple>(this._batchSize + 1); this._bnodeUris = new HashSet <string>(); }
private void mnuOpenConnection_Click(object sender, EventArgs e) { this.ofdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false); if (this.ofdConnection.ShowDialog() == DialogResult.OK) { try { Graph g = new Graph(); FileLoader.Load(g, this.ofdConnection.FileName); OpenConnectionForm openConnections = new OpenConnectionForm(g); openConnections.MdiParent = this; if (openConnections.ShowDialog() == DialogResult.OK) { IGenericIOManager manager = openConnections.Connection; StoreManagerForm genManagerForm = new StoreManagerForm(manager); genManagerForm.MdiParent = this; genManagerForm.Show(); //Add to Recent Connections this.AddRecentConnection(manager); } } catch (RdfParseException) { MessageBox.Show("Unable to open a connection from the given file as it was not a valid RDF Graph or was in a format that the library does not understand", "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Unable to open the given file due to the following error:\n" + ex.Message, "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnConnect_Click(object sender, EventArgs e) { IConnectionDefinition def = this.lstStoreTypes.SelectedItem as IConnectionDefinition; if (def == null) { return; } try { this._connection = def.OpenConnection(); if (this.chkForceReadOnly.Checked) { if (this._connection is IQueryableGenericIOManager) { this._connection = new QueryableReadOnlyConnector((IQueryableGenericIOManager)this._connection); } else { this._connection = new ReadOnlyConnector(this._connection); } } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Connection to " + def.StoreName + " Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private INode AddConnection(IGraph config, IGenericIOManager manager, String persistentFile) { if (config == null) { return(null); } ConfigurationSerializationContext context = new ConfigurationSerializationContext(config); if (manager is IConfigurationSerializable) { INode objNode = context.Graph.CreateUriNode(new Uri("dotnetrdf:storemanager:" + DateTime.Now.ToString("yyyyMMddhhmmss"))); context.NextSubject = objNode; ((IConfigurationSerializable)manager).SerializeConfiguration(context); if (persistentFile != null) { try { //Persist the graph to disk CompressingTurtleWriter ttlwriter = new CompressingTurtleWriter(); ttlwriter.Save(config, persistentFile); } catch (Exception ex) { MessageBox.Show("Unable to persist a Connections File to disk", "Internal Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } return(objNode); } return(null); }
public DotNetRdfGenericRepositoryConnection(DotNetRdfGenericRepository repo, IGenericIOManager manager, DotNetRdfValueFactory factory) : base(repo, factory) { this._repo = repo; this._manager = manager; this._factory = factory; }
public void CopyGraph(String graphUri, IGenericIOManager target) { if (target == null) { return; } Uri source = graphUri.Equals("Default Graph") ? null : new Uri(graphUri); if (ReferenceEquals(this._manager, target)) { CopyMoveRenameGraphForm rename = new CopyMoveRenameGraphForm("Copy"); if (rename.ShowDialog() == DialogResult.OK) { CopyMoveTask task = new CopyMoveTask(this._manager, target, source, rename.Uri, ReferenceEquals(this._manager, target)); this.AddTask(task, this.CopyMoveRenameCallback); } } else { CopyMoveTask task = new CopyMoveTask(this._manager, target, source, source, true); this.AddTask(task, this.CopyMoveRenameCallback); } }
/// <summary> /// Creates a new instance which will represent a write-only view of the Graph with the given URI /// </summary> /// <param name="graphUri">URI of the Graph to write to</param> /// <param name="manager">Generic Store Manager</param> public WriteOnlyStoreGraph(Uri graphUri, IGenericIOManager manager) : base() { this.BaseUri = graphUri; this._manager = manager; this.Intialise(); }
public PreviewGraphTask(IGenericIOManager manager, String graphUri, int previewSize) : base("Preview Graph") { this._manager = manager; this._graphUri = graphUri; this._previewSize = previewSize; }
public void AddFavouriteConnection(IGenericIOManager manager) { INode objNode = this.AddConnection(this._faveConnections, manager, this._faveConnectionsFile); if (objNode != null) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = manager.ToString(); item.Tag = new QuickConnect(this._faveConnections, objNode); item.Click += new EventHandler(QuickConnectClick); ToolStripMenuItem remove = new ToolStripMenuItem(); remove.Text = "Remove Connection from this List"; remove.Tag = new QuickRemove(this.mnuFavouriteConnections, this._faveConnections, objNode, this._faveConnectionsFile); remove.Click += new EventHandler(QuickRemoveClick); item.DropDownItems.Add(remove); ToolStripMenuItem connect = new ToolStripMenuItem(); connect.Text = "Open Connection"; connect.Tag = new QuickConnect(this._faveConnections, objNode); connect.Click += new EventHandler(QuickConnectClick); item.DropDownItems.Add(connect); this.mnuFavouriteConnections.DropDownItems.Add(item); } }
private void btnOpen_Click(object sender, EventArgs e) { if (this.lstConnections.SelectedIndex != -1) { int i = this.lstConnections.SelectedIndex; INode objNode = this._connectionNodes[i]; try { Object temp = ConfigurationLoader.LoadObject(this._g, objNode); if (temp is IGenericIOManager) { this._connection = (IGenericIOManager)temp; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Unable to open the selected connection as it was loaded by the Configuration Loader as an object of type '" + temp.GetType().ToString() + "' which does not implement the IGenericIOManager interface", "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Unable to open the selected connection due to the following error:\n" + ex.Message, "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public CopyMoveTask(IGenericIOManager source, IGenericIOManager target, Uri sourceUri, Uri targetUri, bool forceCopy) : base(GetName(source, target, sourceUri, targetUri, forceCopy)) { this._source = source; this._target = target; this._sourceUri = sourceUri; this._targetUri = targetUri; }
public void shutDown() { if (this._manager != null) { this._manager.Dispose(); } this._manager = null; }
/// <summary> /// Creates a new instance of a Store Graph which will contain the contents of the Graph with the given Uri /// </summary> /// <param name="graphUri">Uri of the Graph to retrieve</param> /// <param name="manager">Generic Store Manager</param> public StoreGraph(Uri graphUri, IGenericIOManager manager) : base() { this.BaseUri = graphUri; this._manager = manager; this._manager.LoadGraph(this, graphUri); this.Intialise(); }
public ExportTask(IGenericIOManager manager, String file) : base("Export Store") { if (file == null) { throw new ArgumentNullException("file", "Cannot Export the Store to a null File"); } this._file = file; this._manager = manager; }
public PersistentGraphCollection(IGenericIOManager manager) { if (manager == null) { throw new ArgumentNullException("manager", "Must use a non-null IGenericIOManager instance with a PersistentGraphCollection"); } this._manager = manager; this.TripleAddedHandler = new TripleEventHandler(this.OnTripleAsserted); this.TripleRemovedHandler = new TripleEventHandler(this.OnTripleRetracted); }
private void FillConnectionList(IGraph config, ListBox lbox) { SparqlParameterizedString query = new SparqlParameterizedString(); query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS)); query.Namespaces.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace)); query.CommandText = "SELECT * WHERE { ?obj a " + ConfigurationLoader.ClassGenericManager + " . OPTIONAL { ?obj rdfs:label ?label } }"; query.CommandText += " ORDER BY DESC(?obj)"; SparqlResultSet results = config.ExecuteQuery(query) as SparqlResultSet; if (results != null) { foreach (SparqlResult r in results) { QuickConnect connect; if (r.HasValue("label") && r["label"] != null) { connect = new QuickConnect(config, r["obj"], r["label"].ToString()); } else { connect = new QuickConnect(config, r["obj"]); } lbox.Items.Add(connect); } } lbox.DoubleClick += new EventHandler((sender, args) => { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect != null) { try { IGenericIOManager manager = connect.GetConnection(); StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } catch (Exception ex) { MessageBox.Show("Error Opening Connection " + connect.ToString() + ":\n" + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); }
public BaseImportTask(String name, IGenericIOManager manager, Uri targetGraph, int batchSize) : base(name) { this._manager = manager; this._targetUri = targetGraph; this._batchSize = batchSize; if (this._batchSize <= 0) { this._batchSize = 100; } this._progress = new ImportProgressHandler(this._counter); this._progress.Progress += new ImportProgressEventHandler(_progress_Progress); }
private void TestWriteToStoreDatasetsHandler(IGenericIOManager manager) { NodeFactory factory = new NodeFactory(); INode a = factory.CreateUriNode(new Uri("http://example.org/a")); INode b = factory.CreateUriNode(new Uri("http://example.org/b")); INode c = factory.CreateUriNode(new Uri("http://example.org/c")); INode d = factory.CreateUriNode(new Uri("http://example.org/d")); Uri graphB = new Uri("http://example.org/graphs/b"); Uri graphD = new Uri("http://example.org/graphs/d"); //Try to ensure that the target Graphs do not exist if (manager.DeleteSupported) { manager.DeleteGraph(TestGraphUri); manager.DeleteGraph(graphB); manager.DeleteGraph(graphD); } else { Graph g = new Graph(); g.BaseUri = TestGraphUri; manager.SaveGraph(g); g.BaseUri = graphB; manager.SaveGraph(g); g.BaseUri = graphD; manager.SaveGraph(g); } //Do the parsing and thus the loading WriteToStoreHandler handler = new WriteToStoreHandler(manager, TestGraphUri); NQuadsParser parser = new NQuadsParser(); parser.Load(handler, new StreamParams("writetostore.nq")); //Load the expected Graphs Graph def = new Graph(); manager.LoadGraph(def, TestGraphUri); Graph gB = new Graph(); manager.LoadGraph(gB, graphB); Graph gD = new Graph(); manager.LoadGraph(gD, graphD); Assert.AreEqual(2, def.Triples.Count, "Should be two triples in the default Graph"); Assert.IsTrue(def.ContainsTriple(new Triple(a, a, a)), "Default Graph should have the a triple"); Assert.AreEqual(1, gB.Triples.Count, "Should be one triple in the b Graph"); Assert.IsTrue(gB.ContainsTriple(new Triple(b, b, b)), "b Graph should have the b triple"); Assert.IsTrue(def.ContainsTriple(new Triple(c, c, c)), "Default Graph should have the c triple"); Assert.AreEqual(1, gD.Triples.Count, "Should be one triple in the d Graph"); Assert.IsTrue(gD.ContainsTriple(new Triple(d, d, d)), "d Graph should have the d triple"); }
private void mnuAddFavourite_Click(object sender, EventArgs e) { if (this.ActiveMdiChild != null) { if (this.ActiveMdiChild is StoreManagerForm) { IGenericIOManager manager = ((StoreManagerForm)this.ActiveMdiChild).Manager; this.AddFavouriteConnection(manager); } else { MessageBox.Show("Only Generic Store Connections may be added to your Favourites", "Add To Favourite Connections Failed", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void mnuNewConnection_Click(object sender, EventArgs e) { NewConnectionForm newConn = new NewConnectionForm(); newConn.StartPosition = FormStartPosition.CenterParent; if (newConn.ShowDialog() == DialogResult.OK) { IGenericIOManager manager = newConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = this; storeManager.Show(); //Add to Recent Connections this.AddRecentConnection(manager); } }
/// <summary> /// Creates a new Write to Store Handler /// </summary> /// <param name="manager">Manager to write to</param> /// <param name="defaultGraphUri">Graph URI to write Triples from the default graph to</param> /// <param name="batchSize">Batch Size</param> public WriteToStoreHandler(IGenericIOManager manager, Uri defaultGraphUri, int batchSize) { if (manager == null) throw new ArgumentNullException("manager", "Cannot write to a null Generic IO Manager"); if (manager.IsReadOnly) throw new ArgumentException("manager", "Cannot write to a Read-Only Generic IO Manager"); if (!manager.UpdateSupported) throw new ArgumentException("manager", "Generic IO Manager must support Triple Level updates to be used with this Handler"); if (batchSize <= 0) throw new ArgumentException("batchSize", "Batch Size must be >= 1"); this._manager = manager; this._defaultGraphUri = defaultGraphUri; this._batchSize = batchSize; //Make the Actions Queue one larger than the Batch Size this._actions = new List<Triple>(this._batchSize + 1); this._bnodeActions = new List<Triple>(this._batchSize + 1); this._bnodeUris = new HashSet<string>(); }
private void btnNewConnection_Click(object sender, EventArgs e) { NewConnectionForm newConn = new NewConnectionForm(); if (newConn.ShowDialog() == DialogResult.OK) { IGenericIOManager manager = newConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } }
public void MoveGraph(String graphUri, IGenericIOManager target) { if (target == null) { return; } if (ReferenceEquals(this._manager, target)) { this.RenameGraph(graphUri); } else { Uri source = graphUri.Equals("Default Graph") ? null : new Uri(graphUri); CopyMoveTask task = new CopyMoveTask(this._manager, target, source, source, false); this.AddTask <TaskResult>(task, this.CopyMoveRenameCallback); } }
public StoreManagerForm(IGenericIOManager manager) { InitializeComponent(); //Configure Form this._manager = manager; this.Text = this._manager.ToString(); //Configure Tasks List this.lvwTasks.ListViewItemSorter = new SortTasksByID(); //Configure Graphs List this.lvwGraphs.ItemDrag += new ItemDragEventHandler(lvwGraphs_ItemDrag); this.lvwGraphs.DragEnter += new DragEventHandler(lvwGraphs_DragEnter); this.lvwGraphs.DragDrop += new DragEventHandler(lvwGraphs_DragDrop); this._copyGraphHandler = this.CopyGraphClick; this._moveGraphHandler = this.MoveGraphClick; }
public void AddRecentConnection(IGenericIOManager manager) { INode objNode = this.AddConnection(this._recentConnections, manager, this._recentConnectionsFile); if (objNode != null) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = manager.ToString(); item.Tag = new QuickConnect(this._recentConnections, objNode); item.Click += new EventHandler(QuickConnectClick); this.mnuRecentConnections.DropDownItems.Add(item); } //Check the number of Recent Connections and delete the Oldest if more than 9 List <INode> conns = this._recentConnections.GetTriplesWithPredicateObject(this._recentConnections.CreateUriNode(new Uri(RdfSpecsHelper.RdfType)), this._recentConnections.CreateUriNode(new Uri(ConfigurationLoader.ConfigurationNamespace + ConfigurationLoader.ClassGenericManager.Substring(ConfigurationLoader.ClassGenericManager.IndexOf(':') + 1)))).Select(t => t.Subject).ToList(); if (conns.Count > MaxRecentConnections) { conns.Sort(); conns.Reverse(); conns.RemoveRange(0, MaxRecentConnections); foreach (INode obj in conns) { this._recentConnections.Retract(this._recentConnections.GetTriplesWithSubject(obj)); this.RemoveFromConnectionsMenu(this.mnuRecentConnections, obj); } try { //Persist the graph to disk CompressingTurtleWriter ttlwriter = new CompressingTurtleWriter(); ttlwriter.Save(this._recentConnections, this._recentConnectionsFile); } catch (Exception ex) { MessageBox.Show("Unable to persist a Connections File to disk", "Internal Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void QuickConnectClick(object sender, EventArgs e) { if (sender == null) { return; } Object tag = null; if (sender is Control) { tag = ((Control)sender).Tag; } else if (sender is ToolStripItem) { tag = ((ToolStripItem)sender).Tag; } else if (sender is Menu) { tag = ((Menu)sender).Tag; } if (tag != null) { if (tag is QuickConnect) { QuickConnect qc = (QuickConnect)tag; try { IGenericIOManager manager = qc.GetConnection(); StoreManagerForm genManager = new StoreManagerForm(manager); genManager.MdiParent = this; genManager.Show(); } catch (Exception ex) { MessageBox.Show("Unable to load the Connection due to an error: " + ex.Message, "Quick Connect Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void TestWriteToStoreHandler(IGenericIOManager manager) { //First ensure that our test file exists EnsureTestData(); //Try to ensure that the target Graph does not exist if (manager.DeleteSupported) { manager.DeleteGraph(TestGraphUri); } else { Graph g = new Graph(); g.BaseUri = TestGraphUri; manager.SaveGraph(g); } Graph temp = new Graph(); try { manager.LoadGraph(temp, TestGraphUri); Assert.IsTrue(temp.IsEmpty, "Unable to ensure that Target Graph in Store is empty prior to running Test"); } catch { //An Error Loading the Graph is OK } WriteToStoreHandler handler = new WriteToStoreHandler(manager, TestGraphUri, 100); TurtleParser parser = new TurtleParser(); parser.Load(handler, "temp.ttl"); manager.LoadGraph(temp, TestGraphUri); Assert.IsFalse(temp.IsEmpty, "Graph should not be empty"); Graph orig = new Graph(); orig.LoadFromFile("temp.ttl"); Assert.AreEqual(orig, temp, "Graphs should be equal"); }
private static String GetName(IGenericIOManager source, IGenericIOManager target, Uri sourceUri, Uri targetUri, bool forceCopy) { if (ReferenceEquals(source, target) && !forceCopy) { //Source and Target Store are same so must be a Rename return("Move"); } else { //Different Source and Target store so a Copy/Move if (forceCopy) { //Source and Target URI are equal so a Copy return("Copy"); } else { //Otherwise is a Move return("Move"); } } }
/// <summary> /// Creates a new set of Generic IO Parameters using the given <see cref="IGenericIOManager">IGenericIOManager</see> /// </summary> /// <param name="manager">IO Manager for the underlying Store</param> /// <param name="threads">Number of Threads to use for operations which can be multi-threaded</param> public GenericIOParams(IGenericIOManager manager, int threads) { this._manager = manager; this._threads = 1; }
/// <summary> /// Creates a new set of Generic IO Parameters using the given <see cref="IGenericIOManager">IGenericIOManager</see> /// </summary> /// <param name="manager">IO Manager for the underlying Store</param> public GenericIOParams(IGenericIOManager manager) : this(manager, 1) { }
public void shutDown() { if (this._manager != null) this._manager.Dispose(); this._manager = null; }
private void btnConnectVirtuoso_Click(object sender, EventArgs e) { if (this.txtVirtuosoServer.Text.Equals(String.Empty)) { this.ParameterRequired("Server", "Virtuoso"); } else if (this.txtVirtuosoDatabase.Text.Equals(String.Empty)) { this.ParameterRequired("Database", "Virtuoso"); } else if (this.txtVirtuosoUsername.Equals(String.Empty)) { this.ParameterRequired("Username", "Virtuoso"); } else if (this.txtVirtuosoPassword.Text.Equals(String.Empty)) { this.ParameterRequired("Password", "Virtuoso"); } else { int port = 1111; if (Int32.TryParse(this.txtVirtuosoPort.Text, out port)) { this._manager = new VirtuosoManager(this.txtVirtuosoServer.Text, port, this.txtVirtuosoDatabase.Text, this.txtVirtuosoUsername.Text, this.txtVirtuosoPassword.Text); } else { this._manager = new VirtuosoManager(this.txtVirtuosoServer.Text, port, this.txtVirtuosoDatabase.Text, this.txtVirtuosoUsername.Text, this.txtVirtuosoPassword.Text); } this.DialogResult = DialogResult.OK; this.Close(); } }
/// <summary> /// Creates a new Store Graph Persistence Wrapper /// </summary> /// <param name="manager">Generic IO Manager</param> /// <param name="g">Graph to wrap</param> /// <param name="graphUri">Graph URI (the URI the Graph will be persisted as)</param> /// <param name="writeOnly">Whether to operate in write-only mode</param> /// <remarks> /// <para> /// <strong>Note:</strong> In order to operate in write-only mode the <see cref="IGenericIOManager">IGenericIOManager</see> must support triple level updates indicated by it returning true to its <see cref="IGenericIOManager.UpdateSupported">UpdateSupported</see> property and the Graph to be wrapped must be an empty Graph /// </para> /// </remarks> public StoreGraphPersistenceWrapper(IGenericIOManager manager, IGraph g, Uri graphUri, bool writeOnly) : base(g, writeOnly) { if (manager == null) throw new ArgumentNullException("manager","Cannot persist to a null Generic IO Manager"); if (manager.IsReadOnly) throw new ArgumentException("Cannot persist to a read-only Generic IO Manager", "manager"); if (writeOnly && !manager.UpdateSupported) throw new ArgumentException("If writeOnly is set to true then the Generic IO Manager must support triple level updates", "writeOnly"); if (writeOnly && !g.IsEmpty) throw new ArgumentException("If writeOnly is set to true then the input graph must be empty", "writeOnly"); this._manager = manager; this.BaseUri = graphUri; }
/// <summary> /// Creates a new Store Graph Persistence Wrapper around a new empty Graph /// </summary> /// <param name="manager">Generic IO Manager</param> /// <param name="graphUri">Graph URI (the URI the Graph will be persisted as)</param> public StoreGraphPersistenceWrapper(IGenericIOManager manager, Uri graphUri) : this(manager, graphUri, false) { }
/// <summary> /// Creates a new Store Graph Persistence Wrapper /// </summary> /// <param name="manager">Generic IO Manager</param> /// <param name="g">Graph to wrap</param> public StoreGraphPersistenceWrapper(IGenericIOManager manager, IGraph g) : this(manager, g, g.BaseUri, false) { }
public ConnectionInfo(IGenericIOManager manager) { this._manager = manager; }
/// <summary> /// Creates a new Read-Only connection which is a read-only wrapper around another store /// </summary> /// <param name="manager">Manager for the Store you want to wrap as read-only</param> public ReadOnlyConnector(IGenericIOManager manager) { this._manager = manager; }
/// <summary> /// Creates a new Write to Store Handler /// </summary> /// <param name="manager">Manager to write to</param> /// <param name="batchSize">Batch Size</param> public WriteToStoreHandler(IGenericIOManager manager, int batchSize) : this(manager, null, batchSize) { }
public DotNetRdfGenericRepository(IGenericIOManager manager) { this._manager = manager; }
public ImportFileTask(IGenericIOManager manager, String file, Uri targetUri, int batchSize) : base("Import File", manager, targetUri, batchSize) { this._file = file; }
public ImportUriTask(IGenericIOManager manager, Uri u, Uri targetUri, int batchSize) : base("Import URI", manager, targetUri, batchSize) { this._u = u; }
/// <summary> /// Tries to load a Generic IO Manager based on information from the Configuration Graph /// </summary> /// <param name="g">Configuration Graph</param> /// <param name="objNode">Object Node</param> /// <param name="targetType">Target Type</param> /// <param name="obj">Output Object</param> /// <returns></returns> public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj) { IGenericIOManager manager = null; obj = null; String server, user, pwd, store; bool isAsync; Object temp; INode storeObj; //Create the URI Nodes we're going to use to search for things INode propServer = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer), propDb = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase), propStore = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyStore), propAsync = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyAsync); switch (targetType.FullName) { #if !NO_SYNC_HTTP case AllegroGraph: //Get the Server, Catalog and Store server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } String catalog = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog)); store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore); if (store == null) { return(false); } //Get User Credentials ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); if (user != null && pwd != null) { manager = new AllegroGraphConnector(server, catalog, store, user, pwd); } else { manager = new AllegroGraphConnector(server, catalog, store); } break; #endif case DatasetFile: //Get the Filename and whether the loading should be done asynchronously String file = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyFromFile)); if (file == null) { return(false); } file = ConfigurationLoader.ResolvePath(file); isAsync = ConfigurationLoader.GetConfigurationBoolean(g, objNode, propAsync, false); manager = new DatasetFileManager(file, isAsync); break; #if !NO_SYNC_HTTP case Dydra: //Get the Account Name and Store String account = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog)); if (account == null) { return(false); } store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore); if (store == null) { return(false); } //Get User Credentials ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); if (user != null) { manager = new DydraConnector(account, store, user); } else { manager = new DydraConnector(account, store); } break; case FourStore: //Get the Server and whether Updates are enabled server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } bool enableUpdates = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEnableUpdates), true); manager = new FourStoreConnector(server, enableUpdates); break; case Fuseki: //Get the Server URI server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } manager = new FusekiConnector(server); break; #endif case InMemory: //Get the Dataset/Store INode datasetObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingDataset)); if (datasetObj != null) { temp = ConfigurationLoader.LoadObject(g, datasetObj); if (temp is ISparqlDataset) { manager = new InMemoryManager((ISparqlDataset)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the In-Memory Manager identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingDataset property points to an Object that cannot be loaded as an object which implements the ISparqlDataset interface"); } } else { //If no dnr:usingDataset try dnr:usingStore instead storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingStore)); if (storeObj != null) { temp = ConfigurationLoader.LoadObject(g, storeObj); if (temp is IInMemoryQueryableStore) { manager = new InMemoryManager((IInMemoryQueryableStore)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the In-Memory Manager identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingStore property points to an Object that cannot be loaded as an object which implements the IInMemoryQueryableStore interface"); } } else { //If no dnr:usingStore either then create a new empty store manager = new InMemoryManager(); } } break; #if !NO_SYNC_HTTP case Joseki: //Get the Query and Update URIs server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } String queryService = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryPath)); if (queryService == null) { return(false); } String updateService = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUpdatePath)); if (updateService == null) { manager = new JosekiConnector(server, queryService); } else { manager = new JosekiConnector(server, queryService, updateService); } break; #endif case ReadOnly: //Get the actual Manager we are wrapping storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager)); temp = ConfigurationLoader.LoadObject(g, storeObj); if (temp is IGenericIOManager) { manager = new ReadOnlyConnector((IGenericIOManager)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the Read-Only Connector identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:genericManager property points to an Object which cannot be loaded as an object which implements the required IGenericIOManager interface"); } break; case ReadOnlyQueryable: //Get the actual Manager we are wrapping storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager)); temp = ConfigurationLoader.LoadObject(g, storeObj); if (temp is IQueryableGenericIOManager) { manager = new QueryableReadOnlyConnector((IQueryableGenericIOManager)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the Queryable Read-Only Connector identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:genericManager property points to an Object which cannot be loaded as an object which implements the required IQueryableGenericIOManager interface"); } break; #if !NO_SYNC_HTTP case Sesame: case SesameV5: case SesameV6: //Get the Server and Store ID server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore); if (store == null) { return(false); } ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); if (user != null && pwd != null) { manager = (IGenericIOManager)Activator.CreateInstance(targetType, new Object[] { server, store, user, pwd }); } else { manager = (IGenericIOManager)Activator.CreateInstance(targetType, new Object[] { server, store }); } break; case Sparql: //Get the Endpoint URI or the Endpoint server = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEndpointUri)); //What's the load mode? String loadModeRaw = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode)); SparqlConnectorLoadMethod loadMode = SparqlConnectorLoadMethod.Construct; if (loadModeRaw != null) { try { #if SILVERLIGHT loadMode = (SparqlConnectorLoadMethod)Enum.Parse(typeof(SparqlConnectorLoadMethod), loadModeRaw, false); #else loadMode = (SparqlConnectorLoadMethod)Enum.Parse(typeof(SparqlConnectorLoadMethod), loadModeRaw); #endif } catch { throw new DotNetRdfConfigurationException("Unable to load the SparqlConnector identified by the Node '" + objNode.ToString() + "' as the value given for the property dnr:loadMode is not valid"); } } if (server == null) { INode endpointObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEndpoint)); if (endpointObj == null) { return(false); } temp = ConfigurationLoader.LoadObject(g, endpointObj); if (temp is SparqlRemoteEndpoint) { manager = new SparqlConnector((SparqlRemoteEndpoint)temp, loadMode); } else { throw new DotNetRdfConfigurationException("Unable to load the SparqlConnector identified by the Node '" + objNode.ToString() + "' as the value given for the property dnr:endpoint points to an Object which cannot be loaded as an object which is of the type SparqlRemoteEndpoint"); } } else { //Are there any Named/Default Graph URIs IEnumerable <Uri> defGraphs = from def in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultGraphUri)) where def.NodeType == NodeType.Uri select((IUriNode)def).Uri; IEnumerable <Uri> namedGraphs = from named in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyNamedGraphUri)) where named.NodeType == NodeType.Uri select((IUriNode)named).Uri; if (defGraphs.Any() || namedGraphs.Any()) { manager = new SparqlConnector(new SparqlRemoteEndpoint(UriFactory.Create(server), defGraphs, namedGraphs), loadMode); } else { manager = new SparqlConnector(UriFactory.Create(server), loadMode); } } break; case SparqlHttpProtocol: //Get the Service URI server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } manager = new SparqlHttpProtocolConnector(UriFactory.Create(server)); break; case Stardog: //Get the Server and Store server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { return(false); } store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore); if (store == null) { return(false); } //Get User Credentials ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); //Get Reasoning Mode StardogReasoningMode reasoning = StardogReasoningMode.None; String mode = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode)); if (mode != null) { try { reasoning = (StardogReasoningMode)Enum.Parse(typeof(StardogReasoningMode), mode); } catch { reasoning = StardogReasoningMode.None; } } if (user != null && pwd != null) { manager = new StardogConnector(server, store, reasoning, user, pwd); } else { manager = new StardogConnector(server, store, reasoning); } break; case Talis: //Get the Store Name and User credentials store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore); if (store == null) { return(false); } ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); if (user != null && pwd != null) { manager = new TalisPlatformConnector(store, user, pwd); } else { manager = new TalisPlatformConnector(store); } break; #endif } #if !NO_PROXY //Check whether this is a proxyable manager and if we need to load proxy settings if (manager is BaseHttpConnector) { INode proxyNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyProxy)); if (proxyNode != null) { temp = ConfigurationLoader.LoadObject(g, proxyNode); if (temp is WebProxy) { ((BaseHttpConnector)manager).Proxy = (WebProxy)temp; } else { throw new DotNetRdfConfigurationException("Unable to load Generic Manager identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:proxy property pointed to an Object which could not be loaded as an object of the required type WebProxy"); } } } #endif obj = manager; return(manager != null); }
/// <summary> /// Creates a new Store Graph Persistence Wrapper /// </summary> /// <param name="manager">Generic IO Manager</param> /// <param name="g">Graph to wrap</param> /// <param name="writeOnly">Whether to operate in write-only mode</param> /// <remarks> /// <para> /// <strong>Note:</strong> In order to operate in write-only mode the <see cref="IGenericIOManager">IGenericIOManager</see> must support triple level updates indicated by it returning true to its <see cref="IGenericIOManager.UpdateSupported">UpdateSupported</see> property and the Graph to be wrapped must be an empty Graph /// </para> /// </remarks> public StoreGraphPersistenceWrapper(IGenericIOManager manager, IGraph g, bool writeOnly) : this(manager, g, g.BaseUri, writeOnly) { }
public ListGraphsTask(IGenericIOManager manager) : base("List Graphs") { this._manager = manager; }
/// <summary> /// Creates a new Store Graph Persistence Wrapper around a new empty Graph /// </summary> /// <param name="manager">Generic IO Manager</param> /// <param name="graphUri">Graph URI (the URI the Graph will be persisted as)</param> /// <param name="writeOnly">Whether to operate in write-only mode</param> /// <remarks> /// <para> /// <strong>Note:</strong> In order to operate in write-only mode the <see cref="IGenericIOManager">IGenericIOManager</see> must support triple level updates indicated by it returning true to its <see cref="IGenericIOManager.UpdateSupported">UpdateSupported</see> property /// </para> /// <para> /// When not operating in write-only mode the existing Graph will be loaded from the underlying store /// </para> /// </remarks> public StoreGraphPersistenceWrapper(IGenericIOManager manager, Uri graphUri, bool writeOnly) : base(writeOnly) { if (manager == null) throw new ArgumentNullException("manager", "Cannot persist to a null Generic IO Manager"); if (manager.IsReadOnly) throw new ArgumentException("Cannot persist to a read-only Generic IO Manager", "manager"); if (writeOnly && !manager.UpdateSupported) throw new ArgumentException("If writeOnly is set to true then the Generic IO Manager must support triple level updates", "writeOnly"); this._manager = manager; this.BaseUri = graphUri; if (!writeOnly) { //Load in the existing data this._manager.LoadGraph(this._g, graphUri); } }
private void btnDydraConnect_Click(object sender, EventArgs e) { if (this.txtDydraAccount.Text.Equals(String.Empty)) { this.ParameterRequired("Account Name", "Dydra"); } else if (this.txtDydraRepository.Text.Equals(String.Empty)) { this.ParameterRequired("Repository", "Dydra"); } else { if (this.txtDydraApiKey.Text.Equals(String.Empty)) { this._manager = new DydraConnector(this.txtDydraAccount.Text, this.txtDydraRepository.Text); } else { this._manager = new DydraConnector(this.txtDydraAccount.Text, this.txtDydraRepository.Text, this.txtDydraApiKey.Text); } this.DialogResult = DialogResult.OK; this.Close(); } }
private void btnConnectDatasetFile_Click(object sender, EventArgs e) { if (this.txtDatasetFile.Equals(String.Empty)) { this.ParameterRequired("File", "RDF Dataset File"); } else { try { this._manager = new DatasetFileManager(this.txtDatasetFile.Text, true); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show("Unable to connect to the Dataset File due to the following error:\n" + ex.Message, "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnConnect4Store_Click(object sender, EventArgs e) { if (this.txt4StoreServer.Text.Equals(String.Empty)) { this.ParameterRequired("Server URI", "4store"); } else { this._manager = new FourStoreConnector(this.txt4StoreServer.Text, this.chk4storeUpdates.Checked); this.DialogResult = DialogResult.OK; this.Close(); } }
/// <summary> /// Creates a new Write to Store Handler /// </summary> /// <param name="manager">Manager to write to</param> public WriteToStoreHandler(IGenericIOManager manager) : this(manager, null, DefaultBatchSize) { }
private void btnConnectSparql_Click(object sender, EventArgs e) { if (this.txtSparqlEndpoint.Equals(String.Empty)) { this.ParameterRequired("SPARQL Endpoint", "SPARQL Endpoint"); } else { SparqlConnectorLoadMethod mode; if (this.radSparqlConstruct.Checked) { mode = SparqlConnectorLoadMethod.Construct; } else { mode = SparqlConnectorLoadMethod.Describe; } try { this._manager = new SparqlConnector(new Uri(this.txtSparqlEndpoint.Text), mode); this.DialogResult = DialogResult.OK; this.Close(); } catch (UriFormatException) { this.UriParameterInvalid("SPARQL Endpoint", "SPARQL Endpoint"); } } }
/// <summary> /// Creates a new Write to Store Handler /// </summary> /// <param name="manager">Manager to write to</param> /// <param name="defaultGraphUri">Graph URI to write Triples from the default graph to</param> public WriteToStoreHandler(IGenericIOManager manager, Uri defaultGraphUri) : this(manager, defaultGraphUri, DefaultBatchSize) { }
private void btnSparqlHttpConnect_Click(object sender, EventArgs e) { if (this.txtSparqlHttpServer.Text.Equals(String.Empty)) { this.ParameterRequired("Protocol Server", "SPARQL Uniform HTTP Protocol"); } else { try { this._manager = new SparqlHttpProtocolConnector(new Uri(this.txtSparqlHttpServer.Text)); this.DialogResult = DialogResult.OK; this.Close(); } catch (UriFormatException) { this.UriParameterInvalid("Protocol Server", "SPARQL Uniform HTTP Protocol"); } } }
public UpdateTask(IGenericIOManager manager, String update) : base("SPARQL Update") { this._manager = manager; this._update = update; }
private void btnConnectFuseki_Click(object sender, EventArgs e) { if (this.txtFusekiUri.Text.Equals(String.Empty)) { this.ParameterRequired("Fuseki Server URI", "Fuseki"); } else { try { this._manager = new FusekiConnector(this.txtFusekiUri.Text); this.DialogResult = DialogResult.OK; this.Close(); } catch (ArgumentException argEx) { this.ArgumentInvalid("Fuseki Server URI", "Fuseki", argEx); } } }
/// <summary> /// Creates a new instance of the Generic Writer which connects to an arbitrary Store using the given Generic Manager /// </summary> /// <param name="manager">Manager for the underlying Store</param> public GenericWriter(IGenericIOManager manager) { this._manager = manager; }
private void btnConnectInMemory_Click(object sender, EventArgs e) { this._manager = new InMemoryManager(); this.DialogResult = DialogResult.OK; this.Close(); }
private void btnConnectStardog_Click(object sender, EventArgs e) { if (this.txtStardogServer.Text.Equals(String.Empty)) { this.ParameterRequired("Server URI", "Stardog"); } else if (this.txtStardogStore.Equals(String.Empty)) { this.ParameterRequired("Store ID", "Stardog"); } else { if (!this.txtStardogUsername.Text.Equals(String.Empty) && !this.txtStardogPassword.Equals(String.Empty)) { this._manager = new StardogConnector(this.txtStardogServer.Text, this.txtStardogStore.Text, this.txtStardogUsername.Text, this.txtStardogPassword.Text); } else { this._manager = new StardogConnector(this.txtStardogServer.Text, this.txtStardogStore.Text); } this.DialogResult = DialogResult.OK; this.Close(); } }