Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.

Sun, 31 Jul 2022 20:23:27 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 31 Jul 2022 20:23:27 +0200
changeset 384
d68826df8b63
parent 383
bd20f8710f45
child 385
09af9f46518f

Product and recipe beerxml export support for hop extracts. Recipes with missing hop from the database use a default utilisation value.

src/EditProductExport.cpp file | annotate | diff | comparison | revisions
src/EditRecipeExport.cpp file | annotate | diff | comparison | revisions
src/database/db_product.cpp file | annotate | diff | comparison | revisions
src/database/db_recipe.cpp file | annotate | diff | comparison | revisions
--- a/src/EditProductExport.cpp	Sun Jul 31 16:29:05 2022 +0200
+++ b/src/EditProductExport.cpp	Sun Jul 31 20:23:27 2022 +0200
@@ -23,8 +23,8 @@
     qDebug() << "export";
 
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" });
-    /*                                                    "Leaf Wet", "Cryo", "Extract" */
+    const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet",      "Pellet" });
+    /*                                                    "Leaf Wet", "Cryo", "CO2 extract", "Iso extract" */
     /*  We use more hop forms then beerxml knows about, so we send known names */
     /*  instead of what we internally use. */
 
@@ -127,6 +127,9 @@
 	xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).beta, 'f', 1));
 	xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).hsi, 'f', 1));
 	xmlWriter->writeTextElement("ORIGIN", product->hops.at(i).origin);
+	xmlWriter->writeTextElement("BMS_FORM", g_hop_forms[product->hops.at(i).form]);
+        xmlWriter->writeTextElement("BMS_UTILISATION", QString::number(product->hops.at(i).utilisation, 'f', 4));
+        xmlWriter->writeTextElement("BMS_BU_FACTOR", QString::number(product->hops.at(i).bu_factor, 'f', 1));
 	xmlWriter->writeEndElement();
     }
     xmlWriter->writeEndElement();	// HOPS
--- a/src/EditRecipeExport.cpp	Sun Jul 31 16:29:05 2022 +0200
+++ b/src/EditRecipeExport.cpp	Sun Jul 31 20:23:27 2022 +0200
@@ -21,8 +21,8 @@
 void EditRecipe::exportBeerXML()
 {
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" });
-    /*                                                    "Leaf Wet", "Cryo", "Extract" */
+    const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet",      "Pellet" });
+    /*                                                    "Leaf Wet", "Cryo", "CO2 extract", "Iso extract" */
     /*  We use more hop forms then beerxml knows about, so we send known names */
     /*  instead of what we internally use. */
 
@@ -119,6 +119,9 @@
 	xmlWriter->writeTextElement("BETA", QString::number(recipe->hops.at(i).beta, 'f', 1));
 	xmlWriter->writeTextElement("HSI", QString::number(recipe->hops.at(i).hsi, 'f', 1));
 	xmlWriter->writeTextElement("ORIGIN", recipe->hops.at(i).origin);
+	xmlWriter->writeTextElement("BMS_FORM", g_hop_forms[recipe->hops.at(i).form]);
+	xmlWriter->writeTextElement("BMS_UTILISATION", QString::number(recipe->hops.at(i).utilisation, 'f', 4));
+	xmlWriter->writeTextElement("BMS_BU_FACTOR", QString::number(recipe->hops.at(i).bu_factor, 'f', 1));
 	xmlWriter->writeEndElement();
     }
     xmlWriter->writeEndElement();	// HOPS
--- a/src/database/db_product.cpp	Sun Jul 31 16:29:05 2022 +0200
+++ b/src/database/db_product.cpp	Sun Jul 31 20:23:27 2022 +0200
@@ -378,7 +378,10 @@
 			    h.utilisation = yquery.value("utilisation").toDouble();
 			if (h.bu_factor == 0)
 			    h.bu_factor = yquery.value("bu_factor").toDouble();
-                    }
+                    } else {
+			h.utilisation = my_ut_pellet;
+			h.bu_factor = 1.0;
+		    }
 		    prod->hops.append(h);
 		}
 		qDebug() << "hops" << prod->hops.size();
--- a/src/database/db_recipe.cpp	Sun Jul 31 16:29:05 2022 +0200
+++ b/src/database/db_recipe.cpp	Sun Jul 31 20:23:27 2022 +0200
@@ -220,6 +220,9 @@
 		    if (yquery.first()) {
 			h.utilisation = yquery.value("utilisation").toDouble();
 			h.bu_factor = yquery.value("bu_factor").toDouble();
+		    } else {
+			h.utilisation = my_ut_pellet;
+			h.bu_factor = 1.0;
 		    }
 		}
 		reci->hops.append(h);

mercurial