public Vet getSpecificVet(int index) {
   init();
   if (index < 0) {
     index = 0;
   }
   if (index > (data.size() - 1)) {
     index = data.size() - 1;
   }
   Vet obj = data.get(index);
   Long id = obj.getId();
   return Vet.findVet(id);
 }
Exemple #2
0
  // ---------------------------------------------------------------------------------------------
  // Method for finding the nearest vet. ---------------------------------------------------------
  private void findNearestVet() {
    Double tempVetLat, tempVetLng;
    LatLng tempVetLatLng;
    String tempVetName;
    float minimumDistance = 0;
    nearestVetPosition = 0;
    Log.d("VetFirstActivity", "ready to read the data from the list");
    if (vetList != null) {
      for (int i = 0; i < vetList.size(); i++) {
        tempVetLat = vetList.get(i).getLat();
        tempVetLng = vetList.get(i).getLng();
        tempVetName = vetList.get(i).getName();
        Log.d(
            "VetFirstActivity",
            "(#" + i + ") " + tempVetName + "(" + tempVetLat + ", " + tempVetLng + ")");
        markerOptionsList.add(
            new MarkerOptions().position(new LatLng(tempVetLat, tempVetLng)).title(tempVetName));
        Log.d("VetFirstActivity", "added an item to markerOptionsList");

        tempVetLatLng = new LatLng(tempVetLat, tempVetLng);

        float[] distance_results = new float[2];
        Location.distanceBetween(
            currentLocationLatLng.latitude,
            currentLocationLatLng.longitude,
            tempVetLatLng.latitude,
            tempVetLatLng.longitude,
            distance_results);
        Log.d(
            "VetFirstActivity",
            "distance: "
                + distance_results[0]
                + " m - initial bearing: "
                + distance_results[1]
                + " degrees");

        if (i == 0) {
          minimumDistance = distance_results[0];
        } else if (minimumDistance > distance_results[0]) {
          minimumDistance = distance_results[0];
          nearestVetPosition = i;
        }
      }
    } else {
      Log.d("VetFirstActivity", "empty vetList");
    }
    nearestVet = vetList.get(nearestVetPosition);
    nearestVetLatLng = new LatLng(nearestVet.getLat(), nearestVet.getLng());
    Log.d(
        "VetFirstActivity",
        "nearest vet is: " + nearestVet.getName() + "(" + nearestVet.getTelephone() + ")");
  }
  public static void main(String[] args) {

    Vet vet = new Vet("Moshe", 5);
    vet.addCustomer(new Customer("Maayan"));
    vet.addCustomer(new Customer("Ronen"));
    vet.getCustomer("MaayAn").addPet(new Dog("Bree"));
    vet.getCustomer("Ronen").addPet(new Dog("Riko"));
    vet.getCustomer("MaayAn").addPet(new Cat("mitzi"));
    // System.out.println(vet.getCustomer("maayan").getPets());
    // vet.sendSale("Sale!!! only for now DOGLY on sale");
    vet.getCustomer("RONEN").removeFromSaleMessages();
    // vet.checkVaccin();
    vet.addAnimalToHospitalize(vet.getCustomer("maaYAn").getPetByName("mitzi"));
    System.out.println(vet.getHospitalizedAnimals());
  }
 public void setLastName(Vet obj, int index) {
   String lastName = "lastName_" + index;
   if (lastName.length() > 30) {
     lastName = lastName.substring(0, 30);
   }
   obj.setLastName(lastName);
 }
 public void setAddress(Vet obj, int index) {
   String address = "address_" + index;
   if (address.length() > 50) {
     address = address.substring(0, 50);
   }
   obj.setAddress(address);
 }
 public void setHomePage(Vet obj, int index) {
   String homePage = "homePage_" + index;
   if (homePage.length() > 30) {
     homePage = homePage.substring(0, 30);
   }
   obj.setHomePage(homePage);
 }
 public void setCity(Vet obj, int index) {
   String city = "city_" + index;
   if (city.length() > 30) {
     city = city.substring(0, 30);
   }
   obj.setCity(city);
 }
 public void setFirstName(Vet obj, int index) {
   String firstName = "firstName_" + index;
   if (firstName.length() > 30) {
     firstName = firstName.substring(0, 30);
   }
   obj.setFirstName(firstName);
 }
 public void setEmail(Vet obj, int index) {
   String email = "foo" + index + "@bar.com";
   if (email.length() > 30) {
     email = email.substring(0, 30);
   }
   obj.setEmail(email);
 }
 public void setEmployedSince(Vet obj, int index) {
   Calendar employedSince =
       new GregorianCalendar(
           Calendar.getInstance().get(Calendar.YEAR),
           Calendar.getInstance().get(Calendar.MONTH),
           Calendar.getInstance().get(Calendar.DAY_OF_MONTH) - 1);
   obj.setEmployedSince(employedSince);
 }
Exemple #11
0
 // ---------------------------------------------------------------------------------------------
 // Method for updating the info of the vet that we're focused on. ------------------------------
 private void updateBasicVetInfo(final Vet vet) {
   vetName = (TextView) findViewById(R.id.vet_fir_name);
   vetName.setText(vet.getName());
   vetAddress = (TextView) findViewById(R.id.vet_fir_address);
   vetAddress.setText(vet.getAddress());
   vetCallButton = (ImageButton) findViewById(R.id.vet_fir_call_button);
   vetPhoneNumber = "tel:" + vet.getTelephone();
   vetCallButton.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           AppServices.loggingAction(
               loggedInUserID, activityTag, getString(R.string.act_vet_call_tag), vet.getVetID());
           Intent call_intent = new Intent(Intent.ACTION_CALL, Uri.parse(vetPhoneNumber));
           startActivity(call_intent);
         }
       });
 }
 public void setBirthDay(Vet obj, int index) {
   Date birthDay =
       new GregorianCalendar(
               Calendar.getInstance().get(Calendar.YEAR),
               Calendar.getInstance().get(Calendar.MONTH),
               Calendar.getInstance().get(Calendar.DAY_OF_MONTH),
               Calendar.getInstance().get(Calendar.HOUR_OF_DAY),
               Calendar.getInstance().get(Calendar.MINUTE),
               Calendar.getInstance().get(Calendar.SECOND)
                   + new Double(Math.random() * 1000).intValue())
           .getTime();
   obj.setBirthDay(birthDay);
 }
  public static void main(String args[]) throws JAXBException {
    ServiceRequest<Vet> serviceRequest = new ServiceRequest<Vet>();
    serviceRequest.setChannelId("001");
    serviceRequest.setRequestTime(new DateTime());
    serviceRequest.addRequestParam("afdas", "asdfasd");
    serviceRequest.addRequestParam("asdfasd", "afsd");
    serviceRequest.addRequestParam("dasf", "safd");

    Vet vets = new Vet();
    vets.setFirstName("Farhan");
    serviceRequest.setPayLoad(vets);

    //
    //        ApplicationContext context = new
    // ClassPathXmlApplicationContext("applicationContext.xml");
    //        PetClinicManagerBase service =  context.getBean(PetClinicManagerImpl.class);
    //        Result<List<PetType>> owner = service.findAllPetTypes();
    // main(). response.setResult(owner);
    JAXBContext jaxbContext = JAXBContext.newInstance(ServiceRequest.class);
    Marshaller marshaller = jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(serviceRequest, System.out);
  }
  public void init() {
    int from = 0;
    int to = 10;
    data = Vet.findVetEntries(from, to);
    if (data == null) {
      throw new IllegalStateException(
          "Find entries implementation for 'Vet' illegally returned null");
    }
    if (!data.isEmpty()) {
      return;
    }

    data = new ArrayList<Vet>();
    for (int i = 0; i < 10; i++) {
      Vet obj = getNewTransientVet(i);
      try {
        obj.persist();
      } catch (ConstraintViolationException e) {
        StringBuilder msg = new StringBuilder();
        for (Iterator<ConstraintViolation<?>> iter = e.getConstraintViolations().iterator();
            iter.hasNext(); ) {
          ConstraintViolation<?> cv = iter.next();
          msg.append("[")
              .append(cv.getConstraintDescriptor())
              .append(":")
              .append(cv.getMessage())
              .append("=")
              .append(cv.getInvalidValue())
              .append("]");
        }
        throw new RuntimeException(msg.toString(), e);
      }
      obj.flush();
      data.add(obj);
    }
  }
 public void setSpecialty(Vet obj, int index) {
   Specialty specialty = Specialty.class.getEnumConstants()[0];
   obj.setSpecialty(specialty);
 }
 public Vet getRandomVet() {
   init();
   Vet obj = data.get(rnd.nextInt(data.size()));
   Long id = obj.getId();
   return Vet.findVet(id);
 }
 public void setTelephone(Vet obj, int index) {
   String telephone = "telephone_" + index;
   obj.setTelephone(telephone);
 }