예제 #1
0
 private static String dto2ddi(DatasetDTO datasetDto) throws XMLStreamException {
   OutputStream outputStream = new ByteArrayOutputStream();
   XMLStreamWriter xmlw = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStream);
   xmlw.writeStartElement("codeBook");
   xmlw.writeDefaultNamespace("http://www.icpsr.umich.edu/DDI");
   writeAttribute(xmlw, "version", "2.0");
   createStdyDscr(xmlw, datasetDto);
   createdataDscr(xmlw, datasetDto.getDatasetVersion().getFiles());
   xmlw.writeEndElement(); // codeBook
   xmlw.flush();
   String xml = outputStream.toString();
   return XmlPrinter.prettyPrintXml(xml);
 }
예제 #2
0
  /**
   * @todo This is just a stub, copied from DDIExportServiceBean. It should produce valid DDI based
   *     on http://guides.dataverse.org/en/latest/developers/tools.html#msv but it is incomplete and
   *     will be worked on as part of https://github.com/IQSS/dataverse/issues/2579 . We'll want to
   *     reference the DVN 3.x code for creating a complete DDI.
   * @todo Rename this from "study" to "dataset".
   */
  private static void createStdyDscr(XMLStreamWriter xmlw, DatasetDTO datasetDto)
      throws XMLStreamException {
    String title = dto2title(datasetDto.getDatasetVersion());
    String authors = dto2authors(datasetDto.getDatasetVersion());
    String persistentAgency = datasetDto.getProtocol();
    String persistentAuthority = datasetDto.getAuthority();
    String persistentId = datasetDto.getIdentifier();

    String citation = datasetDto.getDatasetVersion().getCitation();
    xmlw.writeStartElement("stdyDscr");
    xmlw.writeStartElement("citation");

    xmlw.writeStartElement("titlStmt");

    xmlw.writeStartElement("titl");
    xmlw.writeCharacters(title);
    xmlw.writeEndElement(); // titl

    xmlw.writeStartElement("IDNo");
    writeAttribute(xmlw, "agency", persistentAgency);
    xmlw.writeCharacters(persistentAuthority + "/" + persistentId);
    xmlw.writeEndElement(); // IDNo
    xmlw.writeEndElement(); // titlStmt

    xmlw.writeStartElement("rspStmt");

    xmlw.writeStartElement("AuthEnty");
    xmlw.writeCharacters(authors);
    xmlw.writeEndElement(); // AuthEnty

    xmlw.writeEndElement(); // rspStmt

    xmlw.writeStartElement("biblCit");
    xmlw.writeCharacters(citation);
    xmlw.writeEndElement(); // biblCit
    xmlw.writeEndElement(); // citation
    xmlw.writeEndElement(); // stdyDscr
  }