Author: amarkhel
Date: 2009-03-20 13:10:23 -0400 (Fri, 20 Mar 2009)
New Revision: 13066
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/Image.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.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/IImageAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.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/SearchAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java
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-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -36,6 +36,7 @@
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@@ -99,6 +100,9 @@
@Transient
private Long countUnvisitedImages;
+ @OneToOne(cascade=CascadeType.ALL, optional=true)
+ private Image coveringImage;
+
// ********************** Accessor Methods ********************** //
@@ -222,9 +226,13 @@
return -1;
}
- public Image getLastImage(){
+ public Image getCoveringImage(){
+ if(coveringImage != null){
+ return coveringImage;
+ }
if(images != null && images.size() > 0){
- return images.get(images.size() - 1);
+ coveringImage = images.get(0);
+ return images.get(0);
}else{
return null;
}
@@ -270,4 +278,8 @@
countUnvisitedImages--;
}
}
+
+ public void setCoveringImage(Image coveringImage) {
+ this.coveringImage = coveringImage;
+ }
}
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-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -87,6 +87,8 @@
@NotEmpty
@Length(min=3)
private String name;
+ @Transient
+ private Boolean covering;
@Column(length = 1024, nullable = false)
@NotNull
@@ -326,5 +328,13 @@
public void setAllowComments(boolean allowComments) {
this.allowComments = allowComments;
}
+
+ public boolean isCovering() {
+ return this.equals(this.getAlbum().getCoveringImage());
+ }
+
+ public void setCovering(Boolean covering) {
+ this.covering = covering;
+ }
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -31,7 +31,6 @@
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
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-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -28,16 +28,17 @@
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
@Name("albumAction")
@Stateless
+@AutoCreate
public class AlbumAction implements IAlbumAction {
@In(value="entityManager")
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java 2009-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -20,6 +20,8 @@
*/
package org.richfaces.realworld.service;
+import java.util.List;
+
import javax.ejb.Local;
import org.richfaces.realworld.domain.Comment;
@@ -41,4 +43,6 @@
public abstract MetaTag getTagByName(String tag);
+ public abstract List<MetaTag> popularTags();
+
}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java 2009-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -1,12 +1,10 @@
package org.richfaces.realworld.service;
-import java.util.Date;
import java.util.List;
import javax.ejb.Local;
-import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
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-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -20,9 +20,12 @@
*/
package org.richfaces.realworld.service;
+import java.util.List;
+
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.richfaces.realworld.domain.Comment;
@@ -31,6 +34,7 @@
@Name("imageAction")
@Stateless
+@AutoCreate
public class ImageAction implements IImageAction {
@In(value="entityManager")
@@ -58,6 +62,11 @@
image.addMetaTag(t);
}
}*/
+ if(image.isCovering()){
+ if(!image.equals(image.getAlbum().getCoveringImage())){
+ image.getAlbum().setCoveringImage(image);
+ }
+ }
if(isFlushNeeded){
em.flush();
}
@@ -101,4 +110,8 @@
public MetaTag getTagByName(String tag) {
return (MetaTag)em.createQuery("from MetaTag m where m.tag
=:tag").setParameter("tag", tag).getSingleResult();
}
+
+ public List<MetaTag> popularTags() {
+ return (List<MetaTag>)em.createQuery("from MetaTag m order by
count(m.images) desc").setMaxResults(20).getResultList();
+ }
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -6,6 +6,7 @@
import javax.persistence.EntityManager;
import javax.persistence.Query;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
@@ -14,6 +15,7 @@
@Name("searchAction")
@Stateless
+@AutoCreate
@SuppressWarnings("unchecked")
public class SearchAction implements ISearchAction {
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-03-20
17:02:34 UTC (rev 13065)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java 2009-03-20
17:10:23 UTC (rev 13066)
@@ -30,16 +30,17 @@
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
-import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
@Name("shelfAction")
@Stateless
+@AutoCreate
public class ShelfAction implements IShelfAction {
@In(value="entityManager")
Show replies by date