Пример #1
1
  /** Get events filtered by program orgUnit and between dates. */
  public static List<Event> getEvents(String program, String orgUnit, Date minDate, Date maxDate) {
    try {
      Response response;

      String DHIS_URL = PreferencesState.getInstance().getDhisURL();
      String startDate = EventExtended.format(minDate, EventExtended.AMERICAN_DATE_FORMAT);
      String endDate =
          EventExtended.format(
              new Date(maxDate.getTime() + (8 * 24 * 60 * 60 * 1000)),
              EventExtended.AMERICAN_DATE_FORMAT);
      String url =
          String.format(DHIS_URL + DHIS_CHECK_EVENT_API, program, orgUnit, startDate, endDate);
      Log.d(TAG, url);
      url = ServerAPIController.encodeBlanks(url);

      response = ServerAPIController.executeCall(null, url, "GET");
      if (!response.isSuccessful()) {
        Log.e(TAG, "pushData (" + response.code() + "): " + response.body().string());
        throw new IOException(response.message());
      }
      JSONObject events = new JSONObject(response.body().string());
      ObjectMapper mapper = new ObjectMapper();
      JsonNode jsonNode = mapper.convertValue(mapper.readTree(events.toString()), JsonNode.class);

      return EventsWrapper.getEvents(jsonNode);

    } catch (Exception ex) {
      ex.printStackTrace();
      return null;
    }
  }
Пример #2
0
 /**
  * Download the related events. and checks all the quarantine surveys. If a survey is in the
  * server, the survey should be set as sent. Else, the survey should be set as completed and it
  * will be resend.
  */
 public static void checkAllQuarantineSurveys() {
   List<Survey> quarantineSurveys = Survey.getAllQuarantineSurveys();
   Date minDate = Survey.getMinQuarantineEventDate();
   Date maxDate = Survey.getMaxQuarantineEventDate();
   String program = quarantineSurveys.get(0).getProgram().getUid();
   String orgUnit = OrgUnit.findUIDByName(PreferencesState.getInstance().getOrgUnit());
   List<Event> events = getEvents(program, orgUnit, minDate, maxDate);
   if (events != null) {
     for (Survey survey : quarantineSurveys) {
       updateQuarantineSurveysStatus(events, survey);
     }
   }
 }
Пример #3
0
 public void setActionBarDashboard() {
   if (PreferencesState.getInstance().isVerticalDashboard()) {
     LayoutUtils.setActionbarAppName(dashboardActivity);
   } else {
     // Get Tab + User
     String title = getCapitalizeName();
     String user = getCurrentUsername();
     String appNameColorString = getAppNameColorString();
     String appName = getAppName();
     Spanned spannedTitle =
         Html.fromHtml(
             String.format(
                 "<font color=\"#%s\"><b>%s</b></font> | %s", appNameColorString, appName, title));
     LayoutUtils.setActionbarTitle(dashboardActivity, spannedTitle, user);
   }
 }