Package org.ofbiz.product.config.ProductConfigWrapper

Examples of org.ofbiz.product.config.ProductConfigWrapper.ConfigOption


        public void reset() {
            showOption = 0;
            List<ConfigOption> options = question.getOptions();
            if (question.isSelected()) {
                ConfigOption selectedOption = question.getSelected();
                showOption = options.indexOf(selectedOption);
            }
            ConfigOption configoption = options.get(showOption);
            button.setText(configoption.getDescription());
            return;
        }
View Full Code Here


            if (ci.isStandard()) {
                selectedOptions.addAll(options);
            } else {
                Iterator availOptions = options.iterator();
                while (availOptions.hasNext()) {
                    ConfigOption oneOption = (ConfigOption)availOptions.next();
                    if (oneOption.isSelected()) {
                        selectedOptions.add(oneOption);
                    }
                }
            }

            if (selectedOptions.size() > 0) {
                selectedOptionSize += selectedOptions.size();
                configItemId = ci.getConfigItemAssoc().getString("configItemId");
                sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum");
                try {
                    List <GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum));
                    Iterator <GenericValue> configIt = configs.iterator();
                    while (configIt.hasNext()) {
                        GenericValue productConfigConfig = configIt.next();
                        Iterator selOpIt = selectedOptions.iterator();
                        while (selOpIt.hasNext()) {
                            ConfigOption oneOption = (ConfigOption)selOpIt.next();
                            String configOptionId = oneOption.configOption.getString("configOptionId");
                            if (productConfigConfig.getString("configOptionId").equals(configOptionId)) {
                                configsToCheck.add(productConfigConfig);
                            }
                        }
                    }

                } catch (GenericEntityException e) {
                    Debug.logError(e, module);
                }
                          
            } 
        }
        if (UtilValidate.isNotEmpty(configsToCheck)) {
            Iterator <GenericValue> ctci = configsToCheck.iterator();
            while (ctci.hasNext()) {
                GenericValue productConfigConfig =  ctci.next();
                String tempConfigId = productConfigConfig.getString("configId");
                try {
                    List tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId));
                    if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) {
                            configWrapper.configId = tempConfigId;
                            Debug.logInfo("Existing configuration found with configId:"+ tempConfigId,  module);
                            return;
                    }
                } catch (GenericEntityException e) {
                    Debug.logError(e, module);
                }
               
            }
        }
       
        //Current configuration is not found in ProductConfigConfig entity. So lets store this one
        boolean nextId = true;
        for (int i = 0; i < questions.size(); i++) {
            String configItemId = null;
            Long sequenceNum = null;
            List <ProductConfigWrapper.ConfigOption> selectedOptions = new ArrayList <ProductConfigWrapper.ConfigOption>();       
            ConfigItem ci = (ConfigItem)questions.get(i);
            List options = ci.getOptions();
           if (ci.isStandard()) {
                selectedOptions.addAll(options);
            } else {
                Iterator availOptions = options.iterator();
                while (availOptions.hasNext()) {
                    ConfigOption oneOption = (ConfigOption)availOptions.next();
                    if (oneOption.isSelected()) {
                        selectedOptions.add(oneOption);
                    }
                }
            }
           
            if (selectedOptions.size() > 0) {
                if (nextId) {
                    configId = delegator.getNextSeqId("ProductConfigConfig");
                    //get next configId only once and only if there are selectedOptions
                    nextId = false;
                }
                configItemId = ci.getConfigItemAssoc().getString("configItemId");
                sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum");
                Iterator selOpIt = selectedOptions.iterator();
                while (selOpIt.hasNext()) {
                    ConfigOption oneOption = (ConfigOption)selOpIt.next();
                    String configOptionId = oneOption.configOption.getString("configOptionId");
                    GenericValue productConfigConfig = delegator.makeValue("ProductConfigConfig");
                    productConfigConfig.put("configId", configId);
                    productConfigConfig.put("configItemId", configItemId);
                    productConfigConfig.put("sequenceNum", sequenceNum);
View Full Code Here

    public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, double quantity, LocalDispatcher dispatcher) throws GenericServiceException {
        boolean available = true;
        List options = productConfig.getSelectedOptions();
        Iterator optionsIt = options.iterator();
        while (optionsIt.hasNext()) {
            ConfigOption ci = (ConfigOption)optionsIt.next();
            List products = ci.getComponents();
            Iterator productsIt = products.iterator();
            while (productsIt.hasNext()) {
                GenericValue product = (GenericValue)productsIt.next();
                String productId = product.getString("productId");
                Double cmpQuantity = product.getDouble("quantity");
                double neededQty = 1.0;
                if (cmpQuantity != null) {
                    neededQty = quantity * cmpQuantity.doubleValue();
                }
                if (!isProductInventoryAvailableByFacility(productId, inventoryFacilityId, neededQty, dispatcher)) {
                    ci.setAvailable(false);
                }
            }
            if (!ci.isAvailable()) {
                available = false;
            }
        }
        return available;
    }
View Full Code Here

            ProductConfigWrapper pcw = null;
            pcw = item.getConfigWrapper();
            List selected = pcw.getSelectedOptions();
            Iterator iter = selected.iterator();
            while(iter.hasNext()){
                ConfigOption configoption = (ConfigOption)iter.next();
                Map itemInfo = new HashMap();
                if (configoption.isSelected() && !configoption.isDefault()){
                    itemInfo.put("productId", "");
                    itemInfo.put("sku", "");
                    itemInfo.put("configDescription", configoption.getDescription());
                    itemInfo.put("configQuantity", UtilFormatOut.formatQuantity(item.getQuantity()));
                    itemInfo.put("configBasePrice", UtilFormatOut.formatPrice(configoption.getOffsetPrice()));
                    //itemInfo.put("isTaxable", item.taxApplies() ? "T" : " ");
                    list.add(itemInfo);
                }
            }
        }
View Full Code Here

                    // pcw = new ProductConfigWrapper(delegator, session.getDispatcher(), productId, null, null, null, null, null, null);
                    pcw = item.getConfigWrapper();
                    List selected = pcw.getSelectedOptions();
                    Iterator iter = selected.iterator();
                    while(iter.hasNext()){   
                        ConfigOption configoption = (ConfigOption)iter.next();
                        if (configoption.isSelected()){
                            XModel option = Journal.appendNode(model, "tr", ""+cart.getItemIndex(item), "");
                            Journal.appendNode(option, "td", "sku", "");
                            Journal.appendNode(option, "td", "desc", configoption.getDescription());
                            Journal.appendNode(option, "td", "qty", "");
                            Journal.appendNode(option, "td", "price", UtilFormatOut.formatPrice(configoption.getPrice()));
                            Journal.appendNode(option, "td", "index", Integer.toString(cart.getItemIndex(item)));
                        }
                    }
                }
                 
View Full Code Here

        public void setupButton(XButton button){
            this.button = button;
            List options = question.getOptions();
            if(question.isSelected()){
                ConfigOption selectedOption = question.getSelected();
                showOption = options.indexOf(selectedOption);
            }
            ConfigOption configoption = (ConfigOption)options.get(showOption);        
            button.setText(configoption.getDescription());
            return;
        }
View Full Code Here

        } */

        public void buttonClicked(){
            //only two choices, if the button is clicked, toggle
            List options = question.getOptions();
            ConfigOption unselectedoption = (ConfigOption)options.get(showOption);        
            unselectedoption.setSelected(false);
            showOption = (showOption+1)%2;
            ConfigOption selectedoption = (ConfigOption)options.get(showOption);        
            selectedoption.setSelected(true);
            button.setText(selectedoption.getDescription());
            return;
        }
View Full Code Here

              
        public void reset(){
            showOption = 0;
            List options = question.getOptions();
            if(question.isSelected()){
                ConfigOption selectedOption = question.getSelected();
                showOption = options.indexOf(selectedOption);
            }
            ConfigOption configoption = (ConfigOption)options.get(showOption);        
            button.setText(configoption.getDescription());
            return;          
        }
View Full Code Here

            Iterator options = question.getOptions().iterator();
          
            DefaultListModel listModel = new DefaultListModel();
           
            while(options.hasNext()){
                ConfigOption configoption = (ConfigOption)options.next();
                listModel.addElement(configoption.getDescription());
                //Debug.logInfo("Found option " + configoption.getDescription(), module);
                //Debug.logInfo("IsAvailable: "+configoption.isAvailable()+
                //    ", IsSelected: "+configoption.isSelected(), module);
            }
           
View Full Code Here

                    List<ConfigOption> options = (List<ConfigOption>)question.getOptions();
                    for (ConfigOption option: options){
                        option.setSelected(false);
                    }
                    for(int i: selected){
                        ConfigOption option = options.get(i);
                        option.setSelected(true);
                    }
                    m_configureItem.listPressed();
                }
            }
            catch(Exception ex){
View Full Code Here

TOP

Related Classes of org.ofbiz.product.config.ProductConfigWrapper.ConfigOption

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.