Connected application components

This commit is contained in:
Marvin Scham
2023-06-27 05:23:43 +02:00
parent b78fb49eb1
commit d01c4d0b1d
31 changed files with 402 additions and 561 deletions

View File

@@ -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
}

View File

@@ -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;
}
}

View File

@@ -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
}