public List<DirtyBicycle> getDirtyBicycles(final Year year, final String file) throws PriceReaderException { List<DirtyBicycle> toReturn = new ArrayList<DirtyBicycle>(); HSSFSheet sheet = getSheet(file, 0); List<PriceRow> rows = getPriceRows(sheet, Brand.STELS); for (PriceRow row : rows) { String dirtyName = row.getModelName().trim(); List<SimpleBicycle> km; if (year.equals(Year.YEAR_2016)) { km = knownModels; } else if (year.equals(Year.YEAR_2015)) { km = knownModels2015; } else { LOGGER.error("YEAR is not defined"); return Collections.emptyList(); } for (SimpleBicycle simpleBicycle : km) { if (simpleBicycle.getDirtyModel().equals(dirtyName.trim())) { DirtyBicycle bicycle = new DirtyBicycle(simpleBicycle); bicycle.setPrice(getRoundedPrice(row.getRetailPrice())); bicycle.setDescription(row.getDescription()); bicycle.setProdCode(CodeGenerator.generateCode(bicycle)); toReturn.add(bicycle); } } } return toReturn; }
public List<Bicycle> getBicycles(final Year year, final String filePath) throws PriceReaderException { List<DirtyBicycle> list = getDirtyBicycles(year, filePath); List<Bicycle> toReturn = new ArrayList<>(); for (DirtyBicycle bicycle : list) { Bicycle b = DescriptionParser.parseDescription(bicycle.getDescription(), bicycle); b.setModel("Stels " + b.getModel()); b.setShortDescription(DescriptionParser.getShortDescription(b)); String imgName = b.getProductCode() + ".jpg"; b.setImageName(imgName); toReturn.add(b); } return toReturn; }