本文整理汇总了Java中org.springframework.samples.petclinic.Vet类的典型用法代码示例。如果您正苦于以下问题:Java Vet类的具体用法?Java Vet怎么用?Java Vet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vet类属于org.springframework.samples.petclinic包,在下文中一共展示了Vet类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetVets
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
public void testGetVets() {
Collection<Vet> vets = this.clinic.getVets();
// Use the inherited countRowsInTable() convenience method (from
// AbstractTransactionalDataSourceSpringContextTests) to verify the
// results.
assertEquals("JDBC query must show the same number of vets", super.countRowsInTable("VETS"), vets.size());
Vet v1 = EntityUtils.getById(vets, Vet.class, 2);
assertEquals("Leary", v1.getLastName());
assertEquals(1, v1.getNrOfSpecialties());
assertEquals("radiology", (v1.getSpecialties().get(0)).getName());
Vet v2 = EntityUtils.getById(vets, Vet.class, 3);
assertEquals("Douglas", v2.getLastName());
assertEquals(2, v2.getNrOfSpecialties());
assertEquals("dentistry", (v2.getSpecialties().get(0)).getName());
assertEquals("surgery", (v2.getSpecialties().get(1)).getName());
}
示例2: refreshVetsCache
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
/**
* Refresh the cache of Vets that the Clinic is holding.
* @see org.springframework.samples.petclinic.Clinic#getVets()
*/
@ManagedOperation
@Transactional(readOnly = true)
public void refreshVetsCache() throws DataAccessException {
synchronized (this.vets) {
this.logger.info("Refreshing vets cache");
// Retrieve the list of all vets.
this.vets.clear();
this.vets.addAll(this.simpleJdbcTemplate.query(
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
ParameterizedBeanPropertyRowMapper.newInstance(Vet.class)));
// Retrieve the list of all possible specialties.
final List<Specialty> specialties = this.simpleJdbcTemplate.query(
"SELECT id, name FROM specialties",
ParameterizedBeanPropertyRowMapper.newInstance(Specialty.class));
// Build each vet's list of specialties.
for (Vet vet : this.vets) {
final List<Integer> vetSpecialtiesIds = this.simpleJdbcTemplate.query(
"SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
new ParameterizedRowMapper<Integer>() {
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);
}
}
}
}
示例3: getVets
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
@Transactional(readOnly = true)
public Collection<Vet> getVets() throws DataAccessException {
synchronized (this.vets) {
if (this.vets.isEmpty()) {
refreshVetsCache();
}
return this.vets;
}
}
示例4: createVetManagerTree
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
private void createVetManagerTree() {
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Vets");
Collection vets = clinic.getVets();
for (Iterator i = vets.iterator(); i.hasNext();) {
Vet vet = (Vet)i.next();
DefaultMutableTreeNode vetNode = new DefaultMutableTreeNode(vet);
for (Iterator s = vet.getSpecialties().iterator(); s.hasNext();) {
Specialty specialty = (Specialty)s.next();
vetNode.add(new DefaultMutableTreeNode(specialty));
}
rootNode.add(vetNode);
}
this.vetsTreeModel = new DefaultTreeModel(rootNode);
this.vetsTree = new JTree(vetsTreeModel);
vetsTree.setShowsRootHandles(true);
vetsTree.addTreeSelectionListener(new TreeStatusBarUpdater(getStatusBar()) {
public String getSelectedObjectName() {
Vet selectedVet = getSelectedVet();
if (selectedVet != null)
return selectedVet.getFirstName() + " " + selectedVet.getLastName();
return "Vets";
}
});
vetsTree.setCellRenderer(getTreeCellRenderer());
vetsTree.setRootVisible(true);
}
示例5: getSelectedVet
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
private Vet getSelectedVet() {
DefaultMutableTreeNode node = getSelectedVetNode();
if (node != null)
return (Vet)node.getUserObject();
return null;
}
示例6: getSelectedVetNode
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
private DefaultMutableTreeNode getSelectedVetNode() {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)vetsTree.getLastSelectedPathComponent();
if (node == null || !(node.getUserObject() instanceof Vet))
return null;
return node;
}
示例7: getVets
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public Collection<Vet> getVets() {
return this.em.createQuery("SELECT vet FROM Vet vet ORDER BY vet.lastName, vet.firstName").getResultList();
}
示例8: getVets
import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public Collection<Vet> getVets() {
return sessionFactory.getCurrentSession().createQuery("from Vet vet order by vet.lastName, vet.firstName").list();
}