Connected application components
This commit is contained in:
@@ -9,6 +9,7 @@ import com.jayway.jsonpath.ReadContext;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
import de.rwu.easydrop.model.Webshop;
|
||||
import de.rwu.easydrop.util.Timestamp;
|
||||
|
||||
/**
|
||||
* Interface to an Amazon data source.
|
||||
@@ -61,6 +62,7 @@ public final class AmazonProductDataSource extends AbstractDataSource {
|
||||
product.setDeliveryPrice(
|
||||
ctx.read(root + "shippingOptions[0].shippingCost.value.amount", double.class));
|
||||
product.setMerchant(ctx.read(root + "merchant.name", String.class));
|
||||
product.setLastUpdate(Timestamp.now());
|
||||
} catch (PathNotFoundException e) {
|
||||
// Pass, allow incomplete ProductDTO to pass for later validation
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package de.rwu.easydrop.api.client;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import de.rwu.easydrop.data.connector.AbstractProductPersistence;
|
||||
import de.rwu.easydrop.exception.PersistenceException;
|
||||
import de.rwu.easydrop.util.Config;
|
||||
|
||||
/**
|
||||
@@ -17,17 +15,6 @@ public class DataSourceFactory {
|
||||
* The data source config.
|
||||
*/
|
||||
private Config config;
|
||||
/**
|
||||
* Persistence interface.
|
||||
*/
|
||||
private AbstractProductPersistence persistence = null;
|
||||
|
||||
/**
|
||||
* @param newPersistence the persistence to set
|
||||
*/
|
||||
public void setPersistence(final AbstractProductPersistence newPersistence) {
|
||||
this.persistence = newPersistence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newConfig the config to set
|
||||
@@ -65,17 +52,4 @@ public class DataSourceFactory {
|
||||
String apiKey = config.getProperty("EBAY_API_KEY");
|
||||
return new EbayItemDataSource(apiUrl, apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a persistence data source.
|
||||
*
|
||||
* @return ProductPersistenceInterface
|
||||
*/
|
||||
public AbstractProductPersistence createProductPersistenceDataSource() {
|
||||
if (persistence == null) {
|
||||
throw new PersistenceException("Persistence is not set");
|
||||
}
|
||||
|
||||
return persistence;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.jayway.jsonpath.ReadContext;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
import de.rwu.easydrop.model.Webshop;
|
||||
import de.rwu.easydrop.util.Timestamp;
|
||||
|
||||
/**
|
||||
* Interface to an eBay data source.
|
||||
@@ -70,6 +71,7 @@ public final class EbayItemDataSource extends AbstractDataSource {
|
||||
product.setDeliveryPrice(
|
||||
ctx.read(root + "shippingOptions[0].shippingCost.value", double.class));
|
||||
product.setMerchant(ctx.read(root + "seller.username", String.class));
|
||||
product.setLastUpdate(Timestamp.now());
|
||||
} catch (PathNotFoundException e) {
|
||||
// Pass, allow incomplete ProductDTO to pass for later validation
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user