[richfaces-svn-commits] JBoss Rich Faces SVN: r12386 - in trunk/test-applications/realworld/ejb/src/main: java/org/richfaces/realworld/service and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Jan 23 08:23:32 EST 2009


Author: amarkhel
Date: 2009-01-23 08:23:32 -0500 (Fri, 23 Jan 2009)
New Revision: 12386

Added:
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
Removed:
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Gallery.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/GalleryImage.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/GalleryAction.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IGalleryAction.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/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/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/IMessageAction.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/MessageAction.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
   trunk/test-applications/realworld/ejb/src/main/resources/import.sql
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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -7,11 +7,13 @@
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
@@ -92,6 +94,14 @@
     )
     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
 	 */
@@ -100,6 +110,53 @@
 
 	// ********************** 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 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);
+		}
+	list.add(this.getName()+delimiter);
+	String path = "";
+	for(int i =0; i < list.size(); i++){
+		path += list.get(i);
+	}
+	return path;
+}
+	public List<Album> getArrayOfParents(){
+		return getArrayOfParents(new ArrayList<Album>());
+	}
+	
+	public List<Album> getArrayOfParents(List<Album> albums){
+		if(this.getParent() == null){
+			Collections.reverse(albums);
+			return albums;
+		}else{
+			albums.add(this.getParent());
+			this.getParent().getArrayOfParents(albums);
+		}
+		return albums;
+	}
+	
     /**
 	 * Getter for property id
 	 * 

Deleted: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Gallery.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Gallery.java	2009-01-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Gallery.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -1,113 +0,0 @@
-package org.richfaces.realworld.domain;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-
-import org.hibernate.validator.Length;
-import org.hibernate.validator.NotEmpty;
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.annotations.Name;
-
- at Entity
- at Name("gallery")
- at Table(name = "galleries")
-public class Gallery implements Serializable {
-
-    private static final long serialVersionUID = -7042878411608396483L;
-
-    @Id
-    @GeneratedValue
-    @Column(name = "GALLERY_ID")
-    private Long id = null;
-
-    @Column(length = 255, nullable = false)
-    @NotNull
-	@NotEmpty
-    @Length(min=3)
-    private String name;
-    
-    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gallery")
-    @org.hibernate.annotations.OrderBy(clause = "uploaded desc")
-    @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
-    private List<GalleryImage> images = new ArrayList<GalleryImage>();
-    
-    /**
-	 * Getter for property id
-	 * 
-	 * @return id of album
-	 */
-    public Long getId() {
-        return id;
-    }
-
-    /**
-	 * Getter for property name
-	 * 
-	 * @return name of album
-	 */
-    public String getName() {
-        return name;
-    }
-
-	/**
-	 * Setter for property name
-	 * 
-	 * @param name - name of album
-	 */
-    public void setName(String name) {
-        this.name = name;
-    }
-    
-    /**
-	 * This method add image to collection of images of current album
-	 * 
-	 * @param image - image to add
-	 */
-    public void addImage(GalleryImage image) {
-        if (image == null) {
-            throw new IllegalArgumentException("Null image!");
-        } 
-        if (image.getGallery() != null && !this.equals(image.getGallery())) {
-            image.getGallery().getImages().remove(image);
-        }   
-        image.setGallery(this);
-        images.add(image);
-    }
-
-	/**
-	 * This method remove image from collection of images of album
-	 * 
-	 * @param image - image to remove
-	 */
-    public void removeImage(GalleryImage image) {
-        if (image == null) {
-            throw new IllegalArgumentException("Null image");
-        }  
-        image.setGallery(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 List<GalleryImage> getImages() {
-		return images;
-	}
-
-}

Deleted: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/GalleryImage.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/GalleryImage.java	2009-01-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/GalleryImage.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -1,157 +0,0 @@
-package org.richfaces.realworld.domain;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.hibernate.validator.Length;
-import org.hibernate.validator.NotEmpty;
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.annotations.Name;
-
- at Entity
- at Name("galleryImage")
- at Table(name = "galleryImages")
-public class GalleryImage implements Serializable {
-
-    private static final long serialVersionUID = -7042878411608396483L;
-
-    @Id
-    @GeneratedValue
-    @Column(name = "GALLERY_IMAGE_ID")
-    private Long id = null;
-
-    @Column(length = 255)
-    private String name;
-    
-    @Column(length = 1024)
-    private String path;
-    
-    @Column(length = 255)
-    private String cameraModel;
-    
-    @Column(length = 255)
-    private String author;
-    
-    private int height;
-    
-    private double size;
-    
-    private int width;
-
-    @Column(length = 1024)
-    private String description;
-    
-    @Temporal(TemporalType.TIMESTAMP)
-    private Date created;
-    
-    @Temporal(TemporalType.TIMESTAMP)
-    private Date uploaded;
-    
-    @ManyToOne(fetch = FetchType.LAZY)
-    @JoinColumn(name="IMG_GALLERY_ID",
-    referencedColumnName="GALLERY_ID")
-    private Gallery gallery;
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getCameraModel() {
-		return cameraModel;
-	}
-
-	public void setCameraModel(String cameraModel) {
-		this.cameraModel = cameraModel;
-	}
-
-	public String getAuthor() {
-		return author;
-	}
-
-	public void setAuthor(String author) {
-		this.author = author;
-	}
-
-	public int getHeight() {
-		return height;
-	}
-
-	public void setHeight(int height) {
-		this.height = height;
-	}
-
-	public int getWidth() {
-		return width;
-	}
-
-	public void setWidth(int width) {
-		this.width = width;
-	}
-
-	public String getDescription() {
-		return description;
-	}
-
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public Date getCreated() {
-		return created;
-	}
-
-	public void setCreated(Date created) {
-		this.created = created;
-	}
-
-	public Gallery getGallery() {
-		return gallery;
-	}
-
-	public void setGallery(Gallery gallery) {
-		this.gallery = gallery;
-	}
-
-	public Long getId() {
-		return id;
-	}
-
-	public String getPath() {
-		return path;
-	}
-
-	public void setPath(String path) {
-		this.path = path;
-	}
-
-	public Date getUploaded() {
-		return uploaded;
-	}
-
-	public void setUploaded(Date uploaded) {
-		this.uploaded = uploaded;
-	}
-
-	public double getSize() {
-		return size;
-	}
-
-	public void setSize(double size) {
-		this.size = size;
-	}
-}

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -17,6 +17,8 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
 import javax.persistence.ManyToOne;
 import javax.persistence.OneToMany;
 import javax.persistence.OneToOne;
@@ -76,7 +78,7 @@
     @Temporal(TemporalType.TIMESTAMP)
     private Date uploaded;
     
-    @OneToOne
+    @OneToOne(optional=false, cascade = { CascadeType.ALL })
     @JoinColumn(name="RANK_ID")
     private Rank rank; 
     
@@ -109,6 +111,14 @@
     @JoinColumn(name="IMG_ALBUM_ID",
     referencedColumnName="ALBUM_ID")
     private Album album;
+    
+    @ManyToMany
+    @JoinTable(
+        name = "SHARED_IMAGES",
+        joinColumns =        @JoinColumn(name = "IMAGE_ID"),
+        inverseJoinColumns = @JoinColumn(name = "USER_ID")
+    )
+    private List<User> sharedOwners = new ArrayList<User>();
 
 	/**
 	 * No-arg constructor for JavaBean tools
@@ -155,6 +165,14 @@
         this.name = name;
     }
 
+    public List<User> getSharedOwners() {
+		return sharedOwners;
+	}
+
+	public void setSharedOwners(List<User> sharedOwners) {
+		this.sharedOwners = sharedOwners;
+	}
+	
 	/**
 	 * Getter for property description
 	 * 
@@ -204,6 +222,15 @@
 		return albumName;
 	}
 
+	public String getMetatagString(Image image){
+		StringBuilder s = new StringBuilder();
+		for(MetaTag t: image.getTags()){
+			s.append(t.getTag());
+			s.append(", ");
+		}
+		return s.toString();
+	}
+	
 	public void setAlbumName(String albumName) {
 		this.albumName = albumName;
 	}
@@ -273,7 +300,7 @@
 	}
 
 	public List<MetaTag> getMeta() {
-		return meta;
+ 		return meta;
 	}
 
 	public void setMeta(List<MetaTag> meta) {
@@ -319,4 +346,22 @@
 	public void setUploaded(Date uploaded) {
 		this.uploaded = uploaded;
 	}
+
+	public boolean containTag(String a) {
+		for(MetaTag t :this.getTags()){
+			if(t.getTag().equals(a)){
+				return true;
+			}
+		}
+		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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -18,7 +18,9 @@
 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")
@@ -124,6 +126,11 @@
 	}
 
 	public String getOwnerLogin() {
+		if(ownerLogin == null){
+			if(getOwner()!=null){
+				ownerLogin = getOwner().getLogin();
+			}
+		}
 		return ownerLogin;
 	}
 

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Rank.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -61,10 +61,13 @@
 
 	public double getRating() {
 		double total2 = (double)total;
-		double result = total2/hits;
-		BigDecimal x = new BigDecimal(result);
-		x = x.setScale(2, BigDecimal.ROUND_HALF_UP);
-		return x.doubleValue();
+		if(total2 >0 && hits>0){
+			double result = total2/hits;
+			BigDecimal x = new BigDecimal(result);
+			x = x.setScale(2, BigDecimal.ROUND_HALF_UP);
+			return x.doubleValue();
+		}
+		return 0;
 	}
 	
 }

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -28,6 +28,7 @@
 import org.hibernate.validator.Pattern;
 import org.jboss.seam.ScopeType;
 import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Role;
 import org.jboss.seam.annotations.Scope;
 
 @NamedQueries({
@@ -50,12 +51,21 @@
    @NamedQuery(
         name = "user-friendExist",
         query = "SELECT count(u) FROM User u JOIN u.friendshipRequests fr WHERE u.login=:login and fr.friend.login=:friend"
-   )
+   ),
+    @NamedQuery(
+        name = "user-rootAlbums",
+        query = "from Album a  WHERE a.owner.login=:login and a.parent is null"
+   ),
+   @NamedQuery(
+	        name = "user-outcomeMessages",
+	        query = "from Message m  WHERE m.author.login=:login"
+	   )
 })
 
 @Entity
 @Scope(ScopeType.CONVERSATION)
 @Name("user")
+ at Role(name="selectedUser", scope=ScopeType.CONVERSATION)
 @Table(name = "Users")
 public class User implements Serializable {
 	
@@ -84,9 +94,6 @@
     @Pattern(regex=".+ at .+\\.[a-z]+", message="Not valid e-mail")
 	private String email;
 	
-	@Column(length = 255)
-	private String avatarPath;
-	
 	@Column(length = 255, nullable = false)
     @NotNull
     @NotEmpty
@@ -103,8 +110,11 @@
 	private String confirmPassword;
 	
 	@ManyToMany(mappedBy = "sharedOwners")
-    private List<Album> sharedAlbums = new ArrayList<Album>();
+    private List<Album> favoriteAlbums = new ArrayList<Album>();
 	
+	@ManyToMany(mappedBy = "sharedOwners")
+    private List<Image> favoriteImages = new ArrayList<Image>();
+	
 	@ManyToMany
     @JoinTable(
         name = "USER_FRIENDS",
@@ -159,14 +169,6 @@
 		this.email = email;
 	}
 
-	public String getAvatarPath() {
-		return avatarPath;
-	}
-
-	public void setAvatarPath(String avatarPath) {
-		this.avatarPath = avatarPath;
-	}
-
 	public String getLogin() {
 		return login;
 	}
@@ -276,12 +278,12 @@
 		this.friends = friends;
 	}
 
-	public List<Album> getSharedAlbums() {
-		return sharedAlbums;
+	public List<Album> getFavoriteAlbums() {
+		return favoriteAlbums;
 	}
 
-	public void setSharedAlbums(List<Album> sharedAlbums) {
-		this.sharedAlbums = sharedAlbums;
+	public void setFavoriteAlbums(List<Album> favoriteAlbums) {
+		this.favoriteAlbums = favoriteAlbums;
 	}
 
 	public List<Message> getMessages() {
@@ -301,6 +303,9 @@
 	}
 
 	public void addFriendshipRequest(User owner) {
+		if (getFriendshipRequest(owner, this) != null) {
+			return;
+		}
 		FriendshipRequest request = new FriendshipRequest();
 		request.setUser(this);
 		request.setFriend(owner);
@@ -333,17 +338,39 @@
 		return null;
 	}
 
-	public void removeFromSharedAlbums(Album album) {
-		sharedAlbums.remove(album);
+	public void removeFromFavoriteAlbums(Album album) {
+		favoriteAlbums.remove(album);
 	}
 
-	public void addSharedAlbum(Album album) {
+	public void addFavoriteAlbum(Album album) {
 		if (album == null) {
             throw new IllegalArgumentException("Null album!");
         } 
-		if(sharedAlbums.contains(album)){
+		if(favoriteAlbums.contains(album)){
 			return;
 		}
-		sharedAlbums.add(album);
+		favoriteAlbums.add(album);
 	}
+	
+	public void removeFromFavoriteImages(Image image) {
+		favoriteImages.remove(image);
+	}
+
+	public void addFavoriteImage(Image image) {
+		if (image == null) {
+            throw new IllegalArgumentException("Null image!");
+        } 
+		if(favoriteAlbums.contains(image)){
+			return;
+		}
+		favoriteImages.add(image);
+	}
+
+	public List<Image> getFavoriteImages() {
+		return favoriteImages;
+	}
+
+	public void setFavoriteImages(List<Image> favoriteImages) {
+		this.favoriteImages = favoriteImages;
+	}
 }
\ No newline at end of file

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -7,6 +7,7 @@
 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.User;
 
 @Name("albumAction")
@@ -16,6 +17,8 @@
 	@In(value="entityManager")
 	EntityManager em;
 	
+	private static final String SLASH = "/";
+	
 	@In @Out
 	private User user;
 
@@ -29,11 +32,34 @@
 	}
 	
 	public void deleteAlbum(Album album){
-		user.removeAlbum(album);
+		if(album.getParent()!=null){
+			album.getParent().removeChildAlbum(album);
+		}else{
+			user.removeAlbum(album);
+		}
 		em.flush();
 	}
 	
 	public void editAlbum(Album album){
 		em.flush();
 	}
+	
+	public void flush(){
+		em.flush();
+	}
+	
+	public void renameAllImagesFromAlbumAndChilds(Album album, String replace,
+			String forReplace) {
+		for (Image image : album.getImages()) {
+			image.setPath(image.getPath().replaceAll(replace, forReplace));
+		}
+
+		for (Album a : album.getChildAlbums()) {
+			String replace2 = replace + SLASH + a.getName();
+			String forReplace2 = forReplace + SLASH + a.getName();
+			renameAllImagesFromAlbumAndChilds(a, replace2, forReplace2);
+		}
+		em.flush();
+	}
+	
 }

Deleted: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/GalleryAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/GalleryAction.java	2009-01-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/GalleryAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -1,45 +0,0 @@
-package org.richfaces.realworld.service;
-
-import java.util.List;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.richfaces.realworld.domain.Gallery;
-import org.richfaces.realworld.domain.GalleryImage;
-
- at Name("galleryAction")
- at Stateless
-public class GalleryAction implements IGalleryAction {
-
-	@In(value="entityManager")
-	EntityManager em;
-	/* (non-Javadoc)
-	 * @see org.richfaces.realworld.service.IGalleryAction#addGallery(java.lang.String)
-	 */
-	public void addGallery(String name){
-		Gallery gal = new Gallery();
-		gal.setName(name);
-		em.persist(gal);
-		em.flush();
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.richfaces.realworld.service.IGalleryAction#addmage(org.richfaces.realworld.domain.Gallery, org.richfaces.realworld.domain.GalleryImage)
-	 */
-	public void addImage(Gallery gallery, GalleryImage image){
-		gallery.addImage(image);
-		em.flush();
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.richfaces.realworld.service.IGalleryAction#getGalleries()
-	 */
-	public List<Gallery> getGalleries(){
-		List<Gallery> galleries = em.createQuery("from Gallery")
-		.getResultList();
-		return galleries;
-	}
-}

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IAlbumAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -13,4 +13,9 @@
 	
 	public void editAlbum(Album album);
 
+	public abstract void flush();
+
+	public abstract void renameAllImagesFromAlbumAndChilds(Album dragValue,
+			String albumOld, String albumNew);
+
 }
\ No newline at end of file

Deleted: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IGalleryAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IGalleryAction.java	2009-01-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IGalleryAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -1,19 +0,0 @@
-package org.richfaces.realworld.service;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.richfaces.realworld.domain.Gallery;
-import org.richfaces.realworld.domain.GalleryImage;
-
- at Local
-public interface IGalleryAction {
-
-	public abstract void addGallery(String name);
-
-	public abstract void addImage(Gallery gallery, GalleryImage image);
-
-	public abstract List<Gallery> getGalleries();
-
-}
\ No newline at end of file

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IMessageAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -3,6 +3,7 @@
 import javax.ejb.Local;
 
 import org.richfaces.realworld.domain.Message;
+import org.richfaces.realworld.domain.User;
 
 @Local
 public interface IMessageAction {
@@ -12,4 +13,6 @@
 	public abstract void deleteMessage(Message message);
 
 	public void markAsReaded(Message message);
+	
+	public long countNotReadedMessages(User user);
 }
\ No newline at end of file

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -6,6 +6,8 @@
 
 import org.richfaces.realworld.domain.Album;
 import org.richfaces.realworld.domain.FriendshipRequest;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.Message;
 import org.richfaces.realworld.domain.User;
 
 @Local
@@ -16,11 +18,15 @@
 	public void updateUser(User user);
 	public void resetUser(User user);
 	public List<String> getUsers(String suggest);
-	public long countNotReadedMessages(User user);
 	public void removeFromFriends(User owner, User removed);
 	public boolean friendExist(User user, User friend);
 	public void addFriend(User user, User friend, FriendshipRequest request);
-	public void removeFromSharedAlbums(User user, Album album);
-	public void addSharedAlbum(Album album);
+	public void removeFromFavoriteAlbums(User user, Album album);
+	public void addFavoriteAlbum(Album album);
 	public void loginAnonymous();
+	public List<Album> getRootAlbums(User user);
+	public List<Message> getHistory(User historyUser);
+	public List<Message> getOutgoingMessages();
+	public void addFavoriteImage(Image image);
+	public void removeFromFavoriteImages(User user, Image image);
 }
\ No newline at end of file

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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -5,6 +5,7 @@
 
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
 import org.richfaces.realworld.domain.Message;
 import org.richfaces.realworld.domain.User;
 
@@ -13,9 +14,13 @@
 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")
 	public void sendMessage(Message message){
 		if(message.getOwnerLogin() != null){
 			User user = (User)em.createQuery("from User u where u.login = :login")
@@ -31,6 +36,13 @@
 		em.flush();
 	}
 	
+	public long countNotReadedMessages(User user){
+		Long result = (Long)em.createNamedQuery(USER_COUNT_MESSAGES_QUERY)
+		.setParameter(LOGIN_PARAMETER, user.getLogin())
+		.getSingleResult();
+		return result;
+	}
+	
 	public void deleteMessage(Message message){
 		em.remove(message);
 		message.getOwner().removeMessage(message);

Added: 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	                        (rev 0)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -0,0 +1,14 @@
+package org.richfaces.realworld.service;
+
+import java.util.Comparator;
+
+import org.richfaces.realworld.domain.Message;
+
+public class MessageComparator implements Comparator {
+
+		  public int compare(Object obj1, Object obj2) {
+		    Message mes1 = (Message) obj1;
+		    Message mes2 = (Message) obj2;
+		    return mes1.getDate().after(mes2.getDate())?-1:1;
+		  }
+}


Property changes on: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.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/SearchService.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java	2009-01-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -1,6 +1,7 @@
 package org.richfaces.realworld.service;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -10,7 +11,9 @@
 
 import org.jboss.seam.annotations.In;
 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
@@ -48,6 +51,11 @@
 	EntityManager em;
 	
 	public List<Image> searchImages(String searchPattern, String additionalParams, Map<String, Object> paramMap){
+		List<String> additions = new ArrayList<String>();
+		List<String> removals = new ArrayList<String>();
+		if(!parse(searchPattern, additions, removals)){
+			return null;
+		}
 		String fullQuery = null;
 		if(paramMap != null && paramMap.get(CASE_SENSITIVE_PARAMETER) != null){
 			boolean sensitive = (Boolean)paramMap.get(CASE_SENSITIVE_PARAMETER);
@@ -57,10 +65,37 @@
 				fullQuery = SEARCH_QUERY_BEGIN + additionalParams + SEARCH_QUERY_END;
 			}
 		}
-		Query prepared = prepareQuery(fullQuery, searchPattern, additionalParams, paramMap);
-		return prepared.getResultList();
+		Query prepared = prepareQuery(fullQuery, additions.get(0), additionalParams, paramMap);
+		List<Image> tempResult = prepared.getResultList();
+		additions.remove(0);
+		return filter(tempResult, additions, removals);
 	}
 	
+	private List<Image> filter(List<Image> tempResult, List<String> additions,
+			List<String> removals) {
+		List<Image> result = new ArrayList<Image>();
+		result.addAll(tempResult);
+		for(Image i : tempResult){
+			for(String a:additions){
+				if(!i.containTag(a)){
+					result.remove(i);
+					break;
+				}
+			}
+		}
+		tempResult.clear();
+		tempResult.addAll(result);
+		for(Image i : result){
+			for(String a:removals){
+				if(i.containTag(a)){
+					tempResult.remove(i);
+					break;
+				}
+			}
+		}
+		return tempResult;
+	}
+
 	public List<Image> popularImages(String additionalParams, Map<String, Object> paramMap){
 		String fullQuery = SEARCH_RELEVANT_QUERY_BEGIN + additionalParams + SEARCH_POPULAR_QUERY_END;
 		Query prepared = prepareQuery(fullQuery, null, additionalParams, paramMap);
@@ -129,4 +164,74 @@
 		Query query = em.createQuery("select distinct t.tag from Image i join i.tags t");
 		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"));
+			return false;
+		}
+		if(str.lastIndexOf('+')==-1 && str.lastIndexOf('-')==-1){
+			adds.add(str);
+			return true;
+		}
+		int curIndex=0;
+		int prevIndex=0;
+		boolean prevSignplus =true;
+		boolean signedPreviousChar = false;
+		for(int i =0; i< str.length(); i++){
+			char c = str.charAt(i);
+			if(c == '+' ){
+				if(signedPreviousChar == false){
+					
+					curIndex = i;
+					if(prevSignplus){
+						if(prevIndex ==0){
+							adds.add(str.substring(prevIndex, curIndex));
+						}else{
+							adds.add(str.substring(prevIndex+1, curIndex));
+						}
+					}else{
+						removes.add(str.substring(prevIndex+1, curIndex));
+					}
+					prevSignplus=true;
+					signedPreviousChar=true;
+					prevIndex =i;
+				}else {
+					Events.instance().raiseEvent("addErrorEvent", new Exception("Invalid syntax"));
+					return false;
+				}
+				
+			}else if(c == '-'){
+				if(signedPreviousChar == false){
+					curIndex = i;
+					signedPreviousChar=true;
+					if(prevSignplus){
+						if(prevIndex ==0){
+							adds.add(str.substring(prevIndex, curIndex));
+						}else{
+							adds.add(str.substring(prevIndex+1, curIndex));
+						}
+					}else{
+						removes.add(str.substring(prevIndex+1, curIndex));
+					}
+					prevSignplus=false;
+					
+					prevIndex =i;
+				}else {
+					Events.instance().raiseEvent("addErrorEvent", new Exception("Invalid syntax"));
+					return false;
+				}
+			}else{
+				signedPreviousChar=false;
+			}
+		}
+		char c2 = str.charAt(prevIndex);
+		if(c2 == '+'){
+			adds.add(str.substring(prevIndex+1));
+		}else if(c2 == '-'){
+			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-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java	2009-01-23 13:23:32 UTC (rev 12386)
@@ -20,26 +20,29 @@
  */
 package org.richfaces.realworld.service;
 
+import java.util.Collections;
 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.jboss.seam.annotations.Out;
 import org.richfaces.realworld.domain.Album;
 import org.richfaces.realworld.domain.FriendshipRequest;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.Message;
 import org.richfaces.realworld.domain.User;
 
 @Name("userAction")
 @Stateless
+ at AutoCreate
 public class UserAction implements IUserAction {
 	
 	private static final String USER_FRIEND_EXIST_QUERY = "user-friendExist";
 
-	private static final String USER_COUNT_MESSAGES_QUERY = "user-countMessages";
-
 	private static final String USER_AVAILABLE_USERS_QUERY = "user-availableUsers";
 
 	private static final String USER_EXIST_QUERY = "user-exist";
@@ -56,6 +59,8 @@
 
 	private static final String USERNAME_PARAMETER = "username";
 
+	private static final String USER_OUTCOMING_MESSAGES = "user-outcomeMessages";
+
 	@In(value="entityManager")
 	EntityManager em;
 	
@@ -79,12 +84,26 @@
 		this.user = user;
 	}
 	
+	public List<Album> getRootAlbums(User user) {
+		List<Album> albums = em.createNamedQuery("user-rootAlbums")
+		.setParameter("login", user.getLogin())
+		.getResultList();
+		return albums;
+	}
+	
 	public void resetUser(User user) {
 		em.refresh(user);
 		em.flush();
 		this.user = user;
 	}
 
+	public List<Message> getOutgoingMessages(){
+		List<Message> messages = em.createNamedQuery(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)
@@ -99,12 +118,7 @@
 		return users;
 	}
 	
-	public long countNotReadedMessages(User user){
-		Long result = (Long)em.createNamedQuery(USER_COUNT_MESSAGES_QUERY)
-		.setParameter(LOGIN_PARAMETER, user.getLogin())
-		.getSingleResult();
-		return result;
-	}
+	
 
 	public void removeFromFriends(User owner, User removed) {
 		owner.removeFriend(removed);
@@ -127,13 +141,13 @@
 		em.flush();
 	}
 
-	public void removeFromSharedAlbums(User user, Album album) {
-		user.removeFromSharedAlbums(album);
+	public void removeFromFavoriteAlbums(User user, Album album) {
+		user.removeFromFavoriteAlbums(album);
 		em.flush();
 	}
 
-	public void addSharedAlbum(Album album) {
-		user.addSharedAlbum(album);
+	public void addFavoriteAlbum(Album album) {
+		user.addFavoriteAlbum(album);
 		album.getSharedOwners().add(user);
 		em.flush();
 	}
@@ -141,4 +155,32 @@
 	public void loginAnonymous() {
 		user = new User();	
 	}
+
+	public List<Message> getHistory(User historyUser) {
+		List<Message> userMessages = getUserMessages(historyUser);
+		List<Message> userSecondMessages = getUserSecondMessages(historyUser);
+		userMessages.addAll(userSecondMessages);
+		MessageComparator c = new MessageComparator();
+		Collections.sort(userMessages, c );
+		return userMessages;
+	}
+
+	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();
+	}
+
+	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();
+	}
+
+	public void addFavoriteImage(Image image) {
+		user.addFavoriteImage(image);
+		image.getSharedOwners().add(user);
+		em.flush();
+	}
+
+	public void removeFromFavoriteImages(User user, Image image) {
+		user.removeFromFavoriteImages(image);
+		em.flush();
+	}
 }
\ No newline at end of file

Modified: trunk/test-applications/realworld/ejb/src/main/resources/import.sql
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/resources/import.sql	2009-01-23 13:11:28 UTC (rev 12385)
+++ trunk/test-applications/realworld/ejb/src/main/resources/import.sql	2009-01-23 13:23:32 UTC (rev 12386)
@@ -1,12 +1,14 @@
-INSERT INTO Users(user_id, firstname, secondname, email, avatarpath, login, password, birthdate) VALUES (1,  'Andrey', 'Markhel', 'amarkhel at exadel.com', 'avatar.jpg', 'amarkhel', '12345',  '1985-01-08');
-INSERT INTO Users(user_id, firstname, secondname, email, avatarpath, login, password, birthdate) VALUES (2, 'Andrey', 'Markhel', 'amarkhel at exadel.com', 'avatar.jpg', 'root', '12345',  '1985-01-08');
-INSERT INTO Users(user_id, firstname, secondname, email, avatarpath, login, password, birthdate) VALUES (3, 'Andrey', 'Markhel', 'amarkhel at exadel.com', 'avatar.jpg', 'qqqq', '12345',  '1985-01-08');
-INSERT INTO Users(user_id, firstname, secondname, email, avatarpath, login, password, birthdate) VALUES (4, 'Andrey', 'Markhel', 'amarkhel at exadel.com', 'avatar.jpg', 'sss', '12345',  '1985-01-08');
-INSERT INTO albums(album_id, name, description, shared, album_user_id) VALUES (1,  'Cars', 'Photo of my dog', true, 1);
-INSERT INTO albums(album_id, name, description, shared, album_user_id) VALUES (2,  'Tetki', 'Simple Album 2', true, 1);
-INSERT INTO albums(album_id, name, description, shared, album_user_id) VALUES (3,  'Football', 'Simple Album 3', true, 2);
-INSERT INTO albums(album_id, name, description, shared, album_user_id) VALUES (4,  'Japan', 'Simple Album', true, 3);
-INSERT INTO albums(album_id, name, description, shared, album_user_id) VALUES (5,  'Music', 'Simple Album 2', true, 3);
+INSERT INTO Users(user_id, firstname, secondname, email, login, password, birthdate) VALUES (1,  'Andrey', 'Markhel', 'amarkhel at exadel.com',  'amarkhel', '12345',  '1985-01-08');
+INSERT INTO Users(user_id, firstname, secondname, email, login, password, birthdate) VALUES (2, 'Andrey', 'Markhel', 'amarkhel at exadel.com',  'root', '12345',  '1985-01-08');
+INSERT INTO Users(user_id, firstname, secondname, email, login, password, birthdate) VALUES (3, 'Andrey', 'Markhel', 'amarkhel at exadel.com',  'qqqq', '12345',  '1985-01-08');
+INSERT INTO Users(user_id, firstname, secondname, email, login, password, birthdate) VALUES (4, 'Andrey', 'Markhel', 'amarkhel at exadel.com',  'sss', '12345',  '1985-01-08');
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (1,  'Cars', 'Photo of my dog', true, 1, null);
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (2,  'Tetki', 'Simple Album 2', true, 1, null);
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (3,  'Football', 'Simple Album 3', true, 2, null);
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (4,  'Japan', 'Simple Album', true, 3, null);
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (5,  'Music', 'Simple Album 2', false, 3, null);
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (6,  'Child1', 'Simple Album 2', true, 1, 1);
+INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_album_id) VALUES (7,  'Child2', 'Simple Album 2', true, 1, 1);
 INSERT INTO Ranks(rank_id, total, hits) VALUES (1, 100, 21);
 INSERT INTO Ranks(rank_id, total, hits) VALUES (2, 200, 21);
 INSERT INTO Ranks(rank_id, total, hits) VALUES (3, 100, 31);
@@ -70,9 +72,14 @@
 INSERT INTO images(image_id, name, path, description, created, img_album_id, rank_id, cameraModel, height, size, width, uploaded) VALUES (29,  'Street musician', 'qqqq/Music/StreetMusician.jpg', 'unknown musician',  '2008-12-18', 5, 29,'Canon S3', 336, 60.5, 500, '2008-12-01');
 INSERT INTO images(image_id, name, path, description, created, img_album_id, rank_id, cameraModel, height, size, width, uploaded) VALUES (30,  'SOAD', 'qqqq/Music/system-of-a-down.jpg', 'Try not to loose your innervision!',  '2008-12-18', 5, 30,'Canon S3', 500, 39.5, 323, '2008-12-01');
 INSERT INTO images(image_id, name, path, description, created, img_album_id, rank_id, cameraModel, height, size, width, uploaded) VALUES (31,  'Amon Tobin', 'qqqq/Music/tobin.jpg', 'Brasilian, works in London. Try his "Supermodified2000" album', '2008-12-18', 5, 31,'Canon S3', 450, 37, 302, '2008-12-01');
-INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (1, 'Cool', 1);
-INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (2, 'Cool2', 1);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (1, 'Beach', 1);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (22, 'Sun', 1);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (23, 'Summer', 1);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (2, 'Cool', 1);
 INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (3, 'richfaces', 2);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (24, 'Beach', 2);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (25, 'Sun', 2);
+INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (26, 'amarkhel', 2);
 INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (4, 'Cool', 3);
 INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (5, 'theCool', 4);
 INSERT INTO metatags(metatag_id, tag, image_metatag_id) VALUES (6, 'Cool', 5);
@@ -95,45 +102,10 @@
 INSERT INTO comments(comment_id, date, message, image_comment_id, from_user_id) VALUES (2, '1985-01-08', 'Hello I am user2', 1, 3);
 INSERT INTO messages(message_id, date, message, author_id, owner_id, readed, theme, friendshipRequest) VALUES (1, '1985-01-08', 'Hello I am user', 2, 1, false, 'Hello, amarkhel', false);
 INSERT INTO messages(message_id, date, message, author_id, owner_id, readed, theme, friendshipRequest) VALUES (2, '1985-01-08', 'Please, add meto your friends', 3, 1, false, 'Request for friendship', true);
+INSERT INTO messages(message_id, date, message, author_id, owner_id, readed, theme, friendshipRequest) VALUES (3, '1985-01-09', 'Hello ', 1, 2, false, 'Hello, amarkhel', false);
 INSERT INTO shared_albums(album_id, user_id) VALUES(4, 1);
 INSERT INTO shared_albums(album_id, user_id) VALUES(5, 1);
+INSERT INTO shared_images(image_id, user_id) VALUES(30, 1);
+INSERT INTO shared_images(image_id, user_id) VALUES(31, 1);
 INSERT INTO user_friends(user1_id, user2_id) VALUES(1, 2);
-INSERT INTO friendship_requests(REQUEST_ID, USER_ID, FRIEND_ID) VALUES(1, 3, 1);
-INSERT INTO galleries(GALLERY_ID, name) VALUES (1, 'Fun');
-INSERT INTO galleries(GALLERY_ID, name) VALUES (2, 'Sport');
-INSERT INTO galleries(GALLERY_ID, name) VALUES (3, 'Nature');
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (1, 'Picture1','Fun/img-2e015.jpg' ,'Canon ES3', 'Nick', 1280, 145, 1024, 'Description', '1985-01-08', '2008-21-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (2, 'Picture2', 'Fun/img-9b1c2.jpg','Canon ES3', 'Nick', 1024, 129, 768, 'Description', '1985-01-08', '2008-22-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (3, 'Picture3', 'Fun/img-20d46.jpg','Canon ES3', 'Andrey', 1600, 260, 1200, 'Description', '1985-01-08', '2008-23-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (4, 'Picture4','Fun/img-31c2e.jpg' ,'Canon ES3', 'Ilya', 1280, 169, 1024, 'Description', '1985-01-08', '2008-24-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (5, 'Picture5','Fun/img-69fe6.jpg' ,'Canon ES3', 'Nick', 1280, 102, 1024, 'Description', '1985-01-08', '2008-25-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (6, 'Picture6', 'Fun/img-334ee.jpg','Canon ES3', 'aaa', 1024, 90.9, 768, 'Description', '1985-01-08', '2008-21-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (7, 'Picture7','Fun/img-828dd.jpg' ,'Canon ES3', 'qwazar', 1280, 276, 1024, 'Description', '1985-01-08', '2008-27-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (8, 'Picture8','Fun/img-6537e.jpg' ,'Canon ES3', '', 1600, 338, 1200, 'Description', '1985-01-08', '2008-21-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (9, 'Picture9','Fun/img-7141c.jpg' ,'Canon FS', 'Pit', 1024, 159, 768, 'Description', '1985-01-08', '2008-22-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (10, 'Picture10','Fun/img-25386.jpg' ,'Canon ES3', 'Nick', 1600, 217, 1200, 'Description', '1985-01-08', '2008-21-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (11, 'Picture11','Fun/img-99215.jpg' ,'Canon ES3', 'Andrey', 1024, 74, 768, 'Description', '1985-01-08', '2008-24-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (12, 'Picture12', 'Fun/img-a9307.jpg','Canon ES3', 'aaa', 1680, 197, 1050, 'Description', '1985-01-08', '2008-21-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (13, 'Picture13','Fun/img-b8d37.jpg' ,'Canon ES3-2', 'x-files', 1280, 275, 1024, 'Description', '1985-01-08', '2008-11-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (14, 'Picture14','Fun/img-be1c0.jpg' ,'Canon ES3', 'Nk', 1024, 90.4, 768, 'Description', '1985-01-08', '2008-12-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (15, 'Picture15','Fun/img-cf3ee.jpg' ,'Canon ES3', 'Nickolas', 1024, 97.6, 768, 'Description', '1985-01-08', '2008-22-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (16, 'Picture16','Fun/img-d5ada.jpg' ,'Canon ES3', 'Andr', 1024, 192, 768, 'Description', '1985-01-08', '2008-22-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (17, 'Picture17','Fun/img-d5ed3.jpg' ,'Canon ES3', 'adc', 1024, 213, 768, 'Description', '1985-01-08', '2008-23-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (18, 'Picture18','Fun/img-d966e.jpg' ,'Canon ES3', 'Neeek', 1600, 128, 1200, 'Description', '1985-01-08', '2008-24-11', 1 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (19, 'Picture19','Sport/1.jpg' ,'Canon ES3', 'Potk', 1600, 736, 1200, 'Description', '1985-01-08', '2008-25-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (20, 'Picture20','Sport/2.jpg' ,'Canon ES3', 'aqw', 1280, 229, 1024, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (21, 'Picture100','Sport/3.jpg' ,'Canon ES3', 'ass', 1600, 310, 1200, 'Description', '1985-01-08', '2008-27-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (22, 'Picture101','Sport/4.jpg' ,'Canon ES3', 'www', 1600, 728, 1200, 'Description', '1985-01-08', '2008-29-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (23, 'Picture111','Sport/5.jpg' ,'Canon ES3', 'Nwww', 1280, 251, 1024, 'Description', '1985-01-08', '2008-30-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (24, 'Picture1111','Sport/6.jpg' ,'Canon ES3', 'www', 1280, 278, 1024, 'Description', '1985-01-08', '2008-11-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (25, 'Picture113','Sport/7.jpg' ,'Canon ES3-2', 'Nick', 1600, 689, 1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (26, 'Picture1s','Sport/8.jpg' ,'Canon ES3', 'Nick', 1280, 285, 1024, 'Description', '1985-01-08', '2008-14-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (27, 'Picture1sd','Sport/9.jpg' ,'Canon ES3', 'Nick', 1600, 468, 1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (28, 'Picture1ssd','Sport/10.jpg' ,'Canon ES3', 'Nick', 1600, 313, 1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (29, 'Picture1xd','Sport/11.jpg' ,'Canon ES3', 'Nick', 1600, 214, 1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (30, 'Picture1dfd','Sport/12.jpg' ,'Canon ES3', 'Nick', 1280, 336, 1024, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (31, 'Picture1ww','Sport/13.jpg' ,'Canon ES3', 'Nick', 1600, 287, 1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (32, 'Picture1weqw','Sport/14.jpg' ,'Canon ES3', 'Nick', 1600, 400,1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (33, 'Picture1wdfeqw','Sport/15.jpg' ,'Canon ES3', 'Nick', 1280, 194, 1024, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (34, 'Picture1wseqw','Sport/16.jpg' ,'Canon ES3', 'Nick', 1600, 197, 1200, 'Description', '1985-01-08', '2008-21-11', 2 );
-INSERT INTO galleryImages(GALLERY_IMAGE_ID, name, path, cameraModel, author, height, size, width, description, created, uploaded, IMG_GALLERY_ID) VALUES (35, 'Picture1wddeqw','Sport/17.jpg' ,'Canon ES3', 'Nick', 1280, 87.9, 1024, 'Description', '1985-01-08', '2008-21-11', 2 );
\ No newline at end of file
+INSERT INTO friendship_requests(REQUEST_ID, USER_ID, FRIEND_ID) VALUES(1, 3, 1);
\ No newline at end of file




More information about the richfaces-svn-commits mailing list