public String automaticQuery_action() {
    try {
      int queryValue = 1;
      if (!StringUtil.isEmpty(automaticQueryNthValue)) {
        queryValue = Integer.valueOf(automaticQueryNthValue).intValue();
      }
      NetworkDataSubsetResult result =
          networkDataService.runAutomaticQuery(automaticQueryType, queryValue);

      NetworkDataAnalysisEvent event = new NetworkDataAnalysisEvent();
      event.setLabel("Automatic Query");
      event.setAttributeSet("N/A");
      event.setQuery(
          friendlyNameMap.get(automaticQueryType)
              + " ("
              + (StringUtil.isEmpty(automaticQueryNthValue) ? "1" : automaticQueryNthValue)
              + ")");
      event.setVertices(result.getVertices());
      event.setEdges(result.getEdges());
      events.add(event);
      canUndo = true;

    } catch (Exception e) {
      FacesMessage message = new FacesMessage(e.getMessage());
      getFacesContext().addMessage(automaticQueryError.getClientId(getFacesContext()), message);
    }

    return null;
  }
  /**
   * @param study - study that we are exporting
   * @param out
   * @throws IOException
   */
  @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  public void exportStudy(Study study, OutputStream out) throws IOException {
    if (study.getReleasedVersion() == null) {
      throw new IllegalArgumentException(
          "Study does not have released version, study.id = " + study.getId());
    }
    Metadata metadata = study.getReleasedVersion().getMetadata();

    MarcFactory factory = MarcFactory.newInstance();
    Record record = factory.newRecord();

    DataField title = factory.newDataField("245", '0', ' ');
    title.addSubfield(factory.newSubfield('a', metadata.getTitle()));
    if (!StringUtil.isEmpty(metadata.getAuthorsStr())) {
      title.addSubfield(factory.newSubfield('c', metadata.getAuthorsStr()));
    }
    if (!StringUtil.isEmpty(metadata.getDistributionDate())) {
      title.addSubfield(factory.newSubfield('s', metadata.getDistributionDate()));
    }
    record.addVariableField(title);

    DataField globalId = factory.newDataField("440", ' ', ' ');
    globalId.addSubfield(factory.newSubfield('v', study.getGlobalId()));
    record.addVariableField(globalId);

    for (StudyOtherId studyOtherId : metadata.getStudyOtherIds()) {
      DataField otherId = factory.newDataField("440", ' ', ' ');
      otherId.addSubfield(factory.newSubfield('v', studyOtherId.getOtherId()));
      record.addVariableField(otherId);
    }
    for (StudyAbstract studyAbstract : metadata.getStudyAbstracts()) {
      DataField abstractField = factory.newDataField("520", ' ', ' ');
      abstractField.addSubfield(factory.newSubfield('a', studyAbstract.getText()));
      record.addVariableField(abstractField);
    }

    DataField handle = factory.newDataField("856", ' ', ' ');
    handle.addSubfield(factory.newSubfield('u', study.getHandleURL()));
    record.addVariableField(handle);

    DataField dataverseUrl = factory.newDataField("535", ' ', ' ');
    dataverseUrl.addSubfield(
        factory.newSubfield(
            'd',
            "http://" + PropertyUtil.getHostUrl() + "/dvn/study?globalId=" + study.getGlobalId()));
    record.addVariableField(dataverseUrl);

    for (StudyTopicClass studyTopicClass : metadata.getStudyTopicClasses()) {
      DataField topicClass = factory.newDataField("650", ' ', ' ');
      topicClass.addSubfield(factory.newSubfield('a', studyTopicClass.getValue()));
      record.addVariableField(topicClass);
    }
    MarcStreamWriter writer = new MarcStreamWriter(out);

    writer.write(record);

    out.flush();
  }
Example #3
0
 private void writeRights(XMLStreamWriter xmlw, Metadata metadata) throws XMLStreamException {
   Study study = metadata.getStudyVersion().getStudy();
   // Rights
   if (study.getOwner().isDownloadTermsOfUseEnabled()
       && !StringUtil.isEmpty(study.getOwner().getDownloadTermsOfUse())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(study.getOwner().getDownloadTermsOfUse());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getConfidentialityDeclaration())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getConfidentialityDeclaration());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getSpecialPermissions())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getSpecialPermissions());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getRestrictions())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getRestrictions());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getContact())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getContact());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getCitationRequirements())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getCitationRequirements());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getDepositorRequirements())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getDepositorRequirements());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getConditions())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getConditions());
     xmlw.writeEndElement();
   }
   if (!StringUtil.isEmpty(metadata.getDisclaimer())) {
     xmlw.writeStartElement("dc:rights");
     xmlw.writeCharacters(metadata.getDisclaimer());
     xmlw.writeEndElement();
   }
 }
 private String getNetworkMeasureParametersAsString(List<NetworkMeasureParameter> parameterLists) {
   String returnString = "";
   if (parameterLists != null) {
     for (NetworkMeasureParameter parameter : parameterLists) {
       if (!"".equals(returnString)) {
         returnString += "; ";
       }
       returnString += parameter.getName() + " = ";
       returnString +=
           !StringUtil.isEmpty(parameter.getValue())
               ? parameter.getValue()
               : parameter.getDefaultValue();
     }
   }
   return returnString;
 }
  private DefaultMutableTreeNode newTreeNode(Study study, VDC vdc) {

    String url = null;
    if (studyUrl != null) {
      url =
          appendParameterToUrl("/dvn/dv/" + vdc.getAlias() + studyUrl, "studyId=" + study.getId());
    }

    StudyUI studyUI = new StudyUI(study);

    String studyText = studyUI.getMetadata().getTitle();
    if (!StringUtil.isEmpty(studyUI.getAuthors())) {
      studyText += " by " + studyUI.getAuthors();
    }

    return newTreeNode(studyText, url, false);
  }
Example #6
0
  private void writeCoverage(XMLStreamWriter xmlw, Metadata metadata) throws XMLStreamException {
    // Time Period Covered
    String elementText = null;
    if (!StringUtil.isEmpty(metadata.getTimePeriodCoveredStart())
        || !StringUtil.isEmpty(metadata.getTimePeriodCoveredEnd())) {
      xmlw.writeStartElement("dc:coverage");
      elementText = "Time Period Covered: ";
      if (!StringUtil.isEmpty(metadata.getTimePeriodCoveredStart())) {
        elementText += metadata.getTimePeriodCoveredStart();
      }
      if (!StringUtil.isEmpty(metadata.getTimePeriodCoveredEnd())) {
        if (!StringUtil.isEmpty(metadata.getTimePeriodCoveredStart())) {
          elementText += " - ";
        }
        elementText += metadata.getTimePeriodCoveredEnd();
      }
      xmlw.writeCharacters(elementText);
      xmlw.writeEndElement();
    }

    // Date Of Collection
    if (!StringUtil.isEmpty(metadata.getDateOfCollectionStart())
        || !StringUtil.isEmpty(metadata.getDateOfCollectionEnd())) {
      xmlw.writeStartElement("dc:coverage");
      elementText = "Date of Collection: ";
      if (!StringUtil.isEmpty(metadata.getDateOfCollectionStart())) {
        elementText += metadata.getDateOfCollectionStart();
      }
      if (!StringUtil.isEmpty(metadata.getDateOfCollectionEnd())) {
        if (!StringUtil.isEmpty(metadata.getDateOfCollectionStart())) {
          elementText += " - ";
        }
        elementText += metadata.getDateOfCollectionEnd();
      }
      xmlw.writeCharacters(elementText);
      xmlw.writeEndElement();
    }

    // Country/Nation
    if (!StringUtil.isEmpty(metadata.getCountry())) {
      xmlw.writeStartElement("dc:coverage");
      xmlw.writeCharacters("Country/Nation: " + metadata.getCountry());
      xmlw.writeEndElement();
    }

    // Geographic Data
    if (!StringUtil.isEmpty(metadata.getGeographicCoverage())) {
      xmlw.writeStartElement("dc:coverage");
      xmlw.writeCharacters("Geographic Coverage: " + metadata.getGeographicCoverage());
      xmlw.writeEndElement();
    }
    if (!StringUtil.isEmpty(metadata.getGeographicUnit())) {
      xmlw.writeStartElement("dc:coverage");
      xmlw.writeCharacters("Geographic Unit: " + metadata.getGeographicUnit());
      xmlw.writeEndElement();
    }

    for (StudyGeoBounding geoBounding : metadata.getStudyGeoBoundings()) {
      xmlw.writeStartElement("dc:coverage");
      xmlw.writeCharacters("Geographic Bounding: " + geoBounding);
      xmlw.writeEndElement();
    }
  }
Example #7
0
  /**
   * @param xmlw - stream to write DublinCore XML for the study
   * @param study - get metadata from released version of the study.
   * @throws XMLStreamException
   * @throws IllegalArgumentException - if study does not have a released version.
   */
  public void createDC(XMLStreamWriter xmlw, Study study) throws XMLStreamException {
    if (study.getReleasedVersion() == null) {
      throw new IllegalArgumentException(
          "Study does not have released version, study.id = " + study.getId());
    }
    Metadata metadata = study.getReleasedVersion().getMetadata();

    xmlw.writeStartElement("oai_dc:dc");
    xmlw.writeAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
    xmlw.writeAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
    xmlw.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    xmlw.writeAttribute(
        "xsi:schemaLocation",
        "http://www.openarchives.org/OAI/2.0/oai_dc/    http://www.openarchives.org/OAI/2.0/oai_dc.xsd");

    // Title
    xmlw.writeStartElement("dc:title");
    xmlw.writeCharacters(metadata.getTitle());
    xmlw.writeEndElement();

    // Identifier
    xmlw.writeStartElement("dc:identifier");
    xmlw.writeCharacters(study.getPersistentURL());
    xmlw.writeEndElement();

    // Creator
    for (StudyAuthor author : metadata.getStudyAuthors()) {
      xmlw.writeStartElement("dc:creator");
      xmlw.writeCharacters(author.getName());
      xmlw.writeEndElement();
    }

    // Publisher
    for (StudyProducer producer : metadata.getStudyProducers()) {
      xmlw.writeStartElement("dc:publisher");
      xmlw.writeCharacters(producer.getName());
      xmlw.writeEndElement();
    }

    // Date
    if (!StringUtil.isEmpty(metadata.getProductionDate())) {
      xmlw.writeStartElement("dc:date");
      xmlw.writeCharacters(metadata.getProductionDate());
      xmlw.writeEndElement();
    }

    // Relation
    for (StudyRelPublication rp : metadata.getStudyRelPublications()) {
      xmlw.writeStartElement("dc:relation");
      xmlw.writeCharacters(rp.getText());
      xmlw.writeEndElement();
    }
    for (StudyRelMaterial rm : metadata.getStudyRelMaterials()) {
      xmlw.writeStartElement("dc:relation");
      xmlw.writeCharacters(rm.getText());
      xmlw.writeEndElement();
    }
    for (StudyRelStudy rs : metadata.getStudyRelStudies()) {
      xmlw.writeStartElement("dc:relation");
      xmlw.writeCharacters(rs.getText());
      xmlw.writeEndElement();
    }
    for (StudyOtherRef or : metadata.getStudyOtherRefs()) {
      xmlw.writeStartElement("dc:relation");
      xmlw.writeCharacters(or.getText());
      xmlw.writeEndElement();
    }

    // Subject
    for (StudyKeyword keyword : metadata.getStudyKeywords()) {
      xmlw.writeStartElement("dc:subject");
      xmlw.writeCharacters(keyword.getValue());
      xmlw.writeEndElement();
    }
    for (StudyTopicClass topicClass : metadata.getStudyTopicClasses()) {
      xmlw.writeStartElement("dc:subject");
      xmlw.writeCharacters(topicClass.getValue());
      xmlw.writeEndElement();
    }

    // Description
    for (StudyAbstract studyAbstract : metadata.getStudyAbstracts()) {
      xmlw.writeStartElement("dc:description");
      xmlw.writeCharacters(studyAbstract.getText());
      xmlw.writeEndElement();
    }
    xmlw.writeStartElement("dc:description");
    xmlw.writeCharacters("Citation: " + metadata.getTextCitation());
    xmlw.writeEndElement();

    // Coverage
    writeCoverage(xmlw, metadata);

    // Type
    if (!StringUtil.isEmpty(metadata.getKindOfData())) {
      xmlw.writeStartElement("dc:type");
      xmlw.writeCharacters(metadata.getKindOfData());
      xmlw.writeEndElement();
    }

    // Source
    if (!StringUtil.isEmpty(metadata.getDataSources())) {
      xmlw.writeStartElement("dc:source");
      xmlw.writeCharacters(metadata.getDataSources());
      xmlw.writeEndElement();
    }

    // Rights
    writeRights(xmlw, metadata);

    // End root element
    xmlw.writeEndElement();
  }