use of eu.ggnet.dwoss.price.api.EngineTracer in project dwoss by gg-net.
the class PriceEngine method estimate.
/**
* Executes the Estimation for one SopoUnit.
* This Method never fails an always returns a usable not null PriceEngineResult
*
* @param uu the UniqueUnit
* @param spec the ProductSpec
* @param stock the Stock
* @return a estimated PriceEngineResult.
*/
public PriceEngineResult estimate(UniqueUnit uu, ProductSpec spec, String stock) {
Objects.requireNonNull(uu, "UniqueUnit is null");
Product p = Objects.requireNonNull(uu.getProduct(), "Product of " + uu + " is null");
Objects.requireNonNull(spec, "ProductSpec is null");
PriceEngineResult per = new PriceEngineResult(uu, stock);
TraceCollector log = new TraceCollector();
per.setTax(GlobalConfig.DEFAULT_TAX.getTax());
per.setWarrantyId(uu.getWarranty().ordinal());
if (uu.getWarranty().equals(Warranty.WARRANTY_TILL_DATE)) {
per.setWarrentyValid(uu.getWarrentyValid());
}
L.debug("Starting estimation for refuribisId:{}", uu.getRefurbishId());
if (uu.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED) || p.getFlags().contains(Product.Flag.PRICE_FIXED)) {
EngineTracer et = new EngineTracer(PriceEngine.class.getSimpleName(), "estimate");
if (uu.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED)) {
L.debug("refurbishId:{} has UnitPriceFixed", uu.getRefurbishId());
per.setCustomerPrice(uu.getPrice(PriceType.CUSTOMER));
per.setRetailerPrice(uu.getPrice(PriceType.RETAILER));
per.setUnitPriceFixed(SET);
per.setSpecial("FIX UNIT");
et.info("UnitFixPrice");
} else {
L.debug("refurbishId:{} has PartPriceFixed", uu.getRefurbishId());
per.setCustomerPrice(p.getPrice(PriceType.CUSTOMER));
per.setRetailerPrice(p.getPrice(PriceType.RETAILER));
per.setManufacturerPartPriceFixed(SET);
per.setSpecial("FIX PRODUCT");
et.info("ProductFixPrice");
}
log.add(et);
} else if (!estimator.isUnsatisfied()) {
Result result = estimator.get().estimate(spec, uu);
L.debug("{}", result);
log.add(result.getTracer());
per.setSpecial(result.getTag());
per.setRetailerPrice(result.getRetailerPrice());
per.setCustomerPrice(result.getCustomerPrice());
per.setRetailerToCustomerPricePercentage(result.getRetailerToCustomerPricePercentage());
} else {
L.debug("No Estimator found for {},{}", uu, spec);
per.setSpecial("NO ESTIMATION");
}
per.consumeLog(log);
return per;
}
use of eu.ggnet.dwoss.price.api.EngineTracer in project dwoss by gg-net.
the class TraceCollector method error.
public void error(String clazz, String msg) {
EngineTracer t = new EngineTracer(clazz, null);
t.error(msg);
add(t);
}
use of eu.ggnet.dwoss.price.api.EngineTracer in project dwoss by gg-net.
the class TraceCollector method getMessages.
public String getMessages() {
StringBuilder messages = new StringBuilder();
for (Iterator<EngineTracer> it = tracers.iterator(); it.hasNext(); ) {
EngineTracer et = it.next();
messages.append(et.collectMessages());
if (it.hasNext())
messages.append(", ");
}
return messages.toString();
}
Aggregations