コード例 #1
0
  private static void addFormatSet(SolrInputDocument doc, Collection<DcsFormat> set) {
    if (set == null || set.size() == 0) {
      return;
    }

    for (DcsFormat fmt : set) {
      setadd(doc, FormatField.NAME, fmt.getName());
      setadd(doc, FormatField.FORMAT, fmt.getFormat());
      setadd(doc, FormatField.SCHEMA, fmt.getSchemeUri());
      setadd(doc, FormatField.VERSION, fmt.getVersion());
    }
  }
コード例 #2
0
  private static Set<DcsFormat> getFormatSet(SolrDocument doc) {
    Set<DcsFormat> set = new HashSet<DcsFormat>();

    String[] names = setgetAll(doc, FormatField.NAME);
    String[] schemas = setgetAll(doc, FormatField.SCHEMA);
    String[] versions = setgetAll(doc, FormatField.VERSION);
    String[] formats = setgetAll(doc, FormatField.FORMAT);

    for (int i = 0; i < formats.length; i++) {
      DcsFormat fmt = new DcsFormat();

      if (formats[i] != null) fmt.setFormat(formats[i]);
      if (names[i] != null) fmt.setName(names[i]);
      if (schemas[i] != null) fmt.setSchemeUri(schemas[i]);
      if (versions[i] != null) fmt.setVersion(versions[i]);

      set.add(fmt);
    }

    return set;
  }
コード例 #3
0
  public static SolrInputDocument indexMetadataFile(
      SolrInputDocument doc, Collection<DcsMetadataRef> set, List<SolrInputDocument> docs) {

    int foundFgdc = 0;
    // Assuming the DCS file is available in the Sip
    for (DcsMetadataRef ref : set) {
      DcsFile file = null;
      for (SolrInputDocument document : docs) {
        String refStr = ref.getRef();
        String id = (String) document.getFieldValue(EntityField.ID.solrName());
        if (refStr.equals(id))
          try {
            file = (DcsFile) fromSolr(toSolrDocument(document));
          } catch (IOException e) {
            e
                .printStackTrace(); // To change body of catch statement use File | Settings | File
                                    // Templates.
          }
      }
      if (file == null) continue;
      // get the file from SIP or from index
      //  DcsFile file = new DcsFile();
      for (DcsFormat format : file.getFormats()) {
        if (format.getFormat().contains("fgdc")) {
          MetadataDocument fgdcDoc = null;
          try {
            String fileSource = file.getSource().replace("file://", "");

            fgdcDoc = MetadataDocument.Factory.parse(new File(fileSource));
            ThemeType[] keywords = fgdcDoc.getMetadata().getIdinfo().getKeywords().getThemeArray();
            PlaceType[] places = fgdcDoc.getMetadata().getIdinfo().getKeywords().getPlaceArray();

            Set<String> themes = new HashSet<String>();
            for (ThemeType theme : keywords) {
              for (String themeStr : theme.getThemekeyArray()) themes.add(themeStr);
            }
            addStrings(doc, themes, CoreMetadataField.SUBJECT);

            Set<String> placeKeys = new HashSet<String>();
            for (PlaceType place : places) {
              for (String placeStr : place.getPlacekeyArray()) placeKeys.add(placeStr);
            }
            addStrings(doc, placeKeys, SeadSolrField.DeliverableUnitField.LOCATION);

          } catch (XmlException e) {
            e
                .printStackTrace(); // To change body of catch statement use File | Settings | File
                                    // Templates.
          } catch (IOException e) {
            e
                .printStackTrace(); // To change body of catch statement use File | Settings | File
                                    // Templates.
          }
          foundFgdc = 1;
        }
        if (foundFgdc == 1) break;
      }
      if (foundFgdc == 1) break;
    }
    return doc;
  }