Package org.fusesource.camel.component.sap.model.rfc

Examples of org.fusesource.camel.component.sap.model.rfc.Structure


        // 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


                response.addAttachment(entry.getKey(), entry.getValue().getDataSource());
            }
        }

        // Retrieve SAP response object from body of exchange message.
        Structure flightCustomerGetListResponse = source.getMessage().getBody(Structure.class);

        if (flightCustomerGetListResponse == null) {
            throw new Exception("No Flight Customer Get List Response");
        }

        // Check BAPI return parameter for errors
        @SuppressWarnings("unchecked")
        Table<Structure> bapiReturn = flightCustomerGetListResponse.get("RETURN", Table.class);
        Structure bapiReturnEntry = bapiReturn.get(0);
        if (!bapiReturnEntry.get("TYPE", String.class).equals("S")) {
            String message = bapiReturnEntry.get("MESSAGE", String.class);
            throw new Exception("BAPI call failed: " + message);
        }

        // Get customer list table from response object.
        @SuppressWarnings("unchecked")
        Table<? extends Structure> customerList = flightCustomerGetListResponse.get("CUSTOMER_LIST", Table.class);

        if (customerList == null || customerList.size() == 0) {
            throw new Exception("No Customer Info.");
        }

        // Get Flight Customer data from first row of table.
        Structure customer = customerList.get(0);

        // Create bean to hold Flight Customer data.
        FlightCustomerInfo flightCustomerInfo = new FlightCustomerInfo();

        // Get customer id from Flight Customer data and add to bean.
        String customerId = customer.get("CUSTOMERID", String.class);
        if (customerId != null) {
            flightCustomerInfo.setCustomerNumber(customerId);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set customer number = '{}' in flight customer info", customerId);
            }
        }

        // Get customer name from Flight Customer data and add to bean.
        String customerName = customer.get("CUSTNAME", String.class);
        if (customerName != null) {
            flightCustomerInfo.setName(customerName);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set customer name = '{}' in flight customer info", customerName);
            }
        }

        // Get customer form of address from Flight Customer data and add to bean.
        String formOfAddress = customer.get("FORM", String.class);
        if (formOfAddress != null) {
            flightCustomerInfo.setFormOfAddress(formOfAddress);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set form of address = '{}' in flight customer info", formOfAddress);
            }
        }

        // Get customer street name from Flight Customer data and add to bean.
        String street = customer.get("STREET", String.class);
        if (street != null) {
            flightCustomerInfo.setStreet(street);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set street = '{}' in flight customer info", street);
            }
        }

        // Get customer PO box from Flight Customer data and add to bean.
        String poBox = customer.get("POBOX", String.class);
        if (poBox != null) {
            flightCustomerInfo.setPoBox(poBox);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set PO box = '{}' in flight customer info", poBox);
            }
        }

        // Get customer postal code from Flight Customer data and add to bean.
        String postalCode = customer.get("POSTCODE", String.class);
        if (postalCode != null) {
            flightCustomerInfo.setPostalCode(postalCode);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set postal code = '{}' in flight customer info", postalCode);
            }
        }

        // Get customer city name from Flight Customer data and add to bean.
        String city = customer.get("CITY", String.class);
        if (city != null) {
            flightCustomerInfo.setCity(city);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set city = '{}' in flight customer info", city);
            }
        }

        // Get customer country name from Flight Customer data and add to bean.
        String country = customer.get("COUNTR", String.class);
        if (country != null) {
            flightCustomerInfo.setCountry(country);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set country = '{}' in flight customer info", country);
            }
        }

        // Get customer country ISO code from Flight Customer data and add to bean.
        String countryIso = customer.get("COUNTR_ISO", String.class);
        if (countryIso != null) {
            flightCustomerInfo.setCountryIso(countryIso);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set iso country code = '{}' in flight customer info", countryIso);
            }
        }

        // Get customer region name from Flight Customer data and add to bean.
        String region = customer.get("REGION", String.class);
        if (region != null) {
            flightCustomerInfo.setRegion(region);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set region = '{}' in flight customer info", region);
            }
        }

        // Get customer phone number from Flight Customer data and add to bean.
        String phone = customer.get("PHONE", String.class);
        if (phone != null) {
            flightCustomerInfo.setPhone(phone);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set phone = '{}' in flight customer info", phone);
            }
        }

        // Get customer email from Flight Customer data and add to bean.
        String email = customer.get("EMAIL", String.class);
        if (email != null) {
            flightCustomerInfo.setEmail(email);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Set email = '{}' in flight customer info", email);
            }
View Full Code Here

        PassengerInfo passengerInfo = flightTripRequestInfo.getPassengerInfo();
        exchange.getContext().setProperty(FLIGHT_TRIP_REQUEST_INFO, flightTripRequestInfo, Scope.EXCHANGE);

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

        //
        // Add Flight Trip Data to request object.
        //

        Structure flightTripData = request.get("FLIGHT_TRIP_DATA", Structure.class);

        // Add Travel Agency Number to request if set
        String travelAgencyNumber = flightConnectionInfo.getTravelAgencyNumber();
        if (travelAgencyNumber != null && travelAgencyNumber.length() != 0) {
            flightTripData.put("AGENCYNUM", travelAgencyNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added AGENCYNUM = '{}' to FLIGHT_TRIP_DATA", travelAgencyNumber);
            }

        }

        // Add Customer ID to request if set
        String flightCustomerNumber = flightCustomerInfo.getCustomerNumber();
        if (flightCustomerNumber != null && flightCustomerNumber.length() != 0) {
            flightTripData.put("CUSTOMERID", flightCustomerNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CUSTOMERID = '{}' to FLIGHT_TRIP_DATA", flightCustomerNumber);
            }

        }

        // Add Flight Connection Number to request if set
        String flightConnectionNumber = flightConnectionInfo.getFlightConnectionNumber();
        if (flightConnectionNumber != null && flightConnectionNumber.length() != 0) {
            flightTripData.put("FLCONN1", flightConnectionNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added FLCONN1 = '{}' to FLIGHT_TRIP_DATA", flightConnectionNumber);
            }

        }

        // Add Departure Date to request if set
        Date flightConnectionDepartureData = flightConnectionInfo.getDepartureDate();
        if (flightConnectionDepartureData != null) {
            flightTripData.put("FLDATE1", flightConnectionDepartureData);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added FLDATE1 = '{}' to FLIGHT_TRIP_DATA", flightConnectionDepartureData);
            }

        }

        // Add Flight Connection Class to  request.
        // C : Business Class
        // Y : Economy Class
        // F : First Class
        String flightConnectionClass = "Y";
        if (flightConnectionClass != null && flightConnectionClass.length() != 0) {
            flightTripData.put("CLASS", flightConnectionClass);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CLASS = '{}' to FLIGHT_TRIP_DATA", flightConnectionClass);
            }

        }


        //
        // Add Passenger List Data to request object.
        //
        @SuppressWarnings("unchecked")
        Table<Structure> passengerList = request.get("PASSENGER_LIST", Table.class);
        Structure passengerListEntry = passengerList.add();

        // Add Passenger Form of Address to request if set
        String passengerFormOfAddress = passengerInfo.getFormOfAddress();
        if (passengerFormOfAddress != null && passengerFormOfAddress.length() != 0) {
            passengerListEntry.put("PASSFORM", passengerFormOfAddress);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added PASSFORM = '{}' to PASSENGER_LIST", passengerFormOfAddress);
            }

        }

        // Add Passenger Name to request if set
        String passengerName = passengerInfo.getName();
        if (passengerName != null && passengerName.length() != 0) {
            passengerListEntry.put("PASSNAME", passengerName);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added PASSNAME = '{}' to PASSENGER_LIST", passengerName);
            }

        }

        // Add Passenger Data of Birth to request if set
        Date passengerDateOfBirth = passengerInfo.getDateOfBirth();
        if (passengerDateOfBirth != null) {
            passengerListEntry.put("PASSBIRTH", passengerDateOfBirth);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added PASSBIRTH = '{}' to PASSENGER_LIST", passengerDateOfBirth);
            }

        }
View Full Code Here

        FlightTripRequestInfo flightTripRequestInfo = (FlightTripRequestInfo) exchange.getContext().getProperty(FLIGHT_TRIP_REQUEST_INFO).getValue();
        FlightConnectionInfo flightConnectionInfo = flightTripRequestInfo.getFlightConnectionInfo();
        PassengerInfo passengerInfo = flightTripRequestInfo.getPassengerInfo();

        // Retrieve SAP response object from body of exchange message.
        Structure flightTripCreateResponse = source.getMessage().getBody(Structure.class);

        if (flightTripCreateResponse == null) {
            throw new Exception("No Flight Trip Create Response");
        }

        // Check BAPI return parameter for errors
        @SuppressWarnings("unchecked")
        Table<Structure> bapiReturn = flightTripCreateResponse.get("RETURN", Table.class);
        Structure bapiReturnEntry = bapiReturn.get(0);
        if (!bapiReturnEntry.get("TYPE", String.class).equals("S")) {
            String message = bapiReturnEntry.get("MESSAGE", String.class);
            throw new Exception("BAPI call failed: " + message);
        }

        // Create bean to hold Flight Booking data.
        BookFlightResponse bookFlightResponse = new BookFlightResponse();

        // Trip Number
        String tripNumber = flightTripCreateResponse.get("TRIPNUMBER", String.class);
        if (tripNumber != null) {
            bookFlightResponse.setTripNumber(tripNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added TRIPNUMBER = '{}' to request", tripNumber);
            }
        } else {
            throw new Exception("No Flight Booking Trip Number");
        }

        // Pricing Info
        Structure ticketPrice = flightTripCreateResponse.get("TICKET_PRICE", Structure.class);
        if (ticketPrice != null) {
            // Ticket Price
            BigDecimal tripPrice = ticketPrice.get("TRIPPRICE", BigDecimal.class);
            bookFlightResponse.setTicketPrice(tripPrice);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added TICKET_PRICE = '{}' to request", tripPrice);
            }
            // Ticket Tax
            BigDecimal tripTax = ticketPrice.get("TRIPTAX", BigDecimal.class);
            bookFlightResponse.setTicketTax(tripTax);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added TICKET_TAX = '{}' to request", tripTax);
            }
            // Currency
            String currency = ticketPrice.get("CURR", String.class);
            bookFlightResponse.setCurrency(currency);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CURRENCY = '{}' to request", currency);
            }
        } else {
View Full Code Here

        // 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

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

        // Get BAPI_FLCONN_GETLIST SAP Response object.
        Structure flightConnectionGetListResponse = exchange.getMessage().getContent(Structure.class);

        if (flightConnectionGetListResponse == null) {
            throw new Exception("No Flight Connection Get List Response.");
        }

        // Get the list of matching flight connections in response object.
        @SuppressWarnings("unchecked")
        Table<? extends Structure> connectionList = flightConnectionGetListResponse.get("FLIGHT_CONNECTION_LIST", Table.class);
        if (connectionList == null || connectionList.size() == 0) {
            throw new Exception("No Flight Connections");
        }

        // Select the first connection.
        Structure connection = connectionList.get(0);

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

        // Copy connection number of matching connection into request.
        String connectionNumber = connection.get("FLIGHTCONN", String.class);
        if (connectionNumber != null) {
            request.put("CONNECTIONNUMBER", connectionNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CONNECTIONNUMBER = '{}' to request", connectionNumber);
            }
        } else {
            throw new Exception("No Flight Connection Number");
        }

        // Copy agency number of matching connection into request.
        String travelAgencyNumber = connection.get("AGENCYNUM", String.class);
        if (travelAgencyNumber != null) {
            request.put("TRAVELAGENCYNUMBER", travelAgencyNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added TRAVELAGENCYNUMBER = '{}' to request", travelAgencyNumber);
            }
        } else {
            throw new Exception("No Agency Number");
        }

        // Copy flight date of matching connection into request.
        Date flightDate = connection.get("FLIGHTDATE", Date.class);
        if (flightDate != null) {
            request.put("FLIGHTDATE", flightDate);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added FLIGHTDATE = '{}' to request", flightDate);
            }
        } else {
            throw new Exception("No Flight Date");
        }

        // Include availability data in RFC response.
        request.put("NO_AVAILIBILITY", "");

        // Put request object into body of exchange message.
        response.getMessage().setBody(request);
        return response;
    }
View Full Code Here

            for (Entry<String, DataHandler> entry : source.getMessage().getAttachments().entrySet()) {
                response.addAttachment(entry.getKey(), entry.getValue().getDataSource());
            }
        }

        Structure flightConnectionGetDetailResponse = source.getMessage().getBody(Structure.class);

        if (flightConnectionGetDetailResponse == null) {
            throw new Exception("No Flight Connection Get Detail Response");
        }

        // Create flight connection info bean.
        FlightConnectionInfo flightConnectionInfo = new FlightConnectionInfo();

        //
        // Add connection data to flight connection info bean.
        //

        Structure connectionData = flightConnectionGetDetailResponse.get("CONNECTION_DATA", Structure.class);
        if (connectionData != null) {

            // Add travel agency number to flight connection info if set.
            String travelAgencyNumber = connectionData.get("AGENCYNUM", String.class);
            if (travelAgencyNumber != null) {
                flightConnectionInfo.setTravelAgencyNumber(travelAgencyNumber);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set travel agency number = '{}' in flight connection info", travelAgencyNumber);
                }
            }

            // Add flight connection number to flight connection info if set.
            String flightConnectionNumber = connectionData.get("FLIGHTCONN", String.class);
            if (flightConnectionNumber != null) {
                flightConnectionInfo.setFlightConnectionNumber(flightConnectionNumber);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set flight connection number = '{}' in flight connection info", flightConnectionNumber);
                }
            }

            // Add departure date to flight connection info if set.
            Date departureDate = connectionData.get("FLIGHTDATE", Date.class);
            if (departureDate != null) {
                flightConnectionInfo.setDepartureDate(departureDate);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set depature date = '{}' in flight connection info", departureDate);
                }
            }

            // Add departure airport to flight connection info if set.
            String departureAirport = connectionData.get("AIRPORTFR", String.class);
            if (departureAirport != null) {
                flightConnectionInfo.setDepartureAirport(departureAirport);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure airport = '{}' in flight connection info", departureAirport);
                }
            }

            // Add departure city to flight connection info if set.
            String departureCity = connectionData.get("CITYFROM", String.class);
            if (departureCity != null) {
                flightConnectionInfo.setDepartureCity(departureCity);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure city = '{}' in flight connection info", departureCity);
                }
            }

            // Add arrival airport to flight connection info if set.
            String arrivalAirport = connectionData.get("AIRPORTTO", String.class);
            if (arrivalAirport != null) {
                flightConnectionInfo.setArrivalAirport(arrivalAirport);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival airport = '{}' in flight connection info", arrivalAirport);
                }
            }

            // Add arrival city to flight connection info if set.
            String arrivalCity = connectionData.get("CITYTO", String.class);
            if (arrivalCity != null) {
                flightConnectionInfo.setArrivalCity(arrivalCity);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival city = '{}' in flight connection info", arrivalCity);
                }
            }

            // Add number of hops to flight connection info if set.
            String numberOfHops = connectionData.get("NUMHOPS", String.class);
            if (numberOfHops != null) {
                flightConnectionInfo.setNumberOfHops(numberOfHops);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set number of hops = '{}' in flight connection info", numberOfHops);
                }
            }

            // Add departure time to flight connection info if set.
            Date departureTime = connectionData.get("DEPTIME", Date.class);
            if (departureTime != null) {
                flightConnectionInfo.setDepartureTime(departureTime);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure time = '{}' in flight connection info", departureTime);
                }
            }

            // Add arrival time to flight connection info if set.
            Date arrivalTime = connectionData.get("ARRTIME", Date.class);
            if (arrivalTime != null) {
                flightConnectionInfo.setArrivalTime(arrivalTime);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival time = '{}' in flight connection info", arrivalTime);
                }
            }

            // Add arrival date to flight connection info if set.
            Date arrivalDate = connectionData.get("ARRDATE", Date.class);
            if (arrivalDate != null) {
                flightConnectionInfo.setArrivalDate(arrivalDate);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival date = '{}' in flight connection info", arrivalDate);
                }
            }

            // Add flight time to flight connection info if set.
            Integer flightTime = connectionData.get("FLIGHTTIME", Integer.class);
            if (flightTime != null) {
                flightConnectionInfo.setFlightTime(flightTime.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set flight time = '{}' in flight connection info", flightTime);
                }
            }

        }

        //
        // Add flight hop list to flight connection info bean.
        //

        @SuppressWarnings("unchecked")
        Table<Structure> hopList = flightConnectionGetDetailResponse.get("FLIGHT_HOP_LIST", Table.class);
        List<FlightHop> flightHopList = new ArrayList<FlightHop>();

        for (Structure hop : hopList) {

            // Create flight hop object.
            FlightHop flightHop = new FlightHop();

            // Add hop number to flight hop if set.
            String hopNumber = hop.get("HOP", String.class);
            if (hopNumber != null) {
                flightHop.setHopNumber(hopNumber);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set hop number = '{}' in flight hop", hopNumber);
                }
            }

            // Add airline code to flight hop if set.
            String airlineCode = hop.get("AIRLINEID", String.class);
            if (airlineCode != null) {
                flightHop.setAirlineCode(airlineCode);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set airline code = '{}' in flight hop", airlineCode);
                }
            }

            // Add airline name to flight hop if set.
            String airlineName = hop.get("AIRLINE", String.class);
            if (airlineName != null) {
                flightHop.setAirlineName(airlineName);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set airline name = '{}' in flight hop", airlineName);
                }
            }

            // Add flight connection number to flight hop if set.
            String flightConnectionNumber = hop.get("CONNECTID", String.class);
            if (flightConnectionNumber != null) {
                flightHop.setFlightConnectionNumber(flightConnectionNumber);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set flight connection number = '{}' in flight hop", flightConnectionNumber);
                }
            }

            // Add departure airport to flight hop if set.
            String depatureAirport = hop.get("AIRPORTFR", String.class);
            if (depatureAirport != null) {
                flightHop.setDepatureAirport(depatureAirport);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure airport = '{}' in flight hop", depatureAirport);
                }
            }

            // Add departure city to flight hop if set.
            String depatureCity = hop.get("CITYFROM", String.class);
            if (depatureCity != null) {
                flightHop.setDepatureCity(depatureCity);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure city = '{}' in flight hop", depatureCity);
                }
            }

            // Add departure country to flight hop if set.
            String departureCountry = hop.get("CTRYFR", String.class);
            if (departureCountry != null) {
                flightHop.setDepartureCountry(departureCountry);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure country = '{}' in flight hop", departureCountry);
                }
            }

            // Add departure country code to flight hop if set.
            String departureCountryIso = hop.get("CTRYFR_ISO", String.class);
            if (departureCountryIso != null) {
                flightHop.setDepartureCountryIso(departureCountryIso);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure iso country code = '{}' in flight hop", departureCountryIso);
                }
            }

            // Add arrival airport to flight hop if set.
            String arrivalAirport = hop.get("AIRPORTTO", String.class);
            if (arrivalAirport != null) {
                flightHop.setArrivalAirport(arrivalAirport);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival airport = '{}' in flight hop", arrivalAirport);
                }
            }

            // Add arrival city to flight hop if set.
            String arrivalCity = hop.get("CITYTO", String.class);
            if (arrivalCity != null) {
                flightHop.setArrivalCity(arrivalCity);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival city = '{}' in flight hop", arrivalCity);
                }
            }

            // Add arrival country to flight hop if set.
            String arrivalCountry = hop.get("CTRYTO", String.class);
            if (arrivalCountry != null) {
                flightHop.setArrivalCountry(arrivalCountry);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival country = '{}' in flight hop", arrivalCountry);
                }
            }

            // Add arrival country code to flight hop if set.
            String arrivalCountryIso = hop.get("CTRYTO_ISO", String.class);
            if (arrivalCountryIso != null) {
                flightHop.setArrivalCountryIso(arrivalCountryIso);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival iso country code = '{}' in flight hop", arrivalCountryIso);
                }
            }

            // Add departure date to flight hop if set.
            Date departureDate = hop.get("DEPDATE", Date.class);
            if (departureDate != null) {
                flightHop.setDepatureDate(departureDate);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure date = '{}' in flight hop", departureDate);
                }
            }

            // Add departure time to flight hop if set.
            Date departureTime = hop.get("DEPTIME", Date.class);
            if (departureTime != null) {
                flightHop.setDepatureTime(departureTime);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set departure time = '{}' in flight hop", departureTime);
                }
            }

            // Add arrival date to flight hop if set.
            Date arrivalDate = hop.get("ARRDATE", Date.class);
            if (arrivalDate != null) {
                flightHop.setArrivalDate(arrivalDate);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival date = '{}' in flight hop", arrivalDate);
                }
            }

            // Add arrival time to flight hop if set.
            Date arrivalTime = hop.get("ARRTIME", Date.class);
            if (arrivalTime != null) {
                flightHop.setArrivalTime(arrivalTime);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set arrival time = '{}' in flight hop", arrivalTime);
                }
            }

            // Add aircraft type to flight hop if set.
            String aircraftType = hop.get("PLANETYPE", String.class);
            if (aircraftType != null) {
                flightHop.setAircraftType(aircraftType);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set aircraft type = '{}' in flight hop", aircraftType);
                }
            }

            // Add flight hop
            flightHopList.add(flightHop);
        }

        // Add flight hop list to flight connection info.
        flightConnectionInfo.setFlightHopList(flightHopList);

        //
        // Add availability list to flight connection info bean.
        //

        @SuppressWarnings("unchecked")
        Table<Structure> availibilityList = flightConnectionGetDetailResponse.get("AVAILIBILITY", Table.class);
        List<SeatAvailibility> seatAvailiblityList = new ArrayList<SeatAvailibility>();

        for (Structure availibility : availibilityList) {

            // Create seat availability object.
            SeatAvailibility seatAvailiblity = new SeatAvailibility();

            // Add hop number to availability if set.
            String hopNumber = availibility.get("HOP", String.class);
            if (hopNumber != null) {
                seatAvailiblity.setHopNumber(hopNumber);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set hop number = '{}' in seat availibility", hopNumber);
                }
            }

            // Add economy class seat capacity to availability if set.
            Integer economyClassSeatCapacity =  availibility.get("ECONOMAX", Integer.class);
            if (economyClassSeatCapacity != null) {
                seatAvailiblity.setEconomyClassSeatCapacity(economyClassSeatCapacity.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set economy class seat capacity = '{}' in seat availibility", economyClassSeatCapacity);
                }
            }

            // Add economy class free seats to availability if set.
            Integer economyClassFreeSeats =  availibility.get("ECONOFREE", Integer.class);
            if (economyClassFreeSeats != null) {
                seatAvailiblity.setEconomyClassFreeSeats(economyClassFreeSeats.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set economy class free seats = '{}' in seat availibility", economyClassFreeSeats);
                }
            }

            // Add business class seat capacity to availability if set.
            Integer businessClassSeatCapacity =  availibility.get("BUSINMAX", Integer.class);
            if (businessClassSeatCapacity != null) {
                seatAvailiblity.setBusinessClassSeatCapacity(businessClassSeatCapacity.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set business class seat capacity = '{}' in seat availibility", businessClassSeatCapacity);
                }
            }

            // Add business class free seats to availability if set.
            Integer businessClassFreeSeats =  availibility.get("BUSINFREE", Integer.class);
            if (businessClassFreeSeats != null) {
                seatAvailiblity.setBusinessClassFreeSeats(businessClassFreeSeats.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set business class free seats = '{}' in seat availibility", businessClassFreeSeats);
                }
            }

            // Add first class seat capacity to availability if set.
            Integer firstClassClassSeatCapacity =  availibility.get("FIRSTMAX", Integer.class);
            if (firstClassClassSeatCapacity != null) {
                seatAvailiblity.setFirstClassClassSeatCapacity(firstClassClassSeatCapacity.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set first class seat capacity = '{}' in seat availibility", firstClassClassSeatCapacity);
                }
            }

            // Add first class free seats to availability if set.
            Integer firstClassFreeSeats =  availibility.get("FIRSTFREE", Integer.class);
            if (firstClassFreeSeats != null) {
                seatAvailiblity.setFirstClassFreeSeats(firstClassFreeSeats.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set first class free seats = '{}' in seat availibility", firstClassFreeSeats);
                }
            }

            // Add availability to list.
            seatAvailiblityList.add(seatAvailiblity);
        }

        // Add availability list to flight connection info.
        flightConnectionInfo.setSeatAvailibilityList(seatAvailiblityList);

        //
        // Add price info to flight connection info bean.
        //

        Structure prices = (Structure) flightConnectionGetDetailResponse.get("PRICE_INFO", Structure.class);

        if (prices != null) {

            // Create price info object.
            PriceInfo priceInfo = new PriceInfo();

            // Add economy class airfare to availability if set.
            BigDecimal economyClassAirfare =  prices.get("PRICE_ECO1", BigDecimal.class);
            if (economyClassAirfare != null) {
                priceInfo.setEconomyClassAirfare(economyClassAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set economy class airfare = '{}' in seat availibility", economyClassAirfare);
                }
            }

            // Add economy class child airfare to availability if set.
            BigDecimal economyClassChildAirfare =  prices.get("PRICE_ECO2", BigDecimal.class);
            if (economyClassChildAirfare != null) {
                priceInfo.setEconomyClassChildAirfare(economyClassChildAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set economy class child airfare = '{}' in seat availibility", economyClassChildAirfare);
                }
            }

            // Add economy class small child airfare to availability if set.
            BigDecimal economyClassSmallChildAirfare =  prices.get("PRICE_ECO3", BigDecimal.class);
            if (economyClassSmallChildAirfare != null) {
                priceInfo.setEconomyClassSmallChildAirfare(economyClassSmallChildAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set economy class small child airfare = '{}' in seat availibility", economyClassSmallChildAirfare);
                }
            }

            // Add business class airfare to availability if set.
            BigDecimal businessClassAirfare =  prices.get("PRICE_BUS1", BigDecimal.class);
            if (businessClassAirfare != null) {
                priceInfo.setBusinessClassAirfare(businessClassAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set business class airfare = '{}' in seat availibility", businessClassAirfare);
                }
            }

            // Add business class child airfare to availability if set.
            BigDecimal businessClassChildAirfare =  prices.get("PRICE_BUS2", BigDecimal.class);
            if (businessClassChildAirfare != null) {
                priceInfo.setBusinessClassChildAirfare(businessClassChildAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set business class child airfare = '{}' in seat availibility", businessClassChildAirfare);
                }
            }

            // Add business class small child airfare to availability if set.
            BigDecimal businessClassSmallChildAirfare =  prices.get("PRICE_BUS3", BigDecimal.class);
            if (businessClassSmallChildAirfare != null) {
                priceInfo.setBusinessClassSmallChildAirfare(businessClassSmallChildAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set business class small child airfare = '{}' in seat availibility", businessClassSmallChildAirfare);
                }
            }

            // Add first class airfare to availability if set.
            BigDecimal firstClassAirfare =  prices.get("PRICE_FST1", BigDecimal.class);
            if (firstClassAirfare != null) {
                priceInfo.setBusinessClassAirfare(firstClassAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set first class airfare = '{}' in seat availibility", firstClassAirfare);
                }
            }

            // Add first class child airfare to availability if set.
            BigDecimal firstClassChildAirfare =  prices.get("PRICE_FST2", BigDecimal.class);
            if (firstClassChildAirfare != null) {
                priceInfo.setBusinessClassChildAirfare(firstClassChildAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set first class child airfare = '{}' in seat availibility", firstClassChildAirfare);
                }
            }

            // Add first class child airfare to availability if set.
            BigDecimal firstClassSmallChildAirfare =  prices.get("PRICE_FST3", BigDecimal.class);
            if (firstClassSmallChildAirfare != null) {
                priceInfo.setBusinessClassSmallChildAirfare(firstClassSmallChildAirfare.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set first class small child airfare = '{}' in seat availibility", firstClassSmallChildAirfare);
                }
            }

            // Add first class small child airfare to availability if set.
            BigDecimal flightTaxes =  prices.get("TAX", BigDecimal.class);
            if (flightTaxes != null) {
                priceInfo.setFlightTaxes(flightTaxes.toString());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set flight taxes = '{}' in seat availibility", flightTaxes);
                }
            }

            // Add currency type to availability if set.
            String currency = prices.get("CURR", String.class);
            if (currency != null) {
                priceInfo.setCurrency(currency);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set local currency = '{}' in seat availibility", currency);
                }
            }

            // Add currency code to availability if set.
            String currencyIso = prices.get("CURR_ISO", String.class);
            if (currencyIso != null) {
                priceInfo.setCurrencyIso(currencyIso);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Set local currency iso code = '{}' in seat availibility", currencyIso);
                }
View Full Code Here

TOP

Related Classes of org.fusesource.camel.component.sap.model.rfc.Structure

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.