Webshops refactoring + checkstyle

This commit is contained in:
Leonie Eitze
2023-06-27 02:56:28 +02:00
parent 22ee3f3d34
commit 463932f8e9
24 changed files with 168 additions and 208 deletions

View File

@@ -9,6 +9,7 @@ import java.net.URL;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.exception.DataSourceException;
import de.rwu.easydrop.model.Webshop;
import de.rwu.easydrop.util.FormattingUtil;
/**
@@ -23,7 +24,7 @@ public abstract class AbstractDataSource implements DataSource {
*
* @return Data source name
*/
protected abstract String getDataOrigin();
protected abstract Webshop getDataOrigin();
/**
* Returns the data source's API key.
@@ -48,7 +49,7 @@ public abstract class AbstractDataSource implements DataSource {
public ProductDTO getProductDTOById(final String productIdentifier)
throws IllegalArgumentException {
StringBuilder response = new StringBuilder();
String dataOrigin = getDataOrigin();
Webshop dataOrigin = getDataOrigin();
String apiKey = getApiKey();
ProductDTO product = new ProductDTO(productIdentifier, dataOrigin);
@@ -72,20 +73,16 @@ public abstract class AbstractDataSource implements DataSource {
+ responseCode);
}
String line;
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// FIXME: Mock not complete. Data is missing
// FIXME response can be empty
String data;
if (response.toString().isEmpty()){
data = "{}";
}
else {
if (response.toString().isEmpty()) {
data = "{}";
} else {
data = response.toString();
}
buildProductDTO(product, data);

View File

@@ -7,6 +7,7 @@ import java.net.URL;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.exception.DataWriterException;
import de.rwu.easydrop.model.Webshop;
import de.rwu.easydrop.util.FormattingUtil;
/**
@@ -28,7 +29,7 @@ public abstract class AbstractDataWriter {
*
* @return Data target API name
*/
protected abstract String getDataTarget();
protected abstract Webshop getDataTarget();
/**
* Creates an URL object to connect to the API with.
@@ -47,7 +48,7 @@ public abstract class AbstractDataWriter {
*/
protected void sendPutRequest(final ProductDTO dto, final String apiType) {
String apiKey = getApiKey();
String dataTarget = getDataTarget();
Webshop dataTarget = getDataTarget();
if (!dataTarget.equals(dto.getDataOrigin())) {
throw new DataWriterException(

View File

@@ -8,6 +8,7 @@ import com.jayway.jsonpath.PathNotFoundException;
import com.jayway.jsonpath.ReadContext;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.model.Webshop;
/**
* Interface to an Amazon data source.
@@ -18,7 +19,7 @@ public final class AmazonProductDataSource extends AbstractDataSource {
/**
* Name of this data source.
*/
private static final String DATA_ORIGIN = "Amazon";
private static final Webshop DATA_ORIGIN = Webshop.Amazon;
/**
* Base URL to the Amazon data source.
*/
@@ -82,7 +83,7 @@ public final class AmazonProductDataSource extends AbstractDataSource {
}
@Override
protected String getDataOrigin() {
protected Webshop getDataOrigin() {
return DATA_ORIGIN;
}

View File

@@ -3,6 +3,8 @@ package de.rwu.easydrop.api.client;
import java.net.MalformedURLException;
import java.net.URL;
import de.rwu.easydrop.model.Webshop;
/**
* Sends a buy request to the Amazon API.
*
@@ -12,7 +14,7 @@ public final class AmazonPurchaser extends AbstractPurchaser {
/**
* Name of this data source.
*/
private static final String DATA_TARGET = "Amazon";
private static final Webshop DATA_TARGET = Webshop.Amazon;
/**
* Base URL to the Amazon Purchase API.
*/
@@ -61,7 +63,7 @@ public final class AmazonPurchaser extends AbstractPurchaser {
}
@Override
protected String getDataTarget() {
protected Webshop getDataTarget() {
return DATA_TARGET;
}
}

View File

@@ -3,6 +3,8 @@ package de.rwu.easydrop.api.client;
import java.net.MalformedURLException;
import java.net.URL;
import de.rwu.easydrop.model.Webshop;
/**
* Sends a sell request to the Amazon API.
*
@@ -12,7 +14,7 @@ public final class AmazonSeller extends AbstractSeller {
/**
* Name of this data source.
*/
private static final String DATA_TARGET = "Amazon";
private static final Webshop DATA_TARGET = Webshop.Amazon;
/**
* Base URL to the Amazon Purchase API.
*/
@@ -61,7 +63,7 @@ public final class AmazonSeller extends AbstractSeller {
}
@Override
protected String getDataTarget() {
protected Webshop getDataTarget() {
return DATA_TARGET;
}
}

View File

@@ -8,6 +8,7 @@ import com.jayway.jsonpath.PathNotFoundException;
import com.jayway.jsonpath.ReadContext;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.model.Webshop;
/**
* Interface to an eBay data source.
@@ -18,7 +19,7 @@ public final class EbayItemDataSource extends AbstractDataSource {
/**
* Name of this data source.
*/
private static final String DATA_ORIGIN = "eBay";
private static final Webshop DATA_ORIGIN = Webshop.eBay;
/**
* Base URL to the eBay data source.
*/
@@ -77,7 +78,7 @@ public final class EbayItemDataSource extends AbstractDataSource {
}
@Override
protected String getDataOrigin() {
protected Webshop getDataOrigin() {
return DATA_ORIGIN;
}

View File

@@ -3,6 +3,8 @@ package de.rwu.easydrop.api.client;
import java.net.MalformedURLException;
import java.net.URL;
import de.rwu.easydrop.model.Webshop;
/**
* Sends a buy request to the eBay API.
*
@@ -12,7 +14,7 @@ public final class EbayPurchaser extends AbstractPurchaser {
/**
* Name of this data source.
*/
private static final String DATA_TARGET = "eBay";
private static final Webshop DATA_TARGET = Webshop.eBay;
/**
* Base URL to the eBay Purchase API.
*/
@@ -46,7 +48,7 @@ public final class EbayPurchaser extends AbstractPurchaser {
}
@Override
protected String getDataTarget() {
protected Webshop getDataTarget() {
return DATA_TARGET;
}
}

View File

@@ -3,6 +3,8 @@ package de.rwu.easydrop.api.client;
import java.net.MalformedURLException;
import java.net.URL;
import de.rwu.easydrop.model.Webshop;
/**
* Sends a sell request to the eBay API.
*
@@ -12,7 +14,7 @@ public final class EbaySeller extends AbstractSeller {
/**
* Name of this data source.
*/
private static final String DATA_TARGET = "eBay";
private static final Webshop DATA_TARGET = Webshop.eBay;
/**
* Base URL to the eBay Purchase API.
*/
@@ -46,7 +48,7 @@ public final class EbaySeller extends AbstractSeller {
}
@Override
protected String getDataTarget() {
protected Webshop getDataTarget() {
return DATA_TARGET;
}
}

View File

@@ -14,36 +14,37 @@ public class OfferDTO {
*/
private String offerId;
/*
* The product that our software buys
/**
* The product that our software buys.
*/
Product sourceProduct;
private Product sourceProduct;
/*
* The product that our software sells
/**
* The product that our software sells.
*/
Product saleProduct;
private Product saleProduct;
/*
/**
* Date of the creation of the offer
* NOTE: Use Timestamp? https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html
* NOTE: Use Timestamp?
* https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html
*/
Date creationDate;
private Date creationDate;
/*
* Date of last update of the offer on the destination website (API)
/**
* Date of last update of the offer on the destination website (API).
*/
Date upDate;
private Date upDate;
/*
* Date of last check if offer is still valid
/**
* Date of last check if offer is still valid.
*/
Date checkDate;
private Date checkDate;
/**
* Creates OfferDTO instance.
*
* @param newOfferId Internal Offer identifier
* @param newOfferId Internal Offer identifier
*/
public OfferDTO(final String newOfferId) {
this.offerId = newOfferId;

View File

@@ -1,5 +1,6 @@
package de.rwu.easydrop.api.dto;
import de.rwu.easydrop.model.Webshop;
import lombok.Data;
/**
@@ -10,9 +11,9 @@ import lombok.Data;
@Data
public class ProductDTO {
/**
* Data source platform, like "Amazon".
* Data source platform, like Amazon.
*/
private String dataOrigin;
private Webshop dataOrigin;
/**
* Platform internal product identifier.
@@ -45,7 +46,7 @@ public class ProductDTO {
* @param newProductId Internal Product indetifier
* @param newDataOrigin Data Origin
*/
public ProductDTO(final String newProductId, final String newDataOrigin) {
public ProductDTO(final String newProductId, final Webshop newDataOrigin) {
this.productId = newProductId;
this.dataOrigin = newDataOrigin;
}

View File

@@ -7,32 +7,39 @@ import javax.naming.ConfigurationException;
import de.rwu.easydrop.model.Offer;
import de.rwu.easydrop.model.ProductCatalogue;
/**
* The application core.
*
* @since 0.3.0
*/
public class Core {
/**
* Offer identifier.
*/
private OfferIdentifier ident;
/**
* Offer provisioner.
*/
private OfferProvisioner provis;
private OfferReviewer review;
private OfferUpdater update;
public Core() throws ConfigurationException{
/**
* Constructor.
*
* @throws ConfigurationException
*/
public Core() throws ConfigurationException {
this.ident = new OfferIdentifier();
this.provis = new OfferProvisioner();
this.review = new OfferReviewer();
this.update = new OfferUpdater();
}
public void runCore(List<ProductCatalogue> pCats){
/**
* Runs the core.
*
* @param pCats
*/
public void runCore(final List<ProductCatalogue> pCats) {
List<Offer> identifiedOffers = ident.runIdentifier(pCats);
provis.runProvisioner(identifiedOffers);
List<Offer> updatingOffers = review.runReviewer();
update.runUpdater(updatingOffers);
}
}

View File

@@ -14,7 +14,6 @@ import de.rwu.easydrop.service.retriever.OfferRetriever;
import de.rwu.easydrop.service.processing.OrderManager;
import de.rwu.easydrop.exception.InvalidCatalogueException;
public class OfferIdentifier {
/**
* Logger for main process.
@@ -24,13 +23,15 @@ public class OfferIdentifier {
* OfferRetriever gets the offer from persistence.
*/
private OfferRetriever offerRetriever;
/**
* OfferIdentifier identifies offers that are
* feasible to place on a target platform based on
* their margin.
*
* @throws ConfigurationException
*/
public OfferIdentifier() throws ConfigurationException{
public OfferIdentifier() throws ConfigurationException {
this.offerRetriever = new OfferRetriever();
}
@@ -38,6 +39,7 @@ public class OfferIdentifier {
* runIdentifier calls the price function that decides
* if it is feasible to dropship products and if so,
* at which margin.
*
* @param pCats
* @return newOffers
*/
@@ -53,36 +55,25 @@ public class OfferIdentifier {
possibleOffer.setSaleProduct(pair.getProduct2());
identifiedOffers.add(possibleOffer);
LOGGER.info(
"Identified offer "
+
pair.getProduct1().getProductId()
+
" -> "
+
pair.getProduct2().getProductId()
);
"Identified offer "
+
pair.getProduct1().getProductId()
+
" -> "
+
pair.getProduct2().getProductId());
// Following fields will be set if offer confirmed
// creationDate, offerId
// Following fields will be set if offer needs update
// upDate
}
catch (InvalidCatalogueException e) {
} catch (InvalidCatalogueException e) {
// if no margin, getHighestMarginProducts will throw
System.out.print("product has no margin");
}
}
List<Offer> newOffers = new ArrayList<>();
List<Offer> existingOffers = offerRetriever.loadOffers();
for (Offer identifiedOffer: identifiedOffers) {
for (Offer identifiedOffer : identifiedOffers) {
boolean isNew = true;
for (Offer existingOffer: existingOffers) {
if (
existingOffer.getSourceProduct().getProductId().
equals(identifiedOffer.getSourceProduct().getProductId())) {
isNew = false;
break;
}
}
if (isNew) {
newOffers.add(identifiedOffer);
}

View File

@@ -2,33 +2,23 @@ package de.rwu.easydrop.core;
import java.util.List;
import de.rwu.easydrop.util.Config;
import de.rwu.easydrop.data.connector.AbstractProductPersistence;
import de.rwu.easydrop.exception.DataWriterException;
import de.rwu.easydrop.model.Offer;
import de.rwu.easydrop.service.retriever.ProductRetriever;
import de.rwu.easydrop.service.writer.OfferWriter;
import de.rwu.easydrop.api.client.AmazonSeller;
import de.rwu.easydrop.api.client.EbaySeller;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.exception.DataWriterException;
import de.rwu.easydrop.model.Offer;
import de.rwu.easydrop.model.Webshop;
import de.rwu.easydrop.service.mapping.ProductMapper;
import de.rwu.easydrop.service.writer.OfferWriter;
import de.rwu.easydrop.util.Config;
public class OfferProvisioner {
/**
* Config.
*/
private Config config;
/**
* Gets the products from persistence.
*/
private ProductRetriever productRetriever;
// ProductWriter
/**
* Is the product databank.
*/
private AbstractProductPersistence db;
/**
* Writes offers into persistence.
*/
*/
private OfferWriter offerWriter;
/**
@@ -41,16 +31,11 @@ public class OfferProvisioner {
private EbaySeller ebaySeller;
private void toSeller(final Offer offer) throws IllegalArgumentException {
// TODO dataOrigin should use the webshop enum
if (offer.getSaleProduct().getDataOrigin().toLowerCase().equals("ebay")) {
this.ebaySeller.sellProduct(new ProductDTO(
offer.getSaleProduct().getProductId(),
"Amazon"));
if (offer.getSaleProduct().getDataOrigin() == Webshop.eBay) {
this.ebaySeller.sellProduct(ProductMapper.mapProductToDTO(offer.getSaleProduct()));
} else if (offer.getSaleProduct().getDataOrigin().toLowerCase().equals("amazon")) {
this.amazonSeller.sellProduct(new ProductDTO(
offer.getSaleProduct().getProductId(),
"eBay"));
} else if (offer.getSaleProduct().getDataOrigin().equals(Webshop.Amazon)) {
this.amazonSeller.sellProduct(ProductMapper.mapProductToDTO(offer.getSaleProduct()));
} else {
throw new IllegalArgumentException("Unsupported target plattform");
}
@@ -74,11 +59,12 @@ public class OfferProvisioner {
/**
* Method for placing orders on a target platform.
*
* @param offersToProvision
*/
public final void runProvisioner(final List<Offer> offersToProvision) {
for (Offer newOffer: offersToProvision){
for (Offer newOffer : offersToProvision) {
try {
this.toSeller(newOffer);
@@ -92,10 +78,9 @@ public class OfferProvisioner {
}
} catch (IllegalArgumentException e) {
System.out.println(
"Offer could not be placed, " +
newOffer.getSaleProduct().getDataOrigin() +
" is not supported"
);
"Offer could not be placed, "
+ newOffer.getSaleProduct().getDataOrigin()
+ " is not supported");
} catch (DataWriterException e) {
System.out.println("could not transmit offer");
}

View File

@@ -0,0 +1,6 @@
/**
* EasyDrop's core.
*
* @since 0.3.0
*/
package de.rwu.easydrop.core;

View File

@@ -2,12 +2,7 @@ package de.rwu.easydrop.data.connector;
import de.rwu.easydrop.api.dto.OfferDTO;
public abstract class AbstractOfferPersistence {
/**
* Data origin.
*/
public static final String DATA_ORIGIN = "Persistence";
public abstract class AbstractOfferPersistence {
/**
* Writes a ProductDTO to persistence.
*
@@ -17,12 +12,14 @@ public abstract class AbstractOfferPersistence {
/**
* Gets a OfferDTO from persistence.
*
* @param offerId
* @return Offer data transfer object
*/
//@Override
public abstract OfferDTO getOfferDTOById(String OfferId);
public abstract OfferDTO getOfferDTOById(String offerId);
/**
* Deletes all data from persistence.
*/
public abstract void clearData();
public abstract void clearData();
}

View File

@@ -11,6 +11,7 @@ import org.sqlite.SQLiteDataSource;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.exception.PersistenceException;
import de.rwu.easydrop.model.Webshop;
/**
* Allows connecting to a SQLite Database.
@@ -18,11 +19,6 @@ import de.rwu.easydrop.exception.PersistenceException;
* @since 0.2.0
*/
public final class SQLiteConnector extends AbstractProductPersistence {
/**
* Data origin.
*/
private static final String DATA_ORIGIN = "SQLite";
/**
* SQLite Database.
*/
@@ -95,7 +91,7 @@ public final class SQLiteConnector extends AbstractProductPersistence {
PreparedStatement statement = connection.prepareStatement(query)) {
int index = 0;
statement.setString(++index, dto.getDataOrigin());
statement.setString(++index, dto.getDataOrigin().toString());
statement.setString(++index, dto.getProductId());
statement.setDouble(++index, dto.getCurrentPrice());
statement.setString(++index, dto.getMerchant());
@@ -120,8 +116,9 @@ public final class SQLiteConnector extends AbstractProductPersistence {
try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
dto = new ProductDTO(resultSet.getString("productId"),
resultSet.getString("dataOrigin"));
Webshop newShop = Webshop.fromString(resultSet.getString("dataOrigin"));
dto = new ProductDTO(resultSet.getString("productId"), newShop);
dto.setCurrentPrice(resultSet.getDouble("currentPrice"));
dto.setMerchant(resultSet.getString("merchant"));
dto.setDeliveryPrice(resultSet.getDouble("deliveryPrice"));
@@ -149,8 +146,9 @@ public final class SQLiteConnector extends AbstractProductPersistence {
}
@Override
protected String getDataOrigin() {
return DATA_ORIGIN;
protected Webshop getDataOrigin() {
throw new UnsupportedOperationException(
this.getClass().getName() + " doesn't support getDataOrigin");
}
@Override

View File

@@ -10,23 +10,10 @@ import lombok.Data;
*/
@Data
public class Product {
/**
* Constants for data source/destination platforms.
*/
public enum Webshop {
/**
* Amazon.
*/
AMAZON,
/**Ebay.
*/
EBAY
}
/**
* Data source platform, like "Amazon".
*/
private String dataOrigin;
private Webshop dataOrigin;
/**
* Platform internal product identifier.

View File

@@ -5,11 +5,27 @@ package de.rwu.easydrop.model;
*/
public enum Webshop {
/**
* Amazon.
* Amazon Product API.
*/
Amazon,
/**
* eBay.
* eBay Item API.
*/
eBay
eBay;
/**
* Attempts to derive a webshop value from a string.
*
* @param str String
* @return webshop
* @throws IllegalArgumentException
*/
public static Webshop fromString(final String str) {
for (Webshop shop : Webshop.values()) {
if (shop.toString().equalsIgnoreCase(str)) {
return shop;
}
}
throw new IllegalArgumentException(String.format("No webshop called {} found", str));
}
}

View File

@@ -11,7 +11,6 @@ import de.rwu.easydrop.model.Offer;
*
* @see Offer
* @see OfferDTO
* @see OfferDTO
*/
public final class OfferMapper {
@@ -39,7 +38,7 @@ public final class OfferMapper {
/**
* Creates an OfferDTO object from a corresponding offer.
*
* @param Offer offer
* @param offer
* @return OfferDTO
*/
public static OfferDTO mapOfferToDTO(final Offer offer) {

View File

@@ -5,7 +5,6 @@ import java.util.List;
import javax.naming.ConfigurationException;
import de.rwu.easydrop.exception.InvalidProductException;
import de.rwu.easydrop.model.Product;
import de.rwu.easydrop.model.ProductCatalogue;
import de.rwu.easydrop.util.ProductsConfig;
@@ -58,16 +57,9 @@ public class CatalogueRetriever {
for (Product product : pCat.getProducts()) {
Product newProduct = new Product();
newProduct.setDataOrigin(product.getDataOrigin());
newProduct.setProductId(product.getProductId());
if (newProduct.getDataOrigin().equals("Amazon")) {
newProduct = productRetriever.getProductFromAmazon(product.getProductId());
} else if (newProduct.getDataOrigin().equals("eBay")) {
newProduct = productRetriever.getProductFromEbay(product.getProductId());
} else {
throw new InvalidProductException("Product data origin is invalid");
}
newProduct = productRetriever.getProductFromWebshop(product.getDataOrigin(),
product.getProductId());
newProductCatalogue.addProduct(newProduct);
}

View File

@@ -1,14 +1,5 @@
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

@@ -6,6 +6,7 @@ import de.rwu.easydrop.api.client.EbayItemDataSource;
import de.rwu.easydrop.api.dto.ProductDTO;
import de.rwu.easydrop.data.connector.AbstractProductPersistence;
import de.rwu.easydrop.model.Product;
import de.rwu.easydrop.model.Webshop;
import de.rwu.easydrop.service.mapping.ProductMapper;
import de.rwu.easydrop.service.validation.ProductValidator;
@@ -21,9 +22,9 @@ public class ProductRetriever {
private DataSourceFactory dataSourceFactory;
/**
* @param newDataSourceFactory the dataSourceFactory to set
* @param newDataSourceFactory the WebshopFactory to set
*/
public void setDataSourceFactory(final DataSourceFactory newDataSourceFactory) {
public void setWebshopFactory(final DataSourceFactory newDataSourceFactory) {
this.dataSourceFactory = newDataSourceFactory;
}
@@ -31,7 +32,7 @@ public class ProductRetriever {
* @param newDataSourceFactory
*/
public ProductRetriever(final DataSourceFactory newDataSourceFactory) {
this.setDataSourceFactory(newDataSourceFactory);
this.setWebshopFactory(newDataSourceFactory);
}
/**
@@ -83,23 +84,23 @@ public class ProductRetriever {
}
/**
* Retrieves a product from an API by name of the API so that high-level components do not need to be extended
* 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
* @param shop Data source name, e.g. Amazon
* @param productIdentifier 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(Product.webshop dataSourceName, final String productName) {
switch(dataSourceName) {
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);
default:
return null;
public Product getProductFromWebshop(final Webshop shop, final String productIdentifier) {
switch (shop) {
case Amazon:
return getProductFromAmazon(productIdentifier);
case eBay:
return getProductFromEbay(productIdentifier);
default:
return null;
}
}
}

View File

@@ -1,8 +1,5 @@
package de.rwu.easydrop.service.validation;
import java.util.HashSet;
import java.util.Set;
import de.rwu.easydrop.exception.InvalidProductException;
import de.rwu.easydrop.model.Product;
@@ -31,26 +28,8 @@ public final class ProductValidator {
if (product.getCurrentPrice() == 0.00) {
throw new InvalidProductException("Current price cannot be 0.00");
}
if (!isInValidDataOrigins(product.getDataOrigin())) {
throw new InvalidProductException("Unknown data source");
}
if (product.getProductId().equals("")) {
throw new InvalidProductException("Product ID cannot be empty");
}
}
/**
* Checks whether a dataOrigin is within the set of valid ones.
*
* @param dataOrigin like "Amazon"
* @return true if valid
*/
public static boolean isInValidDataOrigins(final String dataOrigin) {
Set<String> validOrigins = new HashSet<>();
validOrigins.add("Amazon");
validOrigins.add("eBay");
return validOrigins.contains(dataOrigin);
}
}

View File

@@ -13,6 +13,7 @@ import com.jayway.jsonpath.JsonPathException;
import de.rwu.easydrop.model.Product;
import de.rwu.easydrop.model.ProductCatalogue;
import de.rwu.easydrop.model.Webshop;
/**
* Reads the user-specified catalogue of products.
@@ -122,8 +123,8 @@ public final class ProductsConfig {
ArrayList<HashMap<String, Object>> identifiers = JsonPath.read(jsonIdentifiers, "$");
for (HashMap<String, Object> product : identifiers) {
String dataOrigin = product.keySet().iterator().next();
String identifier = product.get(dataOrigin).toString();
Webshop dataOrigin = Webshop.fromString(product.keySet().iterator().next());
String identifier = product.get(dataOrigin.toString()).toString();
Product newProduct = new Product();
newProduct.setDataOrigin(dataOrigin);