Package it.eng.spagobi.wapp.bo

Examples of it.eng.spagobi.wapp.bo.Menu


    // Calculate which are the leaves at the 3rd level
    //List limitLeaves=fillDepths(objectsList);

    Iterator it = objectsList.iterator();
    while (it.hasNext()) {
      Menu menu= (Menu) it.next();
      /* ********* start luca changes *************** */
      RequestContainer reqCont = ChannelUtilities.getRequestContainer(httpRequest);
      SessionContainer sessionContainer = reqCont.getSessionContainer();
      SessionContainer permanentSession = sessionContainer.getPermanentContainer();
      IEngUserProfile profile = (IEngUserProfile)permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
      /* ********* end luca changes ***************** */
      if (initialPath != null) {
        if (initialPath.equalsIgnoreCase(menu.getName())) addItemForJSTree(htmlStream, menu, true);
        else addItemForJSTree(htmlStream, menu, false);
      } else {
        if (menu.getParentId() == null || menu.getParentId().intValue()==0) addItemForJSTree(htmlStream, menu, true);
        else addItemForJSTree(htmlStream, menu, false);
      }
    }
    //htmlStream.append("        document.write(treeFunct);\n");
    htmlStream.append("        document.getElementById('treeFoldersTd" + requestIdentity + "').innerHTML = treeFunct;\n");
View Full Code Here


  private boolean canCreateMaster(Menu menu) {
    boolean canCreateMaster = false;
    Role[] currentRoles;
    Integer parentId;
    Menu parentMenu;
    Role[] parentRoles;
   
    logger.debug("IN");
   
    try {
     
      Assert.assertNotNull(menu, "Input parameter [menu] cannot be null");
      logger.debug("Menu id is equal to [" + menu.getMenuId()+ "]");
      logger.debug("Menu name is equal to [" + menu.getName()+ "]");
      logger.debug("Menu descr is equal to [" + menu.getDescr()+ "]");
     
      parentId = menu.getParentId();
      logger.debug("Parent menu id is equal to [" + menu.getMenuId()+ "]");
      if( parentId == null || parentId.intValue() == 0) {
        canCreateMaster = false;
      } else{
       
        parentMenu = null;
        try {
          parentMenu = DAOFactory.getMenuDAO().loadMenuByID(parentId);
        } catch (Throwable t) {
          logger.error("Impossible to load menu with id equal to [" + parentId + "] from database", t);
          return false;
        }
       
        parentRoles = parentMenu.getRoles();
        logger.debug("Parent menu have [" + parentRoles.length + "] role(s)");
        currentRoles = menu.getRoles();
        logger.debug("Menu have [" + currentRoles.length + "] role(s)");
 
        boolean equals=true;
View Full Code Here

  private boolean canBeMovedDown(Menu menu) {
    Integer parentId = (menu.getParentId()==null)?new Integer("0"):menu.getParentId();
    Integer currentProg = menu.getProg();
    Iterator it = _objectsList.iterator();
    while (it.hasNext()) {
      Menu aMenu = (Menu) it.next();
      Integer parentMenuId = (aMenu.getParentId()==null)?new Integer("0"):aMenu.getParentId();
      if (parentId != null && parentId.equals(parentMenuId) && currentProg.intValue() < aMenu.getProg().intValue())
        return true;
    }
    return false;
  }
View Full Code Here

    ServletOutputStream out = httpResp.getOutputStream();

    String menuId=(String)serviceRequest.getAttribute("MENU_ID");
    logger.debug("menuId="+menuId);
    if(menuId!=null){
      Menu menu=DAOFactory.getMenuDAO().loadMenuByID(Integer.valueOf(menuId));
      String fileName=menu.getStaticPage();
     
      if (fileName==null) {
        logger.error("Menu with id = " + menu.getMenuId() + " has no file name specified");
        throw new Exception("Menu has no file name specified");
      }

      // check the validity of the fileName (it must not be a path)
      // TODO remove this control and write better this action, or remove the action at all
      if (fileName.contains("\\") || fileName.contains("/") || fileName.contains("..")) {
        logger.error("Menu with id = " + menu.getMenuId() + " has file name [" + fileName + "] containing file separator character!!!");
        throw new Exception("Menu file name cannot contain file separator character");
      }
     
      logger.debug("fileName="+fileName);
     
View Full Code Here

  private boolean containsMenu(List lst, Menu menu){
    if (lst == null)
      return false;
   
    for (int i=0; i<lst.size(); i++){
      Menu tmpMenu = (Menu)lst.get(i);
      if (tmpMenu.getMenuId().intValue() == menu.getMenuId().intValue())
        return true
    }
    return false;
  }
View Full Code Here

    logger.debug("IN");
    try {
      String menuId = (String) request.getAttribute("MENU_ID");
      if (menuId!=null) {
     
        Menu menu=DAOFactory.getMenuDAO().loadMenuByID(Integer.valueOf(menuId));
        String parameters = menu.getObjParameters();
        logger.debug("using parameters " + parameters);
        String labelSubObject = menu.getSubObjName();
        logger.debug("using subobject " + labelSubObject);
        String snapName = menu.getSnapshotName();
        logger.debug("using snapshot name " + snapName);
        Integer snapHistory = menu.getSnapshotHistory();
        logger.debug("using snapshot history " + snapHistory);
            boolean displayToolbar = !menu.getHideToolbar();
            boolean displaySliders = !menu.getHideSliders();
            // set into request all information for invoking ExecuteBIObjectModule.pageCreationHandler on loop call
        response.setAttribute(ObjectsTreeConstants.OBJECT_ID, menu.getObjId().toString());
        response.setAttribute(SpagoBIConstants.TOOLBAR_VISIBLE, new Boolean(displayToolbar).toString());
        response.setAttribute(SpagoBIConstants.SLIDERS_VISIBLE, new Boolean(displaySliders).toString());
            if (parameters!= null && !parameters.trim().equalsIgnoreCase("")) {
              response.setAttribute(ObjectsTreeConstants.PARAMETERS, parameters);
            }
View Full Code Here

      List filteredMenuList = (List) o;
      if(filteredMenuList!=null && !filteredMenuList.isEmpty()){
      result = new JSONObject();
      JSONArray tempFirstLevelMenuList = new JSONArray();
        for (int i=0; i<filteredMenuList.size(); i++){
          Menu menuElem = (Menu)filteredMenuList.get(i);
          String path=MenuUtilities.getMenuPath(menuElem);
          if (menuElem.getLevel().intValue() == 1){
            JSONObject temp = new JSONObject();
            temp.put(NAME, "menu"+i);
            temp.put(ID, menuElem.getMenuId());
            MessageBuilder msgBuild=new MessageBuilder();
            String text = "";
            if (!menuElem.isAdminsMenu() || !menuElem.getName().startsWith("#"))
              text = msgBuild.getUserMessage(menuElem.getName(),null, locale);
            else{             
              if (menuElem.getName().startsWith("#")){       
                String titleCode = menuElem.getName().substring(1);                 
                text = msgBuild.getMessage(titleCode, locale);               
              } else {
                text = menuElem.getName();
              }
            }
            temp.put(TEXT, text);
            temp.put(PATH, path);
            String icon=DetailMenuModule.assignImage(menuElem);
                if(menuElem.isViewIcons() && !icon.equalsIgnoreCase("")){                  
                   temp.put(ICON, contextName+defaultThemePath+icon);
                }
           
            if(menuElem.getObjId()!=null){
              temp.put(HREF, "execDirectUrl('"+contextName+"/servlet/AdapterHTTP?ACTION_NAME=MENU_BEFORE_EXEC&MENU_ID="+menuElem.getMenuId()+"', '"+path+"' )");
            }else if(menuElem.getStaticPage()!=null){
              temp.put(HREF, "execDirectUrl('"+contextName+"/servlet/AdapterHTTP?ACTION_NAME=READ_HTML_FILE&MENU_ID="+menuElem.getMenuId()+"', '"+path+"' )");
            }else if(menuElem.getFunctionality()!=null){
              temp.put(HREF, "execDirectUrl('"+DetailMenuModule.findFunctionalityUrl(menuElem, contextName)+"', '"+path+"')");
            }else if(menuElem.getExternalApplicationUrl()!=null){
              temp.put(HREF, "callExternalApp('"+StringEscapeUtils.escapeJavaScript(menuElem.getExternalApplicationUrl())+"', '"+path+"')");
            }else if (menuElem.isAdminsMenu() && menuElem.getUrl()!=null){             
              String url = "javascript:execDirectUrl('"+ menuElem.getUrl()+"'";
              url = url.replace("${SPAGOBI_CONTEXT}",contextName);
              url = url.replace("${SPAGO_ADAPTER_HTTP}", GeneralUtilities.getSpagoAdapterHttpUrl());   
              path = path.replace("#","");
              temp.put(HREF, url+", '"+path+"')");
            }
                     
            if (menuElem.getHasChildren()){   
             
              List lstChildrenLev2 = menuElem.getLstChildren();
              JSONArray tempMenuList =(JSONArray)getChildren(lstChildrenLev2, 1,locale);
              temp.put(ITEMS, tempMenuList);
            }
            tempFirstLevelMenuList.put(temp);
          }
View Full Code Here

  }

  private Object getChildren(List children, int level, Locale locale) throws JSONException{
    JSONArray tempMenuList = new JSONArray();
    for (int j=0; j<children.size(); j++){
      Menu childElem = (Menu)children.get(j)
      JSONObject  temp2 = new JSONObject();

      temp2.put(ID, new Double(Math.random()).toString());
      MessageBuilder msgBuild=new MessageBuilder();
      String text = "";
      if (!childElem.isAdminsMenu() || !childElem.getName().startsWith("#"))
        text = msgBuild.getUserMessage(childElem.getName(),null, locale);
      else{             
        if (childElem.getName().startsWith("#")){       
          String titleCode = childElem.getName().substring(1);                 
          text = msgBuild.getMessage(titleCode, locale);               
        } else {
          text = childElem.getName();
        }
      }
      //String text = msgBuild.getUserMessage(childElem.getName(),null, locale);
      temp2.put(TEXT, text);
      String path=MenuUtilities.getMenuPath(childElem);
      temp2.put(PATH, path);
      String icon=DetailMenuModule.assignImage(childElem);
          if(childElem.isViewIcons() && !icon.equalsIgnoreCase("")){
             temp2.put(ICON, contextName+defaultThemePath+icon);
          }
      if(childElem.getObjId()!=null){
        temp2.put(HREF, "javascript:execDirectUrl('"+contextName+"/servlet/AdapterHTTP?ACTION_NAME=MENU_BEFORE_EXEC&MENU_ID="+childElem.getMenuId()+"', '"+path+"' )");
      }else if(childElem.getStaticPage()!=null){
        temp2.put(HREF, "javascript:execDirectUrl('"+contextName+"/servlet/AdapterHTTP?ACTION_NAME=READ_HTML_FILE&MENU_ID="+childElem.getMenuId()+"', '"+path+"' )");
      }else if(childElem.getFunctionality()!=null){
        temp2.put(HREF, "javascript:execDirectUrl('"+DetailMenuModule.findFunctionalityUrl(childElem, contextName)+"', '"+path+"')");
      }else if(childElem.getExternalApplicationUrl()!=null){
        temp2.put(HREF, "javascript:callExternalApp('"+StringEscapeUtils.escapeJavaScript(childElem.getExternalApplicationUrl())+"', '"+path+"')");
      }else if(childElem.isAdminsMenu() && childElem.getUrl()!=null){       
        String url = "javascript:execDirectUrl('"+ childElem.getUrl()+"'";
        url = url.replace("${SPAGOBI_CONTEXT}",contextName);
        url = url.replace("${SPAGO_ADAPTER_HTTP}", GeneralUtilities.getSpagoAdapterHttpUrl());   
        path = path.replace("#","");
        temp2.put(HREF, url+", '"+path+"')");
      }
      if (childElem.getHasChildren()){
        level ++;
        List childrenBis = childElem.getLstChildren();
        JSONArray tempMenuList2 =(JSONArray)getChildren(childrenBis,level, locale);
        temp2.put(ITEMS, tempMenuList2);
      }
      tempMenuList.put(temp2);
    
View Full Code Here

      String menuId = (String) request.getAttribute(MENU_ID);

      //String parentId = (String) request.getAttribute(PARENT_ID);
      response.setAttribute(AdmintoolsConstants.MODALITY, modality);

      Menu menu = DAOFactory.getMenuDAO().loadMenuByID(Integer.valueOf(menuId));
      response.setAttribute(MENU, menu);
      Integer parentIdInt=menu.getParentId();

      if(parentIdInt!=null){

        String parentId=parentIdInt.toString();
View Full Code Here

    SessionContainer sessCont = reqCont.getSessionContainer();
    SessionContainer permSess = sessCont.getPermanentContainer();
    IEngUserProfile profile = (IEngUserProfile)permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);

   
    Menu menu = recoverMenuDetails(request, mod);
    response.setAttribute(MENU, menu);
    response.setAttribute(AdmintoolsConstants.MODALITY, mod);
    IMenuDAO menuDao=DAOFactory.getMenuDAO();
    menuDao.setUserProfile(profile);
    // if there are some validation errors into the errorHandler does not write into DB
    Collection errors = errorHandler.getErrors();
    if (errors != null && errors.size() > 0) {
      Iterator iterator = errors.iterator();
      while (iterator.hasNext()) {
        Object error = iterator.next();
        if (error instanceof EMFValidationError) {
          Integer parentMenuId = menu.getParentId();
          Menu parentMenu = null;
          if (parentMenuId != null) {
            parentMenu = menuDao.loadMenuByID(parentMenuId);
          }
          if (parentMenu== null) {
            throw new EMFUserError(EMFErrorSeverity.ERROR, "10001", messageBundle);
          } else {
            response.setAttribute(PARENT_ID, parentMenu.getMenuId());
          }
          return;
        }
      }
    }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.wapp.bo.Menu

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.