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

The following examples show how to use org.springframework.samples.petclinic.model.Vet. 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: VetsAtomView.java    From audit4j-demo with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model,
                                       HttpServletRequest request, HttpServletResponse response) throws Exception {

    Vets vets = (Vets) model.get("vets");
    List<Vet> vetList = vets.getVetList();
    List<Entry> entries = new ArrayList<Entry>(vetList.size());

    for (Vet vet : vetList) {
        Entry entry = new Entry();
        // see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
        entry.setId(String.format("tag:springsource.org,%s", vet.getId()));
        entry.setTitle(String.format("Vet: %s %s", vet.getFirstName(), vet.getLastName()));
        //entry.setUpdated(visit.getDate().toDate());

        Content summary = new Content();
        summary.setValue(vet.getSpecialties().toString());
        entry.setSummary(summary);

        entries.add(entry);
    }
    response.setContentType("blabla");
    return entries;

}
 
Example #2
Source File: VetsAtomView.java    From docker-workflow-plugin with MIT License 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model,
                                       HttpServletRequest request, HttpServletResponse response) throws Exception {

    Vets vets = (Vets) model.get("vets");
    List<Vet> vetList = vets.getVetList();
    List<Entry> entries = new ArrayList<Entry>(vetList.size());

    for (Vet vet : vetList) {
        Entry entry = new Entry();
        // see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
        entry.setId(String.format("tag:springsource.org,%s", vet.getId()));
        entry.setTitle(String.format("Vet: %s %s", vet.getFirstName(), vet.getLastName()));
        //entry.setUpdated(visit.getDate().toDate());

        Content summary = new Content();
        summary.setValue(vet.getSpecialties().toString());
        entry.setSummary(summary);

        entries.add(entry);
    }
    response.setContentType("blabla");
    return entries;

}
 
Example #3
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 #4
Source File: AbstractClinicServiceTests.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Test
public void shouldFindVets() {
    Collection<Vet> vets = this.clinicService.findVets();

    Vet vet = EntityUtils.getById(vets, Vet.class, 3);
    assertThat(vet.getLastName()).isEqualTo("Douglas");
    assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
    assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry");
    assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery");
}
 
Example #5
Source File: AbstractClinicServiceTests.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindVets() {
    Collection<Vet> vets = this.clinicService.findVets();

    Vet vet = EntityUtils.getById(vets, Vet.class, 3);
    assertThat(vet.getLastName()).isEqualTo("Douglas");
    assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
    assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry");
    assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery");
}
 
Example #6
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;
}
 
Example #7
Source File: AbstractClinicServiceTests.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Test
public void shouldFindVets() {
    Collection<Vet> vets = this.clinicService.findVets();

    Vet vet = EntityUtils.getById(vets, Vet.class, 3);
    assertThat(vet.getLastName()).isEqualTo("Douglas");
    assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
    assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry");
    assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery");
}
 
Example #8
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 #9
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 #10
Source File: AbstractClinicServiceTests.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Test
public void shouldFindVets() {
    Collection<Vet> vets = this.clinicService.findVets();

    Vet vet = EntityUtils.getById(vets, Vet.class, 3);
    assertThat(vet.getLastName()).isEqualTo("Douglas");
    assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
    assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry");
    assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery");
}
 
Example #11
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 #12
Source File: JpaVetRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Collection<Vet> findAll() {
    return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
}
 
Example #13
Source File: ClinicServiceImpl.java    From audit4j-demo with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(readOnly = true)
@Cacheable(value = "vets")
public Collection<Vet> findVets() throws DataAccessException {
    return vetRepository.findAll();
}
 
Example #14
Source File: ClinicService.java    From audit4j-demo with Apache License 2.0 4 votes vote down vote up
@Audit
Collection<Vet> findVets() throws DataAccessException;
 
Example #15
Source File: JpaVetRepositoryImpl.java    From audit4j-demo with Apache License 2.0 4 votes vote down vote up
@Override
@Cacheable(value = "vets")
@SuppressWarnings("unchecked")
public Collection<Vet> findAll() {
    return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
}
 
Example #16
Source File: JpaVetRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 4 votes vote down vote up
@Override
@Cacheable(value = "vets")
@SuppressWarnings("unchecked")
public Collection<Vet> findAll() {
    return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
}
 
Example #17
Source File: ClinicServiceImpl.java    From docker-workflow-plugin with MIT License 4 votes vote down vote up
@Override
@Transactional(readOnly = true)
@Cacheable(value = "vets")
public Collection<Vet> findVets() throws DataAccessException {
    return vetRepository.findAll();
}
 
Example #18
Source File: JpaVetRepositoryImpl.java    From docker-workflow-plugin with MIT License 4 votes vote down vote up
@Override
@Cacheable(value = "vets")
@SuppressWarnings("unchecked")
public Collection<Vet> findAll() {
    return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
}
 
Example #19
Source File: ClinicServiceImpl.java    From DevOps-for-Web-Development with MIT License 4 votes vote down vote up
@Override
@Transactional(readOnly = true)
@Cacheable(value = "vets")
public Collection<Vet> findVets() throws DataAccessException {
    return vetRepository.findAll();
}
 
Example #20
Source File: ClinicServiceImpl.java    From DevOps-for-Web-Development with MIT License 4 votes vote down vote up
@Override
@Transactional(readOnly = true)
@Cacheable(value = "vets")
public Collection<Vet> findVets() throws DataAccessException {
    return vetRepository.findAll();
}
 
Example #21
Source File: VetRepository.java    From docker-workflow-plugin with MIT License 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
Collection<Vet> findAll() throws DataAccessException;
 
Example #22
Source File: VetRepository.java    From amazon-ecs-java-microservices with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
@Transactional(readOnly = true)
@Cacheable("vets")
Collection<Vet> findAll() throws DataAccessException;
 
Example #23
Source File: VetRepository.java    From DevOps-for-Web-Development with MIT License 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
Collection<Vet> findAll() throws DataAccessException;
 
Example #24
Source File: VetRepository.java    From audit4j-demo with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
Collection<Vet> findAll() throws DataAccessException;
 
Example #25
Source File: VetRepository.java    From amazon-ecs-java-microservices with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
@Transactional(readOnly = true)
@Cacheable("vets")
Collection<Vet> findAll() throws DataAccessException;
 
Example #26
Source File: VetRepository.java    From DevOps-for-Web-Development with MIT License 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
Collection<Vet> findAll() throws DataAccessException;
 
Example #27
Source File: VetRepository.java    From amazon-ecs-java-microservices with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve all <code>Vet</code>s from the data store.
 *
 * @return a <code>Collection</code> of <code>Vet</code>s
 */
@Transactional(readOnly = true)
@Cacheable("vets")
Collection<Vet> findAll() throws DataAccessException;
 
Example #28
Source File: ClinicService.java    From DevOps-for-Web-Development with MIT License votes vote down vote up
Collection<Vet> findVets() throws DataAccessException; 
Example #29
Source File: ClinicService.java    From docker-workflow-plugin with MIT License votes vote down vote up
Collection<Vet> findVets() throws DataAccessException; 
Example #30
Source File: ClinicService.java    From DevOps-for-Web-Development with MIT License votes vote down vote up
Collection<Vet> findVets() throws DataAccessException;