ProjectExporter implements Serializable { public Document exportToXml(Plan p) throws PlanningException { Document doc = createProjectDoc(); addProject(p, doc, false); return doc; } ProjectExporter(); Document exportToXml(Plan p); Document createProjectDoc(); Document createTemplateDoc(); String getObjectiveTreeAsTemplate(Plan p, String templateLibrary, String name, String description); void exportToFile(Plan p, File target); Document exportTemplates(List<TemplateTree> trees); void addProject(Plan p, Document projectsDoc, boolean addDigitalObjectData); String exportTreeToFreemind(Plan plan); String exportTreeToFreemind(TreeNode treeRoot); static OutputFormat prettyFormat; static OutputFormat compactFormat; }
@Test public void exportToXml_planProperties() throws PlanningException { Plan p = generateBasicPlan(); p.setPlanProperties(generatePlanProperties()); Document doc = exporter.exportToXml(p); Element ppElement = (Element) getNode(doc, "/plans/p:plan/p:properties"); assertThat(ppElement.attributeValue("author"), is("Author")); assertThat(ppElement.attributeValue("organization"), is("Organization")); assertThat(ppElement.attributeValue("name"), is("Name")); assertThat(ppElement.attributeValue("privateProject"), is("true")); assertThat(ppElement.attributeValue("reportPublic"), is("true")); assertThat(ppElement.attributeValue("repositoryIdentifier"), is("Repository ID")); Element reportElement = getElement(doc, "/plans/p:plan/p:properties/p:report"); checkDigitalObject(reportElement, p.getPlanProperties().getReportUpload()); assertThat(getElement(doc, "/plans/p:plan/p:properties/p:state").attributeValue("value"), is("0")); checkContentByName(ppElement, "p:description"); checkContentByName(ppElement, "p:owner"); }
@Test public void exportToXml_basis() throws PlanningException { Plan p = generateBasicPlan(); p.setProjectBasis(generateBasis()); Document doc = exporter.exportToXml(p); Element basisElement = (Element) getNode(doc, "/plans/p:plan/p:basis"); assertThat(basisElement.attributeValue("identificationCode"), is("Identification code")); checkContentByName(basisElement, "p:documentTypes"); checkContentByName(basisElement, "p:applyingPolicies"); checkContentByName(basisElement, "p:designatedCommunity"); checkContentByName(basisElement, "p:mandate"); checkContentByName(basisElement, "p:organisationalProcedures"); checkContentByName(basisElement, "p:planningPurpose"); checkContentByName(basisElement, "p:planRelations"); checkContentByName(basisElement, "p:preservationRights"); checkContentByName(basisElement, "p:referenceToAgreements"); Element newTriggerElement = getElement(basisElement, "p:triggers/p:trigger[@type='NEW_COLLECTION']"); assertThat(newTriggerElement.attributeValue("active"), is("true")); assertThat(newTriggerElement.attributeValue("description"), is("New description")); Element periodicTriggerElement = getElement(basisElement, "p:triggers/p:trigger[@type='PERIODIC_REVIEW']"); assertThat(periodicTriggerElement.attributeValue("active"), is("false")); Element ceTriggerElement = getElement(basisElement, "p:triggers/p:trigger[@type='CHANGED_ENVIRONMENT']"); assertThat(ceTriggerElement.attributeValue("active"), is("false")); assertThat(ceTriggerElement.attributeValue("description"), is("Changed environment description")); Element coTriggerElement = getElement(basisElement, "p:triggers/p:trigger[@type='CHANGED_OBJECTIVE']"); assertThat(coTriggerElement.attributeValue("active"), is("false")); Element ccpTriggerElement = getElement(basisElement, "p:triggers/p:trigger[@type='CHANGED_COLLECTION_PROFILE']"); assertThat(ccpTriggerElement.attributeValue("active"), is("false")); }
@Test public void exportToXml_alternative() throws PlanningException { Plan p = generateBasicPlan(); AlternativesDefinition alternativesDefinition = new AlternativesDefinition(); alternativesDefinition.setDescription("Description"); Alternative alt1 = generateAlternative("Alternative 1"); alternativesDefinition.addAlternative(alt1); Alternative alt2 = generateAlternative("Alternative 2"); alternativesDefinition.addAlternative(alt2); p.setAlternativesDefinition(alternativesDefinition); Document doc = exporter.exportToXml(p); assertThat(getNodes(doc, "/plans/p:plan/p:alternatives/p:alternative").size(), is(2)); Element alt1Element = getElement(doc, "/plans/p:plan/p:alternatives/p:alternative[@name='Alternative 1']"); assertThat(alt1Element, notNullValue()); checkContentByName(alt1Element, "p:description"); Element ex1Element = getElement(alt1Element, "p:experiment"); checkContentByName(ex1Element, "p:description"); checkContentByName(ex1Element, "p:settings"); checkDigitalObject(getElement(ex1Element, "p:workflow"), alt1.getExperiment().getWorkflow()); Element detailedInfo1Element = getElement(ex1Element, "p:detailedInfos/p:detailedInfo"); assertThat(detailedInfo1Element.attributeValue("key"), is("Short name")); assertThat(detailedInfo1Element.attributeValue("successful"), is("true")); checkContentByName(detailedInfo1Element, "p:programOutput"); checkContentByName(detailedInfo1Element, "p:cpr"); Element measurement1Element = getElement(detailedInfo1Element, "p:measurements/p:measurement"); assertThat(measurement1Element.attributeValue("measureId"), is("Measure id")); checkContentByName(measurement1Element, "p:freeStringValue/p:value"); Element alt2Element = getElement(doc, "/plans/p:plan/p:alternatives/p:alternative[@name='Alternative 2']"); assertThat(alt2Element, notNullValue()); checkContentByName(alt2Element, "p:description"); Element ex2Element = getElement(alt1Element, "p:experiment"); checkContentByName(ex2Element, "p:description"); checkContentByName(ex2Element, "p:settings"); checkDigitalObject(getElement(ex2Element, "p:workflow"), alt1.getExperiment().getWorkflow()); assertThat(getContent(doc, "/plans/p:plan/p:alternatives/p:alternative[@name='Alternative 1']/p:experiment"), notNullValue()); }