ItEr23S08CUEdicionCalendarioLaboral: Checking and managing errors when expiring date is set.
This commit is contained in:
parent
0177a578e8
commit
65503d0318
5 changed files with 42 additions and 7 deletions
|
|
@ -651,4 +651,12 @@ public class BaseCalendarTest {
|
|||
calendar.newVersion(new LocalDate());
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testNotAllowSetExpiringDateIfNotNextCalendar() {
|
||||
BaseCalendar calendar = createBasicCalendar();
|
||||
assertThat(calendar.getNextCalendar(), nullValue());
|
||||
|
||||
calendar.setExpiringDate(WEDNESDAY_LOCAL_DATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,13 +461,16 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void setDateValidFrom(Date date) {
|
||||
Component component = editWindow.getFellow("dateValidFrom");
|
||||
|
||||
try {
|
||||
baseCalendarModel.setDateValidFrom(date);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WrongValueException(
|
||||
editWindow.getFellow("dateValidFrom"),
|
||||
e.getMessage());
|
||||
throw new WrongValueException(component, e.getMessage());
|
||||
} catch (UnsupportedOperationException e) {
|
||||
throw new WrongValueException(component, e.getMessage());
|
||||
}
|
||||
Clients.closeErrorBox(component);
|
||||
}
|
||||
|
||||
public Date getExpiringDate() {
|
||||
|
|
@ -475,8 +478,17 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void setExpiringDate(Date date) {
|
||||
// TODO check possible wrong dates
|
||||
baseCalendarModel.setExpiringDate(date);
|
||||
Component component = editWindow.getFellow("expiringDate");
|
||||
|
||||
try {
|
||||
baseCalendarModel.setExpiringDate((new LocalDate(date)).plusDays(1)
|
||||
.toDateTimeAtStartOfDay().toDate());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WrongValueException(component, e.getMessage());
|
||||
} catch (UnsupportedOperationException e) {
|
||||
throw new WrongValueException(component, e.getMessage());
|
||||
}
|
||||
Clients.closeErrorBox(component);
|
||||
}
|
||||
|
||||
public void goToCreateCopyForm(BaseCalendar baseCalendar) {
|
||||
|
|
@ -801,4 +813,8 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
Util.reloadBindings(createNewVersion);
|
||||
}
|
||||
|
||||
public boolean isLastVersion() {
|
||||
return baseCalendarModel.isLastVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ public class BaseCalendarModel implements IBaseCalendarModel {
|
|||
if ((getBaseCalendar() != null)
|
||||
&& (getBaseCalendar().getExpiringDate() != null)) {
|
||||
getBaseCalendar()
|
||||
.setExpiringDate((new LocalDate(date)).plusDays(1));
|
||||
.setExpiringDate(date);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -412,6 +412,14 @@ public class BaseCalendarModel implements IBaseCalendarModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLastVersion() {
|
||||
if (getBaseCalendar() != null) {
|
||||
return (getBaseCalendar().getNextCalendar() == null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Final conversation steps
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ public interface IBaseCalendarModel {
|
|||
|
||||
void createNewVersion(Date date);
|
||||
|
||||
boolean isLastVersion();
|
||||
|
||||
/*
|
||||
* Final conversation steps
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@
|
|||
<datebox id="dateValidFrom" value="@{controller.dateValidFrom}"
|
||||
disabled="@{controller.isDateValidFromPast}" />
|
||||
<label value="${i18n:_('to')}" />
|
||||
<datebox value="@{controller.expiringDate}" />
|
||||
<datebox id="expiringDate" value="@{controller.expiringDate}"
|
||||
disabled="@{controller.isLastVersion}" />
|
||||
</hbox>
|
||||
|
||||
<hbox>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue