public (List <Vertex>, List <Edge>) LoadKG(string dsName) { if (string.IsNullOrWhiteSpace(dsName)) { log.Here().Warning("The datastore: " + dsName + " doesn't exist."); return(null, null); } string kgPath = this.rootPath + Path.DirectorySeparatorChar + dsName + Path.DirectorySeparatorChar + "KG" + Path.DirectorySeparatorChar; if (string.IsNullOrWhiteSpace(kgPath) || !Directory.Exists(kgPath)) { log.Here().Warning("The path of KGFilePath: " + kgPath + " doesn't exist."); return(null, null); } log.Here().Information("KGFilePath: " + kgPath); KGDataImporter importer = new KGDataImporter(kgPath); List <Vertex> vList = importer.ParseKGVertexes(); List <Edge> eList = importer.ParseKGEdges(); log.Here().Information("KG data has been parsed from Files."); return(vList, eList); }
public static void ImportKG(string rootPath) { KGDataImporter importer = new KGDataImporter(rootPath); writer.CreateKGCollections(importer.ParseKGVertexes(), importer.ParseKGEdges()); Console.WriteLine("Imported KG materials to MongoDB!"); }
private void ImportKG(string kgPath, string dbName) { KGDataImporter importer = new KGDataImporter(kgPath); writer.CreateKGCollections(dbName, importer.ParseKGVertexes(), importer.ParseKGEdges(), false); Console.WriteLine("Imported KG materials to MongoDB!"); }
private KGDataAccessor(IConfiguration config) { log = Log.Logger.ForContext <KGDataAccessor>(); string persistanceType = config.GetSection("PersistanceType").Value; if (persistanceType == "File") { FilePathConfig filePaths = config.GetSection("FileDataPath").Get <FilePathConfig>(); string kgPath = filePaths.KGFilePath; log.Here().Information("KGFilePath: " + kgPath); KGDataImporter importer = new KGDataImporter(kgPath); this.vList = importer.ParseKGVertexes(); this.eList = importer.ParseKGEdges(); log.Here().Information("KG data has been parsed from Files."); string vcPath = filePaths.VCFilePath; log.Here().Information("VCFilePath: " + vcPath); VisuliaztionImporter vImporter = new VisuliaztionImporter(vcPath); this.vcList = vImporter.GetVisuliaztionConfigs(); } else { BsonDocument allFilter = new BsonDocument(); string connectionString = config.GetConnectionString("MongoDbConnection"); string dbName = config.GetConnectionString("DatabaseName"); Console.WriteLine("Database Name: " + dbName); MongoClient client = new MongoClient(connectionString); IMongoDatabase db = client.GetDatabase(dbName); log.Here().Information("connectionString: " + connectionString + ", databaseName: " + dbName); IMongoCollection <Vertex> vCollection = db.GetCollection <Vertex>("Vertexes"); this.vList = vCollection.Find(allFilter).ToList(); IMongoCollection <Edge> eCollection = db.GetCollection <Edge>("Edges"); this.eList = eCollection.Find(allFilter).ToList(); log.Here().Information("KG data has been parsed from MongoDB."); IMongoCollection <VisulizationConfig> vcCollection = db.GetCollection <VisulizationConfig>("VisulizationConfigs"); this.vcList = vcCollection.Find(allFilter).ToList(); log.Here().Information("Visulization Config data has been parsed from MongoDB."); } }