Search in sources :

Example 1 with TbSysProg

use of com.netsteadfast.greenstep.po.hbm.TbSysProg in project bamboobsc by billchen198318.

the class MenuSupportUtils method getProgramMultiName.

public static String getProgramMultiName(SysMenuVO menu, String localeCode) throws ServiceException, Exception {
    TbSysProg sysProg = new TbSysProg();
    sysProg.setProgId(menu.getProgId());
    sysProg.setName(menu.getName());
    return getProgramMultiName(sysProg, localeCode);
}
Also used : TbSysProg(com.netsteadfast.greenstep.po.hbm.TbSysProg)

Example 2 with TbSysProg

use of com.netsteadfast.greenstep.po.hbm.TbSysProg in project bamboobsc by billchen198318.

the class MenuSupportUtils method getMenuData.

/**
	 * 取回下拉選單
	 * 
	 * @param basePath
	 * @param sys
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
public static Map<String, String> getMenuData(String basePath, TbSys sys, String jsessionId, String localeCode) throws ServiceException, Exception {
    Map<String, String> menuData = new HashMap<String, String>();
    List<SysMenuVO> menuList = loadSysMenuData(sys.getSysId());
    if (menuList == null || menuList.size() < 1) {
        return menuData;
    }
    StringBuilder htmlSb = new StringBuilder();
    StringBuilder jsSb = new StringBuilder();
    StringBuilder dlgSb = new StringBuilder();
    Map<String, String> jsFunctionMap = new HashMap<String, String>();
    /*
		for (SysMenuVO sysMenu : menuList) { // create combobox menu javascript
			if (!YesNo.YES.equals(sysMenu.getEnableFlag())) {
				continue;
			}
			if (TYPE_IS_FOLDER.equals(sysMenu.getItemType())) { // 目錄不須要 
				continue;
			}
			String openTabFn = sysMenu.getProgId() + "_TabShow()";
			String refreshTabFn = sysMenu.getProgId() + "_TabRefresh()";
			String closeTabFn = sysMenu.getProgId() + "_TabClose()";
			String tabId = sysMenu.getProgId() + "_ChildTab";	
			jsSb.append("function ").append( openTabFn ).append(" { ");
			jsSb.append("	viewPage.addOrUpdateContentPane(	");
			jsSb.append("		'").append(Constants.MAIN_TabContainer_ID).append("',	");
			jsSb.append("		'").append(tabId).append("',	");
			jsSb.append("		'").append( StringEscapeUtils.escapeEcmaScript(IconUtils.getMenuIcon(basePath, sysMenu.getIcon()) ) ).append(StringEscapeUtils.escapeEcmaScript(sysMenu.getName())).append("',	");
			jsSb.append("		'").append( getUrl(basePath, sys, sysMenu, jsessionId) ).append("',	");			
			jsSb.append("		true,	");
			jsSb.append("		true");
			jsSb.append("	);	");
			jsSb.append("}	");
			jsSb.append("\n");
			jsSb.append("function ").append( refreshTabFn ).append(" { ");
			jsSb.append("	viewPage.refreshContentPane('").append(tabId).append("'); ");
			jsSb.append("}	");
			jsSb.append("\n");
			jsSb.append("function ").append( closeTabFn ).append(" { ");
			jsSb.append("	viewPage.closeContentPane('").append(Constants.MAIN_TabContainer_ID).append("', '").append(tabId).append("'); ");
			jsSb.append("}	");
			jsSb.append("\n");			
			jsFunctionMap.put(sysMenu.getProgId(), openTabFn );
		}
		*/
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("progSystem", sys.getSysId());
    List<TbSysProg> sysProgList = sysProgService.findListByParams(params);
    for (int i = 0; sysProgList != null && i < sysProgList.size(); i++) {
        TbSysProg sysProg = sysProgList.get(i);
        if (MenuItemType.FOLDER.equals(sysProg.getItemType())) {
            // 目錄不須要 
            continue;
        }
        String openTabFn = sysProg.getProgId() + "_TabShow()";
        if (YesNo.YES.equals(sysProg.getEditMode())) {
            openTabFn = sysProg.getProgId() + "_TabShow(oid)";
        }
        String refreshTabFn = sysProg.getProgId() + "_TabRefresh()";
        String closeTabFn = sysProg.getProgId() + "_TabClose()";
        String tabId = sysProg.getProgId() + "_ChildTab";
        boolean iframeMode = false;
        if (YesNo.YES.equals(sysProg.getIsWindow())) {
            iframeMode = true;
        }
        String progMultiName = getProgramMultiName(sysProg, localeCode);
        jsSb.append("function ").append(openTabFn).append(" { ");
        jsSb.append("	viewPage.addOrUpdateContentPane(	");
        jsSb.append("		'").append(Constants.MAIN_TabContainer_ID).append("',	");
        jsSb.append("		'").append(tabId).append("',	");
        //jsSb.append("		'").append( StringEscapeUtils.escapeEcmaScript(IconUtils.getMenuIcon(basePath, sysProg.getIcon()) ) ).append(StringEscapeUtils.escapeEcmaScript(sysProg.getName())).append("',	");
        // 改用讀取多語系名稱
        jsSb.append("		'").append(StringEscapeUtils.escapeEcmaScript(IconUtils.getMenuIcon(basePath, sysProg.getIcon()))).append(StringEscapeUtils.escapeEcmaScript(progMultiName)).append("',	");
        if (YesNo.YES.equals(sysProg.getEditMode())) {
            // 編輯資料Edit 模式
            jsSb.append("		'").append(getUrl(basePath, sys, sysProg, jsessionId)).append("&fields.oid=' + oid,	");
        } else {
            // 查詢Query 或 新增Create 模式
            jsSb.append("		'").append(getUrl(basePath, sys, sysProg, jsessionId)).append("',	");
        }
        jsSb.append("		true,	");
        jsSb.append("		true,	");
        jsSb.append("	").append(String.valueOf(iframeMode)).append("	");
        jsSb.append("	);	");
        jsSb.append("}	");
        jsSb.append("\n");
        jsSb.append("function ").append(refreshTabFn).append(" { ");
        jsSb.append("	viewPage.refreshContentPane('").append(tabId).append("'); ");
        jsSb.append("}	");
        jsSb.append("\n");
        jsSb.append("function ").append(closeTabFn).append(" { ");
        jsSb.append("	viewPage.closeContentPane('").append(Constants.MAIN_TabContainer_ID).append("', '").append(tabId).append("'); ");
        jsSb.append("}	");
        jsSb.append("\n");
        //jsSb.append(Constants.GS_GET_APPLICATION_NAME_SCRIPT_OBJ).append("['").append( sysProg.getProgId() ).append("'] = '").append( StringEscapeUtils.escapeEcmaScript( sysProg.getName() ) ).append("';");
        // 改用讀取多語系名稱
        jsSb.append(Constants.GS_GET_APPLICATION_NAME_SCRIPT_OBJ).append("['").append(sysProg.getProgId()).append("'] = '").append(StringEscapeUtils.escapeEcmaScript(progMultiName)).append("';");
        jsSb.append("\n");
        jsFunctionMap.put(sysProg.getProgId(), openTabFn);
        String dlgId = "";
        if (YesNo.YES.equals(sysProg.getIsDialog())) {
            dlgId = sysProg.getProgId() + "_Dlg";
        }
        if (!StringUtils.isBlank(dlgId)) {
            // 有 dialog 
            dlgSb.append("<div id=\"" + dlgId + "\" data-dojo-type=\"dojox.widget.DialogSimple\" ").append("data-dojo-props='href:\"").append(getUrl(basePath, sys, sysProg, jsessionId)).append("\",").append("	style:\"width: ").append(sysProg.getDialogW()).append("px; height: ").append(sysProg.getDialogH()).append("px\",").append("	title:\"").append(IconUtils.getMenuIcon(basePath, sysProg.getIcon()).replaceAll("'", "\\\\\"")).append(StringEscapeUtils.escapeEcmaScript(progMultiName)).append(// 改用讀取多語系名稱
            "\",").append("	refreshOnShow:\"true\", executeScripts:\"true\" ").append(" '></div>").append("\n");
            String dlgOpenFn = sysProg.getProgId() + "_DlgShow()";
            String dlgHideFn = sysProg.getProgId() + "_DlgHide()";
            if (YesNo.YES.equals(sysProg.getEditMode())) {
                dlgOpenFn = sysProg.getProgId() + "_DlgShow(oid)";
            }
            jsSb.append("function ").append(dlgOpenFn).append(" { ");
            String dlgUrl = "";
            if (YesNo.YES.equals(sysProg.getEditMode())) {
                // 編輯資料Edit 模式					
                dlgUrl = "'" + getUrl(basePath, sys, sysProg, jsessionId) + "&fields.oid=' + oid; ";
                jsSb.append("	var dlgUrl=").append(dlgUrl);
                jsSb.append("	dijit.byId('").append(dlgId).append("').set('href', dlgUrl); ");
            }
            jsSb.append("	dijit.byId('").append(dlgId).append("').show();	");
            jsSb.append("}	");
            jsSb.append("\n");
            jsSb.append("function ").append(dlgHideFn).append(" { ");
            jsSb.append("	dijit.byId('").append(dlgId).append("').hide();	");
            jsSb.append("}	");
            jsSb.append("\n");
        }
    }
    // create combobox menu html
    htmlSb.append("<div data-dojo-type='dijit.PopupMenuItem' >");
    //htmlSb.append("	<span>").append( IconUtils.getMenuIcon(basePath, sys.getIcon()) ).append(sys.getName()).append("</span>");		
    // 改用找多語言設定
    htmlSb.append("	<span>").append(IconUtils.getMenuIcon(basePath, sys.getIcon())).append(getSystemMultiName(sys, localeCode)).append("</span>");
    List<SysMenuVO> parentSysMenuList = searchFolder(menuList);
    htmlSb.append("<div dojoType='dijit.Menu' >");
    for (SysMenuVO sysMenu : parentSysMenuList) {
        List<SysMenuVO> itemSysMenuList = searchItem(sysMenu.getOid(), menuList);
        if (itemSysMenuList == null || itemSysMenuList.size() < 1) {
            continue;
        }
        String multiProgName = getProgramMultiName(sysMenu, localeCode);
        htmlSb.append("<div data-dojo-type='dijit.PopupMenuItem' >");
        //htmlSb.append("<span>").append( IconUtils.getMenuIcon(basePath, sysMenu.getIcon()) ).append(sysMenu.getName()).append("</span>");
        // 改用找多語言設定
        htmlSb.append("<span>").append(IconUtils.getMenuIcon(basePath, sysMenu.getIcon())).append(multiProgName).append("</span>");
        htmlSb.append("<div data-dojo-type='dijit.Menu' >");
        for (SysMenuVO itemMenu : itemSysMenuList) {
            String itemMultiProgName = getProgramMultiName(itemMenu, localeCode);
            htmlSb.append("<div data-dojo-type='dijit.MenuItem' data-dojo-props='onClick:function(){ ").append(StringUtils.defaultString(jsFunctionMap.get(itemMenu.getProgId()))).append(" }'>").append(IconUtils.getMenuIcon(basePath, itemMenu.getIcon())).append(// 改用找多語言設定
            itemMultiProgName).append("</div>");
        }
        htmlSb.append("</div>");
        htmlSb.append("</div>");
    }
    htmlSb.append("</div>");
    htmlSb.append("</div>");
    menuData.put(MENU_ITEM_JAVASCRIPT, jsSb.toString());
    menuData.put(MENU_ITEM_HTML, htmlSb.toString());
    menuData.put(MENU_ITEM_DIALOG, dlgSb.toString());
    return menuData;
}
Also used : HashMap(java.util.HashMap) SysMenuVO(com.netsteadfast.greenstep.vo.SysMenuVO) TbSysProg(com.netsteadfast.greenstep.po.hbm.TbSysProg)

Example 3 with TbSysProg

use of com.netsteadfast.greenstep.po.hbm.TbSysProg in project bamboobsc by billchen198318.

the class MenuSupportUtils method getProgramName.

public static String getProgramName(String progId, String localeCode) {
    if (StringUtils.isBlank(progId)) {
        return "unknown-program";
    }
    String defaultName = "unknown-program";
    String multiName = "unknown-program";
    defaultName = getProgramName(progId);
    if (LocaleLanguageUtils.getMap().get(localeCode) == null) {
        return defaultName;
    }
    TbSysProg sysProg = new TbSysProg();
    sysProg.setName(defaultName);
    sysProg.setProgId(progId);
    try {
        multiName = getProgramMultiName(sysProg, localeCode);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (!StringUtils.isBlank(multiName)) {
        return multiName;
    }
    return defaultName;
}
Also used : TbSysProg(com.netsteadfast.greenstep.po.hbm.TbSysProg) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 4 with TbSysProg

use of com.netsteadfast.greenstep.po.hbm.TbSysProg in project bamboobsc by billchen198318.

the class ReportRoleViewManagementAction method initData.

private void initData() throws ServiceException, Exception {
    String progId = super.getActionMethodProgramId();
    TbSysProg prog = new TbSysProg();
    prog.setProgId(progId);
    prog = this.sysProgService.findByEntityUK(prog);
    if (prog == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
    }
    TbSys sys = new TbSys();
    sys.setSysId(prog.getProgSystem());
    sys = this.sysService.findByEntityUK(sys);
    if (sys == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
    }
    this.defaultUrl = MenuSupportUtils.getUrl(super.getBasePath(), sys, prog, super.getHttpServletRequest().getSession().getId());
    this.roleMap = this.roleService.findForMap(true, true);
}
Also used : TbSys(com.netsteadfast.greenstep.po.hbm.TbSys) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) TbSysProg(com.netsteadfast.greenstep.po.hbm.TbSysProg)

Example 5 with TbSysProg

use of com.netsteadfast.greenstep.po.hbm.TbSysProg in project bamboobsc by billchen198318.

the class SysProgServiceImpl method findSysProgFolderMap.

/**
	 * 找 TB_SYS_PROG.ITEM_TYPE = 'FOLDER' 或 'ITEM' 的資料
	 * 
	 * @param basePath
	 * @param progSystem
	 * @param itemType
	 * @param pleaseSelect
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@Override
public Map<String, String> findSysProgFolderMap(String basePath, String progSystem, String itemType, boolean pleaseSelect) throws ServiceException, Exception {
    if (StringUtils.isBlank(progSystem)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    Map<String, String> dataMap = super.providedSelectZeroDataMap(pleaseSelect);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("progSystem", progSystem);
    params.put("itemType", itemType);
    List<TbSysProg> searchList = this.findListByParams(params);
    if (null == searchList || searchList.size() < 1) {
        return dataMap;
    }
    for (TbSysProg sysProg : searchList) {
        dataMap.put(sysProg.getOid(), IconUtils.getMenuIcon(basePath, sysProg.getIcon()) + sysProg.getName());
    }
    return dataMap;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) TbSysProg(com.netsteadfast.greenstep.po.hbm.TbSysProg)

Aggregations

TbSysProg (com.netsteadfast.greenstep.po.hbm.TbSysProg)7 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)5 HashMap (java.util.HashMap)3 TbSys (com.netsteadfast.greenstep.po.hbm.TbSys)2 SysMenuVO (com.netsteadfast.greenstep.vo.SysMenuVO)1