|
| 1 | +package de.telran.processor; |
| 2 | + |
| 3 | +import de.telran.processor.entity.DownloadedImage; |
| 4 | +import de.telran.processor.entity.ImageDescriptor; |
| 5 | +import de.telran.processor.service.DownloadService; |
| 6 | +import de.telran.processor.service.FileService; |
| 7 | + |
| 8 | +import java.util.List; |
| 9 | +import java.util.stream.Collectors; |
| 10 | + |
| 11 | +public class ImageProcessor { |
| 12 | + |
| 13 | + private FileService fileService; |
| 14 | + private DownloadService downloadService; |
| 15 | + |
| 16 | + public static void main(String[] args) { |
| 17 | + |
| 18 | + String csvFile = args[0]; |
| 19 | + |
| 20 | + FileService fs = new FileService(); |
| 21 | + DownloadService ds = new DownloadService(); |
| 22 | + ImageProcessor processor = new ImageProcessor(fs, ds); |
| 23 | + processor.process(csvFile); |
| 24 | + |
| 25 | + } |
| 26 | + |
| 27 | + public ImageProcessor(FileService fileService, DownloadService downloadService) { |
| 28 | + this.fileService = fileService; |
| 29 | + this.downloadService = downloadService; |
| 30 | + } |
| 31 | + |
| 32 | + public void process(String fileName) { |
| 33 | + //main logic is here |
| 34 | + |
| 35 | + List<ImageDescriptor> imageDescriptors = fileService.readImageDescriptors(fileName); |
| 36 | + |
| 37 | + List<DownloadedImage> downloadedImages = downloadService.downloadImages(imageDescriptors); |
| 38 | + |
| 39 | + List<DownloadedImage> successfullyDownloadedimages = downloadedImages |
| 40 | + .stream() |
| 41 | + .filter(DownloadedImage::isSuccessful) |
| 42 | + .collect(Collectors.toList()); |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + //try { |
| 47 | + // DownloadService ds = new Downloadservice(); |
| 48 | + // List<DownloadedImage> downloadedImages = ds.downloadImages(images); |
| 49 | + //} |
| 50 | + |
| 51 | + |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments