updates cleanup.
This commit is contained in:
@@ -11,19 +11,21 @@ public class AccountReservationList extends ArrayList<Reservation> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean add(final Reservation reservation) {
|
public boolean add(final Reservation reservation) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
Reservation rsrv = this.find(reservation.getReservation_number());
|
||||||
|
if( rsrv != null ){
|
||||||
|
result = false;
|
||||||
|
throw new DuplicateObjectException(String.format("Error Duplicate: Reservation %s", rsrv.getReservation_number()));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
result = reservation.checkValid();
|
result = reservation.checkValid();
|
||||||
} catch (Exception e) {
|
} catch (ReservationException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Reservation rsrv : this) {
|
if(result){
|
||||||
result = reservation.getReservation_number().compareTo(rsrv.getReservation_number()) == 0;
|
reservation.setReservation_number(AccountReservationList.reservationSerial(reservation));
|
||||||
if (result) {
|
result = super.add(reservation);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reservation.setReservation_number(AccountReservationList.reservationSerial(reservation));
|
return result;
|
||||||
return super.add(reservation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public abstract class Reservation {
|
|||||||
throw new IllegalOperationException ("Invalid Change, reservation has completed.");
|
throw new IllegalOperationException ("Invalid Change, reservation has completed.");
|
||||||
}
|
}
|
||||||
if (ZonedDateTime.now().compareTo(this.reservation_start_date) > -1) {
|
if (ZonedDateTime.now().compareTo(this.reservation_start_date) > -1) {
|
||||||
throw new IllegalOperationException ("Invalid Change, reservation started.");
|
throw new IllegalOperationException ("Invalid Change, reservation time started.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user