コード例 #1
0
  public ArrayList<JournalViewModel> getJournal(int cropid) {
    String jsonResult = null;
    ArrayList<JournalViewModel> journals = null;
    try {
      JournalServiceRepository journalRep = new JournalServiceRepository();
      jsonResult = journalRep.execute("/SelectJournalByCropId?crop_id=" + cropid).get();
      JSONArray jsonArray = new JSONArray(jsonResult);
      journals = new ArrayList<JournalViewModel>();
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject jsonObj = jsonArray.getJSONObject(i);
        JournalViewModel journalModel = new JournalViewModel();
        journalModel.setJournalid(jsonObj.getInt("journalid"));
        journalModel.setDesc(jsonObj.getString("description"));
        journalModel.setJournalDate(
            new Date(ModelHelper.parseJsonDate(jsonObj.getString("dateentered"))));
        // journalModel.setPhoto();
        journalModel.setCropid(jsonObj.getInt("cropid"));

        journals.add(journalModel);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return journals;
  }
コード例 #2
0
 public String saveJournal(JournalViewModel journal) {
   String status = null;
   try {
     JournalServiceRepository journalRep = new JournalServiceRepository();
     status = journalRep.execute("/InsertJournal", journal).get();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return status;
 }