Search in sources :

Example 6 with PriceType

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

the class ProductFormater method toSource.

public static String toSource(Product product) {
    String var = randomVar();
    String re = product.getClass().getSimpleName() + " " + var + " = new " + product.getClass().getName() + "();\n";
    for (TradeName id : product.getAdditionalPartNos().keySet()) {
        re += var + ".setAdditionalPartNo(TradeName." + id + ",\"" + product.getAdditionalPartNo(id) + "\");\n";
    }
    for (PriceType id : product.getPrices().keySet()) {
        re += var + ".setPrice(PriceType." + id + "," + product.getPrice(id) + ",\"formToSource\");\n";
    }
    if (!product.getFlags().isEmpty()) {
        re += var + ".setFlags(EnumSet.of(";
        for (Iterator<Product.Flag> it = product.getFlags().iterator(); it.hasNext(); ) {
            Product.Flag flag = it.next();
            re += "Product.Flag." + flag;
            if (it.hasNext())
                re += ",";
        }
        re += "));\n";
    }
    if (product.getName() != null)
        re += var + ".setName(\"" + product.getName() + "\");\n";
    if (product.getDescription() != null)
        re += var + ".setDescription(\"" + product.getDescription() + "\");\n";
    if (product.getPartNo() != null)
        re += var + ".setPartNo(\"" + product.getPartNo() + "\");\n";
    re += var + ".setGroup(ProductGroup." + product.getGroup() + ");\n";
    re += var + ".setTradeName(TradeName." + product.getTradeName() + ");\n";
    re += var + ".setGtin(" + product.getGtin() + ");\n";
    return re;
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)

Aggregations

PriceType (eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)6 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)3 Prices (eu.ggnet.dwoss.uniqueunit.ui.product.ProductFx.Prices)2 FXML (javafx.fxml.FXML)2 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 TradeName (eu.ggnet.dwoss.rules.TradeName)1 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)1 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)1 PicoProduct (eu.ggnet.dwoss.uniqueunit.api.PicoProduct)1 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)1 CategoryProduct (eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct)1 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)1 ProductDto (eu.ggnet.dwoss.uniqueunit.ee.entity.dto.ProductDto)1 AdditionalPartNo (eu.ggnet.dwoss.uniqueunit.ui.product.ProductFx.AdditionalPartNo)1 DecimalFormat (java.text.DecimalFormat)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1