public FileDocumentManager(String directory) : base(new NTriplesAdaptor()) { if (!Directory.Exists(directory)) { try { Directory.CreateDirectory(directory); } catch (Exception ex) { throw new AlexandriaException("Unable to create the Directory " + directory + " for use as an Alexandria Store", ex); } } this._directory = directory; if (!this._directory.EndsWith("\\")) { this._directory += "\\"; } //Ensure relevant other directories exist foreach (String dir in RequiredDirectories) { try { if (!Directory.Exists(Path.Combine(this._directory, dir))) { Directory.CreateDirectory(Path.Combine(this._directory, dir)); } } catch (Exception ex) { throw new AlexandriaException("Unable to create the Required Directory " + dir + " for use as part of an Alexandria Store", ex); } } if (!this.HasDocument(GraphRegistryDocument)) { if (!this.CreateDocument(GraphRegistryDocument)) { throw new AlexandriaException("Unable to create the Required Graph Registry Document"); } } this._graphRegistry = new TsvGraphRegistry(this.GetDocument(GraphRegistryDocument)); }
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"); } }