diff options
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/model')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java | 51 | ||||
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java | 16 |
2 files changed, 9 insertions, 58 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java deleted file mode 100644 index 0ce015c..0000000 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.ufund.api.ufundapi.model; - -import com.ufund.api.ufundapi.persistence.CupboardDAO; -import com.ufund.api.ufundapi.persistence.CupboardFileDao; - -import java.io.IOException; - -public class Cupboard { - CupboardDAO dao = new CupboardFileDao(); - - public void createNeed(Need need) throws IOException { - int id = dao.getNeeds().length; - dao.createNeed(need); - } - -// public void updateID(int id) throws IOException { -// for (int i = 0; i < getNeeds().length; i++) { -// needs.get(i).setID(i); -// } -// } - - public Need[] findNeeds(String name) throws IOException { - return dao.findNeeds(name); - } - - public Need updateNeed(Need need) throws IOException { - return dao.updateNeed(need); - } - - public void removeNeed(int id) throws IOException { - dao.deleteNeed(id); - } - - public void removeNeed(String name) throws IOException { - for (Need need : getNeeds()) { - if (need.getName().equals(name)) { - dao.deleteNeed(need.getId()); - return; - } - } - } - - public Need[] getNeeds() throws IOException { - return dao.getNeeds(); - } - - public Need getNeed(int id) throws IOException { - return dao.getNeed(id); - } - -} diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java index 9187796..2611357 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java @@ -1,5 +1,7 @@ package com.ufund.api.ufundapi.model; +import com.fasterxml.jackson.annotation.JsonProperty; + public class Need { public enum GoalType { @@ -7,12 +9,12 @@ public class Need { PHYSICAL } - private String name; - private int id; - private String[] filterAttributes; - final private GoalType type; - private double maxGoal; - private double current; + @JsonProperty("name") private String name; + @JsonProperty("id") private int id; + @JsonProperty("filterAttributes") private String[] filterAttributes; + @JsonProperty("type") final private GoalType type; + @JsonProperty("maxGoal") private double maxGoal; + @JsonProperty("Current") private double current; /** * Create a new need @@ -22,7 +24,7 @@ public class Need { * @param maxGoal The maximum goal for this need * @param type The type of need (monetary, physical) */ - public Need(String name, int id, double maxGoal, GoalType type) { + public Need(@JsonProperty("name") String name, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, GoalType type) { this.id = id; this.name = name; this.maxGoal = maxGoal; |