[richfaces-svn-commits] JBoss Rich Faces SVN: r14213 - in trunk/examples/photoalbum/source/ejb: sql/short and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu May 14 10:32:33 EDT 2009


Author: amarkhel
Date: 2009-05-14 10:32:33 -0400 (Thu, 14 May 2009)
New Revision: 14213

Modified:
   trunk/examples/photoalbum/source/ejb/sql/full/import.sql
   trunk/examples/photoalbum/source/ejb/sql/short/import.sql
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Image.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java
   trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java
Log:


Modified: trunk/examples/photoalbum/source/ejb/sql/full/import.sql
===================================================================
--- trunk/examples/photoalbum/source/ejb/sql/full/import.sql	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/sql/full/import.sql	2009-05-14 14:32:33 UTC (rev 14213)
@@ -1,6 +1,6 @@
-INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (1,  'Andrey', 'Markhel', 'amarkhel at exadel.com',  'amarkhel', '8cb2237d0679ca88db6464eac60da96345513964',  '1985-01-08', 0, 0, true);
-INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (2,  'Nick',   'Curtis',  'nkurtis at iba.com',      'Viking',   '8cb2237d0679ca88db6464eac60da96345513964',  '1978-01-08', 1, 0, true);
-INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (3,  'John',   'Smith',   'jsmith at jboss.com',     'Noname',   '8cb2237d0679ca88db6464eac60da96345513964',  '1970-01-08', 1, 0, true);
+INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (1,  'Andrey', 'Markhel', 'amarkhel at exadel.com',  'amarkhel', '8cb2237d0679ca88db6464eac60da96345513964',  '1985-01-08', 0, false, true);
+INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (2,  'Nick',   'Curtis',  'nkurtis at iba.com',      'Viking',   '8cb2237d0679ca88db6464eac60da96345513964',  '1978-01-08', 1, false, true);
+INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (3,  'John',   'Smith',   'jsmith at jboss.com',     'Noname',   '8cb2237d0679ca88db6464eac60da96345513964',  '1970-01-08', 1, false, true);
 
 INSERT INTO Shelf(id, name, description, owner_id, created, shared) VALUES (1, 'Nature',       'Nature pictures',        1, '2009-12-18', true);
 INSERT INTO Shelf(id, name, description, owner_id, created, shared) VALUES (2, 'Sport & Cars', 'Sport & Cars pictures',  1, '2009-12-18', true);

Modified: trunk/examples/photoalbum/source/ejb/sql/short/import.sql
===================================================================
--- trunk/examples/photoalbum/source/ejb/sql/short/import.sql	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/sql/short/import.sql	2009-05-14 14:32:33 UTC (rev 14213)
@@ -1,6 +1,6 @@
-INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (1,  'Andrey', 'Markhel', 'amarkhel at exadel.com',  'amarkhel', '8cb2237d0679ca88db6464eac60da96345513964',  '1985-01-08', 0, 0, true);
-INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (2,  'Nick',   'Curtis',  'nkurtis at iba.com',      'Viking',   '8cb2237d0679ca88db6464eac60da96345513964',  '1978-01-08', 1, 0, true);
-INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (3,  'John',   'Smith',   'jsmith at jboss.com',     'Noname',   '8cb2237d0679ca88db6464eac60da96345513964',  '1970-01-08', 1, 0, true);
+INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (1,  'Andrey', 'Markhel', 'amarkhel at exadel.com',  'amarkhel', '8cb2237d0679ca88db6464eac60da96345513964',  '1985-01-08', 0, false, true);
+INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (2,  'Nick',   'Curtis',  'nkurtis at iba.com',      'Viking',   '8cb2237d0679ca88db6464eac60da96345513964',  '1978-01-08', 1, false, true);
+INSERT INTO User(id, firstname, secondname, email, login, passwordHash, birthdate, sex, hasAvatar, preDefined) VALUES (3,  'John',   'Smith',   'jsmith at jboss.com',     'Noname',   '8cb2237d0679ca88db6464eac60da96345513964',  '1970-01-08', 1, false, true);
 
 INSERT INTO Shelf(id, name, description, owner_id, created, shared) VALUES (1, 'Nature',       'Nature pictures',        1, '2009-12-18', true);
 INSERT INTO Shelf(id, name, description, owner_id, created, shared) VALUES (2, 'Sport & Cars', 'Sport & Cars pictures',  1, '2009-12-18', true);

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -23,7 +23,6 @@
 import java.io.Serializable;
 import java.util.Date;
 
-import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Image.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Image.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Image.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -74,6 +74,10 @@
 			query = "select i from Image i where i.path = :path and i.album = :album"
 	),
 	@NamedQuery(
+			name = "image-countIdenticalImages",
+			query = "select count(i) from Image i where i.path like :path and i.album = :album"
+	),
+	@NamedQuery(
 			name = "tag-suggest",
 			query = "select m from MetaTag m where lower(m.tag) like :tag"
 	)})

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -1,30 +1,30 @@
 package org.richfaces.photoalbum.domain;
 
-import org.hibernate.annotations.OrderBy;
-import org.hibernate.validator.Length;
-import org.hibernate.validator.NotEmpty;
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
+import java.io.File;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
 import javax.persistence.OneToMany;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
-import java.io.File;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
 
+import org.hibernate.annotations.OrderBy;
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotEmpty;
+import org.hibernate.validator.NotNull;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
 @Entity
 @Name("shelf")
 @Scope(ScopeType.CONVERSATION)

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -86,7 +86,7 @@
 @Scope(ScopeType.SESSION)
 @Name("user")
 @AutoCreate
- at Table(uniqueConstraints = {
+ at Table(name="User", uniqueConstraints = {
 	@UniqueConstraint(columnNames = "login"),
 	@UniqueConstraint(columnNames = "email")
 		}

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -53,6 +53,7 @@
 	public static final String USER_DELETED_EVENT = "userDeletedEvent";
 	
 	//Errors(Internationalization pending)
+	public static final String YOU_ALREADY_DOWNLOAD_MANY_COPIES_OF_THIS_IMAGE_ERROR = "You already download 256 copies of this image. Please specify another name for uploaded image";
 	public static final String SAME_IMAGE_EXIST_ERROR = "You already have an image with the given name in selected album";
 	public static final String SAME_ALBUM_EXIST_ERROR = "You already have an album with the given name in selected shelf";
 	public static final String SAME_SHELF_EXIST_ERROR = "You already have a shelf with the given name.";
@@ -116,6 +117,7 @@
 	public static final String ADMIN_ROLE = "admin";
 	
 	//misc
+	public static final int NUMBER_OF_IMAGE_COPIES = 256;
 	public static final String AVATAR_JPG = "avatar.jpg";
 	public static final int AVATAR_SIZE = 80;
 	public static final int DEFAULT_IMAGE_SIZEVALUE = 120;
@@ -171,6 +173,7 @@
 	public static final String SHELF_PARAMETER = "shelf";
 	public static final String PATH_PARAMETER = "path";
 	public static final String IMAGE_PATH_EXIST_QUERY = "image-exist";
+	public static final String IMAGE_IDENTICAL_QUERY = "image-countIdenticalImages";
 	public static final String SEARCH_NO_OPTIONS_ERROR = "You must select at least one search option";
 	public static final String TREE_ID = "treeform";
 	public static final String USER_COMMENTS_QUERY = "user-comments";

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -24,6 +24,7 @@
 
 import javax.ejb.Local;
 
+import org.richfaces.photoalbum.domain.Album;
 import org.richfaces.photoalbum.domain.Comment;
 import org.richfaces.photoalbum.domain.Image;
 import org.richfaces.photoalbum.domain.MetaTag;
@@ -54,7 +55,9 @@
 
 	public List<MetaTag> getTagsLikeString(String suggest);
 
-	public boolean isImageWithThisPathExist(Image image);
+	public boolean isImageWithThisPathExist(Album album, String path);
+	
+	public Long getCountIdenticalImages(Album album, String path);
 
 	public List<Comment> findAllUserComments(User user);
 	

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -26,7 +26,6 @@
 import javax.ejb.Local;
 
 import org.richfaces.photoalbum.domain.Shelf;
-import org.richfaces.photoalbum.domain.User;
 /**
  * Interface for manipulating with shelf entity
  *

Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java	2009-05-14 14:32:19 UTC (rev 14212)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java	2009-05-14 14:32:33 UTC (rev 14213)
@@ -36,7 +36,6 @@
 import org.richfaces.photoalbum.domain.Comment;
 import org.richfaces.photoalbum.domain.Image;
 import org.richfaces.photoalbum.domain.MetaTag;
-import org.richfaces.photoalbum.domain.Shelf;
 import org.richfaces.photoalbum.domain.User;
 /**
  * Class for manipulating with image entity. Analogous to DAO pattern.
@@ -226,22 +225,38 @@
     }
 
 	/**
-     * Check if image with specified path already exist
+     * Check if image with specified path already exist in specified album
+     * @param album - album to check
+     * @param path - path to check
      * @return is image with specified path already exist
      */
-	public boolean isImageWithThisPathExist(Image image) {
+	public boolean isImageWithThisPathExist(Album album, String path) {
 		return em.createNamedQuery(Constants.IMAGE_PATH_EXIST_QUERY)
-		.setParameter(Constants.PATH_PARAMETER, image.getPath())
-		.setParameter(Constants.ALBUM_PARAMETER, image.getAlbum())
+		.setParameter(Constants.PATH_PARAMETER, path)
+		.setParameter(Constants.ALBUM_PARAMETER, album)
 		.getResultList().size() != 0;
 	}
+	
+	/**
+     * Return count of images with path, that started from specified path already exist in specified album
+     * @param album - album to check
+     * @param path - path to check
+     * @return count of images
+     */
+	public Long getCountIdenticalImages(Album album, String path) {
+		return (Long)em.createNamedQuery(Constants.IMAGE_IDENTICAL_QUERY)
+		.setParameter(Constants.PATH_PARAMETER, path + Constants.PERCENT)
+		.setParameter(Constants.ALBUM_PARAMETER, album)
+		.getSingleResult();
+	}
 
 	/**
      * Retrieve all cooments posted by given user.
      * @return list of comments
      */
+	@SuppressWarnings("unchecked")
 	public List<Comment> findAllUserComments(User user) {
-		return em.createNamedQuery(Constants.USER_COMMENTS_QUERY)
+		return (List<Comment>)em.createNamedQuery(Constants.USER_COMMENTS_QUERY)
 		.setParameter(Constants.AUTHOR_PARAMETER, user)
 		.getResultList();
 	}




More information about the richfaces-svn-commits mailing list