You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2023/07/27 12:04:49 UTC

[ofbiz-plugins] branch release18.12 updated (534a570a4 -> fd4a24d7e)

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a change to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


    from 534a570a4 Improved: Add a GH SECURITY.md page to framework and plugins branches (OFBIZ-12833)
     new c82a3d802 Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)
     new bcd4e4339 Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)
     new fd4a24d7e Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../groovyScripts/forum/ShowForum.groovy           | 29 +++-----
 .../apache/ofbiz/ecommerce/forum/ForumEvents.java  | 87 ++++++++++++++++++++++
 ecommerce/template/forum/ForumPaging.ftl           |  7 +-
 ecommerce/widget/ForumScreens.xml                  | 18 +----
 4 files changed, 105 insertions(+), 36 deletions(-)
 copy bi/groovyScripts/GetStarSchemas.groovy => ecommerce/groovyScripts/forum/ShowForum.groovy (60%)
 create mode 100644 ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java


[ofbiz-plugins] 03/03: Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git

commit fd4a24d7eb94d6248c27b375dcf1ad9698beeac1
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Mon Mar 27 11:38:08 2023 +0200

    Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)
    
    Definitely fixes a checkstyle issue (was not awake before and the plugins branch has not
    safeguard like the framework, I mean the Git pre-push hook )
---
 .../src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
index 6d5b549b3..7285ce0f5 100644
--- a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
+++ b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
@@ -59,7 +59,7 @@ public class ForumEvents {
             articlesFound = dispatcher.runSync("performFind", UtilMisc.<String, Object>toMap("entityName",
                     "ContentAssocViewTo", "inputFields", inputFields, "userLogin", userLogin, "orderBy", "-createdDate"));
         } catch (GenericServiceException e) {
-            Debug.logError(e, "Cannot get ForumMessages for Forum %s", module, forumId);
+            Debug.logError(e, "Cannot get ForumMessages for Forum %s", MODULE, forumId);
             return ServiceUtil.returnError("Error while searching for Messages, please retry and/or contact Admin.");
         }
         int start = viewIndex * viewSize;
@@ -69,7 +69,7 @@ public class ForumEvents {
             list = it.getPartialList(start + 1, viewSize); // list starts at '1'
             listSize = it.getResultsSizeAfterPartialList();
         } catch (ClassCastException | NullPointerException | GenericEntityException e) {
-            Debug.logInfo("Problem getting partial list" + e, module);
+            Debug.logInfo("Problem getting partial list" + e, MODULE);
         }
 
         // create the result map


[ofbiz-plugins] 01/03: Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git

commit c82a3d80299ca4c37387b74bbae5ca69d1a9d759
Author: cshan-ecomify <11...@users.noreply.github.com>
AuthorDate: Mon Mar 27 08:08:14 2023 +0200

    Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)
    
    * Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434)
    * Improved: Removed commented out code (OFBIZ-11434)
    Conflict handled by hand ecommerce/template/forum/ForumPaging.ftl
---
 ecommerce/groovyScripts/forum/ShowForum.groovy     | 31 ++++++++
 .../apache/ofbiz/ecommerce/forum/ForumEvents.java  | 87 ++++++++++++++++++++++
 ecommerce/template/forum/ForumPaging.ftl           |  7 +-
 ecommerce/widget/ForumScreens.xml                  | 18 +----
 4 files changed, 126 insertions(+), 17 deletions(-)

diff --git a/ecommerce/groovyScripts/forum/ShowForum.groovy b/ecommerce/groovyScripts/forum/ShowForum.groovy
new file mode 100644
index 000000000..d04160c50
--- /dev/null
+++ b/ecommerce/groovyScripts/forum/ShowForum.groovy
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.ofbiz.ecommerce.forum.ForumEvents
+import org.apache.ofbiz.service.ServiceUtil
+
+Map result = ForumEvents.getForumMessages(request, delegator)
+if (ServiceUtil.isSuccess(result)) {
+    context.put("viewSize",result.get("viewSize"))
+    context.put("forumMessages", result.get("forumMessages"))
+    context.put("viewIndex", result.get("viewIndex"))
+    context.put("listSize", result.get("listSize"))
+    context.put("lowIndex", result.get("lowIndex"))
+    context.put("highIndex", result.get("highIndex"))
+}
diff --git a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
new file mode 100644
index 000000000..0d60927b3
--- /dev/null
+++ b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
@@ -0,0 +1,87 @@
+package org.apache.ofbiz.ecommerce.forum;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.ofbiz.base.util.Debug;
+import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilValidate;
+import org.apache.ofbiz.entity.Delegator;
+import org.apache.ofbiz.entity.GenericEntityException;
+import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.util.EntityListIterator;
+import org.apache.ofbiz.service.GenericServiceException;
+import org.apache.ofbiz.service.LocalDispatcher;
+import org.apache.ofbiz.service.ServiceUtil;
+
+public class ForumEvents {
+
+    public static final String module = ForumEvents.class.getName();
+
+    public static Map<String, Object> getForumMessages(HttpServletRequest request, Delegator delegator) {
+
+        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        // ========== Create View Indexes
+        int viewIndex = 0;
+        int viewSize = 20;
+
+        if (UtilValidate.isNotEmpty(request.getParameter("VIEW_INDEX"))) {
+            Integer viewIndexInteger = Integer.parseInt(request.getParameter("VIEW_INDEX"));
+            if (viewIndexInteger != null) {
+                viewIndex = viewIndexInteger;
+            }
+        }
+
+        if (UtilValidate.isNotEmpty(request.getParameter("VIEW_SIZE"))) {
+            Integer viewSizeInteger = Integer.parseInt(request.getParameter("VIEW_SIZE"));
+            if (viewSizeInteger != null) {
+                viewSize = viewSizeInteger;
+            }
+        }
+
+        int lowIndex = viewIndex * viewSize;
+        int highIndex = (viewIndex + 1) * viewSize;
+
+        // =========== Set up the PerformFindList
+        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
+        String forumId = request.getParameter("forumId");
+        Map<String, Object> inputFields = new HashMap<>();
+        inputFields.put("contentIdStart", forumId);
+        inputFields.put("caContentAssocTypeId_fld0", "PUBLISH_LINK");
+        inputFields.put("caContentAssocTypeId_fld1", "RESPONSE");
+
+        Map<String, Object> articlesFound = null;
+
+        try {
+            articlesFound = dispatcher.runSync("performFind", UtilMisc.<String, Object>toMap("entityName",
+                    "ContentAssocViewTo", "inputFields", inputFields, "userLogin", userLogin, "orderBy", "-createdDate"));
+        } catch (GenericServiceException e) {
+            Debug.logError(e, "Cannot get ForumMessages for Forum %s", module, forumId);
+            return ServiceUtil.returnError("Error while searching for Messages, please retry and/or contact Admin.");
+        }
+        int start = viewIndex * viewSize;
+        List<GenericValue> list = null;
+        Integer listSize = 0;
+        try (EntityListIterator it = (EntityListIterator) articlesFound.get("listIt")) {
+            list = it.getPartialList(start + 1, viewSize); // list starts at '1'
+            listSize = it.getResultsSizeAfterPartialList();
+        } catch (ClassCastException | NullPointerException | GenericEntityException e) {
+            Debug.logInfo("Problem getting partial list" + e, module);
+        }
+
+        // create the result map
+        Map<String, Object> result = ServiceUtil.returnSuccess();
+
+        result.put("highIndex", highIndex);
+        result.put("listSize", listSize);
+        result.put("lowIndex", lowIndex);
+        result.put("viewIndex", viewIndex);
+        result.put("viewSize", viewSize);
+        result.put("forumMessages", list);
+
+        return result;
+    }
+}
diff --git a/ecommerce/template/forum/ForumPaging.ftl b/ecommerce/template/forum/ForumPaging.ftl
index 25a4b686e..c501f24b1 100644
--- a/ecommerce/template/forum/ForumPaging.ftl
+++ b/ecommerce/template/forum/ForumPaging.ftl
@@ -16,13 +16,14 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
-
+<#assign viewSize = viewSize?default(20)>
 <#assign viewIndex = viewIndex?default(0)>
 <#assign lowIndex = viewIndex?int * viewSize?int + 1>
 <#assign highIndex = viewIndex?int * viewSize?int + viewSize>
-<#--<br />== viewIndex: ${viewIndex} ==viewSize: ${viewSize} ==lowIndex: ${lowIndex}== highIndex: ${highIndex} == ListSize: ${listSize}-->
+
+<#-- <br />== viewIndex: ${viewIndex} ==viewSize: ${viewSize} ==lowIndex: ${lowIndex}== highIndex: ${highIndex} == ListSize: ${listSize} -->
 <#if forumMessages?has_content && forumMessages?size gt 0>
-  <#assign listSize = forumMessages?size/>
+    <#assign listSize = listSize?default(forumMessages?size)/>
   <#if highIndex gt listSize><#assign highIndex = listSize></#if>
 <div class="product-prevnext">
   <#assign r = listSize / viewSize />
diff --git a/ecommerce/widget/ForumScreens.xml b/ecommerce/widget/ForumScreens.xml
index 2174fec22..be9ec2523 100644
--- a/ecommerce/widget/ForumScreens.xml
+++ b/ecommerce/widget/ForumScreens.xml
@@ -60,20 +60,11 @@ under the License.
                 </entity-one>
                 <!-- parameters for the performFind service -->
                 <set field="parameters.forumId" from-field="parameters.forumId" default-value="${parameters.contentId}"/>
-                <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer" default-value="0" />
+                <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer" default-value="0"/>
+                <set field="parameters.viewIndex" from-field="viewIndex"/>
                 <set field="viewSizeDefaultValue" value="${groovy: modelTheme.getDefaultViewSize()}" type="Integer"/>
-                <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="${viewSizeDefaultValue}"/>
-                <entity-condition entity-name="ContentAssocViewTo" list="forumMessages" >
-                    <condition-list combine="and">
-                        <condition-expr field-name="contentIdStart" from-field="parameters.forumId"/>
-                        <condition-list combine="or">
-                            <condition-expr field-name="caContentAssocTypeId" value="PUBLISH_LINK"/>
-                            <condition-expr field-name="caContentAssocTypeId" value="RESPONSE"/>
-                        </condition-list>
-                    </condition-list>
-                    <order-by field-name="createdDate"/>
-
-                </entity-condition>
+                <set field="parameters.viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="${viewSizeDefaultValue}"/>
+                <script location="component://ecommerce/groovyScripts/forum/ShowForum.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
@@ -101,7 +92,6 @@ under the License.
                                 </section>
                                 <platform-specific><html><html-template location="component://ecommerce/template/forum/ForumPaging.ftl"/></html></platform-specific>
                                 <platform-specific><html><html-template location="component://ecommerce/template/forum/ShowForum.ftl"/></html></platform-specific>
-                                <platform-specific><html><html-template location="component://ecommerce/template/forum/ForumPaging.ftl"/></html></platform-specific>
                             </widgets>
                         </section>
                     </decorator-section>


[ofbiz-plugins] 02/03: Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git

commit bcd4e43390db53eeb9e9858e005703e4f28b2cef
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Mon Mar 27 10:33:09 2023 +0200

    Fixed: Makes Forum Articles respond to pagination controls (OFBIZ-11434) (#76)
    
    Fixes a checkstyle issue
---
 .../src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
index 0d60927b3..6d5b549b3 100644
--- a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
+++ b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/forum/ForumEvents.java
@@ -19,7 +19,7 @@ import org.apache.ofbiz.service.ServiceUtil;
 
 public class ForumEvents {
 
-    public static final String module = ForumEvents.class.getName();
+    public static final String MODULE = ForumEvents.class.getName();
 
     public static Map<String, Object> getForumMessages(HttpServletRequest request, Delegator delegator) {