private static void addStrings(SolrInputDocument doc, Collection<String> set, SolrName field) { if (set == null || set.size() == 0) { return; } for (String s : set) { add(doc, field, s); } }
// metadata refs use DcsFile ids to reference DcsFile content //But why is this not getting // indexed or is it? private static void addMetadataRefSet( SolrInputDocument doc, Collection<DcsMetadataRef> set, SolrName field, ArchiveStore store) throws IOException { if (set == null || set.size() == 0) { return; } addRefSet(doc, set, field); }
private static void addFixitySet(SolrInputDocument doc, Collection<DcsFixity> set) { if (set == null || set.size() == 0) { return; } for (DcsFixity fix : set) { setadd(doc, FixityField.ALGORITHM, fix.getAlgorithm()); setadd(doc, FixityField.VALUE, fix.getValue()); } }
private static void addCreatorSet(SolrInputDocument doc, Collection<SeadPerson> set) { if (set == null || set.size() == 0) { return; } for (SeadPerson creator : set) { setadd(doc, SeadSolrField.CreatorField.CREATORID, creator.getId()); setadd(doc, SeadSolrField.CreatorField.CREATORIDTYPE, creator.getIdType()); setadd(doc, SeadSolrField.CreatorField.NAME, creator.getName()); } }
private static void addRefSet( SolrInputDocument doc, Collection<? extends DcsEntityReference> set, SolrName field) { if (set == null || set.size() == 0) { return; } for (DcsEntityReference ref : set) { setadd(doc, field, ref.getRef()); } }
private static void addResourceIdentifierSet( SolrInputDocument doc, Collection<DcsResourceIdentifier> set) { if (set == null || set.size() == 0) { return; } for (DcsResourceIdentifier id : set) { setadd(doc, ResourceIdentifierField.AUTHORITY, id.getAuthorityId()); setadd(doc, ResourceIdentifierField.TYPE, id.getTypeId()); setadd(doc, ResourceIdentifierField.VALUE, id.getIdValue()); } }
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()); } }
private static void addManifestationFileSet( SolrInputDocument doc, Collection<DcsManifestationFile> set, ArchiveStore store) throws IOException { for (DcsManifestationFile mf : set) { final String fileRef = mf.getRef() == null ? null : mf.getRef().getRef(); setadd(doc, ManifestationFileField.FILE_REF, fileRef); setadd(doc, ManifestationFileField.PATH, mf.getPath()); final Collection<DcsRelation> rels = mf.getRelSet(); if (rels != null && !rels.isEmpty() && fileRef != null) { addRelationSet(doc, rels); for (DcsRelation rel : rels) { // <doc // field="mf_rel_urn:dataconservancy.org:file/4326762_hasRelationship">urn:dataconservancy.org:rel/isMetadataFor</doc> setadd( doc, ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName() + fileRef + "_" + RelationField.RELATION.solrName(), rel.getRelUri()); // <doc // field="mf_rel_urn:dataconservancy.org:file/4326762_relatedTo">http://dataconservancy.org/dcs/entity/article_du</doc> setadd( doc, ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName() + fileRef + "_" + RelationField.TARGET.solrName(), rel.getRef().getRef()); } } } }
private static void addRelationSet(SolrInputDocument doc, Collection<DcsRelation> set) { if (set == null || set.size() == 0) { return; } for (DcsRelation rel : set) { setadd(doc, RelationField.TARGET, rel.getRef() == null ? null : rel.getRef().getRef()); setadd(doc, RelationField.RELATION, rel.getRelUri()); if (rel.getRef() != null && rel.getRelUri() != null) { doc.addField(RELATION_FIELD_PREFIX + rel.getRelUri(), rel.getRef()); } } }
private static String[] setgetAll(SolrDocument doc, String solrField) { Collection<Object> value_col = doc.getFieldValues(solrField); Collection<Object> isnull_col = doc.getFieldValues(solrField + IS_NULL_FIELD_SUFFIX); if (value_col == null || isnull_col == null) { // System.out.println("returing empty " + field.solrName()); // System.out.println("valuecol " + (value_col == null)); // System.out.println("isnull " + (isnull_col == null)); return new String[] {}; } Boolean[] isnull = isnull_col.toArray(new Boolean[] {}); String[] values = value_col.toArray(new String[] {}); for (int i = 0; i < values.length; i++) { if (isnull[i]) { values[i] = null; } } return values; }
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); } } }