Author: lektran
Date: Sat Jul 7 22:14:10 2007
New Revision: 554314
URL: http://svn.apache.org/viewvc?view=rev&rev=554314
Log:
Applied fix from trunk for revision: 548384
Modified:
ofbiz/branches/release4.0/applications/workeffort/servicedef/services.xml
ofbiz/branches/release4.0/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/day.bsh
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/month.bsh
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/upcoming.bsh
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/week.bsh
Modified:
ofbiz/branches/release4.0/applications/workeffort/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/workeffort/servicedef/services.xml?view=diff&rev=554314&r1=554313&r2=554314
==============================================================================
--- ofbiz/branches/release4.0/applications/workeffort/servicedef/services.xml
(original)
+++ ofbiz/branches/release4.0/applications/workeffort/servicedef/services.xml
Sat Jul 7 22:14:10 2007
@@ -168,7 +168,8 @@
</service>
<service name="getWorkEffortEventsByPeriod" auth="true" engine="java"
location="org.ofbiz.workeffort.workeffort.WorkEffortServices"
invoke="getWorkEffortEventsByPeriod">
- <description>Get WorkEffort Events by a period spcified by
periodSeconds attribute. Return a Map with periodStart as the key and a
Collection of events for that period as value
+ <description>Get WorkEffort Events by a period specified by periodType
attribute (one of the
+ java.util.Calendar field values). Return a Map with periodStart as
the key and a Collection of events for that period as value
If filterOutCanceledEvents is set to Boolean(true) then workEfforts
with currentStatusId=EVENT_CANCELLED will not be returned.
To limit the events to a particular partyId, specify the partyId.
To limit the events to a set of partyIds, specify a Collection of partyIds.
</description>
@@ -178,7 +179,7 @@
<attribute name="fixedAssetId" type="String" mode="IN"
optional="true"/>
<attribute name="start" type="java.sql.Timestamp" mode="IN"
optional="false"/>
<attribute name="numPeriods" type="java.lang.Integer" mode="IN"
optional="false"/>
- <attribute name="periodSeconds" type="java.lang.Integer" mode="IN"
optional="false"/>
+ <attribute name="periodType" type="java.lang.Integer" mode="IN"
optional="false"/>
<attribute name="filterOutCanceledEvents" type="java.lang.Boolean"
mode="IN" optional="true"/>
<attribute name="periods" type="java.util.List" mode="OUT"
optional="false"/>
<attribute name="maxConcurrentEntries" type="java.lang.Integer"
mode="OUT" optional="false"/>
Modified:
ofbiz/branches/release4.0/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java?view=diff&rev=554314&r1=554313&r2=554314
==============================================================================
---
ofbiz/branches/release4.0/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java
(original)
+++
ofbiz/branches/release4.0/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java
Sat Jul 7 22:14:10 2007
@@ -27,8 +27,10 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.TimeZone;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
@@ -327,10 +329,10 @@
public static Map getWorkEffortEventsByPeriod(DispatchContext ctx, Map
context) {
Security security = ctx.getSecurity();
GenericValue userLogin = (GenericValue) context.get("userLogin");
+ Locale locale = (Locale) context.get("locale");
Timestamp startDay = (Timestamp) context.get("start");
Integer numPeriodsInteger = (Integer) context.get("numPeriods");
- Integer periodInteger = (Integer) context.get("periodSeconds");
String partyId = (String) context.get("partyId");
Collection partyIds = (Collection) context.get("partyIds");
@@ -344,16 +346,23 @@
//To be returned, the max concurrent entries for a single period
int maxConcurrentEntries = 0;
- long period = periodInteger.intValue()*1000;
+ TimeZone curTz = TimeZone.getDefault();
+
+ Integer periodTypeObject = (Integer) context.get("periodType");
+ int periodType = 0;
+ if (periodTypeObject != null) {
+ periodType = periodTypeObject.intValue();
+ }
int numPeriods = 0;
if(numPeriodsInteger != null) numPeriods =
numPeriodsInteger.intValue();
// get a timestamp (date) for the beginning of today and for beginning
of numDays+1 days from now
- Timestamp startStamp = UtilDateTime.getDayStart(startDay);
- Timestamp endStamp = new
Timestamp(startStamp.getTime()+(period*(numPeriods+1)));
+ Timestamp startStamp = UtilDateTime.getDayStart(startDay, curTz,
locale);
+ Timestamp endStamp = UtilDateTime.adjustTimestamp(startStamp,
periodType, 1, curTz, locale);
+ long periodLen = endStamp.getTime() - startStamp.getTime();
+ endStamp = UtilDateTime.adjustTimestamp(startStamp, periodType,
numPeriods, curTz, locale);
- startStamp.setNanos(0);
// Get the WorkEfforts
List validWorkEfforts = null;
Collection partyIdsToUse = partyIds;
@@ -386,8 +395,8 @@
// For each day in the set we check all work efforts to see if
they fall within range
for (int i = 0; i < numPeriods; i++) {
- Timestamp curPeriodStart = new
Timestamp(startStamp.getTime()+(i*period));
- Timestamp curPeriodEnd = new
Timestamp(curPeriodStart.getTime()+period);
+ Timestamp curPeriodStart =
UtilDateTime.adjustTimestamp(startStamp, periodType, i, curTz, locale);
+ Timestamp curPeriodEnd =
UtilDateTime.adjustTimestamp(curPeriodStart, periodType, 1, curTz, locale);
List curWorkEfforts = new ArrayList();
Map entry = new HashMap();
for (int j = 0; j < validWorkEfforts.size(); j++) {
@@ -407,7 +416,7 @@
calEntry.put("workEffort",workEffort);
long length =
((estimatedCompletionDate.after(endStamp) ? endStamp.getTime() :
estimatedCompletionDate.getTime()) - (estimatedStartDate.before(startStamp) ?
startStamp.getTime() : estimatedStartDate.getTime()));
- int periodSpan = (int) Math.ceil((double) length /
period);
+ int periodSpan = (int) Math.ceil((double) length /
periodLen);
calEntry.put("periodSpan", new Integer(periodSpan));
if(i == 0) calEntry.put("startOfPeriod",
Boolean.TRUE); //If this is the first priod any valid entry is starting here
Modified:
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/day.bsh
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/day.bsh?view=diff&rev=554314&r1=554313&r2=554314
==============================================================================
---
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/day.bsh
(original)
+++
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/day.bsh
Sat Jul 7 22:14:10 2007
@@ -55,7 +55,7 @@
Timestamp prev = UtilDateTime.getDayStart(start,-1);
Timestamp next = UtilDateTime.getDayStart(start,1);
-Map serviceCtx = UtilMisc.toMap("userLogin",
userLogin,"start",start,"numPeriods",new Integer(24),"periodSeconds",new
Integer(3600));
+Map serviceCtx = UtilMisc.toMap("userLogin",
userLogin,"start",start,"numPeriods",new Integer(24),"periodType",new
Integer(Calendar.HOUR));
serviceCtx.put("partyId", partyId);
serviceCtx.put("facilityId", facilityId);
serviceCtx.put("fixedAssetId", fixedAssetId);
Modified:
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/month.bsh
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/month.bsh?view=diff&rev=554314&r1=554313&r2=554314
==============================================================================
---
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/month.bsh
(original)
+++
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/month.bsh
Sat Jul 7 22:14:10 2007
@@ -70,7 +70,7 @@
numDays += prevMonthDays;
getFrom = new Timestamp(tempCal.getTime().getTime());
-serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start",
getFrom,"numPeriods", new Integer(numDays), "periodSeconds", new
Integer(3600*24));
+serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start",
getFrom,"numPeriods", new Integer(numDays), "periodType", new
Integer(Calendar.DATE));
serviceCtx.put("partyId", partyId);
serviceCtx.put("facilityId", facilityId);
serviceCtx.put("fixedAssetId", fixedAssetId);
Modified:
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/upcoming.bsh
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/upcoming.bsh?view=diff&rev=554314&r1=554313&r2=554314
==============================================================================
---
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/upcoming.bsh
(original)
+++
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/upcoming.bsh
Sat Jul 7 22:14:10 2007
@@ -39,7 +39,7 @@
eventsParam = "partyId=" + partyId;
}
-Map serviceCtx = UtilMisc.toMap("userLogin", userLogin,"start",
start,"numPeriods",new Integer(7),"periodSeconds",new Integer(3600*24));
+Map serviceCtx = UtilMisc.toMap("userLogin", userLogin,"start",
start,"numPeriods",new Integer(7),"periodType",new Integer(Calendar.DATE));
serviceCtx.put("partyId", partyId);
serviceCtx.put("facilityId", facilityId);
serviceCtx.put("fixedAssetId", fixedAssetId);
Modified:
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/week.bsh
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/week.bsh?view=diff&rev=554314&r1=554313&r2=554314
==============================================================================
---
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/week.bsh
(original)
+++
ofbiz/branches/release4.0/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/week.bsh
Sat Jul 7 22:14:10 2007
@@ -58,7 +58,7 @@
Timestamp next = UtilDateTime.getDayStart(start,7);
Timestamp end = UtilDateTime.getDayStart(start,6);
-Map serviceCtx = UtilMisc.toMap("userLogin",
userLogin,"start",start,"numPeriods",new Integer(7),"periodSeconds",new
Integer(3600*24));
+Map serviceCtx = UtilMisc.toMap("userLogin",
userLogin,"start",start,"numPeriods",new Integer(7),"periodType",new
Integer(Calendar.DATE));
serviceCtx.put("partyId", partyId);
serviceCtx.put("facilityId", facilityId);
serviceCtx.put("fixedAssetId", fixedAssetId);