private static SolrInputDocument toSolr(DcsCollection col, ArchiveStore store) throws IOException { SolrInputDocument doc = new SolrInputDocument(); add(doc, EntityField.ID, col.getId()); add(doc, EntityField.TYPE, EntityTypeValue.COLLECTION.solrValue()); if (col.getParent() != null) { add(doc, CollectionField.PARENT, col.getParent().getRef()); } add(doc, CoreMetadataField.TITLE, col.getTitle()); addMetadataSet(doc, col.getMetadata()); addMetadataRefSet(doc, col.getMetadataRef(), EntityField.METADATA_REF, store); addResourceIdentifierSet(doc, col.getAlternateIds()); add(doc, CoreMetadataField.TYPE, col.getType()); addStrings(doc, col.getSubjects(), CoreMetadataField.SUBJECT); addStrings(doc, col.getCreators(), CoreMetadataField.CREATOR); return doc; }
private static DcsCollection getCollection(SolrDocument doc) { DcsCollection col = new DcsCollection(); col.setId(getFirst(doc, EntityField.ID)); if (has(doc, CollectionField.PARENT)) { col.setParent(getCollectionRef(doc, CollectionField.PARENT)); } if (has(doc, CoreMetadataField.TYPE)) { col.setType(getFirst(doc, CoreMetadataField.TYPE)); } if (has(doc, CoreMetadataField.TITLE)) { col.setTitle(getFirst(doc, CoreMetadataField.TITLE)); } col.setMetadata(getMetadataSet(doc)); col.setMetadataRef(col.getMetadataRef()); col.setSubjects(getStringSet(doc, CoreMetadataField.SUBJECT)); col.setCreators(getStringSet(doc, CoreMetadataField.CREATOR)); col.setAlternateIds(getResourceIdentifierSet(doc)); return col; }
/** * Copy constructor for a DcsCollection. The state of <code>toCopy</code> is copied * to this. * * @param toCopy the collection to copy */ public DcsCollection(DcsCollection toCopy) { super(toCopy); this.coreMd = toCopy.getCoreMd(); this.parent = toCopy.getParent(); this.metadata = toCopy.getMetadata(); this.metadataRef = toCopy.getMetadataRef(); }
private Set<String> getCollectionRels(DcsEntity collection) { Set<String> rels = new HashSet<String>(); DcsCollection coll = (DcsCollection) collection; for (DcsEntityReference ref : coll.getMetadataRef()) { rels.add(ref.getRef()); } if (coll.getParent() != null) { rels.add(coll.getParent().getRef()); } return rels; }
public DcsCollection createCollection(String parent) { DcsCollection col = new DcsCollection(); col.setId(nextid()); col.setTitle(randomText(rand.nextInt(10) + 1)); if (parent != null) { col.setParent(createCollectionRef(parent)); } col.setMetadata(createMetadataSet(rand.nextInt(2))); col.setSubjects(randomStringSet(4, 4)); col.setType(randomString(4, false)); col.setCreators(randomStringSet(4, 4)); return col; } }
final DcsCollection collection = new DcsCollection(); if (!isEmptyOrNull(id)) { collection.setId(id); if (!isEmptyOrNull(mdRef)) { final DcsMetadataRef md = (DcsMetadataRef) context.convertAnother(collection, DcsMetadataRef.class); collection.addMetadataRef(md); reader.moveUp(); continue; } else { final DcsMetadata md = (DcsMetadata) context.convertAnother(collection, DcsMetadata.class); collection.addMetadata(md); continue; final DcsCollectionRef parent = new DcsCollectionRef(); parent.setRef(parentRef); collection.setParent(parent); collection.setTitle(val); collection.setType(val); collection.addCreator(val); collection.addSubject(val);
col_map.put(col.getId(), col); ancestrymap.put(col.getId(), ancestors); DcsCollectionRef ref = col.getParent(); for (DcsEntityReference ref : col.getMetadataRef()) { updateAncestry(ancestrymap, ref, col.getId());
/** Populates an example sip */ @BeforeClass public static void initExampleSips() { DcsCollection coll = new DcsCollection(); coll.setId("example:/collection"); DcsDeliverableUnit du = new DcsDeliverableUnit(); du.addCollection(new DcsCollectionRef(coll.getId())); du.setId("example:/deleverableUnit"); exampleDcp = new Dcp(); exampleDcp.addCollection(coll); exampleDcp.addDeliverableUnit(du); }
String pid = mapper.getPID(entity.getId()); fdo.setObjectPid(pid); String title = "Collection: " + entity.getId(); if (entity.getTitle() != null) { title = entity.getTitle(); if (entity.getId() != null) { DublinCoreElement dceIdentifier = new DublinCoreElement(); dceIdentifier.setName(DublinCoreConverter.IDENTIFIER); dceIdentifier.setValue(entity.getId()); dc.getElementList().add(dceIdentifier); erdfeid.setLiteral(entity.getId());
if (c.getId().equals(target)) { c.addMetadataRef(mdref); found = true;
private Set<String> getCollectionEntities(String entityId, InputStream content, Metadata md, boolean initial) { Set<String> entities = new HashSet<String>(); /* selected collection is relevant */ entities.add(entityId); try { DcsCollection coll = builder.buildCollection(content); /* * A collection's metadata files are significantly related */ for (DcsEntityReference ref : coll.getMetadataRef()) { entities.add(ref.getRef()); } } catch (InvalidXmlException e) { throw new RuntimeException(e); } finally { try { content.close(); } catch (Exception e) { } } /* A collections events are significantly related */ addRelated(md, entities, EVENT); return entities; }
public Set<DcsCollection> getCollections() { final Set<DcsCollection> collections = new HashSet<DcsCollection>(this.collections.size()); for (DcsCollection c : this.collections) { collections.add(new DcsCollection(c)); } return collections; }
final DcsCollection collection = new DcsCollection(); if (!isEmptyOrNull(id)) { collection.setId(id); final DcsResourceIdentifier rid = (DcsResourceIdentifier) context.convertAnother(collection, DcsResourceIdentifier.class); if (rid != null) { collection.addAlternateId(rid); } reader.moveUp(); continue; if (!isEmptyOrNull(mdRef)) { final DcsMetadataRef md = (DcsMetadataRef) context.convertAnother(collection, DcsMetadataRef.class); collection.addMetadataRef(md); reader.moveUp(); continue; } else { final DcsMetadata md = (DcsMetadata) context.convertAnother(collection, DcsMetadata.class); collection.addMetadata(md); continue; final DcsCollectionRef parent = new DcsCollectionRef(); parent.setRef(parentRef); collection.setParent(parent); collection.setTitle(val); collection.setType(val); collection.addCreator(val);
private Set<String> getCollectionRels(DcsEntity collection) { Set<String> rels = new HashSet<String>(); DcsCollection coll = (DcsCollection) collection; for (DcsEntityReference ref : coll.getMetadataRef()) { rels.add(ref.getRef()); } if (coll.getParent() != null) { rels.add(coll.getParent().getRef()); } return rels; }
private Set<String> getCollectionEntities(String entityId, InputStream content, Metadata md, boolean initial) { Set<String> entities = new HashSet<String>(); /* selected collection is relevant */ entities.add(entityId); try { DcsCollection coll = builder.buildCollection(content); /* * A collection's metadata files are significantly related */ for (DcsEntityReference ref : coll.getMetadataRef()) { entities.add(ref.getRef()); } } catch (InvalidXmlException e) { throw new RuntimeException(e); } finally { try { content.close(); } catch (Exception e) { } } /* A collections events are significantly related */ addRelated(md, entities, EVENT); return entities; }