Wrote OfferIdentifier and updated ProductRetriever
This commit is contained in:
@@ -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<>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user