Search in sources :

Example 26 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class SalesListingProducerOperation method generatePdfListings.

/**
 * Generates PDF files for units in a specific sales channel.
 * The lists are seperated by brand.
 * <p>
 * @param channel the saleschannel
 * @return PDF files for units in a specific sales channel.
 */
private Map<TradeName, Collection<FileJacket>> generatePdfListings(SalesChannel channel) throws UserInfoException {
    SubMonitor m = monitorFactory.newSubMonitor("Endkundenlisten erstellen", 10);
    m.message("lade Gerätedaten");
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransaction();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    PriceType priceType = (channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER);
    m.worked(2, "prüfe und filtere Geräte");
    SortedMap<UniqueUnit, StockUnit> uusus = toSortedMap(uniqueUnits, stockUnits, new UniqueUnitComparator());
    for (Iterator<Map.Entry<UniqueUnit, StockUnit>> it = uusus.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<UniqueUnit, StockUnit> entry = it.next();
        UniqueUnit uu = entry.getKey();
        StockUnit su = entry.getValue();
        if (uu == null)
            throw new NullPointerException(su + " has no UniqueUnit, Database Error");
        if (uu.getSalesChannel() != channel || !uu.hasPrice(priceType) || su.isInTransaction()) {
            it.remove();
        }
    }
    L.info("Selected {} Units for the Lists", uusus.size());
    m.worked(1, "sortiere und bereite Geräte vor");
    Map<Product, Set<UniqueUnit>> stackedUnits = new HashMap<>();
    for (Map.Entry<UniqueUnit, StockUnit> entry : uusus.entrySet()) {
        Product p = entry.getKey().getProduct();
        if (!stackedUnits.containsKey(p))
            stackedUnits.put(p, new HashSet<>());
        stackedUnits.get(p).add(entry.getKey());
    }
    List<StackedLine> stackedLines = new ArrayList<>(stackedUnits.size());
    DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(Locale.GERMAN);
    df.applyPattern("#,###,##0.00");
    for (Map.Entry<Product, Set<UniqueUnit>> entry : stackedUnits.entrySet()) {
        Product p = entry.getKey();
        StackedLine line = new StackedLine();
        line.setBrand(p.getTradeName());
        line.setGroup(p.getGroup());
        line.setCommodityGroupName(p.getGroup().getNote());
        line.setDescription(p.getDescription());
        line.setManufacturerName(p.getTradeName().getName());
        line.setManufacturerPartNo(p.getPartNo());
        line.setName(p.getName());
        line.setImageUrl(imageFinder.findImageUrl(p.getImageId()));
        boolean priceChanged = false;
        double customerPrice = 0;
        for (UniqueUnit uu : entry.getValue()) {
            StackedLineUnit elem = new StackedLineUnit();
            elem.setAccessories(UniqueUnitFormater.toSingleLineAccessories(uu));
            elem.setComment(UniqueUnitFormater.toSingleLineComment(uu));
            elem.setConditionLevelDescription(uu.getCondition().getNote());
            elem.setMfgDate(uu.getMfgDate());
            elem.setRefurbishedId(uu.getRefurbishId());
            elem.setSerial(uu.getSerial());
            elem.setWarranty(uu.getWarranty().getName());
            if (uu.getWarranty().equals(Warranty.WARRANTY_TILL_DATE))
                elem.setWarrentyTill(uu.getWarrentyValid());
            double uuPrice = uu.getPrice(priceType);
            elem.setCustomerPrice(uuPrice);
            elem.setRoundedTaxedCustomerPrice(TwoDigits.roundedApply(uuPrice, GlobalConfig.DEFAULT_TAX.getTax(), 0.02));
            // For the "ab € XXX" handler
            if (customerPrice == 0) {
                customerPrice = uuPrice;
            } else if (customerPrice > uuPrice) {
                customerPrice = uuPrice;
                priceChanged = true;
            } else if (customerPrice < uuPrice) {
                priceChanged = true;
            }
            elem.normaize();
            line.add(elem);
        }
        line.setAmount(line.getUnits().size());
        line.setCustomerPriceLabel((priceChanged ? "ab €" : "€") + df.format(TwoDigits.roundedApply(customerPrice, GlobalConfig.DEFAULT_TAX.getTax(), 0.02)));
        line.normaize();
        stackedLines.add(line);
    }
    L.info("Created {} Lines for the Lists", stackedLines.size());
    m.worked(1, "erzeuge listen");
    Set<ListingConfiguration> configs = new HashSet<>();
    if (listingService.isAmbiguous() || listingService.isUnsatisfied()) {
        for (TradeName brand : TradeName.values()) {
            for (ProductGroup value : ProductGroup.values()) {
                configs.add(ListingConfiguration.builder().filePrefix("Geräteliste ").name(brand.getName() + " " + value.getName()).brand(brand).groups(EnumSet.of(value)).headLeft("Beispieltext Links\nZeile 2").headCenter("Beispieltext Mitte\nZeile 2").headRight("Beispieltext Rechts\nZeile 2").footer("Fusszeilentext").build());
            }
        }
    } else {
        configs.addAll(listingService.get().listingConfigurations());
    }
    m.setWorkRemaining(configs.size() + 1);
    Map<TradeName, Collection<FileJacket>> jackets = new HashMap<>();
    for (ListingConfiguration config : configs) {
        m.worked(1, "erstelle Liste " + config.getName());
        if (StringUtils.isBlank(config.getJasperTemplateFile()))
            config.setJasperTemplateFile(compileReportToTempFile("CustomerSalesListing"));
        if (StringUtils.isBlank(config.getJasperTempleteUnitsFile()))
            config.setJasperTempleteUnitsFile(compileReportToTempFile("CustomerSalesListingUnits"));
        FileJacket fj = createListing(config, stackedLines);
        if (fj != null) {
            if (!jackets.containsKey(config.getBrand()))
                jackets.put(config.getBrand(), new HashSet<>());
            jackets.get(config.getBrand()).add(fj);
        }
    }
    m.finish();
    return jackets;
}
Also used : DecimalFormat(java.text.DecimalFormat) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)

Example 27 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class SalesListingProducerOperation method generateXlsListings.

/**
 * Generates XLS files for units in a specific sales channel.
 * The lists are seperated by brand.
 * <p>
 * @param channel the saleschannel
 * @return XLS files for units in a specific sales channel.
 */
private Map<TradeName, Collection<FileJacket>> generateXlsListings(SalesChannel channel) {
    SubMonitor m = monitorFactory.newSubMonitor("Listen für " + channel.getName() + " erstellen", 100);
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransactionAndPresentStock();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    Map<TradeName, List<UniqueUnit>> units = uniqueUnits.stream().collect(Collectors.groupingBy(uu -> uu.getProduct().getTradeName()));
    m.worked(2, "prüfe und filtere Geräte");
    Map<TradeName, Collection<FileJacket>> files = new HashMap<>();
    for (TradeName k : units.keySet()) {
        List<UniqueUnit> uus = units.get(k);
        Collections.sort(uus, new UniqueUnitComparator());
        List<Object[]> rows = new ArrayList<>();
        for (UniqueUnit get : uus) {
            UniqueUnit uu = get;
            Product p = uu.getProduct();
            // Cases to filter out.
            if (uu.getSalesChannel() != channel)
                continue;
            if (!uu.hasPrice((channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER)))
                continue;
            Object[] row = { uu.getRefurbishId(), p.getPartNo(), p.getGroup().getNote(), p.getTradeName().getName(), p.getName(), p.getDescription(), uu.getWarranty().getName(), uu.getWarrentyValid(), UniqueUnitFormater.toSingleLineAccessories(uu), uu.getCondition().getNote(), UniqueUnitFormater.toSingleLineComment(uu), uu.getPrice(PriceType.RETAILER), uu.getPrice(PriceType.CUSTOMER), (!uu.hasPrice(PriceType.CUSTOMER) ? null : TwoDigits.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.DEFAULT_TAX.getTax(), 0)) };
            rows.add(row);
        }
        if (rows.isEmpty())
            continue;
        m.worked(5, "creating File, Geräte: " + rows.size());
        STable unitTable = new STable();
        unitTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
        unitTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
        unitTable.setRowHeight(1000);
        unitTable.add(new STableColumn("SopoNr", 12));
        unitTable.add(new STableColumn("ArtikelNr", 15));
        unitTable.add(new STableColumn("Warengruppe", 18));
        unitTable.add(new STableColumn("Hersteller", 15));
        unitTable.add(new STableColumn("Bezeichnung", 30));
        unitTable.add(new STableColumn("Beschreibung", 60, LFT));
        unitTable.add(new STableColumn("Garantie", 18, LFT));
        unitTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
        unitTable.add(new STableColumn("Zubehör", 30, LFT));
        unitTable.add(new STableColumn("optische Bewertung", 25));
        unitTable.add(new STableColumn("Bemerkung", 50, LFT));
        unitTable.add(new STableColumn("Händler", 15, EURO));
        unitTable.add(new STableColumn("Endkunde", 15, EURO));
        unitTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
        unitTable.setModel(new STableModelList(rows));
        CCalcDocument cdoc = new TempCalcDocument();
        cdoc.add(new CSheet("Sonderposten", unitTable));
        files.put(k, Arrays.asList(new FileJacket(k.getName() + " Liste", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc))));
    }
    m.finish();
    return files;
}
Also used : Color(java.awt.Color) java.util(java.util) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) URL(java.net.URL) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Representation(eu.ggnet.lucidcalc.CFormat.Representation) LoggerFactory(org.slf4j.LoggerFactory) UploadCommand(eu.ggnet.dwoss.mandator.api.service.FtpConfiguration.UploadCommand) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) TOP(eu.ggnet.lucidcalc.CFormat.VerticalAlignment.TOP) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StringUtils(org.apache.commons.lang3.StringUtils) Mandator(eu.ggnet.dwoss.mandator.api.value.Mandator) Stocks(eu.ggnet.dwoss.stock.ee.assist.Stocks) Inject(javax.inject.Inject) MIDDLE(eu.ggnet.lucidcalc.CFormat.VerticalAlignment.MIDDLE) ListingMailConfiguration(eu.ggnet.dwoss.mandator.api.value.partial.ListingMailConfiguration) JRSaver(net.sf.jasperreports.engine.util.JRSaver) eu.ggnet.dwoss.mandator.api.service(eu.ggnet.dwoss.mandator.api.service) UniqueUnits(eu.ggnet.dwoss.uniqueunit.ee.assist.UniqueUnits) Instance(javax.enterprise.inject.Instance) net.sf.jasperreports.engine(net.sf.jasperreports.engine) UniqueUnitFormater(eu.ggnet.dwoss.uniqueunit.ee.format.UniqueUnitFormater) eu.ggnet.dwoss.util(eu.ggnet.dwoss.util) Stateless(javax.ejb.Stateless) PriceHistory(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory) Logger(org.slf4j.Logger) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType) LEFT(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment.LEFT) DecimalFormat(java.text.DecimalFormat) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) IOException(java.io.IOException) EntityManager(javax.persistence.EntityManager) MultiPartEmail(org.apache.commons.mail.MultiPartEmail) Collectors(java.util.stream.Collectors) JRBeanCollectionDataSource(net.sf.jasperreports.engine.data.JRBeanCollectionDataSource) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) CENTER(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment.CENTER) eu.ggnet.lucidcalc(eu.ggnet.lucidcalc) MonitorFactory(eu.ggnet.dwoss.progress.MonitorFactory) EmailException(org.apache.commons.mail.EmailException) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) GlobalConfig(eu.ggnet.dwoss.configuration.GlobalConfig) InputStream(java.io.InputStream) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 28 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product 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());
}
Also used : ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) UIManager(javax.swing.UIManager) java.util(java.util) TradeName(eu.ggnet.dwoss.rules.TradeName) ONESELF(eu.ggnet.dwoss.rules.TradeName.ONESELF) CategoryProductDto(eu.ggnet.dwoss.uniqueunit.ee.entity.dto.CategoryProductDto) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) Dl(eu.ggnet.saft.Dl) UnitCollectionDto(eu.ggnet.dwoss.uniqueunit.ee.entity.dto.UnitCollectionDto) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) DocumentType(eu.ggnet.dwoss.rules.DocumentType) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) UnitSupporter(eu.ggnet.dwoss.receipt.ee.UnitSupporter) Mandators(eu.ggnet.dwoss.mandator.Mandators) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) ProductFamily(eu.ggnet.dwoss.spec.ee.entity.ProductFamily) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) SpecAgent(eu.ggnet.dwoss.spec.ee.SpecAgent) eu.ggnet.dwoss.mandator.api.value(eu.ggnet.dwoss.mandator.api.value) SpecGenerator(eu.ggnet.dwoss.spec.ee.assist.gen.SpecGenerator) ProductProcessor(eu.ggnet.dwoss.receipt.ee.ProductProcessor) ProductProcessorStub(eu.ggnet.dwoss.receipt.stub.ProductProcessorStub) Reply(eu.ggnet.saft.api.Reply) ACER(eu.ggnet.dwoss.rules.TradeName.ACER) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Pattern(java.util.regex.Pattern) LockModeType(javax.persistence.LockModeType) ProductFamily(eu.ggnet.dwoss.spec.ee.entity.ProductFamily) CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) UnitCollectionDto(eu.ggnet.dwoss.uniqueunit.ee.entity.dto.UnitCollectionDto) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Mandators(eu.ggnet.dwoss.mandator.Mandators) LockModeType(javax.persistence.LockModeType) ProductProcessorStub(eu.ggnet.dwoss.receipt.stub.ProductProcessorStub) UnitSupporter(eu.ggnet.dwoss.receipt.ee.UnitSupporter) SpecAgent(eu.ggnet.dwoss.spec.ee.SpecAgent) SpecGenerator(eu.ggnet.dwoss.spec.ee.assist.gen.SpecGenerator) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) DocumentType(eu.ggnet.dwoss.rules.DocumentType) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) CategoryProductDto(eu.ggnet.dwoss.uniqueunit.ee.entity.dto.CategoryProductDto) Reply(eu.ggnet.saft.api.Reply)

Example 29 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class ProductListController method initialize.

/**
 * Adding the filters to the combo box. Setting the cell values and the
 * filtered list containing the data.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    tableView.getSelectionModel().setSelectionMode(MULTIPLE);
    menuTradeName.getItems().addAll(FXCollections.observableArrayList(TradeName.values()));
    menuProductGroup.getItems().addAll(ProductGroup.values());
    tableView.setOnDragDetected((MouseEvent event) -> {
        ArrayList<Product> selectedProducts = new ArrayList<>();
        selectedProducts.addAll(tableView.getSelectionModel().getSelectedItems());
        ArrayList<PicoProduct> selectedPicoProducts = new ArrayList<>();
        if (selectedProducts.isEmpty())
            return;
        Dragboard db = tableView.startDragAndDrop(TransferMode.ANY);
        ClipboardContent content = new ClipboardContent();
        selectedPicoProducts.addAll(selectedProducts.stream().map(p -> new PicoProduct(p.getId(), p.getName())).collect(Collectors.toList()));
        content.put(PICO_PRODUCT_DATA_FORMAT, selectedPicoProducts);
        db.setContent(content);
        event.consume();
    });
    setCellValues();
    progressBar.progressProperty().bind(LOADING_TASK.progressProperty());
    progressBar.visibleProperty().bind(LOADING_TASK.runningProperty());
    filteredProducts = new FilteredList<>(LOADING_TASK.getPartialResults(), p -> true);
    // filteredList does not allow sorting so it needs to be wrapped in a sortedList
    SortedList<Product> sortedProducts = new SortedList<>(filteredProducts);
    sortedProducts.comparatorProperty().bind(tableView.comparatorProperty());
    tableView.setItems(sortedProducts);
    editButton.disableProperty().bind(tableView.getSelectionModel().selectedItemProperty().isNull());
    Ui.progress().observe(LOADING_TASK);
    Ui.exec(LOADING_TASK);
}
Also used : java.util(java.util) Initializable(javafx.fxml.Initializable) TradeName(eu.ggnet.dwoss.rules.TradeName) javafx.scene.control(javafx.scene.control) URL(java.net.URL) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) MULTIPLE(javafx.scene.control.SelectionMode.MULTIPLE) Ui(eu.ggnet.saft.Ui) FxController(eu.ggnet.saft.api.ui.FxController) java.time(java.time) ProductTask(eu.ggnet.dwoss.uniqueunit.ui.ProductTask) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) DateFormats(eu.ggnet.dwoss.util.DateFormats) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Predicate(java.util.function.Predicate) ProductGroup(eu.ggnet.dwoss.rules.ProductGroup) FilteredList(javafx.collections.transformation.FilteredList) ClosedListener(eu.ggnet.saft.api.ui.ClosedListener) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) FxSaft(eu.ggnet.saft.core.ui.FxSaft) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct)

Example 30 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class TreeTableController method getProducts.

private ObservableList<TreeItem<DataWrapper>> getProducts(CategoryProduct cp) {
    ObservableList<TreeItem<DataWrapper>> result = FXCollections.observableArrayList();
    for (Product product : loadProducts(cp)) {
        TreeItem<DataWrapper> item = new TreeItem<>();
        ProductWrapper productWrapper = new ProductWrapper(item, product);
        item.setValue(productWrapper);
        item.getChildren().add(loading);
        item.expandedProperty().addListener(new ChangeListener<Boolean>() {

            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                if (productWrapper.isLoading()) {
                    return;
                }
                productWrapper.setLoading(true);
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        item.getChildren().addAll(getUnitCollections(product));
                        item.getChildren().remove(loading);
                    }
                }).start();
            }
        });
        result.add(item);
    }
    return result;
}
Also used : TreeItem(javafx.scene.control.TreeItem) CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product)

Aggregations

Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)50 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)29 Test (org.junit.Test)16 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)13 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)11 ProductEao (eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao)11 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)9 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)8 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)5 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 PriceType (eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)5 java.util (java.util)5 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)4 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)4 CategoryProduct (eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct)4 UnitCollection (eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection)4 JExcelLucidCalcReader (eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcReader)4 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)3 TradeName (eu.ggnet.dwoss.rules.TradeName)3 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)2