Changeset 5463


Ignore:
Timestamp:
07/09/14 07:46:46 (10 years ago)
Author:
Twan Goosen
Message:

Fixed CMDI marshalling issues with missing optional fields in VC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/service/impl/VirtualCollectionCMDICreatorImpl.java

    r5427 r5463  
    145145        virtualCollection.setCreationDate(getCreationDate(vc));
    146146        virtualCollection.setStatus(getStatus(vc));
    147         virtualCollection.setReproducability(getReproducability(vc));
    148147        virtualCollection.setPurpose(getPurpose(vc));
    149148        virtualCollection.getCreator().add(getCreator(vc));
    150149        virtualCollection.setGeneratedBy(new CMD.Components.VirtualCollection.GeneratedBy());
     150        virtualCollection.setReproducability(getReproducability(vc));
    151151
    152152        if (vc.getReproducibilityNotice() != null) {
     
    167167
    168168    private ComplextypeStatus1 getStatus(VirtualCollection vc) {
     169        // status is a mandatory field
    169170        final ComplextypeStatus1 status = new ComplextypeStatus1();
    170171        switch (vc.getState()) {
     
    185186
    186187    private ComplextypeReproducability1 getReproducability(VirtualCollection vc) {
    187         final ComplextypeReproducability1 reproducability = new ComplextypeReproducability1();
    188         if (vc.getReproducibility() != null) {
     188        if (vc.getReproducibility() == null) {
     189            return null;
     190        } else {
     191            final ComplextypeReproducability1 reproducability = new ComplextypeReproducability1();
    189192            switch (vc.getReproducibility()) {
    190193                //TODO: better mapping
     
    199202                    break;
    200203            }
    201         }
    202         return reproducability;
     204            return reproducability;
     205        }
    203206    }
    204207
    205208    private ComplextypePurpose1 getPurpose(VirtualCollection vc) {
    206         final ComplextypePurpose1 purpose = new ComplextypePurpose1();
    207         if (vc.getPurpose() != null) {
     209        if (vc.getPurpose() == null) {
     210            return null;
     211        } else {
     212            final ComplextypePurpose1 purpose = new ComplextypePurpose1();
    208213            switch (vc.getPurpose()) {
    209214                case FUTURE_USE:
     
    220225                    break;
    221226            }
    222         }
    223         return purpose;
     227            return purpose;
     228        }
    224229    }
    225230
    226231    private CMD.Components.VirtualCollection.Creator getCreator(VirtualCollection vc) {
    227         final CMD.Components.VirtualCollection.Creator creator = new CMD.Components.VirtualCollection.Creator();
    228         if (vc.getCreators().size() > 0) {
     232        if (vc.getCreators().isEmpty()) {
     233            return null;
     234        } else {
     235            final CMD.Components.VirtualCollection.Creator creator = new CMD.Components.VirtualCollection.Creator();
    229236            final Creator vcCreator = vc.getCreators().get(0);
    230237
     238            // name/creator is a mandatory field
    231239            final CMD.Components.VirtualCollection.Creator.Name name = new CMD.Components.VirtualCollection.Creator.Name();
    232240            name.setValue(vcCreator.getPerson());
    233241            creator.setName(name);
    234242
    235             final Email email = new Email();
    236             email.setValue(vcCreator.getEMail());
    237             creator.setEmail(email);
    238 
    239             final Organisation organisation = new Organisation();
    240             organisation.setValue(vcCreator.getOrganisation());
    241             creator.setOrganisation(organisation);
    242         }
    243         return creator;
     243            if (vcCreator.getEMail() != null) {
     244                final Email email = new Email();
     245                email.setValue(vcCreator.getEMail());
     246                creator.setEmail(email);
     247            }
     248
     249            if (vcCreator.getOrganisation() != null) {
     250                final Organisation organisation = new Organisation();
     251                organisation.setValue(vcCreator.getOrganisation());
     252                creator.setOrganisation(organisation);
     253            }
     254            return creator;
     255        }
    244256    }
    245257}
Note: See TracChangeset for help on using the changeset viewer.