OcDublinCoreUtil { public static DublinCoreCatalog toCatalog(final OcDublinCore source) { final DublinCoreCatalog target = DublinCores.mkOpencastEpisode().getCatalog(); for (String a : source.getAbstract()) target.set(DublinCore.PROPERTY_ABSTRACT, a); for (String a : source.getAccessRights()) target.set(DublinCore.PROPERTY_ACCESS_RIGHTS, a); for (String a : source.getAccrualMethod()) target.set(DublinCore.PROPERTY_ACCRUAL_METHOD, a); for (String a : source.getAccrualPeriodicity()) target.set(DublinCore.PROPERTY_ACCRUAL_PERIODICITY, a); for (String a : source.getAccrualPolicy()) target.set(DublinCore.PROPERTY_ACCRUAL_POLICY, a); for (String a : source.getAlternative()) target.set(DublinCore.PROPERTY_ALTERNATIVE, a); for (String a : source.getAudience()) target.set(DublinCore.PROPERTY_AUDIENCE, a); for (String a : source.getAvailable()) target.set(DublinCore.PROPERTY_AVAILABLE, a); for (String a : source.getBibliographicCitation()) target.set(DublinCore.PROPERTY_BIBLIOGRAPHIC_CITATION, a); for (String a : source.getConformsTo()) target.set(DublinCore.PROPERTY_CONFORMS_TO, a); for (String a : source.getContributor()) target.set(DublinCore.PROPERTY_CONTRIBUTOR, a); for (String a : source.getCoverage()) target.set(DublinCore.PROPERTY_COVERAGE, a); target.set(DublinCore.PROPERTY_CREATED, encodeCreated(source.getCreated())); for (String a : source.getCreator()) target.set(DublinCore.PROPERTY_CREATOR, a); for (Date a : source.getDate()) target.set(DublinCore.PROPERTY_DATE, encodeDate(a)); for (Date a : source.getDateAccepted()) target.set(DublinCore.PROPERTY_DATE_ACCEPTED, encodeDateAccepted(a)); for (Date a : source.getDateCopyrighted()) target.set(DublinCore.PROPERTY_DATE_COPYRIGHTED, encodeDateCopyrighted(a)); for (Date a : source.getDateSubmitted()) target.set(DublinCore.PROPERTY_DATE_SUBMITTED, encodeDateSubmitted(a)); for (String a : source.getDescription()) target.set(DublinCore.PROPERTY_DESCRIPTION, a); for (String a : source.getEducationLevel()) target.set(DublinCore.PROPERTY_EDUCATION_LEVEL, a); for (Long a : source.getExtent()) target.set(DublinCore.PROPERTY_EXTENT, encodeExtent(a)); for (String a : source.getFormat()) target.set(DublinCore.PROPERTY_FORMAT, a); for (String a : source.getHasFormat()) target.set(DublinCore.PROPERTY_HAS_FORMAT, a); for (String a : source.getHasPart()) target.set(DublinCore.PROPERTY_HAS_PART, a); for (String a : source.getHasVersion()) target.set(DublinCore.PROPERTY_HAS_VERSION, a); for (String a : source.getIdentifier()) target.set(DublinCore.PROPERTY_IDENTIFIER, a); for (String a : source.getInstructionalMethod()) target.set(DublinCore.PROPERTY_INSTRUCTIONAL_METHOD, a); for (String a : source.getIsFormatOf()) target.set(DublinCore.PROPERTY_IS_FORMAT_OF, a); for (String a : source.getIsPartOf()) target.set(DublinCore.PROPERTY_IS_PART_OF, a); for (String a : source.getIsReferencedBy()) target.set(DublinCore.PROPERTY_IS_REFERENCED_BY, a); for (String a : source.getIsReplacedBy()) target.set(DublinCore.PROPERTY_IS_REPLACED_BY, a); for (String a : source.getIsRequiredBy()) target.set(DublinCore.PROPERTY_IS_REQUIRED_BY, a); for (String a : source.getIssued()) target.set(DublinCore.PROPERTY_ISSUED, a); for (String a : source.getIsVersionOf()) target.set(DublinCore.PROPERTY_IS_VERSION_OF, a); for (String a : source.getLanguage()) target.set(DublinCore.PROPERTY_LANGUAGE, a); for (String a : source.getLicense()) target.set(DublinCore.PROPERTY_LICENSE, a); for (String a : source.getMediator()) target.set(DublinCore.PROPERTY_MEDIATOR, a); for (String a : source.getMedium()) target.set(DublinCore.PROPERTY_MEDIUM, a); for (String a : source.getModified()) target.set(DublinCore.PROPERTY_MODIFIED, a); for (String a : source.getProvenance()) target.set(DublinCore.PROPERTY_PROVENANCE, a); for (String a : source.getPublisher()) target.set(DublinCore.PROPERTY_PUBLISHER, a); for (String a : source.getReferences()) target.set(DublinCore.PROPERTY_REFERENCES, a); for (String a : source.getRelation()) target.set(DublinCore.PROPERTY_RELATION, a); for (String a : source.getReplaces()) target.set(DublinCore.PROPERTY_REPLACES, a); for (String a : source.getRequires()) target.set(DublinCore.PROPERTY_REQUIRES, a); for (String a : source.getRights()) target.set(DublinCore.PROPERTY_RIGHTS, a); for (String a : source.getRightsHolder()) target.set(DublinCore.PROPERTY_RIGHTS_HOLDER, a); for (String a : source.getSource()) target.set(DublinCore.PROPERTY_SOURCE, a); for (String a : source.getSpatial()) target.set(DublinCore.PROPERTY_SPATIAL, a); for (String a : source.getSubject()) target.set(DublinCore.PROPERTY_SUBJECT, a); for (String a : source.getTableOfContents()) target.set(DublinCore.PROPERTY_TABLE_OF_CONTENTS, a); for (String a : source.getTemporal()) target.set(DublinCore.PROPERTY_TEMPORAL, a); target.set(DublinCore.PROPERTY_TITLE, source.getTitle()); for (String a : source.getType()) target.set(DublinCore.PROPERTY_TYPE, a); for (String a : source.getValid()) target.set(DublinCore.PROPERTY_VALID, a); return target; } private  OcDublinCoreUtil(); static DublinCoreValue encodeCreated(Date a); static DublinCoreValue encodeDate(Date a); static DublinCoreValue encodeDateAccepted(Date a); static DublinCoreValue encodeDateCopyrighted(Date a); static DublinCoreValue encodeDateSubmitted(Date a); static DublinCoreValue encodeExtent(Long a); static DublinCoreCatalog toCatalog(final OcDublinCore source); static JaxbOcDublinCore toJaxb(final OcDublinCore source); static final Function<Date, DublinCoreValue> encodeDate; static final Function<Date, DublinCoreValue> encodeDateAccepted; static final Function<Date, DublinCoreValue> encodeDateCopyrighted; static final Function<Date, DublinCoreValue> encodeDateSubmitted; }
@Test public void testToCatalog() throws Exception { final OcDublinCore source = randomDc(); final DublinCoreCatalog target = OcDublinCoreUtil.toCatalog(source); run(OcDublinCore.class, new OcDublinCore() { @Override public Option<String> getAbstract() { assertEquals("abstract copy", source.getAbstract().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ABSTRACT)); return null; } @Override public Option<String> getAccessRights() { assertEquals("accessRights copy", source.getAccessRights().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ACCESS_RIGHTS)); return null; } @Override public Option<String> getAccrualMethod() { assertEquals("accrualMethod copy", source.getAccrualMethod().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ACCRUAL_METHOD)); return null; } @Override public Option<String> getAccrualPeriodicity() { assertEquals("accrualPeriodicity copy", source.getAccrualPeriodicity().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ACCRUAL_PERIODICITY)); return null; } @Override public Option<String> getAccrualPolicy() { assertEquals("accrualPolicy copy", source.getAccrualPolicy().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ACCRUAL_POLICY)); return null; } @Override public Option<String> getAlternative() { assertEquals("alternative copy", source.getAlternative().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ALTERNATIVE)); return null; } @Override public Option<String> getAudience() { assertEquals("audience copy", source.getAudience().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_AUDIENCE)); return null; } @Override public Option<String> getAvailable() { assertEquals("available copy", source.getAvailable().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_AVAILABLE)); return null; } @Override public Option<String> getBibliographicCitation() { assertEquals("bibliographicCitation copy", source.getBibliographicCitation().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_BIBLIOGRAPHIC_CITATION)); return null; } @Override public Option<String> getConformsTo() { assertEquals("conformsTo copy", source.getConformsTo().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_CONFORMS_TO)); return null; } @Override public Option<String> getContributor() { assertEquals("contributor copy", source.getContributor().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_CONTRIBUTOR)); return null; } @Override public Option<String> getCoverage() { assertEquals("coverage copy", source.getCoverage().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_COVERAGE)); return null; } @Override public Date getCreated() { assertEquals("created copy", encodeCreated(source.getCreated()), target.getFirstVal(DublinCore.PROPERTY_CREATED)); return null; } @Override public Option<String> getCreator() { assertEquals("creator copy", source.getCreator().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_CREATOR)); return null; } @Override public Option<Date> getDate() { assertEquals("date copy", source.getDate().map(encodeDate).getOrElseNull(), target.getFirstVal(DublinCore.PROPERTY_DATE)); return null; } @Override public Option<Date> getDateAccepted() { assertEquals("dateAccepted copy", source.getDateAccepted().map(encodeDateAccepted).getOrElseNull(), target.getFirstVal(DublinCore.PROPERTY_DATE_ACCEPTED)); return null; } @Override public Option<Date> getDateCopyrighted() { assertEquals("dateCopyrighted copy", source.getDateCopyrighted().map(encodeDateCopyrighted).getOrElseNull(), target.getFirstVal(DublinCore.PROPERTY_DATE_COPYRIGHTED)); return null; } @Override public Option<Date> getDateSubmitted() { assertEquals("dateSubmitted copy", source.getDateSubmitted().map(encodeDateSubmitted).getOrElseNull(), target.getFirstVal(DublinCore.PROPERTY_DATE_SUBMITTED)); return null; } @Override public Option<String> getDescription() { assertEquals("description copy", source.getDescription().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_DESCRIPTION)); return null; } @Override public Option<String> getEducationLevel() { assertEquals("educationLevel copy", source.getEducationLevel().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_EDUCATION_LEVEL)); return null; } @Override public Option<Long> getExtent() { assertEquals("extent copy", source.getExtent().getOrElseNull(), (Long) Long.parseLong(target.getFirst(DublinCore.PROPERTY_EXTENT))); return null; } @Override public Option<String> getFormat() { assertEquals("format copy", source.getFormat().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_FORMAT)); return null; } @Override public Option<String> getHasFormat() { assertEquals("hasFormat copy", source.getHasFormat().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_HAS_FORMAT)); return null; } @Override public Option<String> getHasPart() { assertEquals("hasPart copy", source.getHasPart().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_HAS_PART)); return null; } @Override public Option<String> getHasVersion() { assertEquals("hasVersion copy", source.getHasVersion().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_HAS_VERSION)); return null; } @Override public Option<String> getIdentifier() { assertEquals("identifier copy", source.getIdentifier().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IDENTIFIER)); return null; } @Override public Option<String> getInstructionalMethod() { assertEquals("instructionalMethod copy", source.getInstructionalMethod().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_INSTRUCTIONAL_METHOD)); return null; } @Override public Option<String> getIsFormatOf() { assertEquals("isFormatOf copy", source.getIsFormatOf().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IS_FORMAT_OF)); return null; } @Override public Option<String> getIsPartOf() { assertEquals("isPartOf copy", source.getIsPartOf().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IS_PART_OF)); return null; } @Override public Option<String> getIsReferencedBy() { assertEquals("isReferencedBy copy", source.getIsReferencedBy().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IS_REFERENCED_BY)); return null; } @Override public Option<String> getIsReplacedBy() { assertEquals("isReplacedBy copy", source.getIsReplacedBy().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IS_REPLACED_BY)); return null; } @Override public Option<String> getIsRequiredBy() { assertEquals("isRequiredBy copy", source.getIsRequiredBy().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IS_REQUIRED_BY)); return null; } @Override public Option<String> getIssued() { assertEquals("issued copy", source.getIssued().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_ISSUED)); return null; } @Override public Option<String> getIsVersionOf() { assertEquals("isVersionOf copy", source.getIsVersionOf().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_IS_VERSION_OF)); return null; } @Override public Option<String> getLanguage() { assertEquals("language copy", source.getLanguage().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_LANGUAGE)); return null; } @Override public Option<String> getLicense() { assertEquals("license copy", source.getLicense().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_LICENSE)); return null; } @Override public Option<String> getMediator() { assertEquals("mediator copy", source.getMediator().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_MEDIATOR)); return null; } @Override public Option<String> getMedium() { assertEquals("medium copy", source.getMedium().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_MEDIUM)); return null; } @Override public Option<String> getModified() { assertEquals("modified copy", source.getModified().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_MODIFIED)); return null; } @Override public Option<String> getProvenance() { assertEquals("provenance copy", source.getProvenance().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_PROVENANCE)); return null; } @Override public Option<String> getPublisher() { assertEquals("publisher copy", source.getPublisher().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_PUBLISHER)); return null; } @Override public Option<String> getReferences() { assertEquals("references copy", source.getReferences().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_REFERENCES)); return null; } @Override public Option<String> getRelation() { assertEquals("relation copy", source.getRelation().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_RELATION)); return null; } @Override public Option<String> getReplaces() { assertEquals("replaces copy", source.getReplaces().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_REPLACES)); return null; } @Override public Option<String> getRequires() { assertEquals("requires copy", source.getRequires().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_REQUIRES)); return null; } @Override public Option<String> getRights() { assertEquals("rights copy", source.getRights().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_RIGHTS)); return null; } @Override public Option<String> getRightsHolder() { assertEquals("rightsHolder copy", source.getRightsHolder().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_RIGHTS_HOLDER)); return null; } @Override public Option<String> getSource() { assertEquals("source copy", source.getSource().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_SOURCE)); return null; } @Override public Option<String> getSpatial() { assertEquals("spatial copy", source.getSpatial().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_SPATIAL)); return null; } @Override public Option<String> getSubject() { assertEquals("subject copy", source.getSubject().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_SUBJECT)); return null; } @Override public Option<String> getTableOfContents() { assertEquals("tableOfContents copy", source.getTableOfContents().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_TABLE_OF_CONTENTS)); return null; } @Override public Option<String> getTemporal() { assertEquals("temporal copy", source.getTemporal().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_TEMPORAL)); return null; } @Override public String getTitle() { assertEquals("title copy", source.getTitle(), target.getFirst(DublinCore.PROPERTY_TITLE)); return null; } @Override public Option<String> getType() { assertEquals("type copy", source.getType().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_TYPE)); return null; } @Override public Option<String> getValid() { assertEquals("valid copy", source.getValid().getOrElseNull(), target.getFirst(DublinCore.PROPERTY_VALID)); return null; } }); }