Package org.hoteia.qalingo.core.domain

Examples of org.hoteia.qalingo.core.domain.CatalogCategoryMaster


      try {
          if(params != null){
                for (Object param : params) {
                    if (param == null) continue;
                    if (param instanceof CatalogCategoryMaster) {
                        CatalogCategoryMaster catalogCategoryMaster = (CatalogCategoryMaster) param;
                        getParams.put(RequestConstants.REQUEST_PARAMETER_CATALOG_CATEGORY_CODE, handleParamValue(catalogCategoryMaster.getCode()));
                        break;
                    } else if (param instanceof CatalogCategoryVirtual) {
                        CatalogCategoryVirtual catalogCategoryVirtual = (CatalogCategoryVirtual) param;
                        getParams.put(RequestConstants.REQUEST_PARAMETER_CATALOG_CATEGORY_CODE, handleParamValue(catalogCategoryVirtual.getCode().toString()));
                        break;
View Full Code Here


            final CatalogMaster catalogMaster = catalogService.getMasterCatalogById(currentMarketArea.getCatalog().getCatalogMaster().getId());

            Set<CatalogCategoryMaster> catalogCategories = new HashSet<CatalogCategoryMaster>();
            if(catalogMaster.getCatalogCategories() != null){
                for (Iterator<CatalogCategoryMaster> iterator = catalogMaster.getCatalogCategories().iterator(); iterator.hasNext();) {
                    CatalogCategoryMaster categoryMaster = (CatalogCategoryMaster) iterator.next();
                    CatalogCategoryMaster reloadedCategoryMaster = catalogCategoryService.getMasterCatalogCategoryById(categoryMaster.getId(), new FetchPlan(categoryMasterFetchPlans));
                    Set<CatalogCategoryMaster> reloadedSubCategories = new HashSet<CatalogCategoryMaster>();
                    if(reloadedCategoryMaster.getSortedChildCatalogCategories() != null){
                        for (Iterator<CatalogCategoryMaster> iteratorSubCategories = reloadedCategoryMaster.getSortedChildCatalogCategories().iterator(); iteratorSubCategories.hasNext();) {
                            CatalogCategoryMaster subCategory = (CatalogCategoryMaster) iteratorSubCategories.next();
                            CatalogCategoryMaster reloadedSubCategory = catalogCategoryService.getMasterCatalogCategoryById(subCategory.getId(), new FetchPlan(categoryMasterFetchPlans));
                            reloadedSubCategories.add(reloadedSubCategory);
                        }
                    }
                    reloadedCategoryMaster.setCatalogCategories(reloadedSubCategories);
                    catalogCategories.add(reloadedCategoryMaster);
View Full Code Here

            FetchPlan fetchPlanWithProducts = new FetchPlan(categoryMasterFetchPlans);
            fetchPlanWithProducts.getFetchModes().add(new SpecificFetchMode(CatalogCategoryVirtual_.catalogCategoryProductSkuRels.getName()));
            fetchPlanWithProducts.getFetchModes().add(new SpecificFetchMode("catalogCategoryProductSkuRels.pk.productSku"));
            fetchPlanWithProducts.getFetchModes().add(new SpecificFetchMode(CatalogCategoryVirtual_.assets.getName()));
           
            CatalogCategoryMaster reloadedCategory = catalogCategoryService.getMasterCatalogCategoryByCode(categoryCode, requestData.getMasterCatalogCode(), fetchPlanWithProducts);
            catalogCategoryPojo = (BoCatalogCategoryPojo) catalogPojoService.buildCatalogCategory(reloadedCategory);
            final List<ProductSku> productSkus = reloadedCategory.getSortedProductSkus();
            catalogCategoryPojo.setProductMarketings(buildSortedProduct(productSkus));
           
        } else if("virtual".equals(catalogType)){
            FetchPlan fetchPlanWithProducts = new FetchPlan(categoryVirtualFetchPlans);
            fetchPlanWithProducts.getFetchModes().add(new SpecificFetchMode(CatalogCategoryVirtual_.catalogCategoryProductSkuRels.getName()));
            fetchPlanWithProducts.getFetchModes().add(new SpecificFetchMode(CatalogCategoryVirtual_.catalogCategoryProductSkuRels.getName() + "." + CatalogCategoryVirtualProductSkuRel_.pk.getName() "." + org.hoteia.qalingo.core.domain.CatalogCategoryVirtualProductSkuPk_.productSku.getName()));

            CatalogCategoryVirtual reloadedCategory = catalogCategoryService.getVirtualCatalogCategoryByCode(categoryCode, requestData.getVirtualCatalogCode(), requestData.getMasterCatalogCode(), fetchPlanWithProducts);
            catalogCategoryPojo = (BoCatalogCategoryPojo) catalogPojoService.buildCatalogCategory(reloadedCategory);
            final List<ProductSku> productSkus = reloadedCategory.getSortedProductSkus();
            catalogCategoryPojo.setProductMarketings(buildSortedProduct(productSkus));
        }
        return catalogCategoryPojo;
    }
View Full Code Here

        final String categoryCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CATALOG_CATEGORY_CODE);
        final String catalogType = request.getParameter(RequestConstants.REQUEST_PARAMETER_CATALOG_TYPE);

        BoCatalogCategoryPojo catalogCategoryPojo = new BoCatalogCategoryPojo();
        if("master".equals(catalogType)){
            CatalogCategoryMaster reloadedCategory = catalogCategoryService.getMasterCatalogCategoryByCode(categoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));
            catalogCategoryPojo = (BoCatalogCategoryPojo) catalogPojoService.buildCatalogCategory(reloadedCategory);
           
            List<ProductSku> productSkus = productService.findProductSkusNotInThisMasterCatalogCategoryId(reloadedCategory.getId(), new FetchPlan(productSkuFetchPlans));
            catalogCategoryPojo.setProductMarketings(buildSortedProduct(productSkus));
           
        } else if("virtual".equals(catalogType)){
            CatalogCategoryVirtual reloadedCategory = catalogCategoryService.getVirtualCatalogCategoryByCode(categoryCode, requestData.getVirtualCatalogCode(), requestData.getMasterCatalogCode(), new FetchPlan(categoryVirtualFetchPlans));
            catalogCategoryPojo = (BoCatalogCategoryPojo) catalogPojoService.buildCatalogCategory(reloadedCategory);
           
            List<ProductSku> productSkus = productService.findProductSkusNotInThisVirtualCatalogCategoryId(reloadedCategory.getId(), new FetchPlan(productSkuFetchPlans));
            catalogCategoryPojo.setProductMarketings(buildSortedProduct(productSkus));
        }
        return catalogCategoryPojo;
    }
View Full Code Here

        final String skuCodes = request.getParameter(RequestConstants.REQUEST_PARAMETER_SKU_CODE_LIST);

        BoCatalogCategoryPojo catalogCategoryPojo = new BoCatalogCategoryPojo();

        if("master".equals(catalogType)){
            CatalogCategoryMaster reloadedCategory = catalogCategoryService.getMasterCatalogCategoryByCode(categoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));
           
            if(StringUtils.isNotEmpty(skuCodes)){
                List<String> productSkuCodes = reloadedCategory.getProductSkuCodes();
                String[] skuCodesSplit = skuCodes.split(";");
                for (int i = 0; i < skuCodesSplit.length; i++) {
                    String skuCode = skuCodesSplit[i];
                    if(productSkuCodes != null
                            && !productSkuCodes.contains(skuCode)){
                        final ProductSku reloadedProductSku = productService.getProductSkuByCode(skuCode, new FetchPlan(productSkuFetchPlans));
                        if(reloadedProductSku != null){
                            reloadedCategory.getCatalogCategoryProductSkuRels().add(new CatalogCategoryMasterProductSkuRel(reloadedCategory, reloadedProductSku));
                            reloadedCategory = catalogCategoryService.saveOrUpdateCatalogCategory(reloadedCategory);
                        }
                    }
                }
            }
            catalogCategoryPojo = (BoCatalogCategoryPojo) catalogPojoService.buildCatalogCategory(reloadedCategory);
           
        } else if("virtual".equals(catalogType)){
            CatalogCategoryVirtual reloadedCategory = catalogCategoryService.getVirtualCatalogCategoryByCode(categoryCode, requestData.getVirtualCatalogCode(), requestData.getMasterCatalogCode(), new FetchPlan(categoryVirtualFetchPlans));
           
            if(StringUtils.isNotEmpty(skuCodes)){
                List<String> productSkuCodes = reloadedCategory.getProductSkuCodes();
                String[] skuCodesSplit = skuCodes.split(";");
                for (int i = 0; i < skuCodesSplit.length; i++) {
                    String skuCode = skuCodesSplit[i];
                    if(productSkuCodes != null
                            && !productSkuCodes.contains(skuCode)){
                        final ProductSku reloadedProductSku = productService.getProductSkuByCode(skuCode, new FetchPlan(productSkuFetchPlans));
                        if(reloadedProductSku != null){
                            reloadedCategory.getCatalogCategoryProductSkuRels().add(new CatalogCategoryVirtualProductSkuRel(reloadedCategory, reloadedProductSku));
                            reloadedCategory = catalogCategoryService.saveOrUpdateCatalogCategory(reloadedCategory);
                        }
                    }
                }
            }
View Full Code Here

    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), BoUrls.MASTER_CATEGORY_DETAILS.getVelocityPage());
        final RequestData requestData = requestUtil.getRequestData(request);
       
    final String catalogCategoryCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CATALOG_CATEGORY_CODE);

    final CatalogCategoryMaster catalogCategory = catalogCategoryService.getMasterCatalogCategoryByCode(catalogCategoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));

    // SANITY CHECK
    if(catalogCategory == null){
            final String url = backofficeUrlService.generateUrl(BoUrls.MASTER_CATALOG, requestData);
            return new ModelAndView(new RedirectView(url));
    }
   
        modelAndView.addObject("availableGlobaleAttributeDefinitions", backofficeViewBeanFactory.buildListViewBeanAttributeDefinition(requestData, attributeService.findCatalogCategoryGlobalAttributeDefinitions()));
        modelAndView.addObject("availableMarketAreaAttributeDefinitions", backofficeViewBeanFactory.buildListViewBeanAttributeDefinition(requestData, attributeService.findCatalogCategoryMarketAreaAttributeDefinitions()));

    modelAndView.addObject(ModelConstants.URL_BACK, backofficeUrlService.generateUrl(BoUrls.MASTER_CATALOG, requestData));

    initProductMasterCategoryModelAndView(request, modelAndView, catalogCategory);
   
        Object[] params = {catalogCategory.getName() + " (" + catalogCategory.getCode() + ")"};
        overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView, BoUrls.MASTER_CATEGORY_DETAILS.getKey(), params);

        return modelAndView;
  }
View Full Code Here

       
    final String catalogCategoryCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CATALOG_CATEGORY_CODE);

        if(StringUtils.isNotEmpty(catalogCategoryCode)){
            // EDIT MODE
            final CatalogCategoryMaster catalogCategory = catalogCategoryService.getMasterCatalogCategoryByCode(catalogCategoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));
           
            Object[] params = {catalogCategory.getName() + " (" + catalogCategory.getCode() + ")"};
            overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView, BoUrls.MASTER_CATEGORY_EDIT.getKey(), params);
           
            initProductMasterCategoryModelAndView(request, modelAndView, catalogCategory);
           
        } else {
View Full Code Here

    final String catalogCategoryId = catalogCategoryForm.getId();
    final String parentCatalogCategoryId = catalogCategoryForm.getDefaultParentCategoryId();

    if(StringUtils.isNotEmpty(catalogCategoryId)){
      final String catalogCategoryCode = catalogCategoryForm.getCode();
      final CatalogCategoryMaster catalogCategory = catalogCategoryService.getMasterCatalogCategoryByCode(catalogCategoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));

         // SANITY CHECK
          if(catalogCategory == null){
              final String url = backofficeUrlService.generateUrl(BoUrls.MASTER_CATALOG, requestData);
              return new ModelAndView(new RedirectView(url));
          }
         
      // UPDATE CATEORY
      if (result.hasErrors()) {
        if(StringUtils.isNotEmpty(parentCatalogCategoryId)){
          // CHIELD CATEGORY
          final CatalogCategoryMaster parentCatalogCategory = catalogCategoryService.getMasterCatalogCategoryById(parentCatalogCategoryId, new FetchPlan(categoryMasterFetchPlans));
          initProductMasterCategoryModelAndView(request, modelAndView, parentCatalogCategory);
          return modelAndView;
         
        } else {
          // ROOT CATEGORY
          initProductMasterCategoryModelAndView(request, modelAndView, catalogCategory);
          return modelAndView;
        }
      }
     
      // UPDATE CATEGORY
      try {
//        CatalogCategoryMaster catalogCategoryMaster = new CatalogCategoryMaster();
        webBackofficeService.updateCatalogCategory(requestData, currentMarketArea, currentRetailer, currentLocalization, catalogCategory, catalogCategoryForm);
        addSuccessMessage(request, coreMessageSource.getMessage("business.catalog.category.edit.success.message", locale));
       
        final String urlRedirect = backofficeUrlService.generateUrl(BoUrls.MASTER_CATEGORY_DETAILS, requestData, catalogCategory);;
        return new ModelAndView(new RedirectView(urlRedirect));
       
      } catch (UniqueConstraintCodeCategoryException e) {
        addErrorMessage(request, coreMessageSource.getMessage("business.catalog.category.edit.error.message",  locale));
       
        if(StringUtils.isNotEmpty(parentCatalogCategoryId)){
          // CHIELD CATEGORY
          final CatalogCategoryMaster parentCatalogCategory = catalogCategoryService.getMasterCatalogCategoryById(parentCatalogCategoryId, new FetchPlan(categoryMasterFetchPlans));
          initProductMasterCategoryModelAndView(request, modelAndView, parentCatalogCategory);
          return modelAndView;
         
        } else {
          // ROOT CATEGORY
          initProductMasterCategoryModelAndView(request, modelAndView, catalogCategory);
          return modelAndView;
        }
       
      }

    } else {
        CatalogCategoryMaster parentCatalogCategory = null;
        if(StringUtils.isNotEmpty(parentCatalogCategoryId)){
              parentCatalogCategory = catalogCategoryService.getMasterCatalogCategoryById(parentCatalogCategoryId, new FetchPlan(categoryMasterFetchPlans));
        }

      // CREATE A NEW CATEORY
      if (result.hasErrors()) {
        if(StringUtils.isNotEmpty(parentCatalogCategoryId)){
          // CHIELD CATEGORY
          initProductMasterCategoryModelAndView(request, modelAndView, null);
          return modelAndView;
         
        } else {
          // ROOT CATEGORY
          initProductMasterCategoryModelAndView(request, modelAndView, null);
          return modelAndView;
        }
      }
     
      // SAVE CATEGORY
      try {
        CatalogCategoryMaster catalogCategoryMaster = new CatalogCategoryMaster();
        CatalogCategoryMaster savedCatalogCategory = webBackofficeService.createCatalogCategory(requestData, currentMarketArea, currentLocalization, parentCatalogCategory, catalogCategoryMaster, catalogCategoryForm);
        addSuccessMessage(request, coreMessageSource.getMessage("business.catalog.category.add.success.message", locale));
       
        final String urlRedirect = backofficeUrlService.generateUrl(BoUrls.MASTER_CATEGORY_DETAILS, requestData, savedCatalogCategory);
        return new ModelAndView(new RedirectView(urlRedirect));
       
View Full Code Here

    protected List<CatalogCategoryMaster> buildCategories(final RequestData requestData, final String catalogCategoryCode) throws Exception {
        final Localization currentLocalization = requestData.getMarketAreaLocalization();
        List<CatalogCategoryMaster> categories = catalogCategoryService.findAllMasterCatalogCategoriesByCatalogCode(requestData.getVirtualCatalogCode(), new FetchPlan(categoryMasterFetchPlans));
        if(StringUtils.isNotEmpty(catalogCategoryCode)){
            for (Iterator<CatalogCategoryMaster> iterator = categories.iterator(); iterator.hasNext();) {
                CatalogCategoryMaster CatalogCategoryMaster = (CatalogCategoryMaster) iterator.next();
                if(CatalogCategoryMaster.getCode().equalsIgnoreCase(catalogCategoryCode)){
                    iterator.remove();
                }
            }
        }
        Collections.sort(categories, new Comparator<CatalogCategoryMaster>() {
View Full Code Here

    @ModelAttribute(ModelConstants.CATALOG_CATEGORY_FORM)
    protected CatalogCategoryForm initCatalogCategoryForm(final HttpServletRequest request, final Model model) throws Exception {
        final RequestData requestData = requestUtil.getRequestData(request);
        final String catalogCategoryCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CATALOG_CATEGORY_CODE);
        if(StringUtils.isNotEmpty(catalogCategoryCode)){
            final CatalogCategoryMaster catalogCategory = catalogCategoryService.getMasterCatalogCategoryByCode(catalogCategoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));
            backofficeFormFactory.buildCatalogMasterCategoryForm(requestData, null, catalogCategory);
        }
        final String parentCatalogCategoryCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_PARENT_CATALOG_CATEGORY_CODE);
        if(StringUtils.isNotEmpty(parentCatalogCategoryCode)){
            final CatalogCategoryMaster parentCatalogCategory = catalogCategoryService.getMasterCatalogCategoryByCode(parentCatalogCategoryCode, requestData.getMasterCatalogCode(), new FetchPlan(categoryMasterFetchPlans));
            return backofficeFormFactory.buildCatalogMasterCategoryForm(requestData, parentCatalogCategory, null);
        }
        return backofficeFormFactory.buildCatalogMasterCategoryForm(requestData, null, null);
    }
View Full Code Here

TOP

Related Classes of org.hoteia.qalingo.core.domain.CatalogCategoryMaster

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.