use of eu.ggnet.dwoss.spec.ee.entity.ProductSpec in project dwoss by gg-net.
the class PriceCoreOperation method loadAndCalculate.
/**
* Loads all AVAILABLE SopoUnits from the Sopodb an puts them trough the PriceEngine
*
* @param monitor
* @return
*/
public List<PriceEngineResult> loadAndCalculate(IMonitor monitor) {
L.info("Starting loadAndCalculate()");
final SubMonitor m = SubMonitor.convert(monitor, 100);
m.start();
final StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
final UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
final ProductSpecEao productSpecEao = new ProductSpecEao(specEm);
m.message("loading Units");
List<Integer> uuids = stockUnitEao.findByNoLogicTransactionAsUniqueUnitId();
List<UniqueUnit> uus = uniqueUnitEao.findByIds(uuids);
m.worked(10, "updating Eols");
updateEols(uus);
m.worked(5, "loading ProductSpecs");
Set<Product> products = toProducts(uus);
List<ProductSpec> productSpecs = productSpecEao.findByProductIds(toProductIds(products));
Map<Product, ProductSpec> productToSpecs = toProductProductSpec(products, productSpecs);
m.worked(10);
final List<PriceEngineResult> pers = new ArrayList<>();
m.setWorkRemaining(uus.size() + 5);
for (UniqueUnit uu : uus) {
m.worked(1, "Calculating RefurbishId(" + uu.getRefurbishId() + ")");
StockUnit su = stockUnitEao.findByUniqueUnitId(uu.getId());
pers.add(priceEngine.estimate(uu, productToSpecs.get(uu.getProduct()), su.getStock() != null ? su.getStock().getName() : "kein Lager"));
}
m.finish();
L.info("Finished loadAndCalculate(), estimated {} Units", pers.size());
return pers;
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSpec in project dwoss by gg-net.
the class DesktopBundleViewTryout method tryoutView.
@Test
public void tryoutView() throws InterruptedException {
final ProductSpec spec = new SpecGenerator().makeSpec();
DesktopBundleView view = new DesktopBundleView(new Mandators() {
@Override
public Mandator loadMandator() {
return Mandator.builder().defaultMailSignature(null).smtpConfiguration(null).mailTemplateLocation(null).company(CompanyGen.makeCompany()).dossierPrefix("DW").documentIntermix(null).documentIdentifierGeneratorConfigurations(new EnumMap<>(DocumentType.class)).build();
}
@Override
public DefaultCustomerSalesdata loadSalesdata() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("loadSalesdata - Not supported yet.");
}
@Override
public ReceiptCustomers loadReceiptCustomers() {
return ReceiptCustomers.builder().build();
}
@Override
public SpecialSystemCustomers loadSystemCustomers() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("loadSystemCustomers - Not supported yet.");
}
@Override
public Contractors loadContractors() {
return new Contractors(EnumSet.of(TradeName.ALSO, TradeName.ACER), EnumSet.of(TradeName.ACER));
}
@Override
public PostLedger loadPostLedger() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("loadPostLedger - Not supported yet.");
}
@Override
public ShippingTerms loadShippingTerms() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("loadShippingTerms - Not supported yet.");
}
}, new SpecAgent() {
@Override
public ProductSpec findProductSpecByPartNoEager(String partNo) {
if (partNo == null)
return null;
if (partNo.startsWith("X"))
return null;
spec.setPartNo(partNo);
return spec;
}
// <editor-fold defaultstate="collapsed" desc="Unneeded Methods">
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
}, new ProductProcessorStub(), TradeName.ACER, TradeName.ACER, ProductGroup.DESKTOP, ProductGroup.MONITOR);
view.setSpec(new DesktopBundle());
OkCancelDialog<DesktopBundleView> dialog = new OkCancelDialog<>("BundleView", view);
dialog.setVisible(true);
dialog.dispose();
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSpec in project dwoss by gg-net.
the class ReceiptProductLogicProductSpecIT method testCreateProductSpec.
@Test
public void testCreateProductSpec() throws Exception {
final long GTIN = 123456782;
// Create a CPU and GPU and persist it.
Cpu cpu = productProcessor.create(new Cpu(Cpu.Series.AMD_V, "TestCPU", Cpu.Type.MOBILE, 2.0, 5));
Gpu gpu = productProcessor.create(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU"));
// Persist Display
Display display = new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE);
ProductModel productModel = new ProductModel("M", new ProductFamily("F", new ProductSeries(ACER, NOTEBOOK, "S")));
Notebook notebook = new Notebook();
notebook.setDisplay(display);
notebook.setGpu(gpu);
notebook.setCpu(cpu);
notebook.setMemory(2048);
notebook.setOs(Desktop.Os.LINUX);
notebook.add(Desktop.Hdd.SSD_0016);
notebook.add(Desktop.Hdd.ROTATING_2000);
notebook.add(Desktop.Odd.DVD_ROM);
notebook.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
notebook.setPartNo("LX.ASDFG.GHJ");
notebook.setModel(productModel);
ProductSpec testSpec = productProcessor.create(notebook, productModel, 0);
assertNotNull(testSpec);
Notebook notebook2 = new Notebook();
notebook2.setDisplay(display);
notebook2.setGpu(gpu);
notebook2.setCpu(cpu);
notebook2.setMemory(2048);
notebook2.setOs(Desktop.Os.LINUX);
notebook2.add(Desktop.Hdd.SSD_0016);
notebook2.add(Desktop.Hdd.ROTATING_2000);
notebook2.add(Desktop.Odd.DVD_ROM);
notebook2.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
notebook2.setPartNo("LX.ASDFG.GH2");
notebook2.setModel(productModel);
ProductSpec testSpec2 = productProcessor.create(notebook2, productModel, GTIN);
assertNotNull(testSpec2);
assertNotSame(testSpec2, testSpec);
Product product = uuAgent.findById(Product.class, testSpec2.getProductId());
assertThat(product).isNotNull().returns(GTIN, Product::getGtin);
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSpec in project dwoss by gg-net.
the class ReceiptProductLogicProductSpecIT method testUpdateProductSpecModelChange.
@Test
public void testUpdateProductSpecModelChange() {
ProductModel productModel = productProcessor.create(ACER, NOTEBOOK, null, null, "TestModel");
Cpu cpu = productProcessor.create(new Cpu(Cpu.Series.AMD_V, "TestCPU", Cpu.Type.MOBILE, 2.0, 5));
Gpu gpu = productProcessor.create(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU"));
Notebook notebook = new Notebook();
notebook.setDisplay(new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE));
notebook.setGpu(gpu);
notebook.setCpu(cpu);
notebook.setMemory(2048);
notebook.setOs(Desktop.Os.LINUX);
notebook.add(Desktop.Hdd.SSD_0016);
notebook.add(Desktop.Hdd.ROTATING_2000);
notebook.add(Desktop.Odd.DVD_ROM);
notebook.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
notebook.setPartNo("LX.ASDFG.GHP");
notebook.setModel(productModel);
ProductSpec spec = productProcessor.create(notebook, productModel, 0);
ProductFamily family = spec.getModel().getFamily();
ProductModel productModel2 = productProcessor.create(ACER, NOTEBOOK, family.getSeries(), family, "TestModel2");
spec = productProcessor.refresh(spec, productModel2);
long model2Id = spec.getModel().getId();
String comment = "MuhBlub";
((Notebook) spec).setComment(comment);
productProcessor.update(spec, 0);
List<ProductSeries> series = specAgent.findAllEager(ProductSeries.class);
assertNotNull(series);
assertEquals(1, series.size());
assertNotNull(series.get(0));
assertNotNull(series.get(0).getFamilys());
assertEquals(1, series.get(0).getFamilys().size());
assertNotNull(series.get(0).getFamilys().toArray()[0]);
List<ProductSpec> specs = specAgent.findAllEager(ProductSpec.class);
assertNotNull(specs);
assertEquals(1, specs.size());
assertEquals(model2Id, specs.get(0).getModel().getId());
assertEquals(comment, ((Notebook) specs.get(0)).getComment());
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSpec in project dwoss by gg-net.
the class ReceiptUnitOperationIT method testReceiptAndUpdate.
@Test
public void testReceiptAndUpdate() throws InterruptedException {
customerGenerator.makeSystemCustomers(contractors.all().toArray(new TradeName[0]));
// Constants ,later permutate throug all
Stock stock = stockGenerator.makeStocksAndLocations(2).get(0);
List<ReceiptOperation> operations = Arrays.asList(SALEABLE, INTERNAL_REWORK, MISSING_PARTS, REPAIR);
// Receipt a Unit
ProductSpec productSpec = receiptGenerator.makeProductSpec();
Product product = uniqueUnitAgent.findById(Product.class, productSpec.getProductId());
StockTransaction stockTransaction = stockTransactionEmo.requestRollInPrepared(stock.getId(), "No User", "Rollin via ReceiptUnitOperationHelper.findOrCreateRollInTransaction");
for (TradeName contractor : contractors.all()) {
Shipment productShipment = stockAgent.persist(new Shipment("SHIPMENTNAME_" + contractor, contractor, TradeName.ACER, Shipment.Status.OPENED));
for (ReceiptOperation receiptOperation : operations) {
UniqueUnit receiptUnit = unitGenerator.makeUniqueUnit(contractor, product);
unitProcessor.receipt(receiptUnit, product, productShipment, stockTransaction, receiptOperation, "Receipt Operation from Test", "Testuser");
asserts(receiptUnit, stockTransaction, receiptOperation, contractor);
for (ReceiptOperation updateOperation : operations) {
UniqueUnit uniqueUnit = uniqueUnitAgent.findUnitByIdentifierEager(Identifier.REFURBISHED_ID, receiptUnit.getIdentifier(Identifier.REFURBISHED_ID));
unitProcessor.update(uniqueUnit, product, updateOperation, "Update Operation from Test", "Testuser");
assertsUpdate(receiptUnit, stockTransaction, updateOperation, contractor);
}
}
}
Thread.sleep(3000);
}
Aggregations