当前位置: 首页>>代码示例>>Java>>正文


Java Vet类代码示例

本文整理汇总了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());
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:17,代码来源:AbstractJpaClinicTests.java

示例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);
			}
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:SimpleJdbcClinic.java

示例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;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:10,代码来源:SimpleJdbcClinic.java

示例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);
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:28,代码来源:VetManagerView.java

示例5: getSelectedVet

import org.springframework.samples.petclinic.Vet; //导入依赖的package包/类
private Vet getSelectedVet() {
    DefaultMutableTreeNode node = getSelectedVetNode();
    if (node != null)
        return (Vet)node.getUserObject();

    return null;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:8,代码来源:VetManagerView.java

示例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;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:8,代码来源:VetManagerView.java

示例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();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:6,代码来源:EntityManagerClinic.java

示例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();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:6,代码来源:HibernateClinic.java


注:本文中的org.springframework.samples.petclinic.Vet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。