Package org.switchyard.quickstarts.camel.sap.binding.jaxb

Examples of org.switchyard.quickstarts.camel.sap.binding.jaxb.BookFlightRequest


    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        CamelBindingData response = super.decompose(exchange, target);

        // Get BOOK_FLIGHT Request JAXB Bean object.
        BookFlightRequest bookFlightRequest = exchange.getMessage().getContent(BookFlightRequest.class);

        // Create SAP Request object from target endpoint.
        SAPEndpoint endpoint = target.getMessage().getExchange().getContext().getEndpoint("sap:destination:nplDest:BAPI_FLCUST_GETLIST", SAPEndpoint.class);
        Structure request = endpoint.getRequest();

        // Add Customer Name to request if set
        if (bookFlightRequest.getCustomerName() != null && bookFlightRequest.getCustomerName().length() > 0) {
            request.put("CUSTOMER_NAME", bookFlightRequest.getCustomerName());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CUSTOMER_NAME = '{}' to request", bookFlightRequest.getCustomerName());
            }
        } else {
            throw new Exception("No Customer Name");
        }
View Full Code Here


    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        CamelBindingData response = super.decompose(exchange, target);
       
        // Get BOOK_FLIGHT Request JAXB Bean object.
        BookFlightRequest bookFlightRequest = exchange.getMessage().getContent(BookFlightRequest.class);

        // Create SAP Request object from target endpoint.
        SAPEndpoint endpoint = response.getMessage().getExchange().getContext().getEndpoint("sap:destination:nplDest:BAPI_FLCONN_GETLIST", SAPEndpoint.class);
        Structure request = endpoint.getRequest();

        // Add Travel Agency Number to request if set
        if (bookFlightRequest.getTravelAgencyNumber() != null && bookFlightRequest.getTravelAgencyNumber().length() > 0) {
            request.put("TRAVELAGENCY", bookFlightRequest.getTravelAgencyNumber());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added TRAVELAGENCY = '{}' to request", bookFlightRequest.getTravelAgencyNumber());
            }
        } else {
            throw new Exception("No Travel Agency Number");
        }

        // Add Flight Date to request if set
        if (bookFlightRequest.getFlightDate() != null) {
            @SuppressWarnings("unchecked")
            Table<Structure> table = request.get("DATE_RANGE", Table.class);
            Structure date_range = table.add();
            date_range.put("SIGN", "I");
            date_range.put("OPTION", "EQ");
            Date date = bookFlightRequest.getFlightDate();
            date_range.put("LOW", date);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added DATE_RANGE = '{}' to request", RfcUtil.marshal(table));
            }
        } else {
            throw new Exception("No Flight Date");
        }

        // Add Start Destination if set
        if (bookFlightRequest.getStartAirportCode() != null && bookFlightRequest.getStartAirportCode().length() > 0) {
            Structure destination_from = request.get("DESTINATION_FROM", Structure.class);
            destination_from.put("AIRPORTID", bookFlightRequest.getStartAirportCode());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added DESTINATION_FROM = '{}' to request", RfcUtil.marshal(destination_from));
            }
        } else {
            throw new Exception("No Start Destination");
        }

        // Add End Destination if set
        if (bookFlightRequest.getEndAirportCode() != null && bookFlightRequest.getEndAirportCode().length() > 0) {
            Structure destination_to = request.get("DESTINATION_TO", Structure.class);
            destination_to.put("AIRPORTID", bookFlightRequest.getEndAirportCode());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added DESTINATION_TO = '{}' to request", RfcUtil.marshal(destination_to));
            }
        } else {
            throw new Exception("No End Destination");
View Full Code Here

TOP

Related Classes of org.switchyard.quickstarts.camel.sap.binding.jaxb.BookFlightRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.