Skip to content

Commit

Permalink
Revert "Revert "Revert "Update Recipe with imgUrl parsing"""
Browse files Browse the repository at this point in the history
This reverts commit d575a06.
  • Loading branch information
EAction13 committed Dec 6, 2023
1 parent d575a06 commit 320da11
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/src/main/java/cse/gradle/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Recipe {
private Date date;
private UUID id;

private String imgUrl;
private String imgURLString;

// empty constructor
public Recipe() {
Expand Down Expand Up @@ -116,7 +116,7 @@ public UUID getId() {
}

public String getImgUrl(){
return imgUrl;
return imgURLString;
}

// setters
Expand Down Expand Up @@ -145,12 +145,12 @@ public void setId(UUID newId) {
}

public void setImgURL(String imgURL){
this.imgUrl = imgURL;
this.imgURLString = imgURL;
}

// toString method for saving to file (csv)
public String toString() {
return ingredients + "," + instructions + "," + category + "," + name + "," + date + "," + id + "," + imgUrl;
return ingredients + "," + instructions + "," + category + "," + name + "," + date + "," + id;
}

// toDocument method for saving to database
Expand All @@ -162,7 +162,6 @@ public Document toDocument() {
doc.append("name", name);
doc.append("date", date.toString());
doc.append("id", id.toString());
doc.append("imgUrl", imgUrl.toString());
return doc;
}

Expand Down Expand Up @@ -227,7 +226,6 @@ public static Recipe parseRecipeFromString(String json) {
String instructions = jsonNode.has("instructions") ? jsonNode.get("instructions").asText() : "";
String category = jsonNode.has("category") ? jsonNode.get("category").asText() : "";
String name = jsonNode.has("name") ? jsonNode.get("name").asText() : "";
String imgUrl = jsonNode.has("imgUrl") ? jsonNode.get("imgUrl").asText() : "";
Date dateCreated = tempDate;
try {
dateCreated = jsonNode.has("date") ? format.parse(jsonNode.get("date").asText()) : tempDate;
Expand All @@ -240,7 +238,6 @@ public static Recipe parseRecipeFromString(String json) {

// Create a recipe object
Recipe recipe = new Recipe(ingredients, instructions, category, name);
recipe.setImgURL(imgUrl);

recipe.setDate(dateCreated);
System.out.println("dateCreated: " + dateCreated);
Expand Down

0 comments on commit 320da11

Please sign in to comment.