Search in sources :

Example 16 with Element

use of org.omegat.filters3.Element in project gocd by gocd.

the class HgModificationSplitter method parseFiles.

private List<File> parseFiles(Element filesElement, String fileType) {
    List files = filesElement.getChild(fileType).getChildren("file");
    List<File> modifiedFiles = new ArrayList<>();
    for (Iterator iterator = files.iterator(); iterator.hasNext(); ) {
        Element node = (Element) iterator.next();
        modifiedFiles.add(new File(org.apache.commons.lang.StringEscapeUtils.unescapeXml(node.getText())));
    }
    return modifiedFiles;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 17 with Element

use of org.omegat.filters3.Element in project gocd by gocd.

the class HgModificationSplitter method parseChangeset.

private Modification parseChangeset(Element changeset) throws ParseException {
    Date modifiedTime = DateUtils.parseRFC822(changeset.getChildText("date"));
    String author = org.apache.commons.lang.StringEscapeUtils.unescapeXml(changeset.getChildText("author"));
    String comment = org.apache.commons.lang.StringEscapeUtils.unescapeXml(changeset.getChildText("desc"));
    String revision = changeset.getChildText("node");
    Modification modification = new Modification(author, comment, null, modifiedTime, revision);
    Element files = changeset.getChild("files");
    List<File> modifiedFiles = parseFiles(files, "modified");
    List<File> addedFiles = parseFiles(files, "added");
    List<File> deletedFiles = parseFiles(files, "deleted");
    modifiedFiles.removeAll(addedFiles);
    modifiedFiles.removeAll(deletedFiles);
    addModificationFiles(modification, ModifiedAction.added, addedFiles);
    addModificationFiles(modification, ModifiedAction.deleted, deletedFiles);
    addModificationFiles(modification, ModifiedAction.modified, modifiedFiles);
    return modification;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element) File(java.io.File) Date(java.util.Date)

Example 18 with Element

use of org.omegat.filters3.Element in project gocd by gocd.

the class SvnLogXmlParser method parseDOMTree.

private List<Modification> parseDOMTree(Document document, String path) throws ParseException {
    List<Modification> modifications = new ArrayList<>();
    Element rootElement = document.getRootElement();
    List logEntries = rootElement.getChildren("logentry");
    for (Iterator iterator = logEntries.iterator(); iterator.hasNext(); ) {
        Element logEntry = (Element) iterator.next();
        Modification modification = parseLogEntry(logEntry, path);
        if (modification != null) {
            modifications.add(modification);
        }
    }
    return modifications;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element)

Example 19 with Element

use of org.omegat.filters3.Element in project gocd by gocd.

the class SvnLogXmlParser method parseLogEntry.

private Modification parseLogEntry(Element logEntry, String path) throws ParseException {
    Element logEntryPaths = logEntry.getChild("paths");
    if (logEntryPaths == null) {
        /* Path-based access control forbids us from learning
             * details of this log entry, so skip it. */
        return null;
    }
    Date modifiedTime = convertDate(logEntry.getChildText("date"));
    String author = logEntry.getChildText("author");
    String comment = logEntry.getChildText("msg");
    String revision = logEntry.getAttributeValue("revision");
    Modification modification = new Modification(author, comment, null, modifiedTime, revision);
    List paths = logEntryPaths.getChildren("path");
    for (Iterator iterator = paths.iterator(); iterator.hasNext(); ) {
        Element node = (Element) iterator.next();
        if (underPath(path, node.getText())) {
            ModifiedAction action = convertAction(node.getAttributeValue("action"));
            modification.createModifiedFile(node.getText(), null, action);
        }
    }
    return modification;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element) ModifiedAction(com.thoughtworks.go.domain.materials.ModifiedAction)

Example 20 with Element

use of org.omegat.filters3.Element in project gocd by gocd.

the class StageCctrayPresentationModelTest method shouldContainBuilds.

private void shouldContainBuilds(Element root) {
    Element buildProject = findChildByName(root, "cruise :: ft :: firefox");
    assertThat(buildProject, hasAttribute("activity", "Sleeping"));
    assertThat(buildProject, hasAttribute("lastBuildStatus", "Success"));
    assertThat(buildProject, hasAttribute("lastBuildLabel", String.valueOf(LABEL)));
    assertThat(buildProject, hasAttribute("lastBuildTime", DATE_STR));
    assertThat(buildProject, hasAttribute("webUrl", buildDetailUrl()));
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)1444 Document (org.jdom2.Document)242 Test (org.junit.Test)157 ArrayList (java.util.ArrayList)111 Attribute (org.jdom2.Attribute)106 IOException (java.io.IOException)76 File (java.io.File)71 JDOMException (org.jdom2.JDOMException)65 XMLOutputter (org.jdom2.output.XMLOutputter)54 List (java.util.List)51 SAXBuilder (org.jdom2.input.SAXBuilder)51 HashMap (java.util.HashMap)49 Test (org.junit.jupiter.api.Test)34 Map (java.util.Map)33 Node (gov.cms.qpp.conversion.model.Node)29 MCRException (org.mycore.common.MCRException)28 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)28 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 Namespace (org.jdom2.Namespace)25 XmlFile (jmri.jmrit.XmlFile)24