@Test public void testRead() { ModsDefinition mods = ModsUtils.unmarshal(XML, ModsDefinition.class); PeriodicalMapper instance = new PeriodicalMapper(); Periodical result = instance.map(mods); Periodical expected = new Periodical(); expected.setIdentifiers(Arrays.asList(new IdentifierMapper.IdentifierItem(0, "type", "IDENTIFIER"))); expected.setSigla("SIGLA"); expected.setShelfLocators(ArrayMapper.toStringItemList(Arrays.asList("SHELF1", "SHELF2"))); expected.setPeriodicities(ArrayMapper.toStringItemList(Arrays.asList("daily"))); expected.setPublishers(Arrays.asList(new OriginInfoMapper.PublisherItem( 0, OriginInfoMapper.PublisherItem.Role.PUBLISHER, "PUBLISHER[0]", "DATE[0]", "PLACETERM[0]"))); expected.setPrinters(Arrays.asList(new OriginInfoMapper.PublisherItem( 1, OriginInfoMapper.PublisherItem.Role.PRINTER, "PRINTER[1]", "DATE[1]", "PLACETERM[1]"))); expected.setTitles(ArrayMapper.toStringItemList(Arrays.asList("MTITLE[0]"))); expected.setSubtitles(ArrayMapper.toStringItemList(Arrays.asList("STITLE[0]"))); expected.setAlternativeTitles(ArrayMapper.toStringItemList(Arrays.asList("ATITLE[0]"))); expected.setKeyTitles(ArrayMapper.toStringItemList(Arrays.asList("KTITLE[0]"))); expected.setAuthors(Arrays.asList(new NameMapper.NameItem(0, "FamilyAuthor1", "GivenAuthor1", NameMapper.NameItem.NameRole.AUTHOR))); expected.setContributors(Arrays.<NameMapper.NameItem>asList()); expected.setLanguages(Arrays.asList(new LanguageMapper.LanguageItem(0, "cze"))); expected.setClassifications(Arrays.asList(new ClassificationMapper.ClassificationPair("DDC", 0, "UDC", 1))); expected.setKeywords(ArrayMapper.toStringItemList(Arrays.asList("TOPIC"))); expected.setPhysicalDescriptions(Arrays.asList(new PhysicalDescriptionMapper.ExtentPair("EXTENT", 0, "SIZE", 1))); expected.setRecordOrigin("RECORDORIGIN"); expected.setNote("NOTE"); assertPeriodicalEquals(expected, result); assertEquals(expected, result); }
@Override public Periodical map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Periodical result = new Periodical(); IdentifierMapper identMap = new IdentifierMapper(); result.setIdentifiers(identMap.map(mods)); LocationDefinition location = nlookup.getLocation(false); if (location != null) { PhysicalLocationDefinition physicalLocation = nlookup.getPhysicalLocation(false); result.setSigla(physicalLocation == null ? null : physicalLocation.getValue()); result.setShelfLocators(ArrayMapper.toStringPlusLanguageItemList(location.getShelfLocator())); } List<OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); result.setPeriodicities(ArrayMapper.toStringItemList(OriginInfoMapper.getFreqencies(origins))); TitleInfoMapper titleMap = new TitleInfoMapper(mods); result.setTitles(ArrayMapper.toStringItemList(titleMap.getTitles())); result.setSubtitles(ArrayMapper.toStringItemList(titleMap.getSubtitles())); result.setAlternativeTitles(ArrayMapper.toStringItemList(titleMap.getAlternativeTitles())); result.setKeyTitles(ArrayMapper.toStringItemList(titleMap.getKeyTitles())); NameMapper nameMap = new NameMapper(); List<NameItem> allNames = nameMap.map(mods); result.setAuthors(NameMapper.filter(allNames, true, NameItem.NameRole.AUTHOR)); result.setContributors(NameMapper.filter(allNames, true, NameItem.NameRole.CONTRIBUTOR)); LanguageMapper languageMap = new LanguageMapper(); result.setLanguages(languageMap.map(mods)); ClassificationMapper classificationMap = new ClassificationMapper(); result.setClassifications(classificationMap.mapPairs(mods)); SubjectMapper subjectMap = new SubjectMapper(mods); result.setKeywords(ArrayMapper.toStringItemList(subjectMap.getKeywords())); PhysicalDescriptionMapper physicalDescriptionMap = new PhysicalDescriptionMapper(); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(physicalDescriptionMap.map(mods))); StringPlusLanguage recordOrigin = nlookup.getRecordOrigin(false); result.setRecordOrigin(recordOrigin == null ? null : recordOrigin.getValue()); NoteDefinition note = nlookup.getNote(false); result.setNote(note == null ? null : note.getValue()); return result; }
PeriodicalMapper implements Mapping.Mapper<Periodical> { @Override public Periodical map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Periodical result = new Periodical(); IdentifierMapper identMap = new IdentifierMapper(); result.setIdentifiers(identMap.map(mods)); LocationDefinition location = nlookup.getLocation(false); if (location != null) { PhysicalLocationDefinition physicalLocation = nlookup.getPhysicalLocation(false); result.setSigla(physicalLocation == null ? null : physicalLocation.getValue()); result.setShelfLocators(ArrayMapper.toStringPlusLanguageItemList(location.getShelfLocator())); } List<OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); result.setPeriodicities(ArrayMapper.toStringItemList(OriginInfoMapper.getFreqencies(origins))); TitleInfoMapper titleMap = new TitleInfoMapper(mods); result.setTitles(ArrayMapper.toStringItemList(titleMap.getTitles())); result.setSubtitles(ArrayMapper.toStringItemList(titleMap.getSubtitles())); result.setAlternativeTitles(ArrayMapper.toStringItemList(titleMap.getAlternativeTitles())); result.setKeyTitles(ArrayMapper.toStringItemList(titleMap.getKeyTitles())); NameMapper nameMap = new NameMapper(); List<NameItem> allNames = nameMap.map(mods); result.setAuthors(NameMapper.filter(allNames, true, NameItem.NameRole.AUTHOR)); result.setContributors(NameMapper.filter(allNames, true, NameItem.NameRole.CONTRIBUTOR)); LanguageMapper languageMap = new LanguageMapper(); result.setLanguages(languageMap.map(mods)); ClassificationMapper classificationMap = new ClassificationMapper(); result.setClassifications(classificationMap.mapPairs(mods)); SubjectMapper subjectMap = new SubjectMapper(mods); result.setKeywords(ArrayMapper.toStringItemList(subjectMap.getKeywords())); PhysicalDescriptionMapper physicalDescriptionMap = new PhysicalDescriptionMapper(); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(physicalDescriptionMap.map(mods))); StringPlusLanguage recordOrigin = nlookup.getRecordOrigin(false); result.setRecordOrigin(recordOrigin == null ? null : recordOrigin.getValue()); NoteDefinition note = nlookup.getNote(false); result.setNote(note == null ? null : note.getValue()); return result; } }
PeriodicalMapper implements Mapping.Mapper<Periodical> { @Override public Periodical map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Periodical result = new Periodical(); IdentifierMapper identMap = new IdentifierMapper(); result.setIdentifiers(identMap.map(mods)); LocationDefinition location = nlookup.getLocation(false); if (location != null) { PhysicalLocationDefinition physicalLocation = nlookup.getPhysicalLocation(false); result.setSigla(physicalLocation == null ? null : physicalLocation.getValue()); result.setShelfLocators(ArrayMapper.toStringPlusLanguageItemList(location.getShelfLocator())); } List<OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); result.setPeriodicities(ArrayMapper.toStringItemList(OriginInfoMapper.getFreqencies(origins))); TitleInfoMapper titleMap = new TitleInfoMapper(mods); result.setTitles(ArrayMapper.toStringItemList(titleMap.getTitles())); result.setSubtitles(ArrayMapper.toStringItemList(titleMap.getSubtitles())); result.setAlternativeTitles(ArrayMapper.toStringItemList(titleMap.getAlternativeTitles())); result.setKeyTitles(ArrayMapper.toStringItemList(titleMap.getKeyTitles())); NameMapper nameMap = new NameMapper(); List<NameItem> allNames = nameMap.map(mods); result.setAuthors(NameMapper.filter(allNames, true, NameItem.NameRole.AUTHOR)); result.setContributors(NameMapper.filter(allNames, true, NameItem.NameRole.CONTRIBUTOR)); LanguageMapper languageMap = new LanguageMapper(); result.setLanguages(languageMap.map(mods)); ClassificationMapper classificationMap = new ClassificationMapper(); result.setClassifications(classificationMap.mapPairs(mods)); SubjectMapper subjectMap = new SubjectMapper(mods); result.setKeywords(ArrayMapper.toStringItemList(subjectMap.getKeywords())); PhysicalDescriptionMapper physicalDescriptionMap = new PhysicalDescriptionMapper(); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(physicalDescriptionMap.map(mods))); StringPlusLanguage recordOrigin = nlookup.getRecordOrigin(false); result.setRecordOrigin(recordOrigin == null ? null : recordOrigin.getValue()); NoteDefinition note = nlookup.getNote(false); result.setNote(note == null ? null : note.getValue()); return result; }  }
PeriodicalMapper implements Mapping.Mapper<Periodical> { @Override public Periodical map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Periodical result = new Periodical(); IdentifierMapper identMap = new IdentifierMapper(); result.setIdentifiers(identMap.map(mods)); LocationDefinition location = nlookup.getLocation(false); if (location != null) { PhysicalLocationDefinition physicalLocation = nlookup.getPhysicalLocation(false); result.setSigla(physicalLocation == null ? null : physicalLocation.getValue()); result.setShelfLocators(ArrayMapper.toStringPlusLanguageItemList(location.getShelfLocator())); } List<OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); result.setPeriodicities(ArrayMapper.toStringItemList(OriginInfoMapper.getFreqencies(origins))); TitleInfoMapper titleMap = new TitleInfoMapper(mods); result.setTitles(ArrayMapper.toStringItemList(titleMap.getTitles())); result.setSubtitles(ArrayMapper.toStringItemList(titleMap.getSubtitles())); result.setAlternativeTitles(ArrayMapper.toStringItemList(titleMap.getAlternativeTitles())); result.setKeyTitles(ArrayMapper.toStringItemList(titleMap.getKeyTitles())); NameMapper nameMap = new NameMapper(); List<NameItem> allNames = nameMap.map(mods); result.setAuthors(NameMapper.filter(allNames, true, NameItem.NameRole.AUTHOR)); result.setContributors(NameMapper.filter(allNames, true, NameItem.NameRole.CONTRIBUTOR)); LanguageMapper languageMap = new LanguageMapper(); result.setLanguages(languageMap.map(mods)); ClassificationMapper classificationMap = new ClassificationMapper(); result.setClassifications(classificationMap.mapPairs(mods)); SubjectMapper subjectMap = new SubjectMapper(mods); result.setKeywords(ArrayMapper.toStringItemList(subjectMap.getKeywords())); PhysicalDescriptionMapper physicalDescriptionMap = new PhysicalDescriptionMapper(); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(physicalDescriptionMap.map(mods))); StringPlusLanguage recordOrigin = nlookup.getRecordOrigin(false); result.setRecordOrigin(recordOrigin == null ? null : recordOrigin.getValue()); NoteDefinition note = nlookup.getNote(false); result.setNote(note == null ? null : note.getValue()); return result; }  @Override Periodical map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, Periodical periodical); }
PeriodicalMapper implements Mapping.Mapper<Periodical> { @Override public Periodical map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Periodical result = new Periodical(); IdentifierMapper identMap = new IdentifierMapper(); result.setIdentifiers(identMap.map(mods)); LocationDefinition location = nlookup.getLocation(false); if (location != null) { PhysicalLocationDefinition physicalLocation = nlookup.getPhysicalLocation(false); result.setSigla(physicalLocation == null ? null : physicalLocation.getValue()); result.setShelfLocators(ArrayMapper.toStringPlusLanguageItemList(location.getShelfLocator())); } List<OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); result.setPeriodicities(ArrayMapper.toStringItemList(OriginInfoMapper.getFreqencies(origins))); TitleInfoMapper titleMap = new TitleInfoMapper(mods); result.setTitles(ArrayMapper.toStringItemList(titleMap.getTitles())); result.setSubtitles(ArrayMapper.toStringItemList(titleMap.getSubtitles())); result.setAlternativeTitles(ArrayMapper.toStringItemList(titleMap.getAlternativeTitles())); result.setKeyTitles(ArrayMapper.toStringItemList(titleMap.getKeyTitles())); NameMapper nameMap = new NameMapper(); List<NameItem> allNames = nameMap.map(mods); result.setAuthors(NameMapper.filter(allNames, true, NameItem.NameRole.AUTHOR)); result.setContributors(NameMapper.filter(allNames, true, NameItem.NameRole.CONTRIBUTOR)); LanguageMapper languageMap = new LanguageMapper(); result.setLanguages(languageMap.map(mods)); ClassificationMapper classificationMap = new ClassificationMapper(); result.setClassifications(classificationMap.mapPairs(mods)); SubjectMapper subjectMap = new SubjectMapper(mods); result.setKeywords(ArrayMapper.toStringItemList(subjectMap.getKeywords())); PhysicalDescriptionMapper physicalDescriptionMap = new PhysicalDescriptionMapper(); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(physicalDescriptionMap.map(mods))); StringPlusLanguage recordOrigin = nlookup.getRecordOrigin(false); result.setRecordOrigin(recordOrigin == null ? null : recordOrigin.getValue()); NoteDefinition note = nlookup.getNote(false); result.setNote(note == null ? null : note.getValue()); return result; }  @Override Periodical map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, Periodical periodical);  }