Package org.ofbiz.product.config.ProductConfigWrapper

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


        List questions = m_pcw.getQuestions();
        if (questions==null) ; // no questions, we shouldn't be here
        else{
            Iterator iter = questions.iterator();
            while (iter.hasNext()) {
                ConfigItem question = (ConfigItem)iter.next();
                List options = question.getOptions();
                Iterator itero = options.iterator();
                while (itero.hasNext()) {
                    ConfigOption configoption = (ConfigOption)itero.next();
                    if (configoption.isSelected()) {
                        listModel.addElement("  "+configoption.getDescription());
View Full Code Here


        List questions = m_pcw.getQuestions();
        if (questions==null) return; // no questions, return

        Iterator iter = questions.iterator();
        while (iter.hasNext()) {
            ConfigItem question = (ConfigItem)iter.next();
            /*Debug.logInfo("Question: " + question.getQuestion(), module);
            Debug.logInfo("IsFirst: "+question.isFirst()+
                    ", IsMandatory: "+question.isMandatory()+
                    ", IsSelected: "+question.isSelected()+
                    ", IsSingleChoice: "+question.isSingleChoice()+
                    ", IsStandard: "+question.isStandard(), module);*/

            List options = question.getOptions();
            Iterator itero = options.iterator();

            while (itero.hasNext()) {
                ConfigOption configoption = (ConfigOption)itero.next();
                /*Debug.logInfo("Found option " + configoption.getDescription(), module);
View Full Code Here

        int selectedOptionSize = 0;
        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) {
                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");
View Full Code Here

        List questions = m_pcw.getQuestions();
        if(questions==null) ; // no questions, we shouldn't be here
        else{
            Iterator iter = questions.iterator();
            while(iter.hasNext()){
                ConfigItem question = (ConfigItem)iter.next();
                List options = question.getOptions();
                Iterator itero = options.iterator();
                while(itero.hasNext()){
                    ConfigOption configoption = (ConfigOption)itero.next();
                    if (configoption.isSelected()){
                        listModel.addElement("  "+configoption.getDescription());
View Full Code Here

        List questions = m_pcw.getQuestions();
        if(questions==null) return; // no questions, return
    
        Iterator iter = questions.iterator();
        while(iter.hasNext()){
            ConfigItem question = (ConfigItem)iter.next();
            /*Debug.logInfo("Question: " + question.getQuestion(), module);
            Debug.logInfo("IsFirst: "+question.isFirst()+
                    ", IsMandatory: "+question.isMandatory()+
                    ", IsSelected: "+question.isSelected()+
                    ", IsSingleChoice: "+question.isSingleChoice()+
                    ", IsStandard: "+question.isStandard(), module);*/
                             
            List options = question.getOptions();
            Iterator itero = options.iterator();
           
            while(itero.hasNext()){
                ConfigOption configoption = (ConfigOption)itero.next();
                /*Debug.logInfo("Found option " + configoption.getDescription(), module);
View Full Code Here

TOP

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

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.