You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(39) |
Dec
(10) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(19) |
Feb
(150) |
Mar
(10) |
Apr
|
May
(8) |
Jun
(11) |
Jul
(27) |
Aug
(52) |
Sep
(35) |
Oct
(30) |
Nov
(18) |
Dec
(4) |
2008 |
Jan
(76) |
Feb
(121) |
Mar
(39) |
Apr
(55) |
May
(18) |
Jun
(49) |
Jul
(32) |
Aug
(4) |
Sep
(10) |
Oct
|
Nov
(3) |
Dec
(33) |
2009 |
Jan
(19) |
Feb
(87) |
Mar
(69) |
Apr
(38) |
May
(47) |
Jun
(20) |
Jul
(5) |
Aug
(76) |
Sep
(145) |
Oct
(34) |
Nov
(8) |
Dec
(68) |
2010 |
Jan
(150) |
Feb
(379) |
Mar
(191) |
Apr
(100) |
May
(525) |
Jun
(269) |
Jul
(127) |
Aug
(190) |
Sep
(190) |
Oct
(29) |
Nov
(147) |
Dec
(83) |
2011 |
Jan
(188) |
Feb
(81) |
Mar
(43) |
Apr
(97) |
May
(63) |
Jun
(129) |
Jul
(17) |
Aug
(124) |
Sep
(6) |
Oct
(20) |
Nov
(67) |
Dec
(23) |
2012 |
Jan
(6) |
Feb
(14) |
Mar
(181) |
Apr
(64) |
May
(102) |
Jun
(47) |
Jul
(26) |
Aug
(3) |
Sep
(1) |
Oct
(14) |
Nov
(13) |
Dec
(23) |
2013 |
Jan
(4) |
Feb
(14) |
Mar
(18) |
Apr
(14) |
May
(27) |
Jun
(27) |
Jul
(5) |
Aug
(2) |
Sep
(74) |
Oct
(79) |
Nov
(21) |
Dec
(97) |
2014 |
Jan
(6) |
Feb
(3) |
Mar
(8) |
Apr
|
May
(5) |
Jun
|
Jul
(9) |
Aug
(6) |
Sep
(3) |
Oct
(10) |
Nov
(6) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
(25) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fc...@us...> - 2008-01-29 12:02:41
|
Revision: 571 http://openutils.svn.sourceforge.net/openutils/?rev=571&view=rev Author: fcarone Date: 2008-01-29 04:02:37 -0800 (Tue, 29 Jan 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-usermanagement-dataobjects-2.0 Added Paths: ----------- tags/openutils-usermanagement-dataobjects-2.0/ tags/openutils-usermanagement-dataobjects-2.0/pom.xml tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java Removed Paths: ------------- tags/openutils-usermanagement-dataobjects-2.0/pom.xml tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java Copied: tags/openutils-usermanagement-dataobjects-2.0 (from rev 568, trunk/openutils-usermanagement-dataobjects) Deleted: tags/openutils-usermanagement-dataobjects-2.0/pom.xml =================================================================== --- trunk/openutils-usermanagement-dataobjects/pom.xml 2008-01-27 15:25:47 UTC (rev 568) +++ tags/openutils-usermanagement-dataobjects-2.0/pom.xml 2008-01-29 12:02:37 UTC (rev 571) @@ -1,74 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>7</version> - <relativePath>..</relativePath> - </parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-usermanagement-dataobjects</artifactId> - <packaging>jar</packaging> - <name>openutils usermanagement dataobjects</name> - <version>2.0-SNAPSHOT</version> - <description>Usermanagement dataobjects</description> - <dependencies> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-annotations</artifactId> - <version>3.2.0.ga</version> - <exclusions> - <exclusion> - <!-- not needed here, just load annotations --> - <groupId>org.hibernate</groupId> - <artifactId>hibernate</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.acegisecurity</groupId> - <artifactId>acegi-security</artifactId> - <version>1.0.6</version> - <exclusions> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-remoting</artifactId> - </exclusion> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-jdbc</artifactId> - </exclusion> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-support</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - <exclusion> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - </exclusion> - <exclusion> - <groupId>oro</groupId> - <artifactId>oro</artifactId> - </exclusion> - <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> -</project> \ No newline at end of file Copied: tags/openutils-usermanagement-dataobjects-2.0/pom.xml (from rev 570, trunk/openutils-usermanagement-dataobjects/pom.xml) =================================================================== --- tags/openutils-usermanagement-dataobjects-2.0/pom.xml (rev 0) +++ tags/openutils-usermanagement-dataobjects-2.0/pom.xml 2008-01-29 12:02:37 UTC (rev 571) @@ -0,0 +1,79 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>7</version> + <relativePath>..</relativePath> + </parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-usermanagement-dataobjects</artifactId> + <packaging>jar</packaging> + <name>openutils usermanagement dataobjects</name> + <version>2.0</version> + <description>Usermanagement dataobjects</description> + <dependencies> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-annotations</artifactId> + <version>3.2.0.ga</version> + <exclusions> + <exclusion> + <!-- not needed here, just load annotations --> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.acegisecurity</groupId> + <artifactId>acegi-security</artifactId> + <version>1.0.6</version> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-remoting</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-jdbc</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-support</artifactId> + </exclusion> + <exclusion> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </exclusion> + <exclusion> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </exclusion> + <exclusion> + <groupId>oro</groupId> + <artifactId>oro</artifactId> + </exclusion> + <exclusion> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-usermanagement-dataobjects-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-usermanagement-dataobjects-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-usermanagement-dataobjects-2.0</url> + </scm> +</project> \ No newline at end of file Deleted: tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java =================================================================== --- trunk/openutils-usermanagement-dataobjects/src/main/java/it/openutils/usermanagement/dataobjects/User.java 2008-01-27 15:25:47 UTC (rev 568) +++ tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java 2008-01-29 12:02:37 UTC (rev 571) @@ -1,301 +0,0 @@ -package it.openutils.usermanagement.dataobjects; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.Table; - -import org.acegisecurity.GrantedAuthority; -import org.acegisecurity.GrantedAuthorityImpl; -import org.acegisecurity.userdetails.UserDetails; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; - - -/** - * @author fberar - * @version $Revision$ ($Author$) - */ -@Entity -@Table(name = "APP_USER") -public class User implements Serializable, UserDetails -{ - - /** - * stable serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - @Id - @Column(name = "ID_USER", length = 50) - private String id; - - @Column(name = "PASSWORD", nullable = false, length = 50) - private String password; - - @Column(name = "ENABLED", nullable = false) - private Boolean enabled; - - @Column(name = "NAME", nullable = false, length = 80) - private String name; - - @Column(name = "SURNAME", nullable = false, length = 80) - private String lastname; - - @Column(name = "EMAIL", nullable = false, length = 150) - private String email; - - @ManyToMany(cascade = CascadeType.PERSIST, targetEntity = Group.class, fetch = FetchType.EAGER) - @Fetch(FetchMode.SUBSELECT) - @JoinTable(name = "APP_USER_GROUP", joinColumns = @JoinColumn(name = "ID_USER"), inverseJoinColumns = @JoinColumn(name = "ID_GROUP")) - private Set<Group> groups; - - public Set<Group> getGroups() - { - return groups; - } - - public void setGroups(Set<Group> groups) - { - this.groups = groups; - } - - /** - * Getter for <code>id</code>. - * @return Returns the id. - */ - public String getId() - { - return this.id; - } - - /** - * Setter for <code>id</code>. - * @param id The id to set. - */ - public void setId(String id) - { - this.id = id; - } - - public Boolean getEnabled() - { - return this.enabled; - } - - public void setEnabled(Boolean enabled) - { - this.enabled = enabled; - } - - public String getPassword() - { - return password; - } - - public void setPassword(String password) - { - this.password = password; - } - - public Set<Role> getRoles() - { - if (groups == null) - { - return null; - } - - Set<Role> roles = new HashSet<Role>(); - - for (Group group : groups) - { - roles.addAll(group.getRoles()); - } - - return roles; - } - - /** - * @see UserDetails.isAccountNonExpired() - */ - public boolean isAccountNonExpired() - { - return (this.enabled == null) ? false : this.enabled.booleanValue(); - } - - /** - * @see UserDetails.isAccountNonLocked() - */ - public boolean isAccountNonLocked() - { - return (this.enabled == null) ? false : this.enabled.booleanValue(); - } - - /** - * @see UserDetails.isCredentialsNonExpired() - */ - public boolean isCredentialsNonExpired() - { - return (this.enabled == null) ? false : this.enabled.booleanValue(); - } - - /** - * @see UserDetails.getAuthorities() - */ - public GrantedAuthority[] getAuthorities() - { - if (this.getRoles() == null) - { - return null; - } - - GrantedAuthority[] auths = new GrantedAuthorityImpl[this.getRoles().size()]; - Iterator<Role> iter = this.getRoles().iterator(); - int i = 0; - while (iter.hasNext()) - { - Role r = iter.next(); - auths[i] = new GrantedAuthorityImpl(r.getId()); - i++; - } - - return auths; - } - - /** - * @see UserDetails.getUsername() - */ - public String getUsername() - { - return this.id; - } - - /** - * @see UserDetails.isEnabled() - */ - public boolean isEnabled() - { - return Boolean.TRUE.equals(this.enabled); - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public String getSurname() - { - return lastname; - } - - public void setSurname(String surname) - { - this.lastname = surname; - } - - public void setLastname(String lastname) - { - this.lastname = lastname; - } - - public String getLastname() - { - return lastname; - } - - /** - * Getter for <code>email</code>. - * @return Returns the email. - */ - public String getEmail() - { - return this.email; - } - - /** - * Setter for <code>email</code>. - * @param email The email to set. - */ - public void setEmail(String email) - { - this.email = email; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", this.id).append( - "enabled", - this.enabled).append("name", this.name).append("surname", this.lastname).append( - "authorities", - this.getAuthorities()).append("username", this.getUsername()).append("email", this.email).append( - "password", - this.password).toString(); - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - final int PRIME = 31; - int result = 1; - result = PRIME * result + ((this.id == null) ? 0 : this.id.hashCode()); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final User other = (User) obj; - if (this.id == null) - { - if (other.id != null) - { - return false; - } - } - else if (!this.id.equals(other.id)) - { - return false; - } - return true; - } - -} Copied: tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java (from rev 569, trunk/openutils-usermanagement-dataobjects/src/main/java/it/openutils/usermanagement/dataobjects/User.java) =================================================================== --- tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java (rev 0) +++ tags/openutils-usermanagement-dataobjects-2.0/src/main/java/it/openutils/usermanagement/dataobjects/User.java 2008-01-29 12:02:37 UTC (rev 571) @@ -0,0 +1,310 @@ +package it.openutils.usermanagement.dataobjects; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.Table; + +import org.acegisecurity.GrantedAuthority; +import org.acegisecurity.GrantedAuthorityImpl; +import org.acegisecurity.userdetails.UserDetails; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; + + +/** + * @author fberar + * @version $Revision$ ($Author$) + */ +@Entity +@Table(name = "APP_USER") +public class User implements Serializable, UserDetails +{ + + /** + * stable serialVersionUID. + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "ID_USER", length = 50) + private String id; + + @Column(name = "PASSWORD", nullable = false, length = 50) + private String password; + + @Column(name = "ENABLED", nullable = false) + private Boolean enabled; + + @Column(name = "NAME", nullable = false, length = 80) + private String name; + + @Column(name = "SURNAME", nullable = false, length = 80) + private String lastname; + + @Column(name = "EMAIL", nullable = false, length = 150) + private String email; + + @ManyToMany(cascade = CascadeType.PERSIST, targetEntity = Group.class, fetch = FetchType.EAGER) + @Fetch(FetchMode.SUBSELECT) + @JoinTable(name = "APP_USER_GROUP", joinColumns = @JoinColumn(name = "ID_USER"), inverseJoinColumns = @JoinColumn(name = "ID_GROUP")) + private Set<Group> groups; + + public Set<Group> getGroups() + { + return groups; + } + + public void setGroups(Set<Group> groups) + { + this.groups = groups; + } + + /** + * Getter for <code>id</code>. + * @return Returns the id. + */ + public String getId() + { + return this.id; + } + + /** + * Setter for <code>id</code>. + * @param id The id to set. + */ + public void setId(String id) + { + this.id = id; + } + + public Boolean getEnabled() + { + return this.enabled; + } + + public void setEnabled(Boolean enabled) + { + this.enabled = enabled; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + /** + * @return The set of roles related to the user. It returns null if the user is not in any group, or an empty set + * if the groups the user is in, do not belong to any role. + */ + public Set<Role> getRoles() + { + if (groups == null) + { + return null; + } + + Set<Role> roles = new HashSet<Role>(); + + for (Group group : groups) + { + Set<Role> groupRoles = group.getRoles(); + if (groupRoles == null) + { + continue; + } + roles.addAll(groupRoles); + } + + return roles; + } + + /** + * @see UserDetails.isAccountNonExpired() + */ + public boolean isAccountNonExpired() + { + return (this.enabled == null) ? false : this.enabled.booleanValue(); + } + + /** + * @see UserDetails.isAccountNonLocked() + */ + public boolean isAccountNonLocked() + { + return (this.enabled == null) ? false : this.enabled.booleanValue(); + } + + /** + * @see UserDetails.isCredentialsNonExpired() + */ + public boolean isCredentialsNonExpired() + { + return (this.enabled == null) ? false : this.enabled.booleanValue(); + } + + /** + * @see UserDetails.getAuthorities() + */ + public GrantedAuthority[] getAuthorities() + { + if (this.getRoles() == null) + { + return null; + } + + GrantedAuthority[] auths = new GrantedAuthorityImpl[this.getRoles().size()]; + Iterator<Role> iter = this.getRoles().iterator(); + int i = 0; + while (iter.hasNext()) + { + Role r = iter.next(); + auths[i] = new GrantedAuthorityImpl(r.getId()); + i++; + } + + return auths; + } + + /** + * @see UserDetails.getUsername() + */ + public String getUsername() + { + return this.id; + } + + /** + * @see UserDetails.isEnabled() + */ + public boolean isEnabled() + { + return Boolean.TRUE.equals(this.enabled); + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getSurname() + { + return lastname; + } + + public void setSurname(String surname) + { + this.lastname = surname; + } + + public void setLastname(String lastname) + { + this.lastname = lastname; + } + + public String getLastname() + { + return lastname; + } + + /** + * Getter for <code>email</code>. + * @return Returns the email. + */ + public String getEmail() + { + return this.email; + } + + /** + * Setter for <code>email</code>. + * @param email The email to set. + */ + public void setEmail(String email) + { + this.email = email; + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", this.id).append( + "enabled", + this.enabled).append("name", this.name).append("surname", this.lastname).append( + "authorities", + this.getAuthorities()).append("username", this.getUsername()).append("email", this.email).append( + "password", + this.password).toString(); + } + + /** + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() + { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((this.id == null) ? 0 : this.id.hashCode()); + return result; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + final User other = (User) obj; + if (this.id == null) + { + if (other.id != null) + { + return false; + } + } + else if (!this.id.equals(other.id)) + { + return false; + } + return true; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fc...@us...> - 2008-01-29 12:02:26
|
Revision: 570 http://openutils.svn.sourceforge.net/openutils/?rev=570&view=rev Author: fcarone Date: 2008-01-29 04:02:26 -0800 (Tue, 29 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare release openutils-usermanagement-dataobjects-2.0 Modified Paths: -------------- trunk/openutils-usermanagement-dataobjects/pom.xml Modified: trunk/openutils-usermanagement-dataobjects/pom.xml =================================================================== --- trunk/openutils-usermanagement-dataobjects/pom.xml 2008-01-29 11:59:58 UTC (rev 569) +++ trunk/openutils-usermanagement-dataobjects/pom.xml 2008-01-29 12:02:26 UTC (rev 570) @@ -1,5 +1,4 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -11,7 +10,7 @@ <artifactId>openutils-usermanagement-dataobjects</artifactId> <packaging>jar</packaging> <name>openutils usermanagement dataobjects</name> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> <description>Usermanagement dataobjects</description> <dependencies> <dependency> @@ -71,4 +70,10 @@ </exclusions> </dependency> </dependencies> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-usermanagement-dataobjects-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-usermanagement-dataobjects-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-usermanagement-dataobjects-2.0</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 15:25:42
|
Revision: 568 http://openutils.svn.sourceforge.net/openutils/?rev=568&view=rev Author: fgiust Date: 2008-01-27 07:25:47 -0800 (Sun, 27 Jan 2008) Log Message: ----------- a deep cleanup Modified Paths: -------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java trunk/openutils-dbmigration/src/site/apt/index.apt Added Paths: ----------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseConditionalTask.java trunk/openutils-dbmigration/src/site/apt/guide.apt Removed Paths: ------------- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java Deleted: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcConditionalTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -1,78 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.migration.generic; - -import it.openutils.migration.task.setup.BaseDbTask; -import it.openutils.migration.task.setup.DbTask; - -import javax.sql.DataSource; - -import org.apache.commons.lang.StringUtils; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; - - -/** - * @author fgiust - * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ - */ -public abstract class JdbcConditionalTask extends BaseDbTask implements DbTask -{ - - private String ddl; - - private boolean not; - - /** - * {@inheritDoc} - */ - public void setDdl(String ddls) - { - this.ddl = ddls; - } - - /** - * Sets the not. - * @param not the not to set - */ - public void setNot(boolean not) - { - this.not = not; - } - - public abstract boolean check(SimpleJdbcTemplate jdbcTemplate); - - /** - * {@inheritDoc} - */ - public void execute(DataSource dataSource) - { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); - - if (check(jdbcTemplate) ^ !not) - { - - String[] ddls = StringUtils.split(ddl, ';'); - for (String statement : ddls) - { - if (StringUtils.isNotBlank(statement)) - { - jdbcTemplate.update(statement); - } - } - } - } - -} Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcIfColumnExistsConditionalTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -1,5 +1,7 @@ package it.openutils.migration.generic; +import it.openutils.migration.task.setup.BaseConditionalTask; + import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; @@ -15,7 +17,7 @@ * @author fgiust * @version $Id: $ */ -public class JdbcIfColumnExistsConditionalTask extends JdbcConditionalTask +public class JdbcIfColumnExistsConditionalTask extends BaseConditionalTask { private String column; Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcObjectCreationTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,7 +15,7 @@ */ package it.openutils.migration.generic; -import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; +import it.openutils.migration.task.setup.GenericConditionalTask; import java.io.IOException; import java.io.InputStream; @@ -28,8 +28,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.ConnectionCallback; @@ -41,18 +39,13 @@ * @author fgiust * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ */ -public class JdbcObjectCreationTask extends GenericScriptBasedConditionalTask +public abstract class JdbcObjectCreationTask extends GenericConditionalTask { - /** - * Logger. - */ - protected Logger log = LoggerFactory.getLogger(getClass()); - - protected String objectType = "TABLE"; - protected String catalog; + abstract String getObjectType(); + /** * {@inheritDoc} */ @@ -95,7 +88,7 @@ { DatabaseMetaData dbMetadata = con.getMetaData(); - ResultSet rs = dbMetadata.getTables(catalog, schema, tableName, new String[]{objectType }); + ResultSet rs = dbMetadata.getTables(catalog, schema, tableName, new String[]{getObjectType() }); boolean tableExists = rs.first(); rs.close(); @@ -128,7 +121,7 @@ String[] ddls = StringUtils.split(scriptContent, ";"); - log.info("Creating new {} {}", objectType, tableName); + log.info("Creating new {} {}", getObjectType(), tableName); for (String ddl : ddls) { Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcTableCreationTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -22,5 +22,12 @@ public class JdbcTableCreationTask extends JdbcObjectCreationTask { - protected String objectType = "TABLE"; + /** + * {@inheritDoc} + */ + @Override + String getObjectType() + { + return "TABLE"; + } } \ No newline at end of file Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/generic/JdbcViewCreationTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -22,5 +22,12 @@ public class JdbcViewCreationTask extends JdbcObjectCreationTask { - protected String objectType = "VIEW"; + /** + * {@inheritDoc} + */ + @Override + String getObjectType() + { + return "VIEW"; + } } \ No newline at end of file Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerFunctionCreateOrUpdateTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,7 +15,7 @@ */ package it.openutils.migration.sqlserver; -import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; +import it.openutils.migration.task.setup.GenericConditionalTask; import java.io.IOException; import java.io.InputStream; @@ -25,8 +25,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; @@ -38,29 +36,10 @@ * @author Danilo Ghirardelli * @version $Id$ */ -public class SqlServerFunctionCreateOrUpdateTask extends GenericScriptBasedConditionalTask +public class SqlServerFunctionCreateOrUpdateTask extends GenericConditionalTask { /** - * Logger. - */ - private Logger log = LoggerFactory.getLogger(SqlServerObjCreationTask.class); - - /** - * The db with the objects, may differ from the current. - */ - private String sourceDb; - - /** - * Sets the sourceDb. - * @param sourceDb the sourceDb to set - */ - public void setSourceDb(String sourceDb) - { - this.sourceDb = sourceDb; - } - - /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @@ -153,8 +132,6 @@ { IOUtils.closeQuietly(is); } - return StringUtils.stripEnd( - StringUtils.trim(StringUtils.replace(scriptContent, "${sourceDb}", this.sourceDb)), - ";"); + return StringUtils.stripEnd(StringUtils.trim(performSubstitution(scriptContent)), ";"); } } \ No newline at end of file Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerGenericAlterTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -17,236 +17,25 @@ import it.openutils.migration.task.setup.GenericConditionalTask; -import java.io.IOException; -import java.io.InputStream; -import javax.sql.DataSource; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.io.Resource; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; - - /** * This class is used for any alter task needed. The triggerValue is the value (only numeric) of result query that - * activates the alter script. Default is zero. Both the condition query and the alter query can be script or embedded - * in the xml. + * activates the alter script. Default is zero. The alter query can be an external script or embedded in the xml. + * @deprecated * @author Danilo Ghirardelli * @version $Id:SqlServerGenericAlterTask.java 3143 2007-09-24 19:50:49Z fgiust $ */ +@Deprecated public class SqlServerGenericAlterTask extends GenericConditionalTask { /** - * Logger. + * Constructor. */ - private Logger log = LoggerFactory.getLogger(SqlServerGenericAlterTask.class); - - /** - * The condition can be in a string or in a script file. - */ - private Resource checkScript; - - /** - * Override of the corresponding string. - */ - private String ddl; - - /** - * The alter script can be embedded in the xml file or in a script file. - */ - private Resource ddlScript; - - /** - * The value that will let the ddl script start. Default is zero. - */ - private Integer triggerValue = 0; - - /** - * The db with the objects, synonyms will point to this db. - */ - private String sourceDb; - - /** - * Sets the checkScript. - * @param checkScript the checkScript to set - */ - public void setCheckScript(Resource checkScript) + public SqlServerGenericAlterTask() { - this.checkScript = checkScript; + super(); + log.warn(getClass().getName() + " is deprecated, please use " + GenericConditionalTask.class.getName()); } - /** - * Sets the ddl. - * @param ddl the ddl to set - */ - @Override - public void setDdl(String ddl) - { - this.ddl = ddl; - } - - /** - * Sets the ddlScript. - * @param ddlScript the ddlScript to set - */ - public void setDdlScript(Resource ddlScript) - { - this.ddlScript = ddlScript; - } - - /** - * Sets the triggerValue. - * @param triggerValue the triggerValue to set - */ - public void setTriggerValue(Integer triggerValue) - { - this.triggerValue = triggerValue; - } - - /** - * Sets the sourceDb. - * @param sourceDb the sourceDb to set - */ - public void setSourceDb(String sourceDb) - { - this.sourceDb = sourceDb; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() - { - - if (StringUtils.isNotEmpty(super.getDescription())) - { - return super.getDescription(); - } - - StringBuffer result = new StringBuffer(); - if (StringUtils.isNotBlank(getCheck())) - { - result.append("Checking alter task condition:\n" + getCheck()); - } - else - { - result.append("Checking alter task condition in script:\n" + checkScript); - } - return result.toString(); - } - - /** - * {@inheritDoc} - */ - @Override - public void execute(DataSource dataSource) - { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); - - String resultQuery; - if (StringUtils.isNotBlank(getCheck())) - { - // Simple query embedded in xml. - resultQuery = getCheck(); - resultQuery = StringUtils.isNotBlank(this.sourceDb) ? StringUtils.replace( - resultQuery, - "${sourceDb}", - this.sourceDb) : resultQuery; - } - else - { - // Check query in a script file. - if (checkScript == null || !checkScript.exists()) - { - log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), checkScript); - return; - } - InputStream is = null; - String scriptContent; - try - { - is = checkScript.getInputStream(); - scriptContent = IOUtils.toString(is, "UTF8"); - } - catch (IOException e) - { - log.error( - "Unable to execute db task \"{}\", script \"{}\" can't be read.", - getDescription(), - checkScript); - return; - } - finally - { - IOUtils.closeQuietly(is); - } - resultQuery = scriptContent; - resultQuery = StringUtils.isNotBlank(this.sourceDb) ? StringUtils.replace( - resultQuery, - "${sourceDb}", - this.sourceDb) : resultQuery; - } - - if ((triggerValue != null) && (jdbcTemplate.queryForInt(resultQuery) == triggerValue)) - { - log.info("Executing Alter Task: {}", getDescription()); - String scriptContent; - - if (StringUtils.isNotBlank(ddl)) - { - scriptContent = ddl; - } - else - { - if (ddlScript == null || !ddlScript.exists()) - { - log - .error( - "Unable to execute db task \"{}\", script \"{}\" not found.", - getDescription(), - ddlScript); - return; - } - InputStream is = null; - try - { - is = ddlScript.getInputStream(); - scriptContent = IOUtils.toString(is, "UTF8"); - } - catch (IOException e) - { - log.error( - "Unable to execute db task \"{}\", script \"{}\" can't be read.", - getDescription(), - ddlScript); - return; - } - finally - { - IOUtils.closeQuietly(is); - } - } - - String[] ddls = StringUtils.split(scriptContent, ";"); - - for (String ddl : ddls) - { - if (StringUtils.isNotBlank(ddl)) - { - String ddlReplaced = ddl; - ddlReplaced = StringUtils.isNotBlank(this.sourceDb) ? StringUtils.replace( - ddlReplaced, - "${sourceDb}", - this.sourceDb) : ddlReplaced; - log.debug("Executing:\n{}", ddlReplaced); - jdbcTemplate.update(ddlReplaced); - } - } - } - } } \ No newline at end of file Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerObjCreationTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,7 +15,7 @@ */ package it.openutils.migration.sqlserver; -import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; +import it.openutils.migration.task.setup.GenericConditionalTask; import java.io.IOException; import java.io.InputStream; @@ -24,8 +24,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; @@ -34,15 +32,10 @@ * @author fgiust * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ */ -public class SqlServerObjCreationTask extends GenericScriptBasedConditionalTask +public class SqlServerObjCreationTask extends GenericConditionalTask { /** - * Logger. - */ - private Logger log = LoggerFactory.getLogger(SqlServerObjCreationTask.class); - - /** * Query to check with standard objects' name. */ private String unqualifiedObjQuery; @@ -53,11 +46,6 @@ private String qualifiedObjQuery; /** - * The db with the objects, synonyms will point to this db. - */ - private String sourceDb; - - /** * Returns the qualifiedObjQuery. * @return the qualifiedObjQuery */ @@ -76,15 +64,6 @@ } /** - * Sets the sourceDb. - * @param sourceDb the sourceDb to set - */ - public void setSourceDb(String sourceDb) - { - this.sourceDb = sourceDb; - } - - /** * Returns the unqualifiedObjQuery. * @return the unqualifiedObjQuery */ @@ -159,11 +138,7 @@ { if (StringUtils.isNotBlank(ddl)) { - String ddlReplaced = ddl; - ddlReplaced = StringUtils.isNotBlank(this.sourceDb) ? StringUtils.replace( - ddlReplaced, - "${sourceDb}", - this.sourceDb) : ddlReplaced; + String ddlReplaced = performSubstitution(ddl); log.debug("Executing:\n{}", ddlReplaced); jdbcTemplate.update(ddlReplaced); } Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerProcedureCreateOrUpdateTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,7 +15,7 @@ */ package it.openutils.migration.sqlserver; -import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; +import it.openutils.migration.task.setup.GenericConditionalTask; import java.io.IOException; import java.io.InputStream; @@ -25,8 +25,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; @@ -38,29 +36,10 @@ * @author Danilo Ghirardelli * @version $Id$ */ -public class SqlServerProcedureCreateOrUpdateTask extends GenericScriptBasedConditionalTask +public class SqlServerProcedureCreateOrUpdateTask extends GenericConditionalTask { /** - * Logger. - */ - private Logger log = LoggerFactory.getLogger(SqlServerObjCreationTask.class); - - /** - * The db with the objects, may differ from the current. - */ - private String sourceDb; - - /** - * Sets the sourceDb. - * @param sourceDb the sourceDb to set - */ - public void setSourceDb(String sourceDb) - { - this.sourceDb = sourceDb; - } - - /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @@ -152,8 +131,6 @@ { IOUtils.closeQuietly(is); } - return StringUtils.stripEnd( - StringUtils.trim(StringUtils.replace(scriptContent, "${sourceDb}", this.sourceDb)), - ";"); + return StringUtils.stripEnd(StringUtils.trim(performSubstitution(scriptContent)), ";"); } } \ No newline at end of file Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/sqlserver/SqlServerViewCreateOrUpdateTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,7 +15,7 @@ */ package it.openutils.migration.sqlserver; -import it.openutils.migration.task.setup.GenericScriptBasedConditionalTask; +import it.openutils.migration.task.setup.GenericConditionalTask; import java.io.IOException; import java.io.InputStream; @@ -25,8 +25,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; @@ -35,29 +33,10 @@ * @author Danilo Ghirardelli * @version $Id: SqlServerViewCreateOrUpdateTask.java 391 2007-07-10 17:25:42Z fgiust $ */ -public class SqlServerViewCreateOrUpdateTask extends GenericScriptBasedConditionalTask +public class SqlServerViewCreateOrUpdateTask extends GenericConditionalTask { /** - * Logger. - */ - private Logger log = LoggerFactory.getLogger(SqlServerObjCreationTask.class); - - /** - * The db with the objects, synonyms will point to this db. - */ - private String sourceDb; - - /** - * Sets the sourceDb. - * @param sourceDb the sourceDb to set - */ - public void setSourceDb(String sourceDb) - { - this.sourceDb = sourceDb; - } - - /** * {@inheritDoc} */ @SuppressWarnings("unchecked") @@ -162,8 +141,6 @@ { IOUtils.closeQuietly(is); } - return StringUtils.stripEnd( - StringUtils.trim(StringUtils.replace(scriptContent, "${sourceDb}", this.sourceDb)), - ";"); + return StringUtils.stripEnd(StringUtils.trim(performSubstitution(scriptContent)), ";"); } } \ No newline at end of file Added: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseConditionalTask.java (rev 0) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseConditionalTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -0,0 +1,240 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.migration.task.setup; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.Resource; +import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; + + +/** + * A base conditional task that executes a task only if an expected condition is met. + * @author fgiust + * @version $Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $ + */ +public abstract class BaseConditionalTask extends BaseDbTask +{ + + /** + * Logger. + */ + protected Logger log = LoggerFactory.getLogger(getClass()); + + /** + * DDL to run when the condition is met. + */ + protected String ddl; + + /** + * If <code>true</code> executes only if check returned <code>false</code> + */ + protected boolean not; + + /** + * Map of key-value that will be replaced in ddl. + */ + protected Map<String, String> variables; + + /** + * Script list to execute + */ + protected List<Resource> scripts; + + /** + * Sets the scripts. + * @param scripts the scripts to set + */ + public void setScripts(List<Resource> scripts) + { + this.scripts = scripts; + } + + /** + * {@inheritDoc} + */ + public final void setDdl(String ddls) + { + this.ddl = ddls; + } + + /** + * Sets the not. + * @param not the not to set + */ + public final void setNot(boolean not) + { + this.not = not; + } + + /** + * Sets the ddlScript. + * @param ddlScript the ddlScript to set + * @deprecated use the "scripts" property + */ + @Deprecated + public final void setDdlScript(Resource ddlScript) + { + log.warn("ddlScript is deprecated, please use \"scripts\""); + if (scripts == null) + { + scripts = new ArrayList<Resource>(1); + } + scripts.add(ddlScript); + } + + /** + * Subclasses need to override this method and provide specific checks. + * @param jdbcTemplate SimpleJdbcTemplate + * @return true if the condition is met + */ + public abstract boolean check(SimpleJdbcTemplate jdbcTemplate); + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() + { + + if (StringUtils.isNotEmpty(super.getDescription())) + { + return super.getDescription(); + } + + if (scripts != null && !scripts.isEmpty()) + { + StringBuffer result = new StringBuffer(); + result.append("Checking :\n"); + for (Resource script : scripts) + { + result.append(" - " + objectNameFromFileName(script) + "\n"); + } + return result.toString(); + + } + + return getClass().getName(); + } + + /** + * @param script The script resource + * @return The script name + */ + protected String objectNameFromFileName(Resource script) + { + return StringUtils.substringBeforeLast(script.getFilename(), "."); + } + + /** + * Perform sobstitution in the given string. + * @param string Original String + * @return processed string + */ + protected String performSubstitution(String string) + { + if (variables == null || variables.isEmpty()) + { + return string; + } + + String stringReplaced = string; + for (String key : variables.keySet()) + { + stringReplaced = StringUtils.replace(stringReplaced, "${" + key + "}", variables.get(key)); + } + + return stringReplaced; + } + + /** + * {@inheritDoc} + */ + public void execute(DataSource dataSource) + { + SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + + if (check(jdbcTemplate) ^ !not) + { + log.info("Executing Alter Task: {}", getDescription()); + + if (StringUtils.isNotBlank(ddl)) + { + executeSingle(jdbcTemplate, ddl); + } + else + { + if (scripts == null || scripts.isEmpty()) + { + log.error("Unable to execute db task \"{}\", no ddl or scripts configured.", getDescription()); + return; + } + + for (Resource script : scripts) + { + String scriptContent = ddl; + InputStream is = null; + try + { + is = script.getInputStream(); + scriptContent = IOUtils.toString(is, "UTF8"); + } + catch (IOException e) + { + log.error( + "Unable to execute db task \"{}\", script \"{}\" can't be read.", + getDescription(), + script); + return; + } + finally + { + IOUtils.closeQuietly(is); + } + executeSingle(jdbcTemplate, scriptContent); + } + } + } + } + + /** + * @param jdbcTemplate + * @param scriptContent + */ + private void executeSingle(SimpleJdbcTemplate jdbcTemplate, String scriptContent) + { + String[] ddls = StringUtils.split(performSubstitution(scriptContent), ';'); + for (String statement : ddls) + { + if (StringUtils.isNotBlank(statement)) + { + log.debug("Executing:\n{}", statement); + jdbcTemplate.update(statement); + } + } + } + +} Property changes on: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseConditionalTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/BaseDbTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -22,7 +22,10 @@ public abstract class BaseDbTask implements DbTask { - private String description; + /** + * An readable description for what this task is doing. + */ + protected String description; /** * {@inheritDoc} Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/ExcelConfigurationTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -225,6 +225,7 @@ * @param updateStatement * @param selectStatement */ + @SuppressWarnings("unchecked") private void processRecords(HSSFSheet sheet, List<String> columns, int[] types, String checkStatement, String insertStatement, String selectStatement, String updateStatement, DataSource dataSource, String tableName) { @@ -351,8 +352,11 @@ { RowMapper rowMapper = new ColumnMapRowMapper(); Object[] selectParams = ArrayUtils.subarray(values.toArray(), 0, selectNum); - List selectResult = jdbcTemplate.query(selectStatement, selectParams, rowMapper); - Map<String, Object> fetchedColumns = (Map<String, Object>) selectResult.get(0); + List<Map<String, Object>> selectResult = jdbcTemplate.query( + selectStatement, + selectParams, + rowMapper); + Map<String, Object> fetchedColumns = selectResult.get(0); int i = 0; boolean updateNeeded = false; for (String columnName : columns) Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericConditionalTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,35 +15,35 @@ */ package it.openutils.migration.task.setup; -import javax.sql.DataSource; +import java.util.HashMap; import org.apache.commons.lang.StringUtils; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; /** + * A siple update task that executes a query and apply a DDL only if the query retuns a certain value (by default + * <code>0</code>) * @author fgiust * @version $Id$ */ -public class GenericConditionalTask extends BaseDbTask implements DbTask +public class GenericConditionalTask extends BaseConditionalTask { - private String check; + /** + * Query for the check condition. + */ + protected String check; - private String ddl; - /** - * {@inheritDoc} + * The value that will let the ddl script start. Default is <code>0</code>. */ - public void setDdl(String ddls) - { - this.ddl = ddls; - } + protected Integer triggerValue = 0; /** * {@inheritDoc} */ - public void setCheck(String name) + public final void setCheck(String name) { this.check = name; } @@ -58,24 +58,61 @@ } /** + * Sets the triggerValue. + * @param triggerValue the triggerValue to set + */ + public final void setTriggerValue(Integer triggerValue) + { + this.triggerValue = triggerValue; + } + + /** * {@inheritDoc} */ - public void execute(DataSource dataSource) + @Override + public String getDescription() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + String supDesc = super.getDescription(); + if (StringUtils.isNotEmpty(supDesc) && !StringUtils.equals(supDesc, getClass().getName())) + { + return super.getDescription(); + } - int result = jdbcTemplate.queryForInt(getCheck()); - if (result == 0) + if (StringUtils.isNotBlank(getCheck())) { - String[] ddls = StringUtils.split(ddl, ';'); - for (String statement : ddls) - { - if (StringUtils.isNotBlank(statement)) - { - jdbcTemplate.update(statement); - } - } + return "Checking alter task condition: " + getCheck(); } + + return getClass().getName(); } + /** + * {@inheritDoc} + */ + @Override + public boolean check(SimpleJdbcTemplate jdbcTemplate) + { + int result = jdbcTemplate.queryForInt(performSubstitution(getCheck())); + return result == triggerValue; + } + + /** + * Sets the sourceDb. + * @param sourceDb the sourceDb to set + * @deprecated + */ + @Deprecated + public final void setSourceDb(String sourceDb) + { + log.warn("sourceDb in " + + getClass().getName() + + " is deprecated, please use the more generic \"variables\" property"); + + if (this.variables == null) + { + variables = new HashMap<String, String>(1); + } + variables.put("sourceDb", sourceDb); + } + } Modified: trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java =================================================================== --- trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2008-01-27 11:23:33 UTC (rev 567) +++ trunk/openutils-dbmigration/src/main/java/it/openutils/migration/task/setup/GenericScriptBasedConditionalTask.java 2008-01-27 15:25:47 UTC (rev 568) @@ -15,163 +15,13 @@ */ package it.openutils.migration.task.setup; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import javax.sql.DataSource; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.io.Resource; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; - - /** * @author fgiust * @version $Id$ + * @deprecated use GenericConditionalTask */ -public class GenericScriptBasedConditionalTask implements DbTask +@Deprecated +public class GenericScriptBasedConditionalTask extends GenericConditionalTask { - /** - * Logger. - */ - private static Logger log = LoggerFactory.getLogger(GenericScriptBasedConditionalTask.class); - - /** - * Script list to execute - */ - protected List<Resource> scripts; - - /** - * Check statement. - */ - protected String check; - - /** - * Custom description. - */ - protected String description; - - /** - * Sets the scripts. - * @param scripts the scripts to set - */ - public void setScripts(List<Resource> scripts) - { - this.scripts = scripts; - } - - /** - * Sets the check. - * @param check the check to set - */ - public void setCheck(String check) - { - this.check = check; - } - - /** - * Sets the description. - * @param description the description to set - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @param script The script resource - * @return The script name - */ - protected String objectNameFromFileName(Resource script) - { - return StringUtils.substringBeforeLast(script.getFilename(), "."); - } - - /** - * {@inheritDoc} - */ - public String getDescription() - { - if (StringUtils.isNotEmpty(description)) - { - return description; - } - - if (scripts == null) - { - return "Nothing to do, no scripts configured"; - } - - StringBuffer result = new StringBuffer(); - if (!scripts.isEmpty()) - { - result.append("Checking :\n"); - for (Resource script : scripts) - { - result.append(" - " + objectNameFromFileName(script) + "\n"); - } - - } - return result.toString(); - } - - /** - * {@inheritDoc} - */ - public void execute(DataSource dataSource) - { - - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); - - for (Resource script : scripts) - { - int result = jdbcTemplate.queryForInt(check, this.objectNameFromFileName(script)); - if (result == 0) - { - if (script == null || !script.exists()) - { - log.error("Unable to execute db task \"{}\", script \"{}\" not found.", getDescription(), script); - return; - } - - String scriptContent; - InputStream is = null; - - try - { - is = script.getInputStream(); - scriptContent = IOUtils.toString(is, "UTF8"); - } - catch (IOException e) - { - log.error( - "Unable to execute db task \"{}\", script \"{}\" can't be read.", - getDescription(), - script); - return; - } - finally - { - IOUtils.closeQuietly(is); - } - - String[] ddls = StringUtils.split(scriptContent, ";"); - - for (String ddl : ddls) - { - if (StringUtils.isNotBlank(ddl)) - { - log.debug("Executing:\n{}", ddl); - jdbcTemplate.update(ddl); - } - } - } - } - - } } Added: trunk/openutils-dbmigration/src/site/apt/guide.apt =================================================================== --- trunk/openutils-dbmigration/src/site/apt/guide.apt (rev 0) +++ trunk/openutils-dbmigration/src/site/apt/guide.apt 2008-01-27 15:25:47 UTC (rev 568) @@ -0,0 +1,310 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + +how to + + + Dbmigration è configurato in un file xml che trovate sotto src/main/resources dei progetti db + In questo file xml trovate le configurazioni base più una lista di task, che è la parte che dovrete andare ad editare. + ++-------------------------------------+ + .... + <property name="setupTasks"> + <list> + <bean class="it.openutils.dbmigration.SqlServerTableCreationTask"> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/tables/BILLING_ADDRESS.sql</value> + </list> + </property> + </bean> + <bean class="it.openutils.dbmigration.SqlServerTableCreationTask"> + ... + </bean> + </list> ++-------------------------------------+ + + + Tutti i bean che sono presenti in questa lista implementano un'interfaccia DbTask che non fa nient'altro che definire l'esecuzione di un qualcosa su db. Partendo da questo sono stati creati una serie di task specifici per le nostre esigenze (e questo vuol dire che possono essere scritti altri task o modificati quelli attuale al momento in cui emerge qualche altra esigenza). + + == I task fondamentali: creazione tabella == + + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerTableCreationTask"> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/tables/BILLING_ADDRESS.sql</value> + <value>classpath:/dbmigration/tables/CUSTOMER.sql</value> + </list> + </property> + </bean> ++-------------------------------------+ + + Il task '''it.openutils.dbmigration.SqlServerTableCreationTask''' si occupa della creazione di tabelle. Viene configurato un singolo creation task per ogni db e questo contiene l'elenco di tutte le tabelle che ci servono per quel db. + Gli script di creazione delle tabelle vanno messi in un file sql separato nel classpath (in sottodirectory dentro a src/main/resources/dbmigration*) e richiamati con la sintassi che vedete nell'esempio. + Quando il task parte utilizza il nome del file per verificare se sullo schema del db esiste già una tabella con il nome del file indicato. Se e solo se non esiste la tabella viene creata lanciando lo script relativo. + + Importante: + * negli script non ci devono essere drop, vengono comunque lanciati solo se la tabella non esiste già. + * questi script devono essere sempre mantenuti aggiornati quando modificate le tabelle. + * l'ordine degli script '''conta'''. In generale gli oggetti che hanno dipendenze da altri oggetti del database devono trovarsi dopo quelli da cui dipendono, all'interno della lista indicata nel file xml. Può essere anche necessario creare più task per rispettare l'ordine corretto tra oggetti diversi. + + == I task fondamentali: creazione altri oggetti del db == + + Può essere necessario creare anche altri oggetti nel database, e sono già disponibili una serie di script per gli oggetti fondamentali, elencati qui di seguito. Valgono le stesse regole usate per le tabelle: lo script controlla prima l'esistenza di un oggetto nel database con il nome uguale a quello del file dello script (case sensitive!), e se manca esegue lo script corrispondente. + + Per tutti i seguenti script è possibile specificare un database di origine (sourceDb) e un database di destinazione (currentDb). Nel file xml spring sostituisce autamaticamente i placeholders con gli opportuni valori dei file di properties. Il bean si occupa successivamente di sostituire i placeholder ${sourceDb} e ${currentDb} '''all'interno dello script''' con i valori specificati, prima di eseguirlo. + Questo può servire in tutti i casi in cui serve referenziare tramite nomi fully qualified oggetti di database diversi all'interno degli script. Per il momento non è mai stato necessario referenziare più di due database contemporaneamente. + + === Creazione di viste === + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerViewCreationTask"> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/dbProdotto/views/TREE_LEVEL.sql</value> + <value>classpath:/dbmigration/dbProdotto/views/PROMO_DETTAGLI_V.sql</value> + </list> + </property> + </bean> ++-------------------------------------+ + + === Creazione di sinonimi === + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerSynonymCreationTask"> + <property name="sourceDb" value="${dbmigration.databaseName.dbProdotto}" /> + <property name="currentDb" value="${dbmigration.databaseName.dbWeb}" /> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/dbWeb/synonyms/BRANI.sql</value> + <value>classpath:/dbmigration/dbWeb/synonyms/IVA.sql</value> + <value>classpath:/dbmigration/dbWeb/synonyms/LINGUA.sql</value> + <value>classpath:/dbmigration/dbWeb/synonyms/PAESE.sql</value> + <value>classpath:/dbmigration/dbWeb/synonyms/PERSONE.sql</value> + <value>classpath:/dbmigration/dbWeb/synonyms/RUOLO.sql</value> + </list> + </property> + </bean> ++-------------------------------------+ + + Per gli script dei sinonimi è '''necessario''' specificare il db in cui si trova l'oggetto di cui verrà creato il sinonimo (sourceDb), e il db di "destinazione" in cui verrà creato il sinonimo (currentDb). Nel file xml spring sostituisce autamaticamente i placeholders con gli opportuni valori dei file di properties. Il bean si occupa successivamente di sostituire i placeholder ${sourceDb} e ${currentDb} '''all'interno dello script''' con i valori specificati, prima di eseguirlo. + I sinonimi non possono avere dipendenze tra loro e di conseguenza l'ordine all'interno di questa lista è irrilevante, ma è l'unico caso. + + === Creazione di trigger === + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerTriggerCreationTask"> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/dbProdotto/triggers/IVA_INSERT.sql</value> + <value>classpath:/dbmigration/dbProdotto/triggers/IVA_UPDATE.sql</value> + </list> + </property> + </bean> ++-------------------------------------+ + + === Creazione di funzioni === + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerFunctionCreationTask"> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/dbProdotto/functions/fn_recupera_persone.sql</value> + <value>classpath:/dbmigration/dbProdotto/functions/FN_Calc_Isbn_From_EAN.sql</value> + </list> + </property> + </bean> ++-------------------------------------+ + + == I task fondamentali: alter di una tabella == + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerGenericAlterTask"> + <property name="currentDb" value="${dbmigration.databaseName.dbUsers}" /> + <property name="triggerValue" value="0" /> + <property name="check"> + <value> + <![CDATA[SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='SHIPPING_ADDRESS' AND COLUMN_NAME ='NOTES']]> + </value> + </property> + <property name="ddl"> + <value>ALTER TABLE [dbo].[SHIPPING_ADDRESS] ADD [NOTES] varchar(400) NULL;</value> + </property> + </bean> ++-------------------------------------+ + + Il principio fondamentale di questo task è semplice: quando faccio una modifica ad una tabella verifico se tale modifica è già presente su db e se non è così la applico. + Questo task lavora esattamente così: + * esegue una query di check su db + * se il risultato di questa query è uguale ad un valore definito (triggerValue)... + * ... viene eseguito lo script per applicare l'alter + + La logica deve essere la più semplice possibile: SE una colonna manca ALLORA creo la colonna. Questo sistema è risultato già in passato molto più semplice ed efficace rispetto ad utilizzare numeri di versione nel db etc. + + Anche in questo caso è possibile (ma facoltativo) indicare i parametri sourceDb e currentDb, visto che il task è di alter generico e può riguardare qualsiasi oggetto del database. I placeholder ${sourceDb} e ${currentDb} all'interno del file di script verrà sostituito prima dell'esecuzione con il valore indicato. ${currentDb} per default è il database raggiungibile come default secondo il DataSource di spring in uso per il task, quindi non è praticamente mai necessario specificarlo. + + È opportuno segnalare che è possibile utilizzare degli script sql al posto delle istruzioni scritte direttamente all'interno del file xml, specialmente se la parte di alter è piuttosto corposa. Per indicare gli script basta utilizzare le properties checkScript e ddlScript: + <pre> + <property name="checkScript"> + <value>classpath:/dbmigration/dbProdotto/alter/checkAlter.sql</value> + </property> + <property name="ddlScript"> + <value>classpath:/dbmigration/dbProdotto/alter/ddlAlter.sql</value> + </property> + </pre> + Si può indicare indifferentemente una condizione di check nell'xml e uno script per l'alter, o anche viceversa. Tuttavia quando si specifica una condizione direttamente nell'xml questa ha la precedenza sull'eventuale script, che viene pertanto ignorato. + In ogni caso, sia nell'xml che nello script, '''non''' è possibile eseguire istruzioni come IF EXIST. Anche per questo motivo esiste questo sistema di script condizionali. + + == Esempio: se aggiungo una colonna == + + + Partiamo dall'esempio di avere creato una tabella su db con questo task: + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerTableCreationTask"> + <property name="scripts"> + <list> + <value>classpath:/dbmigration/tables/PIPPO.sql</value> + </list> + </property> + </bean> + + + + + PIPPO.sql: + CREATE TABLE dbo.PIPPO ( + ID_PIPPO numeric(19,0) IDENTITY(1,1) NOT NULL, + TEST varchar(1000) NULL) + ; + ++-------------------------------------+ + + + Se ad un certo punto avete le necessità di aggiungere una colonna NEWCOL, visto che questa aggiunta dovrà essere trasparente sia per chi ha già la vecchia tabella su db sia per chi parte con un nuovo db dovete fare le seguenti cose: + + * Modificare lo script iniziale: + ++-------------------------------------+ + PIPPO.sql: + CREATE TABLE dbo.PIPPO ( + ID_PIPPO numeric(19,0) IDENTITY(1,1) NOT NULL, + TEST varchar(1000) NULL), + NEWCOL varchar(1000) NULL) + ; + ++-------------------------------------+ + + + * Aggiungere un task di alter: + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerGenericAlterTask"> + <property name="currentDb" value="${dbmigration.databaseName.dbUsers}" /> + <property name="triggerValue" value="0" /> + <property name="check"> + <value> + SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='PIPPO' AND COLUMN_NAME ='NEWCOL' + </value> + </property> + <property name="ddl"> + <value>ALTER TABLE [dbo].[PIPPO] ADD [NEWCOL] varchar(1000) NULL;</value> + </property> + </bean> ++-------------------------------------+ + + Questo task esegue la query: + ++-------------------------------------+ + <property name="check"> + <value> + SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='PIPPO' AND COLUMN_NAME ='NEWCOL' + </value> + </property> ++-------------------------------------+ + + che verifica se la colonna NEWCOL esiste già sullo schema interrogando le tabelle di sistema di sql server. + + Se il risultato matcha quello configurato in + ++-------------------------------------+ + <property name="triggerValue" value="0" /> ++-------------------------------------+ + + e cioè in questo caso se il count torna 0 e quindi la colonna non esiste viene applicato l'alter: + ++-------------------------------------+ + <property name="ddl"> + <value>ALTER TABLE [dbo].[PIPPO] ADD [NEWCOL] varchar(1000) NULL;</value> + </property> ++-------------------------------------+ + + + That's all, dovrebbe essere semplice. + + == Esempio: aggiunta di un constraint == + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerGenericAlterTask"> + <property name="currentDb" value="${dbmigration.databaseName.dbUsers}" /> + <property name="triggerValue" value="0" /> + <property name="check"> + <value> + <![CDATA[SELECT count(*) FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE WHERE TABLE_NAME='CUSTOMER' AND COLUMN_NAME ='USERNAME';]]> + </value> + </property> + <property name="ddl"> + <value><![CDATA[ALTER TABLE [dbo].[CUSTOMER] ADD CONSTRAINT [UNIQUE_CUSTOMER_USERNAME] UNIQUE ([USERNAME])]]></value> + </property> + </bean> ++-------------------------------------+ + + == Esempio: Modifica della lunghezza di un campo esistente == + ++-------------------------------------+ + <bean class="it.openutils.dbmigration.SqlServerGenericAlterTask"> + <property name="currentDb" value="${dbmigration.databaseName.dbUsers}" /> + <property name="triggerValue" value="1" /> + <property name="check"> + <value> + <![CDATA[select count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='BILLING_ADDRESS' AND COLUMN_NAME ='NAME' and character_maximum_length = 200]]> + </value> + </property> + <property name="ddl"> + <value> + <![CDATA[ + ALTER TABLE [dbo].[BILLING_ADDRESS] ALTER COLUMN [NAME] varchar(100) NULL; + ]]> + </value> + </property> + </bean> ++-------------------------------------+ + + == Esempio: query utili == + + Alcune query utili nelle condizioni di check: + * Verifica esistenza di una funzione + select count(*) from dbo.sysobjects where id = object_id('NOME_FUNZIONE') and xtype in (N'FN', N'IF', N'TF') + * Verifica esistenza di un sinonimo + select count(*) from dbo.sysobjects where id = object_id('NOME_SINONIMO') and xtype = N'SN' + * Verifica esistenza di una tabella + select count(*) from dbo.sysobjects where id = object_id('NOME_TABELLA') and OBJECTPROPERTY(id, N'IsUserTable') = 1 + * Verifica esistenza di un trigger + select count(*) from dbo.sysobjects where id = object_id('NOME_TRIGGER') and OBJECTPROPERTY(id, N'IsTrigger') = 1 + * Verifica esistenza di una vista + select count(*) from dbo.sysobjects where id = object_id('NOME_VISTA') and OBJECTPROPERTY(id, N'IsView') = 1 + * Verifica esistenza di una colonna in una tabella + select count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='NOME_TABELLA' AND COLUMN_NAME ='NOME_COLONNA' + * Verifica se una colonna amme... [truncated message content] |
From: <fg...@us...> - 2008-01-27 11:23:36
|
Revision: 567 http://openutils.svn.sourceforge.net/openutils/?rev=567&view=rev Author: fgiust Date: 2008-01-27 03:23:33 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-testing-junit/pom.xml Modified: trunk/openutils-testing-junit/pom.xml =================================================================== --- trunk/openutils-testing-junit/pom.xml 2008-01-27 11:23:26 UTC (rev 566) +++ trunk/openutils-testing-junit/pom.xml 2008-01-27 11:23:33 UTC (rev 567) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-testing-junit</artifactId> <name>openutils test utils (junit)</name> - <version>2.0</version> + <version>2.0.1-SNAPSHOT</version> <description>openutils test utils</description> <dependencies> <dependency> @@ -118,10 +118,4 @@ <properties> <spring.version>2.5.1</spring.version> </properties> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-2.0</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-2.0</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-junit-2.0</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:23:21
|
Revision: 566 http://openutils.svn.sourceforge.net/openutils/?rev=566&view=rev Author: fgiust Date: 2008-01-27 03:23:26 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-testing-junit-2.0 Added Paths: ----------- tags/openutils-testing-junit-2.0/ tags/openutils-testing-junit-2.0/pom.xml tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java tags/openutils-testing-junit-2.0/src/site/apt/ tags/openutils-testing-junit-2.0/src/site/site.xml Removed Paths: ------------- tags/openutils-testing-junit-2.0/pom.xml tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java tags/openutils-testing-junit-2.0/src/site/site.xml Copied: tags/openutils-testing-junit-2.0 (from rev 536, trunk/openutils-testing-junit) Deleted: tags/openutils-testing-junit-2.0/pom.xml =================================================================== --- trunk/openutils-testing-junit/pom.xml 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-junit-2.0/pom.xml 2008-01-27 11:23:26 UTC (rev 566) @@ -1,122 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>6</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-testing-junit</artifactId> - <name>openutils test utils (junit)</name> - <version>2.0-SNAPSHOT</version> - <description>openutils test utils</description> - <dependencies> - <dependency> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-testing</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.13</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-orm</artifactId> - <version>${spring.version}</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.dbunit</groupId> - <artifactId>dbunit</artifactId> - <version>2.2</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.4</version> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate</artifactId> - <version>3.2.1.ga</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>cglib</groupId> - <artifactId>cglib</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - <properties> - <spring.version>2.5.1</spring.version> - </properties> -</project> \ No newline at end of file Copied: tags/openutils-testing-junit-2.0/pom.xml (from rev 565, trunk/openutils-testing-junit/pom.xml) =================================================================== --- tags/openutils-testing-junit-2.0/pom.xml (rev 0) +++ tags/openutils-testing-junit-2.0/pom.xml 2008-01-27 11:23:26 UTC (rev 566) @@ -0,0 +1,127 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>7</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-testing-junit</artifactId> + <name>openutils test utils (junit)</name> + <version>2.0</version> + <description>openutils test utils</description> + <dependencies> + <dependency> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-testing</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.13</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-orm</artifactId> + <version>${spring.version}</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.dbunit</groupId> + <artifactId>dbunit</artifactId> + <version>2.2</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.4</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.1.ga</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + <properties> + <spring.version>2.5.1</spring.version> + </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-junit-2.0</url> + </scm> +</project> \ No newline at end of file Deleted: tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java =================================================================== --- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-01-27 11:23:26 UTC (rev 566) @@ -1,54 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing.junit; - -import it.openutils.testing.DbUnitTestContext; - -import org.junit.Before; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; - - -/** - * @author fgiust - * @version $Id: $ - */ -public class AbstractDbUnitJunitSpringContextTests extends AbstractJUnit4SpringContextTests -{ - - /** - * Slf4j logger that can be reused in subclasses. - */ - protected Logger log = LoggerFactory.getLogger(getClass()); - - /** - * DBUnit text context. - */ - private DbUnitTestContext dbUnitTestContext; - - /** - * Setup the Database before running the test method. - * @throws Exception Any exception. - */ - @SuppressWarnings("unchecked") - @Before - protected void setUpDbUnit() throws Exception - { - dbUnitTestContext = new DbUnitTestContext(this, applicationContext); - dbUnitTestContext.setUpDbUnit(); - } -} Copied: tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java (from rev 543, trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java) =================================================================== --- tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java (rev 0) +++ tags/openutils-testing-junit-2.0/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-01-27 11:23:26 UTC (rev 566) @@ -0,0 +1,54 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.junit; + +import it.openutils.testing.DbUnitTestContext; + +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; + + +/** + * @author fgiust + * @version $Id: $ + */ +public class AbstractDbUnitJunitSpringContextTests extends AbstractJUnit4SpringContextTests +{ + + /** + * Slf4j logger that can be reused in subclasses. + */ + protected Logger log = LoggerFactory.getLogger(getClass()); + + /** + * DBUnit text context. + */ + protected DbUnitTestContext dbUnitTestContext; + + /** + * Setup the Database before running the test method. + * @throws Exception Any exception. + */ + @SuppressWarnings("unchecked") + @Before + protected void setUpDbUnit() throws Exception + { + dbUnitTestContext = new DbUnitTestContext(this, applicationContext); + dbUnitTestContext.setUpDbUnit(); + } +} Copied: tags/openutils-testing-junit-2.0/src/site/apt (from rev 550, trunk/openutils-testing-junit/src/site/apt) Deleted: tags/openutils-testing-junit-2.0/src/site/site.xml =================================================================== --- trunk/openutils-testing-junit/src/site/site.xml 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-junit-2.0/src/site/site.xml 2008-01-27 11:23:26 UTC (rev 566) @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="Openutils"> - <bannerRight> - <name>Openutils</name> - <href>http://openutils.sourceforge.net</href> - </bannerRight> - <bannerLeft> - <name>Sourceforge</name> - <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> - <href>http://openutils.sourceforge.net</href> - </bannerLeft> - <body> - <menu ref="modules" inherit="bottom" /> - <menu ref="reports" inherit="bottom" /> - <head> - <link rel="icon" href="images/favicon.ico" /> - </head> - </body> - <skin> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-maven-skin</artifactId> - </skin> -</project> Copied: tags/openutils-testing-junit-2.0/src/site/site.xml (from rev 537, trunk/openutils-testing-junit/src/site/site.xml) =================================================================== --- tags/openutils-testing-junit-2.0/src/site/site.xml (rev 0) +++ tags/openutils-testing-junit-2.0/src/site/site.xml 2008-01-27 11:23:26 UTC (rev 566) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="Openutils testing (junit)"> + <publishDate position="left" format="yyyy-MM-dd" /> + <bannerRight> + <name>Openutils</name> + <src>http://openutils.sourceforge.net/images/openutils-logo.png</src> + <href>http://openutils.sourceforge.net</href> + </bannerRight> + <bannerLeft> + <name>Sourceforge</name> + <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> + <href>http://www.sourceforge.net/projects/openutils</href> + </bannerLeft> + <body> + <head> + <link rel="icon" href="images/favicon.ico" /> + </head> + <menu name="openutils testing (junit)"> + <item name="Usage" href="index.html"></item> + </menu> + <menu ref="modules" inherit="bottom" /> + <menu ref="reports" inherit="bottom" /> + </body> + <skin> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-maven-skin</artifactId> + <version>1.0</version> + </skin> +</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:23:07
|
Revision: 565 http://openutils.svn.sourceforge.net/openutils/?rev=565&view=rev Author: fgiust Date: 2008-01-27 03:23:07 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare release openutils-testing-junit-2.0 Modified Paths: -------------- trunk/openutils-testing-junit/pom.xml Modified: trunk/openutils-testing-junit/pom.xml =================================================================== --- trunk/openutils-testing-junit/pom.xml 2008-01-27 11:19:17 UTC (rev 564) +++ trunk/openutils-testing-junit/pom.xml 2008-01-27 11:23:07 UTC (rev 565) @@ -1,5 +1,4 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -9,7 +8,7 @@ </parent> <artifactId>openutils-testing-junit</artifactId> <name>openutils test utils (junit)</name> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> <description>openutils test utils</description> <dependencies> <dependency> @@ -119,4 +118,10 @@ <properties> <spring.version>2.5.1</spring.version> </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-junit-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-junit-2.0</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:19:12
|
Revision: 564 http://openutils.svn.sourceforge.net/openutils/?rev=564&view=rev Author: fgiust Date: 2008-01-27 03:19:17 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-testing-testng/pom.xml Modified: trunk/openutils-testing-testng/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2008-01-27 11:19:08 UTC (rev 563) +++ trunk/openutils-testing-testng/pom.xml 2008-01-27 11:19:17 UTC (rev 564) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-testing-testng</artifactId> <name>openutils test utils (testng)</name> - <version>2.0</version> + <version>2.0.1-SNAPSHOT</version> <description>openutils test utils</description> <dependencies> <dependency> @@ -170,10 +170,4 @@ <properties> <spring.version>2.5.1</spring.version> </properties> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-testng-2.0</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-testng-2.0</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-testng-2.0</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:19:10
|
Revision: 563 http://openutils.svn.sourceforge.net/openutils/?rev=563&view=rev Author: fgiust Date: 2008-01-27 03:19:08 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-testing-testng-2.0 Added Paths: ----------- tags/openutils-testing-testng-2.0/ tags/openutils-testing-testng-2.0/pom.xml tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java tags/openutils-testing-testng-2.0/src/site/apt/ tags/openutils-testing-testng-2.0/src/site/site.xml tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java Removed Paths: ------------- tags/openutils-testing-testng-2.0/derby.log tags/openutils-testing-testng-2.0/pom.xml tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java tags/openutils-testing-testng-2.0/src/site/site.xml tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java Copied: tags/openutils-testing-testng-2.0 (from rev 536, trunk/openutils-testing-testng) Property changes on: tags/openutils-testing-testng-2.0 ___________________________________________________________________ Name: svn:ignore + .checkstyle target .settings .classpath .project test-output temp-testng-customsuite.xml derby.log release.properties Deleted: tags/openutils-testing-testng-2.0/derby.log =================================================================== --- trunk/openutils-testing-testng/derby.log 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-testng-2.0/derby.log 2008-01-27 11:19:08 UTC (rev 563) @@ -1,12 +0,0 @@ ----------------------------------------------------------------- -2008-01-09 22:30:08.630 GMT: - Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.2.0 - (485682): instance c013800d-0117-60ac-bb18-00000229e5c0 -on database directory /data/apps/openmind/openutils-trunk/openutils-testing-testng/target/test-db1 - -Database Class Loader started - derby.database.classpath='' ----------------------------------------------------------------- -2008-01-09 22:30:09.498 GMT: - Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.2.0 - (485682): instance f81e0010-0117-60ac-bb18-00000229e5c0 -on database directory /data/apps/openmind/openutils-trunk/openutils-testing-testng/target/test-db2 - -Database Class Loader started - derby.database.classpath='' Deleted: tags/openutils-testing-testng-2.0/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-testng-2.0/pom.xml 2008-01-27 11:19:08 UTC (rev 563) @@ -1,185 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>6</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-testing-testng</artifactId> - <name>openutils test utils (testng)</name> - <version>2.0-SNAPSHOT</version> - <description>openutils test utils</description> - <build> - <plugins> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> - <configuration> - <forkMode>once</forkMode> - </configuration> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-testing</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.4.1</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl104-over-slf4j</artifactId> - <version>1.4.1</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-orm</artifactId> - <version>${spring.version}</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.dbunit</groupId> - <artifactId>dbunit</artifactId> - <version>2.2</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>junit-addons</groupId> - <artifactId>junit-addons</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <classifier>jdk15</classifier> - <version>5.1</version> - <exclusions> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate</artifactId> - <version>3.2.1.ga</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>cglib</groupId> - <artifactId>cglib</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.derby</groupId> - <artifactId>derby</artifactId> - <version>10.2.2.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-dbcp</groupId> - <artifactId>commons-dbcp</artifactId> - <version>1.2.1</version> - <scope>test</scope> - <exclusions> - <exclusion> - <artifactId>xerces</artifactId> - <groupId>xerces</groupId> - </exclusion> - <exclusion> - <artifactId>xml-apis</artifactId> - <groupId>xml-apis</groupId> - </exclusion> - <exclusion> - <artifactId>commons-logging</artifactId> - <groupId>commons-logging</groupId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-jdbc</artifactId> - <version>${spring.version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - <properties> - <spring.version>2.5.1</spring.version> - </properties> -</project> \ No newline at end of file Copied: tags/openutils-testing-testng-2.0/pom.xml (from rev 562, trunk/openutils-testing-testng/pom.xml) =================================================================== --- tags/openutils-testing-testng-2.0/pom.xml (rev 0) +++ tags/openutils-testing-testng-2.0/pom.xml 2008-01-27 11:19:08 UTC (rev 563) @@ -0,0 +1,179 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>7</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-testing-testng</artifactId> + <name>openutils test utils (testng)</name> + <version>2.0</version> + <description>openutils test utils</description> + <dependencies> + <dependency> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-testing</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-orm</artifactId> + <version>${spring.version}</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.dbunit</groupId> + <artifactId>dbunit</artifactId> + <version>2.2</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>junit-addons</groupId> + <artifactId>junit-addons</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <classifier>jdk15</classifier> + <version>5.7</version> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.1.ga</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <version>10.2.2.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-dbcp</groupId> + <artifactId>commons-dbcp</artifactId> + <version>1.2.1</version> + <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>xerces</artifactId> + <groupId>xerces</groupId> + </exclusion> + <exclusion> + <artifactId>xml-apis</artifactId> + <groupId>xml-apis</groupId> + </exclusion> + <exclusion> + <artifactId>commons-logging</artifactId> + <groupId>commons-logging</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-jdbc</artifactId> + <version>${spring.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + <properties> + <spring.version>2.5.1</spring.version> + </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-testng-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-testng-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-testng-2.0</url> + </scm> +</project> \ No newline at end of file Deleted: tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java =================================================================== --- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-27 11:19:08 UTC (rev 563) @@ -1,55 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing.testng; - -import it.openutils.testing.DbUnitTestContext; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeMethod; - - -/** - * @author fgiust - * @version $Id: $ - */ -public class AbstractDbUnitTestNGSpringContextTests extends AbstractTestNGSpringContextTests -{ - - /** - * Slf4j logger that can be reused in subclasses. - */ - protected Logger log = LoggerFactory.getLogger(getClass()); - - /** - * DBUnit text context. - */ - private DbUnitTestContext dbUnitTestContext; - - /** - * Setup the Database before running the test method. - * @throws Exception Any exception. - */ - @SuppressWarnings("unchecked") - @BeforeMethod - protected void setUpDbUnit() throws Exception - { - dbUnitTestContext = new DbUnitTestContext(this, applicationContext); - dbUnitTestContext.setUpDbUnit(); - } - -} Copied: tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java (from rev 543, trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java) =================================================================== --- tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java (rev 0) +++ tags/openutils-testing-testng-2.0/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-27 11:19:08 UTC (rev 563) @@ -0,0 +1,55 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.testng; + +import it.openutils.testing.DbUnitTestContext; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.BeforeMethod; + + +/** + * @author fgiust + * @version $Id: $ + */ +public class AbstractDbUnitTestNGSpringContextTests extends AbstractTestNGSpringContextTests +{ + + /** + * Slf4j logger that can be reused in subclasses. + */ + protected Logger log = LoggerFactory.getLogger(getClass()); + + /** + * DBUnit text context. + */ + protected DbUnitTestContext dbUnitTestContext; + + /** + * Setup the Database before running the test method. + * @throws Exception Any exception. + */ + @SuppressWarnings("unchecked") + @BeforeMethod + protected void setUpDbUnit() throws Exception + { + dbUnitTestContext = new DbUnitTestContext(this, applicationContext); + dbUnitTestContext.setUpDbUnit(); + } + +} Copied: tags/openutils-testing-testng-2.0/src/site/apt (from rev 550, trunk/openutils-testing-testng/src/site/apt) Deleted: tags/openutils-testing-testng-2.0/src/site/site.xml =================================================================== --- trunk/openutils-testing-testng/src/site/site.xml 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-testng-2.0/src/site/site.xml 2008-01-27 11:19:08 UTC (rev 563) @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="Openutils"> - <bannerRight> - <name>Openutils</name> - <href>http://openutils.sourceforge.net</href> - </bannerRight> - <bannerLeft> - <name>Sourceforge</name> - <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> - <href>http://openutils.sourceforge.net</href> - </bannerLeft> - <body> - <menu ref="modules" inherit="bottom" /> - <menu ref="reports" inherit="bottom" /> - <head> - <link rel="icon" href="images/favicon.ico" /> - </head> - </body> - <skin> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-maven-skin</artifactId> - </skin> -</project> Copied: tags/openutils-testing-testng-2.0/src/site/site.xml (from rev 537, trunk/openutils-testing-testng/src/site/site.xml) =================================================================== --- tags/openutils-testing-testng-2.0/src/site/site.xml (rev 0) +++ tags/openutils-testing-testng-2.0/src/site/site.xml 2008-01-27 11:19:08 UTC (rev 563) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="Openutils testing (testng)"> + <publishDate position="left" format="yyyy-MM-dd" /> + <bannerRight> + <name>Openutils</name> + <src>http://openutils.sourceforge.net/images/openutils-logo.png</src> + <href>http://openutils.sourceforge.net</href> + </bannerRight> + <bannerLeft> + <name>Sourceforge</name> + <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> + <href>http://www.sourceforge.net/projects/openutils</href> + </bannerLeft> + <body> + <head> + <link rel="icon" href="images/favicon.ico" /> + </head> + <menu name="openutils testing (testng)"> + <item name="Usage" href="index.html"></item> + </menu> + <menu ref="modules" inherit="bottom" /> + <menu ref="reports" inherit="bottom" /> + </body> + <skin> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-maven-skin</artifactId> + <version>1.0</version> + </skin> +</project> Deleted: tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java =================================================================== --- trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-27 11:19:08 UTC (rev 563) @@ -1,46 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing.testng; - -import it.openutils.testing.DbUnitExecution; - -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.test.context.transaction.TransactionalTestExecutionListener; -import org.springframework.transaction.annotation.Transactional; -import org.testng.annotations.Test; - - -/** - * @author fgiust - * @version $Id: $ - */ -@ContextConfiguration(locations = {"/spring-tests.xml" }) -@DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1") -@TestExecutionListeners({TransactionalTestExecutionListener.class }) -@Transactional -@TransactionConfiguration(transactionManager = "transactionManager1") -public class SingleDatasourceDbUnitTest extends AbstractDbUnitTestNGSpringContextTests -{ - - @Test - public void testLoad() throws Exception - { - // do nothing - } - -} Copied: tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java (from rev 541, trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java) =================================================================== --- tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java (rev 0) +++ tags/openutils-testing-testng-2.0/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-27 11:19:08 UTC (rev 563) @@ -0,0 +1,47 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.testng; + +import it.openutils.testing.DbUnitExecution; + +import org.dbunit.operation.InsertOperation; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.transaction.TransactionConfiguration; +import org.springframework.test.context.transaction.TransactionalTestExecutionListener; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.Test; + + +/** + * @author fgiust + * @version $Id: $ + */ +@ContextConfiguration(locations = {"/spring-tests.xml" }) +@DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1", insertOperation = InsertOperation.class) +@TestExecutionListeners({TransactionalTestExecutionListener.class }) +@Transactional +@TransactionConfiguration(transactionManager = "transactionManager1") +public class SingleDatasourceDbUnitTest extends AbstractDbUnitTestNGSpringContextTests +{ + + @Test + public void testLoad() throws Exception + { + // do nothing + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:18:49
|
Revision: 562 http://openutils.svn.sourceforge.net/openutils/?rev=562&view=rev Author: fgiust Date: 2008-01-27 03:18:51 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare release openutils-testing-testng-2.0 Modified Paths: -------------- trunk/openutils-testing-testng/pom.xml Modified: trunk/openutils-testing-testng/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2008-01-27 11:16:29 UTC (rev 561) +++ trunk/openutils-testing-testng/pom.xml 2008-01-27 11:18:51 UTC (rev 562) @@ -1,5 +1,4 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -9,7 +8,7 @@ </parent> <artifactId>openutils-testing-testng</artifactId> <name>openutils test utils (testng)</name> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> <description>openutils test utils</description> <dependencies> <dependency> @@ -171,4 +170,10 @@ <properties> <spring.version>2.5.1</spring.version> </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-testng-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-testng-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-testng-2.0</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:16:26
|
Revision: 561 http://openutils.svn.sourceforge.net/openutils/?rev=561&view=rev Author: fgiust Date: 2008-01-27 03:16:29 -0800 (Sun, 27 Jan 2008) Log Message: ----------- released version of openutils-testing Modified Paths: -------------- trunk/openutils-testing-junit/pom.xml trunk/openutils-testing-testng/pom.xml Modified: trunk/openutils-testing-junit/pom.xml =================================================================== --- trunk/openutils-testing-junit/pom.xml 2008-01-27 11:12:28 UTC (rev 560) +++ trunk/openutils-testing-junit/pom.xml 2008-01-27 11:16:29 UTC (rev 561) @@ -15,7 +15,7 @@ <dependency> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils-testing</artifactId> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> </dependency> <dependency> <groupId>org.springframework</groupId> @@ -35,7 +35,7 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>1.2</version> + <version>1.4.3</version> </dependency> <dependency> <groupId>log4j</groupId> Modified: trunk/openutils-testing-testng/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2008-01-27 11:12:28 UTC (rev 560) +++ trunk/openutils-testing-testng/pom.xml 2008-01-27 11:16:29 UTC (rev 561) @@ -15,7 +15,7 @@ <dependency> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils-testing</artifactId> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> </dependency> <dependency> <groupId>org.springframework</groupId> @@ -35,12 +35,12 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>1.4.1</version> + <version>1.4.3</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl104-over-slf4j</artifactId> - <version>1.4.1</version> + <version>1.4.3</version> </dependency> <dependency> <groupId>org.springframework</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:12:24
|
Revision: 560 http://openutils.svn.sourceforge.net/openutils/?rev=560&view=rev Author: fgiust Date: 2008-01-27 03:12:28 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-testing/pom.xml Modified: trunk/openutils-testing/pom.xml =================================================================== --- trunk/openutils-testing/pom.xml 2008-01-27 11:12:20 UTC (rev 559) +++ trunk/openutils-testing/pom.xml 2008-01-27 11:12:28 UTC (rev 560) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-testing</artifactId> <name>openutils test utils</name> - <version>2.0</version> + <version>2.0.1-SNAPSHOT</version> <description>openutils test utils</description> <dependencies> <dependency> @@ -61,10 +61,4 @@ <properties> <spring.version>2.5.1</spring.version> </properties> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-2.0</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-2.0</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-2.0</url> - </scm> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:12:16
|
Revision: 559 http://openutils.svn.sourceforge.net/openutils/?rev=559&view=rev Author: fgiust Date: 2008-01-27 03:12:20 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-testing-2.0 Added Paths: ----------- tags/openutils-testing-2.0/ tags/openutils-testing-2.0/pom.xml tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java tags/openutils-testing-2.0/src/site/apt/dbunit.apt tags/openutils-testing-2.0/src/site/apt/index.apt tags/openutils-testing-2.0/src/site/site.xml Removed Paths: ------------- tags/openutils-testing-2.0/pom.xml tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java tags/openutils-testing-2.0/src/site/apt/index.apt tags/openutils-testing-2.0/src/site/site.xml Copied: tags/openutils-testing-2.0 (from rev 539, trunk/openutils-testing) Deleted: tags/openutils-testing-2.0/pom.xml =================================================================== --- trunk/openutils-testing/pom.xml 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/pom.xml 2008-01-27 11:12:20 UTC (rev 559) @@ -1,65 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>6</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-testing</artifactId> - <name>openutils test utils</name> - <version>2.0-SNAPSHOT</version> - <description>openutils test utils</description> - <dependencies> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.4.1</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl104-over-slf4j</artifactId> - <version>1.4.1</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.dbunit</groupId> - <artifactId>dbunit</artifactId> - <version>2.2</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>junit-addons</groupId> - <artifactId>junit-addons</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - <properties> - <spring.version>2.5.1</spring.version> - </properties> -</project> Copied: tags/openutils-testing-2.0/pom.xml (from rev 558, trunk/openutils-testing/pom.xml) =================================================================== --- tags/openutils-testing-2.0/pom.xml (rev 0) +++ tags/openutils-testing-2.0/pom.xml 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,70 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>7</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-testing</artifactId> + <name>openutils test utils</name> + <version>2.0</version> + <description>openutils test utils</description> + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.dbunit</groupId> + <artifactId>dbunit</artifactId> + <version>2.2</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>junit-addons</groupId> + <artifactId>junit-addons</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + <properties> + <spring.version>2.5.1</spring.version> + </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-2.0</url> + </scm> +</project> Deleted: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-27 11:12:20 UTC (rev 559) @@ -1,38 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * @author fgiust - * @version $Id: $ - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Inherited -@Documented -public @interface DbUnitConfiguration { - - DbUnitExecution[] dbUnitExecutions() default {}; - -} \ No newline at end of file Copied: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java (from rev 549, trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java) =================================================================== --- tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java (rev 0) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,44 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * A DbUnitConfiguration can contain one or more {@link DbUnitExecution}. + * @author fgiust + * @version $Id: $ + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Inherited +@Documented +public @interface DbUnitConfiguration { + + /** + * Array of {@link DbUnitExecution} + */ + DbUnitExecution[] dbUnitExecutions() default { + + }; + +} \ No newline at end of file Deleted: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-27 11:12:20 UTC (rev 559) @@ -1,55 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.dbunit.operation.DatabaseOperation; - - -/** - * @author fgiust - * @version $Id: $ - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Inherited -@Documented -public @interface DbUnitExecution { - - /** - * The resource locations to use for loading dbunit dataset. - */ - String[] datasets() default {}; - - String dataSource() default ""; - - String schema() default ""; - - String excludedTables() default "(^\\$(.*))"; // oracle recycle bin - - boolean truncateAll() default true; - - Class< ? extends DatabaseOperation> truncateOperation() default org.dbunit.operation.TruncateTableOperation.class; - - Class< ? extends DatabaseOperation> insertOperation() default org.dbunit.operation.InsertOperation.class; - -} \ No newline at end of file Copied: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java (from rev 549, trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java) =================================================================== --- tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java (rev 0) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,78 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.dbunit.operation.DatabaseOperation; + + +/** + * @author fgiust + * @version $Id: $ + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Inherited +@Documented +public @interface DbUnitExecution { + + /** + * The resource locations to use for loading dbunit dataset. + */ + String[] datasets() default { + + }; + + /** + * The name of the datasource to use. If can be left unset only if there is only one DataSource available in the + * Spring context. + */ + String dataSource() default ""; + + /** + * Db schema name that will be given to dbUnit. Can be left unset if not needed (database specific) + */ + String schema() default ""; + + /** + * A regexp that can match table names. Any table matching this regular expression will not be considered by DbUnit. + * By default tables starting with $ are ignored (oracle recycle bin). + */ + String excludedTables() default "(^\\$(.*))"; // oracle recycle bin + + /** + * If true, <strong>all</strong> the tables in the database will be truncated before loading any dataset. + */ + boolean truncateAll() default true; + + /** + * The database operation that will be used to truncate tables. Defaults to + * org.dbunit.operation.TruncateTableOperation + */ + Class< ? extends DatabaseOperation> truncateOperation() default org.dbunit.operation.TruncateTableOperation.class; + + /** + * The database operation that will be used to load datasets. Defaults to org.dbunit.operation.InsertOperation + */ + Class< ? extends DatabaseOperation> insertOperation() default org.dbunit.operation.InsertOperation.class; + +} \ No newline at end of file Deleted: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-27 11:12:20 UTC (rev 559) @@ -1,246 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing; - -import java.io.IOException; -import java.net.URL; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; - -import javax.sql.DataSource; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.dbunit.DatabaseUnitException; -import org.dbunit.database.DatabaseConnection; -import org.dbunit.database.DatabaseSequenceFilter; -import org.dbunit.database.IDatabaseConnection; -import org.dbunit.dataset.DataSetException; -import org.dbunit.dataset.FilteredDataSet; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.filter.ITableFilter; -import org.dbunit.dataset.filter.SequenceTableFilter; -import org.dbunit.operation.DatabaseOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; - - -/** - * @author fgiust - * @version $Id: $ - */ -public class DbUnitTestContext -{ - - /** - * Logger. - */ - private static Logger log = LoggerFactory.getLogger(DbUnitTestContext.class); - - private Object testcase; - - private ApplicationContext applicationContext; - - /** - * Dataset cache. - */ - private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>(); - - /** - * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive - * and it doesn't change across tests. - */ - protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>(); - - public DbUnitTestContext(Object testcase, ApplicationContext applicationContext) - { - this.testcase = testcase; - this.applicationContext = applicationContext; - } - - /** - * Setup the Database before running the test method. - * @throws Exception Any exception. - */ - @SuppressWarnings("unchecked") - public void setUpDbUnit() throws Exception - { - DbUnitExecution singleDbUnitExecution = testcase.getClass().getAnnotation(DbUnitExecution.class); - - DbUnitExecution[] executions; - if (singleDbUnitExecution != null) - { - executions = new DbUnitExecution[]{singleDbUnitExecution }; - } - else - { - DbUnitConfiguration dbUnitConfiguration = testcase.getClass().getAnnotation(DbUnitConfiguration.class); - executions = dbUnitConfiguration.dbUnitExecutions(); - } - - for (DbUnitExecution dbUnitExecution : executions) - { - String[] datasets = dbUnitExecution.datasets(); - String dataSourceName = dbUnitExecution.dataSource(); - String schema = dbUnitExecution.schema(); - if (StringUtils.isEmpty(schema)) - { - schema = null; - } - - IDatabaseConnection connection = new DatabaseConnection( - getDatasource(dataSourceName).getConnection(), - schema); - - try - { - ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables()); - - if (dbUnitExecution.truncateAll()) - { - truncateAll(connection, tableFilter, dataSourceName, dbUnitExecution - .truncateOperation() - .newInstance()); - } - - DatabaseOperation dbOperation = dbUnitExecution.insertOperation().newInstance(); - for (String datasetFile : datasets) - { - importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName, dbOperation); - } - } - finally - { - connection.close(); - } - } - } - - /** - * @param datasetFile - * @return - * @throws IOException - * @throws DataSetException - */ - private IDataSet createDataset(String datasetFile) throws IOException, DataSetException - { - IDataSet dataSet = datasetCache.get(datasetFile); - if (dataSet == null) - { - URL datasetUrl = getClass().getResource(datasetFile); - if (datasetUrl == null) - { - throw new IllegalArgumentException("Dataset " + datasetFile + " not found"); - } - dataSet = DbUnitUtils.loadDataset(datasetUrl); - datasetCache.put(datasetFile, dataSet); - } - return dataSet; - } - - private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter, - String dataSourceName, DatabaseOperation databaseOperation) throws SQLException, DataSetException, - DatabaseUnitException - { - - if (dataSet == null) - { - throw new IllegalArgumentException("dataSet is null"); - } - - IDataSet orderedDataset = new FilteredDataSet(tableFilter, dataSet); - if (log.isDebugEnabled()) - { - log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames())); - } - - // if a sorted dataset is available, use table sequence for sorting - IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema()); - if (truncateDataSet != null) - { - ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames()); - orderedDataset = new FilteredDataSet(filter, dataSet); - } - - if (dataSet != null) - { - databaseOperation.execute(connection, orderedDataset); - } - - } - - /** - * @param connection - * @param tableFilter - * @throws SQLException - * @throws DataSetException - * @throws DatabaseUnitException - */ - private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter, String dataSourceName, - DatabaseOperation databaseOperation) throws SQLException, DataSetException, DatabaseUnitException - { - IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema()); - if (truncateDataSet == null) - { - log.debug("Generating sorted dataset for initial cleanup"); - IDataSet unsortedDataSet = connection.createDataSet(); - - log.debug("Unfiltered truncateDataSet: {}", ArrayUtils.toString(unsortedDataSet.getTableNames())); - - ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet( - tableFilter, - unsortedDataSet).getTableNames()); - truncateDataSet = new FilteredDataSet(tableFilter, new FilteredDataSet(filter, unsortedDataSet)); - storeTruncateDataset(dataSourceName, connection.getSchema(), truncateDataSet); - log.debug("Sorted dataset generated"); - } - - log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames())); - if (truncateDataSet != null) - { - databaseOperation.execute(connection, truncateDataSet); - } - } - - private IDataSet getTruncateDataset(String datasourceName, String schema) - { - return truncateDataSetCache.get(datasourceName + "_" + StringUtils.defaultString(schema)); - } - - private IDataSet storeTruncateDataset(String datasourceName, String schema, IDataSet dataset) - { - return truncateDataSetCache.put(datasourceName + "_" + StringUtils.defaultString(schema), dataset); - } - - @SuppressWarnings("unchecked") - protected DataSource getDatasource(String name) - { - if (StringUtils.isEmpty(name)) - { - Map<String, DataSource> dsMap = applicationContext.getBeansOfType(DataSource.class); - if (dsMap == null || dsMap.size() != 1) - { - throw new RuntimeException( - "Unable to find a datasource in spring applicationContext, please specify the datasource bean name " - + "using the \"datasource\" attribute of @DbUnitConfiguration"); - } - return dsMap.values().iterator().next(); - } - return (DataSource) applicationContext.getBean(name); - } -} Copied: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java (from rev 549, trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java) =================================================================== --- tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java (rev 0) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,319 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing; + +import java.io.IOException; +import java.net.URL; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +import javax.sql.DataSource; + +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.dbunit.DatabaseUnitException; +import org.dbunit.database.DatabaseConnection; +import org.dbunit.database.DatabaseSequenceFilter; +import org.dbunit.database.IDatabaseConnection; +import org.dbunit.dataset.DataSetException; +import org.dbunit.dataset.FilteredDataSet; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.filter.ITableFilter; +import org.dbunit.dataset.filter.SequenceTableFilter; +import org.dbunit.operation.DatabaseOperation; +import org.dbunit.operation.DeleteAllOperation; +import org.dbunit.operation.DeleteOperation; +import org.dbunit.operation.InsertOperation; +import org.dbunit.operation.RefreshOperation; +import org.dbunit.operation.TruncateTableOperation; +import org.dbunit.operation.UpdateOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; + + +/** + * @author fgiust + * @version $Id: $ + */ +public class DbUnitTestContext +{ + + /** + * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive + * and it doesn't change across tests. + */ + protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>(); + + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(DbUnitTestContext.class); + + /** + * The test instance. + */ + private Object testcase; + + /** + * Spring application context. + */ + private ApplicationContext applicationContext; + + /** + * Dataset cache. + */ + private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>(); + + /** + * Instantiates a new DbUnitTestContext + * @param testcase test instance + * @param applicationContext Spring application context + */ + public DbUnitTestContext(Object testcase, ApplicationContext applicationContext) + { + this.testcase = testcase; + this.applicationContext = applicationContext; + } + + /** + * Setup the Database before running the test method. + * @throws Exception Any exception. + */ + @SuppressWarnings("unchecked") + public void setUpDbUnit() throws Exception + { + DbUnitExecution singleDbUnitExecution = testcase.getClass().getAnnotation(DbUnitExecution.class); + + DbUnitExecution[] executions = null; + if (singleDbUnitExecution != null) + { + executions = new DbUnitExecution[]{singleDbUnitExecution }; + } + else + { + DbUnitConfiguration dbUnitConfiguration = testcase.getClass().getAnnotation(DbUnitConfiguration.class); + if (dbUnitConfiguration != null) + { + executions = dbUnitConfiguration.dbUnitExecutions(); + } + } + if (executions != null) + { + for (DbUnitExecution dbUnitExecution : executions) + { + String[] datasets = dbUnitExecution.datasets(); + String dataSourceName = dbUnitExecution.dataSource(); + String schema = dbUnitExecution.schema(); + if (StringUtils.isEmpty(schema)) + { + schema = null; + } + + IDatabaseConnection connection = new DatabaseConnection( + getDatasource(dataSourceName).getConnection(), + schema); + + try + { + ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables()); + + if (dbUnitExecution.truncateAll()) + { + truncateAll(connection, tableFilter, dataSourceName, getDatabaseOperation(dbUnitExecution + .truncateOperation())); + } + + DatabaseOperation dbOperation = getDatabaseOperation(dbUnitExecution.insertOperation()); + for (String datasetFile : datasets) + { + importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName, dbOperation); + } + } + finally + { + connection.close(); + } + } + } + } + + /** + * Instantiates the givec Database Operation. Standard operations in the <code>org.dbunit.operation</code> package + * have protected constructors and needs to be accessed using the public static fields in + * <code>org.dbunit.operation.DatabaseOperation</code>. + * @param dboperationClass db operation class + * @return db operation instance + * @throws InstantiationException if the given db operation class cannot be instantiated + * @throws IllegalAccessException if the given db operation class cannot be instantiated + */ + private DatabaseOperation getDatabaseOperation(Class< ? extends DatabaseOperation> dboperationClass) + throws InstantiationException, IllegalAccessException + { + if (UpdateOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.UPDATE; + } + else if (InsertOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.INSERT; + } + else if (RefreshOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.REFRESH; + } + else if (DeleteOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.DELETE; + } + else if (DeleteAllOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.DELETE_ALL; + } + else if (TruncateTableOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.TRUNCATE_TABLE; + } + else if (DeleteOperation.class.equals(dboperationClass)) + { + return DatabaseOperation.UPDATE; + } + + return dboperationClass.newInstance(); + + } + + /** + * Creates a dataset instance by fetching a file from the classpath + * @param datasetFile name of the file, will be loaded from the classpath + * @return IDataSet instance + * @throws IOException + * @throws DataSetException + */ + private IDataSet createDataset(String datasetFile) throws IOException, DataSetException + { + IDataSet dataSet = datasetCache.get(datasetFile); + if (dataSet == null) + { + URL datasetUrl = getClass().getResource(datasetFile); + if (datasetUrl == null) + { + throw new IllegalArgumentException("Dataset " + datasetFile + " not found"); + } + dataSet = DbUnitUtils.loadDataset(datasetUrl); + datasetCache.put(datasetFile, dataSet); + } + return dataSet; + } + + private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter, + String dataSourceName, DatabaseOperation databaseOperation) throws SQLException, DataSetException, + DatabaseUnitException + { + + if (dataSet == null) + { + throw new IllegalArgumentException("dataSet is null"); + } + + IDataSet orderedDataset = new FilteredDataSet(tableFilter, dataSet); + if (log.isDebugEnabled()) + { + log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames())); + } + + // if a sorted dataset is available, use table sequence for sorting + IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema()); + if (truncateDataSet != null) + { + ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames()); + orderedDataset = new FilteredDataSet(filter, dataSet); + } + + if (dataSet != null) + { + databaseOperation.execute(connection, orderedDataset); + } + + } + + /** + * @param connection + * @param tableFilter + * @throws SQLException + * @throws DataSetException + * @throws DatabaseUnitException + */ + private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter, String dataSourceName, + DatabaseOperation databaseOperation) throws SQLException, DataSetException, DatabaseUnitException + { + IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema()); + if (truncateDataSet == null) + { + log.debug("Generating sorted dataset for initial cleanup"); + IDataSet unsortedDataSet = connection.createDataSet(); + + log.debug("Unfiltered truncateDataSet: {}", ArrayUtils.toString(unsortedDataSet.getTableNames())); + + ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet( + tableFilter, + unsortedDataSet).getTableNames()); + truncateDataSet = new FilteredDataSet(tableFilter, new FilteredDataSet(filter, unsortedDataSet)); + storeTruncateDataset(dataSourceName, connection.getSchema(), truncateDataSet); + log.debug("Sorted dataset generated"); + } + + log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames())); + if (truncateDataSet != null) + { + databaseOperation.execute(connection, truncateDataSet); + } + } + + private IDataSet getTruncateDataset(String datasourceName, String schema) + { + return truncateDataSetCache.get(datasourceName + "_" + StringUtils.defaultString(schema)); + } + + private IDataSet storeTruncateDataset(String datasourceName, String schema, IDataSet dataset) + { + return truncateDataSetCache.put(datasourceName + "_" + StringUtils.defaultString(schema), dataset); + } + + /** + * Loads a named datasource from the spring context. + * @param name datasource name. + * @return Datasource instance + */ + @SuppressWarnings("unchecked") + protected DataSource getDatasource(String name) + { + if (StringUtils.isEmpty(name)) + { + Map<String, DataSource> dsMap = applicationContext.getBeansOfType(DataSource.class); + if (dsMap == null || dsMap.size() != 1) + { + throw new RuntimeException( + "Unable to find a datasource in spring applicationContext, please specify the datasource bean name " + + "using the \"datasource\" attribute of @DbUnitConfiguration"); + } + return dsMap.values().iterator().next(); + } + return (DataSource) applicationContext.getBean(name); + } + +} Deleted: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-27 11:12:20 UTC (rev 559) @@ -1,115 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.sql.SQLException; - -import org.apache.commons.lang.StringUtils; -import org.dbunit.database.IDatabaseConnection; -import org.dbunit.dataset.DataSetException; -import org.dbunit.dataset.FilteredDataSet; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.excel.XlsDataSet; -import org.dbunit.dataset.xml.XmlDataSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @author fgiust - * @version $Id: $ - */ -public final class DbUnitUtils -{ - - /** - * Logger. - */ - private static Logger log = LoggerFactory.getLogger(DbUnitUtils.class); - - /** - * @param connection - * @param tableNames - * @param file - * @param xls - * @throws SQLException - * @throws IOException - * @throws DataSetException - */ - public static void exportDataset(IDatabaseConnection connection, String[] tableNames, File file) - throws SQLException, IOException, DataSetException - { - OutputStream fos = null; - - try - { - IDataSet fullDataSet = connection.createDataSet(); - - if (tableNames != null && tableNames.length > 0) - { - fullDataSet = new FilteredDataSet(tableNames, fullDataSet); - } - - fos = new FileOutputStream(file); - if (StringUtils.equalsIgnoreCase(StringUtils.substringAfterLast(file.getName(), "."), "xls")) - { - XlsDataSet.write(fullDataSet, fos); - } - else - { - XmlDataSet.write(fullDataSet, fos); - } - } - finally - { - connection.close(); - fos.close(); - } - - log.debug("Dataset exported at {}", file.getAbsolutePath()); - } - - /** - * @param url - * @return - * @throws IOException - * @throws DataSetException - */ - public static IDataSet loadDataset(URL url) throws IOException, DataSetException - { - if (url == null) - { - throw new IllegalArgumentException("URL is null"); - } - InputStream is = url.openStream(); - IDataSet dataSet = null; - - if (is != null) - { - log.debug("loading dataset {}", url.getFile()); - dataSet = url.getFile().endsWith(".xls") ? new XlsDataSet(is) : new XmlDataSet(is); - is.close(); - } - return dataSet; - } - -} Copied: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java (from rev 549, trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java) =================================================================== --- tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java (rev 0) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,123 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.sql.SQLException; + +import org.apache.commons.lang.StringUtils; +import org.dbunit.database.IDatabaseConnection; +import org.dbunit.dataset.DataSetException; +import org.dbunit.dataset.FilteredDataSet; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.excel.XlsDataSet; +import org.dbunit.dataset.xml.XmlDataSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author fgiust + * @version $Id: $ + */ +public final class DbUnitUtils +{ + + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(DbUnitUtils.class); + + /** + * Do not instantiate. + */ + private DbUnitUtils() + { + // do not instantiate + } + + /** + * Exports a list of table to an xml/xsl file + * @param file The file name we save the dataset to + * @param connection connection to use + * @param tableNames optional list of table names + * @throws IOException An IO Exception. + * @throws DataSetException A dataset exception. + * @throws SQLException A SQL Exception. + */ + public static void exportDataset(IDatabaseConnection connection, String[] tableNames, File file) + throws SQLException, IOException, DataSetException + { + OutputStream fos = null; + + try + { + IDataSet fullDataSet = connection.createDataSet(); + + if (tableNames != null && tableNames.length > 0) + { + fullDataSet = new FilteredDataSet(tableNames, fullDataSet); + } + + fos = new FileOutputStream(file); + if (StringUtils.equalsIgnoreCase(StringUtils.substringAfterLast(file.getName(), "."), "xls")) + { + XlsDataSet.write(fullDataSet, fos); + } + else + { + XmlDataSet.write(fullDataSet, fos); + } + } + finally + { + connection.close(); + fos.close(); + } + + log.debug("Dataset exported at {}", file.getAbsolutePath()); + } + + /** + * @param url dataset url (can be an xml or excel file) + * @return loaded dataset + * @throws IOException error reading the file + * @throws DataSetException error loading the dataset + */ + public static IDataSet loadDataset(URL url) throws IOException, DataSetException + { + if (url == null) + { + throw new IllegalArgumentException("URL is null"); + } + InputStream is = url.openStream(); + IDataSet dataSet = null; + + if (is != null) + { + log.debug("loading dataset {}", url.getFile()); + dataSet = url.getFile().endsWith(".xls") ? new XlsDataSet(is) : new XmlDataSet(is); + is.close(); + } + return dataSet; + } + +} Deleted: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-27 11:12:20 UTC (rev 559) @@ -1,50 +0,0 @@ -/* - * Copyright Openmind http://www.openmindonline.it - * - * 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 it.openutils.testing; - -import java.util.regex.Pattern; - -import org.dbunit.dataset.DataSetException; -import org.dbunit.dataset.filter.AbstractTableFilter; - - -/** - * @author fgiust - * @version $Id: $ - */ -public class RegExpTableFilter extends AbstractTableFilter -{ - - private Pattern pattern; - - public RegExpTableFilter(String pattern) - { - if (pattern != null) - { - this.pattern = Pattern.compile(pattern); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isValidName(String tableName) throws DataSetException - { - return pattern == null || !pattern.matcher(tableName).matches(); - } - -} Copied: tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java (from rev 549, trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java) =================================================================== --- tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java (rev 0) +++ tags/openutils-testing-2.0/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,55 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing; + +import java.util.regex.Pattern; + +import org.dbunit.dataset.DataSetException; +import org.dbunit.dataset.filter.AbstractTableFilter; + + +/** + * A table filter that excludes tables mathing the given regexp. + * @author fgiust + * @version $Id: $ + */ +public class RegExpTableFilter extends AbstractTableFilter +{ + + private Pattern pattern; + + /** + * Instantiates a new RegExpTableFilter + * @param pattern regexp pattern + */ + public RegExpTableFilter(String pattern) + { + if (pattern != null) + { + this.pattern = Pattern.compile(pattern); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isValidName(String tableName) throws DataSetException + { + return pattern == null || !pattern.matcher(tableName).matches(); + } + +} Copied: tags/openutils-testing-2.0/src/site/apt/dbunit.apt (from rev 550, trunk/openutils-testing/src/site/apt/dbunit.apt) =================================================================== --- tags/openutils-testing-2.0/src/site/apt/dbunit.apt (rev 0) +++ tags/openutils-testing-2.0/src/site/apt/dbunit.apt 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,76 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + + +DbUnit tests + + Openutils provide a base class that take cares of the common operations involved in preparing the test environment using + DbUnit. + + You can extend <<<it.openutils.testing.testng.AbstractDbUnitTestNGSpringContextTests>>> or + <<<it.openutils.testing.junit.AbstractDbUnitJunitSpringContextTests>>>, depending on the test framework of your choice + (remember to include the appropriate dependency, openutils-testing-testng or openutils-testing-junit). + Apart from the underline test framework used, there is no difference in how those class will work. + + Those base classes extend the standard <<<Abstract*SpringContextTests>>> classes provided by Spring, so they support + dependency injection and needs to be configured from a Spring context. + +How to + + All the setup can be configured using annotations. This is a sample test that can make use of data loaded by DbUnit: + ++----------------------------------------------+ + +@ContextConfiguration(locations = {"/spring-tests.xml" }) +@DbUnitExecution(datasets = {"/db1-load.xml" }) +public class SampleDbUnitTest extends AbstractDbUnitTestNGSpringContextTests +{ + @Test + public void testSomething() { + ... + } +} + ++----------------------------------------------+ + + The <<<DbUnitExecution>>> annotation controls how the setup will be performed. It can be configured with a list of file names + (xml od xsl DbUnit datasets) that will be loaded before every single method in this test class is executed. + + In detail the setup that will be performed before each method is: + + * truncate *any table* in the database. This can be turned of by the <<<truncateAll>>> DbUnitExecution parameter + + * load the given datasets into the db + + [] + + You can setup also more than one execution if your tests depend on more than one database or schema, annotating your + class like in this example: + ++----------------------------------------------+ + +@DbUnitConfiguration(dbUnitExecutions = { + @DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1"), + @DbUnitExecution(datasets = {"/db2-load.xml" }, dataSource = "dataSource2") }) + ++----------------------------------------------+ + + + Note that this test classes don't extend Spring transactional tests, so you need to manually turn on Transactions using + standard Spring annotations: + ++----------------------------------------------+ + +@TestExecutionListeners({TransactionalTestExecutionListener.class }) +@Transactional + ++----------------------------------------------+ + + Also note that the content of your db will definitively be modified by these tests, they are expected to be run on a + test-only instance! + + + Deleted: tags/openutils-testing-2.0/src/site/apt/index.apt =================================================================== --- trunk/openutils-testing/src/site/apt/index.apt 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/site/apt/index.apt 2008-01-27 11:12:20 UTC (rev 559) @@ -1,8 +0,0 @@ - -------------------------- - O p e n u t i l s - -------------------------- - Fabrizio Giustina - -------------------------- - -openutils-testing - Copied: tags/openutils-testing-2.0/src/site/apt/index.apt (from rev 550, trunk/openutils-testing/src/site/apt/index.apt) =================================================================== --- tags/openutils-testing-2.0/src/site/apt/index.apt (rev 0) +++ tags/openutils-testing-2.0/src/site/apt/index.apt 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,27 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + +openutils-testing + + Openutils-testing extends the standard spring testing framework by providing more high-level base testing classes and utils. + + In particular, it provides a {{{dbunit.html}framework for using with dbunit in Spring test cases}}. + + The openutils-testing jar only contains generic classes that don't depends on any specific test framework. You should + depend on openutils-testing-testng or openutils-testing-junit + + + +Released versions + + openutils-testing-testng: + + {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}} + + openutils-testing-junit: + + {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}} + Deleted: tags/openutils-testing-2.0/src/site/site.xml =================================================================== --- trunk/openutils-testing/src/site/site.xml 2008-01-20 19:22:22 UTC (rev 539) +++ tags/openutils-testing-2.0/src/site/site.xml 2008-01-27 11:12:20 UTC (rev 559) @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="Openutils testing"> - <publishDate position="left" format="yyyy-MM-dd" /> - <bannerRight> - <name>Openutils</name> - <src>http://openutils.sourceforge.net/images/openutils-logo.png</src> - <href>http://openutils.sourceforge.net</href> - </bannerRight> - <bannerLeft> - <name>Sourceforge</name> - <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> - <href>http://www.sourceforge.net/projects/openutils</href> - </bannerLeft> - <body> - <head> - <link rel="icon" href="images/favicon.ico" /> - </head> - <menu name="openutils testing"> - <item name="Usage" href="index.html"></item> - </menu> - <menu ref="modules" inherit="bottom" /> - <menu ref="reports" inherit="bottom" /> - </body> - <skin> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils-maven-skin</artifactId> - <version>1.0</version> - </skin> -</project> Copied: tags/openutils-testing-2.0/src/site/site.xml (from rev 553, trunk/openutils-testing/src/site/site.xml) =================================================================== --- tags/openutils-testing-2.0/src/site/site.xml (rev 0) +++ tags/openutils-testing-2.0/src/site/site.xml 2008-01-27 11:12:20 UTC (rev 559) @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="Openutils testing"> + <publishDate position="navigation-bottom" format="yyyy-MM-dd" /> + <version position="navigation-bottom" /> + <bannerRight> + <name>Openutils</name> + <src>http://openutils.sourceforge.net/images/openutils-logo.png</src> + <href>http://openutils.sourceforge.net</href> + </bannerRight> + <bannerLeft> + <name>Sourceforge</name> + <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> + <href>http://www.sourceforge.net/projects/openutils</href> + </bannerLeft> + <body> + <head> + <link rel="icon" href="images/favicon.ico" /> + </head> + <breadcrumbs> + <item name="openutils" href="http://openutils.sourceforge.net/" /> + <item name="openutils-testing" href="http://openutils.sourceforge.net/openutils-testing" /> + </breadcrumbs> + <menu name="openutils testing"> + <item name="Usage" href="index.html"></item> + <item name="DbUnit tests" href="dbunit.html"></item> + </menu> + <menu ref="modules" inherit="bottom" /> + <menu ref="reports" inherit="bottom" /> + </body> + <skin> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-maven-skin</artifactId> + <version>1.0</version> + </skin> +</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:12:00
|
Revision: 558 http://openutils.svn.sourceforge.net/openutils/?rev=558&view=rev Author: fgiust Date: 2008-01-27 03:12:01 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare release openutils-testing-2.0 Modified Paths: -------------- trunk/openutils-testing/pom.xml Modified: trunk/openutils-testing/pom.xml =================================================================== --- trunk/openutils-testing/pom.xml 2008-01-27 11:09:26 UTC (rev 557) +++ trunk/openutils-testing/pom.xml 2008-01-27 11:12:01 UTC (rev 558) @@ -1,5 +1,4 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -9,7 +8,7 @@ </parent> <artifactId>openutils-testing</artifactId> <name>openutils test utils</name> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> <description>openutils test utils</description> <dependencies> <dependency> @@ -62,4 +61,10 @@ <properties> <spring.version>2.5.1</spring.version> </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-testing-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-testing-2.0</url> + </scm> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 11:09:21
|
Revision: 557 http://openutils.svn.sourceforge.net/openutils/?rev=557&view=rev Author: fgiust Date: 2008-01-27 03:09:26 -0800 (Sun, 27 Jan 2008) Log Message: ----------- upgrade to testng 5.7 Modified Paths: -------------- trunk/openutils-testing-testng/pom.xml Removed Paths: ------------- trunk/openutils-testing-testng/derby.log Deleted: trunk/openutils-testing-testng/derby.log =================================================================== --- trunk/openutils-testing-testng/derby.log 2008-01-27 10:55:21 UTC (rev 556) +++ trunk/openutils-testing-testng/derby.log 2008-01-27 11:09:26 UTC (rev 557) @@ -1,6 +0,0 @@ ----------------------------------------------------------------- -2008-01-20 20:42:12.281 GMT: - Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.2.0 - (485682): instance c013800d-0117-98ef-dce7-000001d801b8 -on database directory /data/apps/openmind/openutils-trunk/openutils-testing-testng/target/test-db1 - -Database Class Loader started - derby.database.classpath='' Modified: trunk/openutils-testing-testng/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2008-01-27 10:55:21 UTC (rev 556) +++ trunk/openutils-testing-testng/pom.xml 2008-01-27 11:09:26 UTC (rev 557) @@ -11,14 +11,6 @@ <name>openutils test utils (testng)</name> <version>2.0-SNAPSHOT</version> <description>openutils test utils</description> - <build> - <plugins> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.4</version> - </plugin> - </plugins> - </build> <dependencies> <dependency> <groupId>net.sourceforge.openutils</groupId> @@ -113,7 +105,7 @@ <groupId>org.testng</groupId> <artifactId>testng</artifactId> <classifier>jdk15</classifier> - <version>5.1</version> + <version>5.7</version> <exclusions> <exclusion> <groupId>junit</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 10:55:15
|
Revision: 556 http://openutils.svn.sourceforge.net/openutils/?rev=556&view=rev Author: fgiust Date: 2008-01-27 02:55:21 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/openutils-bshd5/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2008-01-27 10:55:14 UTC (rev 555) +++ trunk/openutils-bshd5/pom.xml 2008-01-27 10:55:21 UTC (rev 556) @@ -8,7 +8,7 @@ </parent> <artifactId>openutils-bshd5</artifactId> <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>2.0</version> + <version>2.0.1-SNAPSHOT</version> <description>openutils base Spring-Hibernate DAO for java 5.0</description> <dependencies> <dependency> @@ -105,10 +105,4 @@ <properties> <spring.version>2.5.1</spring.version> </properties> - - <scm> - <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0</connection> - <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0</developerConnection> - <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-2.0</url> - </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 10:55:10
|
Revision: 555 http://openutils.svn.sourceforge.net/openutils/?rev=555&view=rev Author: fgiust Date: 2008-01-27 02:55:14 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-bshd5-2.0 Added Paths: ----------- tags/openutils-bshd5-2.0/ tags/openutils-bshd5-2.0/pom.xml tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/FilterMetadata.java tags/openutils-bshd5-2.0/src/site/apt/ tags/openutils-bshd5-2.0/src/site/apt/configuration.apt tags/openutils-bshd5-2.0/src/site/apt/index.apt tags/openutils-bshd5-2.0/src/site/site.xml Removed Paths: ------------- tags/openutils-bshd5-2.0/pom.xml tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/FilterMetadata.java tags/openutils-bshd5-2.0/src/site/site.xml Copied: tags/openutils-bshd5-2.0 (from rev 536, trunk/openutils-bshd5) Deleted: tags/openutils-bshd5-2.0/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-bshd5-2.0/pom.xml 2008-01-27 10:55:14 UTC (rev 555) @@ -1,115 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>6</version> - <relativePath>..</relativePath> - </parent> - <artifactId>openutils-bshd5</artifactId> - <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>2.0-SNAPSHOT</version> - <description>openutils base Spring-Hibernate DAO for java 5.0</description> - <dependencies> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.4.3</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl104-over-slf4j</artifactId> - <version>1.4.3</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-jdbc</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-orm</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-aop</artifactId> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate</artifactId> - <version>3.2.1.ga</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>cglib</groupId> - <artifactId>cglib</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>cglib</groupId> - <artifactId>cglib-nodep</artifactId> - <version>2.1_3</version> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - <version>1.7.0</version> - <exclusions> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <optional>true</optional> - </dependency> - </dependencies> - <properties> - <spring.version>2.5.1</spring.version> - </properties> -</project> \ No newline at end of file Copied: tags/openutils-bshd5-2.0/pom.xml (from rev 554, trunk/openutils-bshd5/pom.xml) =================================================================== --- tags/openutils-bshd5-2.0/pom.xml (rev 0) +++ tags/openutils-bshd5-2.0/pom.xml 2008-01-27 10:55:14 UTC (rev 555) @@ -0,0 +1,114 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>7</version> + <relativePath>..</relativePath> + </parent> + <artifactId>openutils-bshd5</artifactId> + <name>openutils base Spring-Hibernate DAO for java 5.0</name> + <version>2.0</version> + <description>openutils base Spring-Hibernate DAO for java 5.0</description> + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl104-over-slf4j</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-jdbc</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-orm</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.1.ga</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>2.1_3</version> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.7.0</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> + </dependencies> + <properties> + <spring.version>2.5.1</spring.version> + </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-2.0</url> + </scm> +</project> \ No newline at end of file Deleted: tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-01-27 10:55:14 UTC (rev 555) @@ -1,607 +0,0 @@ -package it.openutils.dao.hibernate; - -import it.openutils.hibernate.example.EnhancedExample; -import it.openutils.hibernate.example.FilterMetadata; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.aopalliance.aop.AspectException; -import org.hibernate.Criteria; -import org.hibernate.Hibernate; -import org.hibernate.HibernateException; -import org.hibernate.ObjectNotFoundException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.criterion.CriteriaSpecification; -import org.hibernate.criterion.Criterion; -import org.hibernate.criterion.Order; -import org.hibernate.type.Type; -import org.springframework.aop.framework.AopContext; -import org.springframework.orm.hibernate3.HibernateCallback; -import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - - -/** - * Base Hibernate DAO. - * @author Fabrizio Giustina - * @version $Id$ - * @param <T> Persistence class - * @param <K> Object Key - */ -public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport - implements - HibernateDAO<T, K> -{ - - private Class<T> referenceClass; - - private boolean aopenabled; - - public HibernateDAOImpl() - { - super(); - } - - /** - * @param referenceClass - */ - @SuppressWarnings({"unchecked" }) - public HibernateDAOImpl(Class referenceClass) - { - super(); - this.referenceClass = referenceClass; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> find(String query) - { - return getHibernateTemplate().find(query); - } - - /** - * {@inheritDoc} - */ - public List<T> findAll() - { - return findAll(getDefaultOrder()); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findAll(final Order[] orderProperties) - { - return getThis().findAll(orderProperties, new ArrayList<Criterion>()); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findAll(final Order[] orderProperties, final List<Criterion> criteria) - { - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(getReferenceClass()); - if (null != orderProperties) - { - for (int j = 0; j < orderProperties.length; j++) - { - crit.addOrder(orderProperties[j]); - } - - } - if (criteria != null) - { - for (Criterion criterion : criteria) - { - crit.add(criterion); - } - } - return crit.list(); - } - }); - } - - /** - * {@inheritDoc} - */ - public List<T> find(String query, Object obj, Type type) - { - return find(query, new Object[]{obj }, new Type[]{type }); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> find(final String query, final Object[] obj, final Type[] type) - { - return (List<T>) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - // hibernate 3 - return ses.createQuery(query).setParameters(obj, type).list(); - } - }); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T load(K key) - { - T result = (T) getHibernateTemplate().load(getReferenceClass(), key); - Hibernate.initialize(result); - return result; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T loadIfAvailable(K key) - { - T result; - try - { - result = (T) getHibernateTemplate().load(getReferenceClass(), key); - Hibernate.initialize(result); - } - catch (ObjectNotFoundException e) - { - // during lazy initialization - return null; - } - catch (HibernateObjectRetrievalFailureException e) - { - // during load - if (e.getCause() instanceof ObjectNotFoundException) - { - return null; - } - throw e; - } - return result; - } - - /** - * {@inheritDoc} - */ - public void saveOrUpdate(final T obj) - { - getHibernateTemplate().saveOrUpdate(obj); - } - - /** - * {@inheritDoc} - */ - public void update(T obj) - { - getHibernateTemplate().update(obj); - } - - /** - * {@inheritDoc} - */ - public boolean delete(final K key) - { - - return (Boolean) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - ses.delete(ses.load(getReferenceClass(), key)); - return true; - } - }); - - } - - /** - * {@inheritDoc} - */ - public void refresh(T obj) - { - getHibernateTemplate().refresh(obj); - } - - /** - * {@inheritDoc} - */ - public void evict(T obj) - { - getHibernateTemplate().evict(obj); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public T merge(final T obj) - { - return (T) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - return ses.merge(obj); - } - }); - - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public K save(T obj) - { - return (K) getHibernateTemplate().save(obj); - } - - /** - * {@inheritDoc} - */ - public T findFilteredFirst(final T filter) - { - return getFirstInCollection(findFiltered(filter, 1, 0)); - } - - /** - * {@inheritDoc} - */ - public T findFilteredFirst(final T filter, List<Criterion> criteria) - { - return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria)); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter) - { - return findFiltered(filter, getDefaultFilterMetadata()); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(T filter, Order[] orderProperties) - { - return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata) - { - return findFiltered(filter, metadata, Integer.MAX_VALUE, 0); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final int maxResults, final int page) - { - return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page); - } - - /** - * {@inheritDoc} - */ - public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults, - final int page) - { - return findFiltered(filter, null, metadata, maxResults, page); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, - final int maxResults, final int page) - { - return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, new ArrayList<Criterion>()); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public List<T> findFiltered(T filter, Order[] customOrder, Map<String, FilterMetadata> metadata, int maxResults, - int page, List<Criterion> additionalCriteria) - { - final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this - .getDefaultOrder(); - - return (List<T>) getHibernateTemplate().execute( - new HibernateCallbackForExecution(filter, page, maxResults, metadata, orderProperties, additionalCriteria)); - } - - /** - * Return the specific Object class that will be used for class-specific implementation of this DAO. - * @return the reference Class - */ - protected Class<T> getReferenceClass() - { - return referenceClass; - } - - public void setReferenceClass(Class<T> referenceClass) - { - this.referenceClass = referenceClass; - } - - /** - * Return a list of <code>Order</code> object to be used for the default ordering of the collection. - * @return the property name - */ - protected Order[] getDefaultOrder() - { - return new Order[0]; - } - - /** - * Obtain an instance of Query for a named query string defined in the mapping file. - * @param name the name of a query defined externally - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final int maxResults) - { - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - return q.list(); - } - }); - } - - /** - * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. - * @param name the name of a query defined externally - * @param params the parameter array - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final Serializable[] params, final int maxResults) - { - - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - if (null != params) - { - for (int i = 0; i < params.length; i++) - { - q.setParameter(i, params[i]); - } - } - return q.list(); - } - }); - } - - /** - * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. - * @param name the name of a query defined externally - * @param params the parameter Map - * @param maxResults max number of results - * @return Query - */ - protected List< ? > getNamedQuery(final String name, final Map<String, Object> params, final int maxResults) - { - return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() - { - - public Object doInHibernate(Session ses) throws HibernateException - { - Query q = ses.getNamedQuery(name); - q.setMaxResults(maxResults); - if (params != null) - { - for (Map.Entry<String, Object> entry : params.entrySet()) - { - setParameterValue(q, entry.getKey(), entry.getValue()); - } - } - return q.list(); - } - }); - } - - /** - * Convenience method to set paramers in the query given based on the actual object type in passed in as the value. - * You may need to add more functionaly to this as desired (or not use this at all). - * @param query the Query to set - * @param key the key name - * @param value the object to set as the parameter - */ - protected void setParameterValue(Query query, String key, Object value) - { - if (null == key || null == value) - { - return; - } - query.setParameter(key, value); - } - - /** - * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't - * set any default filter, subclasses may override this. - * @return map of property name - filter metadata - */ - protected Map<String, FilterMetadata> getDefaultFilterMetadata() - { - return new HashMap<String, FilterMetadata>(0); - } - - /** - * Returns the first object in the collection or null if the collection is null or empty. - * @param list collection - * @return first element in the list - */ - @SuppressWarnings("unchecked") - private T getFirstInCollection(Collection<T> list) - { - if (list != null && !list.isEmpty()) - { - Object result = list.iterator().next(); - Hibernate.initialize(result); - return (T) result; - } - return null; - } - - /** - * Sets the aopenabled. - * @param aopenabled the aopenabled to set - */ - public void setAopenabled(boolean aopenabled) - { - this.aopenabled = aopenabled; - } - - /** - * @return This is needed as for http://opensource.atlassian.com/projects/spring/browse/SPR-2226 - */ - @SuppressWarnings("unchecked") - private HibernateDAO<T, K> getThis() - { - if (!aopenabled) - { - return this; - } - - try - { - return (HibernateDAO<T, K>) AopContext.currentProxy(); - } - catch (AspectException exc) - { - logger.debug("Not running inside an AOP proxy, so no proxy can be returned: " + exc.getMessage()); - return this; - } - catch (IllegalStateException e) - { - logger.warn("Cannot access proxy: " + e.getMessage()); - aopenabled = false; - return this; - } - } - - /** - * @author carone - * @version $Id$ - */ - private final class HibernateCallbackForExecution implements HibernateCallback - { - - /** - * - */ - private final T filter; - - /** - * - */ - private final int page; - - /** - * - */ - private final int maxResults; - - /** - * - */ - private final Map<String, FilterMetadata> metadata; - - /** - * - */ - private final Order[] orderProperties; - - private List<Criterion> additionalCriteria; - - /** - * @param filter - * @param page - * @param maxResults - * @param metadata - * @param orderProperties - */ - private HibernateCallbackForExecution( - T filter, - int page, - int maxResults, - Map<String, FilterMetadata> metadata, - Order[] orderProperties, - List<Criterion> additionalCriteria) - { - this.filter = filter; - this.page = page; - this.maxResults = maxResults; - this.metadata = metadata; - this.orderProperties = orderProperties; - this.additionalCriteria = additionalCriteria; - } - - public Object doInHibernate(Session ses) throws HibernateException - { - Criteria crit = ses.createCriteria(filter.getClass()); - crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); - crit.setMaxResults(maxResults); - crit.setFirstResult(maxResults * page); - - if (orderProperties != null && orderProperties.length > 0) - { - for (Order order : orderProperties) - { - if (order != null) - { - crit.addOrder(order); - } - } - } - EnhancedExample.create(crit, filter, metadata); - if (additionalCriteria != null && !additionalCriteria.isEmpty()) - { - for (Criterion criterion : additionalCriteria) - { - crit.add(criterion); - } - } - return crit.list(); - } - } - -} \ No newline at end of file Copied: tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java (from rev 551, trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java) =================================================================== --- tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java (rev 0) +++ tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-01-27 10:55:14 UTC (rev 555) @@ -0,0 +1,611 @@ +package it.openutils.dao.hibernate; + +import it.openutils.hibernate.example.EnhancedExample; +import it.openutils.hibernate.example.FilterMetadata; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.aopalliance.aop.AspectException; +import org.hibernate.Criteria; +import org.hibernate.Hibernate; +import org.hibernate.HibernateException; +import org.hibernate.ObjectNotFoundException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.criterion.CriteriaSpecification; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Order; +import org.hibernate.type.Type; +import org.springframework.aop.framework.AopContext; +import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + + +/** + * Base Hibernate DAO. + * @author Fabrizio Giustina + * @version $Id$ + * @param <T> Persistence class + * @param <K> Object Key + */ +public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport + implements + HibernateDAO<T, K> +{ + + private Class<T> referenceClass; + + private boolean aopenabled; + + /** + * Instantiates a new DAO instance + */ + public HibernateDAOImpl() + { + super(); + } + + /** + * Sets the class of the persistent bean managed by this DAO + * @param referenceClass the class for the bean managed by this DAO + */ + @SuppressWarnings({"unchecked" }) + public HibernateDAOImpl(Class referenceClass) + { + super(); + this.referenceClass = referenceClass; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> find(String query) + { + return getHibernateTemplate().find(query); + } + + /** + * {@inheritDoc} + */ + public List<T> findAll() + { + return findAll(getDefaultOrder()); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findAll(final Order[] orderProperties) + { + return getThis().findAll(orderProperties, new ArrayList<Criterion>()); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findAll(final Order[] orderProperties, final List<Criterion> criteria) + { + return (List<T>) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Criteria crit = ses.createCriteria(getReferenceClass()); + if (null != orderProperties) + { + for (int j = 0; j < orderProperties.length; j++) + { + crit.addOrder(orderProperties[j]); + } + + } + if (criteria != null) + { + for (Criterion criterion : criteria) + { + crit.add(criterion); + } + } + return crit.list(); + } + }); + } + + /** + * {@inheritDoc} + */ + public List<T> find(String query, Object obj, Type type) + { + return find(query, new Object[]{obj }, new Type[]{type }); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> find(final String query, final Object[] obj, final Type[] type) + { + return (List<T>) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + // hibernate 3 + return ses.createQuery(query).setParameters(obj, type).list(); + } + }); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T load(K key) + { + T result = (T) getHibernateTemplate().load(getReferenceClass(), key); + Hibernate.initialize(result); + return result; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T loadIfAvailable(K key) + { + T result; + try + { + result = (T) getHibernateTemplate().load(getReferenceClass(), key); + Hibernate.initialize(result); + } + catch (ObjectNotFoundException e) + { + // during lazy initialization + return null; + } + catch (HibernateObjectRetrievalFailureException e) + { + // during load + if (e.getCause() instanceof ObjectNotFoundException) + { + return null; + } + throw e; + } + return result; + } + + /** + * {@inheritDoc} + */ + public void saveOrUpdate(final T obj) + { + getHibernateTemplate().saveOrUpdate(obj); + } + + /** + * {@inheritDoc} + */ + public void update(T obj) + { + getHibernateTemplate().update(obj); + } + + /** + * {@inheritDoc} + */ + public boolean delete(final K key) + { + + return (Boolean) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + ses.delete(ses.load(getReferenceClass(), key)); + return true; + } + }); + + } + + /** + * {@inheritDoc} + */ + public void refresh(T obj) + { + getHibernateTemplate().refresh(obj); + } + + /** + * {@inheritDoc} + */ + public void evict(T obj) + { + getHibernateTemplate().evict(obj); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public T merge(final T obj) + { + return (T) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + return ses.merge(obj); + } + }); + + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public K save(T obj) + { + return (K) getHibernateTemplate().save(obj); + } + + /** + * {@inheritDoc} + */ + public T findFilteredFirst(final T filter) + { + return getFirstInCollection(findFiltered(filter, 1, 0)); + } + + /** + * {@inheritDoc} + */ + public T findFilteredFirst(final T filter, List<Criterion> criteria) + { + return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria)); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter) + { + return findFiltered(filter, getDefaultFilterMetadata()); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(T filter, Order[] orderProperties) + { + return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata) + { + return findFiltered(filter, metadata, Integer.MAX_VALUE, 0); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final int maxResults, final int page) + { + return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page); + } + + /** + * {@inheritDoc} + */ + public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults, + final int page) + { + return findFiltered(filter, null, metadata, maxResults, page); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata, + final int maxResults, final int page) + { + return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, new ArrayList<Criterion>()); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> findFiltered(T filter, Order[] customOrder, Map<String, FilterMetadata> metadata, int maxResults, + int page, List<Criterion> additionalCriteria) + { + final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this + .getDefaultOrder(); + + return (List<T>) getHibernateTemplate().execute( + new HibernateCallbackForExecution(filter, page, maxResults, metadata, orderProperties, additionalCriteria)); + } + + /** + * Return the specific Object class that will be used for class-specific implementation of this DAO. + * @return the reference Class + */ + protected Class<T> getReferenceClass() + { + return referenceClass; + } + + public void setReferenceClass(Class<T> referenceClass) + { + this.referenceClass = referenceClass; + } + + /** + * Return a list of <code>Order</code> object to be used for the default ordering of the collection. + * @return the property name + */ + protected Order[] getDefaultOrder() + { + return new Order[0]; + } + + /** + * Obtain an instance of Query for a named query string defined in the mapping file. + * @param name the name of a query defined externally + * @param maxResults max number of results + * @return Query + */ + protected List< ? > getNamedQuery(final String name, final int maxResults) + { + return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + return q.list(); + } + }); + } + + /** + * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. + * @param name the name of a query defined externally + * @param params the parameter array + * @param maxResults max number of results + * @return Query + */ + protected List< ? > getNamedQuery(final String name, final Serializable[] params, final int maxResults) + { + + return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + if (null != params) + { + for (int i = 0; i < params.length; i++) + { + q.setParameter(i, params[i]); + } + } + return q.list(); + } + }); + } + + /** + * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given. + * @param name the name of a query defined externally + * @param params the parameter Map + * @param maxResults max number of results + * @return Query + */ + protected List< ? > getNamedQuery(final String name, final Map<String, Object> params, final int maxResults) + { + return (List< ? >) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session ses) throws HibernateException + { + Query q = ses.getNamedQuery(name); + q.setMaxResults(maxResults); + if (params != null) + { + for (Map.Entry<String, Object> entry : params.entrySet()) + { + setParameterValue(q, entry.getKey(), entry.getValue()); + } + } + return q.list(); + } + }); + } + + /** + * Convenience method to set paramers in the query given based on the actual object type in passed in as the value. + * You may need to add more functionaly to this as desired (or not use this at all). + * @param query the Query to set + * @param key the key name + * @param value the object to set as the parameter + */ + protected void setParameterValue(Query query, String key, Object value) + { + if (null == key || null == value) + { + return; + } + query.setParameter(key, value); + } + + /** + * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't + * set any default filter, subclasses may override this. + * @return map of property name - filter metadata + */ + protected Map<String, FilterMetadata> getDefaultFilterMetadata() + { + return new HashMap<String, FilterMetadata>(0); + } + + /** + * Returns the first object in the collection or null if the collection is null or empty. + * @param list collection + * @return first element in the list + */ + @SuppressWarnings("unchecked") + private T getFirstInCollection(Collection<T> list) + { + if (list != null && !list.isEmpty()) + { + Object result = list.iterator().next(); + Hibernate.initialize(result); + return (T) result; + } + return null; + } + + /** + * Sets the aopenabled. + * @param aopenabled the aopenabled to set + */ + public void setAopenabled(boolean aopenabled) + { + this.aopenabled = aopenabled; + } + + /** + * @return This is needed as for http://opensource.atlassian.com/projects/spring/browse/SPR-2226 + */ + @SuppressWarnings("unchecked") + private HibernateDAO<T, K> getThis() + { + if (!aopenabled) + { + return this; + } + + try + { + return (HibernateDAO<T, K>) AopContext.currentProxy(); + } + catch (AspectException exc) + { + logger.debug("Not running inside an AOP proxy, so no proxy can be returned: " + exc.getMessage()); + return this; + } + catch (IllegalStateException e) + { + logger.warn("Cannot access proxy: " + e.getMessage()); + aopenabled = false; + return this; + } + } + + /** + * @author carone + * @version $Id$ + */ + private final class HibernateCallbackForExecution implements HibernateCallback + { + + /** + * + */ + private final T filter; + + /** + * + */ + private final int page; + + /** + * + */ + private final int maxResults; + + /** + * + */ + private final Map<String, FilterMetadata> metadata; + + /** + * + */ + private final Order[] orderProperties; + + private List<Criterion> additionalCriteria; + + /** + * @param filter + * @param page + * @param maxResults + * @param metadata + * @param orderProperties + */ + private HibernateCallbackForExecution( + T filter, + int page, + int maxResults, + Map<String, FilterMetadata> metadata, + Order[] orderProperties, + List<Criterion> additionalCriteria) + { + this.filter = filter; + this.page = page; + this.maxResults = maxResults; + this.metadata = metadata; + this.orderProperties = orderProperties; + this.additionalCriteria = additionalCriteria; + } + + public Object doInHibernate(Session ses) throws HibernateException + { + Criteria crit = ses.createCriteria(filter.getClass()); + crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); + crit.setMaxResults(maxResults); + crit.setFirstResult(maxResults * page); + + if (orderProperties != null && orderProperties.length > 0) + { + for (Order order : orderProperties) + { + if (order != null) + { + crit.addOrder(order); + } + } + } + EnhancedExample.create(crit, filter, metadata); + if (additionalCriteria != null && !additionalCriteria.isEmpty()) + { + for (Criterion criterion : additionalCriteria) + { + crit.add(criterion); + } + } + return crit.list(); + } + } + +} \ No newline at end of file Deleted: tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-bshd5-2.0/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java 2008-01-27 10:55:14 UTC (rev 555) @@ -1,75 +0,0 @@ -package it.openutils.dao.hibernate; - -import java.util.Date; - - -/** - * @author Fabrizio Giustina - * @version $Id: $ - * @deprecated use FilterMetadata - */ -@Deprecated -public class MutableDateRange extends Date -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * range start. - */ - private Date from; - - /** - * range end. - */ - private Date to; - - /** - * Getter for <code>from</code>. - * @return Returns the from. - */ - public Date getFrom() - { - return this.from; - } - - /** - * Setter for <code>from</code>. - * @param from The from to set. - */ - public void setFrom(Date from) - { - this.from = from; - } - - /** - * Getter for <code>to</code>. - * @return Returns the to. - */ - public Date getTo() - { - return this.to; - } - - /** - * Setter for <code>to</code>. - * @param to The to to set. - */ - public void setTo(Date to) - { - this.to = to; - } - - /** - * Returns <code>true</code> if at least one date is set. - * @return <code>true</code> if at least one date is set - */ - public boolean isSet() - { - return this.to != null || this.from != null; - } - -} Deleted: tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/EnhancedExample.java 2008-01-20 17:02:17 UTC (rev 536) +++ tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java 2008-01-27 10:55:14 UTC (rev 555) @@ -1,332 +0,0 @@ -package it.openutils.hibernate.example; - -import it.openutils.dao.hibernate.MutableDateRange; - -import java.lang.reflect.InvocationTargetException; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang.ClassUtils; -import org.apache.commons.lang.StringUtils; -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.criterion.Restrictions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.dao.DataRetrievalFailureException; - - -/** - * @author Fabrizio Giustina - * @version $Id: $ - */ -public class EnhancedExample -{ - - private Map<String, FilterMetadata> metadata; - - private EnhancedExample(Criteria crit, Object filter, Map<String, FilterMetadata> metadata) - { - this.metadata = metadata == null ? new HashMap<String, FilterMetadata>(0) : metadata; - fillCriteria(null, crit, filter); - } - - /** - * Logger. - */ - private static Logger log = LoggerFactory.getLogger(EnhancedExample.class); - - /** - * Fills a criteria object calling addCondition() for any non-null property or for any component in collections. - * @param crit Criteria - * @param filter javabean which will be analyzed for non-null properties - * @throws HibernateException exception while building the criteria - */ - public static void create(Criteria crit, Object filter, Map<String, FilterMetadata> metadata) - throws HibernateException - { - new EnhancedExample(crit, filter, metadata); - } - - /** - * Adds contitions to an existing criteria or create sub-criteria for associations. - * @param crit Criteria - * @param propertyName property name in parent bean - * @param value property value - * @throws HibernateException exception while building the criteria - */ - private void addCondition(Criteria crit, String propertyName, Object value, Object parentObject) - throws HibernateException - { - - String simplePropertyName = StringUtils.contains(propertyName, ".") ? StringUtils.substringAfterLast( - propertyName, - ".") : propertyName; - - if (isSimpleType(value) || value.getClass().isEnum()) - { - - // don't filter on empty strings! - if (value instanceof String && StringUtils.isBlank((String) value)) - { - return; - } - - FilterMetadata fmd = metadata.get(propertyName); - - if (fmd == null) - { - fmd = FilterMetadata.EQUAL; - } - - fmd.createFilter(crit, simplePropertyName, value); - - } - else if (value instanceof MutableDateRange) // @todo MutableDateRange should be removed, use a FilterMetadata - // for this scope - { - Date from = ((MutableDateRange) value).getFrom(); - Date to = ((MutableDateRange) value).getTo(); - if (from != null && to != null) - { - log.debug("crit.add(Restrictions.between({},{}, {})", new Object[]{propertyName, from, to }); - crit.add(Restrictions.between(propertyName, from, to)); - } - else if (from != null) - { - - log.debug("crit.add(Restrictions.ge({}, {})", propertyName, to); - - crit.add(Restrictions.ge(propertyName, from)); - } - else if (to != null) - { - log.debug("crit.add(Restrictions.le({}, {})", propertyName, to); - crit.add(Restrictions.le(propertyName, to)); - } - } - else - { - if (containsSomething(value)) - { - // @todo handle multiple associations in lists? - // see http://opensource2.atlassian.com/projects/hibernate/browse/HHH-879 - if ((value instanceof Set || value instanceof List) && !((Collection) value).isEmpty()) - { - // collection: the new criteria has already been created, now we only nee to analize content - - for (Object element : ((Collection< ? extends Object>) value)) - { - - log.debug("crit.createCriteria({})", simplePropertyName); - Criteria childrenCriteria = crit.createCriteria(simplePropertyName); - fillCriteria(propertyName, childrenCriteria, element); - } - } - else if ((value instanceof Map) && !((Map) value).isEmpty()) - { - FilterMetadata fmd = metadata.get(propertyName); - - if (fmd != null) - { - fmd.createFilter(crit, simplePropertyName, value); - } - else - { - log.warn( - "Maps are not handled without a FilterMetadata. Property is {} and value is {}.", - propertyName, - value); - } - } - else - { - log.debug("crit.createCriteria({})", simplePropertyName); - Criteria childrenCriteria = crit.createCriteria(simplePropertyName); - fillCriteria(propertyName, childrenCriteria, value); - } - } - } - } - - /** - * Check if the bean contains at least a valid property. - * @param bean javabean - * @return <code>true</code> if the bean contains at least a valid property - */ - private boolean containsSomething(Object bean) - { - - if (bean == null) - { - return false; - } - if (isSimpleType(bean)) - { - return true; - } - else if (bean instanceof MutableDateRange) - { - return ((MutableDateRange) bean).isSet(); - } - - if (bean instanceof Collection) - { - - Collection coll = ((Collection) bean); - if (coll.isEmpty()) - { - return false; - } - - if (containsSomething(coll.iterator().next())) - { - return true; - } - } - else if (bean instanceof Map) - { - Map coll = ((Map) bean); - if (coll.isEmpty()) - { - return false; - } - - if (containsSomething(coll.values().iterator().next())) - { - return true; - } - } - - Map<String, Object> properties; - try - { - properties = PropertyUtils.describe(bean); - } - catch (Throwable e) - { - if (e instanceof InvocationTargetException) - { - e = ((InvocationTargetException) e).getTargetException(); - } - - log.error("Unable to build filter, PropertyUtils.describe throws an exception while analizing class " - + ClassUtils.getShortClassName(bean, "NULL"), e); - return false; - } - - for (Map.Entry<String, Object> property : properties.entrySet()) - { - - if (!PropertyUtils.isWriteable(bean, property.getKey())) - { - // skip readonly properties - continue; - } - - Object propertyValue = property.getValue(); - if (propertyValue == null) - { - continue; - } - - if (isSimpleType(propertyValue) || containsSomething(propertyValue)) - { - return true; - } - } - - return false; - } - - /** - * Fills a criteria object calling addCondition() for any non-null property or for any component in collections. - * @param crit Criteria - * @param filter javabean which will be analyzed for non-null properties - * @throws HibernateException exception while building the criteria - */ - private void fillCriteria(String parentPropertyName, Criteria crit, Object filter) throws HibernateException - { - if ((filter instanceof Set || filter instanceof List) && !((Collection) filter).isEmpty()) - { - // collection: the new criteria has already been created, now we only need to analize content - for (Object element : ((Collection) filter)) - { - fillCriteria(parentPropertyName, crit, element); - } - } - - Map<String, Object> properties; - try - { - properties = PropertyUtils.describe(filter); - } - catch (Throwable e) - { - if (e instanceof InvocationTargetException) - { - e = ((InvocationTargetException) e).getTargetException(); - } - - throw new DataRetrievalFailureException( - "Unable to build filter, PropertyUtils.describe throws an exception while analizing class " - + ClassUtils.getShortClassName(filter, "NULL") - + ":" - + e.getClass(), - e); - } - - Iterator<String> iterator = properties.keySet().iterator(); - while (iterator.hasNext()) - { - String propertyName = iterator.next(); - - Object value = properties.get(propertyName); - - // add only non-null values, ignore read-only properties - if (value != null && PropertyUtils.isWriteable(filter, propertyName)) - { - String composedPropertyName = (parentPropertyName == null) ? propertyName : parentPropertyName - + "." - + propertyName; - addCondition(crit, composedPropertyName, value, filter); - } - } - } - - /** - * Check if the given object is a simple java type - * @param object object to check - * @return <code>true</code>if the given object is a simple type - */ - private boolean isSimpleType(Object object) - { - - Class< ? extends Object> objClass = object.getClass(); - - return objClass.isPrimitive() - || objClass.equals(Integer.class) - || objClass.equals(Long.class) - || objClass.equals(Short.class) - || objClass.equals(Boolean.class) - || objClass.equals(String.class) - || objClass.equals(Double.class) - || objClass.equals(Float.class) - || objClass.equals(Date.class) - || objClass.equals(Byte.class) - || objClass.equals(BigDecimal.class) - || objClass.equals(Timestamp.class) - || objClass.equals(Character.class) - || Calendar.class.isAssignableFrom(objClass); - } - -} Copied: tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java (from rev 551, trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/EnhancedExample.java) =================================================================== --- tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java (rev 0) +++ tags/openutils-bshd5-2.0/src/main/java/it/openutils/hibernate/example/EnhancedExample.java 2008-01-27 10:55:14 UTC (rev 555) @@ -0,0 +1,305 @@ +package it.openutils.hibernate.example; + +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.ClassUtils; +import org.apache.commons.lang.StringUtils; +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.DataRetrievalFailureException; + + +/** + * @author Fabrizio Giustina + * @version $Id: $ + */ +public final class EnhancedExample +{ + + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(EnhancedExample.class); + + private Map<String, FilterMetadata> metadata; + + private EnhancedExample(Criteria crit, Object filter, Map<String, FilterMetadata> metadata) + { + this.metadata = metadata == null ? new HashMap<String, FilterMetadata>(0) : metadata; + fillCriteria(null, crit, filter); + } + + /** + * Fills a criteria object calling addCondition() for any non-null property or for any component in collections. + * @param crit Criteria + * @param filter javabean which will be analyzed for non-null properties + * @param metadata Map of property names - ... [truncated message content] |
From: <fg...@us...> - 2008-01-27 10:54:50
|
Revision: 554 http://openutils.svn.sourceforge.net/openutils/?rev=554&view=rev Author: fgiust Date: 2008-01-27 02:54:56 -0800 (Sun, 27 Jan 2008) Log Message: ----------- [maven-release-plugin] prepare release openutils-bshd5-2.0 Modified Paths: -------------- trunk/openutils-bshd5/pom.xml Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2008-01-27 10:53:50 UTC (rev 553) +++ trunk/openutils-bshd5/pom.xml 2008-01-27 10:54:56 UTC (rev 554) @@ -1,5 +1,4 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.sourceforge.openutils</groupId> @@ -9,7 +8,7 @@ </parent> <artifactId>openutils-bshd5</artifactId> <name>openutils base Spring-Hibernate DAO for java 5.0</name> - <version>2.0-SNAPSHOT</version> + <version>2.0</version> <description>openutils base Spring-Hibernate DAO for java 5.0</description> <dependencies> <dependency> @@ -106,4 +105,10 @@ <properties> <spring.version>2.5.1</spring.version> </properties> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-2.0</url> + </scm> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 10:53:51
|
Revision: 553 http://openutils.svn.sourceforge.net/openutils/?rev=553&view=rev Author: fgiust Date: 2008-01-27 02:53:50 -0800 (Sun, 27 Jan 2008) Log Message: ----------- update parent Modified Paths: -------------- trunk/openutils-backup/pom.xml trunk/openutils-bshd5/pom.xml trunk/openutils-configuration-dataobjects/pom.xml trunk/openutils-configuration-services/pom.xml trunk/openutils-dbmigration/pom.xml trunk/openutils-deployment/pom.xml trunk/openutils-hibernate-security/pom.xml trunk/openutils-log4j/pom.xml trunk/openutils-maven-skin/pom.xml trunk/openutils-mgnlspring/pom.xml trunk/openutils-mgnlstripes/pom.xml trunk/openutils-spring/pom.xml trunk/openutils-spring-rmibernate/pom.xml trunk/openutils-tags-spring/pom.xml trunk/openutils-testing/pom.xml trunk/openutils-testing/src/site/site.xml trunk/openutils-testing-junit/pom.xml trunk/openutils-testing-junit-dwr/pom.xml trunk/openutils-testing-testng/pom.xml trunk/openutils-testing-testng-dwr/pom.xml trunk/openutils-usermanagement/pom.xml trunk/openutils-usermanagement-dataobjects/pom.xml trunk/openutils-web/pom.xml trunk/src/site/apt/index.apt trunk/src/site/site.xml Modified: trunk/openutils-backup/pom.xml =================================================================== --- trunk/openutils-backup/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-backup/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-backup</artifactId> Modified: trunk/openutils-bshd5/pom.xml =================================================================== --- trunk/openutils-bshd5/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-bshd5/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-bshd5</artifactId> @@ -102,12 +102,6 @@ <artifactId>commons-lang</artifactId> <version>2.3</version> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <optional>true</optional> - </dependency> </dependencies> <properties> <spring.version>2.5.1</spring.version> Modified: trunk/openutils-configuration-dataobjects/pom.xml =================================================================== --- trunk/openutils-configuration-dataobjects/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-configuration-dataobjects/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -3,7 +3,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <groupId>net.sourceforge.openutils</groupId> Modified: trunk/openutils-configuration-services/pom.xml =================================================================== --- trunk/openutils-configuration-services/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-configuration-services/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <groupId>net.sourceforge.openutils</groupId> Modified: trunk/openutils-dbmigration/pom.xml =================================================================== --- trunk/openutils-dbmigration/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-dbmigration/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-dbmigration</artifactId> Modified: trunk/openutils-deployment/pom.xml =================================================================== --- trunk/openutils-deployment/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-deployment/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-deployment</artifactId> Modified: trunk/openutils-hibernate-security/pom.xml =================================================================== --- trunk/openutils-hibernate-security/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-hibernate-security/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <artifactId>openutils</artifactId> <groupId>net.sourceforge.openutils</groupId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <modelVersion>4.0.0</modelVersion> Modified: trunk/openutils-log4j/pom.xml =================================================================== --- trunk/openutils-log4j/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-log4j/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -5,7 +5,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-log4j</artifactId> Modified: trunk/openutils-maven-skin/pom.xml =================================================================== --- trunk/openutils-maven-skin/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-maven-skin/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-maven-skin</artifactId> Modified: trunk/openutils-mgnlspring/pom.xml =================================================================== --- trunk/openutils-mgnlspring/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-mgnlspring/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <modelVersion>4.0.0</modelVersion> Modified: trunk/openutils-mgnlstripes/pom.xml =================================================================== --- trunk/openutils-mgnlstripes/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-mgnlstripes/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -3,7 +3,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <modelVersion>4.0.0</modelVersion> Modified: trunk/openutils-spring/pom.xml =================================================================== --- trunk/openutils-spring/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-spring/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-spring</artifactId> Modified: trunk/openutils-spring-rmibernate/pom.xml =================================================================== --- trunk/openutils-spring-rmibernate/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-spring-rmibernate/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-spring-rmibernate</artifactId> Modified: trunk/openutils-tags-spring/pom.xml =================================================================== --- trunk/openutils-tags-spring/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-tags-spring/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-tags-spring</artifactId> Modified: trunk/openutils-testing/pom.xml =================================================================== --- trunk/openutils-testing/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-testing/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-testing</artifactId> Modified: trunk/openutils-testing/src/site/site.xml =================================================================== --- trunk/openutils-testing/src/site/site.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-testing/src/site/site.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -22,6 +22,7 @@ </breadcrumbs> <menu name="openutils testing"> <item name="Usage" href="index.html"></item> + <item name="DbUnit tests" href="dbunit.html"></item> </menu> <menu ref="modules" inherit="bottom" /> <menu ref="reports" inherit="bottom" /> Modified: trunk/openutils-testing-junit/pom.xml =================================================================== --- trunk/openutils-testing-junit/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-testing-junit/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-testing-junit</artifactId> Modified: trunk/openutils-testing-junit-dwr/pom.xml =================================================================== --- trunk/openutils-testing-junit-dwr/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-testing-junit-dwr/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-testing-junit-dwr</artifactId> Modified: trunk/openutils-testing-testng/pom.xml =================================================================== --- trunk/openutils-testing-testng/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-testing-testng/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-testing-testng</artifactId> @@ -15,10 +15,7 @@ <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> - <configuration> - <forkMode>once</forkMode> - </configuration> + <version>2.4</version> </plugin> </plugins> </build> Modified: trunk/openutils-testing-testng-dwr/pom.xml =================================================================== --- trunk/openutils-testing-testng-dwr/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-testing-testng-dwr/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-testing-testng-dwr</artifactId> Modified: trunk/openutils-usermanagement/pom.xml =================================================================== --- trunk/openutils-usermanagement/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-usermanagement/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <groupId>net.sourceforge.openutils</groupId> Modified: trunk/openutils-usermanagement-dataobjects/pom.xml =================================================================== --- trunk/openutils-usermanagement-dataobjects/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-usermanagement-dataobjects/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <groupId>net.sourceforge.openutils</groupId> Modified: trunk/openutils-web/pom.xml =================================================================== --- trunk/openutils-web/pom.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/openutils-web/pom.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -4,7 +4,7 @@ <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> - <version>6</version> + <version>7</version> <relativePath>..</relativePath> </parent> <artifactId>openutils-web</artifactId> Modified: trunk/src/site/apt/index.apt =================================================================== --- trunk/src/site/apt/index.apt 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/src/site/apt/index.apt 2008-01-27 10:53:50 UTC (rev 553) @@ -16,4 +16,27 @@ {{{http://www.openmindonline.it}http://www.openmindonline.it}} +Distribution + Openutils releases are available in the main maven2 repository. + + Snapshots versions are available in separate repository hosted at sourceforge: + add the following repository to your pom if you need to download openutils snapshots + ++----------------------------------------------+ + + <repositories> + <repository> + <id>snapshots.openutils.sourceforge.net</id> + <name>openutils snapshot repository</name> + <url>http://openutils.sourceforge.net/repository/snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + ++----------------------------------------------+ \ No newline at end of file Modified: trunk/src/site/site.xml =================================================================== --- trunk/src/site/site.xml 2008-01-27 10:52:15 UTC (rev 552) +++ trunk/src/site/site.xml 2008-01-27 10:53:50 UTC (rev 553) @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="Openutils"> <publishDate position="left" format="yyyy-MM-dd" /> + <version position="bottom" /> <bannerRight> <name>Openutils</name> <src>http://openutils.sourceforge.net/images/openutils-logo.png</src> @@ -16,7 +17,6 @@ <link rel="icon" href="images/favicon.ico" /> </head> <menu ref="modules" inherit="bottom" /> - <menu ref="reports" inherit="bottom" /> </body> <skin> <groupId>net.sourceforge.openutils</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-27 10:52:14
|
Revision: 552 http://openutils.svn.sourceforge.net/openutils/?rev=552&view=rev Author: fgiust Date: 2008-01-27 02:52:15 -0800 (Sun, 27 Jan 2008) Log Message: ----------- update surefire version Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2008-01-26 20:22:36 UTC (rev 551) +++ trunk/pom.xml 2008-01-27 10:52:15 UTC (rev 552) @@ -5,7 +5,7 @@ <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> <packaging>pom</packaging> - <version>6</version> + <version>7</version> <name>openutils</name> <description>openutils parent POM</description> <url>http://openutils.sourceforge.net</url> @@ -97,6 +97,10 @@ <version>2.0-beta-7</version> </plugin> <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.4</version> + </plugin> + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> @@ -145,6 +149,12 @@ <reporting> <plugins> <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <quiet>true</quiet> + </configuration> + </plugin> + <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> </plugin> <plugin> @@ -162,6 +172,7 @@ </plugin> <plugin> <artifactId>maven-surefire-report-plugin</artifactId> + <version>2.4</version> </plugin> <plugin> <artifactId>maven-changelog-plugin</artifactId> @@ -197,9 +208,9 @@ <module>openutils-usermanagement</module> <module>openutils-testing</module> <module>openutils-testing-testng</module> - <module>openutils-testing-testng-dwr</module> <module>openutils-testing-junit</module> <module>openutils-testing-junit-dwr</module> + <module>openutils-testing-testng-dwr</module> <module>openutils-web</module> <module>openutils-tags-spring</module> <module>openutils-dbmigration</module> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-26 20:22:32
|
Revision: 551 http://openutils.svn.sourceforge.net/openutils/?rev=551&view=rev Author: fgiust Date: 2008-01-26 12:22:36 -0800 (Sat, 26 Jan 2008) Log Message: ----------- removed deprecated classes, add documentation Modified Paths: -------------- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/EnhancedExample.java trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/FilterMetadata.java trunk/openutils-bshd5/src/site/apt/index.apt trunk/openutils-bshd5/src/site/site.xml Added Paths: ----------- trunk/openutils-bshd5/src/site/apt/configuration.apt Removed Paths: ------------- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java Modified: trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-01-26 19:07:44 UTC (rev 550) +++ trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-01-26 20:22:36 UTC (rev 551) @@ -43,13 +43,17 @@ private boolean aopenabled; + /** + * Instantiates a new DAO instance + */ public HibernateDAOImpl() { super(); } /** - * @param referenceClass + * Sets the class of the persistent bean managed by this DAO + * @param referenceClass the class for the bean managed by this DAO */ @SuppressWarnings({"unchecked" }) public HibernateDAOImpl(Class referenceClass) Deleted: trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java 2008-01-26 19:07:44 UTC (rev 550) +++ trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/MutableDateRange.java 2008-01-26 20:22:36 UTC (rev 551) @@ -1,75 +0,0 @@ -package it.openutils.dao.hibernate; - -import java.util.Date; - - -/** - * @author Fabrizio Giustina - * @version $Id: $ - * @deprecated use FilterMetadata - */ -@Deprecated -public class MutableDateRange extends Date -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * range start. - */ - private Date from; - - /** - * range end. - */ - private Date to; - - /** - * Getter for <code>from</code>. - * @return Returns the from. - */ - public Date getFrom() - { - return this.from; - } - - /** - * Setter for <code>from</code>. - * @param from The from to set. - */ - public void setFrom(Date from) - { - this.from = from; - } - - /** - * Getter for <code>to</code>. - * @return Returns the to. - */ - public Date getTo() - { - return this.to; - } - - /** - * Setter for <code>to</code>. - * @param to The to to set. - */ - public void setTo(Date to) - { - this.to = to; - } - - /** - * Returns <code>true</code> if at least one date is set. - * @return <code>true</code> if at least one date is set - */ - public boolean isSet() - { - return this.to != null || this.from != null; - } - -} Modified: trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/EnhancedExample.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/EnhancedExample.java 2008-01-26 19:07:44 UTC (rev 550) +++ trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/EnhancedExample.java 2008-01-26 20:22:36 UTC (rev 551) @@ -1,7 +1,5 @@ package it.openutils.hibernate.example; -import it.openutils.dao.hibernate.MutableDateRange; - import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; import java.sql.Timestamp; @@ -19,7 +17,6 @@ import org.apache.commons.lang.StringUtils; import org.hibernate.Criteria; import org.hibernate.HibernateException; -import org.hibernate.criterion.Restrictions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DataRetrievalFailureException; @@ -29,9 +26,14 @@ * @author Fabrizio Giustina * @version $Id: $ */ -public class EnhancedExample +public final class EnhancedExample { + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(EnhancedExample.class); + private Map<String, FilterMetadata> metadata; private EnhancedExample(Criteria crit, Object filter, Map<String, FilterMetadata> metadata) @@ -41,14 +43,10 @@ } /** - * Logger. - */ - private static Logger log = LoggerFactory.getLogger(EnhancedExample.class); - - /** * Fills a criteria object calling addCondition() for any non-null property or for any component in collections. * @param crit Criteria * @param filter javabean which will be analyzed for non-null properties + * @param metadata Map of property names - filter metadata * @throws HibernateException exception while building the criteria */ public static void create(Criteria crit, Object filter, Map<String, FilterMetadata> metadata) @@ -91,40 +89,17 @@ fmd.createFilter(crit, simplePropertyName, value); } - else if (value instanceof MutableDateRange) // @todo MutableDateRange should be removed, use a FilterMetadata - // for this scope - { - Date from = ((MutableDateRange) value).getFrom(); - Date to = ((MutableDateRange) value).getTo(); - if (from != null && to != null) - { - log.debug("crit.add(Restrictions.between({},{}, {})", new Object[]{propertyName, from, to }); - crit.add(Restrictions.between(propertyName, from, to)); - } - else if (from != null) - { - - log.debug("crit.add(Restrictions.ge({}, {})", propertyName, to); - - crit.add(Restrictions.ge(propertyName, from)); - } - else if (to != null) - { - log.debug("crit.add(Restrictions.le({}, {})", propertyName, to); - crit.add(Restrictions.le(propertyName, to)); - } - } else { if (containsSomething(value)) { // @todo handle multiple associations in lists? // see http://opensource2.atlassian.com/projects/hibernate/browse/HHH-879 - if ((value instanceof Set || value instanceof List) && !((Collection) value).isEmpty()) + if ((value instanceof Set || value instanceof List) && !((Collection< ? >) value).isEmpty()) { // collection: the new criteria has already been created, now we only nee to analize content - for (Object element : ((Collection< ? extends Object>) value)) + for (Object element : ((Collection< ? >) value)) { log.debug("crit.createCriteria({})", simplePropertyName); @@ -132,7 +107,7 @@ fillCriteria(propertyName, childrenCriteria, element); } } - else if ((value instanceof Map) && !((Map) value).isEmpty()) + else if ((value instanceof Map) && !((Map< ? , ? >) value).isEmpty()) { FilterMetadata fmd = metadata.get(propertyName); @@ -163,6 +138,7 @@ * @param bean javabean * @return <code>true</code> if the bean contains at least a valid property */ + @SuppressWarnings("unchecked") private boolean containsSomething(Object bean) { @@ -174,15 +150,11 @@ { return true; } - else if (bean instanceof MutableDateRange) - { - return ((MutableDateRange) bean).isSet(); - } if (bean instanceof Collection) { - Collection coll = ((Collection) bean); + Collection< ? > coll = ((Collection< ? >) bean); if (coll.isEmpty()) { return false; @@ -195,7 +167,7 @@ } else if (bean instanceof Map) { - Map coll = ((Map) bean); + Map< ? , ? > coll = ((Map< ? , ? >) bean); if (coll.isEmpty()) { return false; @@ -254,12 +226,13 @@ * @param filter javabean which will be analyzed for non-null properties * @throws HibernateException exception while building the criteria */ + @SuppressWarnings("unchecked") private void fillCriteria(String parentPropertyName, Criteria crit, Object filter) throws HibernateException { - if ((filter instanceof Set || filter instanceof List) && !((Collection) filter).isEmpty()) + if ((filter instanceof Set || filter instanceof List) && !((Collection< ? >) filter).isEmpty()) { // collection: the new criteria has already been created, now we only need to analize content - for (Object element : ((Collection) filter)) + for (Object element : ((Collection< ? >) filter)) { fillCriteria(parentPropertyName, crit, element); } Modified: trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/FilterMetadata.java =================================================================== --- trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/FilterMetadata.java 2008-01-26 19:07:44 UTC (rev 550) +++ trunk/openutils-bshd5/src/main/java/it/openutils/hibernate/example/FilterMetadata.java 2008-01-26 20:22:36 UTC (rev 551) @@ -10,19 +10,24 @@ /** + * FilterMetadata can be used to alter how properties are handled. * @author Fabrizio Giustina - * @version $Id$ + * @version $Id: $ */ public interface FilterMetadata { - void createFilter(Criteria criteria, String propertyName, Object propertyValue); - + /** + * A filter metadata that adds a LIKE condition. + */ FilterMetadata LIKE = new FilterMetadata() { private Logger log = LoggerFactory.getLogger(FilterMetadata.class); + /** + * {@inheritDoc} + */ public void createFilter(Criteria crit, String propertyName, Object propertyValue) { crit.add(Restrictions.ilike(propertyName, (String) propertyValue, MatchMode.ANYWHERE)); @@ -34,11 +39,17 @@ } }; + /** + * A filter metadata that adds an EQUAL condition. + */ FilterMetadata EQUAL = new FilterMetadata() { private Log log = LogFactory.getLog(FilterMetadata.class); + /** + * {@inheritDoc} + */ public void createFilter(Criteria crit, String propertyName, Object propertyValue) { if (log.isDebugEnabled()) @@ -49,4 +60,12 @@ crit.add(Restrictions.eq(propertyName, propertyValue)); } }; + + /** + * The createFilter method can alter an existing criteria adding restrictions. + * @param criteria the parent criteria + * @param propertyName current property name + * @param propertyValue property value + */ + void createFilter(Criteria criteria, String propertyName, Object propertyValue); } Added: trunk/openutils-bshd5/src/site/apt/configuration.apt =================================================================== --- trunk/openutils-bshd5/src/site/apt/configuration.apt (rev 0) +++ trunk/openutils-bshd5/src/site/apt/configuration.apt 2008-01-26 20:22:36 UTC (rev 551) @@ -0,0 +1,67 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + +Using annotations + + This is the preferred way of creating and configuring a new DAO using Spring 2.5 and annotations: + ++-----------------------------------------------+ + +public interface SampleDAO extends HibernateDAO<Sample, Integer> +{ + + @Repository(value = "sampleDAO") + public static class SampleDAOImpl extends HibernateDAOImpl<Sample, Integer> implements SampleDAO + { + + @Autowired + public SampleDAOImpl(SessionFactory factory) + { + setSessionFactory(factory); + setReferenceClass(Sample.class); + } + } +} + ++-----------------------------------------------+ + + Simple, isn't it? With those few lines you are: + + * Creating youd DAO interface, which allow you to manage <<<Sample>>> objects with a key of type <<<Integer>>> + + * Implementing your interface and setup your DAO + + * Registing you DAO in the Spring context using the <<<@Repository>>> annotation + + [] + + + +Using xml + + You need to write at least the DAO interface; the DAO implementation can be a subclass of HibernateDAOImpl or can + be created by Spring you you do not need to alter or add any method. + ++-----------------------------------------------+ + +public interface SampleDAO extends HibernateDAO<Sample, Integer> +{ + +} + <bean id="sampleDAO" class="org.springframework.aop.framework.ProxyFactoryBean"> + <property name="proxyInterfaces" value="com.myapp.SampleDAO"/> + <property name="target"> + <bean + class="it.openutils.dao.hibernate.HibernateDAOImpl"> + <property name="sessionFactory" ref="sessionFactory"/> + <property name="referenceClass" value="com.myapp.Sample"/> + </bean> + </property> + </bean> + ++-----------------------------------------------+ + + Property changes on: trunk/openutils-bshd5/src/site/apt/configuration.apt ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-bshd5/src/site/apt/index.apt =================================================================== --- trunk/openutils-bshd5/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550) +++ trunk/openutils-bshd5/src/site/apt/index.apt 2008-01-26 20:22:36 UTC (rev 551) @@ -1,14 +1,22 @@ -------------------------- - O p e n u t i l s + O p e n u t i l s -------------------------- Fabrizio Giustina -------------------------- openutils-bshd5 - bshd5 stands for "base spring-hibernate DAO for java 5" + bshd5 means "base spring-hibernate DAO for java 5". + It provides a base generic DAO class that can be reused and that offer most of the needed methods (load, find, save, etc) + already implemented. + The base class also provides an enhanced version of hibernate "find by example" feature allowing associations in examples. + + See {{{configuration.html}configuration}} for how to setup your DAOs and look at {{{apidocs/index.html}javadocs}} for + more details. + + Released versions Check it at {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-bshd5}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-bshd5}} Modified: trunk/openutils-bshd5/src/site/site.xml =================================================================== --- trunk/openutils-bshd5/src/site/site.xml 2008-01-26 19:07:44 UTC (rev 550) +++ trunk/openutils-bshd5/src/site/site.xml 2008-01-26 20:22:36 UTC (rev 551) @@ -21,7 +21,8 @@ <item name="openutils-bshd5" href="http://openutils.sourceforge.net/openutils-bshd5" /> </breadcrumbs> <menu name="openutils-bshd5"> - <item name="Usage" href="index.html"></item> + <item name="Usage" href="index.html"/> + <item name="Configuration" href="configuration.html"/> </menu> <menu ref="modules" inherit="bottom" /> <menu ref="reports" inherit="bottom" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-26 19:07:41
|
Revision: 550 http://openutils.svn.sourceforge.net/openutils/?rev=550&view=rev Author: fgiust Date: 2008-01-26 11:07:44 -0800 (Sat, 26 Jan 2008) Log Message: ----------- docs! Modified Paths: -------------- trunk/openutils-testing/src/site/apt/index.apt Added Paths: ----------- trunk/openutils-testing/src/site/apt/dbunit.apt trunk/openutils-testing-junit/src/site/apt/ trunk/openutils-testing-junit/src/site/apt/index.apt trunk/openutils-testing-testng/src/site/apt/ trunk/openutils-testing-testng/src/site/apt/index.apt Added: trunk/openutils-testing/src/site/apt/dbunit.apt =================================================================== --- trunk/openutils-testing/src/site/apt/dbunit.apt (rev 0) +++ trunk/openutils-testing/src/site/apt/dbunit.apt 2008-01-26 19:07:44 UTC (rev 550) @@ -0,0 +1,76 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + + +DbUnit tests + + Openutils provide a base class that take cares of the common operations involved in preparing the test environment using + DbUnit. + + You can extend <<<it.openutils.testing.testng.AbstractDbUnitTestNGSpringContextTests>>> or + <<<it.openutils.testing.junit.AbstractDbUnitJunitSpringContextTests>>>, depending on the test framework of your choice + (remember to include the appropriate dependency, openutils-testing-testng or openutils-testing-junit). + Apart from the underline test framework used, there is no difference in how those class will work. + + Those base classes extend the standard <<<Abstract*SpringContextTests>>> classes provided by Spring, so they support + dependency injection and needs to be configured from a Spring context. + +How to + + All the setup can be configured using annotations. This is a sample test that can make use of data loaded by DbUnit: + ++----------------------------------------------+ + +@ContextConfiguration(locations = {"/spring-tests.xml" }) +@DbUnitExecution(datasets = {"/db1-load.xml" }) +public class SampleDbUnitTest extends AbstractDbUnitTestNGSpringContextTests +{ + @Test + public void testSomething() { + ... + } +} + ++----------------------------------------------+ + + The <<<DbUnitExecution>>> annotation controls how the setup will be performed. It can be configured with a list of file names + (xml od xsl DbUnit datasets) that will be loaded before every single method in this test class is executed. + + In detail the setup that will be performed before each method is: + + * truncate *any table* in the database. This can be turned of by the <<<truncateAll>>> DbUnitExecution parameter + + * load the given datasets into the db + + [] + + You can setup also more than one execution if your tests depend on more than one database or schema, annotating your + class like in this example: + ++----------------------------------------------+ + +@DbUnitConfiguration(dbUnitExecutions = { + @DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1"), + @DbUnitExecution(datasets = {"/db2-load.xml" }, dataSource = "dataSource2") }) + ++----------------------------------------------+ + + + Note that this test classes don't extend Spring transactional tests, so you need to manually turn on Transactions using + standard Spring annotations: + ++----------------------------------------------+ + +@TestExecutionListeners({TransactionalTestExecutionListener.class }) +@Transactional + ++----------------------------------------------+ + + Also note that the content of your db will definitively be modified by these tests, they are expected to be run on a + test-only instance! + + + Property changes on: trunk/openutils-testing/src/site/apt/dbunit.apt ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-testing/src/site/apt/index.apt =================================================================== --- trunk/openutils-testing/src/site/apt/index.apt 2008-01-26 18:39:46 UTC (rev 549) +++ trunk/openutils-testing/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550) @@ -1,15 +1,27 @@ -------------------------- O p e n u t i l s -------------------------- - Fabrizio Giustina + Fabrizio Giustina -------------------------- openutils-testing + Openutils-testing extends the standard spring testing framework by providing more high-level base testing classes and utils. + In particular, it provides a {{{dbunit.html}framework for using with dbunit in Spring test cases}}. + The openutils-testing jar only contains generic classes that don't depends on any specific test framework. You should + depend on openutils-testing-testng or openutils-testing-junit + + Released versions - Check it at {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing}} + openutils-testing-testng: + {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}} + + openutils-testing-junit: + + {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}} + Added: trunk/openutils-testing-junit/src/site/apt/index.apt =================================================================== --- trunk/openutils-testing-junit/src/site/apt/index.apt (rev 0) +++ trunk/openutils-testing-junit/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550) @@ -0,0 +1,20 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + +openutils-testing-junit + + openutils-testing-junit is a junit specific extension of openutils-testing. + + See {{{../openutils-testing/}openutils-testing}} for documentation. + + + +Released versions + + openutils-testing-junit: + + {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}} + Property changes on: trunk/openutils-testing-junit/src/site/apt/index.apt ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing-testng/src/site/apt/index.apt =================================================================== --- trunk/openutils-testing-testng/src/site/apt/index.apt (rev 0) +++ trunk/openutils-testing-testng/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550) @@ -0,0 +1,17 @@ + -------------------------- + O p e n u t i l s + -------------------------- + Fabrizio Giustina + -------------------------- + +openutils-testing-testng + + openutils-testing-testng is a testng specific extension of openutils-testing. + + See {{{../openutils-testing/}openutils-testing}} for documentation. + + + +Released versions + + {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}} Property changes on: trunk/openutils-testing-testng/src/site/apt/index.apt ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-26 18:39:40
|
Revision: 549 http://openutils.svn.sourceforge.net/openutils/?rev=549&view=rev Author: fgiust Date: 2008-01-26 10:39:46 -0800 (Sat, 26 Jan 2008) Log Message: ----------- javadocs Modified Paths: -------------- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-26 18:14:12 UTC (rev 548) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-26 18:39:46 UTC (rev 549) @@ -24,6 +24,7 @@ /** + * A DbUnitConfiguration can contain one or more {@link DbUnitExecution}. * @author fgiust * @version $Id: $ */ @@ -33,6 +34,11 @@ @Documented public @interface DbUnitConfiguration { - DbUnitExecution[] dbUnitExecutions() default {}; + /** + * Array of {@link DbUnitExecution} + */ + DbUnitExecution[] dbUnitExecutions() default { + }; + } \ No newline at end of file Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-26 18:14:12 UTC (rev 548) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-26 18:39:46 UTC (rev 549) @@ -38,18 +38,41 @@ /** * The resource locations to use for loading dbunit dataset. */ - String[] datasets() default {}; + String[] datasets() default { + }; + + /** + * The name of the datasource to use. If can be left unset only if there is only one DataSource available in the + * Spring context. + */ String dataSource() default ""; + /** + * Db schema name that will be given to dbUnit. Can be left unset if not needed (database specific) + */ String schema() default ""; + /** + * A regexp that can match table names. Any table matching this regular expression will not be considered by DbUnit. + * By default tables starting with $ are ignored (oracle recycle bin). + */ String excludedTables() default "(^\\$(.*))"; // oracle recycle bin + /** + * If true, <strong>all</strong> the tables in the database will be truncated before loading any dataset. + */ boolean truncateAll() default true; + /** + * The database operation that will be used to truncate tables. Defaults to + * org.dbunit.operation.TruncateTableOperation + */ Class< ? extends DatabaseOperation> truncateOperation() default org.dbunit.operation.TruncateTableOperation.class; + /** + * The database operation that will be used to load datasets. Defaults to org.dbunit.operation.InsertOperation + */ Class< ? extends DatabaseOperation> insertOperation() default org.dbunit.operation.InsertOperation.class; } \ No newline at end of file Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-26 18:14:12 UTC (rev 548) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-26 18:39:46 UTC (rev 549) @@ -15,11 +15,7 @@ */ package it.openutils.testing; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.net.URL; import java.sql.SQLException; import java.util.HashMap; @@ -36,10 +32,8 @@ import org.dbunit.dataset.DataSetException; import org.dbunit.dataset.FilteredDataSet; import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.excel.XlsDataSet; import org.dbunit.dataset.filter.ITableFilter; import org.dbunit.dataset.filter.SequenceTableFilter; -import org.dbunit.dataset.xml.XmlDataSet; import org.dbunit.operation.DatabaseOperation; import org.dbunit.operation.DeleteAllOperation; import org.dbunit.operation.DeleteOperation; @@ -322,39 +316,4 @@ return (DataSource) applicationContext.getBean(name); } - /** - * Exports a list of table to an xml/xsl file - * @param file The file name we save the dataset to - * @param dataSource datasource to use - * @param schema optional schema name - * @param tableNames optional list of table names - * @throws IOException An IO Exception. - * @throws DataSetException A dataset exception. - * @throws SQLException A SQL Exception. - */ - public void exportDataset(File file, DataSource dataSource, String schema, String[] tableNames) throws IOException, - DataSetException, SQLException - { - IDatabaseConnection connection = new DatabaseConnection(dataSource.getConnection(), schema); - - IDataSet fullDataSet = connection.createDataSet(); - - if (tableNames != null && tableNames.length > 0) - { - fullDataSet = new FilteredDataSet(tableNames, fullDataSet); - } - - OutputStream fos = new BufferedOutputStream(new FileOutputStream(file)); - if (file.getName().toLowerCase().endsWith(".xls")) - { - XlsDataSet.write(fullDataSet, fos); - } - else - { - XmlDataSet.write(fullDataSet, fos); - } - fos.close(); - - log.info("Dataset exported at {}", file.getAbsolutePath()); - } } Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-26 18:14:12 UTC (rev 548) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-26 18:39:46 UTC (rev 549) @@ -47,14 +47,22 @@ private static Logger log = LoggerFactory.getLogger(DbUnitUtils.class); /** - * @param connection - * @param tableNames - * @param file - * @param xls - * @throws SQLException - * @throws IOException - * @throws DataSetException + * Do not instantiate. */ + private DbUnitUtils() + { + // do not instantiate + } + + /** + * Exports a list of table to an xml/xsl file + * @param file The file name we save the dataset to + * @param connection connection to use + * @param tableNames optional list of table names + * @throws IOException An IO Exception. + * @throws DataSetException A dataset exception. + * @throws SQLException A SQL Exception. + */ public static void exportDataset(IDatabaseConnection connection, String[] tableNames, File file) throws SQLException, IOException, DataSetException { @@ -89,10 +97,10 @@ } /** - * @param url - * @return - * @throws IOException - * @throws DataSetException + * @param url dataset url (can be an xml or excel file) + * @return loaded dataset + * @throws IOException error reading the file + * @throws DataSetException error loading the dataset */ public static IDataSet loadDataset(URL url) throws IOException, DataSetException { Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-26 18:14:12 UTC (rev 548) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-26 18:39:46 UTC (rev 549) @@ -22,6 +22,7 @@ /** + * A table filter that excludes tables mathing the given regexp. * @author fgiust * @version $Id: $ */ @@ -30,6 +31,10 @@ private Pattern pattern; + /** + * Instantiates a new RegExpTableFilter + * @param pattern regexp pattern + */ public RegExpTableFilter(String pattern) { if (pattern != null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-26 18:14:08
|
Revision: 548 http://openutils.svn.sourceforge.net/openutils/?rev=548&view=rev Author: fgiust Date: 2008-01-26 10:14:12 -0800 (Sat, 26 Jan 2008) Log Message: ----------- bump version to 2.0, requires java 5 Modified Paths: -------------- trunk/openutils-log4j/pom.xml trunk/openutils-log4j/src/site/apt/index.apt Modified: trunk/openutils-log4j/pom.xml =================================================================== --- trunk/openutils-log4j/pom.xml 2008-01-26 18:13:01 UTC (rev 547) +++ trunk/openutils-log4j/pom.xml 2008-01-26 18:14:12 UTC (rev 548) @@ -10,7 +10,7 @@ </parent> <artifactId>openutils-log4j</artifactId> <packaging>jar</packaging> - <version>1.0.2-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> <name>openutils for Log4j</name> <description>openutils log4j extensions</description> <build> @@ -19,8 +19,8 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.4</source> - <target>1.4</target> + <source>1.5</source> + <target>1.5</target> </configuration> </plugin> </plugins> @@ -29,7 +29,7 @@ <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> - <version>1.2.13</version> + <version>1.2.14</version> </dependency> <dependency> <groupId>javax.mail</groupId> Modified: trunk/openutils-log4j/src/site/apt/index.apt =================================================================== --- trunk/openutils-log4j/src/site/apt/index.apt 2008-01-26 18:13:01 UTC (rev 547) +++ trunk/openutils-log4j/src/site/apt/index.apt 2008-01-26 18:14:12 UTC (rev 548) @@ -24,3 +24,4 @@ Check it at {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-log4j}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-log4j}} + Warning: since release 2.0 openutils-log4j requires java 5 or higher This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-26 18:12:56
|
Revision: 547 http://openutils.svn.sourceforge.net/openutils/?rev=547&view=rev Author: fgiust Date: 2008-01-26 10:13:01 -0800 (Sat, 26 Jan 2008) Log Message: ----------- generics Modified Paths: -------------- trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java trunk/openutils-log4j/src/main/java/it/openutils/log4j/FilteredPatternLayout.java trunk/openutils-log4j/src/main/java/it/openutils/log4j/Log4jConfigurationServlet.java Modified: trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java 2008-01-26 18:05:51 UTC (rev 546) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java 2008-01-26 18:13:01 UTC (rev 547) @@ -129,6 +129,7 @@ return datePattern; } + @Override public void activateOptions() { super.activateOptions(); @@ -302,6 +303,7 @@ * Before actually logging, this method will check whether it is time to do a rollover. If it is, it will schedule * the next rollover time and then rollover. */ + @Override protected void subAppend(LoggingEvent event) { long n = System.currentTimeMillis(); Modified: trunk/openutils-log4j/src/main/java/it/openutils/log4j/FilteredPatternLayout.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/FilteredPatternLayout.java 2008-01-26 18:05:51 UTC (rev 546) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/FilteredPatternLayout.java 2008-01-26 18:13:01 UTC (rev 547) @@ -46,14 +46,14 @@ { /** - * Holds the list of filtered frames. + * Line separator for stacktrace frames. */ - private Set filteredFrames = new HashSet(); + private static String lineSeparator = "\n"; /** - * Line separator for stacktrace frames. + * Holds the list of filtered frames. */ - private static String lineSeparator = "\n"; + private Set<String> filteredFrames = new HashSet<String>(); static { @@ -68,16 +68,18 @@ } /** - * @see org.apache.log4j.Layout#ignoresThrowable() + * {@inheritDoc} */ + @Override public boolean ignoresThrowable() { return false; } /** - * @see org.apache.log4j.PatternLayout#format(org.apache.log4j.spi.LoggingEvent) + * {@inheritDoc} */ + @Override public String format(LoggingEvent event) { @@ -130,10 +132,10 @@ */ private boolean startsWithAFilteredPAttern(String string) { - Iterator iterator = filteredFrames.iterator(); + Iterator<String> iterator = filteredFrames.iterator(); while (iterator.hasNext()) { - if (string.trim().startsWith((String) iterator.next())) + if (string.trim().startsWith(iterator.next())) { return true; } Modified: trunk/openutils-log4j/src/main/java/it/openutils/log4j/Log4jConfigurationServlet.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/Log4jConfigurationServlet.java 2008-01-26 18:05:51 UTC (rev 546) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/Log4jConfigurationServlet.java 2008-01-26 18:13:01 UTC (rev 547) @@ -121,7 +121,7 @@ Level.WARN.toString(), Level.INFO.toString(), Level.DEBUG.toString(), - Level.ALL.toString()}; + Level.ALL.toString() }; /** * Don't include html head. @@ -135,13 +135,21 @@ * @exception ServletException if an error occurs * @exception IOException if an error occurs */ + @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String className = request.getParameter(PARAM_CLASS); + String level = request.getParameter(PARAM_LEVEL); + if (className != null && level != null) + { + setClass(className, level); + } + String sortByLevelParam = request.getParameter(PARAM_SORTBYLEVEL); boolean sortByLevel = ("true".equalsIgnoreCase(sortByLevelParam) || "yes".equalsIgnoreCase(sortByLevelParam)); - List loggers = getSortedLoggers(sortByLevel); + List<Logger> loggers = getSortedLoggers(sortByLevel); int loggerNum = 0; PrintWriter out = response.getWriter(); @@ -175,11 +183,11 @@ displayLogger(out, Logger.getRootLogger(), loggerNum++, request); // print the rest of the loggers - Iterator iterator = loggers.iterator(); + Iterator<Logger> iterator = loggers.iterator(); while (iterator.hasNext()) { - displayLogger(out, (Logger) iterator.next(), loggerNum++, request); + displayLogger(out, iterator.next(), loggerNum++, request); } out.println("</tbody>"); @@ -201,16 +209,9 @@ * @exception ServletException if an error occurs * @exception IOException if an error occurs */ + @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String className = request.getParameter(PARAM_CLASS); - String level = request.getParameter(PARAM_LEVEL); - - if (className != null) - { - setClass(className, level); - } - doGet(request, response); } @@ -284,12 +285,13 @@ * @param sortByLevel if <code>true</code> sort loggers by level instead of name. * @return List the list of sorted loggers. */ - private List getSortedLoggers(boolean sortByLevel) + @SuppressWarnings("unchecked") + private List<Logger> getSortedLoggers(boolean sortByLevel) { - Enumeration enm = LogManager.getCurrentLoggers(); - Comparator comp = new LoggerComparator(sortByLevel); - List list = new ArrayList(); + Enumeration<Logger> enm = LogManager.getCurrentLoggers(); + List<Logger> list = new ArrayList<Logger>(); + // Add all current loggers to the list while (enm.hasMoreElements()) { @@ -297,7 +299,7 @@ } // sort the loggers - Collections.sort(list, comp); + Collections.sort(list, new LoggerComparator(sortByLevel)); return list; } @@ -354,7 +356,7 @@ /** * Compare the names of two <code>Logger</code>s. Used for sorting. */ - private class LoggerComparator implements Comparator + private class LoggerComparator implements Comparator<Logger> { /** @@ -377,11 +379,8 @@ * @param object2 an <code>Object</code> value * @return an <code>int</code> value */ - public int compare(Object object1, Object object2) + public int compare(Logger logger1, Logger logger2) { - Logger logger1 = (Logger) object1; - Logger logger2 = (Logger) object2; - if (!sortByLevel) { return logger1.getName().compareTo(logger2.getName()); @@ -394,6 +393,7 @@ * @param object an <code>Object</code> value * @return a <code>boolean</code> value */ + @Override public boolean equals(Object object) { if (!(object instanceof LoggerComparator)) @@ -406,6 +406,7 @@ /** * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return super.hashCode(); @@ -413,8 +414,9 @@ } /** - * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) + * {@inheritDoc} */ + @Override public void init(ServletConfig config) throws ServletException { String fragmentParam = config.getInitParameter(CONFIG_FRAGMENT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-26 18:05:50
|
Revision: 546 http://openutils.svn.sourceforge.net/openutils/?rev=546&view=rev Author: fgiust Date: 2008-01-26 10:05:51 -0800 (Sat, 26 Jan 2008) Log Message: ----------- new AlternateSMTPAppender Modified Paths: -------------- trunk/openutils-log4j/src/main/java/it/openutils/log4j/DynamicSubjectSMTPAppender.java trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java Added Paths: ----------- trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java Added: trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java (rev 0) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java 2008-01-26 18:05:51 UTC (rev 546) @@ -0,0 +1,663 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.log4j; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Timer; +import java.util.TimerTask; + +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.Layout; +import org.apache.log4j.Level; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.helpers.OptionConverter; +import org.apache.log4j.spi.ErrorCode; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.spi.TriggeringEventEvaluator; + + +/** + * An alternative of <code>org.apache.log4j.net.SMTPAppender</code> with few differences: + * <ul> + * <li>allow customizing the mail subject using a pattern</li> + * <li>can be configured with a timeout (in seconds), it will only send messages after this timeout</li> + * <li>it will send a mail for every single message (bufferSize is not supported), but it will aggregate any identical + * log event received during the timeout. Identical events are log with same message and same stack trace</li> + * </ul> + * + * <pre> + * <appender name="mail" class="it.openutils.log4j.AlternateSMTPAppender"> + * <param name="Threshold" value="ERROR" /> + * <param name="To" value="lo...@ex..." /> + * <param name="From" value="in...@ex..." /> + * <param name="SMTPHost" value="localhost" /> + * <param name="Timeout" value="180" /> + * <param name="Subject" value="[EXAMPLE] %m" /> + * <layout class="org.apache.log4j.PatternLayout"> + * <param name="ConversionPattern" value="%-5p %c %d{dd.MM.yyyy HH:mm:ss} -- %m%n" /> + * </layout> + * <param name="Header" + * value=" + * =================================== + * Myapp (production environment) + * Date: %d{dd.MM.yyyy HH:mm:ss} + * =================================== + * " /> + * </appender> + * </pre> + * + * @author Fabrizio Giustina + * @version $Id$ + */ +public class AlternateSMTPAppender extends AppenderSkeleton +{ + + private String to; + + private String from; + + private Layout subjectLayout; + + private String smtpHost; + + private boolean locationInfo; + + private Timer timer = new Timer(); + + private TimerTask timerTask; + + private int timeout; + + protected Map<LoggingEventAggregator, LoggingEventAggregator> events = new LinkedHashMap<LoggingEventAggregator, LoggingEventAggregator>() + { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * {@inheritDoc} + */ + @Override + public LoggingEventAggregator put(LoggingEventAggregator key, LoggingEventAggregator value) + { + LoggingEventAggregator lea = this.get(key); + if (lea != null) + { + lea.incrementCount(); + return lea; + } + + return super.put(key, value); + } + + }; + + protected Message msg; + + protected TriggeringEventEvaluator evaluator; + + /** + * The default constructor will instantiate the appender with a {@link TriggeringEventEvaluator} that will trigger + * on events with level ERROR or higher. + */ + public AlternateSMTPAppender() + { + this(new DefaultEvaluator()); + } + + /** + * Use <code>evaluator</code> passed as parameter as the {@link TriggeringEventEvaluator} for this SMTPAppender. + */ + public AlternateSMTPAppender(TriggeringEventEvaluator evaluator) + { + this.evaluator = evaluator; + } + + /** + * Activate the specified options, such as the smtp host, the recipient, from, etc. + */ + @Override + public void activateOptions() + { + Properties props = new Properties(System.getProperties()); + if (smtpHost != null) + { + props.put("mail.smtp.host", smtpHost); + } + + Session session = Session.getInstance(props, null); + // session.setDebug(true); + msg = new MimeMessage(session); + + try + { + if (from != null) + { + msg.setFrom(getAddress(from)); + } + else + { + msg.setFrom(); + } + + msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); + } + catch (MessagingException e) + { + LogLog.error("Could not activate SMTPAppender options.", e); + } + } + + /** + * Perform SMTPAppender specific appending actions, mainly adding the event to a cyclic buffer and checking if the + * event triggers an e-mail to be sent. + */ + @Override + public void append(LoggingEvent event) + { + + if (!checkEntryConditions()) + { + return; + } + + event.getThreadName(); + event.getNDC(); + if (locationInfo) + { + event.getLocationInformation(); + } + + LoggingEventAggregator leg = new LoggingEventAggregator(event); + + events.put(leg, leg); + + if (evaluator.isTriggeringEvent(event)) + { + if (timeout == 0) + { + // send immediately + sendBuffer(events.values()); + return; + } + if (timerTask == null) + { + + timerTask = new TimerTask() + { + + @Override + public void run() + { + Collection<LoggingEventAggregator> le; + synchronized (events) + { + le = new ArrayList<LoggingEventAggregator>(events.values()); + events.clear(); + timerTask = null; + } + + sendBuffer(le); + } + }; + + this.timer.schedule(this.timerTask, this.timeout * 1000L); + + } + } + } + + /** + * This method determines if there is a sense in attempting to append. + * <p> + * It checks whether there is a set output target and also if there is a set layout. If these checks fail, then the + * boolean value <code>false</code> is returned. + */ + protected boolean checkEntryConditions() + { + if (this.msg == null) + { + errorHandler.error("Message object not configured."); + return false; + } + + if (this.evaluator == null) + { + errorHandler.error("No TriggeringEventEvaluator is set for appender [" + name + "]."); + return false; + } + + if (this.layout == null) + { + errorHandler.error("No layout set for appender named [" + name + "]."); + return false; + } + return true; + } + + @Override + public synchronized void close() + { + this.closed = true; + } + + InternetAddress getAddress(String addressStr) + { + try + { + return new InternetAddress(addressStr); + } + catch (AddressException e) + { + errorHandler.error("Could not parse address [" + addressStr + "].", e, ErrorCode.ADDRESS_PARSE_FAILURE); + return null; + } + } + + InternetAddress[] parseAddress(String addressStr) + { + try + { + return InternetAddress.parse(addressStr, true); + } + catch (AddressException e) + { + errorHandler.error("Could not parse address [" + addressStr + "].", e, ErrorCode.ADDRESS_PARSE_FAILURE); + return null; + } + } + + /** + * Returns value of the <b>To</b> option. + */ + public String getTo() + { + return to; + } + + /** + * The <code>SMTPAppender</code> requires a {@link org.apache.log4j.Layout layout}. + */ + @Override + public boolean requiresLayout() + { + return true; + } + + /** + * Send the contents of the cyclic buffer as an e-mail message. + */ + protected void sendBuffer(Collection<LoggingEventAggregator> eventsCollection) + { + + // Note: this code already owns the monitor for this + // appender. This frees us from needing to synchronize on 'cb'. + try + { + + for (LoggingEventAggregator lea : eventsCollection) + { + MimeBodyPart part = new MimeBodyPart(); + + StringBuffer sbuf = new StringBuffer(); + String t = layout.getHeader(); + if (t != null) + { + sbuf.append(t); + } + + sbuf.append("\nNumber of occurences: "); + sbuf.append(lea.getCount()); + sbuf.append("\n\n"); + + LoggingEvent event = lea.getLoggingEvent(); + + if (this.subjectLayout != null) + { + String subject = this.subjectLayout.format(event); + + if (subject != null) + { + subject = subject.trim(); + if (subject.indexOf("\n") > 0) + { + subject = subject.substring(0, subject.indexOf("\n")); + } + } + + this.msg.setSubject(subject); + } + + sbuf.append(layout.format(event)); + if (layout.ignoresThrowable()) + { + String[] s = event.getThrowableStrRep(); + if (s != null) + { + for (String element : s) + { + sbuf.append(element); + } + } + } + t = layout.getFooter(); + if (t != null) + { + sbuf.append(t); + } + part.setContent(sbuf.toString(), layout.getContentType()); + + Multipart mp = new MimeMultipart(); + mp.addBodyPart(part); + msg.setContent(mp); + + msg.setSentDate(new Date()); + Transport.send(msg); + } + + } + catch (Exception e) + { + LogLog.error("Error occured while sending e-mail notification.", e); + } + + } + + /** + * Returns value of the <b>EvaluatorClass</b> option. + */ + public String getEvaluatorClass() + { + return evaluator == null ? null : evaluator.getClass().getName(); + } + + /** + * Returns value of the <b>From</b> option. + */ + public String getFrom() + { + return from; + } + + /** + * Returns value of the <b>Subject</b> option. + */ + public String getSubject() + { + return subjectLayout.toString(); + } + + /** + * The <b>From</b> option takes a string value which should be a e-mail address of the sender. + */ + public void setFrom(String from) + { + this.from = from; + } + + /** + * The <b>Subject</b> option takes a string value which should be a the subject of the e-mail message. + */ + public void setSubject(String subjectPattern) + { + this.subjectLayout = new PatternLayout(subjectPattern); + } + + /** + * This option is ignored! + */ + @Deprecated + public void setBufferSize(int bufferSize) + { + // kept as deprecated + LogLog.warn("BufferSize property is deprecated for " + getClass().getName()); + } + + /** + * The <b>SMTPHost</b> option takes a string value which should be a the host name of the SMTP server that will + * send the e-mail message. + */ + public void setSMTPHost(String smtpHost) + { + this.smtpHost = smtpHost; + } + + /** + * Returns value of the <b>SMTPHost</b> option. + */ + public String getSMTPHost() + { + return smtpHost; + } + + /** + * The <b>To</b> option takes a string value which should be a comma separated list of e-mail address of the + * recipients. + */ + public void setTo(String to) + { + this.to = to; + } + + /** + * Returns value of the <b>BufferSize</b> option. + */ + public int getBufferSize() + { + return 0; + } + + /** + * The <b>EvaluatorClass</b> option takes a string value representing the name of the class implementing the {@link + * TriggeringEventEvaluator} interface. A corresponding object will be instantiated and assigned as the triggering + * event evaluator for the SMTPAppender. + */ + public void setEvaluatorClass(String value) + { + evaluator = (TriggeringEventEvaluator) OptionConverter.instantiateByClassName( + value, + TriggeringEventEvaluator.class, + evaluator); + } + + /** + * @param value + */ + public void setEvaluator(TriggeringEventEvaluator value) + { + evaluator = value; + } + + /** + * The <b>LocationInfo</b> option takes a boolean value. By default, it is set to false which means there will be + * no effort to extract the location information related to the event. As a result, the layout that formats the + * events as they are sent out in an e-mail is likely to place the wrong location information (if present in the + * format). + * <p> + * Location information extraction is comparatively very slow and should be avoided unless performance is not a + * concern. + */ + public void setLocationInfo(boolean locationInfo) + { + this.locationInfo = locationInfo; + } + + /** + * Returns value of the <b>LocationInfo</b> option. + */ + public boolean getLocationInfo() + { + return locationInfo; + } + + /** + * Returns the timeout. + * @return the timeout + */ + public int getTimeout() + { + return timeout; + } + + /** + * Sets the timeout. + * @param timeout the timeout to set + */ + public void setTimeout(int timeout) + { + this.timeout = timeout; + } +} + + +class LoggingEventAggregator +{ + + private LoggingEvent loggingEvent; + + private int count; + + public LoggingEventAggregator(LoggingEvent loggingEvent) + { + this.loggingEvent = loggingEvent; + this.count = 1; + } + + /** + * Returns the loggingEvent. + * @return the loggingEvent + */ + public LoggingEvent getLoggingEvent() + { + return loggingEvent; + } + + /** + * Returns the count. + * @return the count + */ + public int getCount() + { + return count; + } + + /** + * Sets the count. + * @param count the count to set + */ + public void setCount(int count) + { + this.count = count; + } + + public void incrementCount() + { + count++; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + + Object lem = loggingEvent.getMessage(); + String[] thstr = loggingEvent.getThrowableStrRep(); + result = prime * result + ((lem == null) ? 0 : lem.hashCode()); + result = prime * result + Arrays.hashCode(thstr); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + final LoggingEventAggregator other = (LoggingEventAggregator) obj; + + Object lem = loggingEvent.getMessage(); + String[] thstr = loggingEvent.getThrowableStrRep(); + + Object otherLem = other.loggingEvent.getMessage(); + String[] otherThstr = other.loggingEvent.getThrowableStrRep(); + + if (lem == null) + { + if (otherLem != null) + { + return false; + } + } + + else if (!lem.equals(otherLem)) + { + return false; + } + if (!Arrays.equals(thstr, otherThstr)) + { + return false; + } + return true; + } + +} + + +class DefaultEvaluator implements TriggeringEventEvaluator +{ + + public boolean isTriggeringEvent(LoggingEvent event) + { + return event.getLevel().isGreaterOrEqual(Level.ERROR); + } +} Property changes on: trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-log4j/src/main/java/it/openutils/log4j/DynamicSubjectSMTPAppender.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/DynamicSubjectSMTPAppender.java 2008-01-26 13:58:30 UTC (rev 545) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/DynamicSubjectSMTPAppender.java 2008-01-26 18:05:51 UTC (rev 546) @@ -1,5 +1,5 @@ /* - * Copyright 2005 Fabrizio Giustina. + * Copyright Openmind http://www.openmindonline.it * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,117 +15,14 @@ */ package it.openutils.log4j; -import java.util.Date; - -import javax.mail.Multipart; -import javax.mail.Transport; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMultipart; - -import org.apache.log4j.Layout; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.helpers.LogLog; -import org.apache.log4j.net.SMTPAppender; -import org.apache.log4j.spi.LoggingEvent; - - /** - * An extension of <code>org.apache.log4j.net.SMTPAppender</code> which let you customize the mail subject using a - * pattern. Sample configuration: - * - * <pre> - * <appender name="mail" class="it.openutils.log4j.DynamicSubjectSMTPAppender"> - * <param name="Threshold" value="ERROR" /> - * <param name="To" value="lo...@ex..." /> - * <param name="From" value="in...@ex..." /> - * <param name="SMTPHost" value="localhost" /> - * <param name="BufferSize" value="1" /> - * <param name="Subject" value="[EXAMPLE] %m" /> - * <layout class="org.apache.log4j.PatternLayout"> - * <param name="ConversionPattern" value="%-5p %c %d{dd.MM.yyyy HH:mm:ss} -- %m%n" /> - * </layout> - * </appender> - * </pre> - * + * See it.openutils.log4j.AlternateSMTPAppender + * @deprecated use it.openutils.log4j.AlternateSMTPAppender which has this and other features * @author Fabrizio Giustina - * @version $Id$ + * @version $Id: $ */ -public class DynamicSubjectSMTPAppender extends SMTPAppender +@Deprecated +public class DynamicSubjectSMTPAppender extends AlternateSMTPAppender { - private Layout subjectLayout; - - /** - * Setter for <code>subject</code>. - * @param subjectPattern The subjectPattern to set. - */ - public void setSubject(String subjectPattern) - { - this.subjectLayout = new PatternLayout(subjectPattern); - } - - /** - * Send the contents of the cyclic buffer as an e-mail message. - */ - protected void sendBuffer() - { - try - { - MimeBodyPart part = new MimeBodyPart(); - - StringBuffer sbuf = new StringBuffer(); - String t = layout.getHeader(); - if (t != null) - sbuf.append(t); - int len = cb.length(); - for (int i = 0; i < len; i++) - { - LoggingEvent event = cb.get(); - - if (this.subjectLayout != null) - { - String subject = this.subjectLayout.format(event); - if (subject != null) - { - subject = subject.trim(); - if (subject.indexOf("\n") > 0) - { - subject = subject.substring(0, subject.indexOf("\n")); - } - } - this.msg.setSubject(subject); - } - - sbuf.append(layout.format(event)); - if (layout.ignoresThrowable()) - { - String[] s = event.getThrowableStrRep(); - if (s != null) - { - for (int j = 0; j < s.length; j++) - { - sbuf.append(s[j]); - } - } - } - } - t = layout.getFooter(); - if (t != null) - sbuf.append(t); - part.setContent(sbuf.toString(), layout.getContentType()); - - Multipart mp = new MimeMultipart(); - mp.addBodyPart(part); - msg.setContent(mp); - - msg.setSentDate(new Date()); - Transport.send(msg); - } - catch (Exception e) - { - LogLog.error("Error occured while sending e-mail notification.", e); - } - - } - } Modified: trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java 2008-01-26 13:58:30 UTC (rev 545) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/EnhancedDailyRollingFileAppender.java 2008-01-26 18:05:51 UTC (rev 546) @@ -1,3 +1,18 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.log4j; import java.io.File; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |