Пример #1
0
  List<Medicament> getMedicaments() throws Exception {
    Class response = ResponseMedicament.class;
    Letters letters = new Letters();
    char[] chars = letters.getChars();
    Set<Medicament> medicaments = new HashSet<Medicament>();
    for (char c : chars) {
      String responseJsonTxt =
          getContent(
              response,
              parametrs.get("param1"),
              parametrs.get("param8"),
              parametrs.get("param9"),
              parametrs.get("param10"),
              parametrs.get("param11"),
              parametrs.get("param12"),
              parametrs.get("param13"),
              parametrs.get("param14"),
              parametrs.get("param15"),
              Character.toString(c));
      ResponseMedicament responseMedicament =
          (ResponseMedicament) getResponseJson(responseJsonTxt, ResponseMedicament.class);
      List<Medicament> responseMedicaments = responseMedicament.getRows();
      if (responseMedicaments != null) medicaments.addAll(responseMedicaments);
      if (responseMedicament.getTotal() > 1)
        addMoreThan1000Medicaments(medicaments, c, responseMedicament.getTotal(), response);
    }

    return new ArrayList<Medicament>(medicaments);
  }
Пример #2
0
 Medicament getMedicament(int i) throws Exception {
   Class response = ResponseMedicament.class;
   String responseJsonTxt =
       getContent(
           response,
           parametrs.get("param1"),
           parametrs.get("param4"),
           parametrs.get("param5"),
           Integer.toString(i),
           parametrs.get("param6"),
           parametrs.get("param7"));
   ResponseMedicament responseMedicament =
       (ResponseMedicament) getResponseJson(responseJsonTxt, ResponseMedicament.class);
   return responseMedicament.getRows().get(0);
 }
Пример #3
0
 void addMoreThan1000Medicaments(Set<Medicament> medicaments, char c, int total, Class response)
     throws Exception {
   for (int i = 1; i < total; i++) {
     String responseJsonTxt =
         getContent(
             response,
             parametrs.get("param1"),
             parametrs.get("param8"),
             parametrs.get("param9"),
             Integer.toString(i),
             parametrs.get("param11"),
             parametrs.get("param12"),
             parametrs.get("param13"),
             parametrs.get("param14"),
             parametrs.get("param15"),
             Character.toString(c));
     ResponseMedicament responseMedicament =
         (ResponseMedicament) getResponseJson(responseJsonTxt, ResponseMedicament.class);
     List<Medicament> responseMedicaments = responseMedicament.getRows();
     medicaments.addAll(responseMedicaments);
   }
 }