Examples of Visit


Examples of org.springframework.samples.petclinic.Visit

    return visit;
  }

  /** Method inserts a new <code>Visit</code>. */
  protected ModelAndView onSubmit(Object command) throws ServletException {
    Visit visit = (Visit) command;
    // delegate the insert to the Business layer
    getClinic().storeVisit(visit);
    return new ModelAndView(getSuccessView(), "ownerId", visit.getPet().getOwner().getId());
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Visit

    }

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

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

Examples of org.springframework.samples.petclinic.Visit

  }

  public void storeVisit(Visit visit) {
    // Consider returning the persistent object here, for exposing
    // a newly assigned id using any persistence provider...
    Visit merged = this.em.merge(visit);
    this.em.flush();
    visit.setId(merged.getId());
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Visit

  }

  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

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
TOP
Copyright © 2018 www.massapi.com. 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.