|
|
|
@ -159,6 +159,7 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the category as a comma-separated list. |
|
|
|
|
* @see #stringifyCategories(Recipe) |
|
|
|
|
*/ |
|
|
|
|
public String getCategory() { |
|
|
|
|
return category; |
|
|
|
@ -241,6 +242,8 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
|
|
|
|
|
getIngredients().setWrappedData( |
|
|
|
|
buildIngredientFacade(recipe.getIngredientHash())); |
|
|
|
|
stringifyCategories(recipe); |
|
|
|
|
|
|
|
|
|
log.info("Set recipe: " + this.recipe); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -255,7 +258,19 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
if (recipe == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
stringifyCategories(recipe); |
|
|
|
|
return recipe; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Categories are a Set attached to recipe. Build |
|
|
|
|
* a displayable comma-separated list of them. |
|
|
|
|
* |
|
|
|
|
* @param recipe Recipe to get categories from. |
|
|
|
|
* |
|
|
|
|
* @see #getCategory() |
|
|
|
|
*/ |
|
|
|
|
private void stringifyCategories(Recipe recipe) { |
|
|
|
|
Set<Category> cList = recipe.getCategories(); |
|
|
|
|
StringBuffer sb = new StringBuffer(35); |
|
|
|
|
boolean first = true; |
|
|
|
@ -268,7 +283,6 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
sb.append(cat.getCategory()); |
|
|
|
|
} |
|
|
|
|
this.category = sb.toString(); |
|
|
|
|
return recipe; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -344,7 +358,8 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
if (instructions == null) { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
String s = instructions.replace("\n\n", "<p/>"); |
|
|
|
|
String s = instructions.replace("\r\n", "<p/>") |
|
|
|
|
.replace("\n\n", "<p/>"); |
|
|
|
|
s = s.replace("\n", "<br/>"); |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
@ -413,11 +428,11 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
this.setMoveUpAble(moveUpable && selectable); |
|
|
|
|
this.setMoveDownAble(moveDownable && selectable); |
|
|
|
|
this.setSelectable(selectable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auditRows(ingList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
// ---
|
|
|
|
|
public void setMoveUpAble(boolean moveUpable) { |
|
|
|
|
this.moveUpable = moveUpable; |
|
|
|
|
} |
|
|
|
@ -464,11 +479,11 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void auditRows(List<IngredientUI> rows) { |
|
|
|
|
log.info("=== AUDIT ROWS ==="); |
|
|
|
|
for ( IngredientUI row : rows ) { |
|
|
|
|
log.info((row.isSelected() ? "[X]" : "[ ]" ) +" ROW="+row); |
|
|
|
|
} |
|
|
|
|
log.info("=== DONE ==="); |
|
|
|
|
// log.info("=== AUDIT ROWS ===");
|
|
|
|
|
// for ( IngredientUI row : rows ) {
|
|
|
|
|
// log.info((row.isSelected() ? "[X]" : "[ ]" ) +" ROW="+row);
|
|
|
|
|
// }
|
|
|
|
|
// log.info("=== DONE ===");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -527,21 +542,21 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
* Invoked when the "E"(dit" button for Ingkey shopping |
|
|
|
|
* category has been clicked. |
|
|
|
|
* |
|
|
|
|
* @param item The item whose ingredient key will |
|
|
|
|
* have its shopping category edited. Resets the dialog |
|
|
|
|
* backing bean internal state. |
|
|
|
|
* @param item The item whose ingredient key will have its |
|
|
|
|
* shopping category edited. Resets the dialog |
|
|
|
|
* backing bean internal state. |
|
|
|
|
*/ |
|
|
|
|
public void ajaxEditShopcat(IngredientUI item) { |
|
|
|
|
editShopcatBean.beginEdit(item.getIngkey(), |
|
|
|
|
editShopcatBean.beginEdit(item.getIngkey(), |
|
|
|
|
item.getShopCat()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* On "OK" for edit shopcat where shopcat has changed, |
|
|
|
|
* update the shopcat Entity and the ingredients. |
|
|
|
|
* On "OK" for edit shopcat where shopcat has changed, update |
|
|
|
|
* the shopcat Entity and the ingredients. |
|
|
|
|
*/ |
|
|
|
|
public void doUpdateShopcat() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final String key = editShopcatBean.getIngkey(); |
|
|
|
|
if (StringUtils.isBlank(key)) { |
|
|
|
|
return; // Do not set category if no ingKey
|
|
|
|
@ -555,20 +570,20 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
sc = new Shopcat(); |
|
|
|
|
sc.setIngkey(key); |
|
|
|
|
} else { |
|
|
|
|
if ( StringUtils.equals(sc.getShopcategory(), catname) ) { |
|
|
|
|
if (StringUtils.equals(sc.getShopcategory(), |
|
|
|
|
catname)) { |
|
|
|
|
return; // No change
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
sc.setShopcategory(catname); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Because the database does not have a UNIQUE |
|
|
|
|
* constraint on ingkeys, we must delete old |
|
|
|
|
* shopcat(s) for this key before adding (updating) |
|
|
|
|
* the new shopcat. |
|
|
|
|
/* |
|
|
|
|
* Because the database does not have a UNIQUE constraint |
|
|
|
|
* on ingkeys, we must delete old shopcat(s) for this key |
|
|
|
|
* before adding (updating) the new shopcat. |
|
|
|
|
*/ |
|
|
|
|
this.recipeService.deleteShopcatByIngKey(key); |
|
|
|
|
if (! StringUtils.isBlank(catname)) { |
|
|
|
|
if (!StringUtils.isBlank(catname)) { |
|
|
|
|
this.recipeService.saveShopcat(sc); |
|
|
|
|
} |
|
|
|
|
updateDisplayedShopcats(key, sc); |
|
|
|
@ -711,14 +726,14 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
List<Ingredient> iList = recipe.getIngredientHash(); |
|
|
|
|
iList.clear(); |
|
|
|
|
for (IngredientUI iui : saveIng) { |
|
|
|
|
if ( iui.isIngGroup() ) { |
|
|
|
|
if (iui.isIngGroup()) { |
|
|
|
|
// Ing group is an attribute of ingredients.
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Ingredient ing = iui.getIngredient(); |
|
|
|
|
ing.setRecipe(recipe); |
|
|
|
|
if (!updateShopcat(iui)) { // Obsolete???
|
|
|
|
|
log.info("Shopcat has not been updated" +iui); |
|
|
|
|
log.info("Shopcat has not been updated" + iui); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
iList.add(ing); |
|
|
|
@ -769,7 +784,7 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
ing.setShopCat(scat); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Parse out the comma-separated category text control and |
|
|
|
|
* post the results as children of the recipe |
|
|
|
@ -798,7 +813,7 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
cat.setId(ocat.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
recipe.setCategories(new HashSet(newList)); |
|
|
|
|
recipe.setCategories(new HashSet<Category>(newList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Category searchCategory(Set<Category> oldList, |
|
|
|
@ -978,7 +993,7 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the suggestCategory |
|
|
|
|
* @return the suggestCategory List |
|
|
|
|
*/ |
|
|
|
|
public List<String> getSuggestCategory() { |
|
|
|
|
if (suggestCategory == null) { |
|
|
|
|