Convert control statements one liners to blocks
The code convention we are using forbids the use of one liners control statements. FEA: ItEr62S05BugFixing
This commit is contained in:
parent
300e002add
commit
c352bb282a
21 changed files with 92 additions and 47 deletions
|
|
@ -60,8 +60,9 @@ public class TypeOfWorkHoursDAO extends IntegrationEntityDAO<TypeOfWorkHours>
|
|||
c.add(Restrictions.eq("code", code));
|
||||
|
||||
TypeOfWorkHours found = (TypeOfWorkHours) c.uniqueResult();
|
||||
if (found==null)
|
||||
if (found == null) {
|
||||
throw new InstanceNotFoundException(code, TypeOfWorkHours.class.getName());
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,14 +109,16 @@ public class CostCategory extends IntegrationEntity {
|
|||
|
||||
public void addHourCost(HourCost hourCost) {
|
||||
hourCosts.add(hourCost);
|
||||
if(hourCost.getCategory()!=this)
|
||||
if (hourCost.getCategory() != this) {
|
||||
hourCost.setCategory(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeHourCost(HourCost hourCost) {
|
||||
hourCosts.remove(hourCost);
|
||||
if(hourCost.getCategory()==this)
|
||||
if (hourCost.getCategory() == this) {
|
||||
hourCost.setCategory(null);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAddHourCost(HourCost hourCost) {
|
||||
|
|
|
|||
|
|
@ -126,10 +126,12 @@ public class HourCost extends IntegrationEntity {
|
|||
public void setCategory(CostCategory category) {
|
||||
CostCategory oldCategory = this.category;
|
||||
this.category = category;
|
||||
if(oldCategory!=null)
|
||||
if (oldCategory != null) {
|
||||
oldCategory.removeHourCost(this);
|
||||
if(category!=null && !category.getHourCosts().contains(this))
|
||||
}
|
||||
if (category != null && !category.getHourCosts().contains(this)) {
|
||||
category.addHourCost(this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActiveAtDate(LocalDate date) {
|
||||
|
|
|
|||
|
|
@ -132,10 +132,11 @@ public class ResourcesCostCategoryAssignment extends IntegrationEntity {
|
|||
public void setResource(Resource resource) {
|
||||
Resource oldResource = this.resource;
|
||||
this.resource = resource;
|
||||
if(oldResource!=null)
|
||||
if (oldResource != null) {
|
||||
oldResource.removeResourcesCostCategoryAssignment(this);
|
||||
if(resource!=null &&
|
||||
!resource.getResourcesCostCategoryAssignments().contains(this)) {
|
||||
}
|
||||
if (resource != null
|
||||
&& !resource.getResourcesCostCategoryAssignments().contains(this)) {
|
||||
resource.addResourcesCostCategoryAssignment(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,9 @@ public class ExternalCompanyDAO extends GenericDAOHibernate<ExternalCompany, Lon
|
|||
c.add(Restrictions.eq("name", name));
|
||||
|
||||
ExternalCompany found = (ExternalCompany) c.uniqueResult();
|
||||
if (found == null)
|
||||
if (found == null) {
|
||||
throw new InstanceNotFoundException(name, ExternalCompany.class.getName());
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
|
@ -101,8 +102,9 @@ public class ExternalCompanyDAO extends GenericDAOHibernate<ExternalCompany, Lon
|
|||
c.add(Restrictions.eq("nif", nif));
|
||||
|
||||
ExternalCompany found = (ExternalCompany) c.uniqueResult();
|
||||
if (found == null)
|
||||
if (found == null) {
|
||||
throw new InstanceNotFoundException(nif, ExternalCompany.class.getName());
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,8 +100,9 @@ public abstract class CriterionRequirementHandler<T, S, R> implements
|
|||
List<T> listOrderElements = getAllChildren(orderElement);
|
||||
listOrderElements.add(orderElement);
|
||||
for (T element : listOrderElements) {
|
||||
if (existSameCriterionRequirement(element, newRequirement))
|
||||
if (existSameCriterionRequirement(element, newRequirement)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -125,8 +126,9 @@ public abstract class CriterionRequirementHandler<T, S, R> implements
|
|||
return true;
|
||||
}
|
||||
for (HoursGroup hoursGroup : getHoursGroups(orderLine)) {
|
||||
if (hoursGroup.existSameCriterionRequirement(newRequirement))
|
||||
if (hoursGroup.existSameCriterionRequirement(newRequirement)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -137,8 +139,9 @@ public abstract class CriterionRequirementHandler<T, S, R> implements
|
|||
T orderElement, CriterionRequirement newRequirement) {
|
||||
Criterion criterion = newRequirement.getCriterion();
|
||||
for (CriterionRequirement requirement : getCriterionRequirements(orderElement)) {
|
||||
if (requirement.getCriterion().equals(criterion))
|
||||
if (requirement.getCriterion().equals(criterion)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,19 +434,23 @@ public class Order extends OrderLineGroup {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null || isNewObject())
|
||||
}
|
||||
if (obj == null || isNewObject()) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Order)) {
|
||||
return false;
|
||||
}
|
||||
Order other = (Order) obj;
|
||||
if (getId() == null) {
|
||||
if (other.getId() != null)
|
||||
if (other.getId() != null) {
|
||||
return false;
|
||||
} else if (!getId().equals(other.getId()))
|
||||
}
|
||||
} else if (!getId().equals(other.getId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -221,10 +221,12 @@ public class LimitingResourceQueueElement extends BaseEntity {
|
|||
}
|
||||
|
||||
public void remove(LimitingResourceQueueDependency d) {
|
||||
if (dependenciesAsOrigin.contains(d))
|
||||
if (dependenciesAsOrigin.contains(d)) {
|
||||
dependenciesAsOrigin.remove(d);
|
||||
if (dependenciesAsDestiny.contains(d))
|
||||
}
|
||||
if (dependenciesAsDestiny.contains(d)) {
|
||||
dependenciesAsDestiny.remove(d);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<LimitingResourceQueueDependency> getDependenciesAsOrigin() {
|
||||
|
|
|
|||
|
|
@ -106,8 +106,9 @@ public class QualityFormItem implements INewObject {
|
|||
@SuppressWarnings("unused")
|
||||
@AssertTrue(message = "percentage should be greater than 0% and less than 100%")
|
||||
public boolean checkConstraintQualityFormItemPercentage() {
|
||||
if (percentage == null)
|
||||
if (percentage == null) {
|
||||
return true;
|
||||
}
|
||||
return ((percentage.compareTo(new BigDecimal(100).setScale(2)) <= 0) && (percentage
|
||||
.compareTo(new BigDecimal(0).setScale(2)) > 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,8 +120,9 @@ public class TaskQualityFormItem implements INewObject {
|
|||
@SuppressWarnings("unused")
|
||||
@AssertTrue(message = "percentage should be greater than 0% and less than 100%")
|
||||
public boolean checkConstraintQualityFormItemPercentage() {
|
||||
if (percentage == null)
|
||||
if (percentage == null) {
|
||||
return true;
|
||||
}
|
||||
if ((percentage.compareTo(new BigDecimal(100).setScale(2)) <= 0)
|
||||
&& (percentage.compareTo(new BigDecimal(0).setScale(2)) > 0)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1006,8 +1006,9 @@ public abstract class Resource extends IntegrationEntity {
|
|||
|
||||
public void addResourcesCostCategoryAssignment(ResourcesCostCategoryAssignment assignment) {
|
||||
resourcesCostCategoryAssignments.add(assignment);
|
||||
if(assignment.getResource()!=this)
|
||||
if (assignment.getResource() != this) {
|
||||
assignment.setResource(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void addUnvalidatedResourcesCostCategoryAssignment(
|
||||
|
|
@ -1019,8 +1020,9 @@ public abstract class Resource extends IntegrationEntity {
|
|||
|
||||
public void removeResourcesCostCategoryAssignment(ResourcesCostCategoryAssignment assignment) {
|
||||
resourcesCostCategoryAssignments.remove(assignment);
|
||||
if(assignment.getResource()==this)
|
||||
if (assignment.getResource() == this) {
|
||||
assignment.setResource(null);
|
||||
}
|
||||
}
|
||||
|
||||
@AssertTrue(message="Some criterion satisfactions overlap in time")
|
||||
|
|
|
|||
|
|
@ -237,19 +237,23 @@ public class Scenario extends BaseEntity {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null || isNewObject())
|
||||
}
|
||||
if (obj == null || isNewObject()) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Scenario)) {
|
||||
return false;
|
||||
}
|
||||
Scenario other = (Scenario) obj;
|
||||
if (getId() == null) {
|
||||
if (other.getId() != null)
|
||||
if (other.getId() != null) {
|
||||
return false;
|
||||
} else if (!getId().equals(other.getId()))
|
||||
}
|
||||
} else if (!getId().equals(other.getId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,9 @@ public class DescriptionValue implements INewObject {
|
|||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
if (value == null)
|
||||
if (value == null) {
|
||||
value = "";
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,8 +201,9 @@ public class OrderElementTest {
|
|||
try {
|
||||
InvalidValue[] invalidValues =
|
||||
orderElementValidator.getInvalidValues(orderElement);
|
||||
if (invalidValues.length > 0)
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
} catch (ValidationException e) {
|
||||
fail("It not should throw an exception");
|
||||
}
|
||||
|
|
@ -216,8 +217,9 @@ public class OrderElementTest {
|
|||
try {
|
||||
InvalidValue[] invalidValues =
|
||||
orderElementValidator.getInvalidValues(orderElement);
|
||||
if (invalidValues.length > 0)
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
} catch (ValidationException e) {
|
||||
fail("It no should throw an exception");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ public class CriterionRequirementWrapper implements INewObject {
|
|||
}
|
||||
|
||||
public String getCriterionAndType() {
|
||||
if(criterionWithItsType == null) return criterionAndType;
|
||||
if (criterionWithItsType == null) {
|
||||
return criterionAndType;
|
||||
}
|
||||
return criterionWithItsType.getNameAndType();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -364,8 +364,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
private AssignedHoursToOrderElementController assignedHoursController;
|
||||
|
||||
public void setupAssignedHoursToOrderElementController() throws Exception {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
if (assignedHoursController == null) {
|
||||
|
|
@ -382,8 +383,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
private ManageOrderElementAdvancesController manageOrderElementAdvancesController;
|
||||
|
||||
public void setupManageOrderElementAdvancesController() throws Exception {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
Component orderElementAdvances = editWindow
|
||||
|
|
@ -404,8 +406,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
public void setupAssignedLabelsToOrderElementController()
|
||||
throws Exception {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
if (assignedLabelsController == null) {
|
||||
|
|
@ -422,8 +425,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
public void setupAssignedCriterionRequirementsToOrderElementController()
|
||||
throws Exception {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
if (assignedCriterionRequirementController == null) {
|
||||
|
|
@ -444,8 +448,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
public void setupAssignedMaterialsToOrderElementController()
|
||||
throws Exception {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
if (assignedMaterialsController == null) {
|
||||
|
|
@ -462,8 +467,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
private AssignedTaskQualityFormsToOrderElementController assignedTaskQualityFormController;
|
||||
|
||||
public void setupAssignedTaskQualityFormsToOrderElementController() throws Exception {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
Component orderElementTaskQualityForms = editWindow
|
||||
|
|
@ -482,8 +488,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
private OrderAuthorizationController orderAuthorizationController;
|
||||
|
||||
public void setupOrderAuthorizationController() {
|
||||
if (!confirmLastTab())
|
||||
if (!confirmLastTab()) {
|
||||
return;
|
||||
}
|
||||
setCurrentTab();
|
||||
|
||||
Component orderElementAuthorizations = editWindow
|
||||
|
|
@ -1220,10 +1227,12 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void showOrderElementFilter() {
|
||||
if (orderFilter != null)
|
||||
if (orderFilter != null) {
|
||||
orderFilter.setVisible(false);
|
||||
if (orderElementFilter != null)
|
||||
}
|
||||
if (orderElementFilter != null) {
|
||||
orderElementFilter.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void showCreateButtons(boolean showCreate) {
|
||||
|
|
|
|||
|
|
@ -334,8 +334,9 @@ public class CutyPrint {
|
|||
}
|
||||
if (generatedCSS != null) {
|
||||
return generatedCSS.getAbsolutePath();
|
||||
} else
|
||||
} else {
|
||||
return srFile;
|
||||
}
|
||||
}
|
||||
|
||||
private static String widthForTaskNamesColumnCSS(
|
||||
|
|
|
|||
|
|
@ -298,8 +298,9 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
|
||||
private String showInvalidValues(ValidationException e) {
|
||||
String result = "";
|
||||
for (InvalidValue each : e.getInvalidValues())
|
||||
for (InvalidValue each : e.getInvalidValues()) {
|
||||
result = result + each.getMessage();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,8 +208,9 @@ public class MachineModel implements IMachineModel {
|
|||
@Transactional(readOnly = true)
|
||||
public List<MachineWorkersConfigurationUnit> getConfigurationUnitsOfMachine() {
|
||||
ArrayList<MachineWorkersConfigurationUnit> elements = new ArrayList<MachineWorkersConfigurationUnit>();
|
||||
if ( machine != null )
|
||||
if (machine != null) {
|
||||
elements.addAll(machine.getConfigurationUnits());
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,12 +265,14 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
|
||||
private boolean showInvalidProperty() {
|
||||
if (getWorkReport() != null) {
|
||||
if (!validateWorkReport())
|
||||
if (!validateWorkReport()) {
|
||||
return true;
|
||||
}
|
||||
for (WorkReportLine workReportLine : getWorkReport()
|
||||
.getWorkReportLines()) {
|
||||
if (!validateWorkReportLine(workReportLine))
|
||||
if (!validateWorkReportLine(workReportLine)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -320,10 +320,11 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
|
|||
}
|
||||
|
||||
private PositionInWorkReportEnum getPosition(boolean sharedByLines) {
|
||||
if (sharedByLines)
|
||||
if (sharedByLines) {
|
||||
return PositionInWorkReportEnum.HEADING;
|
||||
else
|
||||
} else {
|
||||
return PositionInWorkReportEnum.LINE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue