Skip to content

Commit

Permalink
Issue #14: Applying formatting techniques in EvaluatePlaceDAO class
Browse files Browse the repository at this point in the history
  • Loading branch information
joao18araujo committed May 6, 2016
1 parent ddc8c96 commit f3079d3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/src/main/java/dao/EvaluatePlaceDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
public class EvaluatePlaceDAO extends DAO{

private static final String STRING_EMPTY = "";

public EvaluatePlaceDAO() {

}
Expand All @@ -20,27 +22,31 @@ public EvaluatePlaceDAO(Activity currentActivity) {
}

public void evaluatePlace(Evaluation evaluation) {
final String evaluationQuery;
String evaluationQuery = STRING_EMPTY;

String consultEvaluation = "SELECT * FROM evaluate_place WHERE idPlace = \"" +
evaluation.getIdPlace() + "\" " + "AND idUser = \"" +
evaluation.getIdUser() + "\"";

JSONObject findEvaluation = executeConsult("SELECT * FROM evaluate_place WHERE idPlace = \"" + evaluation.getIdPlace() + "\" " +
"AND idUser = \"" + evaluation.getIdUser() + "\"");
JSONObject findEvaluation = executeConsult(consultEvaluation);

if(findEvaluation==null) {
evaluationQuery = "INSERT INTO evaluate_place(grade, idUser, idPlace) VALUES (\"" + evaluation.getgrade() + "\"," +
"\"" + evaluation.getIdUser() + "\"," +
evaluationQuery = "INSERT INTO evaluate_place(grade, idUser, idPlace) VALUES (\"" +
evaluation.getgrade() + "\"," + "\"" + evaluation.getIdUser() + "\"," +
"\"" + evaluation.getIdPlace() + "\")";
}else{
evaluationQuery = "UPDATE evaluate_place SET grade = \"" +evaluation.getgrade() + "\" " +
"WHERE idPlace = \"" + evaluation.getIdPlace() + "\" AND idUser = \"" + evaluation.getIdUser() + "\"";
evaluationQuery = "UPDATE evaluate_place SET grade = \"" +
evaluation.getgrade() + "\" " + "WHERE idPlace = \"" + evaluation.getIdPlace() +
"\" AND idUser = \"" + evaluation.getIdUser() + "\"";
}

executeQuery(evaluationQuery);
}


public JSONObject searchPlaceEvaluation(int placeId, int userId) {
String searchPlaceEvaluationQuery = "SELECT * FROM evaluate_place WHERE idUser = \"" + userId
+ "\" AND idPlace = " + placeId;
String searchPlaceEvaluationQuery = "SELECT * FROM evaluate_place WHERE idUser = \"" +
userId + "\" AND idPlace = " + placeId;
return executeConsult(searchPlaceEvaluationQuery);
}
}

0 comments on commit f3079d3

Please sign in to comment.