diff --git a/libreplan-business/src/main/java/org/libreplan/business/workreports/entities/WorkReportType.java b/libreplan-business/src/main/java/org/libreplan/business/workreports/entities/WorkReportType.java index e77a9b48d..ef5652b2e 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/workreports/entities/WorkReportType.java +++ b/libreplan-business/src/main/java/org/libreplan/business/workreports/entities/WorkReportType.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import org.apache.commons.lang.StringUtils; import org.hibernate.NonUniqueResultException; import org.hibernate.validator.AssertTrue; import org.hibernate.validator.NotEmpty; @@ -522,4 +523,13 @@ public class WorkReportType extends IntegrationEntity implements IHumanIdentifia public String getHumanId() { return name; } + + public boolean isMonthlyTimesheetsType() { + if (StringUtils.isBlank(name)) { + return false; + } + return name.equals(PredefinedWorkReportTypes.MONTHLY_TIMESHEETS + .getName()); + } + } \ No newline at end of file diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java index f5f580174..ee911b111 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java @@ -151,7 +151,7 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements @Override @Transactional(readOnly = true) public void initEdit(WorkReportType workReportType) { - if (isMonthlyTimesheetsWorkReportType(workReportType)) { + if (workReportType.isMonthlyTimesheetsType()) { throw new IllegalArgumentException( "Monthly timesheets work report type cannot be edited"); } @@ -166,12 +166,6 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements initOldCodes(); } - private boolean isMonthlyTimesheetsWorkReportType( - WorkReportType workReportType) { - return workReportType.getName().equals( - PredefinedWorkReportTypes.MONTHLY_TIMESHEETS.getName()); - } - private WorkReportType getFromDB(WorkReportType workReportType) { return getFromDB(workReportType.getId()); } @@ -226,7 +220,7 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements @Override @Transactional public void confirmRemove(WorkReportType workReportType) { - if (isMonthlyTimesheetsWorkReportType(workReportType)) { + if (workReportType.isMonthlyTimesheetsType()) { throw new IllegalArgumentException( "Monthly timesheets work report type cannot be removed"); }