Пример #1
0
    @Override
    public JAXBElement<?> map(ArrayItem item, JAXBElement<?> origin) {
      JAXBElement<?> source = origin;
      if (origin == null) {
        if (item instanceof ExtentItem) {
          source = factory.createPhysicalDescriptionTypeExtent(null);
        } else if (item instanceof NoteItem) {
          NoteItem noteItem = (NoteItem) item;
          NoteType noteType = factory.createNoteType();
          noteType.setAtType(noteItem.getType());
          source = factory.createPhysicalDescriptionTypeNote(noteType);
        } else {
          throw new IllegalStateException("unsupported array item: " + item.getClass());
        }
      }

      if (item instanceof ExtentItem) {
        ExtentItem extentItem = (ExtentItem) item;
        JAXBElement<String> extentSource = (JAXBElement<String>) source;
        // delete with empty string to prevent XML nil
        extentSource.setValue(extentItem.getValue() != null ? extentItem.getValue() : "");
      } else if (item instanceof NoteItem && !((NoteItem) item).ignore) {
        NoteItem noteItem = (NoteItem) item;
        NoteType noteType = (NoteType) source.getValue();
        noteType.setValue(noteItem.getValue());
      }
      return source;
    }
Пример #2
0
 @Test
 public void testGetKeywords() {
   ModsType mods = new ModsType();
   SubjectType subject = new SubjectType();
   mods.getModsGroup().add(subject);
   subject.getTopicOrGeographicOrTemporal().add(factory.createSubjectTypeTopic("keyword[0]"));
   subject.getTopicOrGeographicOrTemporal().add(factory.createSubjectTypeTopic("keyword[1]"));
   subject.getTopicOrGeographicOrTemporal().add(factory.createSubjectTypeGenre("genre[2]"));
   subject.getTopicOrGeographicOrTemporal().add(factory.createSubjectTypeTopic("keyword[3]"));
   SubjectMapper instance = new SubjectMapper(mods);
   List<String> result = instance.getKeywords();
   List<String> expect = Arrays.asList("keyword[0]", "keyword[1]", "keyword[3]");
   assertThat(result, Is.is(expect));
 }