/** * 根据输入的path地址获取含有所有dbrule和tableRule的Map. 只在初始化的时候调用一次. * * @param path 路径名系统内采用 getClass().getResourceAsStream(path);的方式获取对应的stream资源 * @return */ @SuppressWarnings("unchecked") public synchronized void initLogicTabMarticMap(String path, Map<String, LogicTabMatrix> map) { Document doc = getDocument(path); Element ele = doc.getRootElement(); String dbType = trim(ele.attributeValue("dbType")); Iterator dbTabItr = ele.elementIterator("table"); int i = 1; while (dbTabItr.hasNext()) { Element aVtab = (Element) dbTabItr.next(); LogicTabMatrix aVtabMatrix = new LogicTabMatrix(); // globalTableRule,如果有则储存起来 Element globeRule = aVtab.element("globalTableRule"); if (globeRule != null) { TabRule globTabRule = this.getTabRule(globeRule); aVtabMatrix.setGlobalTableRule(globTabRule); } String logicName = validAndTrim(aVtab.attributeValue("logicName"), "无法找到第" + i + "个虚拟表的logicName"); // martrix里面的TableName是返还给前端用于表名替换的,因此要保持原样 aVtabMatrix.setTableName(logicName); String needRowCopy = trim(aVtab.attributeValue("rowCopy")); if (needRowCopy != null && !needRowCopy.equals("")) { aVtabMatrix.setNeedRowCopy(Boolean.valueOf(needRowCopy)); } String reverseOutput = trim(aVtab.attributeValue("reverseOutput")); if (reverseOutput != null && !reverseOutput.equals("")) { aVtabMatrix.setAllowReverseOutput(Boolean.valueOf(reverseOutput)); } aVtabMatrix.setDBType(dbType); String tabFactor = trim(aVtab.elementText("tableFactor")); aVtabMatrix.setTableFactor(tabFactor); Element dbRules = (Element) aVtab.element("dbRules"); Iterator rulesItr = dbRules.elementIterator("dbRule"); Map<String, DBRule> ruleMap = getRuleList(rulesItr, aVtabMatrix); // 当一个Rule对象有expression的时候放在depositedRule和allRule // 如果没有expressionString串,则只放在allRule待选 Map<String, DBRule> depositedRules = getDepositedRule(ruleMap); aVtabMatrix.setAllRules(ruleMap); aVtabMatrix.setDepositedRules(depositedRules); List<DBRule> defaultRuleList = getDefaultRuleList(aVtab, aVtabMatrix); aVtabMatrix.setDefaultRules(defaultRuleList); map.put(logicName.toLowerCase(), aVtabMatrix); i++; } }