/** * Returns true if the supplied {@code dcp} contains a Manifestation File that references {@code target}. Returns * false otherwise. * * @param dcp the dcp * @param target the target of a manifestation file reference * @return true if the dcp contains a manifestation file referencing target. */ public boolean hasManifestationFile(Dcp dcp, String target) { for (DcsManifestation man : dcp.getManifestations()) { for (DcsManifestationFile mf : man.getManifestationFiles()) { if (mf.getRef().getRef().equals(target)) { return true; } } } return false; }
public DcsFileRef getRef() { return new DcsFileRef(ref); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DcsManifestationFile that = (DcsManifestationFile) o; if (path != null ? !path.equals(that.path) : that.path != null) return false; if (ref != null ? !ref.equals(that.ref) : that.ref != null) return false; if (relSet != null ? !relSet.equals(that.relSet) : that.relSet != null) return false; return true; }
for (DcsEntity entity : entities) { if (entity instanceof DcsFile) { DcsFileRef file_ref = new DcsFileRef(entity.getId()); if (mf.getRef() != null && mf.getRef().equals(file_ref)) { result.add(entity); add_descendants(entity, entities, result);
for (DcsEntity entity : entities) { if (entity instanceof DcsFile) { DcsFileRef file_ref = new DcsFileRef(entity.getId()); if (mf.getRef() != null && mf.getRef().equals(file_ref)) { result.add(entity); add_descendants(entity, entities, result);
private DcsFile getFirstFileOf(Dcp dcp, DcsManifestation man) { for (DcsFile test : dcp.getFiles()) { for (DcsManifestationFile mf : man.getManifestationFiles()) { if (mf.getRef().getRef().equals(test.getId())) { return test; } } } return null; }
public void setRef(DcsFileRef ref) { Assertion.notNull(ref); this.ref = new DcsFileRef(ref); }
/** * Returns true if the supplied {@code dcp} contains a Manifestation File that references {@code target}. Returns * false otherwise. * * @param dcp the dcp * @param target the target of a manifestation file reference * @return true if the dcp contains a manifestation file referencing target. */ public boolean hasManifestationFile(Dcp dcp, String target) { for (DcsManifestation man : dcp.getManifestations()) { for (DcsManifestationFile mf : man.getManifestationFiles()) { if (mf.getRef().getRef().equals(target)) { return true; } } } return false; }
public DcsFile uploadFile(String path, String... manifestations) { if (manifestations.length == 0 && dcp.getManifestations().size() == 1) { return uploadFile(path, dcp.getManifestations().iterator().next() .getId()); } else if (manifestations.length == 0) { throw new IllegalStateException("Cannot add a file if there are no manifestations"); } DcsFile file = newFile(); uploadFile(file, path); for (String m : manifestations) { DcsManifestation manifestation = getManifestation(m); DcsManifestationFile dmf = new DcsManifestationFile(); dmf.setRef(new DcsFileRef(file.getId())); manifestation.addManifestationFile(dmf); saveManifestation(manifestation); } return file; }
private Set<String> getManifestationRefs(DcsEntity manifestation) { Set<String> rels = new HashSet<String>(); DcsManifestation m = (DcsManifestation) manifestation; for (DcsEntityReference ref : m.getMetadataRef()) { rels.add(ref.getRef()); } for (DcsManifestationFile file : m.getManifestationFiles()) { rels.add(file.getRef().getRef()); } if (m.getDeliverableUnit() != null) { rels.add(m.getDeliverableUnit()); } return rels; } }
public DcsFile referenceFile(String path, String... manifestations) { if (manifestations.length == 0 && dcp.getManifestations().size() == 1) { return referenceFile(path, dcp.getManifestations().iterator() .next().getId()); } else if (manifestations.length == 0) { throw new IllegalStateException("Cannot add a file if there are no manifestations"); } DcsFile file = newFile(); URI pathUri = getUri(path); file.setSource(pathUri.toASCIIString()); file.setName(getFileName(pathUri)); for (String m : manifestations) { DcsManifestation manifestation = getManifestation(m); DcsManifestationFile dmf = new DcsManifestationFile(); dmf.setRef(new DcsFileRef(file.getId())); manifestation.addManifestationFile(dmf); saveManifestation(manifestation); } return file; }
public DcsManifestation createManifestation(String du, List<DcsFile> files) { DcsManifestation man = new DcsManifestation(); man.setId(nextid()); man.setDeliverableUnit(du); man.setDateCreated(DateUtility.toIso8601(DateUtility.now())); man.setMetadata(createMetadataSet(rand.nextInt(3))); man.setMetadataRef(createMetadataRefSet(rand.nextInt(2))); int numfiles = rand.nextInt(10); for (int i = 0; i < numfiles; i++) { DcsManifestationFile manfile = new DcsManifestationFile(); DcsFile file = createFile(); files.add(file); manfile.setRef(new DcsFileRef(file.getId())); manfile.setPath(randomString(10, false)); if (rand.nextBoolean()) { manfile.setRelSet(createRelations(rand.nextInt(2))); } man.addManifestationFile(manfile); } return man; }
private Set<String> getManifestationRefs(DcsEntity manifestation) { Set<String> rels = new HashSet<String>(); DcsManifestation m = (DcsManifestation) manifestation; for (DcsEntityReference ref : m.getMetadataRef()) { rels.add(ref.getRef()); } for (DcsManifestationFile file : m.getManifestationFiles()) { rels.add(file.getRef().getRef()); } if (m.getDeliverableUnit() != null) { rels.add(m.getDeliverableUnit()); } return rels; } }
mf.setRef(new DcsFileRef(file.getId())); mf.setPath("/");
private Set<String> getManifestationEntities(String entityId, InputStream content, Metadata md, boolean initial) { Set<String> entities = new HashSet<String>(); entities.add(entityId); try { DcsManifestation man = builder.buildManifestation(content); /* * A manifestation's metadata files are significantly related */ for (DcsEntityReference ref : man.getMetadataRef()) { entities.add(ref.getRef()); } /* A manifestation's files are significantly related */ for (DcsManifestationFile f : man.getManifestationFiles()) { entities.add(f.getRef().getRef()); } } catch (InvalidXmlException e) { throw new RuntimeException(e); } finally { try { content.close(); } catch (Exception e) { } } /* A manifestation's events are significantly related */ addRelated(md, entities, EVENT); return entities; }
mf.setRef(new DcsFileRef(file.getId())); mf.setPath("/");
private Set<String> getManifestationEntities(String entityId, InputStream content, Metadata md, boolean initial) { Set<String> entities = new HashSet<String>(); entities.add(entityId); try { DcsManifestation man = builder.buildManifestation(content); /* * A manifestation's metadata files are significantly related */ for (DcsEntityReference ref : man.getMetadataRef()) { entities.add(ref.getRef()); } /* A manifestation's files are significantly related */ for (DcsManifestationFile f : man.getManifestationFiles()) { entities.add(f.getRef().getRef()); } } catch (InvalidXmlException e) { throw new RuntimeException(e); } finally { try { content.close(); } catch (Exception e) { } } /* A manifestation's events are significantly related */ addRelated(md, entities, EVENT); return entities; }