Search in sources :

Example 86 with Document

use of org.dom4j.Document in project cpsolver by UniTime.

the class StudentRequestXml method main.

public static void main(String[] args) {
    try {
        ToolBox.configureLogging();
        StudentSectioningModel model = new StudentSectioningModel(new DataProperties());
        Assignment<Request, Enrollment> assignment = new DefaultSingleAssignment<Request, Enrollment>();
        StudentSectioningXMLLoader xmlLoad = new StudentSectioningXMLLoader(model, assignment);
        xmlLoad.setInputFile(new File(args[0]));
        xmlLoad.load();
        Document document = exportModel(assignment, model);
        FileOutputStream fos = new FileOutputStream(new File(args[1]));
        (new XMLWriter(fos, OutputFormat.createPrettyPrint())).write(document);
        fos.flush();
        fos.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) DataProperties(org.cpsolver.ifs.util.DataProperties) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) DefaultSingleAssignment(org.cpsolver.ifs.assignment.DefaultSingleAssignment) Document(org.dom4j.Document) File(java.io.File) XMLWriter(org.dom4j.io.XMLWriter)

Example 87 with Document

use of org.dom4j.Document in project cpsolver by UniTime.

the class StudentSectioningXMLSaver method saveDocument.

public Document saveDocument() {
    Document document = DocumentHelper.createDocument();
    document.addComment("Student Sectioning");
    populate(document);
    return document;
}
Also used : Document(org.dom4j.Document)

Example 88 with Document

use of org.dom4j.Document in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method updateMavenBuildFileContent.

protected void updateMavenBuildFileContent(File mavenBuildFile, Map<String, String> mavenPropertiesMap, boolean addDependencies, boolean updateModules) throws DocumentException, IOException {
    SAXReader saxReader = new SAXReader();
    Document pomDocument = saxReader.read(mavenBuildFile);
    setMavenBuildScriptProperties(pomDocument, mavenPropertiesMap);
    if (updateModules) {
        setMavenBuildScriptModules(pomDocument);
    }
    if (addDependencies) {
        setMavenDependencyElements(pomDocument);
    }
    saveXmlDocoment(pomDocument, mavenBuildFile);
}
Also used : SAXReader(org.dom4j.io.SAXReader) Document(org.dom4j.Document)

Example 89 with Document

use of org.dom4j.Document in project cpsolver by UniTime.

the class TimetableXMLSaver method saveDocument.

public Document saveDocument() {
    Document document = DocumentHelper.createDocument();
    document.addComment("University Course Timetabling");
    if (iSaveCurrent && getAssignment().nrAssignedVariables() != 0) {
        StringBuffer comments = new StringBuffer("Solution Info:\n");
        Map<String, String> solutionInfo = (getSolution() == null ? getModel().getExtendedInfo(getAssignment()) : getSolution().getExtendedInfo());
        for (String key : new TreeSet<String>(solutionInfo.keySet())) {
            String value = solutionInfo.get(key);
            comments.append("    " + key + ": " + value + "\n");
        }
        document.addComment(comments.toString());
    }
    Element root = document.addElement("timetable");
    doSave(root);
    return document;
}
Also used : TreeSet(java.util.TreeSet) Element(org.dom4j.Element) Document(org.dom4j.Document)

Example 90 with Document

use of org.dom4j.Document in project zm-mailbox by Zimbra.

the class RightManager method genAdminDocs.

/**
     * generates two files in the output directory
     *
     * {right}-expanded.xml: the root combo right fully expanded
     * {right}-ui.xml: all UI covered by the root combo right
     *
     * @param outputDir
     * @throws ServiceException
     * @throws IOException
     */
private void genAdminDocs(String outputDir) throws ServiceException, IOException {
    if (!outputDir.endsWith("/")) {
        outputDir = outputDir + "/";
    }
    List<AdminRight> rootRights = ImmutableList.of(Admin.R_adminConsoleRights);
    for (AdminRight right : rootRights) {
        Multimap<UI, Right> uiMap = TreeMultimap.create();
        /*
             * output the rights XML.  This XML has the root combo right expanded
             * down to each atom(preset or attrs) right
             */
        Document document = DocumentHelper.createDocument();
        Element rightsRoot = document.addElement(E_ROOT);
        genAdminDocByRight(rightsRoot, right, uiMap);
        writeXML(outputDir + right.getName() + "-expanded.xml", document);
        /*
             * output the UI XML.  This XML contains one entry for each UI, sorted by
             * the description of the UI.
             */
        document = DocumentHelper.createDocument();
        Element uiRoot = document.addElement(E_ROOT);
        genAdminDocByUI(uiRoot, uiMap);
        writeXML(outputDir + right.getName() + "-ui.xml", document);
    }
}
Also used : Element(org.dom4j.Element) Document(org.dom4j.Document)

Aggregations

Document (org.dom4j.Document)288 Element (org.dom4j.Element)192 SAXReader (org.dom4j.io.SAXReader)143 Test (org.junit.Test)102 StringReader (java.io.StringReader)88 File (java.io.File)57 ArrayList (java.util.ArrayList)47 List (java.util.List)40 IOException (java.io.IOException)27 DocumentException (org.dom4j.DocumentException)25 XMLWriter (org.dom4j.io.XMLWriter)22 HashMap (java.util.HashMap)19 Map (java.util.Map)18 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)17 LinkedList (java.util.LinkedList)16 Attribute (org.dom4j.Attribute)15 Node (org.dom4j.Node)14 FileOutputStream (java.io.FileOutputStream)11 DavException (com.zimbra.cs.dav.DavException)10 OutputFormat (org.dom4j.io.OutputFormat)9