Improved: Inconsistent String Comparisons, Applied plugins groovy patch from jira issue. (OFBIZ-9254)

I found an inconsistency in the code for string comparison statusId.equals("PRUN_COMPLETED") whereas it should be written as "PRUN_COMPLETED".equals(statusId) cause the former can throw NullPointerException if the variable found to be NULL.

Thanks Devanshu Vyas for your contribution.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-plugins/trunk@1795344 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Deepak Dixit
2017-05-16 17:36:32 +00:00
parent 91fb6d5f4d
commit 18894e6dc0
16 changed files with 62 additions and 62 deletions
@@ -55,7 +55,7 @@ if (miniProduct && productStoreId && prodCatalogId ) {
// returns: isSale, price, orderItemPriceInfos
context.priceResult = priceResult
// Check if Price has to be displayed with tax
if (productStore.get("showPricesWithVatTax").equals("Y")) {
if ("Y".equals(productStore.get("showPricesWithVatTax"))) {
Map priceMap = runService('calcTaxForDisplay', ["basePrice": priceResult.get("price"), "locale": locale, "productId": optProductId, "productStoreId": productStoreId])
context.price = priceMap.get("priceWithTax")
} else {
@@ -68,7 +68,7 @@ if (miniProduct && productStoreId && prodCatalogId ) {
if (configWrapper) {
configWrapper.setDefaultConfig()
// Check if Config Price has to be displayed with tax
if (productStore.get("showPricesWithVatTax").equals("Y")) {
if ("Y".equals(productStore.get("showPricesWithVatTax"))) {
BigDecimal totalPriceNoTax = configWrapper.getTotalPrice()
Map totalPriceMap = runService('calcTaxForDisplay', ["basePrice": totalPriceNoTax, "locale": locale, "productId": optProductId, "productStoreId": productStoreId])
context.totalPrice = totalPriceMap.get("priceWithTax")
@@ -36,6 +36,6 @@ import javax.servlet.http.*
contentIdTo = parameters.contentIdTo
if (!contentIdTo || !contentIdTo.equals("TEMPLATE_MASTER")) {
if (!contentIdTo || !"TEMPLATE_MASTER".equals(contentIdTo)) {
context.dynamicPrimaryHTMLField = "textData"
}
@@ -69,7 +69,7 @@ if ("add".equals(mode)) {
}
}
if (permissionType.equals("complex")) {
if ("complex".equals(permissionType)) {
mapIn = [:]
mapIn.userLogin = userLogin
targetOperationList = StringUtil.split(targetOperation, "|")
@@ -39,7 +39,7 @@ context.partyId = partyId
// nuke the event messages
request.removeAttribute("_EVENT_MESSAGE_")
if (partyId && !partyId.equals("_NA_")) {
if (partyId && !"_NA_".equals(partyId)) {
party = from("Party").where("partyId", partyId).queryOne()
person = party.getRelatedOne("Person", false)
context.party = party
@@ -176,7 +176,7 @@ if (orderHeader) {
ritems = oitem.getRelated("ReturnItem", null, null, false)
ritems.each { ritem ->
rh = ritem.getRelatedOne("ReturnHeader", false)
if (!rh.statusId.equals("RETURN_CANCELLED")) {
if (!"RETURN_CANCELLED".equals(rh.statusId)) {
returned += ritem.returnQuantity
}
}
@@ -35,7 +35,7 @@ if (!partyId) {
}
context.partyId = partyId
if (partyId && !partyId.equals("_NA_")) {
if (partyId && !"_NA_".equals(partyId)) {
party = from("Party").where("partyId", partyId).queryOne()
person = party.getRelatedOne("Person", false)
context.party = party
@@ -89,7 +89,7 @@ context.cart = cart
// nuke the event messages
request.removeAttribute("_EVENT_MESSAGE_")
if (cartPartyId && !cartPartyId.equals("_NA_")) {
if (cartPartyId && !"_NA_".equals(cartPartyId)) {
cartParty = from("Party").where("partyId", cartPartyId).queryOne()
if (cartParty) {
cartPerson = cartParty.getRelatedOne("Person", false)
@@ -31,7 +31,7 @@ context.cart = cart
// nuke the event messages
request.removeAttribute("_EVENT_MESSAGE_")
if (partyId && !partyId.equals("_NA_")) {
if (partyId && !"_NA_".equals(partyId)) {
party = from("Party").where("partyId", partyId).queryOne()
person = party.getRelatedOne("Person", false)
context.party = party
@@ -145,13 +145,13 @@ while (te.hasNext()) {
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
if ("d0".equals(dayNumber)) day0Total += hours
if ("d1".equals(dayNumber)) day1Total += hours
if ("d2".equals(dayNumber)) day2Total += hours
if ("d3".equals(dayNumber)) day3Total += hours
if ("d4".equals(dayNumber)) day4Total += hours
if ("d5".equals(dayNumber)) day5Total += hours
if ("d6".equals(dayNumber)) day6Total += hours
taskTotal += hours
}
entry.rateTypeId = timeEntry.rateTypeId
@@ -163,7 +163,7 @@ if (timeEntry) {
}
// add empty lines if timesheet not completed
if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) {
if (!"TIMESHEET_COMPLETED".equals(timesheet.statusId)) {
for (c=0; c < 3; c++) { // add empty lines
entries.add(["timesheetId" : timesheet.timesheetId])
}
+2 -2
View File
@@ -73,13 +73,13 @@ if (phases) {
taskInfo = resultTaskInfo.taskInfo
taskInfo.taskNr = task.workEffortId
taskInfo.phaseNr = phase.phaseId
if (taskInfo.plannedHours && !taskInfo.currentStatusId.equals("PTS_COMPLETED") && taskInfo.plannedHours > taskInfo.actualHours) {
if (taskInfo.plannedHours && !"PTS_COMPLETED".equals(taskInfo.currentStatusId) && taskInfo.plannedHours > taskInfo.actualHours) {
taskInfo.resource = taskInfo.plannedHours + " Hrs"
} else {
taskInfo.resource = taskInfo.actualHours + " Hrs"
}
Double duration = resultTaskInfo.plannedHours
if (taskInfo.currentStatusId.equals("PTS_COMPLETED")) {
if ("PTS_COMPLETED".equals(taskInfo.currentStatusId)) {
taskInfo.completion = 100
} else {
if (taskInfo.actualHours && taskInfo.plannedHours) {
@@ -40,7 +40,7 @@ entryIterator = from("ProjectPhaseTaskAndTimeEntryTimeSheet")
.queryIterator()
while (entryItem = entryIterator.next()) {
invoice = entryItem.getRelatedOne("Invoice", false)
if (invoice.getString("statusId").equals("INVOICE_IN_PROCESS")) {
if ("INVOICE_IN_PROCESS".equals(invoice.getString("statusId"))) {
context.partyIdFrom = invoice.partyIdFrom
context.partyId = invoice.partyId
context.invoiceId = invoice.invoiceId
@@ -22,10 +22,10 @@ projectMembers = from("WorkEffortPartyAssignment").where("workEffortId", context
toPartyId = null
fromPartyId = null
projectMembers.each {member ->
if (member.roleTypeId.equals("INTERNAL_ORGANIZATIO")) {
if ("INTERNAL_ORGANIZATIO".equals(member.roleTypeId)) {
fromPartyId = member.partyId
}
if (member.roleTypeId.equals("CLIENT_BILLING")) {
if ("CLIENT_BILLING".equals(member.roleTypeId)) {
toPartyId = member.partyId
}
if (fromPartyId && toPartyId && fromPartyId.equals(toPartyId)) {
@@ -46,7 +46,7 @@ userLoginId = userLogin.partyId
} else {
custRequestTypeId = projectAndTaskMap.custRequestTypeId
backlogStatusId = projectAndTaskMap.backlogStatusId
if (custRequestTypeId.equals("RF_SCRUM_MEETINGS") && backlogStatusId.equals("CRQ_REVIEWED")) {
if ("RF_SCRUM_MEETINGS".equals(custRequestTypeId) && "CRQ_REVIEWED".equals(backlogStatusId)) {
projectSprintBacklogAndTaskList.add(projectAndTaskMap)
}
}
+30 -30
View File
@@ -182,26 +182,26 @@ while (te.hasNext()) {
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
if ("d0".equals(dayNumber)) day0Total += hours
if ("d1".equals(dayNumber)) day1Total += hours
if ("d2".equals(dayNumber)) day2Total += hours
if ("d3".equals(dayNumber)) day3Total += hours
if ("d4".equals(dayNumber)) day4Total += hours
if ("d5".equals(dayNumber)) day5Total += hours
if ("d6".equals(dayNumber)) 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
if ("pd0".equals(dayNumber)) pDay0Total += planHours
if ("pd1".equals(dayNumber)) pDay1Total += planHours
if ("pd2".equals(dayNumber)) pDay2Total += planHours
if ("pd3".equals(dayNumber)) pDay3Total += planHours
if ("pd4".equals(dayNumber)) pDay4Total += planHours
if ("pd5".equals(dayNumber)) pDay5Total += planHours
if ("pd6".equals(dayNumber)) pDay6Total += planHours
planTotal += planHours
}
@@ -265,13 +265,13 @@ while ((emplLeaveMap = emplLeave.next())) {
["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
if ("d0".equals(leaveDayNumber)) day0Total += leaveHours
if ("d1".equals(leaveDayNumber)) day1Total += leaveHours
if ("d2".equals(leaveDayNumber)) day2Total += leaveHours
if ("d3".equals(leaveDayNumber)) day3Total += leaveHours
if ("d4".equals(leaveDayNumber)) day4Total += leaveHours
if ("d5".equals(leaveDayNumber)) day5Total += leaveHours
if ("d6".equals(leaveDayNumber)) day6Total += leaveHours
leaveTaskTotal += leaveHours
}
if (resultHours.hours) {
@@ -280,13 +280,13 @@ while ((emplLeaveMap = emplLeave.next())) {
["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
if ("pd0".equals(leavePlanDay)) pDay0Total += leavePlanHours
if ("pd1".equals(leavePlanDay)) pDay1Total += leavePlanHours
if ("pd2".equals(leavePlanDay)) pDay2Total += leavePlanHours
if ("pd3".equals(leavePlanDay)) pDay3Total += leavePlanHours
if ("pd4".equals(leavePlanDay)) pDay4Total += leavePlanHours
if ("pd5".equals(leavePlanDay)) pDay5Total += leavePlanHours
if ("pd6".equals(leavePlanDay)) pDay6Total += leavePlanHours
leavePlanTotal += leavePlanHours
}
leaveEntry.rateTypeId = "STANDARD"
@@ -303,7 +303,7 @@ if (emplLeaveEntry) {
}
// add empty lines if timesheet not completed
if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) {
if (!"TIMESHEET_COMPLETED".equals(timesheet.statusId)) {
for (c=0; c < 3; c++) { // add empty lines
entries.add(["timesheetId" : timesheet.timesheetId])
}
@@ -393,7 +393,7 @@ userLoginId = userLogin.partyId
if (partyAssignmentTaskMap) {
custRequestTypeId = projectAndTaskMap.custRequestTypeId
backlogStatusId = projectAndTaskMap.backlogStatusId
if (custRequestTypeId.equals("RF_SCRUM_MEETINGS") && backlogStatusId.equals("CRQ_REVIEWED")) {
if ("RF_SCRUM_MEETINGS".equals(custRequestTypeId) && "CRQ_REVIEWED".equals(backlogStatusId)) {
projectSprintBacklogAndTaskList.add(projectAndTaskMap)
}
} else {
+8 -8
View File
@@ -148,13 +148,13 @@ while (te.hasNext()) {
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
if ("d0".equals(dayNumber)) day0Total += hours
if ("d1".equals(dayNumber)) day1Total += hours
if ("d2".equals(dayNumber)) day2Total += hours
if ("d3".equals(dayNumber)) day3Total += hours
if ("d4".equals(dayNumber)) day4Total += hours
if ("d5".equals(dayNumber)) day5Total += hours
if ("d6".equals(dayNumber)) day6Total += hours
taskTotal += hours
}
entry.rateTypeId = timeEntry.rateTypeId
@@ -166,7 +166,7 @@ if (timeEntry) {
}
// add empty lines if timesheet not completed
if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) {
if (!"TIMESHEET_COMPLETED".equals(timesheet.statusId)) {
for (c=0; c < 3; c++) { // add empty lines
entries.add(["timesheetId" : timesheet.timesheetId])
}
+1 -1
View File
@@ -35,7 +35,7 @@ entryExprs =
entryIterator = from("ProjectSprintBacklogTaskAndTimeEntryTimeSheet").where(entryExprs).orderBy("-fromDate").queryIterator()
while (entryItem = entryIterator.next()) {
invoice = entryItem.getRelatedOne("Invoice", false)
if (invoice.getString("statusId").equals("INVOICE_IN_PROCESS")) {
if ("INVOICE_IN_PROCESS".equals(invoice.getString("statusId"))) {
context.partyIdFrom = invoice.partyIdFrom
context.partyId = invoice.partyId
context.invoiceId = invoice.invoiceId