Example usage for org.jdom2 Element getAttributeValue

List of usage examples for org.jdom2 Element getAttributeValue

Introduction

In this page you can find the example usage for org.jdom2 Element getAttributeValue.

Prototype

public String getAttributeValue(final String attname) 

Source Link

Document

This returns the attribute value for the attribute with the given name and within no namespace, null if there is no such attribute, and the empty string if the attribute value is empty.

Usage

From source file:controller.MobilePartnerController.java

public Map<String, Object> getConfiguredOverrides() throws Exception {

    Map<String, Object> configOverrides = new HashMap<>();
    SAXBuilder builder = new SAXBuilder();
    File xmlFile = new File(DIR + "\\dbconf.xml");
    Document document = (Document) builder.build(xmlFile);
    Element rootNode = document.getRootElement();

    List<Element> list = rootNode.getChildren();

    for (Element element : list) {
        configOverrides.put(element.getAttributeValue("name"), element.getText());
    }/*w  w  w  . j  a  v a2s .  c  o m*/

    return configOverrides;
}

From source file:count_dep.Count_dep.java

public static LinkedList<Event> ReadEvents(File f) throws JDOMException, IOException {
    LinkedList<Event> res = new LinkedList<>();
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(f);
    Element foo = doc.getRootElement();
    List<Element> one_document = foo.getChildren();
    for (Element one_document1 : one_document) {
        List<Element> ERE = one_document1.getChildren();
        for (Element e : ERE) {
            if ("event".equals(e.getName())) {
                List<Element> mentions = e.getChildren("event_mention");
                for (Element m : mentions) {
                    Event eve = new Event();
                    Element charseq;
                    Element ldcscpope = m.getChild("ldc_scope");
                    charseq = ldcscpope.getChild("charseq");
                    eve.span = charseq.getText().replace("\n", " ");
                    Element anchor = m.getChild("anchor");
                    charseq = anchor.getChild("charseq");
                    eve.trigger = charseq.getText();
                    if (eve.trigger.equalsIgnoreCase("saturday")) {
                        int a = 0;
                        a = a + 1;//from   ww w.j a v a2  s  .  com
                    }
                    eve.eventtype = e.getAttribute("SUBTYPE").getValue();
                    eve.eventlargetype = e.getAttribute("TYPE").getValue();
                    List<Element> arguments = m.getChildren("event_mention_argument");
                    for (Element argu : arguments) {
                        String argumentstr = argu.getChild("extent").getChild("charseq").getText();
                        if ("U.S".equals(argumentstr) || "U.N".equals(argumentstr)
                                || "Feb".equals(argumentstr)) {
                            argumentstr += ".";
                        }
                        if (argumentstr.equalsIgnoreCase("Basra")) {
                            int a = 0;
                            a = a + 1;
                        }
                        eve.arguments.add(new EventArgument(argumentstr, argu.getAttributeValue("ROLE")));
                    }
                    eve.filename = f.getName();
                    res.add(eve);
                }

            }
        }
    }
    return res;
}

From source file:count_dep.Count_dep.java

public static LinkedList<Event> ReadGrishmanEvents(File f) throws JDOMException, IOException {
    LinkedList<Event> res = new LinkedList<>();
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(f);
    Element foo = doc.getRootElement();
    List<Element> one_document = foo.getChildren();
    for (Element one_document1 : one_document) {
        List<Element> ERE = one_document1.getChildren();
        for (Element e : ERE) {
            if ("event".equals(e.getName())) {
                List<Element> mentions = e.getChildren("event_mention");
                for (Element m : mentions) {
                    Event eve = new Event();
                    eve.filename = f.getName();
                    Element charseq;
                    Element anchor = m.getChild("anchor");
                    charseq = anchor.getChild("charseq");
                    eve.span = m.getChild("extent").getChild("charseq").getText();
                    eve.trigger = charseq.getText();
                    eve.eventtype = e.getAttribute("SUBTYPE").getValue();
                    List<Element> arguments = m.getChildren("event_mention_argument");
                    for (Element argu : arguments) {
                        eve.arguments//from w w w .jav  a 2s  .  co  m
                                .add(new EventArgument(argu.getChild("extent").getChild("charseq").getText(),
                                        argu.getAttributeValue("ROLE")));
                    }
                    //   eve.filename = f.getName();
                    res.add(eve);
                }

            }

        }
    }
    return res;
}

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

@Override
public Collection<RoomSummary> listRooms() throws CommandException {
    RequestAttributeList attributes = new RequestAttributeList();
    attributes.add("filter-type", "meeting");

    Element response = execApi("report-bulk-objects", attributes);

    List<RoomSummary> meetings = new ArrayList<RoomSummary>();

    for (Element room : response.getChild("report-bulk-objects").getChildren("row")) {
        if (room.getChildText("name").matches("(?i).*Template")) {
            continue;
        }//from   w w w.ja  v a2s.c o  m

        RoomSummary roomSummary = new RoomSummary();
        roomSummary.setId(room.getAttributeValue("sco-id"));
        roomSummary.setName(room.getChildText("name"));
        roomSummary.setDescription(room.getChildText("description"));
        roomSummary.setAlias(room.getChildText("url"));

        String dateCreated = room.getChildText("date-created");
        if (dateCreated != null) {
            roomSummary.setStartDateTime(DateTime.parse(dateCreated));
        }

        meetings.add(roomSummary);
    }

    return Collections.unmodifiableList(meetings);
}

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

/**
 * Sets and returns SCO-ID of folder for meetings.
 *
 * @return meeting folder SCO-ID//from   ww  w  .  j  a va  2  s  .c o  m
 * @throws CommandException
 */
protected String getMeetingsFolderId() throws CommandException {
    if (meetingsFolderId == null) {
        Element response = execApi("sco-shortcuts", null);
        for (Element sco : response.getChild("shortcuts").getChildren("sco")) {
            if ("meetings".equals(sco.getAttributeValue("type"))) {
                // Find sco-id of meetings folder
                RequestAttributeList searchAttributes = new RequestAttributeList();
                searchAttributes.add("sco-id", sco.getAttributeValue("sco-id"));
                searchAttributes.add("filter-is-folder", "1");

                Element shongoFolder = execApi("sco-contents", searchAttributes);

                for (Element folder : shongoFolder.getChild("scos").getChildren("sco")) {
                    if (meetingsFolderName.equals(folder.getChildText("name"))) {
                        meetingsFolderId = folder.getAttributeValue("sco-id");
                    }
                }

                // Creates meetings folder if not exists
                if (meetingsFolderId == null) {
                    logger.debug("Folder /" + meetingsFolderName
                            + " for shongo meetings does not exists, creating...");

                    RequestAttributeList folderAttributes = new RequestAttributeList();
                    folderAttributes.add("folder-id", sco.getAttributeValue("sco-id"));
                    folderAttributes.add("name", meetingsFolderName);
                    folderAttributes.add("type", "folder");

                    Element folder = execApi("sco-update", folderAttributes);

                    meetingsFolderId = folder.getChild("sco").getAttributeValue("sco-id");

                    logger.debug("Folder /" + meetingsFolderName + " for meetings created with sco-id: "
                            + meetingsFolderId);
                }

                break;
            }
        }
    }

    return meetingsFolderId;
}

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

/**
 *
 * @throws CommandException/*  w  w w . java2s  . co m*/
 */
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

/**
 * @param response Element returned by AC API call
 * @return true if the given {@code result} represents and error,
 *         false otherwise/*  ww w. j a v a  2 s  .  c o  m*/
 */
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.cesnet.shongo.connector.device.AdobeConnectConnector.java

/**
 * @param result XML result to parse for error
 * @return true if the given {@code result} saying that login is needed,
 *         false otherwise/*w  ww . j av  a  2  s.  co m*/
 */
private boolean isLoginNeeded(Document result) {
    Element status = result.getRootElement().getChild("status");
    if (status != null) {
        String code = status.getAttributeValue("code");
        if ("no-access".equals(code)) {
            String subCode = status.getAttributeValue("subcode");
            if ("no-login".equals(subCode)) {
                return true;
            }
        }
    }
    return false;
}

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 {//from   w  ww.  j  av a 2s  .co  m
        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 tableOfKeysSQLFromElement(final Element element) {
    LOG.trace("load table of keys sql");
    if (element == null) {
        return;/*  w  w w .  jav a 2s  .  c o m*/
    }
    tableOfKeysSQL.clear();
    for (Element tableOfKey : element.getChildren("tableOfKeySQL")) {
        this.tableOfKeysSQL.put(tableOfKey.getAttributeValue("id"), tableOfKey.getText());
    }
}