Avoid the use of Number constructors
They look bad and are more inefficient. FEA: ItEr74S04BugFixing
This commit is contained in:
parent
538983a372
commit
1a54013e7e
20 changed files with 81 additions and 82 deletions
|
|
@ -35,10 +35,10 @@ import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
|||
import org.zkoss.ganttz.util.ComponentsFinder;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
||||
import org.zkoss.ganttz.util.MutableTreeModel;
|
||||
import org.zkoss.ganttz.util.OnZKDesktopRegistry;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
|
||||
import org.zkoss.ganttz.util.script.IScriptsRegister;
|
||||
import org.zkoss.zk.au.out.AuInvoke;
|
||||
|
|
@ -444,7 +444,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
Comboitem item = new Comboitem();
|
||||
item.setLabel(firstName.substring(0, 1) + " - " + lastName.substring(0, 1));
|
||||
item.setDescription(firstName + " - " + lastName);
|
||||
item.setValue(new Integer(position));
|
||||
item.setValue(position);
|
||||
filterByNameCombo.appendChild(item);
|
||||
position = newPosition;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ public class OrderElementDAO extends IntegrationEntityDAO<OrderElement>
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public BigDecimal getHoursAdvancePercentage(OrderElement orderElement) {
|
||||
final Integer totalChargedHours = orderElement.getSumChargedHours() != null ? orderElement
|
||||
.getSumChargedHours().getTotalChargedHours() : new Integer(0);
|
||||
final int totalChargedHours = orderElement.getSumChargedHours() != null ? orderElement
|
||||
.getSumChargedHours().getTotalChargedHours() : 0;
|
||||
BigDecimal assignedHours = new BigDecimal(totalChargedHours).setScale(2);
|
||||
BigDecimal estimatedHours = new BigDecimal(orderElement.getWorkHours())
|
||||
.setScale(2);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public abstract class HoursGroupHandler<T> implements IHoursGroupHandler<T> {
|
|||
return false;
|
||||
}
|
||||
|
||||
Integer newTotal = 0;
|
||||
int newTotal = 0;
|
||||
|
||||
for (HoursGroup hoursGroup : hoursGroups) {
|
||||
if (hoursGroup.isFixedPercentage()) {
|
||||
|
|
@ -50,7 +50,7 @@ public abstract class HoursGroupHandler<T> implements IHoursGroupHandler<T> {
|
|||
}
|
||||
}
|
||||
|
||||
if (newTotal.compareTo(total) > 0) {
|
||||
if (newTotal > total) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ public abstract class HoursGroupHandler<T> implements IHoursGroupHandler<T> {
|
|||
public void setWorkHours(T orderLine, Integer workHours) throws IllegalArgumentException {
|
||||
|
||||
if (workHours == null) {
|
||||
workHours = new Integer(0);
|
||||
workHours = 0;
|
||||
}
|
||||
|
||||
if (workHours < 0) {
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ import org.navalplanner.business.common.BaseEntity;
|
|||
*/
|
||||
public class SumChargedHours extends BaseEntity {
|
||||
|
||||
private Integer directChargedHours = new Integer(0);
|
||||
private Integer directChargedHours = 0;
|
||||
|
||||
private Integer indirectChargedHours = new Integer(0);
|
||||
private Integer indirectChargedHours = 0;
|
||||
|
||||
protected SumChargedHours() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,13 +77,13 @@ public class PlanningData extends BaseEntity {
|
|||
}
|
||||
|
||||
private BigDecimal calculateByDuration(List<Task> criticalPath) {
|
||||
Integer totalDuration = new Integer(0), duration;
|
||||
BigDecimal totalProgress = BigDecimal.ZERO, progress;
|
||||
int totalDuration = 0;
|
||||
BigDecimal totalProgress = BigDecimal.ZERO;
|
||||
|
||||
for (Task each : criticalPath) {
|
||||
duration = each.getWorkableDays();
|
||||
progress = each.getAdvancePercentage();
|
||||
progress = progress.multiply(BigDecimal.valueOf(duration));
|
||||
int duration = each.getWorkableDays();
|
||||
BigDecimal progress = each.getAdvancePercentage().multiply(
|
||||
BigDecimal.valueOf(duration));
|
||||
|
||||
totalDuration = totalDuration + duration;
|
||||
totalProgress = totalProgress.add(progress);
|
||||
|
|
@ -98,8 +98,8 @@ public class PlanningData extends BaseEntity {
|
|||
* @param denominator
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal divide(BigDecimal numerator, Integer denominator) {
|
||||
if (Integer.valueOf(0).equals(denominator)) {
|
||||
private BigDecimal divide(BigDecimal numerator, int denominator) {
|
||||
if (denominator == 0) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return numerator.divide(BigDecimal.valueOf(denominator), 8,
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ public abstract class TaskElement extends BaseEntity {
|
|||
each.getType());
|
||||
}
|
||||
|
||||
private Integer sumOfHoursAllocated = new Integer(0);
|
||||
private Integer sumOfHoursAllocated = 0;
|
||||
|
||||
public void setSumOfHoursAllocated(Integer sumOfHoursAllocated) {
|
||||
this.sumOfHoursAllocated = sumOfHoursAllocated;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class QualityFormItem implements INewObject {
|
|||
}
|
||||
|
||||
public String getStringPosition() {
|
||||
return position == null ? "" : new Integer(position + 1).toString();
|
||||
return position == null ? "" : Integer.valueOf(position + 1).toString();
|
||||
}
|
||||
|
||||
public void setPosition(Integer newPosition) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class TaskQualityFormItem implements INewObject {
|
|||
}
|
||||
|
||||
public String getStringPosition() {
|
||||
return position == null ? "" : new Integer(position + 1).toString();
|
||||
return position == null ? "" : Integer.valueOf(position + 1).toString();
|
||||
}
|
||||
|
||||
private void setPosition(Integer position) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
package org.navalplanner.business.reports.dtos;
|
||||
|
||||
import static org.navalplanner.business.reports.dtos.WorkingArrangementsPerOrderDTO.removeAfterDate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
|
@ -142,7 +144,7 @@ public class SchedulingProgressPerOrderDTO {
|
|||
}
|
||||
|
||||
private Integer getHoursSpecifiedAtOrder(List<Task> tasks) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
for (Task each: tasks) {
|
||||
result += each.getHoursSpecifiedAtOrder();
|
||||
|
|
@ -151,7 +153,7 @@ public class SchedulingProgressPerOrderDTO {
|
|||
}
|
||||
|
||||
public Integer calculatePlannedHours(List<Task> tasks, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
for (Task each: tasks) {
|
||||
result += calculatePlannedHours(each, date);
|
||||
|
|
@ -160,31 +162,17 @@ public class SchedulingProgressPerOrderDTO {
|
|||
}
|
||||
|
||||
public Integer calculatePlannedHours(Task task, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
|
||||
final List<DayAssignment> dayAssignments = task.getDayAssignments();
|
||||
if (dayAssignments.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (DayAssignment dayAssignment : dayAssignments) {
|
||||
if (date == null || dayAssignment.getDay().compareTo(date) <= 0) {
|
||||
result += dayAssignment.getHours();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return DayAssignment.sum(removeAfterDate(dayAssignments, date))
|
||||
.roundToHours();
|
||||
}
|
||||
|
||||
public Integer calculateRealHours(Order order, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
final List<WorkReportLine> workReportLines = workReportLineDAO
|
||||
.findByOrderElementAndChildren(order);
|
||||
|
||||
if (workReportLines.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (WorkReportLine workReportLine : workReportLines) {
|
||||
final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate());
|
||||
if (date == null || workReportLineDate.compareTo(date) <= 0) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ package org.navalplanner.business.reports.dtos;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
|
@ -45,6 +46,29 @@ import org.navalplanner.business.workreports.entities.WorkReportLine;
|
|||
*/
|
||||
public class WorkingArrangementsPerOrderDTO {
|
||||
|
||||
/**
|
||||
* It returns a new list with the provided assignments such their dates are
|
||||
* inferior to endInclusive or endInclusive is null.
|
||||
*
|
||||
* @param assignments
|
||||
* @param endInclusive
|
||||
* @return a new list with the assignments satisfying the condition
|
||||
*/
|
||||
public static List<DayAssignment> removeAfterDate(
|
||||
Collection<? extends DayAssignment> assignments,
|
||||
LocalDate endInclusive) {
|
||||
if (endInclusive == null) {
|
||||
return new ArrayList<DayAssignment>(assignments);
|
||||
}
|
||||
List<DayAssignment> result = new ArrayList<DayAssignment>();
|
||||
for (DayAssignment each : assignments) {
|
||||
if (each.getDay().compareTo(endInclusive) <= 0) {
|
||||
result.add(each);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private IWorkReportLineDAO workReportLineDAO;
|
||||
|
||||
private String orderName;
|
||||
|
|
@ -140,7 +164,7 @@ public class WorkingArrangementsPerOrderDTO {
|
|||
}
|
||||
|
||||
private Integer getHoursSpecifiedAtOrder(List<Task> tasks) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
for (Task each: tasks) {
|
||||
result += each.getHoursSpecifiedAtOrder();
|
||||
|
|
@ -149,7 +173,7 @@ public class WorkingArrangementsPerOrderDTO {
|
|||
}
|
||||
|
||||
public Integer calculatePlannedHours(List<Task> tasks, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
for (Task each: tasks) {
|
||||
result += calculatePlannedHours(each, date);
|
||||
|
|
@ -157,24 +181,14 @@ public class WorkingArrangementsPerOrderDTO {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Integer calculatePlannedHours(Task task, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
|
||||
public Integer calculatePlannedHours(Task task, final LocalDate date) {
|
||||
final List<DayAssignment> dayAssignments = task.getDayAssignments();
|
||||
if (dayAssignments.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (DayAssignment dayAssignment : dayAssignments) {
|
||||
if (date == null || dayAssignment.getDay().compareTo(date) <= 0) {
|
||||
result += dayAssignment.getHours();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return DayAssignment.sum(removeAfterDate(dayAssignments, date))
|
||||
.roundToHours();
|
||||
}
|
||||
|
||||
public Integer calculateRealHours(List<Task> tasks, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
for (Task each: tasks) {
|
||||
result += calculateRealHours(each, date);
|
||||
|
|
@ -183,13 +197,10 @@ public class WorkingArrangementsPerOrderDTO {
|
|||
}
|
||||
|
||||
public Integer calculateRealHours(Task task, LocalDate date) {
|
||||
Integer result = new Integer(0);
|
||||
int result = 0;
|
||||
|
||||
final List<WorkReportLine> workReportLines = workReportLineDAO
|
||||
.findByOrderElementAndChildren(task.getOrderElement());
|
||||
if (workReportLines.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (WorkReportLine workReportLine : workReportLines) {
|
||||
final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate());
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ public class ManualAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
self.setVariable("status", new Integer(status), true);
|
||||
self.setVariable("status", Integer.valueOf(status), true);
|
||||
}
|
||||
|
||||
private class QueueRenderer implements ListitemRenderer {
|
||||
|
|
|
|||
|
|
@ -344,13 +344,15 @@ public class QueueComponent extends XulElement implements
|
|||
.getCapacityOn(PartialDay.wholeDay(queueElement.getEndDate()))
|
||||
.roundToHours();
|
||||
|
||||
int shadeWidth = new Long((24 - workableHours)
|
||||
* DatesMapperOnInterval.MILISECONDS_PER_HOUR
|
||||
/ datesMapper.getMilisecondsPerPixel()).intValue();
|
||||
int shadeWidth = Long.valueOf(
|
||||
(24 - workableHours)
|
||||
* DatesMapperOnInterval.MILISECONDS_PER_HOUR
|
||||
/ datesMapper.getMilisecondsPerPixel()).intValue();
|
||||
|
||||
int shadeLeft = new Long((workableHours - queueElement.getEndHour())
|
||||
* DatesMapperOnInterval.MILISECONDS_PER_HOUR
|
||||
/ datesMapper.getMilisecondsPerPixel()).intValue()
|
||||
int shadeLeft = Long.valueOf(
|
||||
(workableHours - queueElement.getEndHour())
|
||||
* DatesMapperOnInterval.MILISECONDS_PER_HOUR
|
||||
/ datesMapper.getMilisecondsPerPixel()).intValue()
|
||||
+ shadeWidth;
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
|
|
@ -514,14 +515,14 @@ public abstract class AssignedCriterionRequirementController<T, M> extends
|
|||
@Override
|
||||
public void validate(Component comp, Object value)
|
||||
throws WrongValueException {
|
||||
if (value == null) {
|
||||
value = new Integer(0);
|
||||
orderElementTotalHours.setValue((Integer) value);
|
||||
Validate.isTrue(value instanceof Integer);
|
||||
int intValue = value == null ? 0 : (Integer) value;
|
||||
if (intValue == 0) {
|
||||
orderElementTotalHours.setValue(0);
|
||||
}
|
||||
try {
|
||||
if (getElement() instanceof OrderLine) {
|
||||
((OrderLine) getElement())
|
||||
.setWorkHours((Integer) value);
|
||||
((OrderLine) getElement()).setWorkHours(intValue);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WrongValueException(comp, _(e.getMessage()));
|
||||
|
|
|
|||
|
|
@ -504,8 +504,8 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
Integer totalChargedHours = orderElement.getSumChargedHours() != null ? orderElement
|
||||
.getSumChargedHours().getTotalChargedHours() : new Integer(0);
|
||||
int totalChargedHours = orderElement.getSumChargedHours() != null ? orderElement
|
||||
.getSumChargedHours().getTotalChargedHours() : 0;
|
||||
BigDecimal assignedHours = new BigDecimal(totalChargedHours).setScale(2);
|
||||
|
||||
BigDecimal estimatedHours = new BigDecimal(taskElement.getSumOfHoursAllocated())
|
||||
|
|
|
|||
|
|
@ -883,7 +883,7 @@ public class AdvancedAllocationController extends GenericForwardComposer {
|
|||
Listitem item = new Listitem();
|
||||
item.appendChild(new Listcell(label));
|
||||
advancedAllocationVerticalPagination.appendChild(item);
|
||||
verticalPaginationIndexes.add(new Integer(i));
|
||||
verticalPaginationIndexes.add(i);
|
||||
}
|
||||
if (!rowsCached.isEmpty()) {
|
||||
advancedAllocationVerticalPagination.setSelectedIndex(0);
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ public class LimitingAllocationRow {
|
|||
}
|
||||
|
||||
public String getPriorityStr() {
|
||||
return (new Integer(getPriority()).toString());
|
||||
return Integer.valueOf(getPriority()).toString();
|
||||
}
|
||||
|
||||
public void setPriorityStr(String priority) {
|
||||
|
|
|
|||
|
|
@ -37,13 +37,10 @@ import org.navalplanner.web.planner.allocation.TaskInformation;
|
|||
import org.navalplanner.web.planner.allocation.TaskInformation.ITotalHoursCalculationListener;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.navalplanner.web.planner.taskedition.TaskPropertiesController.ResourceAllocationTypeEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
import org.zkoss.ganttz.timetracker.ICellForDetailItemRenderer;
|
||||
import org.zkoss.ganttz.timetracker.OnColumnsRowRenderer;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
@ -231,7 +228,7 @@ public class LimitingResourceAllocationController extends GenericForwardComposer
|
|||
Listbox result = listbox();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
Listitem item = new Listitem();
|
||||
Listcell cell = new Listcell(new Integer(i).toString());
|
||||
Listcell cell = new Listcell(i + "");
|
||||
cell.setParent(item);
|
||||
if (i == selectedValue) {
|
||||
item.setSelected(true);
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.joda.time.LocalDate;
|
||||
|
|
@ -427,7 +427,7 @@ public class ResourceLoadController implements Composer {
|
|||
Comboitem item = new Comboitem();
|
||||
item.setLabel(firstName.substring(0, 1) + " - " + lastName.substring(0, 1));
|
||||
item.setDescription(firstName + " - " + lastName);
|
||||
item.setValue(new Integer(position));
|
||||
item.setValue(position);
|
||||
filterByNameCombo.appendChild(item);
|
||||
if(resourceLoadModel.getPageFilterPosition() == position) {
|
||||
filterByNameCombo.setSelectedItemApi(item);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public abstract class GenericRESTService<E extends IntegrationEntity,
|
|||
|
||||
List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList =
|
||||
new ArrayList<InstanceConstraintViolationsDTO>();
|
||||
Long numItem = new Long(1);
|
||||
long numItem = 1;
|
||||
|
||||
for (DTO entityDTO : entityDTOs) {
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ public class SubcontractServiceREST implements ISubcontractService {
|
|||
});
|
||||
} catch (ValidationException e) {
|
||||
InstanceConstraintViolationsDTO violation = ConstraintViolationConverter
|
||||
.toDTO(new InstanceConstraintViolationsDTOId(new Long(1),
|
||||
.toDTO(new InstanceConstraintViolationsDTOId(Long.valueOf(1),
|
||||
orderElementDTO.code, OrderDTO.ENTITY_TYPE), e);
|
||||
throw new ViolationError(violation);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue