Skip to content

Commit

Permalink
#36 fix != equals on Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausRicharz committed Feb 24, 2022
1 parent 20ea628 commit 8216759
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -201,7 +202,7 @@ public ActionForward executeAuthenticated(ActionMapping mapping, AddDailyReportF

// make sure that overtimeCompensation is set in the session so that the duration-dropdown-menu will be disabled for timereports with suborder uesa00
if (request.getSession().getAttribute("overtimeCompensation") == null
|| request.getSession().getAttribute("overtimeCompensation") != GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION) {
|| !Objects.equals(request.getSession().getAttribute("overtimeCompensation"), GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION)) {
request.getSession().setAttribute("overtimeCompensation", GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -54,7 +55,7 @@ public ActionForward executeAuthenticated(ActionMapping mapping, AddDailyReportF
// make sure that overtimeCompensation is set in the session so that the duration-dropdown-menu will be disabled
// if the current suborder is overtime compensation.
if (request.getSession().getAttribute("overtimeCompensation") == null
|| request.getSession().getAttribute("overtimeCompensation") != GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION) {
|| !Objects.equals(request.getSession().getAttribute("overtimeCompensation"), GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION)) {
request.getSession().setAttribute("overtimeCompensation", GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public ActionForward executeAuthenticated(ActionMapping mapping, ShowDailyReport
}
// make sure that overtimeCompensation is set in the session so that the duration-dropdown-menu will be disabled for timereports with suborder uesa00
if (request.getSession().getAttribute("overtimeCompensation") == null
|| request.getSession().getAttribute("overtimeCompensation") != GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION) {
|| !Objects.equals(request.getSession().getAttribute("overtimeCompensation"), GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION)) {
request.getSession().setAttribute("overtimeCompensation", GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION);
}
}
Expand Down Expand Up @@ -444,7 +444,7 @@ private ActionForward doRefreshTimereports(ActionMapping mapping, HttpServletReq
}
//check if overtime should be computed until enddate (not today)
if (reportForm.getShowOvertimeUntil()) {
if (ec.getId() != reportForm.getEmployeeContractId()) {
if (!Objects.equals(ec.getId(), reportForm.getEmployeeContractId())) {
ec = employeecontractDAO.getEmployeeContractById(reportForm.getEmployeeContractId());
}
LocalDate date = DateUtils.parse(reportForm.getEnddate(), e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -481,8 +482,8 @@ private void setSubOrder(@Nonnull Suborder suborder, HttpServletRequest request,
if (suborder.getSign().equalsIgnoreCase(GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION)) {
reportForm.setSelectedHourDuration(0);
reportForm.setSelectedMinuteDuration(0);
if (request.getSession().getAttribute("overtimeCompensation") == null || request.getSession().getAttribute("overtimeCompensation")
!= GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION) {
if (request.getSession().getAttribute("overtimeCompensation") == null ||
!Objects.equals(request.getSession().getAttribute("overtimeCompensation"), GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION)) {
request.getSession().setAttribute("overtimeCompensation", GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,12 @@ private boolean formEntriesEqualDB(final Long eocId,
contentForm.getContact_tech_customer())) {
return false;
}
if (eoContent.getContactContractHbt().getId() != contentForm
.getContact_contract_hbt_emp_id()) {
if (!Objects.equals(eoContent.getContactContractHbt().getId(), contentForm
.getContact_contract_hbt_emp_id())) {
return false;
}
if (eoContent.getContactTechHbt().getId() != contentForm
.getContact_tech_hbt_emp_id()) {
if (!Objects.equals(eoContent.getContactTechHbt().getId(), contentForm
.getContact_tech_hbt_emp_id())) {
return false;
}
if (!eoContent.getDescription()
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/org/tb/action/order/StoreSuborderAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ public ActionForward executeAuthenticated(ActionMapping mapping,
soId = -1L;
}
if (suborders != null) {
if (tempSubOrder != null && (tempOrder == null || tempSubOrder.getCustomerorder().getId() == tempOrder.getId())) {
if (tempSubOrder != null && (tempOrder == null || Objects.equals(
tempSubOrder.getCustomerorder().getId(), tempOrder.getId()))) {
int version = 1;
DecimalFormat df = new DecimalFormat("00");
for (Suborder suborder : suborders) {
if (suborder.getParentorder() != null && suborder.getParentorder().getId() == tempSubOrder.getId()) {
if (suborder.getParentorder() != null && Objects.equals(suborder.getParentorder().getId(),
tempSubOrder.getId())) {
if (suborder.getSign().equals(tempSubOrder.getSign() + "." + df.format(version)) && !soId.equals(suborder.getId())) {
version++;
}
Expand All @@ -163,7 +165,8 @@ public ActionForward executeAuthenticated(ActionMapping mapping,
int version = 1;
DecimalFormat df = new DecimalFormat("00");
for (Suborder suborder : suborders) {
if (suborder.getParentorder() == null && suborder.getCustomerorder().getId() == tempOrder.getId()) {
if (suborder.getParentorder() == null && Objects.equals(suborder.getCustomerorder().getId(),
tempOrder.getId())) {
if (suborder.getSign().equals(tempOrder.getSign() + "." + df.format(version)) && !soId.equals(suborder.getId())) {
version++;
}
Expand Down Expand Up @@ -265,8 +268,8 @@ public ActionForward executeAuthenticated(ActionMapping mapping,
so = suborderDAO.getSuborderById(soId);

if (so.getSuborders() != null
&& !so.getSuborders().isEmpty()
&& so.getCustomerorder().getId() != customerorder.getId()) {
&& !so.getSuborders().isEmpty()
&& !Objects.equals(so.getCustomerorder().getId(), customerorder.getId())) {
// set customerorder in all descendants
so.setCustomerOrderForAllDescendants(customerorder, suborderDAO, loginEmployee, so);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.text.ParseException;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -239,7 +240,8 @@ protected ActionForward executeAuthenticated(ActionMapping mapping, AddStatusRep
Statusreport lastKnownReport = existingReports.get(existingReports.size() - 1);

if (request.getSession().getAttribute("currentStatusReport") != null &&
((Statusreport) request.getSession().getAttribute("currentStatusReport")).getId() == lastKnownReport.getId()) {
Objects.equals(((Statusreport) request.getSession().getAttribute("currentStatusReport")).getId(),
lastKnownReport.getId())) {
fromDate = lastKnownReport.getFromdate();
reportForm.setValidUntil(format(lastKnownReport.getUntildate()));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tb/bdom/Suborder.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void setCustomerOrderForAllDescendants(Customerorder customerOrder, Subor
/* create visitor to collect suborders */
SuborderVisitor customerOrderSetter = suborder -> {
// do not modify root suborder
if (visitorRootSuborder.getId() != suborder.getId()) {
if (!Objects.equals(visitorRootSuborder.getId(), suborder.getId())) {
Suborder suborderToModify = visitorSuborderDAO
.getSuborderById(suborder.getId());
if (suborderToModify != null) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/tb/helper/SuborderHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.text.ParseException;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -118,7 +119,7 @@ private void assignCurrentSuborderIdWithOvertimeCompensationAndTrainingFlag(Http
reportForm.setSelectedHourDuration(0);
reportForm.setSelectedMinuteDuration(0);
if (session.getAttribute("overtimeCompensation") == null ||
session.getAttribute("overtimeCompensation") != GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION) {
!Objects.equals(session.getAttribute("overtimeCompensation"), GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION)) {
session.setAttribute("overtimeCompensation", GlobalConstants.SUBORDER_SIGN_OVERTIME_COMPENSATION);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tb/helper/TimereportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public ActionMessages validateNewDate(
}

if (!loginEmployeeContract.getEmployee().getSign().equals("adm")) {
if (authorized && loginEmployeeContract.getId() != timereport.getEmployeecontract().getId()) {
if (authorized && !Objects.equals(loginEmployeeContract.getId(), timereport.getEmployeecontract().getId())) {
if (releaseDate.isBefore(theNewDate) || firstday) {
errors.add("release", new ActionMessage("form.timereport.error.not.released"));
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/tb/service/TimereportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.Setter;
Expand Down Expand Up @@ -318,7 +319,7 @@ private void checkAuthorization(List<Timereport> timereports, AuthorizedUser aut
throw new AuthorizationException(TR_COMMITTED_TIME_REPORT_REQ_MANAGER);
}
if(TIMEREPORT_STATUS_OPEN.equals(t.getStatus()) &&
authorizedUser.getEmployeeId() != t.getEmployeecontract().getEmployee().getId()) {
!Objects.equals(authorizedUser.getEmployeeId(), t.getEmployeecontract().getEmployee().getId())) {
throw new AuthorizationException(TR_OPEN_TIME_REPORT_REQ_EMPLOYEE);
}
});
Expand Down
Loading

0 comments on commit 8216759

Please sign in to comment.