private static Set<DcsMetadata> getMetadataSet(SolrDocument doc) { Set<DcsMetadata> set = new HashSet<DcsMetadata>(); String[] schemas = setgetAll(doc, MetadataField.SCHEMA); String[] texts = setgetAll(doc, MetadataField.TEXT); for (int i = 0; i < schemas.length; i++) { DcsMetadata md = new DcsMetadata(); md.setMetadata(texts[i]); md.setSchemaUri(schemas[i]); set.add(md); } return set; }
private static void addMetadataSet(SolrInputDocument doc, Collection<DcsMetadata> set) throws IOException { if (set == null || set.size() == 0) { return; } for (DcsMetadata md : set) { setadd(doc, MetadataField.SCHEMA, md.getSchemaUri()); setadd(doc, MetadataField.TEXT, md.getMetadata()); if (md.getMetadata() == null) { continue; } try { Reader in = new StringReader(md.getMetadata()); addXml(doc, "ext_", MetadataField.SEARCH_TEXT.solrName(), new InputSource(in)); in.close(); // Index FGDC String metadata = md.getMetadata(); if (metadata.contains("<metadata>")) // fgdc - change the check { FgdcMapping mapping = new FgdcMapping(); Map<Enum, String> fgdcElements = mapping.map(metadata); Iterator it = fgdcElements.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); add(doc, (SeadSolrField.FgdcField) pair.getKey(), pair.getValue()); it.remove(); // avoids a ConcurrentModificationException } } in.close(); } catch (SAXException e) { throw new IOException(e); } } }