In the calendars screen, selecting the proper facility you should see the work effort associated to the production run;
if you select the proper fixed asset you should see the task.
*/
Delegator delegator = ctx.getDelegator();
Security security = ctx.getSecurity();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
TimeZone timeZone = (TimeZone) context.get("timeZone");
Timestamp startDay = (Timestamp) context.get("start");
Integer numPeriodsInteger = (Integer) context.get("numPeriods");
String calendarType = (String) context.get("calendarType");
if (UtilValidate.isEmpty(calendarType)) {
calendarType = "CAL_PERSONAL";
}
String partyId = (String) context.get("partyId");
Collection<String> partyIds = UtilGenerics.checkCollection(context.get("partyIds"));
String facilityId = (String) context.get("facilityId");
String fixedAssetId = (String) context.get("fixedAssetId");
// Debug.logInfo("======by period for fixedAsset: " + fixedAssetId + " facilityId: " + facilityId + "partyId: " + partyId + " entityExprList:" + (List) context.get("entityExprList"));
String workEffortTypeId = (String) context.get("workEffortTypeId");
Boolean filterOutCanceledEvents = (Boolean) context.get("filterOutCanceledEvents");
if (filterOutCanceledEvents == null) {
filterOutCanceledEvents = Boolean.FALSE;
}
// To be returned, the max concurrent entries for a single period
int maxConcurrentEntries = 0;
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, timeZone, locale);
Timestamp endStamp = UtilDateTime.adjustTimestamp(startStamp, periodType, 1, timeZone, locale);
long periodLen = endStamp.getTime() - startStamp.getTime();
endStamp = UtilDateTime.adjustTimestamp(startStamp, periodType, numPeriods, timeZone, locale);
// Get the WorkEfforts
List<GenericValue> validWorkEfforts = null;
Collection<String> partyIdsToUse = partyIds;
if (partyIdsToUse == null) {
partyIdsToUse = FastSet.newInstance();
}
if (UtilValidate.isNotEmpty(partyId)) {
if (partyId.equals(userLogin.getString("partyId")) || security.hasEntityPermission("WORKEFFORTMGR", "_VIEW", userLogin)) {
partyIdsToUse.add(partyId);
} else {
return ServiceUtil.returnError("You do not have permission to view information for party with ID [" + partyId + "], you must be logged in as a user associated with this party, or have the WORKEFFORTMGR_VIEW or WORKEFFORTMGR_ADMIN permissions.");
}
} else {