roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [30/35] roller git commit: Fixes to Planet's custom groups save, update and delete.
Date Mon, 06 Nov 2017 22:17:31 GMT
Fixes to Planet's custom groups save, update and delete.


Project: http://git-wip-us.apache.org/repos/asf/roller/repo
Commit: http://git-wip-us.apache.org/repos/asf/roller/commit/89e14003
Tree: http://git-wip-us.apache.org/repos/asf/roller/tree/89e14003
Diff: http://git-wip-us.apache.org/repos/asf/roller/diff/89e14003

Branch: refs/heads/master
Commit: 89e14003fcba94b7a0a959b17db4770322e45ed2
Parents: 5a62d70
Author: Dave Johnson <snoopdave@gmail.com>
Authored: Sun Oct 15 17:57:29 2017 -0400
Committer: Dave Johnson <snoopdave@gmail.com>
Committed: Sun Oct 15 17:57:29 2017 -0400

----------------------------------------------------------------------
 .../roller/planet/business/PlanetManager.java   |  7 ++-
 .../business/jpa/JPAPlanetManagerImpl.java      | 20 ++++++++-
 .../weblogger/planet/ui/PlanetGroups.java       | 46 ++++++++++++--------
 .../resources/ApplicationResources.properties   |  2 +
 .../webapp/WEB-INF/jsps/admin/PlanetGroups.jsp  |  4 +-
 5 files changed, 56 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/roller/blob/89e14003/app/src/main/java/org/apache/roller/planet/business/PlanetManager.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/planet/business/PlanetManager.java b/app/src/main/java/org/apache/roller/planet/business/PlanetManager.java
index 730c922..deec197 100644
--- a/app/src/main/java/org/apache/roller/planet/business/PlanetManager.java
+++ b/app/src/main/java/org/apache/roller/planet/business/PlanetManager.java
@@ -25,6 +25,7 @@ import org.apache.roller.planet.pojos.Planet;
 import org.apache.roller.planet.pojos.SubscriptionEntry;
 import org.apache.roller.planet.pojos.PlanetGroup;
 import org.apache.roller.planet.pojos.Subscription;
+import org.apache.roller.weblogger.WebloggerException;
 
 
 /**
@@ -178,5 +179,9 @@ public interface PlanetManager extends Manager {
                            Date endDate,
                            int offset, 
                            int len) throws RollerException;
-    
+
+    /**
+     * Add new PlanetGroup and add it to an existing planet.
+     */
+    void saveNewPlanetGroup(Planet planet, PlanetGroup planetGroup) throws WebloggerException;
 }

http://git-wip-us.apache.org/repos/asf/roller/blob/89e14003/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
b/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
index ff2ab15..5a24a80 100644
--- a/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
+++ b/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
@@ -85,6 +85,10 @@ public class JPAPlanetManagerImpl extends AbstractManagerImpl implements
PlanetM
     }
     
     public void deleteGroup(PlanetGroup group) throws RollerException {
+
+        group.getPlanet().getGroups().remove(group);
+        strategy.store(group.getPlanet());
+
         strategy.remove(group);
     }
     
@@ -251,7 +255,8 @@ public class JPAPlanetManagerImpl extends AbstractManagerImpl implements
PlanetM
         if (sub == null) {
             throw new WebloggerException("subscription cannot be null");
         }
-        TypedQuery<SubscriptionEntry> q = strategy.getNamedQuery("SubscriptionEntry.getBySubscription",
SubscriptionEntry.class);
+        TypedQuery<SubscriptionEntry> q = strategy.getNamedQuery(
+                "SubscriptionEntry.getBySubscription", SubscriptionEntry.class);
         q.setParameter(1, sub);
         if (offset != 0) {
             q.setFirstResult(offset);
@@ -266,7 +271,8 @@ public class JPAPlanetManagerImpl extends AbstractManagerImpl implements
PlanetM
         return getEntries(group, null, null, offset, len);
     }
 
-    public List<SubscriptionEntry> getEntries(PlanetGroup group, Date startDate, Date
endDate, int offset, int len) throws RollerException {
+    public List<SubscriptionEntry> getEntries(
+            PlanetGroup group, Date startDate, Date endDate, int offset, int len) throws
RollerException {
 
         if (group == null) {
             throw new WebloggerException("group cannot be null or empty");
@@ -319,6 +325,16 @@ public class JPAPlanetManagerImpl extends AbstractManagerImpl implements
PlanetM
         
         return ret;
     }
+
+    @Override
+    public void saveNewPlanetGroup(Planet planet, PlanetGroup planetGroup) throws WebloggerException
{
+
+        planetGroup.setPlanet( planet );
+        strategy.store( planetGroup );
+
+        planet.getGroups().add( planetGroup );
+        strategy.store( planet );
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/roller/blob/89e14003/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetGroups.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetGroups.java b/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetGroups.java
index cc06ca9..f65c480 100644
--- a/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetGroups.java
+++ b/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetGroups.java
@@ -22,7 +22,9 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.planet.business.PlanetManager;
+import org.apache.roller.planet.pojos.Planet;
 import org.apache.roller.planet.pojos.PlanetGroup;
+import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.struts2.convention.annotation.AllowedMethods;
 
@@ -81,42 +83,47 @@ public class PlanetGroups extends PlanetUIAction {
         
         return LIST;
     }
-    
-    
-    /** 
+
+
+    /**
      * Save group.
      */
     public String save() {
-        
+
         myValidate();
-        
+
         if (!hasActionErrors()) {
             try {
+                PlanetManager planetManager = WebloggerFactory.getWeblogger().getPlanetManager();
+
+                Planet planet = getPlanet();
                 PlanetGroup planetGroup = getGroup();
-                if(planetGroup == null) {
-                    log.debug("Adding New Group");
+
+                if (planetGroup == null) {
                     planetGroup = new PlanetGroup();
-                    planetGroup.setPlanet(getPlanet());
+                    planetGroup.setPlanet(planet);
+                    getBean().copyTo(planetGroup);
+
+                    log.debug("Adding New Group: " + planetGroup.getHandle());
+                    planetManager.saveNewPlanetGroup(getPlanet(), planetGroup);
+
                 } else {
-                    log.debug("Updating Existing Group");
+                    log.debug("Updating Existing Group: " + planetGroup.getHandle());
+                    getBean().copyTo(planetGroup);
+                    planetManager.saveGroup(planetGroup);
                 }
 
-                // copy in submitted data
-                getBean().copyTo(planetGroup);
-
-                // save and flush
-                PlanetManager pmgr = WebloggerFactory.getWeblogger().getPlanetManager();
-                pmgr.saveGroup(planetGroup);
                 WebloggerFactory.getWeblogger().flush();
-
                 addMessage("planetGroups.success.saved");
 
-            } catch(Exception ex) {
+                setGroup(null);
+
+            } catch (Exception ex) {
                 log.error("Error saving planet group - " + getBean().getId(), ex);
                 addError("planetGroups.error.saved");
             }
         }
-        
+
         return LIST;
     }
 
@@ -133,6 +140,9 @@ public class PlanetGroups extends PlanetUIAction {
                 WebloggerFactory.getWeblogger().flush();
                 
                 addMessage("planetSubscription.success.deleted");
+
+                setGroup(null);
+
             } catch(Exception ex) {
                 log.error("Error deleting planet group - "+getBean().getId());
                 addError("Error deleting planet group");

http://git-wip-us.apache.org/repos/asf/roller/blob/89e14003/app/src/main/resources/ApplicationResources.properties
----------------------------------------------------------------------
diff --git a/app/src/main/resources/ApplicationResources.properties b/app/src/main/resources/ApplicationResources.properties
index 0a2f8c5..8a68c56 100644
--- a/app/src/main/resources/ApplicationResources.properties
+++ b/app/src/main/resources/ApplicationResources.properties
@@ -1179,6 +1179,8 @@ planetGroups.edit.tip=Edit this group
 planetGroups.title=Title
 planetGroups.handle=Handle
 
+planetGroups.subscriptions.tip=Edit the subscriptions in this Custom Group
+
 planetGroups.success.saved=Saved group
 planetGroups.error.saved=Error saving planet group - duplicate?
 

http://git-wip-us.apache.org/repos/asf/roller/blob/89e14003/app/src/main/webapp/WEB-INF/jsps/admin/PlanetGroups.jsp
----------------------------------------------------------------------
diff --git a/app/src/main/webapp/WEB-INF/jsps/admin/PlanetGroups.jsp b/app/src/main/webapp/WEB-INF/jsps/admin/PlanetGroups.jsp
index 420cbd0..f518ac6 100644
--- a/app/src/main/webapp/WEB-INF/jsps/admin/PlanetGroups.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/admin/PlanetGroups.jsp
@@ -33,13 +33,13 @@
     <s:hidden name="bean.id" />
     
     <div class="formrow">
-        <label for="title" class="formrow" /><s:text name="planetGroups.title" /></label>
+        <label for="bean.title" class="formrow" /><s:text name="planetGroups.title"
/></label>
         <s:textfield name="bean.title" size="40" maxlength="255" />
         <img src="<s:url value="/images/help.png"/>" alt="help" title='<s:text
name="planetGroups.tip.title" />' />
     </div>
     
     <div class="formrow">
-        <label for="handle" class="formrow" /><s:text name="planetGroups.handle"
/></label>
+        <label for="bean.handle" class="formrow" /><s:text name="planetGroups.handle"
/></label>
         <s:textfield name="bean.handle" size="40" maxlength="255" />
         <img src="<s:url value="/images/help.png"/>" alt="help" title='<s:text
name="planetGroups.tip.handle" />' />
     </div>


Mime
View raw message