public StaticModelerLoader(DataStore store) { this.store = store; }
public DataStore Export() { var store = new DataStore(); using (var exporter = new DatabaseExporter(GetStatelessSession())) { store.IngredientForms = exporter.IngredientForms(); store.IngredientMetadata = exporter.IngredientMetadata(); store.Ingredients = exporter.Ingredients(); store.NlpAnomalousIngredients = exporter.NlpAnomalousIngredients(); store.NlpDefaultPairings = exporter.NlpDefaultPairings(); store.NlpFormSynonyms = exporter.NlpFormSynonyms(); store.NlpIngredientSynonyms = exporter.NlpIngredientSynonyms(); store.NlpPrepNotes = exporter.NlpPrepNotes(); store.NlpUnitSynonyms = exporter.NlpUnitSynonyms(); store.Recipes = exporter.Recipes(); store.RecipeMetadata = exporter.RecipeMetadata(); store.RecipeIngredients = exporter.RecipeIngredients(); store.Favorites = exporter.Favorites(); store.Menus = exporter.Menus(); store.QueuedRecipes = exporter.QueuedRecipes(); store.RecipeRatings = exporter.RecipeRatings(); store.ShoppingLists = exporter.ShoppingLists(); store.ShoppingListItems = exporter.ShoppingListItems(); } return store; }
public StaticSearch(DataStore store) { this.store = store; }
/// <summary> /// Initializes the context and loads necessary data into memory through the configured data file. /// This must be done before the context is usable. /// </summary> public void Initialize() { var file = CompressedStore ? "KPCData.gz" : "KPCData.xml"; var path = Path.Combine(DataDirectory, file); KPCContext.Log.DebugFormat("Attempting to open local data file: {0}", path); if (!File.Exists(path)) throw new FileNotFoundException("Could not initialize StaticContext. Data file not found.", path); var serializer = new XmlSerializer(typeof (DataStore)); using (var fileReader = new FileStream(path, FileMode.Open)) { if (CompressedStore) { using (var reader = new GZipStream(fileReader, CompressionMode.Decompress)) { store = serializer.Deserialize(reader) as DataStore; } } else { store = serializer.Deserialize(fileReader) as DataStore; } if (store == null) throw new DataStoreException("Could not deserialize data store. It might be correct or an invalid format."); } // Initialize ingredient parser ingParser = new IngredientParser(); ingParser.CreateIndex(store.Ingredients.Select(i => new IngredientSource(i.IngredientId, i.DisplayName))); // Initialize modeler ModelerProxy = new ModelerProxy(this); ModelerProxy.LoadSnapshot(); // Initialize natural language parsing IngredientSynonyms.InitIndex(new StaticIngredientLoader(store)); UnitSynonyms.InitIndex(new StaticUnitLoader(store)); FormSynonyms.InitIndex(new StaticFormLoader(store)); PrepNotes.InitIndex(new StaticPrepLoader(store)); Anomalies.InitIndex(new StaticAnomalyLoader(store)); NumericVocab.InitIndex(); Parser = new Parser(); LoadTemplates(); }