[richfaces-svn-commits] JBoss Rich Faces SVN: r14083 - in trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum: service and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri May 8 12:41:11 EDT 2009


Author: amarkhel
Date: 2009-05-08 12:41:10 -0400 (Fri, 08 May 2009)
New Revision: 14083

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/service/Constants.java
Log:


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-08 16:04:43 UTC (rev 14082)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java	2009-05-08 16:41:10 UTC (rev 14083)
@@ -361,6 +361,51 @@
 		return albums;
 	}
 
+	/**
+	 * This method check, if user already have shelf with given name
+	 * 
+	 * @param shelf - shelf to check
+	 * @return boolean value, that indicated if shelf with the same name exist
+	 */
+	public boolean hasShelfWithName(Shelf shelf) {
+		for(Shelf s : getShelves()){
+			if(!s.equals(shelf) && s.getName().equals(shelf.getName())){
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	/**
+	 * This method check, if parent shelf contain album with the same name as given album
+	 * 
+	 * @param album - album to check
+	 * @return boolean value, that indicate if album with the same name exist
+	 */
+	public boolean hasAlbumWithName(Album album) {
+		for(Album a : album.getShelf().getAlbums()){
+			if(!a.equals(album) && a.getName().equals(album.getName())){
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	/**
+	 * This method check, if containing album already have image with the same name
+	 * 
+	 * @param image - image to check
+	 * @return boolean value, that indicate if image with the same name exist
+	 */
+	public boolean hasImageWithName(Image image) {
+		for(Image i : image.getAlbum().getImages()){
+			if(!i.equals(image) &&  i.getName().equals(image.getName())){
+				return true;
+			}
+		}
+		return false;
+	}
+	
 	public boolean equals(final Object o) {
 		if (this == o) return true;
 		if (o == null || getClass() != o.getClass()) return false;
@@ -379,22 +424,4 @@
 		result = 31 * result + (login != null ? login.hashCode() : 0);
 		return result;
 	}
-
-	public boolean hasShelfWithName(String name) {
-		for(Shelf s : getShelves()){
-			if(s.getName().equals(name)){
-				return true;
-			}
-		}
-		return false;
-	}
-	
-	public boolean hasAlbumWithName(String name) {
-		for(Album a : getAlbums()){
-			if(a.getName().equals(name)){
-				return true;
-			}
-		}
-		return false;
-	}
 }
\ No newline at end of file

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-08 16:04:43 UTC (rev 14082)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java	2009-05-08 16:41:10 UTC (rev 14083)
@@ -53,7 +53,8 @@
 	public static final String USER_DELETED_EVENT = "userDeletedEvent";
 	
 	//Errors(Internationalization pending)
-	public static final String SAME_ALBUM_EXIST_ERROR = "You already have album with given name.";
+	public static final String SAME_IMAGE_EXIST_ERROR = "You already have image with given name in selected album";
+	public static final String SAME_ALBUM_EXIST_ERROR = "You already have album with given name in selected shelf";
 	public static final String SAME_SHELF_EXIST_ERROR = "You already have shelf with given name.";
 	public static final String AVATAR_SAVING_ERROR = "Error while saving avatar to disk";
 	public static final String YOU_CAN_T_ADD_IMAGES_TO_THAT_ALBUM_ERROR = "You can't add images to that album";




More information about the richfaces-svn-commits mailing list