Demo entry 5038876

java code

   

Submitted by anonymous on Jun 01, 2016 at 08:19
Language: Java. Code size: 2.4 kB.

public class InstantConfirmServiceImpl implements DMCCommonService<List<HOTEL_DATA>> {

	private static final Logger LOGGER = LogManager.getLogger();

	@Override
	public List<HOTEL_DATA> processCommonService(List<HOTEL_DATA> hotels, MappingApiServices mappingApiServices,
			List<MappingApiProperties> mappingApiPropertiesList, HTDataConnection dataConnection, int cacheCapacity,
			CommonServiceConfig commonServiceConfig, LogObject log) {
		String dmcCode = null;
		if(null != commonServiceConfig) {
			dmcCode = commonServiceConfig.getDmcCode();
		}
		try {
			return filterInstantConfirm(hotels, Constants.TRUE, dmcCode);
		} catch (Exception e) {
			LOGGER.error("Exception while filtering Instant Confirm Rates");
			e.printStackTrace();
		}
		return null;

	}

	protected List<HOTEL_DATA> filterInstantConfirm(List<HOTEL_DATA> hotels, String isInstantConfirm, String dmcCode) throws Exception {

		LOGGER.debug("Received request for filter InstantConfirm Rates");
		List<HOTEL_DATA> newHotelDataList = new ArrayList<HOTEL_DATA>();
		for (HOTEL_DATA hotel_data : hotels) {
			if (null != hotel_data) {

				List<ROOM_DATA> roomDataList = hotel_data.getROOM_DATA();
				List<ROOM_DATA> newRoomDataList = new ArrayList<ROOM_DATA>();

				if (null != roomDataList && !roomDataList.isEmpty()) {
					for (ROOM_DATA roomData : roomDataList) {

						if (null != roomData && isInstantConfirm.equalsIgnoreCase(roomData.getINSTANT_CONFIRM())) {
							
							/*Set DMC Specific Tags*/
							switch(dmcCode) {
								case Constants.DMC_CRXX0001:
									/*Set Food Code to BB if breakfasts >= adults else to RO*/
									String breakfasts = roomData.getFOOD_CODE();
									OCCUPANCY occupancy = roomData.getOCCUPANCY();
									String adults = null;
									if(null != occupancy) 
										adults = occupancy.getADULTS();
									roomData.setFOOD_CODE(Constants.RO);
									if(null != breakfasts && null != adults && Integer.parseInt(breakfasts) >= Integer.parseInt(adults))
										roomData.setFOOD_CODE(Constants.BB);
									break;
								default:
							}
							
							newRoomDataList.add(roomData);
						}
					}
				}
				if (!CollectionUtils.isEmpty(newRoomDataList)) {
					hotel_data.setROOM_DATA(newRoomDataList);
					newHotelDataList.add(hotel_data);
				}
			}
		}
		LOGGER.debug("Filtered InstantConfirm Rates");
		return newHotelDataList;
	}

}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).