Project

General

Profile

« Previous | Next » 

Revision 91e53109

Added by Andreas Kohlbecker about 3 years ago

ref #9290 SpecimenTypeDesignationEditor now using designation reference correctly

View differences:

src/main/java/eu/etaxonomy/cdm/service/ISpecimenTypeDesignationWorkingSetService.java
23 23
 */
24 24
public interface ISpecimenTypeDesignationWorkingSetService {
25 25

  
26
    public SpecimenTypeDesignationWorkingSetDTO<Registration> create(UUID registrationUuid, UUID publicationUuid, UUID typifiedNameUuid);
26
    public SpecimenTypeDesignationWorkingSetDTO<Registration> create(UUID registrationUuid, UUID typifiedNameUuid);
27 27

  
28 28
    /**
29 29
     * @param id the CDM Entity id
src/main/java/eu/etaxonomy/cdm/service/SpecimenTypeDesignationWorkingSetServiceImpl.java
43 43
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
44 44
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
45 45
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
46
import eu.etaxonomy.cdm.model.reference.Reference;
47 46
import eu.etaxonomy.cdm.ref.TypedEntityReference;
48 47
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO;
49 48
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO;
......
86 85
    CdmRepository repo;
87 86

  
88 87
    @Override
89
    public SpecimenTypeDesignationWorkingSetDTO<Registration> create(UUID registrationUuid, UUID publicationUuid, UUID typifiedNameUuid) {
88
    public SpecimenTypeDesignationWorkingSetDTO<Registration> create(UUID registrationUuid, UUID typifiedNameUuid) {
90 89
        FieldUnit newfieldUnit = FieldUnit.NewInstance();
91 90
        Registration reg = repo.getRegistrationService().load(registrationUuid, RegistrationWorkingSetService.REGISTRATION_DTO_INIT_STRATEGY.getPropertyPaths());
92 91
        if(reg == null){
......
94 93
            reg.setUuid(registrationUuid);
95 94
        }
96 95
        TaxonName typifiedName = repo.getNameService().load(typifiedNameUuid, TAXON_NAME_INIT_STRATEGY);
97
        Reference citation = repo.getReferenceService().load(publicationUuid, Arrays.asList("$"));
98
        SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto = new SpecimenTypeDesignationWorkingSetDTO<>(reg, newfieldUnit, citation, typifiedName);
96
        SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto = new SpecimenTypeDesignationWorkingSetDTO<>(reg, newfieldUnit, typifiedName);
99 97
        return workingSetDto;
100 98
    }
101 99

  
......
120 118
        VersionableEntity baseEntity = regDTO.getTypeDesignationWorkingSet(baseEntityReference).getBaseEntity();
121 119

  
122 120
        SpecimenTypeDesignationWorkingSetDTO<Registration> dto = new SpecimenTypeDesignationWorkingSetDTO<Registration>(regDTO.registration(),
123
                baseEntity, specimenTypeDesignations, regDTO.getCitation(), regDTO.typifiedName());
121
                baseEntity, specimenTypeDesignations, regDTO.typifiedName());
124 122
        return dto;
125 123
    }
126 124

  
......
137 135
            FieldUnit fieldUnit = FieldUnit.NewInstance();
138 136
            GatheringEvent gatheringEvent = GatheringEvent.NewInstance();
139 137
            fieldUnit.setGatheringEvent(gatheringEvent);
140
            fieldUnit = (FieldUnit) repo.getOccurrenceService().save(fieldUnit);
138
            fieldUnit = repo.getOccurrenceService().save(fieldUnit);
141 139

  
142 140
            VersionableEntity baseEntity = bean.getBaseEntity();
143 141
            Set<TypeDesignationBase> typeDesignations = regDTO.getTypeDesignationsInWorkingSet(
......
172 170
            // associate the new typeDesignations with the registration
173 171
            for(SpecimenTypeDesignation std : newTypeDesignations){
174 172
                assureFieldUnit(fieldUnit, std);
175
                std.setCitation(dto.getCitation());
176 173
                dto.getTypifiedName().addTypeDesignation(std, false);
177 174
                regPremerge.addTypeDesignation(std);
178 175
            }
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationWorkingSetDTO.java
25 25
import eu.etaxonomy.cdm.model.name.TaxonName;
26 26
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
27 27
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
28
import eu.etaxonomy.cdm.model.reference.Reference;
29 28

  
30 29
/**
31 30
 * @author a.kohlbecker
......
49 48

  
50 49
    OWNER owner;
51 50

  
52
    private Reference citation;
53

  
54 51
    private TaxonName typifiedName;
55 52

  
56 53
    /**
......
59 56
     * @param baseEntity
60 57
     * @param specimenTypeDesignations can be <code>null</code>
61 58
     */
62
    public SpecimenTypeDesignationWorkingSetDTO(OWNER owner, VersionableEntity baseEntity, List<SpecimenTypeDesignation> specimenTypeDesignations, Reference citation, TaxonName typifiedName) {
59
    public SpecimenTypeDesignationWorkingSetDTO(OWNER owner, VersionableEntity baseEntity, List<SpecimenTypeDesignation> specimenTypeDesignations, TaxonName typifiedName) {
63 60
        super();
64 61
        this.owner = owner;
65 62
        this.baseEntity = baseEntity;
66
        if(citation == null){
67
            throw new NullPointerException("citation must not be null");
68
        }
69 63
        if(typifiedName == null){
70 64
            throw new NullPointerException("typifiedName must not be null");
71 65
        }
72
        this.citation = citation;
73 66
        this.typifiedName = typifiedName;
74 67
        if(baseEntity instanceof FieldUnit){
75 68
            this.fieldUnit = (FieldUnit) baseEntity;
......
89 82
     * @param citationEntityID
90 83
     * @param typifiedNameEntityID
91 84
     */
92
    public SpecimenTypeDesignationWorkingSetDTO(OWNER reg, FieldUnit newfieldUnit, Reference citation, TaxonName typifiedName) {
93
        this(reg, newfieldUnit, null, citation, typifiedName);
85
    public SpecimenTypeDesignationWorkingSetDTO(OWNER reg, FieldUnit newfieldUnit, TaxonName typifiedName) {
86
        this(reg, newfieldUnit, null, typifiedName);
94 87
    }
95 88

  
96 89
    /**
......
297 290
        fieldUnit.getGatheringEvent().setTimeperiod(gatheringDate);
298 291
    }
299 292

  
300
    /**
301
     * @return the citation
302
     */
303
    public Reference getCitation() {
304
        return citation;
305
    }
306

  
307
    /**
308
     * @param citation the citation to set
309
     */
310
    public void setCitation(Reference citation) {
311
        this.citation = citation;
312
    }
313

  
314 293
    /**
315 294
     * @return the typifiedName
316 295
     */
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
150 150
                rootEntities.add(workingSetDto.getOwner());
151 151
            } else {
152 152
                // create a new workingset, for a new fieldunit which is the base for the workingset
153
                workingSetDto = specimenTypeDesignationWorkingSetService.create(idset.registrationUuid, idset.publicationUuid, idset.typifiedNameUuid);
153
                workingSetDto = specimenTypeDesignationWorkingSetService.create(idset.registrationUuid, idset.typifiedNameUuid);
154 154
                // need to use load but put see #7214
155 155
                Registration registration = workingSetDto.getOwner();
156 156
                cache.load(registration);
157
                if(registration.getName() == null && (registration.getTypeDesignations() == null || registration.getTypeDesignations().isEmpty())){
158
                    // need to add the citation to the cache when there is no name or typedesignation in the registry which would bring the citation otherwise.
159
                    cache.load(workingSetDto.getCitation());
160
                }
161 157
                cache.load(workingSetDto.getTypifiedName());
162 158
                rootEntities.add(workingSetDto.getOwner());
163 159
                rootEntities.add(workingSetDto.getTypifiedName());
164
                rootEntities.add(workingSetDto.getCitation());
160

  
165 161
            }
166 162

  
167 163
        } else {
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TypeDesignationWorkingsetEditorIdSet.java
36 36
        this.baseEntityRef = baseEntityRef;
37 37
        this.publicationUuid = publicationUuid;
38 38
        this.typifiedNameUuid = typifiedNameUuid;
39
        if(baseEntityRef == null && publicationUuid == null|| baseEntityRef == null && typifiedNameUuid == null){
40
            throw new NullPointerException("When workingsetId is null, publicationId and typifiedNameId must be non null.");
39
        if(baseEntityRef == null && typifiedNameUuid == null){
40
            throw new NullPointerException("When workingsetId is null the typifiedNameId must be non null.");
41 41
        }
42 42
    }
43 43

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
601 601

  
602 602
            identifierSet = new TypeDesignationWorkingsetEditorIdSet(
603 603
                    event.getRegistrationUuid(),
604
                    getView().getCitationUuid(), // FIXME This may pass the reference (e.g. Article) from RegistrationWorkingsetView
605
                    // to the TypeDesignationWorkingset even if the nomenclatural act is a Section !!! --> #9290
604
                    null,
606 605
                    typifiedNameUuid
607 606
                    );
608 607
            popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
src/test/java/eu/etaxonomy/cdm/service/SpecimenTypeDesignationWorkingSetServiceImplTest.java
100 100
//                "REPRESENTATION", "REPRESENTATION_AUD", "HIBERNATE_SEQUENCES"},
101 101
//                "RegistrationTerms");
102 102

  
103
       SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.create(registrationUuid, publicationUuid, typifiedNameUuid);
103
       SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.create(registrationUuid, typifiedNameUuid);
104 104

  
105 105
       Assert.assertNotNull(workingset.getOwner());
106 106
       Assert.assertEquals(Registration.class, workingset.getOwner().getClass());

Also available in: Unified diff