@SuppressWarnings("unchecked") private ProjectModuleBO convertElementToModule(Element element) { ProjectModuleBO module = new ProjectModuleBO(); module.setId(Long.parseLong(element.getAttributeValue(ATTR_ID))); module.setModuleName(element.getAttributeValue(ATTR_NAME)); module.setRemark(element.getAttributeValue(ATTR_REMARK)); Element developerElement = element.getChild(NODE_DEV); module.setDevelopers(developerElement.getAttributeValue(ATTR_ID)); Element packageElement = element.getChild(NODE_PACKAGE); List<Element> packageChildren = packageElement.getChildren(); for (Element packElement : packageChildren) { String packName = packElement.getAttributeValue(ATTR_NAME); if (StringUtils.isEqual(packElement.getName(), NODE_SRC)) module.setSrcPackage(packName); else if (StringUtils.isEqual(packElement.getName(), NODE_JSP)) module.setJspPackage(packName); else if (StringUtils.isEqual(packElement.getName(), NODE_HBM)) module.setHbmPackage(packName); else if (StringUtils.isEqual(packElement.getName(), NODE_SPRING)) module.setSpringPackage(packName); else if (StringUtils.isEqual(packElement.getName(), NODE_PAGEFLOW)) module.setPageflowPackage(packName); else if (StringUtils.isEqual(packElement.getName(), NODE_VAR)) module.setVarPackage(packName); else if (StringUtils.isEqual(packElement.getName(), NODE_I18N)) module.setI18nPackage(packName); } return module; }
@Override public BusinessComponent query(BOProperty sourceBop) throws Exception { if (sourceBop instanceof DeliveryModeBOP) { if (StringUtils.isEqual(ConstantsValue.VALUE_1.getValue(), sourceBop.getValue().getValue())) getStatus().setHidden(false); else getStatus().setHidden(true); } setValue(getConsoleText()); return super.query(sourceBop); }
/** * @param sourceBCList * @return */ @Override public BusinessComponent query(BOProperty sourceBop) { Map<String, String> streetMap = new LinkedHashMap<String, String>(); EnumRange.addPlease(streetMap); if (StringUtils.isEqual(sourceBop.getValue().getValue(), "9905")) { streetMap.put("1", "街道1"); streetMap.put("2", "街道2"); streetMap.put("3", "街道3"); streetMap.put("4", "街道4"); } EnumRange streetRange = new EnumRange(); streetRange.setResult(streetMap); BCRange bcRange = new BCRange(); bcRange.addRange(streetRange); setRange(bcRange); return this; }
@Override public List<ProjectModuleBO> findModules(BOTemplate bot) { Element rootElement = getRootElement(); if (rootElement == null) return null; List<Element> moduleElements = getElmentsByXpath(getXPath_ModuleAll(), rootElement); if (ContainerUtil.isNull(moduleElements)) return null; List<ProjectModuleBO> modules = new LinkedList<ProjectModuleBO>(); for (Element element : moduleElements) { ProjectModuleBO module = convertElementToModule(element); if (bot == null || ContainerUtil.isNull(bot.getBotMap())) { modules.add(module); continue; } // 判断查询结果是否符合查询条件 boolean inQuery = true; // 模块名称 if (StringUtils.isNotEmpty((String) bot.getBotMap().get("moduleName"))) { if (!StringUtils.hasSubString( module.getModuleName(), bot.getBotMap().get("moduleName").toString())) { inQuery = false; } } // 开发人员 if (inQuery && StringUtils.isNotEmpty((String) bot.getBotMap().get("developers"))) { if (!StringUtils.hasSubString( module.getDevelopers(), bot.getBotMap().get("developers").toString())) { inQuery = false; } } // 模块ID if (inQuery && StringUtils.isNotEmpty((String) bot.getBotMap().get("id"))) { if (!StringUtils.isEqual(module.getId() + "", bot.getBotMap().get("id").toString())) { inQuery = false; } } if (inQuery) modules.add(module); } return modules; }
@SuppressWarnings("unchecked") @Override public void update(ProjectModuleBO module) { Element rootElement = getRootElement(); if (rootElement == null) return; List<Element> elements = getElmentsByXpath(getXPath_ModuleId(module.getId()), rootElement); if (ContainerUtil.isNull(elements)) return; // 修改moduleElement节点 Element moduleElement = elements.get(0); moduleElement.setAttribute(ATTR_NAME, module.getModuleName()); moduleElement.setAttribute(ATTR_REMARK, module.getRemark()); // 修改developers节点 Element developElement = moduleElement.getChild(NODE_DEV); developElement.setAttribute(ATTR_ID, module.getDevelopers()); // 修改package节点 Element packageElement = moduleElement.getChild(NODE_PACKAGE); List<Element> childElements = packageElement.getChildren(); for (Element packElement : childElements) { if (StringUtils.isEqual(NODE_SRC, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getSrcPackage()); else if (StringUtils.isEqual(NODE_JSP, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getJspPackage()); else if (StringUtils.isEqual(NODE_HBM, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getHbmPackage()); else if (StringUtils.isEqual(NODE_SPRING, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getSpringPackage()); else if (StringUtils.isEqual(NODE_PAGEFLOW, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getPageflowPackage()); else if (StringUtils.isEqual(NODE_VAR, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getVarPackage()); else if (StringUtils.isEqual(NODE_I18N, packElement.getName())) packElement.setAttribute(ATTR_NAME, module.getI18nPackage()); } saveXML(rootElement); }