svn commit: r1226325 - in /ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar: CreateUrlParam.groovy Days.groovy Month.groovy Week.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1226325 - in /ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar: CreateUrlParam.groovy Days.groovy Month.groovy Week.groovy

adrianc
Author: adrianc
Date: Mon Jan  2 00:46:00 2012
New Revision: 1226325

URL: http://svn.apache.org/viewvc?rev=1226325&view=rev
Log:
Code cleanup in the work effort calendar groovy scripts.

Modified:
    ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy
    ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy
    ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy
    ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy

Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy?rev=1226325&r1=1226324&r2=1226325&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy (original)
+++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy Mon Jan  2 00:46:00 2012
@@ -17,60 +17,14 @@
  * under the License.
  */
 
-facilityId = parameters.facilityId;
-fixedAssetId = parameters.fixedAssetId;
-partyId = parameters.partyId;
-workEffortTypeId = parameters.workEffortTypeId;
-calendarType = parameters.calendarType;
-hideEvents = parameters.hideEvents;
+import java.util.*;
+import org.ofbiz.base.util.*;
 
-urlParam = "";
-if (facilityId) {
-    urlParam = "facilityId=" + facilityId;
+Map urlParametersMap = UtilHttp.getQueryStringOnlyParameterMap(request);
+urlParametersMap.remove("period");
+urlParametersMap.remove("start");
+StringBuilder sb = new StringBuilder();
+for (entry in urlParametersMap.entrySet()) {
+    sb.append("&").append(entry.getKey()).append("=").append(entry.getValue());
 }
-if (fixedAssetId) {
-    if (urlParam) {
-        urlParam = urlParam + "&";
-    }
-    urlParam = urlParam + "fixedAssetId=" + fixedAssetId;
-}
-if (partyId) {
-    if (urlParam) {
-        urlParam = urlParam + "&";
-    }
-    urlParam = urlParam + "partyId=" + partyId;
-}
-
-if (workEffortTypeId) {
-    if (urlParam) {
-        urlParam = urlParam + "&";
-    }
-    urlParam = urlParam + "workEffortTypeId=" + workEffortTypeId;
-}
-
-if (calendarType) {
-    if (urlParam) {
-        urlParam = urlParam + "&";
-    }
-    urlParam = urlParam + "calendarType=" + calendarType;
-}
-
-if (hideEvents) {
-    if (urlParam) {
-        urlParam = urlParam + "&";
-    }
-    urlParam = urlParam + "hideEvents=" + hideEvents;
-}
-
-if (parameters.portalPageId) {
-    if (urlParam) {
-        urlParam = urlParam + "&";
-    }
-    urlParam = urlParam + "portalPageId=" + parameters.portalPageId;
-}
-
-if (urlParam) {
-    urlParam = "&" + urlParam;
-}
-
-context.put("urlParam", urlParam);
+context.put("urlParam", sb.toString());

Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy?rev=1226325&r1=1226324&r2=1226325&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy (original)
+++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy Mon Jan  2 00:46:00 2012
@@ -18,22 +18,10 @@
  */
 
 import java.util.*;
-import java.text.*;
-import org.ofbiz.entity.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.webapp.pseudotag.*;
-import org.ofbiz.workeffort.workeffort.*;
 import java.sql.Timestamp;
+import org.ofbiz.base.util.*;
 
-String currentDay = parameters.get("currentDay");
 String startParam = parameters.get("start");
-facilityId = parameters.facilityId;
-fixedAssetId = parameters.fixedAssetId;
-partyId = parameters.partyId;
-workEffortTypeId = parameters.workEffortTypeId;
-calendarType = parameters.calendarType;
-entityExprList = context.entityExprList;
-
 Timestamp start = null;
 if (UtilValidate.isNotEmpty(startParam)) {
     start = new Timestamp(Long.parseLong(startParam));
@@ -43,21 +31,18 @@ if (start == null) {
 } else {
     start = UtilDateTime.getDayStart(start, timeZone, locale);
 }
-
 Timestamp prev = UtilDateTime.getDayStart(start, -1, timeZone, locale);
 context.prevMillis = new Long(prev.getTime()).toString();
 Timestamp next = UtilDateTime.getDayStart(start, 1, timeZone, locale);
 context.nextMillis = new Long(next.getTime()).toString();
-
-Map serviceCtx = UtilMisc.toMap("userLogin", userLogin,"start",start,"numPeriods", 24,"periodType", Calendar.HOUR);
-serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType, "locale", locale, "timeZone", timeZone));
-if (entityExprList) {
-    serviceCtx.putAll(["entityExprList" : entityExprList]);
+Map serviceCtx = dispatcher.getDispatchContext().makeValidContext("getWorkEffortEventsByPeriod", "IN", parameters);
+serviceCtx.putAll(UtilMisc.toMap("userLogin", userLogin, "start", start, "numPeriods", 24, "periodType", Calendar.HOUR, "locale", locale, "timeZone", timeZone));
+if (context.entityExprList) {
+    serviceCtx.entityExprList = entityExprList;
 }
-
-Map result = dispatcher.runSync("getWorkEffortEventsByPeriod",serviceCtx);
-context.put("periods",result.get("periods"));
-context.put("maxConcurrentEntries",result.get("maxConcurrentEntries"));
-context.put("start",start);
-context.put("prev",prev);
-context.put("next",next);
+Map result = dispatcher.runSync("getWorkEffortEventsByPeriod", serviceCtx);
+context.put("periods", result.get("periods"));
+context.put("maxConcurrentEntries", result.get("maxConcurrentEntries"));
+context.put("start", start);
+context.put("prev", prev);
+context.put("next", next);

Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy?rev=1226325&r1=1226324&r2=1226325&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy (original)
+++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy Mon Jan  2 00:46:00 2012
@@ -18,24 +18,11 @@
  */
 
 import java.sql.*;
-import java.text.*;
 import java.util.*;
-import org.ofbiz.security.*;
-import org.ofbiz.entity.*;
 import org.ofbiz.base.util.*;
-import org.ofbiz.webapp.pseudotag.*;
-import org.ofbiz.workeffort.workeffort.*;
 
 startParam = parameters.start;
-
-facilityId = parameters.facilityId;
-fixedAssetId = parameters.fixedAssetId;
-partyId = parameters.partyId;
-workEffortTypeId = parameters.workEffortTypeId;
-calendarType = parameters.calendarType;
-entityExprList = context.entityExprList;
-
-start = null;
+Timestamp start = null;
 if (UtilValidate.isNotEmpty(startParam)) {
     start = new Timestamp(Long.parseLong(startParam));
 }
@@ -44,16 +31,13 @@ if (start == null) {
 } else {
     start = UtilDateTime.getMonthStart(start, timeZone, locale);
 }
-
 tempCal = UtilDateTime.toCalendar(start, timeZone, locale);
 numDays = tempCal.getActualMaximum(Calendar.DAY_OF_MONTH);
-
 prev = UtilDateTime.getMonthStart(start, -1, timeZone, locale);
 context.prevMillis = new Long(prev.getTime()).toString();
 next = UtilDateTime.getDayStart(start, numDays+1, timeZone, locale);
 context.nextMillis = new Long(next.getTime()).toString();
 end = UtilDateTime.getMonthEnd(start, timeZone, locale);
-
 //Find out what date to get from
 getFrom = null;
 prevMonthDays =  tempCal.get(Calendar.DAY_OF_WEEK) - tempCal.getFirstDayOfWeek();
@@ -63,7 +47,6 @@ numDays += prevMonthDays;
 getFrom = new Timestamp(tempCal.getTimeInMillis());
 firstWeekNum = tempCal.get(Calendar.WEEK_OF_YEAR);
 context.put("firstWeekNum", firstWeekNum);
-
 // also get days until the end of the week at the end of the month
 lastWeekCal = UtilDateTime.toCalendar(end, timeZone, locale);
 monthEndDay = lastWeekCal.get(Calendar.DAY_OF_WEEK);
@@ -74,15 +57,12 @@ if (followingMonthDays < 0) {
     followingMonthDays += 7;
 }
 numDays += followingMonthDays;
-
-serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom, "numPeriods", numDays, "periodType", Calendar.DATE);
-serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType, "locale", locale, "timeZone", timeZone));
-if (entityExprList) {
-    serviceCtx.putAll(["entityExprList" : entityExprList]);
+Map serviceCtx = dispatcher.getDispatchContext().makeValidContext("getWorkEffortEventsByPeriod", "IN", parameters);
+serviceCtx.putAll(UtilMisc.toMap("userLogin", userLogin, "start", getFrom, "numPeriods", numDays, "periodType", Calendar.DATE, "locale", locale, "timeZone", timeZone));
+if (context.entityExprList) {
+    serviceCtx.entityExprList = entityExprList;
 }
-
 result = dispatcher.runSync("getWorkEffortEventsByPeriod", serviceCtx);
-
 context.put("periods",result.get("periods"));
 context.put("maxConcurrentEntries", result.get("maxConcurrentEntries"));
 context.put("start", start);

Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy?rev=1226325&r1=1226324&r2=1226325&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy (original)
+++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy Mon Jan  2 00:46:00 2012
@@ -18,53 +18,29 @@
  */
 
 import java.util.*;
-import org.ofbiz.security.*;
-import org.ofbiz.entity.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.webapp.pseudotag.*;
-import org.ofbiz.workeffort.workeffort.*;
 import java.sql.Timestamp;
+import org.ofbiz.base.util.*;
 
-String currentDay = parameters.currentDay;
 String startParam = parameters.start;
-
-facilityId = parameters.facilityId;
-fixedAssetId = parameters.fixedAssetId;
-partyId = parameters.partyId;
-workEffortTypeId = parameters.workEffortTypeId;
-calendarType = parameters.calendarType;
-entityExprList = (List) context.get("entityExprList");
-filterOutCanceledEvents = parameters.filterOutCanceledEvents;
-if (!filterOutCanceledEvents) {
-    filterOutCanceledEvents = Boolean.FALSE;
-}
-
 Timestamp start = null;
 if (UtilValidate.isNotEmpty(startParam)) {
     start = new Timestamp(Long.parseLong(startParam));
 }
-
 if (start == null) {
     start = UtilDateTime.getWeekStart(nowTimestamp, timeZone, locale);
 } else {
     start = UtilDateTime.getWeekStart(start, timeZone, locale);
 }
-
 Timestamp prev = UtilDateTime.getDayStart(start, -7, timeZone, locale);
 context.prevMillis = new Long(prev.getTime()).toString();
 Timestamp next = UtilDateTime.getDayStart(start, 7, timeZone, locale);
 context.nextMillis = new Long(next.getTime()).toString();
 Timestamp end = UtilDateTime.getDayStart(start, 6, timeZone, locale);
-
-Map serviceCtx = UtilMisc.toMap("userLogin", userLogin,"start",start,"numPeriods", 7,
-        "periodType", Calendar.DATE);
-serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId,
-        "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType,
-        "locale", locale, "timeZone", timeZone));
-if (entityExprList) {
-    serviceCtx.putAll(["entityExprList" : entityExprList]);
+Map serviceCtx = dispatcher.getDispatchContext().makeValidContext("getWorkEffortEventsByPeriod", "IN", parameters);
+serviceCtx.putAll(UtilMisc.toMap("userLogin", userLogin, "start", start, "numPeriods", 7, "periodType", Calendar.DATE, "locale", locale, "timeZone", timeZone));
+if (context.entityExprList) {
+    serviceCtx.entityExprList = entityExprList;
 }
-
 Map result = dispatcher.runSync("getWorkEffortEventsByPeriod",serviceCtx);
 context.put("periods",result.get("periods"));
 context.put("maxConcurrentEntries",result.get("maxConcurrentEntries"));