コード例 #1
0
  private boolean executeFreeProfessionalsJson(Date date) {
    // requisicao de banco para recuperar lista de profissionais livres, anexado com sua lista de
    // serviços, para mostrar na lista
    // selectedDateFreeFullProfList = FreeTimeCalculator.getFreeProfessionalsFromDate(date,
    // professionalDTOList);
    // selectedDateFreeProfessionalDTOSet = new ArrayList<>();

    // if (selectedDateFreeFullProfList == null) {
    //    Log.i("doInBackground", "Não conseguiu executar TaskRetrieveFreeDays, erro ao recuperar
    // selectedDateFreeFullProfList");
    //    selectedDateFreeProfessionalDTOSet = new ArrayList<>();
    //    return false;
    // }

    // gera lista de profissionais disponiveis
    // for (ProfessionalForSchedule professionalForSchedule : selectedDateFreeFullProfList) {
    // selectedDateFreeProfessionalDTOSet.add(professionalForSchedule.getProfessionalDTO());

    // }
    ProfessionalService professionalService = new ProfessionalService(mParentActivity);
    Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
    calendar.setTime(date);
    try {
      System.out.println(
          "===================================CUST6.EXECUTEFREEPROFESSIONALSJSON=================================");
      System.out.println("Recuperando profissionais livres do calendar: " + calendar);
      System.out.println("Lista de Profs enviados: ");
      for (ProfessionalDTO professionalDTO : professionalDTOList) {
        System.out.println(professionalDTO.getName());
      }

      selectedDateFreeProfessionalDTOSet =
          professionalService.findAvailableProfessionalsInSpecificDate(
              calendar, professionalDTOList);
      System.out.println("Profissionais recebidos em findProfessionalAvailableToScheduling: ");
      for (ProfessionalDTO professionalDTO : selectedDateFreeProfessionalDTOSet) {
        System.out.println(professionalDTO.getName() + " disponível");
      }
    } catch (ServiceException ex) {
      Log.i(
          "doInBackground",
          "Não conseguiu executar TaskRetrieveFreeDays, erro ao recuperar selectedDateFreeProfessionalDTOSet");
      selectedDateFreeProfessionalDTOSet = new LinkedHashSet<>();
      return false;
    }

    if (selectedDateFreeProfessionalDTOSet == null) {
      Log.i(
          "doInBackground",
          "Não conseguiu executar TaskRetrieveFreeDays, selectedDateFreeProfessionalDTOSet está vazia");
      selectedDateFreeProfessionalDTOSet = new LinkedHashSet<>();
      return false;
    }
    return true;
  }
コード例 #2
0
  private boolean validateUtilDateAndProfessional(Date date, ProfessionalDTO professionalDTO) {
    // recupera dailySchedule para verificar se o o dia é util para o profissional
    if (date != null && professionalDTO != null) {
      Calendar toValidateCal = Calendar.getInstance(TimeZone.getDefault());
      toValidateCal.setTime(date);

      System.out.println(
          "Validando profissional " + professionalDTO.getName() + " na data de " + toValidateCal);

      if (selectedDateFreeProfessionalDTOSet.contains(professionalDTO)) {
        // se o profissional selecionado estiver na lista de profissionais livres alimenta
        // professionalForSchedule

        // for (ProfessionalForSchedule professionalForSchedule : selectedDateFreeFullProfList) {
        // if (professionalForSchedule.getProfessionalDTO().getId().equals(professionalDTO.getId()))
        // {
        // initFinishVariables(professionalForSchedule, toValidateCal);

        // System.out.println("Validado profissional pelo selectedDateFreeProfessionalDTOSet");
        // return true;
        //    }
        // }
        initFinishVariables(professionalDTO, toValidateCal);
        return true;
      } else if (selectedProfFreeCalendars != null) {
        // se a lista de dias livres do profissional selecionado foi igual a data selecionada,
        // alimenta professionalForSchedule
        for (Calendar freeCalendar : selectedProfFreeCalendars) {
          if (DateUtilMoti.isSameDay(freeCalendar, toValidateCal)
              && selectedProfessionalDTO
                  .getId()
                  .equals(
                      professionalDTO
                          .getId())) // todo Falta verificar a veracidade do profissional com a
                                     // data???
          {
            // ProfessionalForSchedule professionalForSchedule = new
            // ProfessionalForSchedule(dailyScheduleDTO.getProfessional(),
            // selectedProfServiceDTOList, dailyScheduleDTOs);
            initFinishVariables(professionalDTO, toValidateCal);
            System.out.println("Validado profissional pelo selectedProfFreeDailyScheduleDTOList");
            return true;
          }
        }
      }
    }
    return false;
  }
コード例 #3
0
  private void highlightProfessionalDTOList(
      Set<ProfessionalDTO> availableProfessionalDTOs,
      Set<ProfessionalDTO> unavailableProfessionalsSet) {
    // limpa os dias marcados e profissional selecionado para mostrar profissionais disponiveis na
    // data selecionada

    for (ProfessionalDTO professionalDTO : availableProfessionalDTOs) {
      System.out.println("Nome: " + professionalDTO.getName());
    }
    if (selectedProfessionalDTO != null) {
      // Toast.makeText(getActivity(), selectedProfessionalDTO.getName() + " não está livre no dia
      // selecionado.", Toast.LENGTH_LONG).show();
      professionalLV.clearChoices();
      selectedProfessionalDTO = null;
    }
    professionalAdapter.highlightProfessionals(
        availableProfessionalDTOs, unavailableProfessionalsSet);
    if (selectedProfFreeCalendars != null) selectedProfFreeCalendars.clear();
    screenCalendar.clearHighlightedDates();
    finishDownViewLoad();
  }
コード例 #4
0
  private boolean executeFreeDaysJson(ProfessionalDTO professionalDTO) {
    // requisicao de banco para recuperar lista de dias livres, para mostrar no calendario

    /*
    //precisa recuperar servicos para calcular tempo livre
    ServiceService serviceService = new ServiceService();
    selectedProfServiceDTOList = new ArrayList<>();
    try {
        selectedProfServiceDTOList.clear();
        selectedProfServiceDTOList = serviceService.findAllByProfessionalId(professionalDTO.getId());
    } catch (Exception e) {
        e.printStackTrace();
        Log.i("doInBackground", "Não conseguiu executar TaskRetrieveFreeDays, erro ao recuperar serviceDTOList");
        return false;
    }

    //recupera os dias disponiveis
    selectedProfFreeDailyScheduleDTOList = FreeTimeCalculator.getFreeDatesFromProfessional(professionalDTO, selectedProfServiceDTOList);
    if (selectedProfFreeDailyScheduleDTOList == null) {
        Log.i("doInBackground", "Não conseguiu executar TaskRetrieveFreeDays, erro ao recuperar selectedProfFreeDailyScheduleDTOList");
        selectedProfFreeDailyScheduleDTOList = new ArrayList<>();
        return false;
    }*/
    DailyScheduleService dailyScheduleService = new DailyScheduleService();
    selectedProfFreeCalendars = new ArrayList<>();
    try {
      selectedProfFreeCalendars =
          dailyScheduleService.findAvailableDatesToScheduling(professionalDTO.getId());
    } catch (Exception e) {
      e.printStackTrace();
      Log.i(
          "doInBackground",
          "Não conseguiu executar TaskRetrieveFreeDays, erro ao recuperar selectedProfFreeCalendars");
      return false;
    }
    return true;
  }