Add method in WorkReportType to check if it is a monthly timesheet
FEA: ItEr76S28UserDashboard
This commit is contained in:
parent
6ebcf7f830
commit
e5dda1f10f
2 changed files with 12 additions and 8 deletions
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue