Author: amarkhel
Date: 2009-04-01 06:29:45 -0400 (Wed, 01 Apr 2009)
New Revision: 13334
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java
trunk/test-applications/realworld2/ejb/src/main/resources/import.sql
Log:
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -48,6 +48,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
+import org.jboss.seam.annotations.Scope;
/**
* Class for representing Album Entity EJB3 Entity Bean
@@ -57,7 +58,7 @@
@Entity
@Name("album")
@Table(name = "albums")
-@Role(name = "selectedAlbum", scope = ScopeType.CONVERSATION)
+(a)Scope(ScopeType.CONVERSATION)
public class Album implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
@@ -168,8 +169,15 @@
}
if (image.getAlbum() != null && !this.equals(image.getAlbum())) {
//TODO nick - use removeImage()
+ if(image.getAlbum().getUnvisitedImages().contains(image)){
+ image.getAlbum().getUnvisitedImages().remove(image);
+ }
+ if(image.getAlbum().getShelf().getUnvisitedImages().contains(image)){
+ image.getAlbum().getShelf().getUnvisitedImages().remove(image);
+ }
image.getAlbum().removeImage(image);
}
+ this.setUnvisitedImages(new ArrayList<Image>());
image.setAlbum(this);
images.add(image);
}
@@ -203,7 +211,7 @@
}
public User getOwner() {
- return getShelf().getOwner();
+ return getShelf()!=null ? getShelf().getOwner(): null;
}
public List<Image> getImages() {
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -37,11 +37,14 @@
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.Name;
+import org.jboss.seam.annotations.Scope;
@Entity
@Name("comment")
@Table(name = "comments")
+(a)Scope(ScopeType.EVENT)
public class Comment implements Serializable {
private static final long serialVersionUID = 3429270322123226071L;
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -54,6 +54,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
+import org.jboss.seam.annotations.Scope;
@NamedQueries({
@NamedQuery(
@@ -72,7 +73,7 @@
@Entity
@Name("image")
@Table(name = "Images")
-@Role(name = "selectedImage", scope = ScopeType.CONVERSATION)
+(a)Scope(ScopeType.CONVERSATION)
public class Image implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -34,11 +34,14 @@
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.Name;
+import org.jboss.seam.annotations.Scope;
@Entity
@Name("metaTag")
@Table(name = "metatags")
+(a)Scope(ScopeType.EVENT)
public class MetaTag implements Serializable {
private static final long serialVersionUID = -9065024051468971330L;
@@ -65,11 +68,6 @@
this.id = id;
}
- public MetaTag(Long id, String tag) {
- this.id = id;
- this.tag = tag;
- }
-
public Long getId() {
return id;
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -30,8 +30,6 @@
@Name("shelf")
@Scope(ScopeType.CONVERSATION)
@Table(name = "shelves")
-//TODO nick - rename table to "shelves"
-//TODO nick - should we store this in conversation?
public class Shelf implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
@@ -129,9 +127,11 @@
throw new IllegalArgumentException("Null child!");
if (album.getShelf() != null){
//TODO nick - use removeChildAlbum()
+ album.getShelf().setUnvisitedImages(new ArrayList<Image>());
album.getShelf().removeChildAlbum(album);
}
album.setShelf(this);
+ this.setUnvisitedImages(new ArrayList<Image>());
albums.add(album);
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -20,6 +20,7 @@
*/
package org.richfaces.realworld.service;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -56,9 +57,10 @@
public void deleteAlbum(Album album){
if(album.getShelf()!=null){
- album.getShelf().removeChildAlbum(album);
- album.getShelf().setUnvisitedImages(null);
+ album.getShelf().setUnvisitedImages(new ArrayList<Image>());
}
+ album.getShelf().removeChildAlbum(album);
+ em.remove(album);
if(flushStrategy.isDatabaseStoreStrategy()){
em.flush();
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -51,6 +51,7 @@
image.getAlbum().setCoveringImage(null);
}
image.getAlbum().removeImage(image);
+ em.remove(image);
if (flushStrategy.isDatabaseStoreStrategy()) {
em.flush();
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java 2009-04-01
10:21:47 UTC (rev 13333)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java 2009-04-01
10:29:45 UTC (rev 13334)
@@ -59,6 +59,7 @@
public void deleteShelf(Shelf shelf){
user.removeShelf(shelf);
+ em.remove(shelf);
if(flushStrategy.isDatabaseStoreStrategy()){
em.flush();
}
Modified: trunk/test-applications/realworld2/ejb/src/main/resources/import.sql
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/resources/import.sql 2009-04-01
10:21:47 UTC (rev 13333)
+++ trunk/test-applications/realworld2/ejb/src/main/resources/import.sql 2009-04-01
10:29:45 UTC (rev 13334)
@@ -72,10 +72,7 @@
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (28,
'1985-01-08', 'Beautiful ^Flower^...great Macro....Excellent !!!',13, 1);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (29,
'1985-01-08', 'whoah ! wonderful',13, 1);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (30,
'1985-01-08', 'fantastic shot !!!!!!',13, 1);
-INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (14, 'thumbs.db',
'amarkhel/0/thumbs.db', 'Animals - thumbs.db image',
'2009-12-18', 0, 'Sony CyberShot DSC-T77', 1024, 1917, 768,
'2009-12-01', true);
-INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(0, 14);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (31,
'1985-01-08', 'fantastic shot !!!!!!',14, 1);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (32,
'1985-01-08', 'Wonderful.',14, 1);
+
INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (15, 'turtle.jpg',
'amarkhel/0/turtle.jpg', 'Animals - turtle.jpg image',
'2009-12-18', 0, 'Canon PowerShot SX110 IS', 1024, 1917, 768,
'2009-12-01', true);
INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(0, 15);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (33,
'1985-01-08', 'I Think this is Art!',15, 1);
@@ -231,10 +228,6 @@
INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (46, '203076.jpg',
'Noname/2/203076.jpg', 'Coasts - 203076.jpg image', '2009-12-18',
2, 'Olympus Stylus mju 1040', 1024, 1917, 768, '2009-12-01', true);
INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(2, 46);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (109,
'1985-01-08', 'that is a beautiful flower with great colours ',46, 3);
-INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (47, 'thumbs.db',
'Noname/2/thumbs.db', 'Coasts - thumbs.db image', '2009-12-18',
2, 'BBK DP810', 1024, 1917, 768, '2009-12-01', true);
-INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(2, 47);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (110,
'1985-01-08', 'love every thing about this picture, really beautiful...
:))',47, 3);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (111,
'1985-01-08', 'Bellísima.!!! saludos.',47, 3);
---------------------------------------------------------------------
-- ALBUM - Flora
@@ -297,11 +290,6 @@
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (136,
'1985-01-08', '++Beautiful',61, 1);
INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (62, '403011.jpg',
'amarkhel/3/403011.jpg', 'Flora - 403011.jpg image',
'2009-12-18', 3, 'Konica Minolta', 1024, 1917, 768, '2009-12-01',
true);
INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(3, 62);
-INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (63, 'thumbs.db',
'amarkhel/3/thumbs.db', 'Flora - thumbs.db image', '2009-12-18',
3, 'Panasonic', 1024, 1917, 768, '2009-12-01', true);
-INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(3, 63);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (137,
'1985-01-08', 'Bellísima.!!! saludos.',63, 1);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (138,
'1985-01-08', 'Stunning capture! :-)',63, 1);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (139,
'1985-01-08', 'Perfecft!',63, 1);
---------------------------------------------------------------------
-- ALBUM - Ices
@@ -397,12 +385,8 @@
INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (83, '400000.jpg',
'Viking/4/400000.jpg', 'Ices - 400000.jpg image', '2009-12-18',
4, 'Canon Digital IXUS 80 IS (PowerShot SD1100 IS)', 1024, 1917, 768,
'2009-12-01', true);
INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(4, 83);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (187,
'1985-01-08', 'nice shot =) ',83, 2);
-INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (84, 'thumbs.db',
'Viking/4/thumbs.db', 'Ices - thumbs.db image', '2009-12-18', 4,
'Pentax Optio E40', 1024, 1917, 768, '2009-12-01', true);
-INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(4, 84);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (188,
'1985-01-08', 'Bellísima.!!! saludos.',84, 2);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (189,
'1985-01-08', 'Amazing shot..',84, 2);
-INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (190,
'1985-01-08', 'I Think this is Art!',84, 2);
+
---------------------------------------------------------------------
-- ALBUM - Sport
---------------------------------------------------------------------
@@ -473,8 +457,6 @@
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (224,
'1985-01-08', 'Wow!! Macro stupenda!!! Complimenti! ',98, 3);
INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (99, 'swimmer.jpg',
'Noname/5/swimmer.jpg', 'Sport - swimmer.jpg image',
'2009-12-18', 5, 'BBK DP810', 1024, 1917, 768, '2009-12-01',
true);
INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(5, 99);
-INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (100, 'thumbs.db',
'Noname/5/thumbs.db', 'Sport - thumbs.db image', '2009-12-18', 5,
'BenQ DC E800', 1024, 1917, 768, '2009-12-01', true);
-INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(5, 100);
---------------------------------------------------------------------
-- ALBUM - Underwater
@@ -567,8 +549,6 @@
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (265,
'1985-01-08', 'that is a beautiful flower with great colours ',121, 1);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (266,
'1985-01-08', '|Wonderful| coloured flower .... *excellent* macro .... -nice-
details!!!',121, 1);
INSERT INTO comments(comment_id, date, message, image_id, user_id) VALUES (267,
'1985-01-08', 'really pretty. it looks like there is a lady in the _center_,
blowing kisses!!',121, 1);
-INSERT INTO images(image_id, name, path, description, created, album_id, cameraModel,
width, size, height, uploaded, allowComments) VALUES (122, 'thumbs.db',
'amarkhel/6/thumbs.db', 'Underwater - thumbs.db image',
'2009-12-18', 6, 'Canon Digital IXUS 80 IS (PowerShot SD1100 IS)', 1024,
1917, 768, '2009-12-01', true);
-INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) VALUES(6, 122);
INSERT INTO metatags(metatag_id, tag) VALUES (7, 'butterfly');
INSERT INTO IMAGES_METATAGS(CI_METATAG_ID, CI_IMAGE_ID) ( select 7, image_id from Images
where name like '067%');