Package org.springframework.samples.petclinic.model

Examples of org.springframework.samples.petclinic.model.Visit


        final List<Visit> visits = this.jdbcTemplate.query(
                "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
                new ParameterizedRowMapper<Visit>() {
                    @Override
                    public Visit mapRow(ResultSet rs, int row) throws SQLException {
                        Visit visit = new Visit();
                        visit.setId(rs.getInt("id"));
                        Date visitDate = rs.getDate("visit_date");
                        visit.setDate(new DateTime(visitDate));
                        visit.setDescription(rs.getString("description"));
                        return visit;
                    }
                },
                petId);
        return visits;
View Full Code Here


    }

    @RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET)
    public String initNewVisitForm(@PathVariable("petId") int petId, Map<String, Object> model) {
        Pet pet = this.clinicService.findPetById(petId);
        Visit visit = new Visit();
        pet.addVisit(visit);
        model.put("visit", visit);
        return "pets/createOrUpdateVisitForm";
    }
View Full Code Here

  @Test
  @Transactional
  public void insertVisit() {
      Pet pet7 = this.clinicService.findPetById(7);
      int found = pet7.getVisits().size();
      Visit visit = new Visit();
      pet7.addVisit(visit);
      visit.setDescription("test");
      // both storeVisit and storePet are necessary to cover all ORM tools
      this.clinicService.saveVisit(visit);
      this.clinicService.savePet(pet7);
      pet7 = this.clinicService.findPetById(7);
      assertEquals(found + 1, pet7.getVisits().size());
      assertNotNull("Visit Id should have been generated", visit.getId());
  }
View Full Code Here

TOP

Related Classes of org.springframework.samples.petclinic.model.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.