org.springframework.samples.petclinic.model.Specialty Java Examples

The following examples show how to use org.springframework.samples.petclinic.model.Specialty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VetControllerTests.java    From DevOps-for-Web-Development with MIT License 6 votes vote down vote up
@Before
public void setup() {
    this.mockMvc = MockMvcBuilders.standaloneSetup(vetController).build();

    Vet james = new Vet();
    james.setFirstName("James");
    james.setLastName("Carter");
    james.setId(1);
    Vet helen = new Vet();
    helen.setFirstName("Helen");
    helen.setLastName("Leary");
    helen.setId(2);
    Specialty radiology = new Specialty();
    radiology.setId(1);
    radiology.setName("radiology");
    helen.addSpecialty(radiology);
    given(this.clinicService.findVets()).willReturn(Lists.newArrayList(james, helen));
}
 
Example #2
Source File: JdbcVetRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
/**
 * Refresh the cache of Vets that the ClinicService is holding.
 */
@Override
public Collection<Vet> findAll() throws DataAccessException {
    List<Vet> vets = new ArrayList<>();
    // Retrieve the list of all vets.
    vets.addAll(this.jdbcTemplate.query(
        "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
        BeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query(
        "SELECT id, name FROM specialties",
        BeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
            "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
            new BeanPropertyRowMapper<Integer>() {
                @Override
                public Integer mapRow(ResultSet rs, int row) throws SQLException {
                    return rs.getInt(1);
                }
            },
            vet.getId());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}
 
Example #3
Source File: JdbcVetRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
/**
 * Refresh the cache of Vets that the ClinicService is holding.
 */
@Override
public Collection<Vet> findAll() throws DataAccessException {
    List<Vet> vets = new ArrayList<>();
    // Retrieve the list of all vets.
    vets.addAll(this.jdbcTemplate.query(
        "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
        BeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query(
        "SELECT id, name FROM specialties",
        BeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
            "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
            new BeanPropertyRowMapper<Integer>() {
                @Override
                public Integer mapRow(ResultSet rs, int row) throws SQLException {
                    return rs.getInt(1);
                }
            },
            vet.getId());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}
 
Example #4
Source File: JdbcVetRepositoryImpl.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets()
 */
@Override
public Collection<Vet> findAll() throws DataAccessException {
    List<Vet> vets = new ArrayList<Vet>();
    // Retrieve the list of all vets.
    vets.addAll(this.jdbcTemplate.query(
            "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
            BeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query(
            "SELECT id, name FROM specialties",
            BeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
                "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
                new BeanPropertyRowMapper<Integer>() {
                    @Override
                    public Integer mapRow(ResultSet rs, int row) throws SQLException {
                        return Integer.valueOf(rs.getInt(1));
                    }
                },
                vet.getId().intValue());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}
 
Example #5
Source File: JdbcVetRepositoryImpl.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets()
 */
@Override
public Collection<Vet> findAll() throws DataAccessException {
    List<Vet> vets = new ArrayList<Vet>();
    // Retrieve the list of all vets.
    vets.addAll(this.jdbcTemplate.query(
            "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
            BeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query(
            "SELECT id, name FROM specialties",
            BeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
                "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
                new BeanPropertyRowMapper<Integer>() {
                    @Override
                    public Integer mapRow(ResultSet rs, int row) throws SQLException {
                        return Integer.valueOf(rs.getInt(1));
                    }
                },
                vet.getId().intValue());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}