Example usage for org.dom4j Element getText

List of usage examples for org.dom4j Element getText

Introduction

In this page you can find the example usage for org.dom4j Element getText.

Prototype

String getText();

Source Link

Document

Returns the text value of this element without recursing through child elements.

Usage

From source file:com.nokia.helium.antlint.checks.CheckJepJythonScript.java

License:Open Source License

/**
 * {@inheritDoc}//w w  w . j  a  v a 2 s  .c o m
 */
public void run(Element node) {
    if (node.getName().equals("target")) {
        checkScripts(node);
    }

    if (node.getName().equals("scriptdef")) {
        String scriptdefname = node.attributeValue("name");
        String language = node.attributeValue("language");
        if (language.equals("jep") || language.equals("jython")) {
            writeJepFile(scriptdefname, node.getText());
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckJepJythonScript.java

License:Open Source License

/**
 * Check against the given node./*from   www .  j  a  v  a 2 s.  co m*/
 * 
 * @param node is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkScripts(Element node) {
    String target = node.attributeValue("name");
    List<Element> scriptList = node.selectNodes("//target[@name='" + target + "']/descendant::script");
    for (Element scriptElement : scriptList) {
        String language = scriptElement.attributeValue("language");
        if (language.equals("jep") || language.equals("jython")) {
            writeJepFile("target_" + target, scriptElement.getText());
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckPropertiesInDataModel.java

License:Open Source License

/**
 * {@inheritDoc}/*from  www .  j a  va  2s .c om*/
 */
public void run(Element node) {
    if (node.getName().equals("target")) {
        checkInScripts(node);
        checkInScriptConditions(node);
        checkInPythonTasks(node);
    }

    if (node.getName().equals("scriptdef")) {
        String language = node.attributeValue("language");

        if (language.equals("jep") || language.equals("jython")) {
            checkJepPropertiesInText(node.getText());
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckPropertiesInDataModel.java

License:Open Source License

/**
 * Check the properties defined inside script condition.
 *  /*from w  ww  .j  av  a 2  s. c  o m*/
 * @param node is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkInScriptConditions(Element node) {
    String target = node.attributeValue("name");
    List<Element> scriptList = node.selectNodes("//target[@name='" + target + "']/descendant::scriptcondition");
    for (Element scriptElement : scriptList) {
        String language = scriptElement.attributeValue("language");
        if (language.equals("jep") || language.equals("jython")) {
            checkJepPropertiesInText(scriptElement.getText());
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckPropertiesInDataModel.java

License:Open Source License

/**
 * Check the properties defined inside scripts.
 *  //from w w w.  j  a  v a 2 s.com
 * @param node is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkInScripts(Element node) {
    String target = node.attributeValue("name");
    List<Element> scriptList = node.selectNodes("//target[@name='" + target + "']/descendant::script");
    for (Element scriptElement : scriptList) {
        String language = scriptElement.attributeValue("language");
        if (language.equals("jep") || language.equals("jython")) {
            checkJepPropertiesInText(scriptElement.getText());
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckPropertiesInDataModel.java

License:Open Source License

/**
 * Check the properties defined inside python tasks.
 *  //from  w ww .  java 2  s .  c  o m
 * @param node is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkInPythonTasks(Element node) {
    String target = node.attributeValue("name");
    List<Element> pythonList = node
            .selectNodes("//target[@name='" + target + "']/descendant::*[name()=\"hlm:python\"]");
    for (Element pythonElement : pythonList) {
        checkPropertiesInText(pythonElement.getText());
    }
}

From source file:com.nokia.helium.antlint.checks.CheckPythonTasks.java

License:Open Source License

/**
 * {@inheritDoc}/*  w  w w  .  ja v a2  s . c o m*/
 */
@SuppressWarnings("unchecked")
public void run(Element node) {
    if (node.getName().equals("target")) {
        String target = node.attributeValue("name");
        List<Element> pythonList = node
                .selectNodes("//target[@name='" + target + "']/descendant::*[name()=\"hlm:python\"]");
        int i = 0;
        for (Element pythonElement : pythonList) {
            writePythonFile(i + "_" + target, pythonElement.getText());
            i++;
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckScriptCondition.java

License:Open Source License

/**
 * Check against the given node./*from w  ww  . j  a  v a2  s  .com*/
 * 
 * @param node
 *            is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkScriptConditions(Element node) {
    String target = node.attributeValue("name");
    List<Element> scriptList = node.selectNodes("//target[@name='" + target + "']/descendant::scriptcondition");
    for (Element scriptElement : scriptList) {
        String language = scriptElement.attributeValue("language");
        if (language.equals("jep") || language.equals("jython")) {
            writeJepFile("scriptcondition_" + target, scriptElement.getText());
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckScriptDef.java

License:Open Source License

/**
 * {@inheritDoc}/* www.  java 2s  .  c  om*/
 */
public void run(Element node) {
    if (node.getName().equals("scriptdef")) {
        String scriptdefname = node.attributeValue("name");
        String language = node.attributeValue("language");

        checkScriptDef(scriptdefname, node);

        if (language.equals("beanshell")) {
            writeBeanshellFile(scriptdefname, node.getText());
        }
    }
}

From source file:com.nokia.helium.scm.ant.actions.ChangelogAction.java

License:Open Source License

/**
 * {@inheritDoc}//  w ww  . j  a  v a2  s .co m
 */
@SuppressWarnings("unchecked")
@Override
public void execute(ScmRepository repository) throws ScmException {
    ScmManager scmManager = getTask().getScmManager();
    ScmRevision startRevision = new ScmRevision(startVersion);
    ScmRevision endRevision = new ScmRevision(endVersion);

    ChangeLogScmResult result;
    Date start = null;
    Date end = null;

    if (numDays == 0 && (startDate != null || endDate != null)) {
        try {
            SimpleDateFormat format = new SimpleDateFormat(datePattern);
            start = format.parse(startDate);
            end = format.parse(endDate);
        } catch (ParseException e) {
            throw new ScmException("Date Format not supported:" + e.getMessage());
        }
    } else {
        start = null;
        end = null;
    }
    try {
        if (startVersion == null) {
            result = scmManager.changeLog(repository, getScmFileSet(), start, end, numDays, null, datePattern);
        } else {
            result = scmManager.changeLog(repository, getScmFileSet(), startRevision, endRevision, datePattern);
        }
    } catch (ScmException e) {
        throw new BuildException("Execution of SCM changelog action failed.");
    }
    if (!result.isSuccess()) {
        throw new BuildException("SCM changelog command unsuccessful.");
    }
    // Output changelog information
    ChangeLogSet changelogSet = result.getChangeLog();
    if (logOutput != null && logOutput.equals("xml")) {
        getTask().log(changelogSet.toXML());
    } else if (xmlbom != null) {
        String output = "";
        for (Object object : changelogSet.getChangeSets()) {
            String revision = "";
            ChangeSet changeSet = (ChangeSet) object;
            for (String line : changeSet.toString().split("\n")) {
                if (line.contains("revision:")) {
                    revision = line.replace("revision:", "");
                }
            }

            output = output + "<task><id>" + revision + "</id><synopsis>" + changeSet.getComment()
                    + "</synopsis><completed>"
                    + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(changeSet.getDate())
                    + "</completed></task>";
        }
        String[] path = getTask().getScmUrl().split("/");
        String xml = "<bom><build>untitled</build><content>\n";
        String thisproject = "<project>" + "<name>" + path[path.length - 1] + "</name>" + "<baseline>"
                + getTask().getScmUrl() + "</baseline>" + "<database>mercurial</database>" + output
                + "</project>\n";
        xml = xml + thisproject;
        try {
            if (xmlbom.exists()) {
                SAXReader xmlReader = new SAXReader();
                Document antDoc = xmlReader.read(xmlbom);
                for (Iterator iterator = antDoc.selectNodes("//project").iterator(); iterator.hasNext();) {
                    boolean equal = false;
                    Element element = (Element) iterator.next();
                    for (Iterator iterator2 = antDoc.selectNodes("//baseline").iterator(); iterator2
                            .hasNext();) {
                        Element e2 = (Element) iterator2.next();
                        if (e2.getText().equals(getTask().getScmUrl())) {
                            equal = true;
                        }
                    }
                    if (!equal) {
                        xml = xml + element.asXML() + "\n";
                    }
                }
            }
            xml = xml + "</content></bom>";

            FileWriter fstream = new FileWriter(xmlbom);
            BufferedWriter out = new BufferedWriter(fstream);
            out.write(xml);
            out.close();
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        Iterator iterator = changelogSet.getChangeSets().iterator();
        while (iterator.hasNext()) {
            getTask().log(iterator.next().toString());
        }
    }
}