Search in sources :

Example 6 with BookingBeanSer

use of com.github.drbookings.model.ser.BookingBeanSer in project drbookings by DrBookings.

the class ICalBookingFactory method build.

@Override
public Collection<BookingBeanSer> build() throws IOException {
    final Collection<BookingBeanSer> result = new ArrayList<>();
    final List<ICalendar> icals = Biweekly.parse(file).all();
    for (final ICalendar ical : icals) {
        for (final VEvent e : ical.getEvents()) {
            try {
                result.add(processEvent(e));
            } catch (final Exception ex) {
                if (logger.isInfoEnabled()) {
                    logger.info("Failed to process event ", e);
                }
            // ex.printStackTrace();
            }
        }
    }
    return result;
}
Also used : VEvent(biweekly.component.VEvent) ArrayList(java.util.ArrayList) ICalendar(biweekly.ICalendar) BookingBeanSer(com.github.drbookings.model.ser.BookingBeanSer) IOException(java.io.IOException)

Example 7 with BookingBeanSer

use of com.github.drbookings.model.ser.BookingBeanSer in project drbookings by DrBookings.

the class DataStore method transform.

public static BookingBeanSer transform(final BookingBean bb) {
    final BookingBeanSer result = new BookingBeanSer();
    result.checkInDate = bb.getCheckIn();
    result.checkOutDate = bb.getCheckOut();
    result.bookingId = bb.getId();
    // result.grossEarnings = bb.getGrossEarnings();
    result.grossEarningsExpression = bb.getGrossEarningsExpression();
    result.guestName = bb.getGuest().getName();
    result.roomName = bb.getRoom().getName();
    result.source = bb.getBookingOrigin().getName();
    result.welcomeMailSend = bb.isWelcomeMailSend();
    result.serviceFee = bb.getServiceFee();
    result.serviceFeePercent = bb.getServiceFeesPercent();
    result.cleaningFees = bb.getCleaningFees();
    result.checkInNote = bb.getCheckInNote();
    result.paymentDone = bb.isPaymentDone();
    result.specialRequestNote = bb.getSpecialRequestNote();
    result.checkOutNote = bb.getCheckOutNote();
    result.calendarIds = bb.getCalendarIds();
    result.dateOfPayment = bb.getDateOfPayment();
    result.splitBooking = bb.isSplitBooking();
    result.paymentsSoFar = PaymentSer.transform(bb.getPayments());
    return result;
}
Also used : BookingBeanSer(com.github.drbookings.model.ser.BookingBeanSer)

Example 8 with BookingBeanSer

use of com.github.drbookings.model.ser.BookingBeanSer 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);
}
Also used : XMLStorage(com.github.drbookings.ser.XMLStorage) CleaningBeanSer(com.github.drbookings.model.ser.CleaningBeanSer) BackupCreator(com.github.ktools1000.io.BackupCreator) DataStore(com.github.drbookings.ser.DataStore) RandomString(com.github.ktools1000.RandomString) File(java.io.File) BookingBeanSer(com.github.drbookings.model.ser.BookingBeanSer)

Aggregations

BookingBeanSer (com.github.drbookings.model.ser.BookingBeanSer)8 DataStore (com.github.drbookings.ser.DataStore)3 XMLStorage (com.github.drbookings.ser.XMLStorage)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 CleaningBeanSer (com.github.drbookings.model.ser.CleaningBeanSer)2 LocalDate (java.time.LocalDate)2 ICalendar (biweekly.ICalendar)1 VEvent (biweekly.component.VEvent)1 OverbookingException (com.github.drbookings.OverbookingException)1 BookingBean (com.github.drbookings.model.data.BookingBean)1 RandomString (com.github.ktools1000.RandomString)1 BackupCreator (com.github.ktools1000.io.BackupCreator)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Row (org.apache.poi.ss.usermodel.Row)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1