public static void GenTestDB(bool cleanUpAter = false, bool newsGen = true) { List <News> news_ = new List <News>() { }; List <Commentary> comments_ = new List <Commentary>() { }; Managers.Manager mng = new Managers.Manager("test_db"); //CREATE DB mng.GenDB(cleanUpAter); //GENERATE NEWS,COMMENTS mng.GenNewsComments(newsGen, true); }
public static OrientDatabase Migrate(Managers.Manager to_, Managers.Manager from_, List <IOrientObjects.IOrientDefaultObject> mooveClasses , List <IOrientObjects.IOrientDefaultObject> mooveObjects, bool dropAndCreateIfExists = false, bool generate = false) { OrientDatabase result = null; bool allreadyExists = false; if (to_ == null) { throw new Exception("No from DB passed"); } targetRepo_ = to_.GetRepo(); if (targetRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbTo = targetRepo_.GetDb(); if (dropAndCreateIfExists == true) { //drop and create db if (dbTo != null) { targetRepo_.DeleteDb(); } targetRepo_.CreateDb(); if (targetRepo_.GetDb() == null) { throw new Exception("Db was not recreated"); } } if (from_ != null) { //moove db sourceRepo_ = from_.GetRepo(); if (sourceRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbFrom = sourceRepo_.GetDb(); dbFrom = sourceRepo_.GetDb(); dbTo = targetRepo_.GetDb(); if (dbTo == null) { throw new Exception("No target database exists"); } if (dbFrom == null) { throw new Exception("No source database exists"); } if (mooveClasses != null && mooveClasses.Count() > 0) { MooveClasses(targetRepo_, sourceRepo_, mooveClasses); foreach (OrientDefaultObject oL_ in mooveClasses) { targetRepo_.CreateProperty <OrientDefaultObject>(oL_, null); } } if (mooveObjects != null && mooveObjects.Count() > 0) { ConditionalItemsInit(mooveObjects); MooveObject(); /* * MooveObjectsOfClass<Person>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<Unit>(targetRepo_,sourceRepo_); * * MooveObjectsOfClass<SubUnit>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<MainAssignment>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<OldMainAssignment>(targetRepo_,sourceRepo_); */ } /* * MooveObjectsOfClass<UserSettings>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<CommonSettings>(targetRepo_,sourceRepo_); * * * MooveObjectsOfClass<PersonRelation>(targetRepo_,sourceRepo_); */ } if (generate == true) { //generate scenery to existing to_.GenDB(false, false); to_.GenNewsComments(null, null); } targetRepo_.StoreDbStatistic(null, null); return(result); }
public static OrientDatabase Migrate(Managers.Manager to_, Managers.Manager from_, bool dropAndCreateIfExists = false, bool mooveClasses = false, bool mooveObjects = false, bool generate = false) { OrientDatabase result = null; bool allreadyExists = false; if (to_ == null) { throw new Exception("No from DB passed"); } targetRepo_ = to_.GetRepo(); if (targetRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbTo = targetRepo_.GetDb(); if (dropAndCreateIfExists == true) { //drop and create db if (dbTo != null) { targetRepo_.DeleteDb(); } targetRepo_.CreateDb(); if (targetRepo_.GetDb() == null) { throw new Exception("Db was not recreated"); } } if (from_ != null) { //moove db sourceRepo_ = from_.GetRepo(); if (sourceRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbFrom = sourceRepo_.GetDb(); dbFrom = sourceRepo_.GetDb(); dbTo = targetRepo_.GetDb(); if (dbTo == null) { throw new Exception("No target database exists"); } if (dbFrom == null) { throw new Exception("No source database exists"); } if (mooveClasses) { MooveClasses(targetRepo_, sourceRepo_); targetRepo_.CreateProperty <OrientEdge>(new OrientEdge(), null); //create all properties even if all null. targetRepo_.CreateProperty <MainAssignment>(new MainAssignment(), null); targetRepo_.CreateProperty <Unit>(new Unit(), null); targetRepo_.CreateProperty <Note>(new Note(), null); targetRepo_.CreateProperty <Authorship>(new Authorship(), null); targetRepo_.CreateProperty <Comment>(new Comment(), null); targetRepo_.CreateProperty <Commentary>(new Commentary(), null); targetRepo_.CreateProperty <News>(new News(), null); targetRepo_.CreateProperty <Person>(new Person(), null); targetRepo_.CreateProperty <Liked>(new Liked(), null); targetRepo_.CreateProperty <Tag>(new Tag(), null); targetRepo_.CreateProperty <Tagged>(new Tagged(), null); } if (mooveObjects) { MooveObjectsOfClass <Person>(targetRepo_, sourceRepo_); MooveObjectsOfClass <Unit>(targetRepo_, sourceRepo_); MooveObjectsOfClass <SubUnit>(targetRepo_, sourceRepo_); MooveObjectsOfClass <MainAssignment>(targetRepo_, sourceRepo_); MooveObjectsOfClass <OldMainAssignment>(targetRepo_, sourceRepo_); } /* * MooveObjectsOfClass<UserSettings>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<CommonSettings>(targetRepo_,sourceRepo_); */ MooveObjectsOfClass <PersonRelation>(targetRepo_, sourceRepo_); } if (generate == true) { //generate scenery to existing to_.GenDB(false, false); to_.GenNewsComments(null, null); } targetRepo_.StoreDbStatistic(null, null); return(result); }