コード例 #1
0
  protected Map getSecObjMap(List moduleDateBeans) {
    if ((moduleDateBeans == null) || (moduleDateBeans.size() == 0)) return null;
    Map secobjMap = new LinkedHashMap<Integer, SecModObj>();

    for (Iterator itr = moduleDateBeans.listIterator(); itr.hasNext(); ) {
      ModuleDateBean mdbean = (ModuleDateBean) itr.next();
      List sectionBeans = mdbean.getSectionBeans();
      if ((sectionBeans != null) && (sectionBeans.size() > 0)) {
        int moduleId = mdbean.getModuleId();
        for (Iterator sItr = sectionBeans.listIterator(); sItr.hasNext(); ) {
          SectionBean secbean = (SectionBean) sItr.next();
          secobjMap.put(
              secbean.getSection().getSectionId(), new SecModObj(moduleId, secbean, mdbean));
        }
      }
    }
    return secobjMap;
  }
コード例 #2
0
  /**
   * Indent this section by first checking if indentation is less than 10 levels
   *
   * @return list_auth_modules
   */
  public String CreateSubSectionAction() {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ResourceLoader bundle = new ResourceLoader("org.etudes.tool.melete.bundle.Messages");
    if (!saveModuleDates()) return "list_auth_modules";
    if ((moduleDateBeans == null) || (moduleDateBeans.size() == 0)) return "list_auth_modules";

    // if module is selected then throw message
    if (moduleSelected) {
      String msg = bundle.getString("list_select_indent");
      addMessage(ctx, "Select  Indent", msg, FacesMessage.SEVERITY_ERROR);
      resetSubSectionValues();
      return "list_auth_modules";
    }

    if ((moduleSelected == false) && (sectionSelected == false)) {
      String msg = bundle.getString("list_select_one_indent");
      addMessage(ctx, "Select Indent", msg, FacesMessage.SEVERITY_ERROR);
      resetSubSectionValues();
      return "list_auth_modules";
    }
    if (sectionSelected == true) {
      if ((secObjMap == null) || (secObjMap.size() == 0)) {
        resetSubSectionValues();
        return "list_auth_modules";
      }
      SecModObj smObj = null;
      ModuleDateBean mdbean = null;
      SectionBeanService secBean = null;
      List indentSecBeans = null;
      if (indentSecBeans == null) {
        indentSecBeans = new ArrayList();
      }

      if (selectedSecIds == null) {
        resetSubSectionValues();
        return "list_auth_modules";
      }
      // If one section is selected, we check if its the first section
      // or if it is too deep to indent
      // If multiple sections are selected, we indent those that we can
      // and leave the others alone
      if (selectedSecIds.size() == 1) {
        smObj = (SecModObj) secObjMap.get(selectedSecIds.get(0));
        if ((smObj != null) && (smObj.getMdBean() != null) && (smObj.getSecBean() != null)) {
          mdbean = smObj.getMdBean();
          if (mdbean.getSectionBeans().size() < 2) {
            logger.debug("First section can't be change to subsection");
            resetSubSectionValues();
            return "list_auth_modules";
          } else {
            secBean = smObj.getSecBean();

            boolean indentOk = findIndent(secBean, mdbean.getSectionBeans());
            // Only allow indent upto 10 levels
            if (indentOk) {
              try {
                indentSecBeans.add(secBean);
                moduleService.createSubSection(mdbean.getModule(), indentSecBeans);
              } catch (MeleteException me) {
                logger.debug(me.toString());
                String msg = bundle.getString("indent_right_fail");
                addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
              }
            } else {
              String msg = bundle.getString("indent_right_toodeep");
              addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
            }
          }
        } else {
          resetSubSectionValues();
          return "list_auth_modules";
        }
      } else {
        // Multiple indent code
        boolean res = checkDifModules(selectedSecIds);
        if (res == true) {
          String msg = bundle.getString("list_select_in_onemodule");
          addMessage(ctx, "Select Indent", msg, FacesMessage.SEVERITY_ERROR);
          resetSubSectionValues();
          return "list_auth_modules";
        } else {
          mdbean = null;
          secBean = null;

          for (ListIterator i = selectedSecIds.listIterator(); i.hasNext(); ) {
            Integer sectionId = (Integer) i.next();
            smObj = (SecModObj) secObjMap.get(sectionId);
            if ((smObj != null) && (smObj.getMdBean() != null) && (smObj.getSecBean() != null)) {
              mdbean = smObj.getMdBean();
              secBean = smObj.getSecBean();
              boolean indentOk = findIndent(secBean, mdbean.getSectionBeans());
              if (indentOk) {
                indentSecBeans.add(secBean);
              }
            }
          }
          try {
            moduleService.createSubSection(mdbean.getModule(), indentSecBeans);
          } catch (MeleteException me) {
            logger.debug(me.toString());
            String msg = bundle.getString("indent_right_fail");
            addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
          }
        }
      }
    }
    resetSubSectionValues();
    int saveShowId = showModuleId;
    resetValues();
    setShowModuleId(saveShowId);
    return "list_auth_modules";
  }