diff --git a/src/main/java/shef/servlets/NewRecipeServlet.java b/src/main/java/shef/servlets/NewRecipeServlet.java index 2251e78..612775f 100644 --- a/src/main/java/shef/servlets/NewRecipeServlet.java +++ b/src/main/java/shef/servlets/NewRecipeServlet.java @@ -132,31 +132,4 @@ private void addToSearchStrings(Collection searchStrings, String stringT } searchStrings.add(stringToAdd.toUpperCase()); } - - /** Converts a Datastore entity into a Recipe. */ - private Recipe entityToRecipe(Entity recipeEntity) { - String name = (String) recipeEntity.getProperty("name"); - String user = (String) recipeEntity.getProperty("user"); - String description = (String) recipeEntity.getProperty("description"); - LinkedHashSet tags = new LinkedHashSet<>((LinkedList) (LinkedList) getDataAsList(recipeEntity.getProperty("tags"), TAG)); - LinkedHashSet ingredients = new LinkedHashSet<>((LinkedList) (LinkedList) getDataAsList(recipeEntity.getProperty("ingredients"), INGREDIENT)); - LinkedList steps = (LinkedList) (LinkedList) getDataAsList(recipeEntity.getProperty("steps"), STEP); - long timestamp = (long) recipeEntity.getProperty("timestamp"); - return new Recipe(name, user, description, tags, ingredients, steps, timestamp); - } - - /** Gets a list of Recipe parameters from a Datastore property. */ - private Collection getDataAsList(Object propertiesObject, String field) { - Collection properties = (Collection) propertiesObject; - Collection dataAsList = new LinkedList<>(); - for (EmbeddedEntity property : properties) { - dataAsList.add(property.getProperty(field)); - } - return dataAsList; - } - - private String convertToJsonUsingGson(Recipe recipe) { - Gson gson = new Gson(); - return gson.toJson(recipe); - } } diff --git a/src/main/webapp/recipe.html b/src/main/webapp/recipe.html index 71ce5ce..3367ef0 100644 --- a/src/main/webapp/recipe.html +++ b/src/main/webapp/recipe.html @@ -47,12 +47,27 @@ }); - -

-    
-    
-    
-    
+    
+