List of usage examples for org.dom4j Element elementText
String elementText(QName qname);
From source file:com.globalsight.everest.tm.exporter.ExportOptions.java
License:Apache License
/** * Reads and validates a ExportOptions XML string. */// w w w .j a va 2s .c o m protected void initOther(Element p_root) throws ExporterException { try { Element elem = (Element) p_root.selectSingleNode("//selectOptions"); m_selectOptions.m_selectMode = elem.elementText("selectMode"); m_selectOptions.m_selectFilter = elem.elementText("selectFilter"); m_selectOptions.m_selectChangeCreationId = Boolean .parseBoolean(elem.elementText("selectChangeCreationId")); elem = (Element) p_root.selectSingleNode("//filterOptions"); m_filterOptions.m_createdAfter = elem.elementText("createdafter"); m_filterOptions.m_createdBefore = elem.elementText("createdbefore"); m_filterOptions.m_modifiedAfter = elem.elementText("modifiedafter"); m_filterOptions.m_modifiedBefore = elem.elementText("modifiedbefore"); m_filterOptions.m_lastUsageAfter = elem.elementText("lastusageafter"); m_filterOptions.m_lastUsageBefore = elem.elementText("lastusagebefore"); m_filterOptions.m_createdBy = elem.elementText("createdby"); m_filterOptions.m_modifiedBy = elem.elementText("modifiedby"); m_filterOptions.m_tuId = elem.elementText("tuId"); m_filterOptions.m_sid = elem.elementText("stringId"); m_filterOptions.m_regex = elem.elementText("regex"); m_filterOptions.m_identifyKey = elem.elementText("identifyKey"); m_filterOptions.m_jobId = elem.elementText("jobId"); m_filterOptions.m_language = elem.elementText("language"); m_filterOptions.m_projectName = elem.elementText("projectName"); m_filterOptions.m_conditions.clear(); elem = (Element) p_root.selectSingleNode("//outputOptions"); m_outputOptions.m_systemFields = elem.elementText("systemFields"); List<Element> attributeNodes = p_root.selectNodes("//attribute"); Set<String> attributeSet = new HashSet<String>(); if (attributeNodes != null && attributeNodes.size() > 0) { for (Element attributeElem : attributeNodes) { attributeSet.add(attributeElem.elementText("key") + ":" + attributeElem.elementText("value")); } } m_jobAttributeOptions.jobAttributeSet = attributeSet; } catch (Exception e) { // cast exception and throw error(e.getMessage(), e); } }
From source file:com.globalsight.everest.tm.importer.ImportOptions.java
License:Apache License
/** * Reads and validates a ImportOptions XML string. *///from ww w . j a v a2 s .c o m protected void initOther(Element p_root) throws ImporterException { try { List list; Element locale; Element elem = (Element) p_root.selectSingleNode("//syncOptions"); m_syncOptions.m_syncMode = elem.elementText("syncMode"); elem = (Element) p_root.selectSingleNode("//sourceTmOptions"); m_sourceTmOptions.m_sourceTmName = elem.elementText("sourceTmName"); elem = (Element) p_root.selectSingleNode("//localeOptions"); m_localeOptions.clear(); list = elem.selectNodes("./sourceLocales/locale"); for (int i = 0, max = list.size(); i < max; i++) { locale = (Element) list.get(i); m_localeOptions.m_sourceLocales.add(locale.getText()); } list = elem.selectNodes("./targetLocales/locale"); for (int i = 0, max = list.size(); i < max; i++) { locale = (Element) list.get(i); m_localeOptions.m_targetLocales.add(locale.getText()); } m_localeOptions.m_selectedSource = elem.elementText("selectedSource"); list = elem.selectNodes("./selectedTargets/locale"); for (int i = 0, max = list.size(); i < max; i++) { locale = (Element) list.get(i); m_localeOptions.m_selectedTargets.add(locale.getText()); } } catch (Exception e) { // cast exception and throw error(e.getMessage(), e); } }
From source file:com.globalsight.exporter.ExportOptions.java
License:Apache License
/** * Initializes this object (and derived objects) from an XML string. * Derived objects must implement initOther(). *//*from w w w.j a va 2s . co m*/ public void init(String p_options) throws ExporterException { XmlParser parser = null; Document dom; try { parser = XmlParser.hire(); dom = parser.parseXml(p_options); Element root = dom.getRootElement(); Element elem = (Element) root.selectSingleNode("//fileOptions"); m_fileOptions.m_name = elem.elementText("fileName"); m_fileOptions.m_type = elem.elementText("fileType"); m_fileOptions.m_encoding = elem.elementText("fileEncoding"); m_fileOptions.m_entryCount = elem.elementText("entryCount"); m_fileOptions.m_status = elem.elementText("status"); m_fileOptions.m_errorMessage = elem.elementText("errorMessage"); initOther(root); } catch (ExporterException e) { throw e; } catch (Exception e) { // cast exception and throw error(e.getMessage(), e); } finally { XmlParser.fire(parser); } }
From source file:com.globalsight.importer.ImportOptions.java
License:Apache License
/** * Initializes this object (and derived objects) from an XML string. * Derived objects must implement initOther(). *//*from ww w. j a va 2 s . c om*/ public void init(String p_options) throws ImporterException { XmlParser parser = null; Document dom = null; try { parser = XmlParser.hire(); dom = parser.parseXml(p_options); Element root = dom.getRootElement(); Node node = root.selectSingleNode("//fileOptions"); // This used to use node.valueOf("childnode") but then // entities were incorrectly decoded by the Jaxen library, // i.e. "A&B" became "A & B" instead of "A&B". Element elem = (Element) node; m_fileOptions.m_name = elem.elementText("fileName"); m_fileOptions.m_type = elem.elementText("fileType"); m_fileOptions.m_encoding = elem.elementText("fileEncoding"); m_fileOptions.m_separator = elem.elementText("separator"); m_fileOptions.m_ignoreHeader = elem.elementText("ignoreHeader"); m_fileOptions.m_entryCount = elem.elementText("entryCount"); m_fileOptions.m_status = elem.elementText("status"); m_fileOptions.m_errorMessage = elem.elementText("errorMessage"); initOther(root); } catch (ImporterException e) { throw e; } catch (Exception e) { CATEGORY.error("", e); // cast exception and throw error(e.getMessage(), e); } finally { XmlParser.fire(parser); } }
From source file:com.globalsight.selenium.testcases.util.DownloadUtil.java
License:Apache License
public static String download(String jobName) throws Exception { String wsdlUrl = ConfigUtil.getConfigData("serverUrl") + "/globalsight/services/AmbassadorWebService?wsdl"; AmbassadorServiceLocator loc = new AmbassadorServiceLocator(); Ambassador service = loc.getAmbassadorWebService(new URL(wsdlUrl)); String token = service.login(ConfigUtil.getConfigData("adminName"), ConfigUtil.getConfigData("adminPassword")); String fileXml = null;//from w w w.j a v a2s. c om String waitTimeStr = ConfigUtil.getConfigData("middleWait"); String checkTimesStr = ConfigUtil.getConfigData("checkTimes"); int checkTimes = 30, times = 0; long waitTime = 60000; try { checkTimes = Integer.parseInt(checkTimesStr); waitTime = Long.parseLong(waitTimeStr); } catch (Exception e) { checkTimes = 30; waitTime = 60000; } while (times < checkTimes) { fileXml = service.getJobExportFiles(token, jobName); if (fileXml != null) break; else { Thread.sleep(waitTime); times++; } } SAXReader saxReader = new SAXReader(); Document document = saxReader.read(new StringReader(fileXml)); Element rootElement = document.getRootElement(); String root = rootElement.elementText("root"); ArrayList<Element> paths = (ArrayList<Element>) rootElement.elements("paths"); for (Element element : paths) { String filePath = element.getText(); File outputFile = downloadHttp(root + File.separator + filePath); } return null; }
From source file:com.globalsight.smartbox.bussiness.process.Usecase02PostProcess.java
License:Apache License
/** * Convert xml to csv or txt file//from w w w . ja v a 2 s. c o m * * @param format * @param originFile * @return * @throws Exception */ private File convertXMLToCSVTXT(String format, String targetFile, String outputFilePath) throws Exception { File xmlFile = new File(targetFile); File outputFile = new File(outputFilePath); SAXReader saxReader = new SAXReader(); Document document = saxReader.read(xmlFile); Element aElement = document.getRootElement(); String encoding = aElement.attributeValue("BomInfo"); FileOutputStream fos = new FileOutputStream(outputFilePath); FileUtil.writeBom(fos, encoding); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, encoding)); List<Element> rows = aElement.elements("row"); for (Element row : rows) { List<String> rowStr = new ArrayList<String>(); rowStr.add(row.elementText("sid")); rowStr.add(row.elementText("sourceLocaleName")); rowStr.add(row.elementText("sourceLocaleCode")); rowStr.add(row.elementText("unknown")); rowStr.add(row.elementText("translationSource")); rowStr.add(row.elementText("targetLocale")); rowStr.add(row.elementText("creationDate")); List<Element> segments = row.elements("segment"); for (Element element : segments) { rowStr.add(element.getText()); } StringBuffer sb = new StringBuffer(); if ("csv".equals(format)) { for (String str : rowStr) { sb.append("\"").append(str).append("\"").append(","); } } else { for (String str : rowStr) { sb.append(str).append("|"); } } sb.deleteCharAt(sb.length() - 1); bw.write(sb.toString()); bw.newLine(); } bw.close(); fos.close(); return outputFile; }
From source file:com.globalsight.terminology.importer.ImportOptions.java
License:Apache License
/** * Reads and validates a ImportOptions XML string. * * Xml Format:// ww w . j a va2s. c o m */ protected void initOther(Element p_root) throws ImporterException { try { Element elem = (Element) p_root.selectSingleNode("//syncOptions"); m_syncOptions.m_syncMode = elem.elementText("syncMode"); m_syncOptions.m_syncLanguage = elem.elementText("syncLanguage"); m_syncOptions.m_syncAction = elem.elementText("syncAction"); m_syncOptions.m_nosyncAction = elem.elementText("nosyncAction"); m_columns.clear(); List columns = p_root.selectNodes("/importOptions/columnOptions/column"); for (int i = 0, max = columns.size(); i < max; ++i) { Element col = (Element) columns.get(i); ColumnDescriptor desc = new ColumnDescriptor(); desc.m_position = Integer.parseInt(col.attributeValue("id")); desc.m_name = col.elementText("name"); desc.m_example = col.elementText("example"); desc.m_type = col.elementText("type"); desc.m_termLanguage = col.elementText("termLanguage"); desc.m_encoding = col.elementText("encoding"); desc.m_associatedColumn = col.elementText("associatedColumn"); m_columns.add(desc); } } catch (Exception e) { // cast exception and throw error(e.getMessage(), e); } }
From source file:com.globalsight.terminology.ImportOptions.java
License:Apache License
/** * Reads and validates a ImportOptions XML string. * * Xml Format://from w w w. j a va 2 s. c o m */ private void init(String p_options) throws TermbaseException { XmlParser parser = null; Document dom; try { parser = XmlParser.hire(); dom = parser.parseXml(p_options); } finally { XmlParser.fire(parser); } try { Element root = dom.getRootElement(); Element elem = (Element) root.selectSingleNode("/importOptions/fileOptions"); m_fileOptions.m_name = elem.elementText("fileName"); m_fileOptions.m_type = elem.elementText("fileType"); m_fileOptions.m_encoding = elem.elementText("fileEncoding"); m_fileOptions.m_separator = elem.elementText("separator"); m_fileOptions.m_ignoreHeader = elem.elementText("ignoreHeader"); m_fileOptions.m_entryCount = elem.elementText("entryCount"); m_fileOptions.m_status = elem.elementText("status"); m_fileOptions.m_errorMessage = elem.elementText("errorMessage"); List columns = root.selectNodes("/importOptions/columnOptions/column"); for (int i = 0; i < columns.size(); ++i) { Element col = (Element) columns.get(i); ColumnDescriptor desc = new ColumnDescriptor(); desc.m_position = Integer.parseInt(col.attributeValue("id")); desc.m_name = col.elementText("name"); desc.m_example = col.elementText("example"); desc.m_type = col.elementText("type"); desc.m_termLanguage = col.elementText("termLanguage"); desc.m_encoding = col.elementText("encoding"); desc.m_associatedColumn = col.elementText("associatedColumn"); m_columns.add(desc); } elem = (Element) root.selectSingleNode("/importOptions/syncOptions"); m_syncOptions.m_syncMode = elem.elementText("syncMode"); m_syncOptions.m_syncLanguage = elem.elementText("syncLanguage"); m_syncOptions.m_syncAction = elem.elementText("syncAction"); } catch (Exception e) { // cast exception and throw error(e.getMessage(), e); } }
From source file:com.google.jenkins.flakyTestHandler.junit.FlakyCaseResult.java
License:Open Source License
FlakyCaseResult(FlakySuiteResult parent, Element testCase, String testClassName, boolean keepLongStdio) { String nameAttr = testCase.attributeValue("name"); if (testClassName == null && nameAttr.contains(".")) { testClassName = nameAttr.substring(0, nameAttr.lastIndexOf('.')); nameAttr = nameAttr.substring(nameAttr.lastIndexOf('.') + 1); }//from w w w.j a v a 2s. co m className = testClassName; testName = nameAttr; errorStackTrace = getError(testCase); errorDetails = getErrorMessage(testCase); this.parent = parent; duration = parseTime(testCase); skipped = isMarkedAsSkipped(testCase); skippedMessage = getSkippedMessage(testCase); @SuppressWarnings("LeakingThisInConstructor") Collection<FlakyCaseResult> _this = Collections.singleton(this); stdout = possiblyTrimStdio(_this, keepLongStdio, testCase.elementText("system-out")); stderr = possiblyTrimStdio(_this, keepLongStdio, testCase.elementText("system-err")); // Add flaky tests information List flakyElements = getAllFlakyElements(testCase); flakyRuns = getFlakyRunInformation(flakyElements); }
From source file:com.google.jenkins.flakyTestHandler.junit.FlakyCaseResult.java
License:Open Source License
private static List<FlakyRunInformation> getFlakyRunInformation(List<Element> flakyElements) { List<FlakyRunInformation> flakyRunInformation = new ArrayList<FlakyRunInformation>(); for (Element flakyElement : flakyElements) { // Set errorDetails String errorDetails = flakyElement.attributeValue("message"); // Set errorStackTrace String errorStackTrace = flakyElement.getText(); // Set system-out and system-err String flakyStdout = flakyElement.elementText("system-out"); String flakyStderr = flakyElement.elementText("system-err"); flakyRunInformation/*from w w w . j a v a 2 s .c o m*/ .add(new FlakyRunInformation(errorDetails, errorStackTrace, flakyStdout, flakyStderr)); } return flakyRunInformation; }