Search in sources :

Example 1 with RESCarType

use of org.talend.services.reservation.types.RESCarType in project tesb-rt-se by Talend.

the class ReservationServiceImpl method getCarReservation.

private ConfirmationType getCarReservation(ReservationType reservation) {
    ConfirmationType status = resFactory.createConfirmationType();
    status.setCustomer(reservation.getCustomer());
    status.setFromDate(reservation.getFromDate());
    status.setToDate(reservation.getToDate());
    String clazz = reservation.getCar().getClazz();
    status.setCreditPoints(new BigInteger("0"));
    if (clazz.equalsIgnoreCase("BASIC")) {
        status.setCreditPoints(new BigInteger("120"));
    } else if (clazz.equalsIgnoreCase("STANDRAD")) {
        status.setCreditPoints(new BigInteger("180"));
    } else if (clazz.equalsIgnoreCase("SPORT")) {
        status.setCreditPoints(new BigInteger("210"));
    } else if (clazz.equalsIgnoreCase("SUV")) {
        status.setCreditPoints(new BigInteger("280"));
    } else if (clazz.equalsIgnoreCase("DELUX")) {
        status.setCreditPoints(new BigInteger("280"));
    }
    // status.setCode(RESStatucCodeType.OK);
    if (reservation.getReservationId() != null) {
        status.setReservationId(reservation.getReservationId());
    }
    status.setDescription("Your reservation is booked!");
    RESCarType car = reservation.getCar();
    status.setCar(car);
    if (car != null) {
        // check design model
        String model = car.getDesignModel();
        if ((model != null) && (model.equalsIgnoreCase("GOLF"))) {
            // 
            // status.setCode(RESStatucCodeType.FAILED);
            status.setDescription("Your reservation failed! This car is booked by an other customer already.");
        }
    }
    return status;
}
Also used : ConfirmationType(org.talend.services.reservation.types.ConfirmationType) RESCarType(org.talend.services.reservation.types.RESCarType) BigInteger(java.math.BigInteger)

Example 2 with RESCarType

use of org.talend.services.reservation.types.RESCarType in project tesb-rt-se by Talend.

the class CarRentalClientGui method actionPerformed.

public void actionPerformed(ActionEvent e) {
    if (e.getSource().equals(cmdFind)) {
        if (search != null) {
            search.search((String) cUser.getSelectedItem(), tPickupDate.getText(), tReturnDate.getText());
            ctm.setData(search.getCars());
        }
        cardlist.show(content, SELECT);
    } else if (e.getSource().equals(cmdFindCancel) || e.getSource().equals(cmdClose)) {
        this.appFrame.dispose();
    } else if (e.getSource().equals(cmdSelect)) {
        int pos = selectTable.getSelectedRow();
        if (pos > -1) {
            if (search != null) {
                RESStatusType resStatus = reserve.reserveCar(search.getCustomer(), search.getCars().get(pos), tPickupDate.getText(), tReturnDate.getText());
                ConfirmationType confirm = reserve.getConfirmation(resStatus, search.getCustomer(), search.getCars().get(pos), tPickupDate.getText(), tReturnDate.getText());
                RESCarType car = confirm.getCar();
                CustomerDetailsType customer = confirm.getCustomer();
                lStatus.setText(confirm.getDescription());
                tReservationId.setText(confirm.getReservationId());
                tName.setText(customer.getName());
                tEMail.setText(customer.getEmail());
                tCity.setText(customer.getCity());
                tStatus.setText(customer.getStatus().name());
                tBrand.setText(car.getBrand());
                tModel.setText(car.getDesignModel());
                tPickup.setText(confirm.getFromDate());
                tReturn.setText(confirm.getToDate());
                tDaily.setText(car.getRateDay());
                tWeekEnd.setText(car.getRateWeekend());
                tCredits.setText(confirm.getCreditPoints().toString());
            }
            cardlist.show(content, CONFIRM);
        }
    } else if (e.getSource().equals(cmdSelectBack)) {
        cardlist.show(content, FIND);
    }
}
Also used : ConfirmationType(org.talend.services.reservation.types.ConfirmationType) RESCarType(org.talend.services.reservation.types.RESCarType) CustomerDetailsType(org.talend.services.crm.types.CustomerDetailsType) RESStatusType(org.talend.services.reservation.types.RESStatusType)

Example 3 with RESCarType

use of org.talend.services.reservation.types.RESCarType in project tesb-rt-se by Talend.

the class CarRent method racRent.

/**
 * Rent a car available in the last serach result
 * @param intp - the command interpreter instance
 */
public void racRent() {
    pos = pos - 1;
    String userName = CarSearch.getLastSearchParams()[0];
    String pickupDate = CarSearch.getLastSearchParams()[1];
    String returnDate = CarSearch.getLastSearchParams()[2];
    this.searcher.search(userName, pickupDate, returnDate);
    if (searcher != null && searcher.getCars() != null && pos < searcher.getCars().size() && searcher.getCars().get(pos) != null) {
        RESStatusType resStatus = reserver.reserveCar(searcher.getCustomer(), searcher.getCars().get(pos), pickupDate, returnDate);
        ConfirmationType confirm = reserver.getConfirmation(resStatus, searcher.getCustomer(), searcher.getCars().get(pos), pickupDate, returnDate);
        RESCarType car = confirm.getCar();
        CustomerDetailsType customer = confirm.getCustomer();
        System.out.println(MessageFormat.format(CONFIRMATION, confirm.getDescription(), confirm.getReservationId(), customer.getName(), customer.getEmail(), customer.getCity(), customer.getStatus(), car.getBrand(), car.getDesignModel(), confirm.getFromDate(), confirm.getToDate(), padl(car.getRateDay(), 10), padl(car.getRateWeekend(), 10), padl(confirm.getCreditPoints().toString(), 7)));
    } else {
        // $NON-NLS-1$
        System.out.println("Invalid selection: " + (pos + 1));
    }
}
Also used : ConfirmationType(org.talend.services.reservation.types.ConfirmationType) RESCarType(org.talend.services.reservation.types.RESCarType) CustomerDetailsType(org.talend.services.crm.types.CustomerDetailsType) RESStatusType(org.talend.services.reservation.types.RESStatusType)

Example 4 with RESCarType

use of org.talend.services.reservation.types.RESCarType in project tesb-rt-se by Talend.

the class CarSearch method racShow.

public void racShow() {
    System.out.println(MessageFormat.format(FOUND, this.searcher.getCars().size()));
    System.out.println();
    int pos = 0;
    if (this.searcher.getCars().size() > 0) {
        header = Messages.CarRentalClient_CarDetails;
        System.out.println(header);
        StringBuilder sb = new StringBuilder();
        for (RESCarType car : this.searcher.getCars()) {
            pos++;
            // $NON-NLS-1$
            sb.append(padl("" + pos, HN[0].length())).append(SPC);
            sb.append(padr(car.getBrand(), HN[1].length())).append(SPC);
            sb.append(padr(car.getDesignModel(), HN[2].length())).append(SPC);
            sb.append(padr(car.getClazz(), HN[3].length())).append(SPC);
            sb.append(padl(car.getRateDay(), HN[4].length())).append(SPC);
            sb.append(padl(car.getRateWeekend(), HN[5].length())).append(SPC);
            sb.append(padl(car.getSecurityGuarantee(), HN[6].length())).append(SPC);
            // $NON-NLS-1$
            sb.append("\n");
        }
        System.out.println(sb.toString());
        System.out.println(TO_SELECT);
    }
}
Also used : RESCarType(org.talend.services.reservation.types.RESCarType)

Example 5 with RESCarType

use of org.talend.services.reservation.types.RESCarType in project tesb-rt-se by Talend.

the class AppController method reserve.

@RequestMapping(value = "/reserve", method = RequestMethod.POST)
public String reserve(@RequestParam(value = "carIndex", required = false) Integer carIndex, Model model, HttpSession session) {
    if (session.isNew()) {
        return redirectToMainPage();
    }
    if (carIndex != null && carIndex >= 0) {
        List<RESCarType> cars = searchModel.getCars();
        if (carIndex < cars.size()) {
            CustomerDetailsType customerDetails = searchModel.getCustomer();
            RESCarType selectedCar = cars.get(carIndex);
            SearchRequestParameters requestParams = getSessionAttribute(session, SearchRequestParameters.class);
            RESStatusType resStatus = null;
            ConfirmationType confirm = null;
            try {
                resStatus = reserveModel.reserveCar(customerDetails, selectedCar, requestParams.getPickupDate(), requestParams.getReturnDate());
                confirm = reserveModel.getConfirmation(resStatus, customerDetails, selectedCar, requestParams.getPickupDate(), requestParams.getReturnDate());
            } catch (Exception e) {
                model.addAttribute("excptMessage", e);
                return "error";
            }
            setSessionAttribute(session, ConfirmationType.class, confirm);
            RESStatucCodeType code = confirm.getDescription().contains("failed") ? RESStatucCodeType.FAILED : RESStatucCodeType.OK;
            setSessionAttribute(session, RESStatucCodeType.class, code);
            setSessionAttribute(session, Stages.class, Stages.RESERVATION_INFO);
        }
    }
    return redirectToMainPage();
}
Also used : ConfirmationType(org.talend.services.reservation.types.ConfirmationType) RESCarType(org.talend.services.reservation.types.RESCarType) RESStatucCodeType(org.talend.services.reservation.types.RESStatucCodeType) CustomerDetailsType(org.talend.services.crm.types.CustomerDetailsType) RESStatusType(org.talend.services.reservation.types.RESStatusType) SearchRequestParameters(org.talend.esb.client.app.model.SearchRequestParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RESCarType (org.talend.services.reservation.types.RESCarType)6 ConfirmationType (org.talend.services.reservation.types.ConfirmationType)4 CustomerDetailsType (org.talend.services.crm.types.CustomerDetailsType)3 RESStatusType (org.talend.services.reservation.types.RESStatusType)3 BigInteger (java.math.BigInteger)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 SearchRequestParameters (org.talend.esb.client.app.model.SearchRequestParameters)1 RESStatucCodeType (org.talend.services.reservation.types.RESStatucCodeType)1