List of usage examples for org.dom4j Element attributeValue
String attributeValue(QName qName);
From source file:com.footprint.server.common.config.ConfigHelper.java
License:Open Source License
private static MenuNode createMenuTree(Element element, MenuNode parent) { MenuNode menu = new MenuNode(); menu.setId(element.attributeValue("url")); menu.setName(element.attributeValue("name")); menu.setUrl(element.attributeValue("url")); menu.setParent(parent);//from ww w .j ava 2s .c o m if ("perm".equals(element.getName())) { menu.setPerm(true); } List<Element> elements = element.elements(); for (Element childElement : elements) { if ("perm".equals(childElement.getName()) || "menu".equals(childElement.getName())) { MenuNode child = createMenuTree(childElement, menu); menu.getChildren().add(child); } } return menu; }
From source file:com.founder.fix.fixflow.core.impl.ProcessEngineConfigurationImpl.java
License:Apache License
private void initRulesConfig() { // this.rulesConfigs=new ArrayList<RulesConfig>(); ruleMap.clear();/*from w w w . j a v a 2 s . c om*/ RulesResourceConfig rulesResourceConfig = getFixFlowConfig().getRulesResourceConfig(); List<RulesResource> rulesResources = rulesResourceConfig.getRulesResource(); for (RulesResource rulesResource : rulesResources) { String classPath = rulesResource.getSrc(); Document document = null; try { InputStream in = ReflectUtil.getResourceAsStream(classPath); document = XmlUtil.read(in); } catch (DocumentException e) { log.error("??:" + classPath + "", e); throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION_DCUMENT, classPath, e); } for (Object ele : document.getRootElement().elements("dataBaseTable")) { Element element = (Element) ele; DataBaseTable dataBaseTable = SqlmappingconfigFactory.eINSTANCE.createDataBaseTable(); dataBaseTable.setTableId(element.attributeValue("tableId")); dataBaseTable.setTableName(element.attributeValue("tableName")); dataBaseTable.setTableValue(element.attributeValue("tableValue")); dataBaseTable.setArchiveTable(element.attributeValue("archiveTable")); //dataBaseTable.setMappingType(element.attributeValue("mappingType")); for (Object eleNew : element.elements("column")) { Element columnElement = (Element) eleNew; Column column = SqlmappingconfigFactory.eINSTANCE.createColumn(); column.setColumn(columnElement.attributeValue("column")); column.setName(columnElement.attributeValue("name")); column.setJdbcType(columnElement.attributeValue("jdbcType")); //column.setProperty(columnElement.attributeValue("property")); //column.setSimpleKey(columnElement.attributeValue("property")); dataBaseTable.getColumn().add(column); columnMap.put(dataBaseTable.getTableId() + "_" + column.getColumn(), column); } dataBaseTables.put(dataBaseTable.getTableId(), dataBaseTable); } for (Object ele : document.getRootElement().elements("resultMap")) { Element element = (Element) ele; ResultMap resultMap = SqlmappingconfigFactory.eINSTANCE.createResultMap(); resultMap.setId(element.attributeValue("id")); resultMap.setName(element.attributeValue("name")); resultMap.setType(element.attributeValue("type")); for (Object eleNew : element.elements("result")) { Element resultMappingElement = (Element) eleNew; Result result = SqlmappingconfigFactory.eINSTANCE.createResult(); result.setColumn(resultMappingElement.attributeValue("column")); result.setName(resultMappingElement.attributeValue("name")); result.setJdbcType(resultMappingElement.attributeValue("jdbcType")); result.setProperty(resultMappingElement.attributeValue("property")); //result.setSimpleKey(columnMappingElement.attributeValue("property")); resultMap.getResult().add(result); //columnMappingMap.put(dataBaseTable.getTableId()+"_"+columnMapping.getColumn(), columnMapping); } resultMaps.put(resultMap.getId(), resultMap); } for (Object ele : document.getRootElement().elements("insert")) { Element element = (Element) ele; Insert insertObj = SqlmappingconfigFactory.eINSTANCE.createInsert(); insertObj.setId(element.attributeValue("id")); insertObj.setParameterType(element.attributeValue("parameterType")); insertObj.setRemark(element.attributeValue("remark")); insertObj.setSqlValue(element.getText()); String classPathString = element.attributeValue("classPath"); if (StringUtil.isNotEmpty(classPathString)) { Class<?> classObj = ReflectUtil.loadClass(classPathString); if (classObj != null) { insertObj.setClassPath(classPathString); ruleClassMap.put(element.attributeValue("id"), classObj); } } ruleMap.put(insertObj.getId(), insertObj); } for (Object ele : document.getRootElement().elements("delete")) { Element element = (Element) ele; Delete deleteObj = SqlmappingconfigFactory.eINSTANCE.createDelete(); deleteObj.setId(element.attributeValue("id")); deleteObj.setParameterType(element.attributeValue("parameterType")); deleteObj.setRemark(element.attributeValue("remark")); deleteObj.setSqlValue(element.getText()); String classPathString = element.attributeValue("classPath"); if (StringUtil.isNotEmpty(classPathString)) { Class<?> classObj = ReflectUtil.loadClass(classPathString); if (classObj != null) { deleteObj.setClassPath(classPathString); ruleClassMap.put(element.attributeValue("id"), classObj); } } ruleMap.put(deleteObj.getId(), deleteObj); } for (Object ele : document.getRootElement().elements("update")) { Element element = (Element) ele; Update updateObj = SqlmappingconfigFactory.eINSTANCE.createUpdate(); updateObj.setId(element.attributeValue("id")); updateObj.setParameterType(element.attributeValue("parameterType")); updateObj.setRemark(element.attributeValue("remark")); updateObj.setSqlValue(element.getText()); String classPathString = element.attributeValue("classPath"); if (StringUtil.isNotEmpty(classPathString)) { Class<?> classObj = ReflectUtil.loadClass(classPathString); if (classObj != null) { updateObj.setClassPath(classPathString); ruleClassMap.put(element.attributeValue("id"), classObj); } } ruleMap.put(updateObj.getId(), updateObj); } for (Object ele : document.getRootElement().elements("select")) { Element element = (Element) ele; Select selectObj = SqlmappingconfigFactory.eINSTANCE.createSelect(); selectObj.setId(element.attributeValue("id")); selectObj.setParameterType(element.attributeValue("parameterType")); selectObj.setRemark(element.attributeValue("remark")); selectObj.setSqlValue(element.getText()); selectObj.setResultMap(element.attributeValue("resultMap")); String classPathString = element.attributeValue("classPath"); if (StringUtil.isNotEmpty(classPathString)) { Class<?> classObj = ReflectUtil.loadClass(classPathString); if (classObj != null) { selectObj.setClassPath(classPathString); ruleClassMap.put(element.attributeValue("id"), classObj); } } ruleMap.put(selectObj.getId(), selectObj); } for (Object ele : document.getRootElement().elements("businessRules")) { Element element = (Element) ele; BusinessRules businessRules = SqlmappingconfigFactory.eINSTANCE.createBusinessRules(); businessRules.setId(element.attributeValue("id")); businessRules.setParameterType(element.attributeValue("parameterType")); businessRules.setRemark(element.attributeValue("remark")); businessRules.setSqlValue(element.getText()); businessRules.setResultType(element.attributeValue("resultType")); String classPathString = element.attributeValue("classPath"); if (StringUtil.isNotEmpty(classPathString)) { Class<?> classObj = ReflectUtil.loadClass(classPathString); if (classObj != null) { businessRules.setClassPath(classPathString); ruleClassMap.put(element.attributeValue("id"), classObj); } } ruleMap.put(businessRules.getId(), businessRules); } } }
From source file:com.framework.service.logconfig.LogConfigServiceImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Cacheable("logConfig") public List<LogConfig> getAll() { try {/*w w w . j a v a2 s .co m*/ File shopxxXmlFile = new ClassPathResource("/framework.xml").getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<org.dom4j.Element> elements = document.selectNodes("/framework/logConfig"); List<LogConfig> logConfigs = new ArrayList<LogConfig>(); for (org.dom4j.Element element : elements) { String logType = element.attributeValue("logType"); int logLevel = Integer.parseInt((String) element.attributeValue("logLevel")); String operatObject = element.attributeValue("operatObject"); String urlPattern = element.attributeValue("urlPattern"); LogConfig logConfig = new LogConfig(); logConfig.setLogType(logType); logConfig.setLogLevel(logLevel); logConfig.setUrlPattern(urlPattern); logConfig.setOperatObject(operatObject); logConfigs.add(logConfig); } return logConfigs; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.fxdigital.manager.SoftInfoImpl.java
/** * ???/*from www.j ava2s. c o m*/ * * @return */ public String getDeviceType() { String type = null; String path = getPath(); if (path == null) { return "?"; } File f = new File(path); SAXReader reader = new SAXReader(); try { Document doc = reader.read(f); Element root = doc.getRootElement(); type = root.attributeValue("DeviceType"); } catch (Exception e) { e.printStackTrace(); } return type; }
From source file:com.fxdigital.manager.SoftInfoImpl.java
/** * ??// w ww . ja v a2s . c o m * * @return */ public String getSoftVersion() { String version = null; String path = getPath(); if (path == null) { return "?"; } File f = new File(path); SAXReader reader = new SAXReader(); try { Document doc = reader.read(f); Element root = doc.getRootElement(); version = root.attributeValue("version"); version = "V" + version; } catch (Exception e) { e.printStackTrace(); } if (version == null) version = "V1.0"; return version; }
From source file:com.fxdigital.manager.SoftInfoImpl.java
/** * ??/* w w w. ja v a 2s .c om*/ * * @return */ public String getLicenseTime() { String time = null; String path = getPath(); if (path == null) { return "?"; } File f = new File(path); SAXReader reader = new SAXReader(); try { Document doc = reader.read(f); Element root = doc.getRootElement(); time = root.attributeValue("SerialNumber"); } catch (Exception e) { e.printStackTrace(); } if (time != null && time.length() >= 14) { time = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6, 8) + " " + time.substring(8, 10) + ":" + time.substring(10, 12) + ":" + time.substring(12, 14); } return time; }
From source file:com.github.autoprimer3.SequenceFromDasUcsc.java
License:Open Source License
public String retrieveSequence(String build, String chrom, Integer start, Integer end) throws DocumentException, MalformedURLException { if (!buildToMapMaster.containsKey(build)) { return null; } else {/*from www . ja va 2 s.c o m*/ String chromNumber = chrom.replaceFirst("chr", ""); int length = 0; URL entryPointUrl = new URL(buildToMapMaster.get(build) + "/entry_points"); Document dasXml; SAXReader reader = new SAXReader(); dasXml = reader.read(entryPointUrl); Element root = dasXml.getRootElement(); for (Iterator i = root.elementIterator("ENTRY_POINTS"); i.hasNext();) { Element dsn = (Element) i.next(); for (Iterator j = dsn.elementIterator("SEGMENT"); j.hasNext();) { Element seg = (Element) j.next(); String id = seg.attributeValue("id"); if (id != null && id.equals(chromNumber)) { String stop = seg.attributeValue("stop"); length = Integer.valueOf(stop); break; } } } if (length > 0) { end = end <= length ? end : length; } StringBuilder dna = new StringBuilder(); URL genomeUrl = new URL( buildToMapMaster.get(build) + "/dna?segment=" + chrom + ":" + (start + 1) + "," + end); dasXml = reader.read(genomeUrl); root = dasXml.getRootElement(); for (Iterator i = root.elementIterator("SEQUENCE"); i.hasNext();) { Element dsn = (Element) i.next(); Element seq = dsn.element("DNA"); String text = seq.getText().replaceAll("\n", ""); dna.append(text); //dna.append(seq.getText()); } return dna.toString(); } }
From source file:com.glaf.activiti.extension.xml.ExtensionReader.java
License:Apache License
public List<ExtensionEntity> readTasks(java.io.InputStream inputStream) { List<ExtensionEntity> extensions = new java.util.ArrayList<ExtensionEntity>(); SAXReader xmlReader = new SAXReader(); try {/* ww w. ja va 2 s . c o m*/ Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); String x_type = root.attributeValue("type"); List<?> rows = root.elements("taskmgr"); Iterator<?> iterator = rows.iterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); ExtensionEntity extension = new ExtensionEntity(); extension.setProcessName(element.attributeValue("processName")); extension.setTaskName(element.attributeValue("taskName")); extension.setType(x_type); if (element.elementTextTrim("taskMgmtType") != null) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName("taskMgmtType"); extensionField.setValue(element.elementTextTrim("taskMgmtType")); extension.addField(extensionField); } Element propertiesE = element.element("properties"); if (propertiesE != null) { List<?> properties = propertiesE.elements("property"); Iterator<?> iter = properties.iterator(); while (iter.hasNext()) { Element elem = (Element) iter.next(); String propertyName = elem.attributeValue("key"); String propertyValue = null; if (elem.attribute("value") != null) { propertyValue = elem.attributeValue("value"); } else { propertyValue = elem.getTextTrim(); } if (StringUtils.isNotEmpty(propertyName) && StringUtils.isNotEmpty(propertyValue)) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName(propertyName.trim()); extensionField.setValue(propertyValue.trim()); extension.addField(extensionField); } } } if (element.elementText("handlers") != null) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName("handlers"); extensionField.setValue(element.elementTextTrim("handlers")); extension.addField(extensionField); } extensions.add(extension); } } catch (Exception ex) { throw new RuntimeException(ex); } return extensions; }
From source file:com.glaf.activiti.extension.xml.ExtensionReader.java
License:Apache License
public List<ExtensionEntity> readActions(java.io.InputStream inputStream) { List<ExtensionEntity> extensions = new java.util.ArrayList<ExtensionEntity>(); SAXReader xmlReader = new SAXReader(); try {//w w w. j ava 2s. c om Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); String x_type = root.attributeValue("type"); List<?> actions = root.elements("action"); Iterator<?> iter = actions.iterator(); while (iter.hasNext()) { Element element = (Element) iter.next(); ExtensionEntity extension = new ExtensionEntity(); extension.setProcessName(element.attributeValue("processName")); extension.setTaskName(element.attributeValue("taskName")); extension.setName(element.attributeValue("name")); extension.setType(x_type); extension.setDescription(element.elementTextTrim("description")); Iterator<?> it99 = element.elementIterator(); while (it99.hasNext()) { Element elem = (Element) it99.next(); String propertyName = elem.getName(); String propertyValue = elem.getTextTrim(); if (StringUtils.isNotEmpty(propertyValue)) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName(propertyName.trim()); extensionField.setValue(propertyValue.trim()); extension.addField(extensionField); } } if (element.elementText("sql") != null) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName("sql"); extensionField.setValue(element.elementTextTrim("sql")); extension.addField(extensionField); } if (element.elementText("handlers") != null) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName("handlers"); extensionField.setValue(element.elementTextTrim("handlers")); extension.addField(extensionField); } Element parametersE = element.element("parameters"); if (parametersE != null) { List<?> parameters = parametersE.elements("parameter"); Iterator<?> it = parameters.iterator(); while (it.hasNext()) { Element elem = (Element) it.next(); String propertyName = elem.attributeValue("name"); String type = elem.attributeValue("type"); String propertyValue = null; if (elem.attribute("value") != null) { propertyValue = elem.attributeValue("value"); } else { propertyValue = elem.getTextTrim(); } if (StringUtils.isNotEmpty(propertyName) && StringUtils.isNotEmpty(propertyValue)) { ExtensionParamEntity extensionParam = new ExtensionParamEntity(); extensionParam.setName(propertyName.trim()); extensionParam.setValue(propertyValue.trim()); extensionParam.setType(type); extension.addParam(extensionParam); } } } extensions.add(extension); } } catch (Exception ex) { throw new RuntimeException(ex); } return extensions; }
From source file:com.glaf.activiti.spring.SpringProcessEngineConfigurationBean.java
License:Apache License
@Override protected void initSqlSessionFactory() { logger.info("-------------------------------------------"); logger.info("-------------initSqlSessionFactory()-------"); logger.info("sqlSessionFactory:" + sqlSessionFactory); logger.info("transactionFactory:" + transactionFactory); if (sqlSessionFactory == null) { InputStream inputStream = null; try {//from w ww . ja va 2 s . co m if (configLocation != null) { logger.info("mybatis config:" + this.configLocation.getFile().getAbsolutePath()); inputStream = this.configLocation.getInputStream(); } else { Resource resource = new ClassPathResource("com/glaf/activiti/activiti.mybatis.conf.xml"); inputStream = resource.getInputStream(); } if (!ObjectUtils.isEmpty(this.mapperLocations)) { SAXReader xmlReader = new SAXReader(); EntityResolver entityResolver = new XMLMapperEntityResolver(); xmlReader.setEntityResolver(entityResolver); Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); Element mappers = root.element("mappers"); if (mappers != null) { java.util.List<?> list = mappers.elements(); Collection<String> files = new HashSet<String>(); if (list != null && !list.isEmpty()) { Iterator<?> iterator = list.iterator(); while (iterator.hasNext()) { Element elem = (Element) iterator.next(); if (elem.attributeValue("resource") != null) { String file = elem.attributeValue("resource"); files.add(file); } else if (elem.attributeValue("url") != null) { String file = elem.attributeValue("url"); files.add(file); } } } for (Resource mapperLocation : this.mapperLocations) { if (mapperLocation == null) { continue; } String url = mapperLocation.getURL().toString(); // logger.debug("find mapper:" + url); if (!files.contains(url)) { Element element = mappers.addElement("mapper"); element.addAttribute("url", url); } } } IOUtils.closeStream(inputStream); byte[] bytes = Dom4jUtils.getBytesFromPrettyDocument(doc); inputStream = new ByteArrayInputStream(bytes); } // update the jdbc parameters to the configured ones... Environment environment = new Environment("default", transactionFactory, dataSource); Reader reader = new InputStreamReader(inputStream); Properties properties = new Properties(); properties.put("prefix", databaseTablePrefix); if (databaseType != null) { properties.put("limitBefore", DbSqlSessionFactory.databaseSpecificLimitBeforeStatements.get(databaseType)); properties.put("limitAfter", DbSqlSessionFactory.databaseSpecificLimitAfterStatements.get(databaseType)); properties.put("limitBetween", DbSqlSessionFactory.databaseSpecificLimitBetweenStatements.get(databaseType)); properties.put("orderBy", DbSqlSessionFactory.databaseSpecificOrderByStatements.get(databaseType)); } XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler()); configuration = parser.parse(); sqlSessionFactory = new DefaultSqlSessionFactory(configuration); } catch (Exception e) { throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e); } finally { IoUtil.closeSilently(inputStream); } } }