@Override
 public void saveBean(SystemUser currentUser) {
   setVersion(getVersion() + 1);
   super.saveBean(currentUser);
   if (this.isActive()) {
     writeViewToFile();
   }
 }
Пример #2
0
  @Override
  public void saveBean(SystemUser currentUser) {
    //  get the template from the database (will have the old values)
    if (!isNew()) {
      TopLevelTemplate dbTemplate = new BeanDao(TopLevelTemplate.class).get(getId());
      //  if !new or changed from db template
      if (dbTemplate == null || hasTemplateChanged(dbTemplate)) {
        //  if different load all of the pages and run the script to add the corresponding CPH
        // sections
        BeanDao cmsPageRevisionDao = new BeanDao(CmsPageRevision.class);
        cmsPageRevisionDao.addWhereCriteria(
            "bean.cmsTemplate.class = 'TOP_LEVEL_TEMPLATE' AND bean.cmsTemplate.id="
                + this.getId());
        List<CmsPageRevision> pageList = cmsPageRevisionDao.getAll();
        for (CmsPageRevision page : pageList) {
          page.setTemplate(this, true, true);
          page.saveDetails();
        }

        BeanDao innerTemplateDao = new BeanDao(InnerTemplate.class);
        innerTemplateDao.addWhereCriteria("bean.cmsTemplate.id=" + this.getId());
        List<InnerTemplate> innerTemplateList = innerTemplateDao.getAll();
        boolean hasCprCphModulesChanged = hasCprCphModulesChanged(dbTemplate);
        //  Need to load it out of the session each time or hibernate throws
        //  a Transient Object wobbly.
        for (InnerTemplate innerTemplate : innerTemplateList) {
          InnerTemplate loadedInnerTemplate =
              (InnerTemplate) new BeanDao(InnerTemplate.class).get(innerTemplate.getId());
          loadedInnerTemplate.setTemplate(this, false, true);
          if (hasCprCphModulesChanged) {
            loadedInnerTemplate.updateCmsPageRevisionChildren();
          }
          loadedInnerTemplate.saveDetails();
          //				HibernateUtil.startNewTransaction();
          //				session = HibernateUtil.getCurrentSession();
        }
      }
    }
    for (CmsAtomPassThrough cmsAtomPassThrough : cmsAtomPassThroughList) {
      cmsAtomPassThrough.saveDetails(currentUser);
    }
    super.saveBean(currentUser);

    if (this.isActive()) {
      writeViewToFile();
    }
  }