/** Add Price Data for vendor for given instrument and price */ public void addPriceData(String vendorName, String instrumentName, Double price) throws PriceDataCacheException { logger.info( "PriceDataCacheServiceImpl : addPriceData invoked for " + vendorName + " " + instrumentName + " " + price); TradeInstrumentPrice tradeInstrumentPrice = new TradeInstrumentPrice(); tradeInstrumentPrice.setPrice(price); tradeInstrumentPrice.setTradeInstrument(instrumentName); Vendor vendor = priceDao.getVendor(vendorName); if (null == vendor) { logger.error("PriceDataCacheServiceImpl : No Vendor found with given name " + vendorName); throw new PriceDataCacheException( "Vendor doesn't exist in our system ,pleaes check name of the vendor " + vendorName); } vendor.addPrice(tradeInstrumentPrice); priceDao.saveVendor(vendor); }
/** Add New Vendors to the system if vendor is already there ignore it. */ public void onboardVendors(String[] vendors) { logger.info("PriceDataCacheServiceImpl : onboardVendors invoked "); for (String vendorName : vendors) { Vendor vendor = priceDao.getVendor(vendorName); if (null == vendor) { vendor = new Vendor(); vendor.setVendorName(vendorName); priceDao.saveVendor(vendor); } } }