List of usage examples for org.jdom2 Element getChild
public Element getChild(final String cname)
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
/** * * @throws CommandException// w w w . j a v a2s. c om */ protected void checkAllRoomsCapacity() throws CommandException { Element response = execApi("report-active-meetings", new RequestAttributeList()); RequestAttributeList attributes = new RequestAttributeList(); attributes.add("sco-id", getMeetingsFolderId()); attributes.add("type", "meeting"); Element shongoRoomsElement = execApi("sco-contents", attributes); List<String> shongoRooms = new ArrayList<String>(); for (Element sco : shongoRoomsElement.getChild("scos").getChildren()) { shongoRooms.add(sco.getAttributeValue("sco-id")); } for (Element sco : response.getChild("report-active-meetings").getChildren()) { String scoId = sco.getAttributeValue("sco-id"); if (shongoRooms.contains(scoId)) { checkRoomCapacity(scoId); } else { logger.debug("There is active room (sco-id: " + scoId + ", url: " + sco.getChildText("url-path") + ", name: " + sco.getChildText("name") + "), which was not created by shongo."); } } }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
/** * Returns number of participants.//from ww w.ja v a 2s . c o m * @param roomId sco-id * @return number of participants */ protected int countRoomParticipants(String roomId) throws CommandException { RequestAttributeList scoInfoAttributes = new RequestAttributeList(); scoInfoAttributes.add("sco-id", roomId); Element response = execApi("meeting-usermanager-user-list", scoInfoAttributes); return response.getChild("meeting-usermanager-user-list").getChildren("userdetails").size(); }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
/** * @param response Element returned by AC API call * @return true if the given {@code result} represents and error, * false otherwise/*w w w . j av a 2 s. com*/ */ private boolean isError(Element response) { Element status = response.getChild("status"); if (status != null) { String code = status.getAttributeValue("code"); if ("ok".equals(code)) { return false; } } return true; }
From source file:cz.lbenda.dbapp.rc.db.JDBCConfiguration.java
License:Apache License
public final void loadFromElement(Element element) { setPassword(subElementText(element, "password", "")); setUsername(subElementText(element, "user", "SA")); setUrl(subElementText(element, "url", "")); setDriverClass(subElementText(element, "driverClass", "")); Element libraries = element.getChild("libraries"); if (libraries != null) { for (Element librarie : (List<Element>) libraries.getChildren("librarie")) { getImportedLibreries().add(librarie.getValue()); }//from ww w.j a va2 s .com } }
From source file:cz.lbenda.dbapp.rc.db.JDBCConfiguration.java
License:Apache License
private String subElementText(Element element, String name, String def) { Element el = element.getChild(name); if (el == null) { return def; }// w w w. j av a2 s . co m return el.getText(); }
From source file:cz.lbenda.dbapp.rc.SessionConfiguration.java
License:Apache License
public static void loadFromDocument(final Document document) { configurations.clear();/*from w w w .j ava 2 s . co m*/ Element root = document.getRootElement(); Element sessions = root.getChild("sessions"); for (Element session : sessions.getChildren("session")) { LOG.trace("loadFromDocument - session"); SessionConfiguration sc = new SessionConfiguration(); configurations.add(sc); sc.fromElement(session); } }
From source file:cz.lbenda.dbapp.rc.SessionConfiguration.java
License:Apache License
private void fromElement(final Element element) { setId(element.getAttributeValue("id")); if (element.getChild("connectionTimeout") != null) { this.connectionTimeout = Integer.valueOf(element.getChildText("connectionTimeout")); } else {/* w w w .j a va 2 s .c om*/ connectionTimeout = -1; } jdbcConfigurationFromElement(element.getChild("jdbc")); // tableOfKeysSQLFromElement(element.getChild("tableOfKeySQLs")); Element ed = element.getChild("extendedDescription"); if (ed != null) { setExtendedConfigurationType(ExtendedConfigurationType.valueOf(ed.getAttributeValue("type"))); setExtendedConfigurationPath(ed.getText()); } Element e = element.getChild("libraries"); this.librariesPaths.clear(); if (e != null) { for (Element lib : e.getChildren("library")) { this.librariesPaths.add(lib.getText()); } } loadExtendedConfiguration(); }
From source file:cz.lbenda.dbapp.rc.SessionConfiguration.java
License:Apache License
private void loadExtendedConfigurationFromFile() { SAXBuilder builder = new SAXBuilder(); try {/* w w w .j a va 2 s .c o m*/ File file = new File(extendedConfigurationPath); Document document = builder.build(new FileReader(file)); Element root = document.getRootElement(); loadSchemas(root.getChild("schemas")); tableOfKeysSQLFromElement(root.getChild("tableOfKeySQLs")); tableDescriptionExtensionsFromElement(root.getChild("tableDescriptionExtensions")); } catch (JDOMException e) { LOG.error("The file isn't parsable: " + extendedConfigurationPath, e); throw new RuntimeException("The file isn't parsable: " + extendedConfigurationPath, e); } catch (IOException e) { LOG.error("The file can't be opend as StringReader: " + extendedConfigurationPath, e); throw new RuntimeException("The file cant be opend as StringReader: " + extendedConfigurationPath, e); } }
From source file:dblp.xml.DBLPParserFirstSchema.java
private void extractElements(Element root, final String type) { try {/*from ww w . j a va2s . c om*/ // System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); List<Element> nList = root.getChildren(type); // System.out.println(nList); System.out.println(type + " " + nList.size()); int index = 0; int ignore = 0; final Map<Integer, String> filteredConfs = readNodeFile(conf_filter_path); Set<String> filteredConfsSet = new HashSet<>(); filteredConfsSet.addAll(filteredConfs.values()); for (Element eElement : nList) { String booktitle = eElement.getChild("booktitle").getText(); //TODO: should comment out, now it doesn't filter conferences if (!filteredConfsSet.contains(booktitle)) { ignore++; continue; } String year = eElement.getChild("year").getText(); int year_int = Integer.parseInt(year.trim()); if (year_int < year_threshold) { ignore++; continue; } index++; if (index % 100 == 0) { System.out.println("Node#: " + index + " Ignore#:" + ignore); } String title = eElement.getChild("title").getText(); if (titleSet.contains(title)) { ignore++; continue; } titleSet.add(title); int titleId = titlesCollection.get(title); int yearId = yearsCollection.get(year); int confId = confsCollection.get(booktitle); title_conf_writer.write(titleId + " " + confId + "\n"); title_year_writer.write(titleId + " " + yearId + "\n"); final List<Element> authors = eElement.getChildren("author"); for (Element author : authors) { String author_str = author.getText(); int authorId = authorsCollection.get(author_str); title_author_writer.write(titleId + " " + authorId + "\n"); } } title_author_writer.close(); title_conf_writer.close(); title_year_writer.close(); } catch (IOException ex) { Logger.getLogger(DBLPParserFirstSchema.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:dblp.xml.DBLPParserSecondSchema.java
private void extractElements(Element root, final String type) { try {/*from w w w .jav a 2s . co m*/ List<Element> nList = root.getChildren(type); System.out.println(type + " " + nList.size()); int index = 0; int ignore = 0; final Map<Integer, String> filteredConfs = readNodeFile(conf_filter_path); Set<String> filteredConfsSet = new HashSet<>(); filteredConfsSet.addAll(filteredConfs.values()); for (Element eElement : nList) { String booktitle = eElement.getChild("booktitle").getText(); if (!filteredConfsSet.contains(booktitle)) { ignore++; continue; } String year = eElement.getChild("year").getText(); int year_int = Integer.parseInt(year.trim()); if (year_int < year_threshold) { ignore++; continue; } index++; if (index % 100 == 0) { System.out.println("Node#: " + index + " Ignore#:" + ignore); } String title = eElement.getChild("title").getText(); int titleId = titlesCollection.get(title); int confId = confsCollection.get(booktitle); String yearConf = year + " " + booktitle; int yearConfId = yearConfsCollection.get(yearConf); conf_year_writer.write(confId + " " + yearConfId + "\n"); title_year_writer.write(titleId + " " + yearConfId + "\n"); final List<Element> authors = eElement.getChildren("author"); for (Element author : authors) { String author_str = author.getText(); int authorId = authorsCollection.get(author_str); title_author_writer.write(titleId + " " + authorId + "\n"); author_conf_writer.write(authorId + " " + confId + "\n"); } } title_author_writer.close(); author_conf_writer.close(); title_year_writer.close(); conf_year_writer.close(); } catch (IOException ex) { Logger.getLogger(DBLPParserSecondSchema.class.getName()).log(Level.SEVERE, null, ex); } }