@Test public void testWrite() { ModsDefinition mods = new ModsDefinition(); Monograph m = new Monograph(); m.setIdentifiers(Arrays.asList(new IdentifierMapper.IdentifierItem("type", "IDENTIFIER"))); m.setSigla("SIGLA"); m.setShelfLocators(ArrayMapper.toStringItemList(Arrays.asList("SHELF1", "SHELF2"))); m.setPublishers(Arrays.asList(new OriginInfoMapper.PublisherItem( null, OriginInfoMapper.PublisherItem.Role.PUBLISHER, "PUBLISHER[0]", "DATE[0]", "PLACETERM[0]"))); m.setPrinters(Arrays.asList(new OriginInfoMapper.PublisherItem( null, OriginInfoMapper.PublisherItem.Role.PRINTER, "PRINTER[1]", "DATE[1]", "PLACETERM[1]"))); m.setTitles(ArrayMapper.toStringItemList(Arrays.asList("MTITLE[0]"))); m.setSubtitles(ArrayMapper.toStringItemList(Arrays.asList("STITLE[0]"))); m.setAlternativeTitles(ArrayMapper.toStringItemList(Arrays.asList("ATITLE[0]"))); m.setKeyTitles(ArrayMapper.toStringItemList(Arrays.asList("KTITLE[0]"))); m.setAuthors(Arrays.asList(new NameMapper.NameItem("FamilyAuthor1", "GivenAuthor1", NameMapper.NameItem.NameRole.AUTHOR))); m.setContributors(Arrays.<NameMapper.NameItem>asList()); m.setLanguages(Arrays.asList(new LanguageMapper.LanguageItem(null, "cze"))); m.setClassifications(Arrays.asList(new ClassificationMapper.ClassificationPair("DDC", null, "UDC", null))); m.setKeywords(ArrayMapper.toStringItemList(Arrays.asList("TOPIC"))); m.setPhysicalDescriptions(Arrays.asList(new PhysicalDescriptionMapper.ExtentPair("EXTENT", null, "SIZE", null))); m.setPreservationStateOfArt("PRESERVATIONSTATEOFART"); m.setPreservationTreatment("PRESERVATIONTREATMENT"); m.setRecordOrigin("RECORDORIGIN"); m.setNote("NOTE"); MonographMapper instance = new MonographMapper(); instance.map(mods, m); System.out.println(ModsUtils.toXml(mods, true)); }
@Override public Monograph map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Monograph result = new Monograph(); 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())); } OriginInfoMapper originInfoMap = new OriginInfoMapper(); List<OriginInfoMapper.OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); 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(); List<ArrayItem> pdItems = physicalDescriptionMap.map(mods); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(pdItems)); result.setPreservationTreatment(PhysicalDescriptionMapper.getPreservationTreatment(pdItems)); result.setPreservationStateOfArt(PhysicalDescriptionMapper.getPreservationStateOfArt(pdItems)); 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; }
MonographMapper implements Mapper<Monograph> { @Override public Monograph map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Monograph result = new Monograph(); 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())); } OriginInfoMapper originInfoMap = new OriginInfoMapper(); List<OriginInfoMapper.OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); 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(); List<ArrayItem> pdItems = physicalDescriptionMap.map(mods); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(pdItems)); result.setPreservationTreatment(PhysicalDescriptionMapper.getPreservationTreatment(pdItems)); result.setPreservationStateOfArt(PhysicalDescriptionMapper.getPreservationStateOfArt(pdItems)); 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; } }
MonographMapper implements Mapper<Monograph> { @Override public Monograph map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Monograph result = new Monograph(); 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())); } OriginInfoMapper originInfoMap = new OriginInfoMapper(); List<OriginInfoMapper.OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); 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(); List<ArrayItem> pdItems = physicalDescriptionMap.map(mods); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(pdItems)); result.setPreservationTreatment(PhysicalDescriptionMapper.getPreservationTreatment(pdItems)); result.setPreservationStateOfArt(PhysicalDescriptionMapper.getPreservationStateOfArt(pdItems)); 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; }  }
MonographMapper implements Mapper<Monograph> { @Override public Monograph map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Monograph result = new Monograph(); 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())); } OriginInfoMapper originInfoMap = new OriginInfoMapper(); List<OriginInfoMapper.OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); 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(); List<ArrayItem> pdItems = physicalDescriptionMap.map(mods); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(pdItems)); result.setPreservationTreatment(PhysicalDescriptionMapper.getPreservationTreatment(pdItems)); result.setPreservationStateOfArt(PhysicalDescriptionMapper.getPreservationStateOfArt(pdItems)); 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 Monograph map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, Monograph monograph); }
MonographMapper implements Mapper<Monograph> { @Override public Monograph map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Monograph result = new Monograph(); 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())); } OriginInfoMapper originInfoMap = new OriginInfoMapper(); List<OriginInfoMapper.OriginInfoItem> origins = originInfoMap.map(mods); result.setPublishers(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PUBLISHER)); result.setPrinters(OriginInfoMapper.filter(origins, true, PublisherItem.Role.PRINTER)); 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(); List<ArrayItem> pdItems = physicalDescriptionMap.map(mods); result.setPhysicalDescriptions(PhysicalDescriptionMapper.toPairs(pdItems)); result.setPreservationTreatment(PhysicalDescriptionMapper.getPreservationTreatment(pdItems)); result.setPreservationStateOfArt(PhysicalDescriptionMapper.getPreservationStateOfArt(pdItems)); 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 Monograph map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, Monograph monograph);  }