Modified: ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditDailyHourReport.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditDailyHourReport.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditDailyHourReport.groovy (original) +++ ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditDailyHourReport.groovy Wed Nov 2 19:09:13 2016 @@ -17,420 +17,420 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -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.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.webapp.website.WebSiteWorker; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +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.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.webapp.website.WebSiteWorker +import java.sql.Timestamp -uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale); -partyId = parameters.partyId; +uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale) +partyId = parameters.partyId if (!partyId) { - partyId = parameters.userLogin.partyId; + partyId = parameters.userLogin.partyId } // show the requested timesheet, otherwise the current , if not exist create -timesheet = null; -timesheetId = parameters.timesheetId; +timesheet = null +timesheetId = parameters.timesheetId if (timesheetId) { - timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne(); - partyId = timesheet.partyId; // use the party from this timesheet + timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne() + partyId = timesheet.partyId // use the party from this timesheet } else { // make sure because of timezone changes, not a duplicate timesheet is created - midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3); + midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3) entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("fromDate", EntityComparisonOperator.LESS_THAN, midweek), EntityCondition.makeCondition("thruDate", EntityComparisonOperator.GREATER_THAN, midweek), EntityCondition.makeCondition("partyId", EntityComparisonOperator.EQUALS, partyId) - ], EntityOperator.AND); - entryIterator = from("Timesheet").where(entryExprs).queryIterator(); - timesheet = entryIterator.next(); - entryIterator.close(); + ], EntityOperator.AND) + entryIterator = from("Timesheet").where(entryExprs).queryIterator() + timesheet = entryIterator.next() + entryIterator.close() if (timesheet == null) { - result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]); + result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]) if (result && result.timesheetId) { - timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne(); + timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne() } } } -if (!timesheet) return; -context.timesheet = timesheet; -context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate); +if (!timesheet) return +context.timesheet = timesheet +context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate) // get the user names -context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne(); +context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne() // get the default rate for this person -rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList(); +rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList() if (rateTypes) { - context.defaultRateTypeId = rateTypes[0].rateTypeId; + context.defaultRateTypeId = rateTypes[0].rateTypeId } -entries = []; -entry = ["timesheetId" : timesheet.timesheetId]; -leaveEntry = ["timesheetId" : timesheet.timesheetId]; -taskTotal = 0.00; -planTotal = 0.00; -leaveTaskTotal = 0.00; -leavePlanTotal = 0.00; -day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00; -pDay0Total = 0.00; pDay1Total=0.00; pDay2Total=0.00; pDay3Total=0.00; pDay4Total=0.00; pDay5Total=0.00; pDay6Total=0.00; -pHours = 0.00; -timeEntry = null; -lastTimeEntry = null; -emplLeaveEntry = null; -lastEmplLeaveEntry = null; +entries = [] +entry = ["timesheetId" : timesheet.timesheetId] +leaveEntry = ["timesheetId" : timesheet.timesheetId] +taskTotal = 0.00 +planTotal = 0.00 +leaveTaskTotal = 0.00 +leavePlanTotal = 0.00 +day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00 +pDay0Total = 0.00; pDay1Total=0.00; pDay2Total=0.00; pDay3Total=0.00; pDay4Total=0.00; pDay5Total=0.00; pDay6Total=0.00 +pHours = 0.00 +timeEntry = null +lastTimeEntry = null +emplLeaveEntry = null +lastEmplLeaveEntry = null // retrieve work effort data when the workeffortId has changed. void retrieveWorkEffortData() { // get the planned number of hours - entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false); + entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false) if (entryWorkEffort) { - plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false); - pHours = 0.00; + plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false) + pHours = 0.00 plannedHours.each { plannedHour -> if (plannedHour.estimatedDuration) { - pHours += plannedHour.estimatedDuration; + pHours += plannedHour.estimatedDuration } } - estimatedHour = 0.00; + estimatedHour = 0.00 estimatedMilliSeconds = entryWorkEffort.estimatedMilliSeconds if (estimatedMilliSeconds > 0) - estimatedHour = estimatedMilliSeconds/3600000; - entry.plannedHours = estimatedHour; - //entry.plannedHours = pHours; - planHours = 0.0; - planHours = lastTimeEntry.planHours; - lastTimeEntryOfTasks = from("TimeEntry").where("workEffortId", lastTimeEntry.workEffortId, "partyId", partyId).orderBy("-fromDate").queryList(); - if (lastTimeEntryOfTasks.size() != 0) lastTimeEntry = lastTimeEntryOfTasks[0]; + estimatedHour = estimatedMilliSeconds/3600000 + entry.plannedHours = estimatedHour + //entry.plannedHours = pHours + planHours = 0.0 + planHours = lastTimeEntry.planHours + lastTimeEntryOfTasks = from("TimeEntry").where("workEffortId", lastTimeEntry.workEffortId, "partyId", partyId).orderBy("-fromDate").queryList() + if (lastTimeEntryOfTasks.size() != 0) lastTimeEntry = lastTimeEntryOfTasks[0] if (planHours < 1) { - planHours = estimatedHour; + planHours = estimatedHour } - entry.planHours = lastTimeEntry.planHours; - actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false); - aHours = 0.00; + entry.planHours = lastTimeEntry.planHours + actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false) + aHours = 0.00 actualHours.each { actualHour -> if (actualHour.hours) { - aHours += actualHour.hours; + aHours += actualHour.hours } } - entry.actualHours = aHours; + entry.actualHours = aHours // get party assignment data to be able to set the task to complete - workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)); + workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)) if (workEffortPartyAssigns) { - workEffortPartyAssign = workEffortPartyAssigns[0]; - entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate"); - entry.roleTypeId = workEffortPartyAssign.roleTypeId; + workEffortPartyAssign = workEffortPartyAssigns[0] + entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate") + entry.roleTypeId = workEffortPartyAssign.roleTypeId if ("SCAS_COMPLETED".equals(workEffortPartyAssign.statusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } else { if ("STS_COMPLETED".equals(entryWorkEffort.currentStatusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } // get project/phase information - entry.workEffortId = entryWorkEffort.workEffortId; - entry.workEffortName = entryWorkEffort.workEffortName; - result = runService('getProjectInfoFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]); - entry.phaseId = result.phaseId; - entry.phaseName = result.phaseName; - entry.projectId = result.projectId; - entry.projectName = result.projectName; - entry.taskWbsId = result.taskWbsId; + entry.workEffortId = entryWorkEffort.workEffortId + entry.workEffortName = entryWorkEffort.workEffortName + result = runService('getProjectInfoFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]) + entry.phaseId = result.phaseId + entry.phaseName = result.phaseName + entry.projectId = result.projectId + entry.projectName = result.projectName + entry.taskWbsId = result.taskWbsId } - entry.acualTotal = taskTotal; - entry.planTotal = planTotal; + entry.acualTotal = taskTotal + entry.planTotal = planTotal //Drop Down Lists if (entry.checkComplete != "Y") { if (aHours > 0.00) - entries.add(entry); + entries.add(entry) } else { - entries.add(entry); + entries.add(entry) } // start new entry - taskTotal = 0.00; - planTotal = 0.00; - entry = ["timesheetId" : timesheet.timesheetId]; + taskTotal = 0.00 + planTotal = 0.00 + entry = ["timesheetId" : timesheet.timesheetId] } -timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false); -te = timeEntries.iterator(); +timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false) +te = timeEntries.iterator() while (te.hasNext()) { // only fill lastTimeEntry when not the first time if (timeEntry!=void) { - lastTimeEntry = timeEntry; + lastTimeEntry = timeEntry } - timeEntry = te.next(); + timeEntry = te.next() if (lastTimeEntry && (!lastTimeEntry.workEffortId.equals(timeEntry.workEffortId) || !lastTimeEntry.rateTypeId.equals(timeEntry.rateTypeId))) { - retrieveWorkEffortData(); + retrieveWorkEffortData() } if (timeEntry.hours) { - dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - hours = timeEntry.hours.doubleValue(); - entry.put(String.valueOf(dayNumber), hours); - if (dayNumber.equals("d0")) day0Total += hours; - if (dayNumber.equals("d1")) day1Total += hours; - if (dayNumber.equals("d2")) day2Total += hours; - if (dayNumber.equals("d3")) day3Total += hours; - if (dayNumber.equals("d4")) day4Total += hours; - if (dayNumber.equals("d5")) day5Total += hours; - if (dayNumber.equals("d6")) day6Total += hours; - taskTotal += hours; + dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + hours = timeEntry.hours.doubleValue() + entry.put(String.valueOf(dayNumber), hours) + if (dayNumber.equals("d0")) day0Total += hours + if (dayNumber.equals("d1")) day1Total += hours + if (dayNumber.equals("d2")) day2Total += hours + if (dayNumber.equals("d3")) day3Total += hours + if (dayNumber.equals("d4")) day4Total += hours + if (dayNumber.equals("d5")) day5Total += hours + if (dayNumber.equals("d6")) day6Total += hours + taskTotal += hours } if (timeEntry.planHours) { - dayNumber = "pd" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - planHours = timeEntry.planHours.doubleValue(); - entry.put(String.valueOf(dayNumber), planHours); - if (dayNumber.equals("pd0")) pDay0Total += planHours; - if (dayNumber.equals("pd1")) pDay1Total += planHours; - if (dayNumber.equals("pd2")) pDay2Total += planHours; - if (dayNumber.equals("pd3")) pDay3Total += planHours; - if (dayNumber.equals("pd4")) pDay4Total += planHours; - if (dayNumber.equals("pd5")) pDay5Total += planHours; - if (dayNumber.equals("pd6")) pDay6Total += planHours; - planTotal += planHours; + dayNumber = "pd" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + planHours = timeEntry.planHours.doubleValue() + entry.put(String.valueOf(dayNumber), planHours) + if (dayNumber.equals("pd0")) pDay0Total += planHours + if (dayNumber.equals("pd1")) pDay1Total += planHours + if (dayNumber.equals("pd2")) pDay2Total += planHours + if (dayNumber.equals("pd3")) pDay3Total += planHours + if (dayNumber.equals("pd4")) pDay4Total += planHours + if (dayNumber.equals("pd5")) pDay5Total += planHours + if (dayNumber.equals("pd6")) pDay6Total += planHours + planTotal += planHours } - entry.rateTypeId = timeEntry.rateTypeId; + entry.rateTypeId = timeEntry.rateTypeId } //retrieve Empl Leave data. void retrieveEmplLeaveData() { if (lastEmplLeaveEntry) { //service get Hours result = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": lastEmplLeaveEntry.partyId, "leaveTypeId": lastEmplLeaveEntry.leaveTypeId, "fromDate": lastEmplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": lastEmplLeaveEntry.partyId, "leaveTypeId": lastEmplLeaveEntry.leaveTypeId, "fromDate": lastEmplLeaveEntry.fromDate]) if (result.hours) { - leaveEntry.plannedHours = result.hours; - leaveEntry.planHours = result.hours; + leaveEntry.plannedHours = result.hours + leaveEntry.planHours = result.hours } if (lastEmplLeaveEntry.leaveStatus == "LEAVE_APPROVED") { - leaveEntry.checkComplete = "Y"; + leaveEntry.checkComplete = "Y" } - leaveEntry.partyId = lastEmplLeaveEntry.partyId; - leaveEntry.leaveTypeId = lastEmplLeaveEntry.leaveTypeId; - leaveEntry.leavefromDate = lastEmplLeaveEntry.fromDate; - leaveEntry.leavethruDate = lastEmplLeaveEntry.thruDate; - leaveEntry.description = lastEmplLeaveEntry.description; + leaveEntry.partyId = lastEmplLeaveEntry.partyId + leaveEntry.leaveTypeId = lastEmplLeaveEntry.leaveTypeId + leaveEntry.leavefromDate = lastEmplLeaveEntry.fromDate + leaveEntry.leavethruDate = lastEmplLeaveEntry.thruDate + leaveEntry.description = lastEmplLeaveEntry.description } - leaveEntry.acualTotal = leaveTaskTotal; - leaveEntry.planHours = leavePlanTotal; - leaveEntry.actualHours = leaveTaskTotal; + leaveEntry.acualTotal = leaveTaskTotal + leaveEntry.planHours = leavePlanTotal + leaveEntry.actualHours = leaveTaskTotal //Drop Down Lists - entries.add(leaveEntry); + entries.add(leaveEntry) // start new leaveEntry - leaveTaskTotal = 0.00; - leavePlanTotal = 0.00; - leaveEntry = ["timesheetId" : timesheet.timesheetId]; + leaveTaskTotal = 0.00 + leavePlanTotal = 0.00 + leaveEntry = ["timesheetId" : timesheet.timesheetId] } // define condition -leaveExprs = []; -leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheet.fromDate)); -leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheet.thruDate)); -leaveExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); -emplLeave = from("EmplLeave").where(leaveExprs).cursorScrollInsensitive().distinct().queryIterator(); +leaveExprs = [] +leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheet.fromDate)) +leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheet.thruDate)) +leaveExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) +emplLeave = from("EmplLeave").where(leaveExprs).cursorScrollInsensitive().distinct().queryIterator() while ((emplLeaveMap = emplLeave.next())) { if (emplLeaveEntry!=void) { - lastEmplLeaveEntry = emplLeaveEntry; + lastEmplLeaveEntry = emplLeaveEntry } - emplLeaveEntry = emplLeaveMap; + emplLeaveEntry = emplLeaveMap if (lastEmplLeaveEntry && ( !lastEmplLeaveEntry.leaveTypeId.equals(emplLeaveEntry.leaveTypeId) || !lastEmplLeaveEntry.partyId.equals(emplLeaveEntry.partyId))) { - retrieveEmplLeaveData(); + retrieveEmplLeaveData() } resultHours = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) if (resultHours.hours) { - leaveDayNumber = "d" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); + leaveDayNumber = "d" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) resultHours = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); - leaveHours = resultHours.hours.doubleValue(); - leaveEntry.put(String.valueOf(leaveDayNumber), leaveHours); - if (leaveDayNumber.equals("d0")) day0Total += leaveHours; - if (leaveDayNumber.equals("d1")) day1Total += leaveHours; - if (leaveDayNumber.equals("d2")) day2Total += leaveHours; - if (leaveDayNumber.equals("d3")) day3Total += leaveHours; - if (leaveDayNumber.equals("d4")) day4Total += leaveHours; - if (leaveDayNumber.equals("d5")) day5Total += leaveHours; - if (leaveDayNumber.equals("d6")) day6Total += leaveHours; - leaveTaskTotal += leaveHours; + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) + leaveHours = resultHours.hours.doubleValue() + leaveEntry.put(String.valueOf(leaveDayNumber), leaveHours) + if (leaveDayNumber.equals("d0")) day0Total += leaveHours + if (leaveDayNumber.equals("d1")) day1Total += leaveHours + if (leaveDayNumber.equals("d2")) day2Total += leaveHours + if (leaveDayNumber.equals("d3")) day3Total += leaveHours + if (leaveDayNumber.equals("d4")) day4Total += leaveHours + if (leaveDayNumber.equals("d5")) day5Total += leaveHours + if (leaveDayNumber.equals("d6")) day6Total += leaveHours + leaveTaskTotal += leaveHours } if (resultHours.hours) { - leavePlanDay = "pd" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); + leavePlanDay = "pd" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) resultPlanHours = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); - leavePlanHours = resultPlanHours.hours.doubleValue(); - leaveEntry.put(String.valueOf(leavePlanDay), leavePlanHours); - if (leavePlanDay.equals("pd0")) pDay0Total += leavePlanHours; - if (leavePlanDay.equals("pd1")) pDay1Total += leavePlanHours; - if (leavePlanDay.equals("pd2")) pDay2Total += leavePlanHours; - if (leavePlanDay.equals("pd3")) pDay3Total += leavePlanHours; - if (leavePlanDay.equals("pd4")) pDay4Total += leavePlanHours; - if (leavePlanDay.equals("pd5")) pDay5Total += leavePlanHours; - if (leavePlanDay.equals("pd6")) pDay6Total += leavePlanHours; - leavePlanTotal += leavePlanHours; + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) + leavePlanHours = resultPlanHours.hours.doubleValue() + leaveEntry.put(String.valueOf(leavePlanDay), leavePlanHours) + if (leavePlanDay.equals("pd0")) pDay0Total += leavePlanHours + if (leavePlanDay.equals("pd1")) pDay1Total += leavePlanHours + if (leavePlanDay.equals("pd2")) pDay2Total += leavePlanHours + if (leavePlanDay.equals("pd3")) pDay3Total += leavePlanHours + if (leavePlanDay.equals("pd4")) pDay4Total += leavePlanHours + if (leavePlanDay.equals("pd5")) pDay5Total += leavePlanHours + if (leavePlanDay.equals("pd6")) pDay6Total += leavePlanHours + leavePlanTotal += leavePlanHours } - leaveEntry.rateTypeId = "STANDARD"; + leaveEntry.rateTypeId = "STANDARD" } -emplLeave.close(); +emplLeave.close() if (timeEntry) { - lastTimeEntry = timeEntry; - retrieveWorkEffortData(); + lastTimeEntry = timeEntry + retrieveWorkEffortData() } if (emplLeaveEntry) { - lastEmplLeaveEntry = emplLeaveEntry; - retrieveEmplLeaveData(); + lastEmplLeaveEntry = emplLeaveEntry + retrieveEmplLeaveData() } // add empty lines if timesheet not completed if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) { for (c=0; c < 3; c++) { // add empty lines - entries.add(["timesheetId" : timesheet.timesheetId]); + entries.add(["timesheetId" : timesheet.timesheetId]) } } // add the totals line if at least one entry if (timeEntry || emplLeaveEntry) { - entry = ["timesheetId" : timesheet.timesheetId]; - entry.d0 = day0Total; - entry.d1 = day1Total; - entry.d2 = day2Total; - entry.d3 = day3Total; - entry.d4 = day4Total; - entry.d5 = day5Total; - entry.d6 = day6Total; - entry.pd0 = pDay0Total; - entry.pd1 = pDay1Total; - entry.pd2 = pDay2Total; - entry.pd3 = pDay3Total; - entry.pd4 = pDay4Total; - entry.pd5 = pDay5Total; - entry.pd6 = pDay6Total; - entry.phaseName = uiLabelMap.ScrumTotals; - entry.workEffortId = "Totals"; - entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total; - entries.add(entry); + entry = ["timesheetId" : timesheet.timesheetId] + entry.d0 = day0Total + entry.d1 = day1Total + entry.d2 = day2Total + entry.d3 = day3Total + entry.d4 = day4Total + entry.d5 = day5Total + entry.d6 = day6Total + entry.pd0 = pDay0Total + entry.pd1 = pDay1Total + entry.pd2 = pDay2Total + entry.pd3 = pDay3Total + entry.pd4 = pDay4Total + entry.pd5 = pDay5Total + entry.pd6 = pDay6Total + entry.phaseName = uiLabelMap.ScrumTotals + entry.workEffortId = "Totals" + entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total + entries.add(entry) } -context.timeEntries = entries; +context.timeEntries = entries // get all timesheets of this user, including the planned hours -timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList(); -timesheets = new LinkedList(); +timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList() +timesheets = new LinkedList() timesheetsDb.each { timesheetDb -> - //get hours from EmplLeave; - findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - leaveExprsList = []; - leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheetDb.fromDate)); - leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheetDb.thruDate)); - leaveExprsList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); - emplLeaveList = from("EmplLeave").where(leaveExprsList).cursorScrollInsensitive().distinct().queryIterator(); - leaveHours = 0.00; + //get hours from EmplLeave + findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true) + leaveExprsList = [] + leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheetDb.fromDate)) + leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheetDb.thruDate)) + leaveExprsList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) + emplLeaveList = from("EmplLeave").where(leaveExprsList).cursorScrollInsensitive().distinct().queryIterator() + leaveHours = 0.00 while ((emplLeaveMap = emplLeaveList.next())) { - emplLeaveEntry = emplLeaveMap; + emplLeaveEntry = emplLeaveMap resultHour = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) if (resultHour) { - leaveActualHours = resultHour.hours.doubleValue(); - leaveHours += leaveActualHours; + leaveActualHours = resultHour.hours.doubleValue() + leaveHours += leaveActualHours } } - //get hours from TimeEntry; - timesheet = [:]; - timesheet.putAll(timesheetDb); - entries = timesheetDb.getRelated("TimeEntry", null, null, false); - hours = 0.00; + //get hours from TimeEntry + timesheet = [:] + timesheet.putAll(timesheetDb) + entries = timesheetDb.getRelated("TimeEntry", null, null, false) + hours = 0.00 entries.each { timeEntry -> if (timeEntry.hours) { - hours += timeEntry.hours.doubleValue(); + hours += timeEntry.hours.doubleValue() } } - timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate); - timesheet.hours = hours + leaveHours; - timesheets.add(timesheet); - emplLeaveList.close(); + timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate) + timesheet.hours = hours + leaveHours + timesheets.add(timesheet) + emplLeaveList.close() } -context.timesheets = timesheets; +context.timesheets = timesheets // get existing task that no assign -taskList=[]; -projectSprintBacklogAndTaskList = []; -backlogIndexList = []; -projectAndTaskList = from("ProjectSprintBacklogAndTask").where("sprintTypeId" : "SCRUM_SPRINT","taskCurrentStatusId" : "STS_CREATED").orderBy("projectName ASC","taskActualStartDate DESC").queryList(); +taskList=[] +projectSprintBacklogAndTaskList = [] +backlogIndexList = [] +projectAndTaskList = from("ProjectSprintBacklogAndTask").where("sprintTypeId" : "SCRUM_SPRINT","taskCurrentStatusId" : "STS_CREATED").orderBy("projectName ASC","taskActualStartDate DESC").queryList() projectAndTaskList.each { projectAndTaskMap -> -userLoginId = userLogin.partyId; - sprintId = projectAndTaskMap.sprintId; - workEffortList = from("WorkEffortAndProduct").where("workEffortId", projectAndTaskMap.projectId).queryList(); - backlogIndexList.add(workEffortList[0].productId); +userLoginId = userLogin.partyId + sprintId = projectAndTaskMap.sprintId + workEffortList = from("WorkEffortAndProduct").where("workEffortId", projectAndTaskMap.projectId).queryList() + backlogIndexList.add(workEffortList[0].productId) - partyAssignmentSprintList = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLoginId).queryList(); - partyAssignmentSprintMap = partyAssignmentSprintList[0]; + partyAssignmentSprintList = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLoginId).queryList() + partyAssignmentSprintMap = partyAssignmentSprintList[0] // if this userLoginId is a member of sprint if (partyAssignmentSprintMap) { - workEffortId = projectAndTaskMap.taskId; - partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList(); - partyAssignmentTaskMap = partyAssignmentTaskList[0]; + workEffortId = projectAndTaskMap.taskId + partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList() + partyAssignmentTaskMap = partyAssignmentTaskList[0] // if the task do not assigned if (partyAssignmentTaskMap) { - custRequestTypeId = projectAndTaskMap.custRequestTypeId; - backlogStatusId = projectAndTaskMap.backlogStatusId; + custRequestTypeId = projectAndTaskMap.custRequestTypeId + backlogStatusId = projectAndTaskMap.backlogStatusId if (custRequestTypeId.equals("RF_SCRUM_MEETINGS") && backlogStatusId.equals("CRQ_REVIEWED")) { - projectSprintBacklogAndTaskList.add(projectAndTaskMap); + projectSprintBacklogAndTaskList.add(projectAndTaskMap) } } else { - projectSprintBacklogAndTaskList.add(0,projectAndTaskMap); + projectSprintBacklogAndTaskList.add(0,projectAndTaskMap) } } } // for unplanned taks. -unplanList=[]; +unplanList=[] if (backlogIndexList) { - backlogIndex = new HashSet(backlogIndexList); - custRequestList = from("CustRequest").where("custRequestTypeId", "RF_UNPLAN_BACKLOG","statusId", "CRQ_REVIEWED").orderBy("custRequestDate DESC").queryList(); + backlogIndex = new HashSet(backlogIndexList) + custRequestList = from("CustRequest").where("custRequestTypeId", "RF_UNPLAN_BACKLOG","statusId", "CRQ_REVIEWED").orderBy("custRequestDate DESC").queryList() if (custRequestList) { custRequestList.each { custRequestMap -> - custRequestItemList = custRequestMap.getRelated("CustRequestItem", null, null, false); + custRequestItemList = custRequestMap.getRelated("CustRequestItem", null, null, false) custRequestItem = - productOut = custRequestItemList[0].productId; - product = from("Product").where("productId", productOut).queryOne(); + productOut = custRequestItemList[0].productId + product = from("Product").where("productId", productOut).queryOne() backlogIndex.each { backlogProduct -> productId = backlogProduct if (productId.equals(productOut)) { - custRequestWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", custRequestItemList[0].custRequestId).queryList(); + custRequestWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", custRequestItemList[0].custRequestId).queryList() custRequestWorkEffortList.each { custRequestWorkEffortMap -> - partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryList(); - partyAssignmentTaskMap = partyAssignmentTaskList[0]; + partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryList() + partyAssignmentTaskMap = partyAssignmentTaskList[0] // if the task do not assigned if (!partyAssignmentTaskMap) { - result = [:]; - workEffortMap = from("WorkEffort").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryOne(); - result.description = custRequestMap.description; - result.productName = product.internalName; - result.taskId = workEffortMap.workEffortId; - result.taskName = workEffortMap.workEffortName; - result.custRequestTypeId = custRequestMap.custRequestTypeId; - result.taskTypeId = workEffortMap.workEffortTypeId; - unplanList.add(result); + result = [:] + workEffortMap = from("WorkEffort").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryOne() + result.description = custRequestMap.description + result.productName = product.internalName + result.taskId = workEffortMap.workEffortId + result.taskName = workEffortMap.workEffortName + result.custRequestTypeId = custRequestMap.custRequestTypeId + result.taskTypeId = workEffortMap.workEffortTypeId + unplanList.add(result) } } } @@ -438,26 +438,26 @@ if (backlogIndexList) { } } } -projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["projectName","sprintName","-taskTypeId","custRequestId"]); +projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["projectName","sprintName","-taskTypeId","custRequestId"]) projectSprintBacklogAndTaskList.each { projectSprintBacklogAndTaskMap -> - blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId; + blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId if (blTypeId == "RF_SCRUM_MEETINGS"){ - taskList.add(projectSprintBacklogAndTaskMap); + taskList.add(projectSprintBacklogAndTaskMap) } } -projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["-projectName","sprintName","-taskTypeId","custRequestId"]); +projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["-projectName","sprintName","-taskTypeId","custRequestId"]) projectSprintBacklogAndTaskList.each { projectSprintBacklogAndTaskMap -> - blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId; + blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId if (blTypeId == "RF_PROD_BACKLOG"){ - taskList.add(0,projectSprintBacklogAndTaskMap); + taskList.add(0,projectSprintBacklogAndTaskMap) } } -unplanList = UtilMisc.sortMaps(unplanList,["-productName","-taskTypeId","custRequestId"]); +unplanList = UtilMisc.sortMaps(unplanList,["-productName","-taskTypeId","custRequestId"]) unplanList.each { unplanMap-> - taskList.add(0,unplanMap); + taskList.add(0,unplanMap) } -context.taskList = taskList; +context.taskList = taskList // notification context -webSiteId = WebSiteWorker.getWebSiteId(request); -context.webSiteId = webSiteId; +webSiteId = WebSiteWorker.getWebSiteId(request) +context.webSiteId = webSiteId Modified: ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditWeekTimesheet.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditWeekTimesheet.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditWeekTimesheet.groovy (original) +++ ofbiz/trunk/specialpurpose/scrum/groovyScripts/EditWeekTimesheet.groovy Wed Nov 2 19:09:13 2016 @@ -17,192 +17,192 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale); +uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale) -partyId = parameters.partyId; +partyId = parameters.partyId if (!partyId) { - partyId = parameters.userLogin.partyId; + partyId = parameters.userLogin.partyId } // show the requested timesheet, otherwise the current , if not exist create -timesheet = null; -timesheetId = parameters.timesheetId; +timesheet = null +timesheetId = parameters.timesheetId if (timesheetId) { - timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne(); - partyId = timesheet.partyId; // use the party from this timesheet + timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne() + partyId = timesheet.partyId // use the party from this timesheet } else { // make sure because of timezone changes, not a duplicate timesheet is created - midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3); + midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3) entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("fromDate", EntityComparisonOperator.LESS_THAN, midweek), EntityCondition.makeCondition("thruDate", EntityComparisonOperator.GREATER_THAN, midweek), EntityCondition.makeCondition("partyId", EntityComparisonOperator.EQUALS, partyId) - ], EntityOperator.AND); - entryIterator = from("Timesheet").where(entryExprs).queryIterator(); - timesheet = entryIterator.next(); - entryIterator.close(); + ], EntityOperator.AND) + entryIterator = from("Timesheet").where(entryExprs).queryIterator() + timesheet = entryIterator.next() + entryIterator.close() if (timesheet == null) { - result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]); + result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]) if (result && result.timesheetId) { - timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne(); + timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne() } } } -if (!timesheet) return; -context.timesheet = timesheet; -context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate); +if (!timesheet) return +context.timesheet = timesheet +context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate) // get the user names -context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne(); +context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne() // get the default rate for this person -rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList(); +rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList() if (rateTypes) { - context.defaultRateTypeId = rateTypes[0].rateTypeId; + context.defaultRateTypeId = rateTypes[0].rateTypeId } -entries = []; -entry = ["timesheetId" : timesheet.timesheetId]; -taskTotal = 0.00; -day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00; -pHours = 0.00; -timeEntry = null; -lastTimeEntry = null; +entries = [] +entry = ["timesheetId" : timesheet.timesheetId] +taskTotal = 0.00 +day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00 +pHours = 0.00 +timeEntry = null +lastTimeEntry = null // retrieve work effort data when the workeffortId has changed. void retrieveWorkEffortData() { // get the planned number of hours - entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false); + entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false) if (entryWorkEffort) { - plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false); - pHours = 0.00; + plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false) + pHours = 0.00 plannedHours.each { plannedHour -> if (plannedHour.estimatedDuration) { - pHours += plannedHour.estimatedDuration; + pHours += plannedHour.estimatedDuration } } - entry.plannedHours = pHours; - actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false); - aHours = 0.00; + entry.plannedHours = pHours + actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false) + aHours = 0.00 actualHours.each { actualHour -> if (actualHour.hours) { - aHours += actualHour.hours; + aHours += actualHour.hours } } - entry.actualHours = aHours; + entry.actualHours = aHours // get party assignment data to be able to set the task to complete - workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)); + workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)) if (workEffortPartyAssigns) { - workEffortPartyAssign = workEffortPartyAssigns[0]; - entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate"); - entry.roleTypeId = workEffortPartyAssign.roleTypeId; + workEffortPartyAssign = workEffortPartyAssigns[0] + entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate") + entry.roleTypeId = workEffortPartyAssign.roleTypeId if ("PAS_COMPLETED".equals(workEffortPartyAssign.statusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } // get project/phase information - entry.workEffortId = entryWorkEffort.workEffortId; - entry.workEffortName = entryWorkEffort.workEffortName; - result = runService('getProjectIdAndNameFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]); - entry.sprintId = result.phaseId; - entry.sprintName = result.phaseName; - entry.projectId = result.projectId; - entry.projectName = result.projectName; - entry.taskWbsId = result.taskWbsId; + entry.workEffortId = entryWorkEffort.workEffortId + entry.workEffortName = entryWorkEffort.workEffortName + result = runService('getProjectIdAndNameFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]) + entry.sprintId = result.phaseId + entry.sprintName = result.phaseName + entry.projectId = result.projectId + entry.projectName = result.projectName + entry.taskWbsId = result.taskWbsId } - entry.total = taskTotal; + entry.total = taskTotal //Drop Down Lists - entries.add(entry); + entries.add(entry) // start new entry - taskTotal = 0.00; - entry = ["timesheetId" : timesheet.timesheetId]; + taskTotal = 0.00 + entry = ["timesheetId" : timesheet.timesheetId] } -timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false); -te = timeEntries.iterator(); +timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false) +te = timeEntries.iterator() while (te.hasNext()) { // only fill lastTimeEntry when not the first time if (timeEntry!=void) { - lastTimeEntry = timeEntry; + lastTimeEntry = timeEntry } - timeEntry = te.next(); + timeEntry = te.next() if (lastTimeEntry && (!lastTimeEntry.workEffortId.equals(timeEntry.workEffortId) || !lastTimeEntry.rateTypeId.equals(timeEntry.rateTypeId))) { - retrieveWorkEffortData(); + retrieveWorkEffortData() } if (timeEntry.hours) { - dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - hours = timeEntry.hours.doubleValue(); - entry.put(String.valueOf(dayNumber), hours); - if (dayNumber.equals("d0")) day0Total += hours; - if (dayNumber.equals("d1")) day1Total += hours; - if (dayNumber.equals("d2")) day2Total += hours; - if (dayNumber.equals("d3")) day3Total += hours; - if (dayNumber.equals("d4")) day4Total += hours; - if (dayNumber.equals("d5")) day5Total += hours; - if (dayNumber.equals("d6")) day6Total += hours; - taskTotal += hours; + dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + hours = timeEntry.hours.doubleValue() + entry.put(String.valueOf(dayNumber), hours) + if (dayNumber.equals("d0")) day0Total += hours + if (dayNumber.equals("d1")) day1Total += hours + if (dayNumber.equals("d2")) day2Total += hours + if (dayNumber.equals("d3")) day3Total += hours + if (dayNumber.equals("d4")) day4Total += hours + if (dayNumber.equals("d5")) day5Total += hours + if (dayNumber.equals("d6")) day6Total += hours + taskTotal += hours } - entry.rateTypeId = timeEntry.rateTypeId; + entry.rateTypeId = timeEntry.rateTypeId } if (timeEntry) { - lastTimeEntry = timeEntry; - retrieveWorkEffortData(); + lastTimeEntry = timeEntry + retrieveWorkEffortData() } // add empty lines if timesheet not completed if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) { for (c=0; c < 3; c++) { // add empty lines - entries.add(["timesheetId" : timesheet.timesheetId]); + entries.add(["timesheetId" : timesheet.timesheetId]) } } // add the totals line if at least one entry if (timeEntry) { - entry = ["timesheetId" : timesheet.timesheetId]; - entry.d0 = day0Total; - entry.d1 = day1Total; - entry.d2 = day2Total; - entry.d3 = day3Total; - entry.d4 = day4Total; - entry.d5 = day5Total; - entry.d6 = day6Total; - entry.phaseName = uiLabelMap.ScrumTotals; - entry.workEffortId = "Totals"; - entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total; - entries.add(entry); + entry = ["timesheetId" : timesheet.timesheetId] + entry.d0 = day0Total + entry.d1 = day1Total + entry.d2 = day2Total + entry.d3 = day3Total + entry.d4 = day4Total + entry.d5 = day5Total + entry.d6 = day6Total + entry.phaseName = uiLabelMap.ScrumTotals + entry.workEffortId = "Totals" + entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total + entries.add(entry) } -context.timeEntries = entries; +context.timeEntries = entries // get all timesheets of this user, including the planned hours -timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList(); -timesheets = new LinkedList(); +timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList() +timesheets = new LinkedList() timesheetsDb.each { timesheetDb -> - timesheet = [:]; - timesheet.putAll(timesheetDb); - entries = timesheetDb.getRelated("TimeEntry", null, null, false); - hours = 0.00; + timesheet = [:] + timesheet.putAll(timesheetDb) + entries = timesheetDb.getRelated("TimeEntry", null, null, false) + hours = 0.00 entries.each { timeEntry -> if (timeEntry.hours) { - hours += timeEntry.hours.doubleValue(); + hours += timeEntry.hours.doubleValue() } } - timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate); - timesheet.hours = hours; - timesheets.add(timesheet); + timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate) + timesheet.hours = hours + timesheets.add(timesheet) } -context.timesheets = timesheets; +context.timesheets = timesheets Modified: ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindBacklogItem.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindBacklogItem.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindBacklogItem.groovy (original) +++ ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindBacklogItem.groovy Wed Nov 2 19:09:13 2016 @@ -17,71 +17,71 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -productId =parameters.productId; -custRequestList=[]; -backlogList=[]; -custRequestList = from("CustRequestItem").where("productId", productId).queryList(); +productId =parameters.productId +custRequestList=[] +backlogList=[] +custRequestList = from("CustRequestItem").where("productId", productId).queryList() custRequestList.each { custRequestListMap -> - custRequestId=custRequestListMap.custRequestId; - exprBldr = []; - exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")); - exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")); - andExprs = []; - andExprs.add(EntityCondition.makeCondition("custRequestId", EntityOperator.EQUALS, custRequestId)); - andExprs.add(EntityCondition.makeCondition(exprBldr, EntityOperator.OR)); - custRequestTypeCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); - orderBy = ["custRequestTypeId"]; - productBacklogList = from("CustRequest").where(andExprs).orderBy("custRequestTypeId").queryList(); + custRequestId=custRequestListMap.custRequestId + exprBldr = [] + exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")) + exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")) + andExprs = [] + andExprs.add(EntityCondition.makeCondition("custRequestId", EntityOperator.EQUALS, custRequestId)) + andExprs.add(EntityCondition.makeCondition(exprBldr, EntityOperator.OR)) + custRequestTypeCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) + orderBy = ["custRequestTypeId"] + productBacklogList = from("CustRequest").where(andExprs).orderBy("custRequestTypeId").queryList() productBacklogList.each { productBacklogMap -> - productBackId = productBacklogMap.custRequestId; - taskBacklogList = from("CustRequestWorkEffort").where("custRequestId", productBackId).queryList(); - int countImplTask=0, countImplTaskComplete=0, countInstallTask=0, countInstallTaskComplete=0, countErrTask=0, countErrTaskComplete=0, countTestTask=0; + productBackId = productBacklogMap.custRequestId + taskBacklogList = from("CustRequestWorkEffort").where("custRequestId", productBackId).queryList() + int countImplTask=0, countImplTaskComplete=0, countInstallTask=0, countInstallTaskComplete=0, countErrTask=0, countErrTaskComplete=0, countTestTask=0 taskBacklogList.each { taskBacklogMap -> - taskId = taskBacklogMap.workEffortId; + taskId = taskBacklogMap.workEffortId - task = from("WorkEffort").where("workEffortId", taskId).queryOne(); + task = from("WorkEffort").where("workEffortId", taskId).queryOne() if (task.workEffortTypeId == "SCRUM_TASK_IMPL") { - countImplTask+=1; + countImplTask+=1 if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") { - countImplTaskComplete+=1; + countImplTaskComplete+=1 } } else if (task.workEffortTypeId == "SCRUM_TASK_INST") { - countInstallTask+=1; + countInstallTask+=1 if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") { - countInstallTaskComplete+=1; + countInstallTaskComplete+=1 } } else if (task.workEffortTypeId == "SCRUM_TASK_ERROR") { - countErrTask+=1; + countErrTask+=1 if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") { - countErrTaskComplete+=1; + countErrTaskComplete+=1 } } else if (task.workEffortTypeId == "SCRUM_TASK_TEST" || task.currentStatusId == "STS_CANCELLED") { - countTestTask+=1; + countTestTask+=1 } } if ((countImplTask > 0 || countErrTask > 0 || countInstallTask > 0) && countImplTask == countImplTaskComplete && countInstallTask == countInstallTaskComplete && countErrTask == countErrTaskComplete && countTestTask > 0) { - productBacklogMap = productBacklogMap.getAllFields(); - backlogList.add(productBacklogMap); + productBacklogMap = productBacklogMap.getAllFields() + backlogList.add(productBacklogMap) } } } if (backlogList) { backlogList = UtilMisc.sortMaps(backlogList, ["-custRequestName"]) - context.backlogList = backlogList; + context.backlogList = backlogList } Modified: ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindProductBacklogItem.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindProductBacklogItem.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindProductBacklogItem.groovy (original) +++ ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindProductBacklogItem.groovy Wed Nov 2 19:09:13 2016 @@ -17,122 +17,122 @@ * under the License. */ -import java.sql.*; -import java.sql.Timestamp; -import java.util.Calendar; -import net.fortuna.ical4j.model.DateTime; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.condition.*; -import sun.util.calendar.LocalGregorianCalendar.Date; +import java.sql.* +import java.sql.Timestamp +import java.util.Calendar +import net.fortuna.ical4j.model.DateTime +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.condition.* +import sun.util.calendar.LocalGregorianCalendar.Date -def module = "FindProductBacklogItem.groovy"; +def module = "FindProductBacklogItem.groovy" // list planned and unplanned backlog -conditionBacklogList = []; -orConditionBacklogList = []; -mainConditionBacklogList = []; -orConditionsBacklog = null; -orderBy = "custRequestDate"; +conditionBacklogList = [] +orConditionBacklogList = [] +mainConditionBacklogList = [] +orConditionsBacklog = null +orderBy = "custRequestDate" // Prevents the query on all records when loading the screen for the first time if ("Y".equals(parameters.noConditionFind)) { if(parameters.productId){ - conditionBacklogList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)); + conditionBacklogList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)) } if(parameters.custRequestTypeId){ - conditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, parameters.custRequestTypeId)); + conditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, parameters.custRequestTypeId)) }else{ // Adding both possibilities to the condition - orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")); - orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")); - orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR); + orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")) + orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")) + orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR) } if(parameters.billed){ - conditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, parameters.billed)); + conditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, parameters.billed)) }else{ // Adding both choices to the condition - orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "Y")); - orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "N")); - orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR); + orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "Y")) + orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "N")) + orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR) } if(parameters.statusId){ - orderBy = "custSequenceNum"; - conditionBacklogList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, parameters.statusId)); + orderBy = "custSequenceNum" + conditionBacklogList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, parameters.statusId)) } if(parameters.parentCustRequestId){ - conditionBacklogList.add(EntityCondition.makeCondition("parentCustRequestId", EntityOperator.EQUALS, parameters.parentCustRequestId)); + conditionBacklogList.add(EntityCondition.makeCondition("parentCustRequestId", EntityOperator.EQUALS, parameters.parentCustRequestId)) } if(parameters.description){ - conditionBacklogList.add(EntityCondition.makeCondition("description", EntityOperator.LIKE, "%" + parameters.description + "%")); + conditionBacklogList.add(EntityCondition.makeCondition("description", EntityOperator.LIKE, "%" + parameters.description + "%")) } if(parameters.fromPartyId){ - conditionBacklogList.add(EntityCondition.makeCondition("fromPartyId", EntityOperator.LIKE, "%" + parameters.fromPartyId + "%")); + conditionBacklogList.add(EntityCondition.makeCondition("fromPartyId", EntityOperator.LIKE, "%" + parameters.fromPartyId + "%")) } if (parameters.custRequestDate){ - fromDate = parameters.custRequestDate; - fromDate = fromDate + " " + "00:00:00.000"; - conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate))); - thruDate = parameters.custRequestDate; - thruDate = thruDate + " " + "23:59:59.999"; - conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.LESS_THAN_EQUAL_TO, Timestamp.valueOf(thruDate))); + fromDate = parameters.custRequestDate + fromDate = fromDate + " " + "00:00:00.000" + conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate))) + thruDate = parameters.custRequestDate + thruDate = thruDate + " " + "23:59:59.999" + conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.LESS_THAN_EQUAL_TO, Timestamp.valueOf(thruDate))) } if(parameters.custRequestId){ - conditionBacklogList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.LIKE, parameters.custRequestId + "%")); + conditionBacklogList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.LIKE, parameters.custRequestId + "%")) } - conditionsBacklog = EntityCondition.makeCondition(conditionBacklogList, EntityOperator.AND); + conditionsBacklog = EntityCondition.makeCondition(conditionBacklogList, EntityOperator.AND) if(UtilValidate.isNotEmpty(orConditionsBacklog)){ - mainConditionBacklogList.add(orConditionsBacklog); + mainConditionBacklogList.add(orConditionsBacklog) } - mainConditionBacklogList.add(conditionsBacklog); + mainConditionBacklogList.add(conditionsBacklog) // Request backlogList = select("custRequestId","custRequestTypeId", "custSequenceNum", "statusId", "description", "custEstimatedMilliSeconds", "custRequestName", "parentCustRequestId","productId","billed","custRequestDate","fromPartyId") .from("CustRequestAndCustRequestItem") .where(mainConditionBacklogList) .orderBy("-custRequestTypeId", orderBy) - .queryList(); + .queryList() - def countSequenceBacklog = 1; - def backlogItems = []; + def countSequenceBacklog = 1 + def backlogItems = [] backlogList.each() { backlogItem -> - def tempBacklog = [:]; - tempBacklog.putAll(backlogItem); - tempBacklog.custSequenceNum = countSequenceBacklog; - tempBacklog.realSequenceNum = backlogItem.custSequenceNum; + def tempBacklog = [:] + tempBacklog.putAll(backlogItem) + tempBacklog.custSequenceNum = countSequenceBacklog + tempBacklog.realSequenceNum = backlogItem.custSequenceNum // if custRequest has task then get Actual Hours - backlogCustWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", backlogItem.custRequestId).queryList(); + backlogCustWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", backlogItem.custRequestId).queryList() if (backlogCustWorkEffortList) { - actualHours = 0.00; + actualHours = 0.00 backlogCustWorkEffortList.each() { custWorkEffortMap -> - result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]); - actualHours += result.actualHours; + result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]) + actualHours += result.actualHours } if(actualHours) { - tempBacklog.actualHours = actualHours; + tempBacklog.actualHours = actualHours } else { - tempBacklog.actualHours = null; + tempBacklog.actualHours = null } } else { - tempBacklog.actualHours = null; + tempBacklog.actualHours = null } - backlogItems.add(tempBacklog); - countSequenceBacklog ++; + backlogItems.add(tempBacklog) + countSequenceBacklog ++ } // re-order category list item if ("N".equals(parameters.sequence)) { - backlogItems = UtilMisc.sortMaps(backlogItems, ["parentCustRequestId"]); + backlogItems = UtilMisc.sortMaps(backlogItems, ["parentCustRequestId"]) } - context.backlogItems = backlogItems; + context.backlogItems = backlogItems } Modified: ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindTaskList.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindTaskList.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindTaskList.groovy (original) +++ ofbiz/trunk/specialpurpose/scrum/groovyScripts/FindTaskList.groovy Wed Nov 2 19:09:13 2016 @@ -17,37 +17,37 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.tools.ant.taskdefs.Parallel.TaskList; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.tools.ant.taskdefs.Parallel.TaskList +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -taskId = parameters.taskId;; -taskName = parameters.taskName; -sprintId = parameters.sprintId; -sprintName = parameters.sprintName; -taskTypeId = parameters.taskTypeId; -projectId = parameters.projectId; -projectName = parameters.projectName; -backlogTypeId = parameters.unplannedFlag; -statusId = parameters.statusId; -partyId = parameters.partyId; +taskId = parameters.taskId +taskName = parameters.taskName +sprintId = parameters.sprintId +sprintName = parameters.sprintName +taskTypeId = parameters.taskTypeId +projectId = parameters.projectId +projectName = parameters.projectName +backlogTypeId = parameters.unplannedFlag +statusId = parameters.statusId +partyId = parameters.partyId -unplannedTaskList = []; -plannedTaskList = []; -resultList=[]; -taskList=[]; -implementTaskList=[]; -testTaskList=[]; -errorTaskList = []; -installTaskList = []; +unplannedTaskList = [] +plannedTaskList = [] +resultList=[] +taskList=[] +implementTaskList=[] +testTaskList=[] +errorTaskList = [] +installTaskList = [] // get Unplaned task list if ((taskId != null)||(taskName != null)||(taskTypeId != null)||(sprintId != null)||(sprintName != null) @@ -55,164 +55,164 @@ if ((taskId != null)||(taskName != null) ||(partyId != null)||(viewIndex_1 > 0)||(viewIndex_2 > 0)||(viewIndex_3 > 0)||(viewIndex_4 > 0) ||(viewIndexNo_1 > 0)||(viewIndexNo_2 > 0)||(viewIndexNo_3 > 0)||(viewIndexNo_4 > 0)){ if ((taskId != null)||(taskName != null)||(taskTypeId != null)){ - exprBldr = []; + exprBldr = [] if (taskId) { - exprBldr.add(EntityCondition.makeCondition("workEffortId", EntityOperator.EQUALS, taskId)); + exprBldr.add(EntityCondition.makeCondition("workEffortId", EntityOperator.EQUALS, taskId)) } if (taskName){ - exprBldr.add(EntityCondition.makeCondition("workEffortName", EntityOperator.LIKE, "%"+taskName+"%")); + exprBldr.add(EntityCondition.makeCondition("workEffortName", EntityOperator.LIKE, "%"+taskName+"%")) } if (taskTypeId){ - exprBldr.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, taskTypeId)); + exprBldr.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, taskTypeId)) } if (statusId){ - exprBldr.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, statusId)); + exprBldr.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, statusId)) } - unplannedTaskList = from("UnPlannedBacklogsAndTasks").where(exprBldr).orderBy("-createdDate").queryList(); + unplannedTaskList = from("UnPlannedBacklogsAndTasks").where(exprBldr).orderBy("-createdDate").queryList() } else{ - unplannedTaskList = from("UnPlannedBacklogsAndTasks").orderBy("-createdDate").queryList(); + unplannedTaskList = from("UnPlannedBacklogsAndTasks").orderBy("-createdDate").queryList() } - exprBldr2 = []; + exprBldr2 = [] if (taskId) { - exprBldr2.add(EntityCondition.makeCondition("taskId", EntityOperator.EQUALS, taskId)); + exprBldr2.add(EntityCondition.makeCondition("taskId", EntityOperator.EQUALS, taskId)) } if (taskName){ - exprBldr2.add(EntityCondition.makeCondition("taskName", EntityOperator.LIKE, "%"+taskName+"%")); + exprBldr2.add(EntityCondition.makeCondition("taskName", EntityOperator.LIKE, "%"+taskName+"%")) } if (taskTypeId){ - exprBldr2.add(EntityCondition.makeCondition("taskTypeId", EntityOperator.EQUALS, taskTypeId)); + exprBldr2.add(EntityCondition.makeCondition("taskTypeId", EntityOperator.EQUALS, taskTypeId)) } if (statusId){ - exprBldr2.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, statusId)); + exprBldr2.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, statusId)) } if (sprintId){ - exprBldr2.add(EntityCondition.makeCondition("sprintId", EntityOperator.EQUALS, sprintId)); + exprBldr2.add(EntityCondition.makeCondition("sprintId", EntityOperator.EQUALS, sprintId)) } if (sprintName){ - exprBldr2.add(EntityCondition.makeCondition("sprintName", EntityOperator.LIKE, "%"+sprintName+"%")); + exprBldr2.add(EntityCondition.makeCondition("sprintName", EntityOperator.LIKE, "%"+sprintName+"%")) } if (projectId){ - exprBldr2.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, projectId)); + exprBldr2.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, projectId)) } if (projectName){ - exprBldr2.add(EntityCondition.makeCondition("projectName", EntityOperator.LIKE, "%"+projectName+"%")); + exprBldr2.add(EntityCondition.makeCondition("projectName", EntityOperator.LIKE, "%"+projectName+"%")) } - exprBldr2.add(EntityCondition.makeCondition("sprintTypeId", EntityOperator.EQUALS, "SCRUM_SPRINT")); - plannedTaskList = from("ProjectSprintBacklogAndTask").where(exprBldr2).orderBy("-taskCreatedDate").queryList(); + exprBldr2.add(EntityCondition.makeCondition("sprintTypeId", EntityOperator.EQUALS, "SCRUM_SPRINT")) + plannedTaskList = from("ProjectSprintBacklogAndTask").where(exprBldr2).orderBy("-taskCreatedDate").queryList() unplannedTaskList.each{ unplannedTaskMap -> - unplannedMap = [:]; - unplannedMap.taskId = unplannedTaskMap.workEffortId; - unplannedMap.sprintId = null; - unplannedMap.projectId = null; - unplannedMap.productId = unplannedTaskMap.productId; - unplannedMap.taskName = unplannedTaskMap.workEffortName; - unplannedMap.taskTypeId = unplannedTaskMap.workEffortTypeId; - unplannedMap.taskCurrentStatusId = unplannedTaskMap.currentStatusId; - unplannedMap.taskEstimatedMilliSeconds = unplannedTaskMap.estimatedMilliSeconds; - unplannedMap.taskCreatedDate = unplannedTaskMap.createdDate; - unplannedMap.custRequestId = unplannedTaskMap.custRequestId; - unplannedMap.description = unplannedTaskMap.description; - unplannedMap.custRequestTypeId = unplannedTaskMap.custRequestTypeId; - unplannedMap.taskActualMilliSeconds = unplannedTaskMap.actualMilliSeconds; - unplannedMap.taskEstimatedStartDate = unplannedTaskMap.estimatedStartDate; - taskList.add(unplannedMap); + unplannedMap = [:] + unplannedMap.taskId = unplannedTaskMap.workEffortId + unplannedMap.sprintId = null + unplannedMap.projectId = null + unplannedMap.productId = unplannedTaskMap.productId + unplannedMap.taskName = unplannedTaskMap.workEffortName + unplannedMap.taskTypeId = unplannedTaskMap.workEffortTypeId + unplannedMap.taskCurrentStatusId = unplannedTaskMap.currentStatusId + unplannedMap.taskEstimatedMilliSeconds = unplannedTaskMap.estimatedMilliSeconds + unplannedMap.taskCreatedDate = unplannedTaskMap.createdDate + unplannedMap.custRequestId = unplannedTaskMap.custRequestId + unplannedMap.description = unplannedTaskMap.description + unplannedMap.custRequestTypeId = unplannedTaskMap.custRequestTypeId + unplannedMap.taskActualMilliSeconds = unplannedTaskMap.actualMilliSeconds + unplannedMap.taskEstimatedStartDate = unplannedTaskMap.estimatedStartDate + taskList.add(unplannedMap) } plannedTaskList.each{ plannedTaskMap -> - plannedMap = [:]; - plannedMap.taskId = plannedTaskMap.taskId; - plannedMap.taskName = plannedTaskMap.taskName; - plannedMap.taskTypeId = plannedTaskMap.taskTypeId; - plannedMap.taskCurrentStatusId = plannedTaskMap.taskCurrentStatusId; - plannedMap.taskEstimatedMilliSeconds = plannedTaskMap.taskEstimatedMilliSeconds; - plannedMap.taskCreatedDate = plannedTaskMap.taskCreatedDate; - plannedMap.sprintId = plannedTaskMap.sprintId; - plannedMap.sprintName = plannedTaskMap.sprintName; - plannedMap.projectId = plannedTaskMap.projectId; - plannedMap.projectName = plannedTaskMap.projectName; - plannedMap.custRequestId = plannedTaskMap.custRequestId; - plannedMap.description = plannedTaskMap.description; - plannedMap.custRequestTypeId = plannedTaskMap.custRequestTypeId; - plannedMap.taskActualMilliSeconds = plannedTaskMap.taskActualMilliSeconds; - plannedMap.taskEstimatedStartDate = plannedTaskMap.taskEstimatedStartDate; - taskList.add(plannedMap); + plannedMap = [:] + plannedMap.taskId = plannedTaskMap.taskId + plannedMap.taskName = plannedTaskMap.taskName + plannedMap.taskTypeId = plannedTaskMap.taskTypeId + plannedMap.taskCurrentStatusId = plannedTaskMap.taskCurrentStatusId + plannedMap.taskEstimatedMilliSeconds = plannedTaskMap.taskEstimatedMilliSeconds + plannedMap.taskCreatedDate = plannedTaskMap.taskCreatedDate + plannedMap.sprintId = plannedTaskMap.sprintId + plannedMap.sprintName = plannedTaskMap.sprintName + plannedMap.projectId = plannedTaskMap.projectId + plannedMap.projectName = plannedTaskMap.projectName + plannedMap.custRequestId = plannedTaskMap.custRequestId + plannedMap.description = plannedTaskMap.description + plannedMap.custRequestTypeId = plannedTaskMap.custRequestTypeId + plannedMap.taskActualMilliSeconds = plannedTaskMap.taskActualMilliSeconds + plannedMap.taskEstimatedStartDate = plannedTaskMap.taskEstimatedStartDate + taskList.add(plannedMap) } //Check the backlog if (backlogTypeId){ if (backlogTypeId=="Y"){ taskList.each{taskMap -> if(taskMap.custRequestTypeId=="RF_UNPLAN_BACKLOG"){ - resultList.add(taskMap); + resultList.add(taskMap) } } } if (backlogTypeId=="N"){ taskList.each{taskMap -> if(taskMap.custRequestTypeId=="RF_PROD_BACKLOG"){ - resultList.add(taskMap); + resultList.add(taskMap) } } } } else { taskList.each { taskMap -> - resultList.add(taskMap); + resultList.add(taskMap) } } // Check party assigned if (partyId){ - assignedList = resultList; - resultList = []; + assignedList = resultList + resultList = [] assignedList.each { assignedMap -> - workEffortId = assignedMap.taskId; - assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId, "partyId", partyId).queryList(); + workEffortId = assignedMap.taskId + assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId, "partyId", partyId).queryList() if (assignToList) { - assignedMap.partyId = assignToList[0].partyId; - resultList.add(assignedMap); + assignedMap.partyId = assignToList[0].partyId + resultList.add(assignedMap) } } } else { - assignedList = resultList; - resultList = []; + assignedList = resultList + resultList = [] assignedList.each { assignedMap -> - workEffortId = assignedMap.taskId; - assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList(); + workEffortId = assignedMap.taskId + assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList() if (assignToList) { - assignedMap.partyId = assignToList[0].partyId; - resultList.add(assignedMap); + assignedMap.partyId = assignToList[0].partyId + resultList.add(assignedMap) } else { - resultList.add(assignedMap); + resultList.add(assignedMap) } } } resultList.each{resultMap -> if (resultMap.taskTypeId=="SCRUM_TASK_IMPL"){ - implementTaskList.add(resultMap); + implementTaskList.add(resultMap) } if (resultMap.taskTypeId=="SCRUM_TASK_INST"){ - installTaskList.add(resultMap); + installTaskList.add(resultMap) } if (resultMap.taskTypeId=="SCRUM_TASK_TEST"){ - testTaskList.add(resultMap); + testTaskList.add(resultMap) } if (resultMap.taskTypeId=="SCRUM_TASK_ERROR"){ - errorTaskList.add(resultMap); + errorTaskList.add(resultMap) } } if (implementTaskList){ - context.implementTaskList = implementTaskList; + context.implementTaskList = implementTaskList } if (installTaskList){ - context.installTaskList = installTaskList; + context.installTaskList = installTaskList } if (testTaskList){ - context.testTaskList = testTaskList; + context.testTaskList = testTaskList } if (errorTaskList){ - context.errorTaskList = errorTaskList; + context.errorTaskList = errorTaskList } } |
Free forum by Nabble | Edit this page |