|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
@ -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,8 +542,8 @@ 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 |
|
|
|
|
* @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) { |
|
|
|
@ -537,8 +552,8 @@ public class RecipeDetailBean implements Serializable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 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() { |
|
|
|
|
|
|
|
|
@ -555,17 +570,17 @@ 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)) { |
|
|
|
@ -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) { |
|
|
|
|