[richfaces-svn-commits] JBoss Rich Faces SVN: r13469 - trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Apr 9 10:39:59 EDT 2009


Author: amarkhel
Date: 2009-04-09 10:39:59 -0400 (Thu, 09 Apr 2009)
New Revision: 13469

Modified:
   trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
   trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
Log:


Modified: trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java	2009-04-09 14:39:53 UTC (rev 13468)
+++ trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java	2009-04-09 14:39:59 UTC (rev 13469)
@@ -39,7 +39,7 @@
 
 	public void deleteImage(Image image);
 
-	public void editImage(Image image);
+	public void editImage(Image image, boolean metatagsChanged);
 
 	public void addImage(Image image);
 	

Modified: trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java	2009-04-09 14:39:53 UTC (rev 13468)
+++ trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java	2009-04-09 14:39:59 UTC (rev 13469)
@@ -66,52 +66,54 @@
      * Synchronize state of image entity with database
      *@param image - image to Synchronize
      */
-    public void editImage(Image image) {
-    	//Create cash of metatags early associated with image
-        List<MetaTag> removals = new ArrayList<MetaTag>(image.getImageTags());
-        
-        //Get string representation of current metatgs, associated with image and split them by comma
-        String[] tokens = image.getMetaString().split(Constants.COMMA);
-        
-        //Populate set of tokens - 'candidates to metatags'
-        Set<String> toks = new HashSet<String>();
-        for (String s : tokens) {
-            toks.add(s.trim());
-        }
-        
-        for (String s : toks) {
-        	//Find metatag in early associated tags
-        	MetaTag t = image.getTagByName(s);
-            if (t != null) {
-            	//If found - no work needed
-                removals.remove(t);
-            } else {
-            	//Find metatag in database
-            	t = getTagByName(s);
-            		if(t != null){
-            			//If found simple add reference to it
-            			image.addMetaTag(t);
-            		}else{
-            			//Create new metatag
-            			t = new MetaTag();
-                        t.setTag(s);
-                        image.addMetaTag(t);
-                        //Persist to database to prevent concurrent creation of other metatags with given name
-                        em.persist(t);
-            		}
-            	}
-        }
-        
-        for (MetaTag tag : removals) {
-        	//If metatag in that collection, we need remove them
-            image.removeMetaTag(tag);
-        }
-        //If this image is covering for album, break the reference
-        if (image.isCovering()) {
-            if (!image.equals(image.getAlbum().getCoveringImage())) {
-                image.getAlbum().setCoveringImage(image);
+    public void editImage(Image image, boolean metatagsChanged) {
+    	if(metatagsChanged){
+    		//Create cash of metatags early associated with image
+            List<MetaTag> removals = new ArrayList<MetaTag>(image.getImageTags());
+            
+            //Get string representation of current metatgs, associated with image and split them by comma
+            String[] tokens = image.getMetaString().split(Constants.COMMA);
+            
+            //Populate set of tokens - 'candidates to metatags'
+            Set<String> toks = new HashSet<String>();
+            for (String s : tokens) {
+                toks.add(s.trim());
             }
-        }
+            
+            for (String s : toks) {
+            	//Find metatag in early associated tags
+            	MetaTag t = image.getTagByName(s);
+                if (t != null) {
+                	//If found - no work needed
+                    removals.remove(t);
+                } else {
+                	//Find metatag in database
+                	t = getTagByName(s);
+                		if(t != null){
+                			//If found simple add reference to it
+                			image.addMetaTag(t);
+                		}else{
+                			//Create new metatag
+                			t = new MetaTag();
+                            t.setTag(s);
+                            image.addMetaTag(t);
+                            //Persist to database to prevent concurrent creation of other metatags with given name
+                            em.persist(t);
+                		}
+                	}
+            }
+            
+            for (MetaTag tag : removals) {
+            	//If metatag in that collection, we need remove them
+                image.removeMetaTag(tag);
+            }
+            //If this image is covering for album, break the reference
+            if (image.isCovering()) {
+                if (!image.equals(image.getAlbum().getCoveringImage())) {
+                    image.getAlbum().setCoveringImage(image);
+                }
+            }
+    	}
         em.flush();
     }
 




More information about the richfaces-svn-commits mailing list