rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject svn commit: r1125414 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java main/webapp/WEB-INF/views/home.jsp test/java/org/apache/rave/portal/web/api/
Date Fri, 20 May 2011 14:25:40 GMT
Author: mfranklin
Date: Fri May 20 14:25:40 2011
New Revision: 1125414

URL: http://svn.apache.org/viewvc?rev=1125414&view=rev
Log:
Added additional JPA utilities

Added:
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/
Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java?rev=1125414&r1=1125413&r2=1125414&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/util/JpaUtil.java
Fri May 20 14:25:40 2011
@@ -2,16 +2,13 @@ package org.apache.rave.portal.repositor
 
 import org.springframework.dao.IncorrectResultSizeDataAccessException;
 
+import javax.persistence.EntityManager;
 import java.util.List;
 
 /**
- * @author mfranklin
- *         Date: 4/25/11
- *         Time: 10:13 PM
+ * JPA utilities
  */
 public class JpaUtil {
-	 //Private constructor for utility classes
-	 public JpaUtil () {;}
 
     public static <T> T getSingleResult(List<T> list) {
         if (list == null) {
@@ -27,4 +24,12 @@ public class JpaUtil {
                 throw new IncorrectResultSizeDataAccessException(1);
         }
     }
+    public static <T, I> T saveOrUpdate(I id, EntityManager entityManager, T entity)
{
+        if (id == null) {
+            entityManager.persist(entity);
+            return entity;
+        } else {
+            return entityManager.merge(entity);
+        }
+    }
 }

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp?rev=1125414&r1=1125413&r2=1125414&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp Fri May 20 14:25:40
2011
@@ -68,7 +68,6 @@
 <script type="text/javascript">
     $(function(){
         rave.initProviders();
-        //Get a map of widgets keyed by their type
         rave.initWidgets(rave.createWidgetMap(widgets));
         rave.initDragAndDrop();
     });



Mime
View raw message