Wrote OfferIdentifier and updated ProductRetriever

This commit is contained in:
Leonie Eitze
2023-06-09 17:23:28 +02:00
parent 9906ede6ec
commit c89c8974cf
5 changed files with 89 additions and 15 deletions

View File

@@ -0,0 +1,14 @@
package de.rwu.easydrop.service.retriever;
import de.rwu.easydrop.model.Offer;
import java.util.ArrayList;
import java.util.List;
public class OfferRetriever {
public List<Offer> loadOffers() {
return new ArrayList<>();
}
}

View File

@@ -81,4 +81,28 @@ public class ProductRetriever {
return product;
}
/**
* Retrieves a product from an API by name of the API so that high-level components do not need to be extended
* with exact function call names if we extend the list of webshops.
*
* @param dataSourceName Data source name, e.g. amazon
* @param productName Product name, translated to the correct product ID for the data source
* @return Product from that data source or null if data source not available
*/
public Product getProductFromDataSource(final String dataSourceName, final String productName) {
switch(dataSourceName.toLowerCase()) {
case "amazon":
// TODO: Translation from productName to productId (Amazon) needed
return getProductFromAmazon(productName);
case "ebay":
// TODO: Translation from productName to productId (eBay) needed
return getProductFromEbay(productName);
case "persistence":
// TODO: Translation from productName to productId (persistence layer) needed
return getProductFromPersistence(productName);
default:
return null;
}
}
}