Author: amarkhel
Date: 2009-01-26 07:46:10 -0500 (Mon, 26 Jan 2009)
New Revision: 12419
Added:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Rank.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IAlbumAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IMessageAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
Log:
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,7 +1,22 @@
-/*
- * Album.java
- * Last modified by: $Author$
- * $Revision$ $Date$
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.realworld.domain;
@@ -34,214 +49,220 @@
import org.jboss.seam.annotations.Role;
/**
- * Class for representing Album Entity
- * EJB3 Entity Bean
+ * Class for representing Album Entity EJB3 Entity Bean
*
* @author Andrey Markhel
*/
-@NamedQueries({
- @NamedQuery(
- name = "album-byAlbumNameAndLogin",
- query = "from Album a where a.name=:albumName and
a.owner.login=:login"
- )
-})
-
+@NamedQueries( { @NamedQuery(name = "album-byAlbumNameAndLogin", query =
"from Album a where a.name=:albumName and a.owner.login=:login") })
@Entity
@Name("album")
@Table(name = "albums")
-@Role(name="selectedAlbum", scope = ScopeType.CONVERSATION)
+@Role(name = "selectedAlbum", scope = ScopeType.CONVERSATION)
public class Album implements Serializable {
- private static final long serialVersionUID = -7042878411608396483L;
+ private static final long serialVersionUID = -7042878411608396483L;
- @Id
- @GeneratedValue
- @Column(name = "ALBUM_ID")
- private Long id = null;
+ @Id
+ @GeneratedValue
+ @Column(name = "ALBUM_ID")
+ private Long id = null;
- @Column(length = 255, nullable = false)
- @NotNull
+ @Column(length = 255, nullable = false)
+ @NotNull
@NotEmpty
- @Length(min=3)
- private String name;
+ @Length(min = 3)
+ private String name;
- @Column(length = 1024)
- @NotNull
+ @Column(length = 1024)
+ @NotNull
@NotEmpty
- @Length(min=3)
- private String description;
-
- @ManyToOne
- @JoinColumn(name="ALBUM_USER_ID",
- referencedColumnName="USER_ID")
- private User owner;
+ @Length(min = 3)
+ private String description;
- @NotNull
- private boolean shared;
-
- @Transient
- private String changedName;
-
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "album")
- @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
- private List<Image> images = new ArrayList<Image>();
-
- @ManyToMany
- @JoinTable(
- name = "SHARED_ALBUMS",
- joinColumns = @JoinColumn(name = "ALBUM_ID"),
- inverseJoinColumns = @JoinColumn(name = "USER_ID")
- )
- private List<User> sharedOwners = new ArrayList<User>();
-
- @OneToMany(mappedBy = "parent", cascade = {CascadeType.ALL})
- @org.hibernate.annotations.OrderBy(clause = "NAME asc")
- private List<Album> childAlbums = new ArrayList<Album>();
+ @ManyToOne
+ @JoinColumn(name = "ALBUM_USER_ID", referencedColumnName =
"USER_ID")
+ private User owner;
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "PARENT_ALBUM_ID", nullable = true)
- @org.hibernate.annotations.ForeignKey(name = "FK_ALBUM_PARENT_ID")
- private Album parent;
+ @NotNull
+ private boolean shared;
+
+ @Transient
+ private String changedName;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "album")
+ @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
+ private List<Image> images = new ArrayList<Image>();
+
+ @ManyToMany
+ @JoinTable(name = "SHARED_ALBUMS", joinColumns = @JoinColumn(name =
"ALBUM_ID"), inverseJoinColumns = @JoinColumn(name = "USER_ID"))
+ private List<User> sharedOwners = new ArrayList<User>();
+
+ @OneToMany(mappedBy = "parent", cascade = { CascadeType.ALL })
+ @org.hibernate.annotations.OrderBy(clause = "NAME asc")
+ private List<Album> childAlbums = new ArrayList<Album>();
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "PARENT_ALBUM_ID", nullable = true)
+ @org.hibernate.annotations.ForeignKey(name = "FK_ALBUM_PARENT_ID")
+ private Album parent;
+
/**
* No-arg constructor for JavaBean tools
*/
- public Album() {
- }
+ public Album() {
+ }
// ********************** Accessor Methods ********************** //
- public List<Album> getChildAlbums() { return childAlbums; }
-
- public void addChildAlbum(Album album) {
- if (album == null) throw new IllegalArgumentException("Null child
category!");
- if (album.getParent() != null)
- album.getParent().getChildAlbums().remove(album);
- album.setParent(this);
- childAlbums.add(album);
- }
- public void removeChildAlbum(Album album) {
- if (album == null) throw new IllegalArgumentException("Null child
category!");
- album.setParent(null);
- childAlbums.remove(album);
- }
+ public List<Album> getChildAlbums() {
+ return childAlbums;
+ }
- public Album getParent() { return parent; }
- public void setParent(Album parent) { this.parent = parent; }
+ public void addChildAlbum(Album album) {
+ if (album == null)
+ throw new IllegalArgumentException("Null child category!");
+ if (album.getParent() != null)
+ album.getParent().getChildAlbums().remove(album);
+ album.setParent(this);
+ childAlbums.add(album);
+ }
- public String getAlbumPathFromParents(Album album, List<String> list, String
delimiter) {
- if(album.getParent() == null){
+ public void removeChildAlbum(Album album) {
+ if (album == null)
+ throw new IllegalArgumentException("Null child category!");
+ album.setParent(null);
+ childAlbums.remove(album);
+ }
+
+ public Album getParent() {
+ return parent;
+ }
+
+ public void setParent(Album parent) {
+ this.parent = parent;
+ }
+
+ public String getAlbumPathFromParents(Album album, List<String> list,
+ String delimiter) {
+ if (album.getParent() == null) {
list.add(album.getName() + delimiter);
return "";
- }else{
- album.getParent().getAlbumPathFromParents(album.getParent(), list, delimiter);
+ } else {
+ album.getParent().getAlbumPathFromParents(album.getParent(), list,
+ delimiter);
}
- list.add(this.getName()+delimiter);
- String path = "";
- for(int i =0; i < list.size(); i++){
- path += list.get(i);
+ list.add(this.getName() + delimiter);
+ String path = "";
+ for (int i = 0; i < list.size(); i++) {
+ path += list.get(i);
+ }
+ return path;
}
- return path;
-}
- public List<Album> getArrayOfParents(){
+
+ public List<Album> getArrayOfParents() {
return getArrayOfParents(new ArrayList<Album>());
}
-
- public List<Album> getArrayOfParents(List<Album> albums){
- if(this.getParent() == null){
+
+ public List<Album> getArrayOfParents(List<Album> albums) {
+ if (this.getParent() == null) {
Collections.reverse(albums);
return albums;
- }else{
+ } else {
albums.add(this.getParent());
this.getParent().getArrayOfParents(albums);
}
return albums;
}
-
- /**
+
+ /**
* Getter for property id
*
* @return id of album
*/
- public Long getId() {
- return id;
- }
+ public Long getId() {
+ return id;
+ }
- /**
+ /**
* Getter for property name
*
* @return name of album
*/
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
/**
* Setter for property name
*
- * @param name - name of album
+ * @param name -
+ * name of album
*/
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
/**
* Getter for property description
*
* @return description of album
*/
- public String getDescription() {
- return description;
- }
+ public String getDescription() {
+ return description;
+ }
/**
* Setter for property description
*
- * @param description - description of album
+ * @param description -
+ * description of album
*/
- public void setDescription(String description) {
- this.description = description;
- }
-
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
// ********************** Business Methods ********************** //
/**
* This method add image to collection of images of current album
*
- * @param image - image to add
+ * @param image -
+ * image to add
*/
- public void addImage(Image image) {
- if (image == null) {
- throw new IllegalArgumentException("Null image!");
- }
- if (image.getAlbum() != null && !this.equals(image.getAlbum())) {
- image.getAlbum().getImages().remove(image);
- }
- image.setAlbum(this);
- images.add(image);
- }
+ public void addImage(Image image) {
+ if (image == null) {
+ throw new IllegalArgumentException("Null image!");
+ }
+ if (image.getAlbum() != null && !this.equals(image.getAlbum())) {
+ image.getAlbum().getImages().remove(image);
+ }
+ image.setAlbum(this);
+ images.add(image);
+ }
/**
* This method remove image from collection of images of album
*
- * @param image - image to remove
+ * @param image -
+ * image to remove
*/
- public void removeImage(Image image) {
- if (image == null) {
- throw new IllegalArgumentException("Null image");
- }
- image.setAlbum(null);
- images.remove(image);
- }
+ public void removeImage(Image image) {
+ if (image == null) {
+ throw new IllegalArgumentException("Null image");
+ }
+ image.setAlbum(null);
+ images.remove(image);
+ }
/**
* This method return count of images of current album
*
* @return count of images of this album
*/
- public int getCountImages() {
- return this.getImages()!= null ? this.getImages().size() : 0;
+ public int getCountImages() {
+ return this.getImages() != null ? this.getImages().size() : 0;
- }
+ }
public boolean isShared() {
return shared;
@@ -264,7 +285,7 @@
}
public String getChangedName() {
- if(changedName != null){
+ if (changedName != null) {
return changedName;
}
return this.getName();
@@ -283,8 +304,8 @@
}
public int getIndex(Image image) {
- for(int i =0; i < this.images.size(); i++){
- if(this.images.get(i).equals(image)){
+ for (int i = 0; i < this.images.size(); i++) {
+ if (this.images.get(i).equals(image)) {
return i;
}
}
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.domain;
import java.io.Serializable;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.domain;
import java.io.Serializable;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
/*
* Image.java
* Last modified by: $Author$
@@ -20,6 +40,8 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@@ -34,6 +56,17 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
+@NamedQueries({
+ @NamedQuery(
+ name = "image-tags",
+ query = "select distinct t.tag from Image i join i.tags t"
+ ),
+ @NamedQuery(
+ name = "image-camera",
+ query = "select distinct i.cameraModel from Image i"
+ )
+ }
+)
/**
* Class for representing Image Entity
* EJB3 Entity Bean
@@ -355,13 +388,4 @@
}
return false;
}
-
- public boolean validateTags() {
- for(MetaTag t : this.getTags()){
- if(t.getTag().length()<3){
- return false;
- }
- }
- return true;
- }
}
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.domain;
import java.io.Serializable;
@@ -18,9 +38,7 @@
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.Role;
@Entity
@Name("message")
@Table(name = "messages")
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/MetaTag.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.domain;
import java.io.Serializable;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Rank.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Rank.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Rank.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.domain;
import java.io.Serializable;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.domain;
import java.io.Serializable;
@@ -60,6 +80,16 @@
name = "user-outcomeMessages",
query = "from Message m WHERE m.author.login=:login"
)
+ ,
+ @NamedQuery(
+ name = "user-historyMessages",
+ query = "from Message m where m.author =:author and m.owner=:owner"
+ )
+ ,
+ @NamedQuery(
+ name = "user-user",
+ query = "from User u where u.login = :login"
+ )
})
@Entity
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import javax.ejb.Stateless;
@@ -17,8 +37,6 @@
@In(value="entityManager")
EntityManager em;
- private static final String SLASH = "/";
-
@In @Out
private User user;
@@ -55,8 +73,8 @@
}
for (Album a : album.getChildAlbums()) {
- String replace2 = replace + SLASH + a.getName();
- String forReplace2 = forReplace + SLASH + a.getName();
+ String replace2 = replace + Constants.SLASH + a.getName();
+ String forReplace2 = forReplace + Constants.SLASH + a.getName();
renameAllImagesFromAlbumAndChilds(a, replace2, forReplace2);
}
em.flush();
Added:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
(rev 0)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -0,0 +1,133 @@
+package org.richfaces.realworld.service;
+
+import org.jboss.seam.annotations.In;
+import org.richfaces.realworld.service.IUserAction;
+
+public class Constants {
+
+ public static final String ERROR_ID = "mainform:error";
+ public static final String CLEAR_ERROR_EVENT = "clearErrorEvent";
+ public static final String ADD_ERROR_EVENT = "addErrorEvent";
+ public static final String ALBUM_WITH_THIS_NAME_ALREADY_PRESENT = "Album with this
name already present!";
+ public static final String UPLOAD_ROOT = "uploadRoot";
+ public static final String FILE_SEPARATOR = "file.separator";
+ public static final String SLASH = "/";
+ public static final String DOT = ".";
+ public static final String JPG = "JPG";
+ public static final int MULTY_MODE_FILE_QUANTITY = 100;
+ public static final int SINGLE_MODE_FILE_QUANTITY = 1;
+ public static final String MULTY = "multy";
+ public static final String SINGLE = "single";
+ public static final String FILE_PROCESSING_ERROR = "Error processing occured during
upload";
+ public static final String ADD_IMAGE_EVENT = "addImage";
+ public static final String FILE_SAVE_ERROR = "Error occured during saving image to
disk";
+ public static final int KB = 1024;
+ public static final String FILE_UPLOAD_CLEAR_EVENT = "fileUploadClear";
+ public static final String SHOW_FILE_UPLOAD_EVENT = "showFileUpload";
+ public static final String CHANGE_MODE_FILE_UPLOAD_EVENT = "changeMode";
+ public static final String JPEG = "jpeg";
+ public static final String INVALID_LOGIN_OR_PASSWORD = "Invalid login or
password";
+ public static final String MAIN_OUTCOME = "main";
+ public static final String LOGIN_SUCCESS = "You are successfully
registered.";
+ public static final String REGISTER_LOGIN_NAME_ID = "register:loginName";
+ public static final String REGISTER_CONFIRM_PASSWORD_ID =
"register:confirmPassword";
+ public static final String INDEX_OUTCOME = "index";
+ public static final String ADMIN_ROLE = "admin";
+ public static final String GUEST_ROLE = "guest";
+ public static final String UPDATE_MAIN_AREA_EVENT = "updateMainArea";
+ public static final String WRONG_DND = "That album isn't yours, so you
can't change it's location";
+ public static final String TREE_ID = "tree";
+ public static final String CLEAR_EDITOR_EVENT = "clearEditor";
+ public static final String RE = "Re:";
+ public static final String FRIEND_ERROR_MESSAGE = "This user won't be your
friend!";
+ public static final String SEND_MESSAGE_EVENT = "sendMessage";
+ public static final String HTTPS = "https://";
+ public static final String HTTP = "http://";
+ public static final String HTTP_1_0 = "HTTP/1.0";
+ public static final String HTTP_1_1 = "HTTP/1.1";
+ public static final String PICTURE_FOLDER_PATH = "/picture/";
+ public static final String MINI_FORMAT = "_mini";
+ public static final String MEDIUM_FORMAT = "_medium";
+ public static String URL = "URL";
+ public static String HTML = "HTML";
+ public static String FORUM = "Forum";
+ public static String HTML_PATTERN = "<a href='%s'><img
src='%s' border='0'></a>";
+ public static String FORUM_PATTERN = "[URL=%s][IMG]%s[/IMG][/URL]";
+ public static final String ERROR_PAGE = "/error.seam";
+ public static final String IMAGE_JPG = "image/jpg";
+ public static final String PATH_PARAMETER = "path";
+ public static final String FILE_MANAGER = "fileManager";
+ public static final String ENTITY_MANAGER = "entityManager";
+ public static final String USER_ID = "userId";
+ public static final int INITIAL_DELAY = 10000;
+ public static final int DELAY = 1000;
+ public static final String ALBUM_NODE_TYPE = "album";
+ public static final String USER_MANAGER = "userManager";
+ public static final String TREE_FRIEND_ALBUM_TYPE = "treeFriendAlbum";
+ public static final String TREE_FRIEND_ROOT_NODE_TYPE = "treeRootFriend";
+ public static final String USER = "user";
+ public static final String TREE_FRIEND_TYPE = "treeFriendsAlbums";
+ public static final String TREE_MY_ALBUMS_TYPE = "treeMyAlbums";
+ public static final String TREE_MY_ALBUMS_ITEM = "treeMyAlbumsItem";
+ public static final String TREE_ROOT_NODE_TYPE = "treeRoot";
+ public static final String DATASCROLLER_ID = "mainform:imageScroller";
+ public static final String HAVENT_ACCESS = "You have no rights to view this
album";
+ public static final String FIRST = "first";
+ public static final String NEXT = "next";
+ public static final String LAST = "last";
+ public static final String PREVIOUS = "previous";
+ public static final String OWNER_PARAM = "owner";
+ public static final String AUTHOR_PARAM = "author";
+ public static final String USER_HISTORY_MESSAGES_QUERY =
"user-historyMessages";
+ public static final String USER_FRIEND_EXIST_QUERY = "user-friendExist";
+ public static final String USER_AVAILABLE_USERS_QUERY =
"user-availableUsers";
+ public static final String USER_EXIST_QUERY = "user-exist";
+ public static final String USER_LOGIN_QUERY = "user-login";
+ public static final String USER_ROOT_ALBUMS_QUERY = "user-login";
+ public static final String FRIEND_PARAMETER = "friend";
+ public static final String PERCENT = "%";
+ public static final String LOGIN_PARAMETER = "login";
+ public static final String PASSWORD_PARAMETER = "password";
+ public static final String USERNAME_PARAMETER = "username";
+ public static final String USER_OUTCOMING_MESSAGES = "user-outcomeMessages";
+ public static final String MINUS = "-";
+ public static final String PLUS = "+";
+ public static final String INVALID_SYNTAX = "Invalid syntax";
+ public static final char MINUS_SIGN = '-';
+ public static final char PLUS_SIGN = '+';
+ public static final String DATE_NAMED_PARAMETER = ":date";
+ public static final String UPLOAD_NAMED_PARAMETER = ":upload";
+ public static final String WIDTH_NAMED_PARAMETER = ":width";
+ public static final String HEIGHT_NAMED_PARAMETER = ":height";
+ public static final String SIZE_NAMED_PARAMETER = ":size";
+ public static final String CAMERA_NAMED_PARAMETER = ":camera";
+ public static final String CHOICE_NAMED_PARAMETER = ":choice";
+ public static final String SPINNER_VALUE_NAMED_PARAMETER = ":spinnerValue";
+ public static final String DATE_PARAMETER = "date";
+ public static final String UPLOAD_PARAMETER = "upload";
+ public static final String WIDTH_PARAMETER = "width";
+ public static final String HEIGHT_PARAMETER = "height";
+ public static final String SIZE_PARAMETER = "size";
+ public static final String CAMERA_PARAMETER = "camera";
+ public static final String CHOICE_PARAMETER = "choice";
+ public static final String SPINNER_VALUE_PARAMETER = "spinnerValue";
+ public static final String METATAG_PARAMETER = "metatag";
+ public static final String SEARCH_UNPOPULAR_QUERY_END = " order by r.total/r.hits
asc";
+ public static final String SEARCH_POPULAR_QUERY_END = " order by r.total/r.hits
desc";
+ public static final String SEARCH_RELEVANT_QUERY_BEGIN = "select i from Image i
join i.rank r where i.album.shared=true";
+ public static final String SEARCH_QUERY_END = " order by i.rank.total/i.rank.hits
desc";
+ public static final String SEARCH_QUERY_BEGIN = "select i from MetaTag t join
t.parent i where upper(t.tag) like:metatag and i.album.shared=true";
+ public static final String SEARCH_SENSITIVE_QUERY_BEGIN = "select i from MetaTag t
join t.parent i where t.tag like:metatag and i.album.shared=true";
+ public static final String STRICT_PARAMETER = "STRICT";
+ public static final String CASE_SENSITIVE_PARAMETER = "CASE_SENSITIVE";
+ public static final String IMAGE_TAGS_QUERY = "image-tags";
+ public static final String IMAGE_CAMERA_QUERY = "image-camera";
+ public static final String USER_USER_QUERY = "user-user";
+ public static final String USER_COUNT_MESSAGES_QUERY = "user-countMessages";
+ public static final String ALBUM_BY_ALBUM_NAME_AND_LOGIN_QUERY =
"album-byAlbumNameAndLogin";
+ public static final String ALBUM_NAME_PARAMETER = "albumName";
+ private Constants(){
+
+ }
+
+}
Property changes on:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IAlbumAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IAlbumAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IAlbumAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import javax.ejb.Local;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import javax.ejb.Local;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IMessageAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IMessageAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IMessageAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import javax.ejb.Local;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import java.util.List;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import java.util.List;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import javax.ejb.Stateless;
@@ -12,10 +32,7 @@
@Name("imageAction")
@Stateless
public class ImageAction implements IImageAction {
-
- private static final String ALBUM_BY_ALBUM_NAME_AND_LOGIN_QUERY =
"album-byAlbumNameAndLogin";
- private static final String LOGIN_PARAMETER = "login";
- private static final String ALBUM_NAME_PARAMETER = "albumName";
+
@In(value="entityManager")
EntityManager em;
@@ -30,7 +47,7 @@
String login = albumPrevious.getOwner().getLogin();
String albumName = image.getAlbumName();
albumPrevious.removeImage(image);
- Album album =
(Album)em.createNamedQuery(ALBUM_BY_ALBUM_NAME_AND_LOGIN_QUERY).setParameter(ALBUM_NAME_PARAMETER,
albumName).setParameter(LOGIN_PARAMETER, login).getSingleResult();
+ Album album =
(Album)em.createNamedQuery(Constants.ALBUM_BY_ALBUM_NAME_AND_LOGIN_QUERY).setParameter(Constants.ALBUM_NAME_PARAMETER,
albumName).setParameter(Constants.LOGIN_PARAMETER, login).getSingleResult();
album.addImage(image);
}
image.getTags().clear();
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import javax.ejb.Stateless;
@@ -13,18 +33,14 @@
@Stateless
public class MessageAction implements IMessageAction {
- private static final String LOGIN_PARAMETER = "login";
-
- private static final String USER_COUNT_MESSAGES_QUERY = "user-countMessages";
-
@In(value="entityManager")
EntityManager em;
- @Observer("sendMessage")
+ @Observer(Constants.SEND_MESSAGE_EVENT)
public void sendMessage(Message message){
if(message.getOwnerLogin() != null){
- User user = (User)em.createQuery("from User u where u.login = :login")
- .setParameter(LOGIN_PARAMETER, message.getOwnerLogin())
+ User user = (User)em.createNamedQuery(Constants.USER_USER_QUERY)
+ .setParameter(Constants.LOGIN_PARAMETER, message.getOwnerLogin())
.getSingleResult();
message.setOwner(user);
message.setOwnerLogin(null);
@@ -37,8 +53,8 @@
}
public long countNotReadedMessages(User user){
- Long result = (Long)em.createNamedQuery(USER_COUNT_MESSAGES_QUERY)
- .setParameter(LOGIN_PARAMETER, user.getLogin())
+ Long result = (Long)em.createNamedQuery(Constants.USER_COUNT_MESSAGES_QUERY)
+ .setParameter(Constants.LOGIN_PARAMETER, user.getLogin())
.getSingleResult();
return result;
}
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import java.util.Comparator;
@@ -4,11 +24,9 @@
import org.richfaces.realworld.domain.Message;
-public class MessageComparator implements Comparator {
+public class MessageComparator implements Comparator<Message> {
- public int compare(Object obj1, Object obj2) {
- Message mes1 = (Message) obj1;
- Message mes2 = (Message) obj2;
+ public int compare(Message mes1, Message mes2) {
return mes1.getDate().after(mes2.getDate())?-1:1;
}
}
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
import java.io.Serializable;
@@ -13,43 +33,18 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.MetaTag;
@Name("searchService")
@Stateless
public class SearchService implements ISearchService, Serializable
- {
+ {
- private static final String PERCENT = "%";
- public static final String DATE_NAMED_PARAMETER = ":date";
- public static final String UPLOAD_NAMED_PARAMETER = ":upload";
- public static final String WIDTH_NAMED_PARAMETER = ":width";
- public static final String HEIGHT_NAMED_PARAMETER = ":height";
- public static final String SIZE_NAMED_PARAMETER = ":size";
- public static final String CAMERA_NAMED_PARAMETER = ":camera";
- public static final String CHOICE_NAMED_PARAMETER = ":choice";
- public static final String SPINNER_VALUE_NAMED_PARAMETER = ":spinnerValue";
- private static final String DATE_PARAMETER = "date";
- private static final String UPLOAD_PARAMETER = "upload";
- private static final String WIDTH_PARAMETER = "width";
- private static final String HEIGHT_PARAMETER = "height";
- private static final String SIZE_PARAMETER = "size";
- private static final String CAMERA_PARAMETER = "camera";
- private static final String CHOICE_PARAMETER = "choice";
- private static final String SPINNER_VALUE_PARAMETER = "spinnerValue";
- private static final String METATAG_PARAMETER = "metatag";
- private static final String SEARCH_UNPOPULAR_QUERY_END = " order by r.total/r.hits
asc";
- private static final String SEARCH_POPULAR_QUERY_END = " order by r.total/r.hits
desc";
- private static final String SEARCH_RELEVANT_QUERY_BEGIN = "select i from Image i
join i.rank r where i.album.shared=true";
- private static final String SEARCH_QUERY_END = " order by i.rank.total/i.rank.hits
desc";
- private static final String SEARCH_QUERY_BEGIN = "select i from MetaTag t join
t.parent i where upper(t.tag) like:metatag and i.album.shared=true";
- private static final String SEARCH_SENSITIVE_QUERY_BEGIN = "select i from MetaTag t
join t.parent i where t.tag like:metatag and i.album.shared=true";
private static final long serialVersionUID = -2750591521413940277L;
- public static final String STRICT_PARAMETER = "STRICT";
- public static final String CASE_SENSITIVE_PARAMETER = "CASE_SENSITIVE";
+
@In(value="entityManager")
EntityManager em;
+ @SuppressWarnings("unchecked")
public List<Image> searchImages(String searchPattern, String additionalParams,
Map<String, Object> paramMap){
List<String> additions = new ArrayList<String>();
List<String> removals = new ArrayList<String>();
@@ -57,12 +52,12 @@
return null;
}
String fullQuery = null;
- if(paramMap != null && paramMap.get(CASE_SENSITIVE_PARAMETER) != null){
- boolean sensitive = (Boolean)paramMap.get(CASE_SENSITIVE_PARAMETER);
+ if(paramMap != null && paramMap.get(Constants.CASE_SENSITIVE_PARAMETER) !=
null){
+ boolean sensitive = (Boolean)paramMap.get(Constants.CASE_SENSITIVE_PARAMETER);
if(sensitive){
- fullQuery = SEARCH_SENSITIVE_QUERY_BEGIN + additionalParams + SEARCH_QUERY_END;
+ fullQuery = Constants.SEARCH_SENSITIVE_QUERY_BEGIN + additionalParams +
Constants.SEARCH_QUERY_END;
}else{
- fullQuery = SEARCH_QUERY_BEGIN + additionalParams + SEARCH_QUERY_END;
+ fullQuery = Constants.SEARCH_QUERY_BEGIN + additionalParams +
Constants.SEARCH_QUERY_END;
}
}
Query prepared = prepareQuery(fullQuery, additions.get(0), additionalParams,
paramMap);
@@ -96,14 +91,16 @@
return tempResult;
}
+ @SuppressWarnings("unchecked")
public List<Image> popularImages(String additionalParams, Map<String,
Object> paramMap){
- String fullQuery = SEARCH_RELEVANT_QUERY_BEGIN + additionalParams +
SEARCH_POPULAR_QUERY_END;
+ String fullQuery = Constants.SEARCH_RELEVANT_QUERY_BEGIN + additionalParams +
Constants.SEARCH_POPULAR_QUERY_END;
Query prepared = prepareQuery(fullQuery, null, additionalParams, paramMap);
return prepared.getResultList();
}
+ @SuppressWarnings("unchecked")
public List<Image> worstImages(String additionalParams, Map<String, Object>
paramMap){
- String fullQuery = SEARCH_RELEVANT_QUERY_BEGIN + additionalParams +
SEARCH_UNPOPULAR_QUERY_END;
+ String fullQuery = Constants.SEARCH_RELEVANT_QUERY_BEGIN + additionalParams +
Constants.SEARCH_UNPOPULAR_QUERY_END;
Query prepared = prepareQuery(fullQuery, null, additionalParams, paramMap);
return prepared.getResultList();
}
@@ -112,66 +109,68 @@
Map<String, Object> paramMap) {
Query prepared = em.createQuery(fullQuery);
if(searchPattern != null){
- if(paramMap != null && paramMap.get(STRICT_PARAMETER) != null){
- String strict = paramMap.get(STRICT_PARAMETER).toString();
+ if(paramMap != null && paramMap.get(Constants.STRICT_PARAMETER) != null){
+ String strict = paramMap.get(Constants.STRICT_PARAMETER).toString();
if(strict.equals("STRICT")){
- prepared.setParameter(METATAG_PARAMETER, searchPattern.toUpperCase());
+ prepared.setParameter(Constants.METATAG_PARAMETER, searchPattern.toUpperCase());
}else if(strict.equals("START")){
- prepared.setParameter(METATAG_PARAMETER, searchPattern.toUpperCase()+PERCENT);
+ prepared.setParameter(Constants.METATAG_PARAMETER,
searchPattern.toUpperCase()+Constants.PERCENT);
}else if(strict.equals("END")){
- prepared.setParameter(METATAG_PARAMETER, PERCENT + searchPattern.toUpperCase());
+ prepared.setParameter(Constants.METATAG_PARAMETER, Constants.PERCENT +
searchPattern.toUpperCase());
}else if(strict.equals("INCLUDE")){
- prepared.setParameter(METATAG_PARAMETER, PERCENT +
searchPattern.toUpperCase()+PERCENT);
+ prepared.setParameter(Constants.METATAG_PARAMETER, Constants.PERCENT +
searchPattern.toUpperCase()+Constants.PERCENT);
}
}else{
- prepared.setParameter(METATAG_PARAMETER, searchPattern.toUpperCase()+PERCENT);
+ prepared.setParameter(Constants.METATAG_PARAMETER,
searchPattern.toUpperCase()+Constants.PERCENT);
}
}
- if(paramMap != null && paramMap.get(SPINNER_VALUE_NAMED_PARAMETER) != null){
- prepared.setParameter(SPINNER_VALUE_PARAMETER,
paramMap.get(SPINNER_VALUE_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.SPINNER_VALUE_NAMED_PARAMETER) !=
null){
+ prepared.setParameter(Constants.SPINNER_VALUE_PARAMETER,
paramMap.get(Constants.SPINNER_VALUE_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(CHOICE_NAMED_PARAMETER) != null){
- prepared.setParameter(CHOICE_PARAMETER, paramMap.get(CHOICE_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.CHOICE_NAMED_PARAMETER) !=
null){
+ prepared.setParameter(Constants.CHOICE_PARAMETER,
paramMap.get(Constants.CHOICE_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(DATE_NAMED_PARAMETER) != null){
- prepared.setParameter(DATE_PARAMETER, paramMap.get(DATE_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.DATE_NAMED_PARAMETER) != null){
+ prepared.setParameter(Constants.DATE_PARAMETER,
paramMap.get(Constants.DATE_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(UPLOAD_NAMED_PARAMETER) != null){
- prepared.setParameter(UPLOAD_PARAMETER, paramMap.get(UPLOAD_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.UPLOAD_NAMED_PARAMETER) !=
null){
+ prepared.setParameter(Constants.UPLOAD_PARAMETER,
paramMap.get(Constants.UPLOAD_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(WIDTH_NAMED_PARAMETER) != null){
- prepared.setParameter(WIDTH_PARAMETER, paramMap.get(WIDTH_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.WIDTH_NAMED_PARAMETER) != null){
+ prepared.setParameter(Constants.WIDTH_PARAMETER,
paramMap.get(Constants.WIDTH_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(HEIGHT_NAMED_PARAMETER) != null){
- prepared.setParameter(HEIGHT_PARAMETER, paramMap.get(HEIGHT_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.HEIGHT_NAMED_PARAMETER) !=
null){
+ prepared.setParameter(Constants.HEIGHT_PARAMETER,
paramMap.get(Constants.HEIGHT_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(SIZE_NAMED_PARAMETER) != null){
- prepared.setParameter(SIZE_PARAMETER, paramMap.get(SIZE_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.SIZE_NAMED_PARAMETER) != null){
+ prepared.setParameter(Constants.SIZE_PARAMETER,
paramMap.get(Constants.SIZE_NAMED_PARAMETER));
}
- if(paramMap != null && paramMap.get(CAMERA_NAMED_PARAMETER) != null){
- prepared.setParameter(CAMERA_PARAMETER, paramMap.get(CAMERA_NAMED_PARAMETER));
+ if(paramMap != null && paramMap.get(Constants.CAMERA_NAMED_PARAMETER) !=
null){
+ prepared.setParameter(Constants.CAMERA_PARAMETER,
paramMap.get(Constants.CAMERA_NAMED_PARAMETER));
}
prepared.setMaxResults(20);
return prepared;
}
+ @SuppressWarnings("unchecked")
public List<String> getAllCameras() {
- Query query = em.createQuery("select distinct i.cameraModel from Image i");
+ Query query = em.createNamedQuery(Constants.IMAGE_CAMERA_QUERY);
return (List<String>)query.getResultList();
}
+ @SuppressWarnings("unchecked")
public List<String> getAllMetatags() {
- Query query = em.createQuery("select distinct t.tag from Image i join i.tags
t");
+ Query query = em.createNamedQuery(Constants.IMAGE_TAGS_QUERY);
return (List<String>)query.getResultList();
}
private boolean parse(String str, List<String> adds, List<String> removes){
str = str.trim();
- if(str.startsWith("+") || str.startsWith("-") ||
str.endsWith("+") || str.endsWith("-") || str.length() == 0){
- Events.instance().raiseEvent("addErrorEvent", new Exception("Invalid
syntax"));
+ if(str.startsWith(Constants.PLUS) || str.startsWith(Constants.MINUS) ||
str.endsWith(Constants.PLUS) || str.endsWith(Constants.MINUS) || str.length() == 0){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(Constants.INVALID_SYNTAX));
return false;
}
- if(str.lastIndexOf('+')==-1 && str.lastIndexOf('-')==-1){
+ if(str.lastIndexOf(Constants.PLUS_SIGN)==-1 &&
str.lastIndexOf(Constants.MINUS_SIGN)==-1){
adds.add(str);
return true;
}
@@ -181,7 +180,7 @@
boolean signedPreviousChar = false;
for(int i =0; i< str.length(); i++){
char c = str.charAt(i);
- if(c == '+' ){
+ if(c == Constants.PLUS_SIGN ){
if(signedPreviousChar == false){
curIndex = i;
@@ -198,11 +197,11 @@
signedPreviousChar=true;
prevIndex =i;
}else {
- Events.instance().raiseEvent("addErrorEvent", new Exception("Invalid
syntax"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(Constants.INVALID_SYNTAX));
return false;
}
- }else if(c == '-'){
+ }else if(c == Constants.MINUS_SIGN){
if(signedPreviousChar == false){
curIndex = i;
signedPreviousChar=true;
@@ -219,7 +218,7 @@
prevIndex =i;
}else {
- Events.instance().raiseEvent("addErrorEvent", new Exception("Invalid
syntax"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(Constants.INVALID_SYNTAX));
return false;
}
}else{
@@ -227,9 +226,9 @@
}
}
char c2 = str.charAt(prevIndex);
- if(c2 == '+'){
+ if(c2 == Constants.PLUS_SIGN){
adds.add(str.substring(prevIndex+1));
- }else if(c2 == '-'){
+ }else if(c2 == Constants.MINUS_SIGN){
removes.add(str.substring(prevIndex+1));
}
return true;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2009-01-26
12:44:43 UTC (rev 12418)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2009-01-26
12:46:10 UTC (rev 12419)
@@ -40,27 +40,7 @@
@Stateless
@AutoCreate
public class UserAction implements IUserAction {
-
- private static final String USER_FRIEND_EXIST_QUERY = "user-friendExist";
- private static final String USER_AVAILABLE_USERS_QUERY =
"user-availableUsers";
-
- private static final String USER_EXIST_QUERY = "user-exist";
-
- private static final String USER_LOGIN_QUERY = "user-login";
-
- private static final String FRIEND_PARAMETER = "friend";
-
- private static final String PERCENT = "%";
-
- private static final String LOGIN_PARAMETER = "login";
-
- private static final String PASSWORD_PARAMETER = "password";
-
- private static final String USERNAME_PARAMETER = "username";
-
- private static final String USER_OUTCOMING_MESSAGES = "user-outcomeMessages";
-
@In(value="entityManager")
EntityManager em;
@@ -68,9 +48,9 @@
private User user;
public User login(String username, String password) {
- return user = (User)em.createNamedQuery(USER_LOGIN_QUERY)
- .setParameter(USERNAME_PARAMETER, username)
- .setParameter(PASSWORD_PARAMETER, password)
+ return user = (User)em.createNamedQuery(Constants.USER_LOGIN_QUERY)
+ .setParameter(Constants.USERNAME_PARAMETER, username)
+ .setParameter(Constants.PASSWORD_PARAMETER, password)
.getSingleResult();
}
@@ -84,8 +64,9 @@
this.user = user;
}
+ @SuppressWarnings("unchecked")
public List<Album> getRootAlbums(User user) {
- List<Album> albums = em.createNamedQuery("user-rootAlbums")
+ List<Album> albums = em.createNamedQuery(Constants.USER_ROOT_ALBUMS_QUERY)
.setParameter("login", user.getLogin())
.getResultList();
return albums;
@@ -97,29 +78,29 @@
this.user = user;
}
+ @SuppressWarnings("unchecked")
public List<Message> getOutgoingMessages(){
- List<Message> messages = em.createNamedQuery(USER_OUTCOMING_MESSAGES)
+ List<Message> messages = em.createNamedQuery(Constants.USER_OUTCOMING_MESSAGES)
.setParameter("login", user.getLogin())
.getResultList();
return messages;
}
public boolean isUserExist(String login) {
- return em.createNamedQuery(USER_EXIST_QUERY)
- .setParameter(LOGIN_PARAMETER, login)
+ return em.createNamedQuery(Constants.USER_EXIST_QUERY)
+ .setParameter(Constants.LOGIN_PARAMETER, login)
.getResultList().size() != 0;
}
+ @SuppressWarnings("unchecked")
public List<String> getUsers(String suggest) {
- List<String> users = em.createNamedQuery(USER_AVAILABLE_USERS_QUERY)
- .setParameter(LOGIN_PARAMETER, suggest + PERCENT)
+ List<String> users = em.createNamedQuery(Constants.USER_AVAILABLE_USERS_QUERY)
+ .setParameter(Constants.LOGIN_PARAMETER, suggest + Constants.PERCENT)
.setMaxResults(10)
.getResultList();
return users;
}
-
-
public void removeFromFriends(User owner, User removed) {
owner.removeFriend(removed);
removed.removeFriend(owner);
@@ -127,9 +108,9 @@
}
public boolean friendExist(User user, User friend) {
- Long result = (Long)em.createNamedQuery(USER_FRIEND_EXIST_QUERY)
- .setParameter(LOGIN_PARAMETER, user.getLogin())
- .setParameter(FRIEND_PARAMETER, friend.getLogin())
+ Long result = (Long)em.createNamedQuery(Constants.USER_FRIEND_EXIST_QUERY)
+ .setParameter(Constants.LOGIN_PARAMETER, user.getLogin())
+ .setParameter(Constants.FRIEND_PARAMETER, friend.getLogin())
.getSingleResult();
return result > 0;
}
@@ -165,12 +146,14 @@
return userMessages;
}
+ @SuppressWarnings("unchecked")
private List<Message> getUserSecondMessages(User historyUser) {
- return em.createQuery("from Message m where m.author =:author and
m.owner=:owner").setParameter("author",
historyUser).setParameter("owner", user).getResultList();
+ return
em.createNamedQuery(Constants.USER_HISTORY_MESSAGES_QUERY).setParameter(Constants.AUTHOR_PARAM,
historyUser).setParameter(Constants.OWNER_PARAM, user).getResultList();
}
+ @SuppressWarnings("unchecked")
private List<Message> getUserMessages(User historyUser) {
- return em.createQuery("from Message m where m.author =:author and
m.owner=:owner").setParameter("author",
user).setParameter("owner", historyUser).getResultList();
+ return
em.createNamedQuery(Constants.USER_HISTORY_MESSAGES_QUERY).setParameter(Constants.AUTHOR_PARAM,
user).setParameter(Constants.OWNER_PARAM, historyUser).getResultList();
}
public void addFavoriteImage(Image image) {