%@page import="com.amarsoft.are.util.json.JSONEncoder"%> <%@page import="com.amarsoft.awe.dw.ui.control.Support"%> <%@page import="com.amarsoft.asquery.*"%> <%@ page contentType="text/html; charset=GBK"%> <%@ include file="/Frame/resources/include/include_begin.jspf"%> <% String sColName = CurPage.getParameter("ColName"); String selected = CurPage.getParameter("selected"); if(selected == null) selected = "@@"; else selected = "@"+selected+"@"; String sSelectCol=""; ASQuery xquery = (ASQuery)session.getAttribute("AdvanceXQuery"); String as1 = xquery.getCodeItemDefinition(sColName); String as2[][] = { { "ColumnName", sColName, "" }, { "RelatedDataObjectName", "", "" }, { "EnvironmentUserID", CurUser.getUserID(), "" } , { "EnvironmentOrgID", CurUser.getOrgID(), "" } , { "QueryClass", xquery.queryClass, "" }, { "EnvironmentSortNo", CurOrg.getSortNo(), "" }, { "EnvironmentCorpID", CurOrg.getCorpOrgID(), "" } }; String s = xquery.getStringWithParameterReplaced(as1, as2); String[] sCodeTableArray = StringX.parseArray(s); String codeTableType = sCodeTableArray[0]; String codeTableSource = sCodeTableArray[1]; boolean leafOnly = false; if(sCodeTableArray.length > 2){ leafOnly = "LeafOnly".equals(sCodeTableArray[2]); } String sColDisplayName = xquery.getColDisplayLabel(sColName); ObjectTree tree = new ObjectTree(sColDisplayName); TreeStory root = new TreeStory("", sColDisplayName, ""); root.setExpand(true); tree.getStorys().add(root); if("code".equalsIgnoreCase(codeTableType)){ root.getStorys().addAll(ObjectTreeManager.genTreeNodes(codeTableSource, null)); }else if("datasource".equalsIgnoreCase(codeTableType)){ int managerIndex = codeTableSource.indexOf(","); if(managerIndex < 0) throw new Exception("JBO代码来源定义错误"); int idIndex = codeTableSource.indexOf(",", managerIndex+1); if(idIndex < 0) throw new Exception("JBO代码来源定义错误"); int textIndex = codeTableSource.indexOf(",", idIndex+1); if(textIndex < 0) throw new Exception("JBO代码来源定义错误"); String sIDField = codeTableSource.substring(managerIndex+1, idIndex); String sTextField = codeTableSource.substring(idIndex+1, textIndex); String sSortField = sIDField; String sWhere = codeTableSource.substring(textIndex+1); if(!StringX.isSpace(sWhere)){ sWhere = "where " + sWhere; int iOrder = sWhere.toUpperCase().lastIndexOf("ORDER BY"); if(iOrder > -1 && sWhere.substring(iOrder+9).trim().indexOf(" ") < 0){ sSortField = sWhere.substring(iOrder+9); } } BizObjectManager m = JBOFactory.getFactory().getManager(codeTableSource.substring(0, managerIndex)); BizObjectQuery q = m.createQuery("select "+sIDField+" as V.ID, "+sTextField+" as V.TEXT, "+sSortField+" as V.SORTNO from O "+sWhere); root.getStorys().addAll(ObjectTreeManager.genTreeNodes(q.getResultList(false), null, "Text", null, "SortNo" , null, null , "SortNo", new String[]{as2[5][1]} , "ID", new String[0] )); }else{ // codetable @MIN_MAX String[] sCodeArray = Support.getCodes(codeTableSource, codeTableType); for(int i = 0; i + 1 < sCodeArray.length; i+=2){ TreeStory story = new TreeStory("", sCodeArray[i+1], ""); story.getAttributes().put("ID", sCodeArray[0]); story.getAttributes().put("TEXT", sCodeArray[1]); root.getStorys().add(story); } } //System.out.println(JSONEncoder.encode(tree)); %>
<%@ include file="/Frame/resources/include/include_end.jspf"%>