SPR-6447
+ moved petclinic to spring-samples (https://src.springframework.org/svn/spring-samples/petclinic)
This commit is contained in:
parent
d016a1cc2f
commit
b963906bd1
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa/1.1.0/com.springsource.org.apache.openjpa-1.1.0.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa/1.10/com.springsource.org.apache.openjpa-sources-1.10.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.lib/1.0.2/com.springsource.org.apache.openjpa.lib-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.lib/1.0.2/com.springsource.org.apache.openjpa.lib-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.persistence/1.0.2/com.springsource.org.apache.openjpa.persistence-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.persistence/1.0.2/com.springsource.org.apache.openjpa.persistence-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.java5/1.0.2/com.springsource.org.apache.openjpa.java5-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.java5/1.0.2/com.springsource.org.apache.openjpa.java5-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.jdbc/1.0.2/com.springsource.org.apache.openjpa.jdbc-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.jdbc/1.0.2/com.springsource.org.apache.openjpa.jdbc-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.jdbc.java5/1.0.2/com.springsource.org.apache.openjpa.jdbc.java5-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.jdbc.java5/1.0.2/com.springsource.org.apache.openjpa.jdbc.java5-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.lib.java5/1.0.2/com.springsource.org.apache.openjpa.lib.java5-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.lib.java5/1.0.2/com.springsource.org.apache.openjpa.lib.java5-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.persistence.jdbc/1.0.2/com.springsource.org.apache.openjpa.persistence.jdbc-1.0.2.jar" sourcepath="/IVY_CACHE/org.apache.openjpa/com.springsource.org.apache.openjpa.persistence.jdbc/1.0.2/com.springsource.org.apache.openjpa.persistence.jdbc-sources-1.0.2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-1.1.0.jar" sourcepath="/IVY_CACHE/javax.transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-sources-1.1.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.5.0/com.springsource.javax.servlet-2.5.0.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.5.0/com.springsource.javax.servlet-sources-2.5.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/com.sun.syndication/com.springsource.com.sun.syndication/1.0.0/com.springsource.com.sun.syndication-1.0.0.jar" sourcepath="/IVY_CACHE/com.sun.syndication/com.springsource.com.sun.syndication/1.0.0/com.springsource.com.sun.syndication-sources-1.0.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-1.0.0.jar" sourcepath="IVY_CACHE/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-sources-1.0.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.3.RELEASE/com.springsource.org.aspectj.weaver-1.6.3.RELEASE.jar" sourcepath="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.3.RELEASE/com.springsource.org.aspectj.weaver-sources-1.6.3.RELEASE.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.dbcp/1.2.2.osgi/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.dbcp/1.2.2.osgi/com.springsource.org.apache.commons.dbcp-sources-1.2.2.osgi.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.hsqldb/com.springsource.org.hsqldb/1.8.0.9/com.springsource.org.hsqldb-1.8.0.9.jar" sourcepath="/IVY_CACHE/org.hsqldb/com.springsource.org.hsqldb/1.8.0.9/com.springsource.org.hsqldb-sources-1.8.0.9.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/com.oracle.toplink.essentials/com.springsource.oracle.toplink.essentials/2.0.0.b41-beta2/com.springsource.oracle.toplink.essentials-2.0.0.b41-beta2.jar" sourcepath="/IVY_CACHE/com.oracle.toplink.essentials/com.springsource.oracle.toplink.essentials/2.0.0.b41-beta2/com.springsource.oracle.toplink.essentials-sources-2.0.0.b41-beta2.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.2.0/com.springsource.javax.servlet.jsp.jstl-1.2.0.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.2.0/com.springsource.javax.servlet.jsp.jstl-sources-1.2.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/com.springsource.org.hibernate/3.3.1.GA/com.springsource.org.hibernate-3.3.1.GA.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/com.springsource.org.hibernate.ejb/3.4.0.GA/com.springsource.org.hibernate.ejb-3.4.0.GA.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/com.springsource.org.hibernate.annotations/3.4.0.GA/com.springsource.org.hibernate.annotations-3.4.0.GA.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.slf4j/com.springsource.slf4j.jcl/1.5.3/com.springsource.slf4j.jcl-1.5.3.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.transaction"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.jdbc"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.context"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.beans"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.web"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.aop"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.orm"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.web.servlet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.test"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.springframework.samples.petclinic</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
|
||||
<attributes>
|
||||
<attribute name="hide" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<classpath>
|
||||
</classpath>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#Sun Oct 04 15:30:45 PDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
#Mon Mar 02 16:00:20 PST 2009
|
||||
classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.launching.macosx.MacOSXType\:\:JVM\ 1.6/owners=jst.java\:5.0
|
||||
eclipse.preferences.version=1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#Mon Mar 02 16:00:20 PST 2009
|
||||
eclipse.preferences.version=1
|
||||
validateFragments=false
|
||||
validation.actions-missing-required-attribute=1
|
||||
validation.actions-non-empty-inline-tag=2
|
||||
validation.actions-unknown-attribute=2
|
||||
validation.directive-include-fragment-file-not-found=1
|
||||
validation.directive-include-fragment-file-not-specified=1
|
||||
validation.directive-taglib-duplicate-prefixes-different-uris=1
|
||||
validation.directive-taglib-duplicate-prefixes-same-uris=-1
|
||||
validation.directive-taglib-missing-prefix=1
|
||||
validation.directive-taglib-missing-uri-or-tagdir=1
|
||||
validation.directive-taglib-unresolvable-uri-or-tagdir=2
|
||||
validation.el-general-syntax=1
|
||||
validation.el-lexical-failure=-1
|
||||
validation.java-=-1
|
||||
validation.java-local-variable-is-never-used=-1
|
||||
validation.java-null-local-variable-reference=-1
|
||||
validation.java-potential-null-local-variable-reference=-1
|
||||
validation.java-unused-import=-1
|
||||
validation.translation-tag-class-not-found=2
|
||||
validation.translation-tei-class-not-found=2
|
||||
validation.translation-tei-class-not-instantiated=2
|
||||
validation.translation-tei-class-runtime-exception=2
|
||||
validation.translation-tei-message=1
|
||||
validation.translation-usebean-ambiguous-type-info=2
|
||||
validation.translation-usebean-invalid-id=1
|
||||
validation.translation-usebean-missing-type-info=1
|
||||
validation.use-project-settings=true
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="petclinic">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
|
||||
<wb-resource deploy-path="/WEB-INF/lib" source-path="/target/war-expanded/WEB-INF/lib"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
|
||||
<property name="context-root" value="petclinic"/>
|
||||
<property name="java-output-path" value="target/classes"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<fixed facet="jst.java"/>
|
||||
<fixed facet="jst.web"/>
|
||||
<installed facet="jst.java" version="5.0"/>
|
||||
<installed facet="jst.web" version="2.4"/>
|
||||
</faceted-project>
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#Mon Mar 02 18:15:04 PST 2009
|
||||
attrDuplicate=2
|
||||
attrInvalidName=2
|
||||
attrInvalidValue=2
|
||||
attrNameMismatch=2
|
||||
attrUndefName=2
|
||||
attrUndefValue=2
|
||||
attrValueMismatch=1
|
||||
attrValueUnclosed=2
|
||||
cdataInvalidContent=2
|
||||
cdataUnclosed=1
|
||||
commentInvalidContent=2
|
||||
commentUnclosed=1
|
||||
docDoctypeUnclosed=1
|
||||
docDuplicateTag=1
|
||||
docInvalidChar=2
|
||||
docInvalidContent=2
|
||||
eclipse.preferences.version=1
|
||||
elemCoexistence=2
|
||||
elemDuplicate=2
|
||||
elemEndInvalidCase=1
|
||||
elemInvalidContent=2
|
||||
elemInvalidDirective=1
|
||||
elemInvalidEmptyTag=2
|
||||
elemInvalidName=1
|
||||
elemMissingEnd=2
|
||||
elemMissingStart=2
|
||||
elemStartInvalidCase=2
|
||||
elemUnclosedEndTag=1
|
||||
elemUnclosedStartTag=1
|
||||
elemUnknownName=2
|
||||
elemUnnecessaryEnd=2
|
||||
piInvalidContent=2
|
||||
piUnclosed=1
|
||||
piUndefined=2
|
||||
refInvalidContent=2
|
||||
use-project-settings=true
|
||||
|
|
@ -1 +0,0 @@
|
|||
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
|
||||
|
|
@ -1 +0,0 @@
|
|||
Window
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="org.springframework.samples.petclinic">
|
||||
<property file="${basedir}/../build.properties"/>
|
||||
<property file="${basedir}/../build.versions"/>
|
||||
<import file="${basedir}/../spring-build/war/default.xml"/>
|
||||
</project>
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<project name="setupDB" basedir="." default="all">
|
||||
|
||||
<target name="dropHSQLTables" if="useHSQL">
|
||||
<echo message="Drop tables using: ${db.driver} ${db.url}" />
|
||||
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}" onerror="continue">
|
||||
<classpath>
|
||||
<fileset dir="${spring.root}/lib">
|
||||
<include name="hsqldb/hsqldb.jar" />
|
||||
</fileset>
|
||||
</classpath>
|
||||
<transaction src="${db.dir}/dropTables.txt" />
|
||||
</sql>
|
||||
</target>
|
||||
|
||||
<target name="createHSQLTables" if="useHSQL">
|
||||
<echo message="Create tables using: ${db.driver} ${db.url}" />
|
||||
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}" onerror="continue">
|
||||
<classpath>
|
||||
<fileset dir="${spring.root}/lib">
|
||||
<include name="hsqldb/hsqldb.jar" />
|
||||
</fileset>
|
||||
</classpath>
|
||||
<transaction src="${db.dir}/hsqldb/initDB.txt" />
|
||||
</sql>
|
||||
</target>
|
||||
|
||||
<target name="dropMYSQLTables" if="useMYSQL">
|
||||
<echo message="Dropping tables using: ${db.driver} ${db.url}" />
|
||||
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}" onerror="continue">
|
||||
<classpath>
|
||||
<fileset dir="${db.dir}/mysql">
|
||||
<include name="mysql*.jar" />
|
||||
</fileset>
|
||||
</classpath>
|
||||
<transaction src="${db.dir}/dropTables.txt" />
|
||||
</sql>
|
||||
</target>
|
||||
|
||||
<target name="createMYSQLTables" if="useMYSQL">
|
||||
<echo message="Creating tables using: ${db.driver} ${db.url}" />
|
||||
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}" onerror="continue">
|
||||
<classpath>
|
||||
<fileset dir="${db.dir}/mysql">
|
||||
<include name="mysql*.jar" />
|
||||
</fileset>
|
||||
</classpath>
|
||||
<transaction src="${db.dir}/mysql/initDB.txt" />
|
||||
</sql>
|
||||
</target>
|
||||
|
||||
<target name="emptyTables">
|
||||
<echo message="Emptying tables using: ${db.driver} ${db.url}" />
|
||||
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}">
|
||||
<classpath>
|
||||
<fileset dir="${spring.root}/lib">
|
||||
<include name="hsqldb/hsqldb.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${db.dir}/mysql">
|
||||
<include name="mysql*.jar" />
|
||||
</fileset>
|
||||
</classpath>
|
||||
<transaction src="${db.dir}/emptyDB.txt" />
|
||||
</sql>
|
||||
</target>
|
||||
|
||||
<target name="populateTables">
|
||||
<echo message="Populating tables using: ${db.driver} ${db.url}" />
|
||||
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}">
|
||||
<classpath>
|
||||
<fileset dir="${spring.root}/lib">
|
||||
<include name="hsqldb/hsqldb.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${db.dir}/mysql">
|
||||
<include name="mysql*.jar" />
|
||||
</fileset>
|
||||
</classpath>
|
||||
<transaction src="${db.dir}/populateDB.txt" />
|
||||
</sql>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="dropHSQLTables,createHSQLTables,dropMYSQLTables,createMYSQLTables,emptyTables,populateTables" />
|
||||
|
||||
</project>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
DROP TABLE visits;
|
||||
DROP TABLE pets;
|
||||
DROP TABLE owners;
|
||||
DROP TABLE types;
|
||||
DROP TABLE vet_specialties;
|
||||
DROP TABLE specialties;
|
||||
DROP TABLE vets;
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
DELETE FROM vets;
|
||||
DELETE FROM specialties;
|
||||
DELETE FROM vet_specialties;
|
||||
DELETE FROM types;
|
||||
DELETE FROM owners;
|
||||
DELETE FROM pets;
|
||||
DELETE FROM visits;
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
CREATE DATABASE petclinic;
|
||||
|
||||
GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc';
|
||||
|
|
@ -1 +0,0 @@
|
|||
DROP DATABASE petclinic;
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
USE petclinic;
|
||||
|
||||
CREATE TABLE vets (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30),
|
||||
INDEX(last_name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE specialties (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(80),
|
||||
INDEX(name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE vet_specialties (
|
||||
vet_id INT(4) UNSIGNED NOT NULL,
|
||||
specialty_id INT(4) UNSIGNED NOT NULL
|
||||
) engine=InnoDB;
|
||||
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets(id);
|
||||
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties(id);
|
||||
|
||||
CREATE TABLE types (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(80),
|
||||
INDEX(name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE owners (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30),
|
||||
address VARCHAR(255),
|
||||
city VARCHAR(80),
|
||||
telephone VARCHAR(20),
|
||||
INDEX(last_name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE pets (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(30),
|
||||
birth_date DATE,
|
||||
type_id INT(4) UNSIGNED NOT NULL,
|
||||
owner_id INT(4) UNSIGNED NOT NULL,
|
||||
INDEX(name)
|
||||
) engine=InnoDB;
|
||||
ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners(id);
|
||||
ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types(id);
|
||||
CREATE INDEX pets_name ON pets(name);
|
||||
|
||||
CREATE TABLE visits (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
pet_id INT(4) UNSIGNED NOT NULL,
|
||||
visit_date DATE,
|
||||
description VARCHAR(255),
|
||||
INDEX(pet_id)
|
||||
) engine=InnoDB;
|
||||
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets(id);
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
================================================================================
|
||||
=== Spring PetClinic sample application - MySQL Configuration ===
|
||||
================================================================================
|
||||
|
||||
@author Sam Brannen
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x),
|
||||
which can be found here: http://dev.mysql.com/downloads/
|
||||
|
||||
2) Download Connector/J, the MySQL JDBC driver (e.g., Connector/J 5.1.x), which
|
||||
can be found here: http://dev.mysql.com/downloads/connector/j/
|
||||
Copy the Connector/J JAR file (e.g., mysql-connector-java-5.1.5-bin.jar) into
|
||||
the db/mysql directory.
|
||||
|
||||
3) Create the PetClinic database and user by executing the "db/mysql/createDB.txt"
|
||||
script.
|
||||
|
||||
4) Open "src/main/resources/jdbc.properties"; comment out all properties in the
|
||||
"HSQL Settings" section; uncomment all properties in the "MySQL Settings"
|
||||
section.
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Context path="/petclinic" docBase="petclinic" debug="4" reloadable="true">
|
||||
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_petclinic_log." suffix=".txt" timestamp="true"/>
|
||||
|
||||
<!-- Define a database connection pool for MYSQL -->
|
||||
<Resource name="jdbc/petclinicMYSQL" auth="Container" type="javax.sql.DataSource"/>
|
||||
<ResourceParams name="jdbc/petclinicMYSQL">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>driverClassName</name>
|
||||
<value>org.gjt.mm.mysql.Driver</value>
|
||||
</parameter>
|
||||
<!--
|
||||
The JDBC connection url for connecting to your MySQL dB.
|
||||
The autoReconnect=true argument to the url makes sure that the
|
||||
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
|
||||
connection. mysqld by default closes idle connections after 8 hours.
|
||||
-->
|
||||
<parameter>
|
||||
<name>url</name>
|
||||
<value>jdbc:mysql://localhost:3306/petclinic?autoReconnect=true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>username</name>
|
||||
<value>pc</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>pc</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>maxActive</name>
|
||||
<value>50</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxIdle</name>
|
||||
<value>10</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxWait</name>
|
||||
<value>10000</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandonedTimeout</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>logAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
||||
</Context>
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Context path="/petclinic" docBase="petclinic" debug="4" reloadable="true">
|
||||
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_petclinic_log." suffix=".txt" timestamp="true"/>
|
||||
|
||||
<!-- Define a database connection pool for HSQL -->
|
||||
<!-- NOTE: make sure that a copy of hsqldb.jar is in the TOMCAT common/lib directory -->
|
||||
<Resource name="jdbc/petclinicHSQL" auth="Container" type="javax.sql.DataSource"/>
|
||||
<ResourceParams name="jdbc/petclinicHSQL">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>driverClassName</name>
|
||||
<value>org.hsqldb.jdbcDriver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>url</name>
|
||||
<value>jdbc:hsqldb:hsql://localhost:9001</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>username</name>
|
||||
<value>sa</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>maxActive</name>
|
||||
<value>50</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxIdle</name>
|
||||
<value>10</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxWait</name>
|
||||
<value>10000</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandonedTimeout</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>logAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
<!-- Define a database connection pool for MYSQL -->
|
||||
<Resource name="jdbc/petclinicMYSQL" auth="Container" type="javax.sql.DataSource"/>
|
||||
<ResourceParams name="jdbc/petclinicMYSQL">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>driverClassName</name>
|
||||
<value>org.gjt.mm.mysql.Driver</value>
|
||||
</parameter>
|
||||
<!--
|
||||
The JDBC connection url for connecting to your MySQL dB.
|
||||
The autoReconnect=true argument to the url makes sure that the
|
||||
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
|
||||
connection. mysqld by default closes idle connections after 8 hours.
|
||||
-->
|
||||
<parameter>
|
||||
<name>url</name>
|
||||
<value>jdbc:mysql://localhost:3306/petclinic?autoReconnect=true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>username</name>
|
||||
<value>pc</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>pc</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>maxActive</name>
|
||||
<value>50</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxIdle</name>
|
||||
<value>10</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxWait</name>
|
||||
<value>10000</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandonedTimeout</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>logAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
||||
</Context>
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
INSERT INTO vets VALUES (1, 'James', 'Carter');
|
||||
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
|
||||
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
|
||||
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
|
||||
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
|
||||
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
|
||||
|
||||
INSERT INTO specialties VALUES (1, 'radiology');
|
||||
INSERT INTO specialties VALUES (2, 'surgery');
|
||||
INSERT INTO specialties VALUES (3, 'dentistry');
|
||||
|
||||
INSERT INTO vet_specialties VALUES (2, 1);
|
||||
INSERT INTO vet_specialties VALUES (3, 2);
|
||||
INSERT INTO vet_specialties VALUES (3, 3);
|
||||
INSERT INTO vet_specialties VALUES (4, 2);
|
||||
INSERT INTO vet_specialties VALUES (5, 1);
|
||||
|
||||
INSERT INTO types VALUES (1, 'cat');
|
||||
INSERT INTO types VALUES (2, 'dog');
|
||||
INSERT INTO types VALUES (3, 'lizard');
|
||||
INSERT INTO types VALUES (4, 'snake');
|
||||
INSERT INTO types VALUES (5, 'bird');
|
||||
INSERT INTO types VALUES (6, 'hamster');
|
||||
|
||||
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
|
||||
INSERT INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1);
|
||||
INSERT INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);
|
||||
INSERT INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3);
|
||||
INSERT INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3);
|
||||
INSERT INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4);
|
||||
INSERT INTO pets VALUES (6, 'George', '2000-01-20', 4, 5);
|
||||
INSERT INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6);
|
||||
INSERT INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6);
|
||||
INSERT INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7);
|
||||
INSERT INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8);
|
||||
INSERT INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9);
|
||||
INSERT INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10);
|
||||
INSERT INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10);
|
||||
|
||||
INSERT INTO visits VALUES (1, 7, '1996-03-04', 'rabies shot');
|
||||
INSERT INTO visits VALUES (2, 8, '1996-03-04', 'rabies shot');
|
||||
INSERT INTO visits VALUES (3, 8, '1996-06-04', 'neutered');
|
||||
INSERT INTO visits VALUES (4, 7, '1996-09-04', 'spayed');
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
|
||||
<ivy-module
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
|
||||
version="1.3">
|
||||
|
||||
<info organisation="org.springframework" module="${ant.project.name}">
|
||||
<license name="Apache 2.0" url="http://www.apache.org/licenses/LICENSE-2.0"/>
|
||||
</info>
|
||||
|
||||
<configurations>
|
||||
<include file="${spring.build.dir}/common/default-ivy-configurations.xml"/>
|
||||
<conf name="commons-logging" extends="runtime" description="JARs needed to run with Commons Logging"/>
|
||||
</configurations>
|
||||
|
||||
<publications>
|
||||
<artifact name="${ant.project.name}" type="war" ext="war"/>
|
||||
<artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
|
||||
</publications>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency org="com.oracle.toplink.essentials" name="com.springsource.oracle.toplink.essentials" rev="2.0.0.b41-beta2" conf="compile->compile"/>
|
||||
<dependency org="com.sun.syndication" name="com.springsource.com.sun.syndication" rev="1.0.0" conf="compile->compile"/>
|
||||
<dependency org="com.sun.xml" name="com.springsource.com.sun.xml.bind" rev="2.1.7" />
|
||||
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="compile->compile"/>
|
||||
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.5.0" conf="provided->runtime"/>
|
||||
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.2.0" conf="compile->runtime"/>
|
||||
<dependency org="javax.xml.bind" name="com.springsource.javax.xml.bind" rev="2.1.7" conf="compile->runtime"/>
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile, commons-logging->compile"/>
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.dbcp" rev="1.2.2.osgi" conf="compile->runtime"/>
|
||||
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="compile->runtime"/>
|
||||
<dependency org="org.apache.openjpa" name="com.springsource.org.apache.openjpa" rev="1.1.0" conf="compile->compile"/>
|
||||
<dependency org="org.apache.taglibs" name="com.springsource.org.apache.taglibs.standard" rev="1.1.2" conf="compile->runtime"/>
|
||||
<dependency org="org.aspectj" name="com.springsource.org.aspectj.weaver" rev="1.6.3.RELEASE" conf="compile->compile"/>
|
||||
<dependency org="org.hibernate" name="com.springsource.org.hibernate" rev="3.3.1.GA" conf="compile->compile"/>
|
||||
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.4.0.GA" conf="compile->compile"/>
|
||||
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->runtime"/>
|
||||
<dependency org="org.jdom" name="com.springsource.org.jdom" rev="1.0.0" />
|
||||
<dependency org="org.slf4j" name="com.springsource.slf4j.jcl" rev="1.5.3" conf="compile->runtime"/>
|
||||
<dependency org="org.springframework" name="org.springframework.asm" rev="latest.integration" conf="compile->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.orm" rev="latest.integration" conf="compile->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.oxm" rev="latest.integration" conf="compile->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.web.servlet" rev="latest.integration" conf="compile->compile"/>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit.version}" conf="test->compile" />
|
||||
<dependency org="org.springframework" name="org.springframework.test" rev="latest.integration" conf="compile->compile"/>
|
||||
<dependency org="javax.transaction" name="com.springsource.javax.transaction" rev="1.1.0" conf="test->compile"/>
|
||||
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.4.0.GA" conf="test->compile"/>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</ivy-module>
|
||||
|
|
@ -1,211 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="jpa" name="JPA">
|
||||
<configuration>
|
||||
<setting name="validation-enabled" value="true" />
|
||||
<setting name="provider-name" value="" />
|
||||
<setting name="targe-facet" value="" />
|
||||
<datasource-mapping>
|
||||
<factory-entry name="PetClinic" />
|
||||
</datasource-mapping>
|
||||
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" optional="false" version="1.0" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" optional="false" version="2.5" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
|
||||
</webroots>
|
||||
<sourceRoots>
|
||||
<root url="file://$MODULE_DIR$/src/main/java" />
|
||||
<root url="file://$MODULE_DIR$/src/main/resources" />
|
||||
</sourceRoots>
|
||||
<building>
|
||||
<setting name="EXPLODED_URL" value="file://" />
|
||||
<setting name="EXPLODED_ENABLED" value="false" />
|
||||
<setting name="JAR_URL" value="file://$MODULE_DIR$/../out/petclinic.war" />
|
||||
<setting name="JAR_ENABLED" value="true" />
|
||||
<setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
|
||||
</building>
|
||||
<packaging>
|
||||
<containerElement type="module" name="petclinic">
|
||||
<attribute name="method" value="1" />
|
||||
<attribute name="URI" value="/WEB-INF/classes" />
|
||||
</containerElement>
|
||||
<containerElement type="library" level="module">
|
||||
<attribute name="method" value="1" />
|
||||
<attribute name="URI" value="/WEB-INF/lib" />
|
||||
<url>jar://$IVY_CACHE$/org.apache.taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar!/</url>
|
||||
</containerElement>
|
||||
</packaging>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$APPLICATION_HOME_DIR$/lib/javaee.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="web-servlet" />
|
||||
<orderEntry type="module" module-name="web" />
|
||||
<orderEntry type="module" module-name="beans" />
|
||||
<orderEntry type="module" module-name="transaction" />
|
||||
<orderEntry type="module" module-name="core" />
|
||||
<orderEntry type="module" module-name="context" />
|
||||
<orderEntry type="module" module-name="jdbc" />
|
||||
<orderEntry type="module" module-name="test" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.slf4j/com.springsource.slf4j.jcl/1.5.3/com.springsource.slf4j.jcl-1.5.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/org.slf4j/com.springsource.slf4j.jcl/1.5.3/com.springsource.slf4j.jcl-sources-1.5.3.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="orm" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/com.oracle.toplink.essentials/com.springsource.oracle.toplink.essentials/2.0.0.b41-beta2/com.springsource.oracle.toplink.essentials-2.0.0.b41-beta2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/com.oracle.toplink.essentials/com.springsource.oracle.toplink.essentials/2.0.0.b41-beta2/com.springsource.oracle.toplink.essentials-sources-2.0.0.b41-beta2.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.hibernate/com.springsource.org.hibernate/3.2.6.ga/com.springsource.org.hibernate-3.2.6.ga.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/org.hibernate/com.springsource.org.hibernate/3.2.6.ga/com.springsource.org.hibernate-sources-3.2.6.ga.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$APPLICATION_HOME_DIR$/lib/j2ee.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.apache.taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/com.sun.syndication/com.springsource.com.sun.syndication/0.9.0/com.springsource.com.sun.syndication-0.9.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/com.sun.syndication/com.springsource.com.sun.syndication/0.9.0/com.springsource.com.sun.syndication-sources-0.9.0.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.aspectj/com.springsource.org.aspectj.weaver/1.6.2.RELEASE/com.springsource.org.aspectj.weaver-1.6.2.RELEASE.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/org.aspectj/com.springsource.org.aspectj.weaver/1.6.2.RELEASE/com.springsource.org.aspectj.weaver-sources-1.6.2.RELEASE.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.dbcp/1.2.2.osgi/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.dbcp/1.2.2.osgi/com.springsource.org.apache.commons.dbcp-sources-1.2.2.osgi.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/javax.xml.bind/com.springsource.javax.xml.bind/2.1.7/com.springsource.javax.xml.bind-2.1.7.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$IVY_CACHE$/javax.xml.bind/com.springsource.javax.xml.bind/2.1.7/com.springsource.javax.xml.bind-sources-2.1.7.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/com.thoughtworks.xstream/com.springsource.com.thoughtworks.xstream/1.3.0/com.springsource.com.thoughtworks.xstream-1.3.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
<setting name="state" value="1" />
|
||||
</Base>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
==========================================================================
|
||||
=== Spring PetClinic Sample Application
|
||||
==========================================================================
|
||||
|
||||
@author Ken Krebs
|
||||
@author Juergen Hoeller
|
||||
@author Rob Harrop
|
||||
@author Costin Leau
|
||||
@author Sam Brannen
|
||||
@author Scott Andrews
|
||||
|
||||
==========================================================================
|
||||
=== Data Access Strategies
|
||||
==========================================================================
|
||||
|
||||
PetClinic features alternative DAO implementations and application
|
||||
configurations for JDBC, Hibernate, and JPA, with HSQLDB and MySQL as
|
||||
target databases. The default PetClinic configuration is JDBC on HSQLDB.
|
||||
See "src/main/resources/jdbc.properties" as well as web.xml and
|
||||
applicationContext-*.xml in the "src/main/webapp/WEB-INF" folder for
|
||||
details. A simple comment change in web.xml switches between the data
|
||||
access strategies.
|
||||
|
||||
The JDBC and Hibernate versions of PetClinic also demonstrate JMX support
|
||||
via the use of <context:mbean-export/> for exporting MBeans.
|
||||
SimpleJdbcClinic exposes the SimpleJdbcClinicMBean management interface
|
||||
via JMX through the use of the @ManagedResource and @ManagedOperation
|
||||
annotations; whereas, the HibernateStatistics service is exposed via JMX
|
||||
through auto-detection of the service MBean. You can start up the JDK's
|
||||
JConsole to manage the exported bean.
|
||||
|
||||
All data access strategies can work with JTA for transaction management by
|
||||
activating the JtaTransactionManager and a JndiObjectFactoryBean that
|
||||
refers to a transactional container DataSource. The default for JDBC is
|
||||
DataSourceTransactionManager; for Hibernate, HibernateTransactionManager;
|
||||
for JPA, JpaTransactionManager. Those local strategies allow for working
|
||||
with any locally defined DataSource.
|
||||
|
||||
Note that the sample configurations for JDBC, Hibernate, and JPA configure
|
||||
a BasicDataSource from the Apache Commons DBCP project for connection
|
||||
pooling.
|
||||
|
||||
==========================================================================
|
||||
=== Build and Deployment
|
||||
==========================================================================
|
||||
|
||||
The Spring PetClinic sample application is built using Spring Build, which
|
||||
is a custom build solution based on Ant and Ivy for dependency management.
|
||||
For deployment, the web application needs to be built with Apache Ant 1.6
|
||||
or higher. When the project is first built, Spring Build will use Ivy to
|
||||
automatically download all required dependencies. Thus the initial build
|
||||
may take a few minutes depending on the speed of your Internet connection,
|
||||
but subsequent builds will be much faster.
|
||||
|
||||
Available build commands:
|
||||
|
||||
- ant clean --> cleans the project
|
||||
- ant clean test --> cleans the project and runs all tests
|
||||
- ant clean jar --> cleans the project and builds the WAR
|
||||
|
||||
After building the project with "ant clean jar", you will find the
|
||||
resulting WAR file in the "target/artifacts" directory. By default, an
|
||||
embedded HSQLDB instance in configured. No other steps are necessary to
|
||||
get the data source up and running: you can simply deploy the built WAR
|
||||
file directly to your Servlet container.
|
||||
|
||||
For MySQL, you'll need to use the corresponding schema and SQL scripts in
|
||||
the "db/mysql" subdirectory. Follow the steps outlined in
|
||||
"db/mysql/petclinic_db_setup_mysql.txt" for explicit details.
|
||||
|
||||
In you intend to use a local DataSource, the JDBC settings can be adapted
|
||||
in "src/main/resources/jdbc.properties". To use a JTA DataSource, you need
|
||||
to set up corresponding DataSources in your Java EE container.
|
||||
|
||||
Notes on enabling Log4J:
|
||||
- Log4J is disabled by default due to issues with JBoss.
|
||||
- Uncomment the Log4J listener in "WEB-INF/web.xml" to enable logging.
|
||||
|
||||
==========================================================================
|
||||
=== JPA on Tomcat
|
||||
==========================================================================
|
||||
|
||||
This section provides tips on using the Java Persistence API (JPA) on
|
||||
Apache Tomcat 4.x or higher with a persistence provider that requires
|
||||
class instrumentation (such as TopLink Essentials).
|
||||
|
||||
To use JPA class instrumentation, Tomcat has to be instructed to use a
|
||||
custom class loader which supports instrumentation. See the JPA section of
|
||||
the Spring reference manual for complete details.
|
||||
|
||||
The basic steps are:
|
||||
- Copy "org.springframework.instrument.tomcat-3.0.0.RELEASE.jar" from the
|
||||
Spring distribution to "TOMCAT_HOME/server/lib".
|
||||
- If you're running on Tomcat 5.x, modify "TOMCAT_HOME/conf/server.xml"
|
||||
and add a new "<Context>" element for 'petclinic' (see below). You can
|
||||
alternatively deploy the WAR including "META-INF/context.xml" from this
|
||||
sample application's "src/main/webapp" directory, in which case you
|
||||
will need to uncomment the Loader element in that file to enable the
|
||||
use of the TomcatInstrumentableClassLoader.
|
||||
|
||||
<Context path="/petclinic" docBase="/petclinic/location" ...>
|
||||
<!-- please note that useSystemClassLoaderAsParent is available since Tomcat 5.5.20; remove it if previous versions are being used -->
|
||||
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/>
|
||||
...
|
||||
</Context>
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object with an id property.
|
||||
* Used as a base class for objects needing this property.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class BaseEntity {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return (this.id == null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* The high-level PetClinic business interface.
|
||||
*
|
||||
* <p>This is basically a data access object.
|
||||
* PetClinic doesn't have a dedicated business facade.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public interface Clinic {
|
||||
|
||||
/**
|
||||
* Retrieve all <code>Vet</code>s from the data store.
|
||||
* @return a <code>Collection</code> of <code>Vet</code>s
|
||||
*/
|
||||
Collection<Vet> getVets() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Retrieve all <code>PetType</code>s from the data store.
|
||||
* @return a <code>Collection</code> of <code>PetType</code>s
|
||||
*/
|
||||
Collection<PetType> getPetTypes() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Retrieve <code>Owner</code>s from the data store by last name,
|
||||
* returning all owners whose last name <i>starts</i> with the given name.
|
||||
* @param lastName Value to search for
|
||||
* @return a <code>Collection</code> of matching <code>Owner</code>s
|
||||
* (or an empty <code>Collection</code> if none found)
|
||||
*/
|
||||
Collection<Owner> findOwners(String lastName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Retrieve an <code>Owner</code> from the data store by id.
|
||||
* @param id the id to search for
|
||||
* @return the <code>Owner</code> if found
|
||||
* @throws org.springframework.dao.DataRetrievalFailureException if not found
|
||||
*/
|
||||
Owner loadOwner(int id) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Retrieve a <code>Pet</code> from the data store by id.
|
||||
* @param id the id to search for
|
||||
* @return the <code>Pet</code> if found
|
||||
* @throws org.springframework.dao.DataRetrievalFailureException if not found
|
||||
*/
|
||||
Pet loadPet(int id) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Save an <code>Owner</code> to the data store, either inserting or updating it.
|
||||
* @param owner the <code>Owner</code> to save
|
||||
* @see BaseEntity#isNew
|
||||
*/
|
||||
void storeOwner(Owner owner) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Save a <code>Pet</code> to the data store, either inserting or updating it.
|
||||
* @param pet the <code>Pet</code> to save
|
||||
* @see BaseEntity#isNew
|
||||
*/
|
||||
void storePet(Pet pet) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Save a <code>Visit</code> to the data store, either inserting or updating it.
|
||||
* @param visit the <code>Visit</code> to save
|
||||
* @see BaseEntity#isNew
|
||||
*/
|
||||
void storeVisit(Visit visit) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Deletes a <code>Pet</code> from the data store.
|
||||
*/
|
||||
void deletePet(int id) throws DataAccessException;
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>.
|
||||
* Used as a base class for objects needing these properties.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class NamedEntity extends BaseEntity {
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing an owner.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class Owner extends Person {
|
||||
|
||||
private String address;
|
||||
|
||||
private String city;
|
||||
|
||||
private String telephone;
|
||||
|
||||
private Set<Pet> pets;
|
||||
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return this.telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
protected void setPetsInternal(Set<Pet> pets) {
|
||||
this.pets = pets;
|
||||
}
|
||||
|
||||
protected Set<Pet> getPetsInternal() {
|
||||
if (this.pets == null) {
|
||||
this.pets = new HashSet<Pet>();
|
||||
}
|
||||
return this.pets;
|
||||
}
|
||||
|
||||
public List<Pet> getPets() {
|
||||
List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal());
|
||||
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
|
||||
return Collections.unmodifiableList(sortedPets);
|
||||
}
|
||||
|
||||
public void addPet(Pet pet) {
|
||||
getPetsInternal().add(pet);
|
||||
pet.setOwner(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Pet with the given name, or null if none found for this Owner.
|
||||
*
|
||||
* @param name to test
|
||||
* @return true if pet name is already in use
|
||||
*/
|
||||
public Pet getPet(String name) {
|
||||
return getPet(name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Pet with the given name, or null if none found for this Owner.
|
||||
*
|
||||
* @param name to test
|
||||
* @return true if pet name is already in use
|
||||
*/
|
||||
public Pet getPet(String name, boolean ignoreNew) {
|
||||
name = name.toLowerCase();
|
||||
for (Pet pet : getPetsInternal()) {
|
||||
if (!ignoreNew || !pet.isNew()) {
|
||||
String compName = pet.getName();
|
||||
compName = compName.toLowerCase();
|
||||
if (compName.equals(name)) {
|
||||
return pet;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
|
||||
.append("id", this.getId())
|
||||
|
||||
.append("new", this.isNew())
|
||||
|
||||
.append("lastName", this.getLastName())
|
||||
|
||||
.append("firstName", this.getFirstName())
|
||||
|
||||
.append("address", this.address)
|
||||
|
||||
.append("city", this.city)
|
||||
|
||||
.append("telephone", this.telephone)
|
||||
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing an person.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
*/
|
||||
public class Person extends BaseEntity {
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
return this.firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return this.lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
|
||||
/**
|
||||
* Simple JavaBean business object representing a pet.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class Pet extends NamedEntity {
|
||||
|
||||
private Date birthDate;
|
||||
|
||||
private PetType type;
|
||||
|
||||
private Owner owner;
|
||||
|
||||
private Set<Visit> visits;
|
||||
|
||||
|
||||
public void setBirthDate(Date birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public Date getBirthDate() {
|
||||
return this.birthDate;
|
||||
}
|
||||
|
||||
public void setType(PetType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public PetType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
protected void setOwner(Owner owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Owner getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
protected void setVisitsInternal(Set<Visit> visits) {
|
||||
this.visits = visits;
|
||||
}
|
||||
|
||||
protected Set<Visit> getVisitsInternal() {
|
||||
if (this.visits == null) {
|
||||
this.visits = new HashSet<Visit>();
|
||||
}
|
||||
return this.visits;
|
||||
}
|
||||
|
||||
public List<Visit> getVisits() {
|
||||
List<Visit> sortedVisits = new ArrayList<Visit>(getVisitsInternal());
|
||||
PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false));
|
||||
return Collections.unmodifiableList(sortedVisits);
|
||||
}
|
||||
|
||||
public void addVisit(Visit visit) {
|
||||
getVisitsInternal().add(visit);
|
||||
visit.setPet(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class PetType extends NamedEntity {
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
/**
|
||||
* Models a {@link Vet Vet's} specialty (for example, dentistry).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class Specialty extends NamedEntity {
|
||||
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a veterinarian.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Vet extends Person {
|
||||
|
||||
private Set<Specialty> specialties;
|
||||
|
||||
|
||||
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
|
||||
this.specialties = specialties;
|
||||
}
|
||||
|
||||
protected Set<Specialty> getSpecialtiesInternal() {
|
||||
if (this.specialties == null) {
|
||||
this.specialties = new HashSet<Specialty>();
|
||||
}
|
||||
return this.specialties;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public List<Specialty> getSpecialties() {
|
||||
List<Specialty> sortedSpecs = new ArrayList<Specialty>(getSpecialtiesInternal());
|
||||
PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true, true));
|
||||
return Collections.unmodifiableList(sortedSpecs);
|
||||
}
|
||||
|
||||
public int getNrOfSpecialties() {
|
||||
return getSpecialtiesInternal().size();
|
||||
}
|
||||
|
||||
public void addSpecialty(Specialty specialty) {
|
||||
getSpecialtiesInternal().add(specialty);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.samples.petclinic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a list of veterinarians. Mostly here to be used for the 'vets'
|
||||
* {@link org.springframework.web.servlet.view.xml.MarshallingView}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class Vets {
|
||||
|
||||
private List<Vet> vets;
|
||||
|
||||
@XmlElement
|
||||
public List<Vet> getVetList() {
|
||||
if (vets == null) {
|
||||
vets = new ArrayList<Vet>();
|
||||
}
|
||||
return vets;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a visit.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
*/
|
||||
public class Visit extends BaseEntity {
|
||||
|
||||
/** Holds value of property date. */
|
||||
private Date date;
|
||||
|
||||
/** Holds value of property description. */
|
||||
private String description;
|
||||
|
||||
/** Holds value of property pet. */
|
||||
private Pet pet;
|
||||
|
||||
|
||||
/** Creates a new instance of Visit for the current date */
|
||||
public Visit() {
|
||||
this.date = new Date();
|
||||
}
|
||||
|
||||
|
||||
/** Getter for property date.
|
||||
* @return Value of property date.
|
||||
*/
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
/** Setter for property date.
|
||||
* @param date New value of property date.
|
||||
*/
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/** Getter for property description.
|
||||
* @return Value of property description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/** Setter for property description.
|
||||
* @param description New value of property description.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/** Getter for property pet.
|
||||
* @return Value of property pet.
|
||||
*/
|
||||
public Pet getPet() {
|
||||
return this.pet;
|
||||
}
|
||||
|
||||
/** Setter for property pet.
|
||||
* @param pet New value of property pet.
|
||||
*/
|
||||
public void setPet(Pet pet) {
|
||||
this.pet = pet;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package org.springframework.samples.petclinic.aspects;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
|
||||
/**
|
||||
* Aspect to illustrate Spring-driven load-time weaving.
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
* @since 2.5
|
||||
*/
|
||||
@Aspect
|
||||
public abstract class AbstractTraceAspect {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AbstractTraceAspect.class);
|
||||
|
||||
@Pointcut
|
||||
public abstract void traced();
|
||||
|
||||
@Before("traced()")
|
||||
public void trace(JoinPoint.StaticPart jpsp) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Entering " + jpsp.getSignature().toLongString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
package org.springframework.samples.petclinic.aspects;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
* Simple AspectJ aspect that monitors call count and call invocation time.
|
||||
* Implements the CallMonitor management interface.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
*/
|
||||
@ManagedResource("petclinic:type=CallMonitor")
|
||||
@Aspect
|
||||
public class CallMonitoringAspect {
|
||||
|
||||
private boolean isEnabled = true;
|
||||
|
||||
private int callCount = 0;
|
||||
|
||||
private long accumulatedCallTime = 0;
|
||||
|
||||
|
||||
@ManagedAttribute
|
||||
public void setEnabled(boolean enabled) {
|
||||
isEnabled = enabled;
|
||||
}
|
||||
|
||||
@ManagedAttribute
|
||||
public boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
@ManagedOperation
|
||||
public void reset() {
|
||||
this.callCount = 0;
|
||||
this.accumulatedCallTime = 0;
|
||||
}
|
||||
|
||||
@ManagedAttribute
|
||||
public int getCallCount() {
|
||||
return callCount;
|
||||
}
|
||||
|
||||
@ManagedAttribute
|
||||
public long getCallTime() {
|
||||
return (this.callCount > 0 ? this.accumulatedCallTime / this.callCount : 0);
|
||||
}
|
||||
|
||||
|
||||
@Around("within(@org.springframework.stereotype.Service *)")
|
||||
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
if (this.isEnabled) {
|
||||
StopWatch sw = new StopWatch(joinPoint.toShortString());
|
||||
|
||||
sw.start("invoke");
|
||||
try {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
finally {
|
||||
sw.stop();
|
||||
synchronized (this) {
|
||||
this.callCount++;
|
||||
this.accumulatedCallTime += sw.getTotalTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
package org.springframework.samples.petclinic.aspects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
|
||||
/**
|
||||
* Sample AspectJ annotation-style aspect that saves
|
||||
* every owner name requested to the clinic.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
*/
|
||||
@Aspect
|
||||
public class UsageLogAspect {
|
||||
|
||||
private int historySize = 100;
|
||||
|
||||
// Of course saving all names is not suitable for
|
||||
// production use, but this is a simple example.
|
||||
private List<String> namesRequested = new ArrayList<String>(this.historySize);
|
||||
|
||||
|
||||
public synchronized void setHistorySize(int historySize) {
|
||||
this.historySize = historySize;
|
||||
this.namesRequested = new ArrayList<String>(historySize);
|
||||
}
|
||||
|
||||
@Before("execution(* *.findOwners(String)) && args(name)")
|
||||
public synchronized void logNameRequest(String name) {
|
||||
// Not the most efficient implementation,
|
||||
// but we're aiming to illustrate the power of
|
||||
// @AspectJ AOP, not write perfect code here :-)
|
||||
if (this.namesRequested.size() > this.historySize) {
|
||||
this.namesRequested.remove(0);
|
||||
}
|
||||
this.namesRequested.add(name);
|
||||
}
|
||||
|
||||
public synchronized List<String> getNamesRequested() {
|
||||
return Collections.unmodifiableList(this.namesRequested);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,261 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* A factory that creates a data source fit for use in a system environment. Creates a DBCP simple data source
|
||||
* from the provided connection properties.
|
||||
*
|
||||
* This factory returns a fully-initialized DataSource implementation. When the DataSource is returned, callers are
|
||||
* guaranteed that the database schema and data will have been loaded by that time.
|
||||
*
|
||||
* Is a FactoryBean, for exposing the fully-initialized DataSource as a Spring bean. See {@link #getObject()}.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Scott Andrews
|
||||
*/
|
||||
public class DbcpDataSourceFactory implements FactoryBean<DataSource>, DisposableBean {
|
||||
|
||||
// configurable properties
|
||||
|
||||
private String driverClassName;
|
||||
|
||||
private String url;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private boolean populate;
|
||||
|
||||
private Resource schemaLocation;
|
||||
|
||||
private Resource dataLocation;
|
||||
|
||||
private Resource dropLocation;
|
||||
|
||||
/**
|
||||
* The object created by this factory.
|
||||
*/
|
||||
private BasicDataSource dataSource;
|
||||
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The data source connection URL
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* The data source username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
*The data source password
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that the data base should be populated from the schema and data locations
|
||||
*/
|
||||
public void setPopulate(boolean populate) {
|
||||
this.populate = populate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the file containing the schema DDL to export to the database.
|
||||
* @param schemaLocation the location of the database schema DDL
|
||||
*/
|
||||
public void setSchemaLocation(Resource schemaLocation) {
|
||||
this.schemaLocation = schemaLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the file containing the data to load into the database.
|
||||
* @param testDataLocation the location of the data file
|
||||
*/
|
||||
public void setDataLocation(Resource testDataLocation) {
|
||||
this.dataLocation = testDataLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the file containing the drop scripts for the database.
|
||||
* @param testDataLocation the location of the data file
|
||||
*/
|
||||
public void setDropLocation(Resource testDropLocation) {
|
||||
this.dropLocation = testDropLocation;
|
||||
}
|
||||
|
||||
// implementing FactoryBean
|
||||
|
||||
// this method is called by Spring to expose the DataSource as a bean
|
||||
public DataSource getObject() throws Exception {
|
||||
if (dataSource == null) {
|
||||
initDataSource();
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public Class<DataSource> getObjectType() {
|
||||
return DataSource.class;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// implementing DisposableBean
|
||||
|
||||
public void destroy() throws Exception {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
// internal helper methods
|
||||
|
||||
// encapsulates the steps involved in initializing the data source: creating it, and populating it
|
||||
private void initDataSource() {
|
||||
// create the database source first
|
||||
this.dataSource = createDataSource();
|
||||
|
||||
if (this.populate) {
|
||||
// now populate the database by loading the schema and data
|
||||
populateDataSource();
|
||||
}
|
||||
}
|
||||
|
||||
private BasicDataSource createDataSource() {
|
||||
BasicDataSource dataSource = new BasicDataSource();
|
||||
dataSource.setDriverClassName(this.driverClassName);
|
||||
dataSource.setUrl(this.url);
|
||||
dataSource.setUsername(this.username);
|
||||
dataSource.setPassword(this.password);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
private void populateDataSource() {
|
||||
DatabasePopulator populator = new DatabasePopulator(dataSource);
|
||||
if (dropLocation != null) {
|
||||
try {
|
||||
populator.populate(this.dropLocation);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
populator.populate(this.schemaLocation);
|
||||
populator.populate(this.dataLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a in memory data source with data.
|
||||
*/
|
||||
private class DatabasePopulator {
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
/**
|
||||
* Creates a new database populator.
|
||||
* @param dataSource the data source that will be populated.
|
||||
*/
|
||||
public DatabasePopulator(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the database executing the statements in the provided resource against the database
|
||||
* @param sqlFile spring resource containing SQL to run against the db
|
||||
*/
|
||||
public void populate(Resource sqlFile) {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = dataSource.getConnection();
|
||||
try {
|
||||
String sql = parseSqlIn(sqlFile);
|
||||
executeSql(sql, connection);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("I/O exception occurred accessing the database schema file", e);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("SQL exception occurred exporting database schema", e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("SQL exception occurred acquiring connection", e);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// utility method to read a .sql txt input stream
|
||||
private String parseSqlIn(Resource resource) throws IOException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = resource.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
BufferedWriter writer = new BufferedWriter(sw);
|
||||
|
||||
for (int c=reader.read(); c != -1; c=reader.read()) {
|
||||
writer.write(c);
|
||||
}
|
||||
writer.flush();
|
||||
return sw.toString();
|
||||
|
||||
} finally {
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// utility method to run the parsed sql
|
||||
private void executeSql(String sql, Connection connection) throws SQLException {
|
||||
Statement statement = connection.createStatement();
|
||||
statement.execute(sql);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
package org.springframework.samples.petclinic.hibernate;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.samples.petclinic.Vet;
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Hibernate implementation of the Clinic interface.
|
||||
*
|
||||
* <p>The mappings are defined in "petclinic.hbm.xml", located in the root of the
|
||||
* class path.
|
||||
*
|
||||
* <p>Note that transactions are declared with annotations and that some methods
|
||||
* contain "readOnly = true" which is an optimization that is particularly
|
||||
* valuable when using Hibernate (to suppress unnecessary flush attempts for
|
||||
* read-only operations).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @author Mark Fisher
|
||||
* @since 19.10.2003
|
||||
*/
|
||||
@Repository
|
||||
@Transactional
|
||||
public class HibernateClinic implements Clinic {
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Autowired
|
||||
public HibernateClinic(SessionFactory sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<Vet> getVets() {
|
||||
return sessionFactory.getCurrentSession().createQuery("from Vet vet order by vet.lastName, vet.firstName").list();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<PetType> getPetTypes() {
|
||||
return sessionFactory.getCurrentSession().createQuery("from PetType type order by type.name").list();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<Owner> findOwners(String lastName) {
|
||||
return sessionFactory.getCurrentSession().createQuery("from Owner owner where owner.lastName like :lastName")
|
||||
.setString("lastName", lastName + "%").list();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Owner loadOwner(int id) {
|
||||
return (Owner) sessionFactory.getCurrentSession().load(Owner.class, id);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Pet loadPet(int id) {
|
||||
return (Pet) sessionFactory.getCurrentSession().load(Pet.class, id);
|
||||
}
|
||||
|
||||
public void storeOwner(Owner owner) {
|
||||
// Note: Hibernate3's merge operation does not reassociate the object
|
||||
// with the current Hibernate Session. Instead, it will always copy the
|
||||
// state over to a registered representation of the entity. In case of a
|
||||
// new entity, it will register a copy as well, but will not update the
|
||||
// id of the passed-in object. To still update the ids of the original
|
||||
// objects too, we need to register Spring's
|
||||
// IdTransferringMergeEventListener on our SessionFactory.
|
||||
sessionFactory.getCurrentSession().merge(owner);
|
||||
}
|
||||
|
||||
public void storePet(Pet pet) {
|
||||
sessionFactory.getCurrentSession().merge(pet);
|
||||
}
|
||||
|
||||
public void storeVisit(Visit visit) {
|
||||
sessionFactory.getCurrentSession().merge(visit);
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
Pet pet = loadPet(id);
|
||||
sessionFactory.getCurrentSession().delete(pet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package represent the Hibernate implementation
|
||||
* of PetClinic's persistence layer.
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic.hibernate;
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
package org.springframework.samples.petclinic.jdbc;
|
||||
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
|
||||
/**
|
||||
* Subclass of Pet that carries temporary id properties which
|
||||
* are only relevant for a JDBC implmentation of the Clinic.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @see SimpleJdbcClinic
|
||||
*/
|
||||
class JdbcPet extends Pet {
|
||||
|
||||
private int typeId;
|
||||
|
||||
private int ownerId;
|
||||
|
||||
|
||||
public void setTypeId(int typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public int getTypeId() {
|
||||
return this.typeId;
|
||||
}
|
||||
|
||||
public void setOwnerId(int ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
public int getOwnerId() {
|
||||
return this.ownerId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,342 +0,0 @@
|
|||
package org.springframework.samples.petclinic.jdbc;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.orm.ObjectRetrievalFailureException;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.samples.petclinic.Specialty;
|
||||
import org.springframework.samples.petclinic.Vet;
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.samples.petclinic.util.EntityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* A simple JDBC-based implementation of the {@link Clinic} interface.
|
||||
*
|
||||
* <p>This class uses Java 5 language features and the {@link SimpleJdbcTemplate}
|
||||
* plus {@link SimpleJdbcInsert}. It also takes advantage of classes like
|
||||
* {@link BeanPropertySqlParameterSource} and
|
||||
* {@link ParameterizedBeanPropertyRowMapper} which provide automatic mapping
|
||||
* between JavaBean properties and JDBC parameters or query results.
|
||||
*
|
||||
* <p>SimpleJdbcClinic is a rewrite of the AbstractJdbcClinic which was the base
|
||||
* class for JDBC implementations of the Clinic interface for Spring 2.0.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Rob Harrop
|
||||
* @author Sam Brannen
|
||||
* @author Thomas Risberg
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@Service
|
||||
@ManagedResource("petclinic:type=Clinic")
|
||||
public class SimpleJdbcClinic implements Clinic, SimpleJdbcClinicMBean {
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SimpleJdbcTemplate simpleJdbcTemplate;
|
||||
|
||||
private SimpleJdbcInsert insertOwner;
|
||||
private SimpleJdbcInsert insertPet;
|
||||
private SimpleJdbcInsert insertVisit;
|
||||
|
||||
private final List<Vet> vets = new ArrayList<Vet>();
|
||||
|
||||
|
||||
@Autowired
|
||||
public void init(DataSource dataSource) {
|
||||
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
|
||||
this.insertOwner = new SimpleJdbcInsert(dataSource)
|
||||
.withTableName("owners")
|
||||
.usingGeneratedKeyColumns("id");
|
||||
this.insertPet = new SimpleJdbcInsert(dataSource)
|
||||
.withTableName("pets")
|
||||
.usingGeneratedKeyColumns("id");
|
||||
this.insertVisit = new SimpleJdbcInsert(dataSource)
|
||||
.withTableName("visits")
|
||||
.usingGeneratedKeyColumns("id");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// START of Clinic implementation section *******************************
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Collection<Vet> getVets() throws DataAccessException {
|
||||
synchronized (this.vets) {
|
||||
if (this.vets.isEmpty()) {
|
||||
refreshVetsCache();
|
||||
}
|
||||
return this.vets;
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Collection<PetType> getPetTypes() throws DataAccessException {
|
||||
return this.simpleJdbcTemplate.query(
|
||||
"SELECT id, name FROM types ORDER BY name",
|
||||
ParameterizedBeanPropertyRowMapper.newInstance(PetType.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads {@link Owner Owners} from the data store by last name, returning
|
||||
* all owners whose last name <i>starts</i> with the given name; also loads
|
||||
* the {@link Pet Pets} and {@link Visit Visits} for the corresponding
|
||||
* owners, if not already loaded.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Collection<Owner> findOwners(String lastName) throws DataAccessException {
|
||||
List<Owner> owners = this.simpleJdbcTemplate.query(
|
||||
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like ?",
|
||||
ParameterizedBeanPropertyRowMapper.newInstance(Owner.class),
|
||||
lastName + "%");
|
||||
loadOwnersPetsAndVisits(owners);
|
||||
return owners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the {@link Owner} with the supplied <code>id</code>; also loads
|
||||
* the {@link Pet Pets} and {@link Visit Visits} for the corresponding
|
||||
* owner, if not already loaded.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Owner loadOwner(int id) throws DataAccessException {
|
||||
Owner owner;
|
||||
try {
|
||||
owner = this.simpleJdbcTemplate.queryForObject(
|
||||
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id=?",
|
||||
ParameterizedBeanPropertyRowMapper.newInstance(Owner.class),
|
||||
id);
|
||||
}
|
||||
catch (EmptyResultDataAccessException ex) {
|
||||
throw new ObjectRetrievalFailureException(Owner.class, new Integer(id));
|
||||
}
|
||||
loadPetsAndVisits(owner);
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Pet loadPet(int id) throws DataAccessException {
|
||||
JdbcPet pet;
|
||||
try {
|
||||
pet = this.simpleJdbcTemplate.queryForObject(
|
||||
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=?",
|
||||
new JdbcPetRowMapper(),
|
||||
id);
|
||||
}
|
||||
catch (EmptyResultDataAccessException ex) {
|
||||
throw new ObjectRetrievalFailureException(Pet.class, new Integer(id));
|
||||
}
|
||||
Owner owner = loadOwner(pet.getOwnerId());
|
||||
owner.addPet(pet);
|
||||
pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
|
||||
loadVisits(pet);
|
||||
return pet;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void storeOwner(Owner owner) throws DataAccessException {
|
||||
if (owner.isNew()) {
|
||||
Number newKey = this.insertOwner.executeAndReturnKey(
|
||||
new BeanPropertySqlParameterSource(owner));
|
||||
owner.setId(newKey.intValue());
|
||||
}
|
||||
else {
|
||||
this.simpleJdbcTemplate.update(
|
||||
"UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, " +
|
||||
"city=:city, telephone=:telephone WHERE id=:id",
|
||||
new BeanPropertySqlParameterSource(owner));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void storePet(Pet pet) throws DataAccessException {
|
||||
if (pet.isNew()) {
|
||||
Number newKey = this.insertPet.executeAndReturnKey(
|
||||
createPetParameterSource(pet));
|
||||
pet.setId(newKey.intValue());
|
||||
}
|
||||
else {
|
||||
this.simpleJdbcTemplate.update(
|
||||
"UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
|
||||
"owner_id=:owner_id WHERE id=:id",
|
||||
createPetParameterSource(pet));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void storeVisit(Visit visit) throws DataAccessException {
|
||||
if (visit.isNew()) {
|
||||
Number newKey = this.insertVisit.executeAndReturnKey(
|
||||
createVisitParameterSource(visit));
|
||||
visit.setId(newKey.intValue());
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("Visit update not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
this.simpleJdbcTemplate.update("DELETE FROM pets WHERE id=?", id);
|
||||
}
|
||||
|
||||
// END of Clinic implementation section ************************************
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link MapSqlParameterSource} based on data values from the
|
||||
* supplied {@link Pet} instance.
|
||||
*/
|
||||
private MapSqlParameterSource createPetParameterSource(Pet pet) {
|
||||
return new MapSqlParameterSource()
|
||||
.addValue("id", pet.getId())
|
||||
.addValue("name", pet.getName())
|
||||
.addValue("birth_date", pet.getBirthDate())
|
||||
.addValue("type_id", pet.getType().getId())
|
||||
.addValue("owner_id", pet.getOwner().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link MapSqlParameterSource} based on data values from the
|
||||
* supplied {@link Visit} instance.
|
||||
*/
|
||||
private MapSqlParameterSource createVisitParameterSource(Visit visit) {
|
||||
return new MapSqlParameterSource()
|
||||
.addValue("id", visit.getId())
|
||||
.addValue("visit_date", visit.getDate())
|
||||
.addValue("description", visit.getDescription())
|
||||
.addValue("pet_id", visit.getPet().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the {@link Visit} data for the supplied {@link Pet}.
|
||||
*/
|
||||
private void loadVisits(JdbcPet pet) {
|
||||
final List<Visit> visits = this.simpleJdbcTemplate.query(
|
||||
"SELECT id, visit_date, description FROM visits WHERE pet_id=?",
|
||||
new ParameterizedRowMapper<Visit>() {
|
||||
public Visit mapRow(ResultSet rs, int row) throws SQLException {
|
||||
Visit visit = new Visit();
|
||||
visit.setId(rs.getInt("id"));
|
||||
visit.setDate(rs.getTimestamp("visit_date"));
|
||||
visit.setDescription(rs.getString("description"));
|
||||
return visit;
|
||||
}
|
||||
},
|
||||
pet.getId().intValue());
|
||||
for (Visit visit : visits) {
|
||||
pet.addVisit(visit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the {@link Pet} and {@link Visit} data for the supplied
|
||||
* {@link Owner}.
|
||||
*/
|
||||
private void loadPetsAndVisits(final Owner owner) {
|
||||
final List<JdbcPet> pets = this.simpleJdbcTemplate.query(
|
||||
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE owner_id=?",
|
||||
new JdbcPetRowMapper(),
|
||||
owner.getId().intValue());
|
||||
for (JdbcPet pet : pets) {
|
||||
owner.addPet(pet);
|
||||
pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
|
||||
loadVisits(pet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the {@link Pet} and {@link Visit} data for the supplied
|
||||
* {@link List} of {@link Owner Owners}.
|
||||
*
|
||||
* @param owners the list of owners for whom the pet and visit data should be loaded
|
||||
* @see #loadPetsAndVisits(Owner)
|
||||
*/
|
||||
private void loadOwnersPetsAndVisits(List<Owner> owners) {
|
||||
for (Owner owner : owners) {
|
||||
loadPetsAndVisits(owner);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ParameterizedRowMapper} implementation mapping data from a
|
||||
* {@link ResultSet} to the corresponding properties of the {@link JdbcPet} class.
|
||||
*/
|
||||
private class JdbcPetRowMapper implements ParameterizedRowMapper<JdbcPet> {
|
||||
|
||||
public JdbcPet mapRow(ResultSet rs, int rownum) throws SQLException {
|
||||
JdbcPet pet = new JdbcPet();
|
||||
pet.setId(rs.getInt("id"));
|
||||
pet.setName(rs.getString("name"));
|
||||
pet.setBirthDate(rs.getDate("birth_date"));
|
||||
pet.setTypeId(rs.getInt("type_id"));
|
||||
pet.setOwnerId(rs.getInt("owner_id"));
|
||||
return pet;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package org.springframework.samples.petclinic.jdbc;
|
||||
|
||||
/**
|
||||
* Interface that defines a cache refresh operation.
|
||||
* To be exposed for management via JMX.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @see SimpleJdbcClinic
|
||||
*/
|
||||
public interface SimpleJdbcClinicMBean {
|
||||
|
||||
/**
|
||||
* Refresh the cache of Vets that the Clinic is holding.
|
||||
* @see org.springframework.samples.petclinic.Clinic#getVets()
|
||||
* @see SimpleJdbcClinic#refreshVetsCache()
|
||||
*/
|
||||
void refreshVetsCache();
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package represent the JDBC implementation
|
||||
* of PetClinic's persistence layer.
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic.jdbc;
|
||||
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
package org.springframework.samples.petclinic.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.samples.petclinic.Vet;
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* JPA implementation of the Clinic interface using EntityManager.
|
||||
*
|
||||
* <p>The mappings are defined in "orm.xml" located in the META-INF directory.
|
||||
*
|
||||
* @author Mike Keith
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @since 22.4.2006
|
||||
*/
|
||||
@Repository
|
||||
@Transactional
|
||||
public class EntityManagerClinic implements Clinic {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<PetType> getPetTypes() {
|
||||
return this.em.createQuery("SELECT ptype FROM PetType ptype ORDER BY ptype.name").getResultList();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<Owner> findOwners(String lastName) {
|
||||
Query query = this.em.createQuery("SELECT owner FROM Owner owner WHERE owner.lastName LIKE :lastName");
|
||||
query.setParameter("lastName", lastName + "%");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Owner loadOwner(int id) {
|
||||
return this.em.find(Owner.class, id);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Pet loadPet(int id) {
|
||||
return this.em.find(Pet.class, id);
|
||||
}
|
||||
|
||||
public void storeOwner(Owner owner) {
|
||||
// Consider returning the persistent object here, for exposing
|
||||
// a newly assigned id using any persistence provider...
|
||||
Owner merged = this.em.merge(owner);
|
||||
this.em.flush();
|
||||
owner.setId(merged.getId());
|
||||
}
|
||||
|
||||
public void storePet(Pet pet) {
|
||||
// Consider returning the persistent object here, for exposing
|
||||
// a newly assigned id using any persistence provider...
|
||||
Pet merged = this.em.merge(pet);
|
||||
this.em.flush();
|
||||
pet.setId(merged.getId());
|
||||
}
|
||||
|
||||
public void storeVisit(Visit visit) {
|
||||
// Consider returning the persistent object here, for exposing
|
||||
// a newly assigned id using any persistence provider...
|
||||
Visit merged = this.em.merge(visit);
|
||||
this.em.flush();
|
||||
visit.setId(merged.getId());
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
Pet pet = loadPet(id);
|
||||
this.em.remove(pet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package represent the JPA implementation
|
||||
* of PetClinic's persistence layer.
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic.jpa;
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package represent PetClinic's business layer.
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic;
|
||||
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
package org.springframework.samples.petclinic.toplink;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import oracle.toplink.essentials.exceptions.ValidationException;
|
||||
import oracle.toplink.essentials.platform.database.HSQLPlatform;
|
||||
import oracle.toplink.essentials.queryframework.ValueReadQuery;
|
||||
|
||||
/**
|
||||
* Subclass of the TopLink Essentials default HSQLPlatform class, using native
|
||||
* HSQLDB identity columns for id generation.
|
||||
*
|
||||
* <p>Necessary for PetClinic's default data model, which relies on identity
|
||||
* columns: this is uniformly used across all persistence layer implementations
|
||||
* (JDBC, Hibernate, and JPA).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author <a href="mailto:james.x.clark@oracle.com">James Clark</a>
|
||||
* @since 1.2
|
||||
*/
|
||||
public class EssentialsHSQLPlatformWithNativeSequence extends HSQLPlatform {
|
||||
|
||||
private static final long serialVersionUID = -55658009691346735L;
|
||||
|
||||
|
||||
public EssentialsHSQLPlatformWithNativeSequence() {
|
||||
// setUsesNativeSequencing(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsNativeSequenceNumbers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldNativeSequenceAcquireValueAfterInsert() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueReadQuery buildSelectQueryForNativeSequence() {
|
||||
return new ValueReadQuery("CALL IDENTITY()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printFieldIdentityClause(Writer writer) throws ValidationException {
|
||||
try {
|
||||
writer.write(" IDENTITY");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw ValidationException.fileError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package provide support for using the TopLink
|
||||
* implementation with PetClinic's EntityManagerClinic.
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic.toplink;
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.orm.ObjectRetrievalFailureException;
|
||||
import org.springframework.samples.petclinic.BaseEntity;
|
||||
|
||||
/**
|
||||
* Utility methods for handling entities. Separate from the BaseEntity class
|
||||
* mainly because of dependency on the ORM-associated
|
||||
* ObjectRetrievalFailureException.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 29.10.2003
|
||||
* @see org.springframework.samples.petclinic.BaseEntity
|
||||
*/
|
||||
public abstract class EntityUtils {
|
||||
|
||||
/**
|
||||
* Look up the entity of the given class with the given id in the given
|
||||
* collection.
|
||||
*
|
||||
* @param entities the collection to search
|
||||
* @param entityClass the entity class to look up
|
||||
* @param entityId the entity id to look up
|
||||
* @return the found entity
|
||||
* @throws ObjectRetrievalFailureException if the entity was not found
|
||||
*/
|
||||
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
|
||||
throws ObjectRetrievalFailureException {
|
||||
for (T entity : entities) {
|
||||
if (entity.getId().intValue() == entityId && entityClass.isInstance(entity)) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
throw new ObjectRetrievalFailureException(entityClass, new Integer(entityId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
package org.springframework.samples.petclinic.validation;
|
||||
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
/**
|
||||
* <code>Validator</code> for <code>Owner</code> forms.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class OwnerValidator {
|
||||
|
||||
public void validate(Owner owner, Errors errors) {
|
||||
if (!StringUtils.hasLength(owner.getFirstName())) {
|
||||
errors.rejectValue("firstName", "required", "required");
|
||||
}
|
||||
if (!StringUtils.hasLength(owner.getLastName())) {
|
||||
errors.rejectValue("lastName", "required", "required");
|
||||
}
|
||||
if (!StringUtils.hasLength(owner.getAddress())) {
|
||||
errors.rejectValue("address", "required", "required");
|
||||
}
|
||||
if (!StringUtils.hasLength(owner.getCity())) {
|
||||
errors.rejectValue("city", "required", "required");
|
||||
}
|
||||
|
||||
String telephone = owner.getTelephone();
|
||||
if (!StringUtils.hasLength(telephone)) {
|
||||
errors.rejectValue("telephone", "required", "required");
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < telephone.length(); ++i) {
|
||||
if ((Character.isDigit(telephone.charAt(i))) == false) {
|
||||
errors.rejectValue("telephone", "nonNumeric", "non-numeric");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package org.springframework.samples.petclinic.validation;
|
||||
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
/**
|
||||
* <code>Validator</code> for <code>Pet</code> forms.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class PetValidator {
|
||||
|
||||
public void validate(Pet pet, Errors errors) {
|
||||
String name = pet.getName();
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
errors.rejectValue("name", "required", "required");
|
||||
}
|
||||
else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) {
|
||||
errors.rejectValue("name", "duplicate", "already exists");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package org.springframework.samples.petclinic.validation;
|
||||
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
/**
|
||||
* <code>Validator</code> for <code>Visit</code> forms.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class VisitValidator {
|
||||
|
||||
public void validate(Visit visit, Errors errors) {
|
||||
if (!StringUtils.hasLength(visit.getDescription())) {
|
||||
errors.rejectValue("description", "required", "required");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package represent the set of Validator objects
|
||||
* the Business Layer makes available to the Presentation Layer.
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic.validation;
|
||||
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.validation.OwnerValidator;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
|
||||
/**
|
||||
* JavaBean form controller that is used to add a new <code>Owner</code> to the
|
||||
* system.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/new")
|
||||
@SessionAttributes(types = Owner.class)
|
||||
public class AddOwnerForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public AddOwnerForm(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(Model model) {
|
||||
Owner owner = new Owner();
|
||||
model.addAttribute(owner);
|
||||
return "owners/form";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String processSubmit(@ModelAttribute Owner owner, BindingResult result, SessionStatus status) {
|
||||
new OwnerValidator().validate(owner, result);
|
||||
if (result.hasErrors()) {
|
||||
return "owners/form";
|
||||
}
|
||||
else {
|
||||
this.clinic.storeOwner(owner);
|
||||
status.setComplete();
|
||||
return "redirect:/owners/" + owner.getId();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.samples.petclinic.validation.PetValidator;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
|
||||
/**
|
||||
* JavaBean form controller that is used to add a new <code>Pet</code> to the
|
||||
* system.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/{ownerId}/pets/new")
|
||||
@SessionAttributes("pet")
|
||||
public class AddPetForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public AddPetForm(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@ModelAttribute("types")
|
||||
public Collection<PetType> populatePetTypes() {
|
||||
return this.clinic.getPetTypes();
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
Owner owner = this.clinic.loadOwner(ownerId);
|
||||
Pet pet = new Pet();
|
||||
owner.addPet(pet);
|
||||
model.addAttribute("pet", pet);
|
||||
return "pets/form";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String processSubmit(@ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) {
|
||||
new PetValidator().validate(pet, result);
|
||||
if (result.hasErrors()) {
|
||||
return "pets/form";
|
||||
}
|
||||
else {
|
||||
this.clinic.storePet(pet);
|
||||
status.setComplete();
|
||||
return "redirect:/owners/" + pet.getOwner().getId();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.samples.petclinic.validation.VisitValidator;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
|
||||
/**
|
||||
* JavaBean form controller that is used to add a new <code>Visit</code> to the
|
||||
* system.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/*/pets/{petId}/visits/new")
|
||||
@SessionAttributes("visit")
|
||||
public class AddVisitForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public AddVisitForm(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@PathVariable("petId") int petId, Model model) {
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
Visit visit = new Visit();
|
||||
pet.addVisit(visit);
|
||||
model.addAttribute("visit", visit);
|
||||
return "pets/visitForm";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String processSubmit(@ModelAttribute("visit") Visit visit, BindingResult result, SessionStatus status) {
|
||||
new VisitValidator().validate(visit, result);
|
||||
if (result.hasErrors()) {
|
||||
return "pets/visitForm";
|
||||
}
|
||||
else {
|
||||
this.clinic.storeVisit(visit);
|
||||
status.setComplete();
|
||||
return "redirect:/owners/" + visit.getPet().getOwner().getId();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.support.WebBindingInitializer;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
/**
|
||||
* Shared WebBindingInitializer for PetClinic's custom editors.
|
||||
*
|
||||
* <p>Alternatively, such init-binder code may be put into
|
||||
* {@link org.springframework.web.bind.annotation.InitBinder}
|
||||
* annotated methods on the controller classes themselves.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class ClinicBindingInitializer implements WebBindingInitializer {
|
||||
|
||||
@Autowired
|
||||
private Clinic clinic;
|
||||
|
||||
public void initBinder(WebDataBinder binder, WebRequest request) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
|
||||
binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
|
||||
binder.registerCustomEditor(PetType.class, new PetTypeEditor(this.clinic));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Vets;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* Annotation-driven <em>MultiActionController</em> that handles all non-form
|
||||
* URL's.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Mark Fisher
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
public class ClinicController {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public ClinicController(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom handler for the welcome view.
|
||||
* <p>
|
||||
* Note that this handler relies on the RequestToViewNameTranslator to
|
||||
* determine the logical view name based on the request URL: "/welcome.do"
|
||||
* -> "welcome".
|
||||
*/
|
||||
@RequestMapping("/")
|
||||
public String welcomeHandler() {
|
||||
return "welcome";
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom handler for displaying vets.
|
||||
*
|
||||
* <p>Note that this handler returns a plain {@link ModelMap} object instead of
|
||||
* a ModelAndView, thus leveraging convention-based model attribute names.
|
||||
* It relies on the RequestToViewNameTranslator to determine the logical
|
||||
* view name based on the request URL: "/vets.do" -> "vets".
|
||||
*
|
||||
* @return a ModelMap with the model attributes for the view
|
||||
*/
|
||||
@RequestMapping("/vets")
|
||||
public ModelMap vetsHandler() {
|
||||
Vets vets = new Vets();
|
||||
vets.getVetList().addAll(this.clinic.getVets());
|
||||
return new ModelMap(vets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom handler for displaying an owner.
|
||||
*
|
||||
* @param ownerId the ID of the owner to display
|
||||
* @return a ModelMap with the model attributes for the view
|
||||
*/
|
||||
@RequestMapping("/owners/{ownerId}")
|
||||
public ModelAndView ownerHandler(@PathVariable("ownerId") int ownerId) {
|
||||
ModelAndView mav = new ModelAndView("owners/show");
|
||||
mav.addObject(this.clinic.loadOwner(ownerId));
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom handler for displaying an list of visits.
|
||||
*
|
||||
* @param petId the ID of the pet whose visits to display
|
||||
* @return a ModelMap with the model attributes for the view
|
||||
*/
|
||||
@RequestMapping(value="/owners/*/pets/{petId}/visits", method=RequestMethod.GET)
|
||||
public ModelAndView visitsHandler(@PathVariable int petId) {
|
||||
ModelAndView mav = new ModelAndView("visits");
|
||||
mav.addObject("visits", this.clinic.loadPet(petId).getVisits());
|
||||
return mav;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.validation.OwnerValidator;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
|
||||
/**
|
||||
* JavaBean Form controller that is used to edit an existing <code>Owner</code>.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/{ownerId}/edit")
|
||||
@SessionAttributes(types = Owner.class)
|
||||
public class EditOwnerForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public EditOwnerForm(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
Owner owner = this.clinic.loadOwner(ownerId);
|
||||
model.addAttribute(owner);
|
||||
return "owners/form";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT)
|
||||
public String processSubmit(@ModelAttribute Owner owner, BindingResult result, SessionStatus status) {
|
||||
new OwnerValidator().validate(owner, result);
|
||||
if (result.hasErrors()) {
|
||||
return "owners/form";
|
||||
}
|
||||
else {
|
||||
this.clinic.storeOwner(owner);
|
||||
status.setComplete();
|
||||
return "redirect:/owners/" + owner.getId();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.samples.petclinic.validation.PetValidator;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
|
||||
/**
|
||||
* JavaBean Form controller that is used to edit an existing <code>Pet</code>.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/*/pets/{petId}/edit")
|
||||
@SessionAttributes("pet")
|
||||
public class EditPetForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public EditPetForm(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@ModelAttribute("types")
|
||||
public Collection<PetType> populatePetTypes() {
|
||||
return this.clinic.getPetTypes();
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@PathVariable("petId") int petId, Model model) {
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
model.addAttribute("pet", pet);
|
||||
return "pets/form";
|
||||
}
|
||||
|
||||
@RequestMapping(method = { RequestMethod.PUT, RequestMethod.POST })
|
||||
public String processSubmit(@ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) {
|
||||
new PetValidator().validate(pet, result);
|
||||
if (result.hasErrors()) {
|
||||
return "pets/form";
|
||||
}
|
||||
else {
|
||||
this.clinic.storePet(pet);
|
||||
status.setComplete();
|
||||
return "redirect:/owners/" + pet.getOwner().getId();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE)
|
||||
public String deletePet(@PathVariable int petId) {
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
this.clinic.deletePet(petId);
|
||||
return "redirect:/owners/" + pet.getOwner().getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
/**
|
||||
* JavaBean Form controller that is used to search for <code>Owner</code>s by
|
||||
* last name.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
public class FindOwnersForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
@Autowired
|
||||
public FindOwnersForm(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/owners/search", method = RequestMethod.GET)
|
||||
public String setupForm(Model model) {
|
||||
model.addAttribute("owner", new Owner());
|
||||
return "owners/search";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/owners", method = RequestMethod.GET)
|
||||
public String processSubmit(Owner owner, BindingResult result, Model model) {
|
||||
|
||||
// allow parameterless GET request for /owners to return all records
|
||||
if (owner.getLastName() == null) {
|
||||
owner.setLastName(""); // empty string signifies broadest possible search
|
||||
}
|
||||
|
||||
// find owners by last name
|
||||
Collection<Owner> results = this.clinic.findOwners(owner.getLastName());
|
||||
if (results.size() < 1) {
|
||||
// no owners found
|
||||
result.rejectValue("lastName", "notFound", "not found");
|
||||
return "owners/search";
|
||||
}
|
||||
if (results.size() > 1) {
|
||||
// multiple owners found
|
||||
model.addAttribute("selections", results);
|
||||
return "owners/list";
|
||||
}
|
||||
else {
|
||||
// 1 owner found
|
||||
owner = results.iterator().next();
|
||||
return "redirect:/owners/" + owner.getId();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class PetTypeEditor extends PropertyEditorSupport {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
||||
|
||||
public PetTypeEditor(Clinic clinic) {
|
||||
this.clinic = clinic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
for (PetType type : this.clinic.getPetTypes()) {
|
||||
if (type.getName().equals(text)) {
|
||||
setValue(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.sun.syndication.feed.atom.Content;
|
||||
import com.sun.syndication.feed.atom.Entry;
|
||||
import com.sun.syndication.feed.atom.Feed;
|
||||
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.web.servlet.view.feed.AbstractAtomFeedView;
|
||||
|
||||
/**
|
||||
* A view creating a Atom representation from a list of Visit objects.
|
||||
*
|
||||
* @author Alef Arendsen
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class VisitsAtomView extends AbstractAtomFeedView {
|
||||
|
||||
@Override
|
||||
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
|
||||
feed.setId("tag:springsource.com");
|
||||
feed.setTitle("Pet Clinic Visits");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Visit> visits = (List<Visit>) model.get("visits");
|
||||
for (Visit visit : visits) {
|
||||
Date date = visit.getDate();
|
||||
if (feed.getUpdated() == null || date.compareTo(feed.getUpdated()) > 0) {
|
||||
feed.setUpdated(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Entry> buildFeedEntries(Map<String, Object> model,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Visit> visits = (List<Visit>) model.get("visits");
|
||||
List<Entry> entries = new ArrayList<Entry>(visits.size());
|
||||
|
||||
for (Visit visit : visits) {
|
||||
Entry entry = new Entry();
|
||||
String date = String.format("%1$tY-%1$tm-%1$td", visit.getDate());
|
||||
// see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
|
||||
entry.setId(String.format("tag:springsource.com,%s:%d", date, visit.getId()));
|
||||
entry.setTitle(String.format("%s visit on %s", visit.getPet().getName(), date));
|
||||
entry.setUpdated(visit.getDate());
|
||||
|
||||
Content summary = new Content();
|
||||
summary.setValue(visit.getDescription());
|
||||
entry.setSummary(summary);
|
||||
|
||||
entries.add(entry);
|
||||
}
|
||||
|
||||
return entries;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* The classes in this package represent PetClinic's web presentation layer.
|
||||
*
|
||||
*/
|
||||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
<p>
|
||||
The Spring Data Binding framework, an internal library used by Spring Web Flow.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Custom aspects for the PetClinic sample application -->
|
||||
<aspectj>
|
||||
|
||||
<weaver>
|
||||
<include within="org.springframework.samples.petclinic..*"/>
|
||||
</weaver>
|
||||
|
||||
<aspects>
|
||||
<aspect name="org.springframework.samples.petclinic.aspects.UsageLogAspect"/>
|
||||
<concrete-aspect name="org.springframework.samples.petclinic.aspects.ApplicationTraceAspect"
|
||||
extends="org.springframework.samples.petclinic.aspects.AbstractTraceAspect">
|
||||
<pointcut name="traced" expression="execution(* org.springframework.samples..*.*(..))"/>
|
||||
</concrete-aspect>
|
||||
</aspects>
|
||||
|
||||
</aspectj>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
DROP TABLE visits;
|
||||
DROP TABLE pets;
|
||||
DROP TABLE owners;
|
||||
DROP TABLE types;
|
||||
DROP TABLE vet_specialties;
|
||||
DROP TABLE specialties;
|
||||
DROP TABLE vets;
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
CREATE TABLE vets (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30)
|
||||
);
|
||||
CREATE INDEX vets_last_name ON vets(last_name);
|
||||
|
||||
CREATE TABLE specialties (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(80)
|
||||
);
|
||||
CREATE INDEX specialties_name ON specialties(name);
|
||||
|
||||
CREATE TABLE vet_specialties (
|
||||
vet_id INTEGER NOT NULL,
|
||||
specialty_id INTEGER NOT NULL
|
||||
);
|
||||
alter table vet_specialties add constraint fk_vet_specialties_vets foreign key (vet_id) references vets(id);
|
||||
alter table vet_specialties add constraint fk_vet_specialties_specialties foreign key (specialty_id) references specialties(id);
|
||||
|
||||
CREATE TABLE types (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(80)
|
||||
);
|
||||
CREATE INDEX types_name ON types(name);
|
||||
|
||||
CREATE TABLE owners (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30),
|
||||
address VARCHAR(255),
|
||||
city VARCHAR(80),
|
||||
telephone VARCHAR(20)
|
||||
);
|
||||
CREATE INDEX owners_last_name ON owners(last_name);
|
||||
|
||||
CREATE TABLE pets (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(30),
|
||||
birth_date DATE,
|
||||
type_id INTEGER NOT NULL,
|
||||
owner_id INTEGER NOT NULL
|
||||
);
|
||||
alter table pets add constraint fk_pets_owners foreign key (owner_id) references owners(id);
|
||||
alter table pets add constraint fk_pets_types foreign key (type_id) references types(id);
|
||||
CREATE INDEX pets_name ON pets(name);
|
||||
|
||||
CREATE TABLE visits (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
pet_id INTEGER NOT NULL,
|
||||
visit_date DATE,
|
||||
description VARCHAR(255)
|
||||
);
|
||||
alter table visits add constraint fk_visits_pets foreign key (pet_id) references pets(id);
|
||||
CREATE INDEX visits_pet_id ON visits(pet_id);
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
INSERT INTO vets VALUES (1, 'James', 'Carter');
|
||||
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
|
||||
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
|
||||
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
|
||||
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
|
||||
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
|
||||
|
||||
INSERT INTO specialties VALUES (1, 'radiology');
|
||||
INSERT INTO specialties VALUES (2, 'surgery');
|
||||
INSERT INTO specialties VALUES (3, 'dentistry');
|
||||
|
||||
INSERT INTO vet_specialties VALUES (2, 1);
|
||||
INSERT INTO vet_specialties VALUES (3, 2);
|
||||
INSERT INTO vet_specialties VALUES (3, 3);
|
||||
INSERT INTO vet_specialties VALUES (4, 2);
|
||||
INSERT INTO vet_specialties VALUES (5, 1);
|
||||
|
||||
INSERT INTO types VALUES (1, 'cat');
|
||||
INSERT INTO types VALUES (2, 'dog');
|
||||
INSERT INTO types VALUES (3, 'lizard');
|
||||
INSERT INTO types VALUES (4, 'snake');
|
||||
INSERT INTO types VALUES (5, 'bird');
|
||||
INSERT INTO types VALUES (6, 'hamster');
|
||||
|
||||
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
|
||||
INSERT INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1);
|
||||
INSERT INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);
|
||||
INSERT INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3);
|
||||
INSERT INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3);
|
||||
INSERT INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4);
|
||||
INSERT INTO pets VALUES (6, 'George', '2000-01-20', 4, 5);
|
||||
INSERT INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6);
|
||||
INSERT INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6);
|
||||
INSERT INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7);
|
||||
INSERT INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8);
|
||||
INSERT INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9);
|
||||
INSERT INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10);
|
||||
INSERT INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10);
|
||||
|
||||
INSERT INTO visits VALUES (1, 7, '1996-03-04', 'rabies shot');
|
||||
INSERT INTO visits VALUES (2, 8, '1996-03-04', 'rabies shot');
|
||||
INSERT INTO visits VALUES (3, 8, '1996-06-04', 'neutered');
|
||||
INSERT INTO visits VALUES (4, 7, '1996-09-04', 'spayed');
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
|
||||
version="1.0">
|
||||
|
||||
<persistence-unit-metadata>
|
||||
<xml-mapping-metadata-complete/>
|
||||
<persistence-unit-defaults>
|
||||
<access>PROPERTY</access>
|
||||
</persistence-unit-defaults>
|
||||
</persistence-unit-metadata>
|
||||
|
||||
<package>org.springframework.samples.petclinic</package>
|
||||
|
||||
<mapped-superclass class="BaseEntity">
|
||||
<attributes>
|
||||
<id name="id">
|
||||
<generated-value strategy="IDENTITY"/>
|
||||
</id>
|
||||
<transient name="new"/>
|
||||
</attributes>
|
||||
</mapped-superclass>
|
||||
|
||||
<mapped-superclass class="NamedEntity">
|
||||
<attributes>
|
||||
<basic name="name">
|
||||
<column name="NAME"/>
|
||||
</basic>
|
||||
</attributes>
|
||||
</mapped-superclass>
|
||||
|
||||
<mapped-superclass class="Person">
|
||||
<attributes>
|
||||
<basic name="firstName">
|
||||
<column name="FIRST_NAME"/>
|
||||
</basic>
|
||||
<basic name="lastName">
|
||||
<column name="LAST_NAME"/>
|
||||
</basic>
|
||||
</attributes>
|
||||
</mapped-superclass>
|
||||
|
||||
<entity class="Vet">
|
||||
<table name="VETS"/>
|
||||
<attributes>
|
||||
<many-to-many name="specialtiesInternal" target-entity="Specialty" fetch="EAGER">
|
||||
<join-table name="VET_SPECIALTIES">
|
||||
<join-column name="VET_ID"/>
|
||||
<inverse-join-column name="SPECIALTY_ID"/>
|
||||
</join-table>
|
||||
</many-to-many>
|
||||
<transient name="specialties"/>
|
||||
<transient name="nrOfSpecialties"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
<entity class="Specialty">
|
||||
<table name="SPECIALTIES"/>
|
||||
</entity>
|
||||
|
||||
<entity class="Owner">
|
||||
<table name="OWNERS"/>
|
||||
<attributes>
|
||||
<basic name="address"/>
|
||||
<basic name="city"/>
|
||||
<basic name="telephone"/>
|
||||
<one-to-many name="petsInternal" target-entity="Pet" mapped-by="owner" fetch="EAGER">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
</one-to-many>
|
||||
<transient name="pets"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
<entity class="Pet">
|
||||
<table name="PETS"/>
|
||||
<attributes>
|
||||
<basic name="birthDate">
|
||||
<column name="BIRTH_DATE"/>
|
||||
<temporal>DATE</temporal>
|
||||
</basic>
|
||||
<many-to-one name="owner" fetch="EAGER">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
</many-to-one>
|
||||
<many-to-one name="type" fetch="EAGER">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
</many-to-one>
|
||||
<one-to-many name="visitsInternal" target-entity="Visit" mapped-by="pet" fetch="EAGER">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
</one-to-many>
|
||||
<transient name="visits"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
<entity class="PetType">
|
||||
<table name="TYPES"/>
|
||||
</entity>
|
||||
|
||||
<entity class="Visit">
|
||||
<table name="VISITS"/>
|
||||
<attributes>
|
||||
<basic name="date">
|
||||
<column name="VISIT_DATE"/>
|
||||
<temporal>DATE</temporal>
|
||||
</basic>
|
||||
<many-to-one name="pet" fetch="EAGER">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
</entity-mappings>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
|
||||
version="1.0">
|
||||
|
||||
<persistence-unit name="PetClinic" transaction-type="RESOURCE_LOCAL">
|
||||
|
||||
<!-- Explicitly define mapping file path, else Hibernate won't find the default -->
|
||||
<mapping-file>META-INF/orm.xml</mapping-file>
|
||||
|
||||
<!-- Prevent annotation scanning. In this app we are purely driven by orm.xml -->
|
||||
<exclude-unlisted-classes>true</exclude-unlisted-classes>
|
||||
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
# Properties file with JDBC and JPA settings.
|
||||
#
|
||||
# Applied by <context:property-placeholder location="jdbc.properties"/> from
|
||||
# various application context XML files (e.g., "applicationContext-*.xml").
|
||||
# Targeted at system administrators, to avoid touching the context XML files.
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Common Settings
|
||||
|
||||
hibernate.generate_statistics=true
|
||||
hibernate.show_sql=true
|
||||
jpa.showSql=true
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# HSQL Settings
|
||||
|
||||
jdbc.driverClassName=org.hsqldb.jdbcDriver
|
||||
jdbc.url=jdbc:hsqldb:mem:petclinic
|
||||
jdbc.username=sa
|
||||
jdbc.password=
|
||||
|
||||
# Properties that control the population of schema and data for a new data source
|
||||
jdbc.populate=true
|
||||
jdbc.schemaLocation=classpath:/META-INF/hsqldb/initDB.txt
|
||||
jdbc.dataLocation=classpath:/META-INF/hsqldb/populateDB.txt
|
||||
jdbc.dropLocation=classpath:/META-INF/hsqldb/dropTables.txt
|
||||
|
||||
# Property that determines which Hibernate dialect to use
|
||||
# (only applied with "applicationContext-hibernate.xml")
|
||||
hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
|
||||
# Property that determines which JPA DatabasePlatform to use with TopLink Essentials
|
||||
jpa.databasePlatform=org.springframework.samples.petclinic.toplink.EssentialsHSQLPlatformWithNativeSequence
|
||||
|
||||
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
||||
jpa.database=HSQL
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# MySQL Settings
|
||||
|
||||
#jdbc.driverClassName=com.mysql.jdbc.Driver
|
||||
#jdbc.url=jdbc:mysql://localhost:3306/petclinic
|
||||
#jdbc.username=pc
|
||||
#jdbc.password=pc
|
||||
|
||||
# Properties that control the population of schema and data for a new data source
|
||||
#jdbc.populate=false
|
||||
#jdbc.schemaLocation=
|
||||
#jdbc.dataLocation=
|
||||
#jdbc.dropLocation=
|
||||
|
||||
# Property that determines which Hibernate dialect to use
|
||||
# (only applied with "applicationContext-hibernate.xml")
|
||||
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||
|
||||
# Property that determines which JPA DatabasePlatform to use with TopLink Essentials
|
||||
#jpa.databasePlatform=oracle.toplink.essentials.platform.database.MySQL4Platform
|
||||
|
||||
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
||||
#jpa.database=MYSQL
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
|
||||
# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
|
||||
log4j.rootLogger=INFO, stdout, logfile
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.logfile.File=${petclinic.root}/WEB-INF/petclinic.log
|
||||
log4j.appender.logfile.MaxFileSize=512KB
|
||||
# Keep three backup files.
|
||||
log4j.appender.logfile.MaxBackupIndex=3
|
||||
# Pattern to output: date priority [category] - message
|
||||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
|
||||
|
||||
log4j.logger.org.springframework.samples.petclinic.aspects=DEBUG
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
welcome=Welcome
|
||||
required=is required
|
||||
notFound=has not been found
|
||||
duplicate=is already in use
|
||||
nonNumeric=must be all numeric
|
||||
duplicateFormSubmission=Duplicate form submission is not allowed
|
||||
typeMismatch.date=invalid date
|
||||
typeMismatch.birthDate=invalid date
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
welcome=Willkommen
|
||||
required=muss angegeben werden
|
||||
notFound=wurde nicht gefunden
|
||||
duplicate=ist bereits vergeben
|
||||
nonNumeric=darf nur numerisch sein
|
||||
duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt
|
||||
typeMismatch.date=ungültiges Datum
|
||||
typeMismatch.birthDate=ungültiges Datum
|
||||
|
|
@ -1 +0,0 @@
|
|||
# This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file.
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
- Mapping file for the Hibernate implementation of the Clinic interface.
|
||||
-->
|
||||
<hibernate-mapping auto-import="true" default-lazy="false">
|
||||
|
||||
<class name="org.springframework.samples.petclinic.Vet" table="vets">
|
||||
<id name="id" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="firstName" column="first_name"/>
|
||||
<property name="lastName" column="last_name"/>
|
||||
<set name="specialtiesInternal" table="vet_specialties">
|
||||
<key column="vet_id"/>
|
||||
<many-to-many column="specialty_id" class="org.springframework.samples.petclinic.Specialty"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="org.springframework.samples.petclinic.Specialty" table="specialties">
|
||||
<id name="id" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="name" column="name"/>
|
||||
</class>
|
||||
|
||||
<class name="org.springframework.samples.petclinic.Owner" table="owners">
|
||||
<id name="id" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="firstName" column="first_name"/>
|
||||
<property name="lastName" column="last_name"/>
|
||||
<property name="address" column="address"/>
|
||||
<property name="city" column="city"/>
|
||||
<property name="telephone" column="telephone"/>
|
||||
<set name="petsInternal" inverse="true" cascade="all">
|
||||
<key column="owner_id"/>
|
||||
<one-to-many class="org.springframework.samples.petclinic.Pet"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="org.springframework.samples.petclinic.Pet" table="pets">
|
||||
<id name="id" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="name" column="name"/>
|
||||
<property name="birthDate" column="birth_date" type="date"/>
|
||||
<many-to-one name="owner" column="owner_id" class="org.springframework.samples.petclinic.Owner"/>
|
||||
<many-to-one name="type" column="type_id" class="org.springframework.samples.petclinic.PetType"/>
|
||||
<set name="visitsInternal" inverse="true" cascade="all">
|
||||
<key column="pet_id"/>
|
||||
<one-to-many class="org.springframework.samples.petclinic.Visit"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="org.springframework.samples.petclinic.PetType" table="types">
|
||||
<id name="id" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="name" column="name"/>
|
||||
</class>
|
||||
|
||||
<class name="org.springframework.samples.petclinic.Visit" table="visits">
|
||||
<id name="id" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="date" column="visit_date" type="date"/>
|
||||
<property name="description" column="description"/>
|
||||
<many-to-one name="pet" column="pet_id" class="org.springframework.samples.petclinic.Pet"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<!-- Tomcat context descriptor used for specifying a custom ClassLoader -->
|
||||
<Context path="/petclinic" reloadable="false">
|
||||
<!-- please note that useSystemClassLoaderAsParent is available since Tomcat 5.5.20 / remove if previous versions are being used -->
|
||||
<!--
|
||||
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/>
|
||||
-->
|
||||
</Context>
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Application context definition for PetClinic on Hibernate.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
||||
|
||||
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
||||
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
|
||||
<context:property-placeholder location="classpath:jdbc.properties"/>
|
||||
|
||||
<!--
|
||||
Uses Apache Commons DBCP for connection pooling. See Commons DBCP documentation
|
||||
for the required JAR files. Alternatively you can use another connection pool
|
||||
such as C3P0, similarly configured using Spring.
|
||||
-->
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
|
||||
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}"
|
||||
p:password="${jdbc.password}"/>
|
||||
|
||||
<!-- JNDI DataSource for JEE environments -->
|
||||
<!--
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||
-->
|
||||
|
||||
<!-- Hibernate SessionFactory -->
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
|
||||
p:dataSource-ref="dataSource" p:mappingResources="petclinic.hbm.xml">
|
||||
<property name="hibernateProperties">
|
||||
<props>
|
||||
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
|
||||
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
|
||||
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
|
||||
</props>
|
||||
</property>
|
||||
<property name="eventListeners">
|
||||
<map>
|
||||
<entry key="merge">
|
||||
<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
|
||||
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"
|
||||
p:sessionFactory-ref="sessionFactory"/>
|
||||
|
||||
<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
|
||||
<!--
|
||||
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
|
||||
|
||||
<!--
|
||||
Activates various annotations to be detected in bean classes:
|
||||
Spring's @Required and @Autowired, as well as JSR 250's @Resource.
|
||||
-->
|
||||
<context:annotation-config/>
|
||||
|
||||
<!--
|
||||
Instruct Spring to perform declarative transaction management
|
||||
automatically on annotated classes.
|
||||
-->
|
||||
<tx:annotation-driven/>
|
||||
|
||||
<!--
|
||||
Exporter that exposes the Hibernate statistics service via JMX. Autodetects the
|
||||
service MBean, using its bean name as JMX object name.
|
||||
-->
|
||||
<context:mbean-export/>
|
||||
|
||||
<!-- PetClinic's central data access object: Hibernate implementation -->
|
||||
<bean id="clinic" class="org.springframework.samples.petclinic.hibernate.HibernateClinic"/>
|
||||
|
||||
<!-- Hibernate's JMX statistics service -->
|
||||
<bean name="petclinic:type=HibernateStatistics" class="org.hibernate.jmx.StatisticsService" autowire="byName"/>
|
||||
|
||||
</beans>
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Application context definition for PetClinic on JDBC.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
||||
|
||||
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
||||
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
|
||||
<context:property-placeholder location="classpath:jdbc.properties"/>
|
||||
|
||||
<!--
|
||||
Spring FactoryBean that creates a DataSource using Apache Commons DBCP for connection
|
||||
pooling. See Commons DBCP documentation for the required JAR files. This factory bean
|
||||
can populate the data source with a schema and data scripts if configured to do so.
|
||||
|
||||
An alternate factory bean can be created for different connection pool implementations,
|
||||
C3P0 for example.
|
||||
-->
|
||||
<bean id="dataSource" class="org.springframework.samples.petclinic.config.DbcpDataSourceFactory"
|
||||
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
|
||||
p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}"
|
||||
p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"/>
|
||||
|
||||
<!-- JNDI DataSource for JEE environments -->
|
||||
<!--
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||
-->
|
||||
|
||||
<!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
p:dataSource-ref="dataSource"/>
|
||||
|
||||
<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
|
||||
<!--
|
||||
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
|
||||
|
||||
<!--
|
||||
Activates various annotations to be detected in bean classes: Spring's
|
||||
@Required and @Autowired, as well as JSR 250's @PostConstruct,
|
||||
@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
|
||||
and @PersistenceUnit (if available).
|
||||
-->
|
||||
<context:annotation-config/>
|
||||
|
||||
<!--
|
||||
Instruct Spring to retrieve and apply @AspectJ aspects which are defined
|
||||
as beans in this context (such as the CallMonitoringAspect below).
|
||||
-->
|
||||
<aop:aspectj-autoproxy/>
|
||||
|
||||
<!--
|
||||
Instruct Spring to perform automatic transaction management on annotated classes.
|
||||
The SimpleJdbcClinic implementation declares @Transactional annotations.
|
||||
"proxy-target-class" is set because of SimpleJdbcClinic's @ManagedOperation usage.
|
||||
-->
|
||||
<tx:annotation-driven/>
|
||||
|
||||
<!--
|
||||
Exporter that exposes the Clinic DAO and the CallMonitoringAspect via JMX,
|
||||
based on the @ManagedResource, @ManagedAttribute, and @ManagedOperation annotations.
|
||||
-->
|
||||
<context:mbean-export/>
|
||||
|
||||
<!-- PetClinic's central data access object using Spring's SimpleJdbcTemplate -->
|
||||
<bean id="clinic" class="org.springframework.samples.petclinic.jdbc.SimpleJdbcClinic"/>
|
||||
|
||||
<!-- Call monitoring aspect that monitors call count and call invocation time -->
|
||||
<bean id="callMonitor" class="org.springframework.samples.petclinic.aspects.CallMonitoringAspect"/>
|
||||
|
||||
</beans>
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Application context definition for PetClinic on JPA.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
||||
|
||||
<!--
|
||||
Activates a load-time weaver for the context. Any bean within the context that
|
||||
implements LoadTimeWeaverAware (such as LocalContainerEntityManagerFactoryBean)
|
||||
will receive a reference to the autodetected load-time weaver.
|
||||
-->
|
||||
<context:load-time-weaver/>
|
||||
|
||||
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
||||
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
|
||||
<context:property-placeholder location="classpath:jdbc.properties"/>
|
||||
|
||||
<!--
|
||||
Uses Apache Commons DBCP for connection pooling. See Commons DBCP documentation
|
||||
for the required JAR files. Alternatively you can use another connection pool
|
||||
such as C3P0, similarly configured using Spring.
|
||||
-->
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
|
||||
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}"
|
||||
p:password="${jdbc.password}"/>
|
||||
|
||||
<!-- JNDI DataSource for JEE environments -->
|
||||
<!--
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||
-->
|
||||
|
||||
<!-- JPA EntityManagerFactory -->
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||
p:dataSource-ref="dataSource">
|
||||
<property name="jpaVendorAdapter">
|
||||
<bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"
|
||||
p:databasePlatform="${jpa.databasePlatform}" p:showSql="${jpa.showSql}"/>
|
||||
<!--
|
||||
<bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
|
||||
p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
|
||||
-->
|
||||
<!--
|
||||
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
|
||||
p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
|
||||
-->
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
|
||||
p:entityManagerFactory-ref="entityManagerFactory"/>
|
||||
|
||||
|
||||
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
|
||||
|
||||
<!--
|
||||
Activates various annotations to be detected in bean classes: Spring's
|
||||
@Required and @Autowired, as well as JSR 250's @PostConstruct,
|
||||
@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
|
||||
and @PersistenceUnit (if available).
|
||||
-->
|
||||
<context:annotation-config/>
|
||||
|
||||
<!--
|
||||
Instruct Spring to perform declarative transaction management
|
||||
automatically on annotated classes.
|
||||
-->
|
||||
<tx:annotation-driven mode="aspectj"/>
|
||||
|
||||
<!--
|
||||
Simply defining this bean will cause requests to owner names to be saved.
|
||||
This aspect is defined in petclinic.jar's META-INF/aop.xml file.
|
||||
Note that we can dependency inject this bean like any other bean.
|
||||
-->
|
||||
<bean class="org.springframework.samples.petclinic.aspects.UsageLogAspect" p:historySize="300"/>
|
||||
|
||||
<!--
|
||||
Post-processor to perform exception translation on @Repository classes (from native
|
||||
exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
|
||||
-->
|
||||
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
|
||||
|
||||
<!--
|
||||
Will automatically be transactional due to @Transactional.
|
||||
EntityManager will be auto-injected due to @PersistenceContext.
|
||||
PersistenceExceptions will be auto-translated due to @Repository.
|
||||
-->
|
||||
<bean id="clinic" class="org.springframework.samples.petclinic.jpa.EntityManagerClinic"/>
|
||||
|
||||
</beans>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
|
||||
# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
|
||||
log4j.rootLogger=INFO, stdout, logfile
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.logfile.File=${petclinic.root}/WEB-INF/petclinic.log
|
||||
log4j.appender.logfile.MaxFileSize=512KB
|
||||
# Keep three backup files.
|
||||
log4j.appender.logfile.MaxBackupIndex=3
|
||||
# Pattern to output: date priority [category] - message
|
||||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
|
||||
|
||||
log4j.logger.org.springframework.samples.petclinic.aspects=DEBUG
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
welcome=Welcome
|
||||
required=is required
|
||||
notFound=has not been found
|
||||
duplicate=is already in use
|
||||
nonNumeric=must be all numeric
|
||||
duplicateFormSubmission=Duplicate form submission is not allowed
|
||||
typeMismatch.date=invalid date
|
||||
typeMismatch.birthDate=invalid date
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
welcome=Willkommen
|
||||
required=muss angegeben werden
|
||||
notFound=wurde nicht gefunden
|
||||
duplicate=ist bereits vergeben
|
||||
nonNumeric=darf nur numerisch sein
|
||||
duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt
|
||||
typeMismatch.date=ungültiges Datum
|
||||
typeMismatch.birthDate=ungültiges Datum
|
||||
|
|
@ -1 +0,0 @@
|
|||
# This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file.
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
|
||||
configId="org/springframework/samples/petclinic">
|
||||
<context-root>/petclinic</context-root>
|
||||
<context-priority-classloader>true</context-priority-classloader>
|
||||
</web-app>
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
|
||||
<%
|
||||
Exception ex = (Exception) request.getAttribute("exception");
|
||||
%>
|
||||
|
||||
<h2>Data access failure: <%= ex.getMessage() %></h2>
|
||||
<p/>
|
||||
|
||||
<%
|
||||
ex.printStackTrace(new java.io.PrintWriter(out));
|
||||
%>
|
||||
|
||||
<p/>
|
||||
<br/>
|
||||
<a href="<spring:url value="/" htmlEscape="true" />">Home</a>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
<table class="footer">
|
||||
<tr>
|
||||
<td><a href="<spring:url value="/" htmlEscape="true" />">Home</a></td>
|
||||
<td align="right"><img src="<spring:url value="/static/images/springsource-logo.png" htmlEscape="true" />" alt="Sponsored by SpringSource"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<!--
|
||||
PetClinic :: a Spring Framework demonstration
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="stylesheet" href="<spring:url value="/static/styles/petclinic.css" htmlEscape="true" />" type="text/css"/>
|
||||
<title>PetClinic :: a Spring Framework demonstration</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
<c:choose>
|
||||
<c:when test="${owner.new}"><c:set var="method" value="post"/></c:when>
|
||||
<c:otherwise><c:set var="method" value="put"/></c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<h2><c:if test="${owner.new}">New </c:if>Owner:</h2>
|
||||
<form:form modelAttribute="owner" method="${method}">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
First Name: <form:errors path="firstName" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="firstName" size="30" maxlength="80"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Last Name: <form:errors path="lastName" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="lastName" size="30" maxlength="80"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Address: <form:errors path="address" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="address" size="30" maxlength="80"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
City: <form:errors path="city" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="city" size="30" maxlength="80"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Telephone: <form:errors path="telephone" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="telephone" size="20" maxlength="20"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${owner.new}">
|
||||
<p class="submit"><input type="submit" value="Add Owner"/></p>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<p class="submit"><input type="submit" value="Update Owner"/></p>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form:form>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
|
||||
<h2>Owners:</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>City</th>
|
||||
<th>Telephone</th>
|
||||
<th>Pets</th>
|
||||
</thead>
|
||||
<c:forEach var="owner" items="${selections}">
|
||||
<tr>
|
||||
<td>
|
||||
<spring:url value="owners/{ownerId}" var="ownerUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(ownerUrl)}">${owner.firstName} ${owner.lastName}</a>
|
||||
</td>
|
||||
<td>${owner.address}</td>
|
||||
<td>${owner.city}</td>
|
||||
<td>${owner.telephone}</td>
|
||||
<td>
|
||||
<c:forEach var="pet" items="${owner.pets}">
|
||||
${pet.name}
|
||||
</c:forEach>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
|
||||
|
||||
<h2>Find Owners:</h2>
|
||||
|
||||
<spring:url value="/owners" var="formUrl"/>
|
||||
<form:form modelAttribute="owner" action="${fn:escapeXml(formUrl)}" method="get">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Last Name: <form:errors path="*" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="lastName" size="30" maxlength="80" />
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p class="submit"><input type="submit" value="Find Owners"/></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form:form>
|
||||
|
||||
<br/>
|
||||
<a href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
|
||||
<h2>Owner Information</h2>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td><b>${owner.firstName} ${owner.lastName}</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Address</th>
|
||||
<td>${owner.address}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>City</th>
|
||||
<td>${owner.city}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Telephone </th>
|
||||
<td>${owner.telephone}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="table-buttons">
|
||||
<tr>
|
||||
<td colspan="2" align="center">
|
||||
<spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}" />
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(editUrl)}">Edit Owner</a>
|
||||
</td>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/new" var="addUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}" />
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(addUrl)}">Add New Pet</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Pets and Visits</h2>
|
||||
|
||||
<c:forEach var="pet" items="${owner.pets}">
|
||||
<table width="94%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td><b>${pet.name}</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Birth Date</th>
|
||||
<td><fmt:formatDate value="${pet.birthDate}" pattern="yyyy-MM-dd"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<td>${pet.type.name}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<table>
|
||||
<thead>
|
||||
<th>Visit Date</th>
|
||||
<th>Description</th>
|
||||
</thead>
|
||||
<c:forEach var="visit" items="${pet.visits}">
|
||||
<tr>
|
||||
<td><fmt:formatDate value="${visit.date}" pattern="yyyy-MM-dd"/></td>
|
||||
<td>${visit.description}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="table-buttons">
|
||||
<tr>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/{petId}/edit" var="petUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(petUrl)}">Edit Pet</a>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/{petId}/visits/new" var="visitUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(visitUrl)}">Add Visit</a>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/{petId}/visits.atom" var="feedUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
<a href="${fn:escapeXml(feedUrl)}" rel="alternate" type="application/atom+xml">Atom Feed</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</c:forEach>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
<c:choose>
|
||||
<c:when test="${pet.new}"><c:set var="method" value="post"/></c:when>
|
||||
<c:otherwise><c:set var="method" value="put"/></c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<h2><c:if test="${pet.new}">New </c:if>Pet</h2>
|
||||
|
||||
<b>Owner:</b> ${pet.owner.firstName} ${pet.owner.lastName}
|
||||
<br/>
|
||||
<form:form modelAttribute="pet" method="${method}">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Name: <form:errors path="name" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="name" size="30" maxlength="30"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Birth Date: <form:errors path="birthDate" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="birthDate" size="10" maxlength="10"/> (yyyy-mm-dd)
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Type: <form:errors path="type" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:select path="type" items="${types}"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${pet.new}">
|
||||
<p class="submit"><input type="submit" value="Add Pet"/></p>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<p class="submit"><input type="submit" value="Update Pet"/></p>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form:form>
|
||||
|
||||
<c:if test="${!pet.new}">
|
||||
<form:form method="delete">
|
||||
<p class="submit"><input type="submit" value="Delete Pet"/></p>
|
||||
</form:form>
|
||||
</c:if>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
|
||||
<h2><c:if test="${visit.new}">New </c:if>Visit:</h2>
|
||||
|
||||
<form:form modelAttribute="visit">
|
||||
<b>Pet:</b>
|
||||
<table width="333">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Birth Date</th>
|
||||
<th>Type</th>
|
||||
<th>Owner</th>
|
||||
</thead>
|
||||
<tr>
|
||||
<td>${visit.pet.name}</td>
|
||||
<td><fmt:formatDate value="${visit.pet.birthDate}" pattern="yyyy-MM-dd"/></td>
|
||||
<td>${visit.pet.type.name}</td>
|
||||
<td>${visit.pet.owner.firstName} ${visit.pet.owner.lastName}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="333">
|
||||
<tr>
|
||||
<th>
|
||||
Date:
|
||||
<br/><form:errors path="date" cssClass="errors"/>
|
||||
</th>
|
||||
<td>
|
||||
<form:input path="date" size="10" maxlength="10"/> (yyyy-mm-dd)
|
||||
</td>
|
||||
<tr/>
|
||||
<tr>
|
||||
<th valign="top">
|
||||
Description:
|
||||
<br/><form:errors path="description" cssClass="errors"/>
|
||||
</th>
|
||||
<td>
|
||||
<form:textarea path="description" rows="10" cols="25"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="hidden" name="petId" value="${visit.pet.id}"/>
|
||||
<p class="submit"><input type="submit" value="Add Visit"/></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form:form>
|
||||
|
||||
<br/>
|
||||
<b>Previous Visits:</b>
|
||||
<table width="333">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<c:forEach var="visit" items="${visit.pet.visits}">
|
||||
<c:if test="${!visit.new}">
|
||||
<tr>
|
||||
<td><fmt:formatDate value="${visit.date}" pattern="yyyy-MM-dd"/></td>
|
||||
<td>${visit.description}</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
</c:forEach>
|
||||
</table>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue