Refactored out an edit test.
This commit is contained in:
parent
985ed872e8
commit
9bfd71ee9e
@ -60,6 +60,11 @@ public class ApplicationPeriodFacade {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean isEditing(final ApplicationPeriod newPeriod, final ApplicationPeriod foundPeriod) {
|
||||
return (newPeriod.getId() != null && newPeriod.equals(foundPeriod));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the new period overlaps with some of the saved periods
|
||||
* Different conditions that is handled is for example that a newPeriod that is edited cannot "overlap with itself" and
|
||||
@ -69,11 +74,7 @@ public class ApplicationPeriodFacade {
|
||||
*/
|
||||
public boolean doesPeriodOverlap(final ApplicationPeriod newPeriod) {
|
||||
for(ApplicationPeriod foundPeriod : applicationPeriodDao.findAll()) {
|
||||
if(testForInvalidData(foundPeriod)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(newPeriod.getId() != null && newPeriod.equals(foundPeriod)) {
|
||||
if(testForInvalidData(foundPeriod) || isEditing(newPeriod, foundPeriod)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user