@Test public void testCreateDc() { String xml = "<mods version='3.5' xmlns='http: + "<titleInfo>" + "<nonSort>NS1</nonSort><title>T1</title><subTitle>S1</subTitle><partName>PNam1</partName><partNumber>PNum1</partNumber>" + "</titleInfo>" + "<titleInfo>" + "<title>T2</title><subTitle>S2</subTitle>" + "</titleInfo>" + "<name usage = 'primary' type='personal'>" + "<namePart type='family'>Novotny</namePart>" + "<namePart type='given'>Tomas</namePart>" + "<namePart type='date'>12.9.1999</namePart>" + "<role><roleTerm>cre</roleTerm></role></name>" + "</mods>"; ModsDefinition mods = ModsUtils.unmarshalModsType(new StreamSource(new StringReader(xml))); NdkPeriodicalMapper mapper = new NdkPeriodicalMapper(); Context ctx = new Context("uuid:testId"); OaiDcType result = mapper.createDc(mods, ctx); assertEquals("NS1 T1: S1", result.getTitles().get(0).getValue()); assertEquals("T2: S2", result.getTitles().get(1).getValue()); assertEquals("PNum1", result.getDescriptions().get(0).getValue()); assertEquals("PNam1", result.getDescriptions().get(1).getValue()); assertEquals("Novotny, Tomas, 12.9.1999", result.getCreators().get(0).getValue()); }
@Override protected OaiDcType createDc(ModsDefinition mods, Context ctx) { OaiDcType dc = super.createDc(mods, ctx); for (TitleInfoDefinition titleInfo : mods.getTitleInfo()) { StringBuilder title = new StringBuilder(); addNonSort(title, titleInfo); addTitle(title, titleInfo); addSubTitle(title, titleInfo); addElementType(dc.getTitles(), title.toString()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartNumber()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartName()); } addName(mods.getName(), dc.getCreators()); addElementType(dc.getTypes(), getDcType()); addOriginInfo(mods.getOriginInfo(), dc); addLanguage(mods.getLanguage(), dc); for (PhysicalDescriptionDefinition physicalDesc : mods.getPhysicalDescription()) { for (FormDefinition form : physicalDesc.getForm()) { addElementType(dc.getFormats(), form.getValue()); } for (Extent extent : physicalDesc.getExtent()) { addElementType(dc.getFormats(), extent.getValue()); } } addStringPlusLanguage(dc.getDescriptions(), mods.getAbstract()); addStringPlusLanguage(dc.getDescriptions(), mods.getNote()); for (SubjectDefinition subject : mods.getSubject()) { addStringPlusLanguage(dc.getSubjects(), subject.getTopic()); addStringPlusLanguage(dc.getSubjects(), subject.getGeographic()); addStringPlusLanguage(dc.getSubjects(), subject.getTemporal()); for (SubjectNameDefinition subjectName : subject.getName()) { addStringPlusLanguage(dc.getSubjects(), subjectName.getNamePart()); } } addStringPlusLanguage(dc.getSubjects(), mods.getClassification()); for (LocationDefinition location : mods.getLocation()) { for (UrlDefinition url : location.getUrl()) { addElementType(dc.getSources(), url.getValue()); } addStringPlusLanguage(dc.getSources(), location.getPhysicalLocation()); addStringPlusLanguage(dc.getSources(), location.getShelfLocator()); } return dc; }
NdkPeriodicalMapper extends RdaNdkMapper { @Override protected OaiDcType createDc(ModsDefinition mods, Context ctx) { OaiDcType dc = super.createDc(mods, ctx); for (TitleInfoDefinition titleInfo : mods.getTitleInfo()) { StringBuilder title = new StringBuilder(); addNonSort(title, titleInfo); addTitle(title, titleInfo); addSubTitle(title, titleInfo); addElementType(dc.getTitles(), title.toString()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartNumber()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartName()); } addName(mods.getName(), dc.getCreators()); addElementType(dc.getTypes(), getDcType()); addOriginInfo(mods.getOriginInfo(), dc); addLanguage(mods.getLanguage(), dc); for (PhysicalDescriptionDefinition physicalDesc : mods.getPhysicalDescription()) { for (FormDefinition form : physicalDesc.getForm()) { addElementType(dc.getFormats(), form.getValue()); } for (Extent extent : physicalDesc.getExtent()) { addElementType(dc.getFormats(), extent.getValue()); } } addStringPlusLanguage(dc.getDescriptions(), mods.getAbstract()); addStringPlusLanguage(dc.getDescriptions(), mods.getNote()); for (SubjectDefinition subject : mods.getSubject()) { addStringPlusLanguage(dc.getSubjects(), subject.getTopic()); addStringPlusLanguage(dc.getSubjects(), subject.getGeographic()); addStringPlusLanguage(dc.getSubjects(), subject.getTemporal()); for (SubjectNameDefinition subjectName : subject.getName()) { addStringPlusLanguage(dc.getSubjects(), subjectName.getNamePart()); } } addStringPlusLanguage(dc.getSubjects(), mods.getClassification()); for (LocationDefinition location : mods.getLocation()) { for (UrlDefinition url : location.getUrl()) { addElementType(dc.getSources(), url.getValue()); } addStringPlusLanguage(dc.getSources(), location.getPhysicalLocation()); addStringPlusLanguage(dc.getSources(), location.getShelfLocator()); } return dc; } }
NdkPeriodicalMapper extends RdaNdkMapper { @Override protected OaiDcType createDc(ModsDefinition mods, Context ctx) { OaiDcType dc = super.createDc(mods, ctx); for (TitleInfoDefinition titleInfo : mods.getTitleInfo()) { StringBuilder title = new StringBuilder(); addNonSort(title, titleInfo); addTitle(title, titleInfo); addSubTitle(title, titleInfo); addElementType(dc.getTitles(), title.toString()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartNumber()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartName()); } addName(mods.getName(), dc.getCreators()); addElementType(dc.getTypes(), getDcType()); addOriginInfo(mods.getOriginInfo(), dc); addLanguage(mods.getLanguage(), dc); for (PhysicalDescriptionDefinition physicalDesc : mods.getPhysicalDescription()) { for (FormDefinition form : physicalDesc.getForm()) { addElementType(dc.getFormats(), form.getValue()); } for (Extent extent : physicalDesc.getExtent()) { addElementType(dc.getFormats(), extent.getValue()); } } addStringPlusLanguage(dc.getDescriptions(), mods.getAbstract()); addStringPlusLanguage(dc.getDescriptions(), mods.getNote()); for (SubjectDefinition subject : mods.getSubject()) { addStringPlusLanguage(dc.getSubjects(), subject.getTopic()); addStringPlusLanguage(dc.getSubjects(), subject.getGeographic()); addStringPlusLanguage(dc.getSubjects(), subject.getTemporal()); for (SubjectNameDefinition subjectName : subject.getName()) { addStringPlusLanguage(dc.getSubjects(), subjectName.getNamePart()); } } addStringPlusLanguage(dc.getSubjects(), mods.getClassification()); for (LocationDefinition location : mods.getLocation()) { for (UrlDefinition url : location.getUrl()) { addElementType(dc.getSources(), url.getValue()); } addStringPlusLanguage(dc.getSources(), location.getPhysicalLocation()); addStringPlusLanguage(dc.getSources(), location.getShelfLocator()); } return dc; }  }
NdkPeriodicalMapper extends RdaNdkMapper { @Override protected OaiDcType createDc(ModsDefinition mods, Context ctx) { OaiDcType dc = super.createDc(mods, ctx); for (TitleInfoDefinition titleInfo : mods.getTitleInfo()) { StringBuilder title = new StringBuilder(); addNonSort(title, titleInfo); addTitle(title, titleInfo); addSubTitle(title, titleInfo); addElementType(dc.getTitles(), title.toString()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartNumber()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartName()); } addName(mods.getName(), dc.getCreators()); addElementType(dc.getTypes(), getDcType()); addOriginInfo(mods.getOriginInfo(), dc); addLanguage(mods.getLanguage(), dc); for (PhysicalDescriptionDefinition physicalDesc : mods.getPhysicalDescription()) { for (FormDefinition form : physicalDesc.getForm()) { addElementType(dc.getFormats(), form.getValue()); } for (Extent extent : physicalDesc.getExtent()) { addElementType(dc.getFormats(), extent.getValue()); } } addStringPlusLanguage(dc.getDescriptions(), mods.getAbstract()); addStringPlusLanguage(dc.getDescriptions(), mods.getNote()); for (SubjectDefinition subject : mods.getSubject()) { addStringPlusLanguage(dc.getSubjects(), subject.getTopic()); addStringPlusLanguage(dc.getSubjects(), subject.getGeographic()); addStringPlusLanguage(dc.getSubjects(), subject.getTemporal()); for (SubjectNameDefinition subjectName : subject.getName()) { addStringPlusLanguage(dc.getSubjects(), subjectName.getNamePart()); } } addStringPlusLanguage(dc.getSubjects(), mods.getClassification()); for (LocationDefinition location : mods.getLocation()) { for (UrlDefinition url : location.getUrl()) { addElementType(dc.getSources(), url.getValue()); } addStringPlusLanguage(dc.getSources(), location.getPhysicalLocation()); addStringPlusLanguage(dc.getSources(), location.getShelfLocator()); } return dc; }  @Override void createMods(ModsDefinition mods, Context ctx); }
NdkPeriodicalMapper extends RdaNdkMapper { @Override protected OaiDcType createDc(ModsDefinition mods, Context ctx) { OaiDcType dc = super.createDc(mods, ctx); for (TitleInfoDefinition titleInfo : mods.getTitleInfo()) { StringBuilder title = new StringBuilder(); addNonSort(title, titleInfo); addTitle(title, titleInfo); addSubTitle(title, titleInfo); addElementType(dc.getTitles(), title.toString()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartNumber()); addStringPlusLanguage(dc.getDescriptions(), titleInfo.getPartName()); } addName(mods.getName(), dc.getCreators()); addElementType(dc.getTypes(), getDcType()); addOriginInfo(mods.getOriginInfo(), dc); addLanguage(mods.getLanguage(), dc); for (PhysicalDescriptionDefinition physicalDesc : mods.getPhysicalDescription()) { for (FormDefinition form : physicalDesc.getForm()) { addElementType(dc.getFormats(), form.getValue()); } for (Extent extent : physicalDesc.getExtent()) { addElementType(dc.getFormats(), extent.getValue()); } } addStringPlusLanguage(dc.getDescriptions(), mods.getAbstract()); addStringPlusLanguage(dc.getDescriptions(), mods.getNote()); for (SubjectDefinition subject : mods.getSubject()) { addStringPlusLanguage(dc.getSubjects(), subject.getTopic()); addStringPlusLanguage(dc.getSubjects(), subject.getGeographic()); addStringPlusLanguage(dc.getSubjects(), subject.getTemporal()); for (SubjectNameDefinition subjectName : subject.getName()) { addStringPlusLanguage(dc.getSubjects(), subjectName.getNamePart()); } } addStringPlusLanguage(dc.getSubjects(), mods.getClassification()); for (LocationDefinition location : mods.getLocation()) { for (UrlDefinition url : location.getUrl()) { addElementType(dc.getSources(), url.getValue()); } addStringPlusLanguage(dc.getSources(), location.getPhysicalLocation()); addStringPlusLanguage(dc.getSources(), location.getShelfLocator()); } return dc; }  @Override void createMods(ModsDefinition mods, Context ctx);  }