Author: amarkhel
Date: 2009-05-05 12:29:40 -0400 (Tue, 05 May 2009)
New Revision: 14023
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/User.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.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/IAlbumAction.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
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java
Log:
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-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -64,7 +64,7 @@
@JoinColumn(nullable = false)
private Image image;
- @ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY)
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(nullable = true)
private User author;
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-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -66,6 +66,10 @@
query = "select u from User u where u.login = :username and u.passwordHash =
:password"
),
@NamedQuery(
+ name = "user-comments",
+ query = "select c from Comment c where c.author = :author"
+ ),
+ @NamedQuery(
name = "user-exist",
query = "select u from User u where u.login = :login"
),
Modified:
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java
===================================================================
---
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java 2009-05-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -96,4 +96,12 @@
throw new PhotoAlbumException(e.getMessage());
}
}
+
+ /**
+ * Refresh state of given album
+ * @param album - album to Synchronize
+ */
+ public void resetAlbum(Album album) {
+ em.refresh(album);
+ }
}
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-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -170,6 +170,8 @@
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 SEARCH_NO_WHERE_OPTIONS_ERROR = "You must specify where
search execute";
+ public static final String USER_COMMENTS_QUERY = "user-comments";
+ public static final String AUTHOR_PARAMETER = "author";
private Constants(){
}
}
\ No newline at end of file
Modified:
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java
===================================================================
---
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java 2009-05-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -38,5 +38,7 @@
void deleteAlbum(Album album) throws PhotoAlbumException;
void editAlbum(Album album) throws PhotoAlbumException;
+
+ public void resetAlbum(Album album);
}
\ No newline at end of file
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-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -27,6 +27,7 @@
import org.richfaces.photoalbum.domain.Comment;
import org.richfaces.photoalbum.domain.Image;
import org.richfaces.photoalbum.domain.MetaTag;
+import org.richfaces.photoalbum.domain.User;
/**
* Interface for manipulating with image entity
@@ -55,4 +56,8 @@
public boolean isImageWithThisPathExist(Image image);
+ public List<Comment> findAllUserComments(User user);
+
+ public void resetImage(Image imageo);
+
}
\ No newline at end of file
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-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -43,4 +43,6 @@
void editShelf(Shelf shelf) throws PhotoAlbumException;
List<Shelf> getPredefinedShelves();
+
+ void resetShelf(Shelf shelf);
}
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-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -36,6 +36,8 @@
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.
* EJB3 Bean
@@ -157,10 +159,10 @@
*/
public void deleteComment(Comment comment) throws PhotoAlbumException {
try{
+ Image image = comment.getImage();
em.remove(comment);
+ image.removeComment(comment);
em.flush();
-
- em.refresh(comment.getImage());
}
catch(Exception e){
throw new PhotoAlbumException(e.getMessage());
@@ -228,4 +230,22 @@
.setParameter(Constants.ALBUM_PARAMETER, image.getAlbum())
.getResultList().size() != 0;
}
+
+ /**
+ * Retrieve all cooments posted by given user.
+ * @return list of comments
+ */
+ public List<Comment> findAllUserComments(User user) {
+ return em.createNamedQuery(Constants.USER_COMMENTS_QUERY)
+ .setParameter(Constants.AUTHOR_PARAMETER, user)
+ .getResultList();
+ }
+
+ /**
+ * Refresh state of given image
+ * @param image - image to Synchronize
+ */
+ public void resetImage(Image image) {
+ em.refresh(image);
+ }
}
Modified:
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java
===================================================================
---
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java 2009-05-05
16:29:24 UTC (rev 14022)
+++
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java 2009-05-05
16:29:40 UTC (rev 14023)
@@ -106,4 +106,12 @@
public List<Shelf> getPredefinedShelves() {
return em.createNamedQuery(Constants.USER_SHELVES_QUERY).getResultList();
}
+
+ /**
+ * Refresh state of given shelf
+ * @param shelf - shelf to Synchronize
+ */
+ public void resetShelf(Shelf shelf) {
+ em.refresh(shelf);
+ }
}
\ No newline at end of file
Show replies by date