本文整理汇总了Java中org.springframework.samples.petclinic.Specialty类的典型用法代码示例。如果您正苦于以下问题:Java Specialty类的具体用法?Java Specialty怎么用?Java Specialty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Specialty类属于org.springframework.samples.petclinic包,在下文中一共展示了Specialty类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshVetsCache
import org.springframework.samples.petclinic.Specialty; //导入依赖的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);
}
}
}
}
示例2: createVetManagerTree
import org.springframework.samples.petclinic.Specialty; //导入依赖的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);
}