private static Set<String> getStringSet(SolrDocument doc, SolrName field) { Set<String> set = new HashSet<String>(); if (doc.containsKey(field.solrName())) { for (Object val : doc.getFieldValues(field.solrName())) { set.add((String) val); } } return set; }
private static Set<DcsManifestationFile> getManifestationFileSet(SolrDocument doc) { Set<DcsManifestationFile> set = new HashSet<DcsManifestationFile>(); String[] filerefs = setgetAll(doc, ManifestationFileField.FILE_REF); String[] paths = setgetAll(doc, ManifestationFileField.PATH); for (int i = 0; i < filerefs.length; i++) { DcsManifestationFile mf = new DcsManifestationFile(); if (filerefs[i] != null) { mf.setRef(new DcsFileRef(filerefs[i])); } if (paths[i] != null && paths[i].length() > 0) { mf.setPath(paths[i]); } // <doc // field="mf_rel_urn:dataconservancy.org:file/4326762_hasRelationship">urn:dataconservancy.org:rel/isMetadataFor</doc> // <doc // field="mf_rel_urn:dataconservancy.org:file/4326762_relatedTo">http://dataconservancy.org/dcs/entity/article_du</doc> String[] relations = setgetAll( doc, ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName() + filerefs[i] + "_" + RelationField.RELATION.solrName()); String[] targets = setgetAll( doc, ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName() + filerefs[i] + "_" + RelationField.TARGET.solrName()); for (int j = 0; j < relations.length; j++) { if (relations[j] != null && targets[j] != null) { DcsRelation rel = new DcsRelation(relations[j], targets[j]); mf.addRel(rel); } } set.add(mf); } return set; }
private static Set<DcsEntityReference> getEntityRefSet(SolrDocument doc, EventField field) { Set<DcsEntityReference> set = new HashSet<DcsEntityReference>(); for (String s : setgetAll(doc, field)) { DcsEntityReference ref = new DcsEntityReference(); if (s != null) { ref.setRef(s); } set.add(ref); } return set; }
private static Set<DcsCollectionRef> getCollectionRefSet(SolrDocument doc, SolrName field) { Set<DcsCollectionRef> set = new HashSet<DcsCollectionRef>(); for (String s : setgetAll(doc, field)) { DcsCollectionRef ref = new DcsCollectionRef(); if (s != null) { ref.setRef(s); } set.add(ref); } return set; }
private static Set<DcsFixity> getFixitySet(SolrDocument doc) { Set<DcsFixity> set = new HashSet<DcsFixity>(); String[] algs = setgetAll(doc, FixityField.ALGORITHM); String[] values = setgetAll(doc, FixityField.VALUE); for (int i = 0; i < algs.length; i++) { DcsFixity fix = new DcsFixity(); fix.setAlgorithm(algs[i]); fix.setValue(values[i]); set.add(fix); } return set; }
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 addURIs(SolrInputDocument doc, Set<URI> set, SolrName field) { if (set == null || set.size() == 0) { return; } for (URI u : set) { setadd(doc, field, u.toString()); } }
private static Set<SeadPerson> getCreatorSet(SolrDocument doc) { Set<SeadPerson> set = new HashSet<SeadPerson>(); String[] names = setgetAll(doc, SeadSolrField.CreatorField.NAME); String[] ids = setgetAll(doc, SeadSolrField.CreatorField.CREATORID); String[] types = setgetAll(doc, SeadSolrField.CreatorField.CREATORIDTYPE); for (int i = 0; i < names.length; i++) { SeadPerson cr = new SeadPerson(); cr.setName(names[i]); cr.setId(ids[i]); cr.setIdType(types[i]); set.add(cr); } return set; }
private static Set<SeadDataLocation> getSecondaryDataLocationSet(SolrDocument doc) { Set<SeadDataLocation> locSet = new HashSet<SeadDataLocation>(); String[] name = setgetAll(doc, SeadSolrField.DataLocationField.NAME); String[] types = setgetAll(doc, SeadSolrField.DataLocationField.TYPE); String[] locations = setgetAll(doc, SeadSolrField.DataLocationField.LOCATION); for (int i = 0; i < locations.length; i++) { SeadDataLocation dataLocation = new SeadDataLocation(); dataLocation.setName(name[i]); dataLocation.setType(types[i]); dataLocation.setLocation(locations[i]); locSet.add(dataLocation); } return locSet; }
private static Set<DcsResourceIdentifier> getResourceIdentifierSet(SolrDocument doc) { Set<DcsResourceIdentifier> idSet = new HashSet<DcsResourceIdentifier>(); String[] authorities = setgetAll(doc, ResourceIdentifierField.AUTHORITY); String[] types = setgetAll(doc, ResourceIdentifierField.TYPE); String[] values = setgetAll(doc, ResourceIdentifierField.VALUE); for (int i = 0; i < values.length; i++) { DcsResourceIdentifier id = new DcsResourceIdentifier(); id.setAuthorityId(authorities[i]); id.setTypeId(types[i]); id.setIdValue(values[i]); idSet.add(id); } return idSet; }
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; }
private static void addSecondaryDataLocationSet( SolrInputDocument doc, Set<SeadDataLocation> set) { if (set == null || set.size() == 0) { return; } for (SeadDataLocation dl : set) { setadd(doc, SeadSolrField.DataLocationField.NAME, dl.getName()); setadd(doc, SeadSolrField.DataLocationField.TYPE, dl.getType()); setadd(doc, SeadSolrField.DataLocationField.LOCATION, dl.getLocation()); } }
private static Set<DcsRelation> getRelations(SolrDocument doc) { Set<DcsRelation> set = new HashSet<DcsRelation>(); String[] rels = setgetAll(doc, RelationField.RELATION); String[] targets = setgetAll(doc, RelationField.TARGET); for (int i = 0; i < rels.length; i++) { DcsRelation rel = new DcsRelation(); if (rels[i] != null) { rel.setRelUri(rels[i]); } if (targets[i] != null) { rel.setRef(new DcsEntityReference(targets[i])); } set.add(rel); } return set; }
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; }