Пример #1
0
 @Transactional(readOnly = true)
 public int deleteOther() {
   int deleteCount = 0;
   Template shopCommonJsTemplate = templateService.get("shopCommonJs");
   Template adminCommonJsTemplate = templateService.get("adminCommonJs");
   deleteCount += delete(shopCommonJsTemplate.getStaticPath());
   deleteCount += delete(adminCommonJsTemplate.getStaticPath());
   return deleteCount;
 }
Пример #2
0
  @Transactional(readOnly = true)
  public int build(Product product) {
    Assert.notNull(product);

    delete(product);
    Template template = templateService.get("productContent");
    int buildCount = 0;
    if (product.getIsMarketable()) {
      Map<String, Object> model = new HashMap<String, Object>();
      model.put("product", product);
      buildCount += build(template.getTemplatePath(), product.getPath(), model);
    }
    return buildCount;
  }
Пример #3
0
  @Transactional(readOnly = true)
  public int build(Article article) {
    Assert.notNull(article);

    delete(article);
    Template template = templateService.get("articleContent");
    int buildCount = 0;
    if (article.getIsPublication()) {
      Map<String, Object> model = new HashMap<String, Object>();
      model.put("article", article);
      for (int pageNumber = 1; pageNumber <= article.getTotalPages(); pageNumber++) {
        article.setPageNumber(pageNumber);
        buildCount += build(template.getTemplatePath(), article.getPath(), model);
      }
      article.setPageNumber(null);
    }
    return buildCount;
  }
Пример #4
0
 @Transactional(readOnly = true)
 public int buildOther() {
   int buildCount = 0;
   Template shopCommonJsTemplate = templateService.get("shopCommonJs");
   Template adminCommonJsTemplate = templateService.get("adminCommonJs");
   buildCount +=
       build(shopCommonJsTemplate.getTemplatePath(), shopCommonJsTemplate.getStaticPath());
   buildCount +=
       build(adminCommonJsTemplate.getTemplatePath(), adminCommonJsTemplate.getStaticPath());
   return buildCount;
 }
Пример #5
0
 @Transactional(readOnly = true)
 public int deleteIndex() {
   Template template = templateService.get("index");
   return delete(template.getStaticPath());
 }
Пример #6
0
 @Transactional(readOnly = true)
 public int buildSitemap() {
   int buildCount = 0;
   Template sitemapIndexTemplate = templateService.get("sitemapIndex");
   Template sitemapTemplate = templateService.get("sitemap");
   Map<String, Object> model = new HashMap<String, Object>();
   List<String> staticPaths = new ArrayList<String>();
   for (int step = 0, index = 0, first = 0, count = SITEMAP_MAX_SIZE; ; ) {
     try {
       model.put("index", index);
       String templatePath = sitemapTemplate.getTemplatePath();
       String staticPath = FreemarkerUtils.process(sitemapTemplate.getStaticPath(), model);
       if (step == 0) {
         List<Article> articles = articleDao.findList(first, count, null, null);
         model.put("articles", articles);
         if (articles.size() < count) {
           step++;
           first = 0;
           count -= articles.size();
         } else {
           buildCount += build(templatePath, staticPath, model);
           articleDao.clear();
           articleDao.flush();
           staticPaths.add(staticPath);
           model.clear();
           index++;
           first += articles.size();
           count = SITEMAP_MAX_SIZE;
         }
       } else if (step == 1) {
         List<Product> products = productDao.findList(first, count, null, null);
         model.put("products", products);
         if (products.size() < count) {
           step++;
           first = 0;
           count -= products.size();
         } else {
           buildCount += build(templatePath, staticPath, model);
           productDao.clear();
           productDao.flush();
           staticPaths.add(staticPath);
           model.clear();
           index++;
           first += products.size();
           count = SITEMAP_MAX_SIZE;
         }
       } else if (step == 2) {
         List<Brand> brands = brandDao.findList(first, count, null, null);
         model.put("brands", brands);
         if (brands.size() < count) {
           step++;
           first = 0;
           count -= brands.size();
         } else {
           buildCount += build(templatePath, staticPath, model);
           brandDao.clear();
           brandDao.flush();
           staticPaths.add(staticPath);
           model.clear();
           index++;
           first += brands.size();
           count = SITEMAP_MAX_SIZE;
         }
       } else if (step == 3) {
         List<Promotion> promotions = promotionDao.findList(first, count, null, null);
         model.put("promotions", promotions);
         buildCount += build(templatePath, staticPath, model);
         promotionDao.clear();
         promotionDao.flush();
         staticPaths.add(staticPath);
         if (promotions.size() < count) {
           model.put("staticPaths", staticPaths);
           buildCount +=
               build(
                   sitemapIndexTemplate.getTemplatePath(),
                   sitemapIndexTemplate.getStaticPath(),
                   model);
           break;
         } else {
           model.clear();
           index++;
           first += promotions.size();
           count = SITEMAP_MAX_SIZE;
         }
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return buildCount;
 }
Пример #7
0
 @Transactional(readOnly = true)
 public int buildIndex() {
   Template template = templateService.get("index");
   return build(template.getTemplatePath(), template.getStaticPath());
 }