use of com.github.drbookings.model.ser.CleaningBeanSer in project drbookings by DrBookings.
the class DataStore method transform.
public static CleaningBeanSer transform(final CleaningEntry c) {
final CleaningBeanSer b = new CleaningBeanSer();
b.date = c.getDate();
b.name = c.getElement().getName();
b.room = c.getRoom().getName();
b.calendarIds = c.getCalendarIds();
b.cleaningCosts = c.getCleaningCosts();
if (c.getBooking() != null) {
b.bookingId = c.getBooking().getId();
}
return b;
}
use of com.github.drbookings.model.ser.CleaningBeanSer in project drbookings by DrBookings.
the class DataStore method load.
public void load(final MainManager manager) {
final List<BookingBean> bookingsToAdd = new ArrayList<>();
for (final BookingBeanSer bb : (Iterable<BookingBeanSer>) () -> getBookingsSer().stream().sorted((b1, b2) -> b1.checkInDate.compareTo(b2.checkInDate)).iterator()) {
try {
final BookingBean b = manager.createBooking(bb.bookingId, bb.checkInDate, bb.checkOutDate, bb.guestName, bb.roomName, bb.source);
// b.setGrossEarnings(bb.grossEarnings);
b.setGrossEarningsExpression(bb.grossEarningsExpression);
b.setWelcomeMailSend(bb.welcomeMailSend);
b.setCheckInNote(bb.checkInNote);
b.setPaymentDone(bb.paymentDone);
b.setSpecialRequestNote(bb.specialRequestNote);
b.setCheckOutNote(bb.checkOutNote);
b.setExternalId(bb.externalId);
b.setCalendarIds(bb.calendarIds);
b.setCleaningFees(bb.cleaningFees);
b.setServiceFeesPercent(bb.serviceFeePercent);
b.setDateOfPayment(bb.dateOfPayment);
b.setSplitBooking(bb.splitBooking);
b.setPayments(Payment.transform(bb.paymentsSoFar));
bookingsToAdd.add(b);
} catch (final Exception e) {
if (logger.isErrorEnabled()) {
logger.error(e.getLocalizedMessage(), e);
}
}
}
bookingsToAdd.forEach(b -> {
try {
manager.addBooking(b);
} catch (final OverbookingException e) {
if (logger.isWarnEnabled()) {
logger.warn(e.getLocalizedMessage());
}
}
});
if (logger.isDebugEnabled()) {
logger.debug(bookingsToAdd.size() + " added");
}
for (final CleaningBeanSer cb : getCleaningsSer()) {
final Optional<BookingBean> b = manager.getBooking(cb.bookingId);
if (b.isPresent()) {
manager.addCleaning(cb.date, cb.name, b.get()).setCalendarIds(cb.calendarIds).setCleaningCosts(cb.cleaningCosts);
} else {
if (logger.isWarnEnabled()) {
logger.warn("Failed to add cleaning " + cb + ", failed to find booking for ID " + cb.bookingId);
}
}
}
}
use of com.github.drbookings.model.ser.CleaningBeanSer in project drbookings by DrBookings.
the class CleaningCostsAdder method main.
public static void main(final String[] args) throws Exception {
final File file = new File("/home/alex/bookings.xml");
final float cleaningCosts = 30;
final DataStore ds = new XMLStorage().load(file);
for (final CleaningBeanSer bs : ds.getCleaningsSer()) {
if (bs.name.equalsIgnoreCase("Natalia")) {
bs.cleaningCosts = cleaningCosts;
}
}
new XMLStorage().save(ds, file);
}
use of com.github.drbookings.model.ser.CleaningBeanSer in project drbookings by DrBookings.
the class Anonymiser method main.
public static void main(final String[] args) throws Exception {
final File file = new File("/home/alex/bookings-anonym.xml");
new BackupCreator().makeBackup(file);
final DataStore ds = new XMLStorage().load(file);
for (final Iterator<BookingBeanSer> it = ds.getBookingsSer().iterator(); it.hasNext(); ) {
final BookingBeanSer bs = it.next();
bs.guestName = new RandomString().ofLength(bs.guestName.length()).toString();
}
for (final Iterator<CleaningBeanSer> it = ds.getCleaningsSer().iterator(); it.hasNext(); ) {
final CleaningBeanSer bs = it.next();
bs.name = new RandomString().ofLength(bs.name.length()).toString();
}
new XMLStorage().save(ds, file);
}
Aggregations