Package org.springframework.samples.petclinic

Examples of org.springframework.samples.petclinic.Visit


  private void loadVisits(JdbcPet pet) {
    final List<Visit> visits = this.simpleJdbcTemplate.query(
        "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
        new ParameterizedRowMapper<Visit>() {
          public Visit mapRow(ResultSet rs, int row) throws SQLException {
            Visit visit = new Visit();
            visit.setId(rs.getInt("id"));
            visit.setDate(rs.getTimestamp("visit_date"));
            visit.setDescription(rs.getString("description"));
            return visit;
          }
        },
        pet.getId().intValue());
    for (Visit visit : visits) {
View Full Code Here


  }

  @RequestMapping(method = RequestMethod.GET)
  public String setupForm(@PathVariable("petId") int petId, Model model) {
    Pet pet = this.clinic.loadPet(petId);
    Visit visit = new Visit();
    pet.addVisit(visit);
    model.addAttribute("visit", visit);
    return "pets/visitForm";
  }
View Full Code Here

    PetType dog = new PetType();
    dog.setName("dog");
    Pet bello = new Pet();
    bello.setName("Bello");
    bello.setType(dog);
    Visit belloVisit = new Visit();
    belloVisit.setPet(bello);
    belloVisit.setDate(new Date(2009, 0, 1));
    belloVisit.setDescription("Bello visit");
    Pet wodan = new Pet();
    wodan.setName("Wodan");
    wodan.setType(dog);
    Visit wodanVisit = new Visit();
    wodanVisit.setPet(wodan);
    wodanVisit.setDate(new Date(2009, 0, 2));
    wodanVisit.setDescription("Wodan visit");
    List<Visit> visits = new ArrayList<Visit>();
    visits.add(belloVisit);
    visits.add(wodanVisit);

    model = new HashMap<String, Object>();
View Full Code Here

  }

  public void testInsertVisit() {
    Pet p7 = this.clinic.loadPet(7);
    int found = p7.getVisits().size();
    Visit visit = new Visit();
    p7.addVisit(visit);
    visit.setDescription("test");
    this.clinic.storePet(p7);
    // assertTrue(!visit.isNew()); -- NOT TRUE FOR TOPLINK (before commit)
    p7 = this.clinic.loadPet(7);
    assertEquals(found + 1, p7.getVisits().size());
  }
View Full Code Here

TOP

Related Classes of org.springframework.samples.petclinic.Visit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.