Package eu.planets_project.pp.plato.xml

Examples of eu.planets_project.pp.plato.xml.ProjectExporter


public class ProjectExporterUnitTest {

    @Test
    public void testPlainExport() throws Exception {
        ProjectExporter exporter = new ProjectExporter();

        String s = exporter.exportToString(TestProjectFactory.createMinimalistTestProject());

        Plan q = TestProjectFactory.createMinimalistTestProject();

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        XMLWriter writer = new XMLWriter(buffer, ProjectExporter.prettyFormat);

        assert writer != null;

        writer.write(exporter.exportToXml(q));
        writer.close();
        assert s.equals(buffer.toString());
    }
View Full Code Here


                }
                );
        boolean success = true;
        for (File demoFile : demoFiles) {
            ProjectImporter importer = new ProjectImporter();
            ProjectExporter exporter = new ProjectExporter();

            //
            // for xml compare, we leave the jhoveXML out. we don't compare it.
            // it changes after import, because we call jhove when importing a plan
            List<String> nodesToExclude = new ArrayList<String>();
            nodesToExclude.add("//*[name()='jhoveXML']");
            nodesToExclude.add("//*[name()='changelog']");
           
            String logText = "";
           
            try {
               
                logText = "Test plan: " + demoFile.getAbsolutePath();
                System.out.println(logText);
                log.info(logText);
               
                List<Plan> importedPlans = importer.importProjects(demoFile.getAbsolutePath());
               
                assert importedPlans.size() == 1;
               
                logText = " - organisation: "+ importedPlans.get(0).getPlanProperties().getOrganization();
               
                System.out.println(logText);
                log.info(logText);
               
                File exportedPlanFile = new File(outputPath + demoFile.getName() + ".impexp.xml");

                exporter.exportToFile( importedPlans.get(0), exportedPlanFile);
               
                String sorted1 = createSortedXml(demoFile);
                String sorted2 = createSortedXml(exportedPlanFile);
               
                logText = demoFile +" -> " + sorted1;
View Full Code Here

     * @param baseTempPath used to write temp files for binary data,
     *        must not be used by other exports at the same time
     */
    public void exportComplete(int ppid, OutputStream out, String baseTempPath) {
        BASE64Encoder encoder = new BASE64Encoder();
        ProjectExporter exporter = new ProjectExporter();
        Document doc = exporter.createProjectDoc();

//        int i = 0;
        List<Plan> list = null;
        try {
            list = em.createQuery(
                    "select p from Plan p where p.planProperties.id = "
                            + ppid).getResultList();
        } catch (Exception e1) {
            list = new ArrayList<Plan>();
            FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR, "An error occured while generating the export file.");
            log.error("Could not load planProperties: ", e1);
        }
        try {
            if (list.size() != 1) {
                FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR,
                        "Skipping the export of the plan with properties"+ppid+": Couldnt load.");
            } else {
                //log.debug("adding project "+p.getplanProperties().getName()+" to XML...");
                String tempPath = baseTempPath;
                File tempDir = new File(tempPath);
                tempDir.mkdirs();

                List<Integer> uploadIDs = new ArrayList<Integer>();
                List<Integer> recordIDs = new ArrayList<Integer>();
                try {
                    exporter.addProject(list.get(0), doc, uploadIDs, recordIDs);
                   
                    writeBinaryObjects(recordIDs, uploadIDs, tempPath, encoder);
                    // perform XSLT transformation to get the DATA into the PLANS
                    XMLWriter writer = new XMLWriter(new FileOutputStream("/tmp/testout"+System.currentTimeMillis()+".xml"));
                    writer.write(doc);
View Full Code Here

     * @param uploadIDs
     * @param recordIDs
     * @return
     */
    public Document exportToXml(List<Integer> ppids, List<Integer> uploadIDs, List<Integer> recordIDs) {
        ProjectExporter exporter = new ProjectExporter();
        Document doc = exporter.createProjectDoc();

        int i = 0;
        for (Integer id: ppids) {
            // load one plan after the other:
            List<Plan> list = em.createQuery(
                    "select p from Plan p where p.planProperties.id = "
                            + id).getResultList();
            if (list.size() != 1) {
                FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR,
                        "Skipping the export of the plan with properties"+id+": Couldnt load.");
            } else {
                //log.debug("adding project "+p.getplanProperties().getName()+" to XML...");
                exporter.addProject(list.get(0), doc, uploadIDs, recordIDs);
            }
            list.clear();
            list = null;
           
            log.info("XMLExport: addString destinationed project ppid="+id);
View Full Code Here

            expandNode(node);
            }
    }
   
    public void downloadTree() {
        ProjectExporter exporter = new ProjectExporter();
        Downloader.instance().downloadMM(
                exporter.exportTreeToFreemind(selectedPlan),
                selectedPlan.getPlanProperties().getName()+".mm");
    }
View Full Code Here

        if (selectedPlan == null) {
            FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR, "Please select a plan first.");
            return null;
        }

        ProjectExporter exporter = new ProjectExporter();
       
        String xml = exporter.getObjectiveTreeAsTemplate(selectedPlan, templateLibrary, templateName, templateDescription);       
        try {
            projectImport.storeTemplatesInLibrary(xml.getBytes("UTF-8"));
           
            fragmentRoot = null;
            templateRoot = null;
View Full Code Here

            log.error("No project selected - please load project first.");
            return null;           
        }
        File tempFile = new File(OS.getTmpPath() + "cloneplans_" + System.currentTimeMillis() + ".xml");
        tempFile.deleteOnExit();
        ProjectExporter exporter = new ProjectExporter();
        try {
            exporter.exportToFile(selectedPlan, tempFile);
            List<Plan> plans = projectImport.importProjects(new FileInputStream(tempFile));
            /*
             * store project
             */
            storeProjects(plans);
View Full Code Here

        selectedReqNode = null;
        nodesToDelete.add(node);
    }

    public void downloadTree() {
        ProjectExporter exporter = new ProjectExporter();
        Downloader.instance().downloadMM(
                exporter.exportTreeToFreemind(reqexpTree.getRoot()),
                reqexpTree.getName()+".mm");
    }
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.xml.ProjectExporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.