use of eu.ggnet.dwoss.spec.ee.entity.ProductModel in project dwoss by gg-net.
the class ProductSpecEaoFindByPartNoIT method testFindByPartNo.
/**
* Test of findByPartNo method, of class ProductSpecEao.
*/
@Test
public void testFindByPartNo() throws Exception {
utx.begin();
em.joinTransaction();
ProductSeries veriton = new ProductSeries(TradeName.FUJITSU, ProductGroup.DESKTOP, "Veriton");
em.persist(veriton);
ProductFamily m400 = new ProductFamily("M400");
m400.setSeries(veriton);
em.persist(m400);
ProductModel M480G = new ProductModel("M480G");
M480G.setFamily(m400);
em.persist(M480G);
Desktop M480G_1 = new Desktop("PX.99999.321", 2L);
M480G_1.setModel(M480G);
M480G_1.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
M480G_1.setComment("Ein Kommentar");
M480G_1.setCpu(new Cpu(Cpu.Series.CORE, "Eine CPU", Cpu.Type.MOBILE, 123.0, 2));
M480G_1.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte"));
M480G_1.setOs(Desktop.Os.LINUX);
M480G_1.setMemory(12345);
M480G_1.add(Desktop.Hdd.ROTATING_1000);
M480G_1.add(Desktop.Odd.BLURAY_COMBO);
M480G_1.setExtras(Desktop.Extra.KAMERA);
em.persist(M480G_1);
utx.commit();
utx.begin();
em.joinTransaction();
ProductSpecEao specEao = new ProductSpecEao(em);
Desktop spec = (Desktop) specEao.findByPartNo(M480G_1.getPartNo());
assertNotNull(spec);
assertEquals(M480G_1.getExtras(), spec.getExtras());
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductModel in project dwoss by gg-net.
the class ProductSpecEaoFindByProductIdIT method testFindByProductId.
@Test
public void testFindByProductId() throws Exception {
utx.begin();
em.joinTransaction();
ProductSeries veriton = new ProductSeries(TradeName.FUJITSU, ProductGroup.DESKTOP, "Veriton");
em.persist(veriton);
ProductFamily m400 = new ProductFamily("M400");
m400.setSeries(veriton);
em.persist(m400);
ProductModel M480G = new ProductModel("M480G");
M480G.setFamily(m400);
em.persist(M480G);
Desktop M480G_1 = new Desktop("PX.99999.321", 2L);
M480G_1.setModel(M480G);
M480G_1.setProductId(5L);
M480G_1.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
M480G_1.setComment("Ein Kommentar");
M480G_1.setCpu(new Cpu(Cpu.Series.CORE, "Eine CPU", Cpu.Type.MOBILE, 123.0, 2));
M480G_1.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte"));
M480G_1.setOs(Desktop.Os.LINUX);
M480G_1.setMemory(12345);
M480G_1.add(Desktop.Hdd.ROTATING_1000);
M480G_1.add(Desktop.Odd.BLURAY_COMBO);
M480G_1.setExtras(Desktop.Extra.KAMERA);
em.persist(M480G_1);
Desktop M480G_2 = new Desktop("PX.99999.AAA", 2L);
M480G_2.setModel(M480G);
M480G_2.setProductId(6L);
M480G_2.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
M480G_2.setComment("Ein Kommentar");
M480G_2.setCpu(new Cpu(Cpu.Series.CORE, "Eine CPU", Cpu.Type.MOBILE, 123.0, 2));
M480G_2.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte"));
M480G_2.setOs(Desktop.Os.LINUX);
M480G_2.setMemory(12345);
M480G_2.add(Desktop.Hdd.ROTATING_1000);
M480G_2.add(Desktop.Odd.BLURAY_COMBO);
M480G_2.setExtras(Desktop.Extra.KAMERA);
em.persist(M480G_2);
utx.commit();
ProductSpecEao specEao = new ProductSpecEao(em);
Desktop spec = (Desktop) specEao.findByProductId(5L);
assertNotNull(spec);
List<ProductSpec> productSpecs = specEao.findByProductIds(Arrays.asList(5L, 6L));
assertEquals(2, productSpecs.size());
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductModel in project dwoss by gg-net.
the class ContainerITGeneratorHelper method makeOne.
public ProductSpec makeOne() {
SpecGenerator g = new SpecGenerator();
ProductSpec spec = g.makeSpec();
ProductModel model = spec.getModel();
ProductModelEmo productModelEmo = new ProductModelEmo(specEm);
model = productModelEmo.request(model.getFamily().getSeries().getBrand(), model.getFamily().getSeries().getGroup(), model.getFamily().getSeries().getName(), model.getFamily().getName(), model.getName());
spec.setModel(model);
if (spec instanceof DisplayAble) {
DisplayAble da = (DisplayAble) spec;
da.setDisplay(new DisplayEmo(specEm).weakRequest(da.getDisplay().getSize(), da.getDisplay().getResolution(), da.getDisplay().getType(), da.getDisplay().getRation()));
}
if (spec instanceof Desktop) {
Desktop desktop = (Desktop) spec;
if (desktop.getCpu() == null || desktop.getGpu() == null)
throw new IllegalArgumentException("Cpu or Gpu of a Desktop are null. " + desktop);
Cpu cpu = new CpuEao(specEm).findById(desktop.getCpu().getId());
Gpu gpu = new GpuEao(specEm).findById(desktop.getGpu().getId());
if (cpu != null)
desktop.setCpu(cpu);
if (gpu != null)
desktop.setGpu(gpu);
}
specEm.persist(spec);
return spec;
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductModel in project dwoss by gg-net.
the class UnitViewTryout method main.
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
final SpecGenerator GEN = new SpecGenerator();
final List<ProductSpec> productSpecs = new ArrayList<>();
final Map<String, ProductModel> productModels = new HashMap<>();
final Map<String, ProductSeries> productSeries = new HashMap<>();
final Map<String, ProductFamily> productFamily = new HashMap<>();
final List<Product> products = new ArrayList<>();
for (int i = 0; i < 100; i++) {
ProductSpec spec = GEN.makeSpec();
productSpecs.add(spec);
products.add(new Product(spec.getModel().getFamily().getSeries().getGroup(), spec.getModel().getFamily().getSeries().getBrand(), spec.getPartNo(), spec.getModel().getName()));
productModels.putIfAbsent(spec.getModel().getName(), spec.getModel());
productFamily.putIfAbsent(spec.getModel().getFamily().getName(), spec.getModel().getFamily());
productSeries.putIfAbsent(spec.getModel().getFamily().getSeries().getName(), spec.getModel().getFamily().getSeries());
}
// final Product product = new Product(spec.getModel().getFamily().getSeries().getGroup(),
// spec.getModel().getFamily().getSeries().getBrand(), spec.getPartNo(), spec.getModel().getName());
Dl.remote().add(Mandators.class, 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("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("Not supported yet.");
}
@Override
public Contractors loadContractors() {
return new Contractors(EnumSet.allOf(TradeName.class), TradeName.getManufacturers());
}
@Override
public PostLedger loadPostLedger() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ShippingTerms loadShippingTerms() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.remote().add(SpecAgent.class, new SpecAgent() {
@Override
public ProductSpec findProductSpecByPartNoEager(String partNo) {
return productSpecs.stream().filter(p -> Objects.equals(partNo, p.getPartNo())).findFirst().orElse(null);
}
// <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) {
if (entityClass.equals(ProductSpec.class))
return (List<T>) productSpecs;
else if (entityClass.equals(ProductSeries.class))
return (List<T>) new ArrayList<>(productSeries.values());
else if (entityClass.equals(ProductFamily.class))
return (List<T>) new ArrayList<>(productFamily.values());
else if (entityClass.equals(ProductModel.class))
return (List<T>) new ArrayList<>(productModels.values());
return Collections.emptyList();
}
@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) {
return findAll(entityClass);
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
return findAll(entityClass, start, amount);
}
@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.");
}
});
Dl.remote().add(UnitSupporter.class, new UnitSupporter() {
@Override
public boolean isRefurbishIdAvailable(String refurbishId) {
return Pattern.matches("([2-8][0-9]{4}|A1[0-9]{3})", refurbishId);
}
@Override
public boolean isSerialAvailable(String serial) {
if (serial == null)
return true;
return !serial.startsWith("AAAA");
}
@Override
public String findRefurbishIdBySerial(String serial) {
if (serial == null)
return null;
if (serial.startsWith("B"))
return "12345";
return null;
}
});
Dl.remote().add(UniqueUnitAgent.class, new UniqueUnitAgent() {
@Override
public Product findProductByPartNo(String partNo) {
return products.stream().filter(p -> Objects.equals(partNo, p.getPartNo())).findFirst().orElse(null);
}
// <editor-fold defaultstate="collapsed" desc="Unneeded Methods">
@Override
public UniqueUnit findUnitByIdentifierEager(UniqueUnit.Identifier type, String identifier) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@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.");
}
@Override
public Product findProductByPartNoEager(String partNo) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public CategoryProduct createOrUpdate(CategoryProductDto dto, String username) throws NullPointerException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
// </editor-fold>
@Override
public Reply<Void> deleteCategoryProduct(long id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Reply<Void> addToUnitCollection(PicoUnit unit, long unitCollectionId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Reply<Void> unsetUnitCollection(PicoUnit unit) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Reply<UnitCollection> createOnProduct(long productId, UnitCollectionDto dto, String username) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Reply<UnitCollection> update(UnitCollectionDto dto, String username) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Reply<Void> delete(UnitCollection dto) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.remote().add(ProductProcessor.class, new ProductProcessorStub());
UnitController controller = new UnitController();
UnitModel model = new UnitModel();
model.setContractor(ONESELF);
model.setMode(ACER);
controller.setModel(model);
final UnitView view = new UnitView(null);
view.setModel(model);
controller.setView(view);
view.setController(controller);
controller.init();
// To Model
view.setVisible(true);
System.out.println("View canceled ? " + view.isCancel());
System.out.println(view.getUnit());
System.out.println(model.getProduct());
System.out.println(model.getOperation());
System.out.println(model.getOperationComment());
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductModel in project dwoss by gg-net.
the class ProductSpecTest method testValidateProductSpec.
@Test
public void testValidateProductSpec() {
ProductSeries veriton = new ProductSeries(TradeName.ACER, ProductGroup.DESKTOP, "Veriton");
ProductFamily lfamiliy = new ProductFamily("Veriton L");
lfamiliy.setSeries(veriton);
ProductModel l640 = new ProductModel("Veriton L640");
l640.setFamily(lfamiliy);
ProductSpec s = new BasicSpec("LX.AAAAA.BBB", 1L);
s.setModel(l640);
assertThat(validator.validate(s)).isEmpty();
s.setPartNo("LX.AAAAA.OOB");
assertTrue("The letter O should be allowed", validator.validate(s).isEmpty());
s.setPartNo(" LLL");
assertFalse(s.getPartNo() + " should be invalid", validator.validate(s).isEmpty());
s.setPartNo("RA LL");
assertFalse(s.getPartNo() + " should be invalid", validator.validate(s).isEmpty());
}
Aggregations