public MongoDBDocumentManager(MongoConfiguration config, String db, String collection, MongoDBSchemas schema) : base(null) { this._connection = new Mongo(config); this._db = this._connection.GetDatabase(db); this._connection.Connect(); this._collection = collection; //Ensure the DB is setup correctly this._db.GetCollection(Collection); //Set up the Data Adaptor and Graph Registry this._schema = schema; switch (schema) { case MongoDBSchemas.GraphCentric: this.DataAdaptor = new MongoDBGraphCentricAdaptor(); if (!this.HasDocument(GraphRegistryDocument)) { if (!this.CreateDocument(GraphRegistryDocument)) { throw new AlexandriaException("Unable to create the Required Graph Registry Document"); } } this._registry = new MongoDBGraphCentricRegistry(this.GetDocument(GraphRegistryDocument)); break; case MongoDBSchemas.TripleCentric: this.DataAdaptor = new MongoDBTripleCentricAdaptor(this); this._registry = new MongoDBTripleCentricGraphRegistry(this); break; default: throw new ArgumentException("Unknown MongoDB Schema", "schema"); } }
public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj) { switch (targetType.FullName) { case MongoDBManager: String server = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer)); String storeID = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase)); String collectionID = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog)); String loadMode = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode)); MongoDBSchemas schema = MongoDBDocumentManager.DefaultSchema; if (loadMode != null) { switch (loadMode) { case "GraphCentric": schema = MongoDBSchemas.GraphCentric; break; case "TripleCentric": schema = MongoDBSchemas.TripleCentric; break; } } if (storeID != null) { AlexandriaMongoDBManager manager; if (server == null) { if (collectionID == null) { manager = new AlexandriaMongoDBManager(storeID, schema); } else { manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(new MongoConfiguration(), storeID, collectionID, schema)); } } else { //Have a Custom Connection String if (collectionID == null) { manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(server, storeID, schema)); } else { manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(server, storeID, collectionID, schema)); } } obj = manager; return(true); } //If we get here then the required dnr:database property was missing throw new DotNetRdfConfigurationException("Unable to load the MongoDB Manager identified by the Node '" + objNode.ToString() + "' since there was no value given for the required property dnr:database"); break; case MongoDBDataset: INode managerNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, "dnr:genericManager")); if (managerNode == null) { throw new DotNetRdfConfigurationException("Unable to load the MongoDB Dataset identified by the Node '" + objNode.ToString() + "' since there we no value for the required property dnr:genericManager"); } Object temp = ConfigurationLoader.LoadObject(g, managerNode); if (temp is AlexandriaMongoDBManager) { obj = new AlexandriaMongoDBDataset((AlexandriaMongoDBManager)temp); return(true); } else { throw new DotNetRdfConfigurationException("Unable to load the MongoDB Dataset identified by the Node '" + objNode.ToString() + "' since the value for the dnr:genericManager property pointed to an Object which could not be loaded as an object of type AlexandriaMongoDBManager"); } break; } obj = null; return(false); }
public MongoDBDocumentManager(String connectionString, String db, MongoDBSchemas schema) : this(MongoDBHelper.GetConfiguration(connectionString), db, schema) { }
public MongoDBDocumentManager(String db, MongoDBSchemas schema) : this(new MongoConfiguration(), db, schema) { }
public MongoDBDocumentManager(MongoConfiguration config, String db, MongoDBSchemas schema) : this(config, db, DefaultCollection, schema) { }
public AlexandriaMongoDBManager(String connectionString, String db, MongoDBSchemas schema) : this(new MongoDBDocumentManager(connectionString, db, schema)) { }
public AlexandriaMongoDBManager(MongoConfiguration config, String db, MongoDBSchemas schema) : this(new MongoDBDocumentManager(config, db, schema)) { }
public AlexandriaMongoDBManager(String db, MongoDBSchemas schema) : this(new MongoDBDocumentManager(db, schema)) { }