Revision 002cdd32
Added by Andreas Kohlbecker about 3 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java | ||
---|---|---|
415 | 415 |
dto = new DerivedUnitDTO(derivative); |
416 | 416 |
} |
417 | 417 |
alreadyCollectedSpecimen.put(dto.getUuid(), dto); |
418 |
dto.addAllDerivates(getDerivedUnitDTOsFor(dto, derivative, alreadyCollectedSpecimen)); |
|
418 |
dto.addAllDerivatives(getDerivedUnitDTOsFor(dto, derivative, alreadyCollectedSpecimen));
|
|
419 | 419 |
derivedUnits.add(dto); |
420 | 420 |
} |
421 | 421 |
} |
... | ... | |
533 | 533 |
if (alreadyCollectedSpecimen.get(derivedUnitDTO.getUuid()) == null){ |
534 | 534 |
alreadyCollectedSpecimen.put(derivedUnitDTO.getUuid(), derivedUnitDTO); |
535 | 535 |
} |
536 |
derivedUnitDTO.addAllDerivates(getDerivedUnitDTOsFor(derivedUnitDTO, derivedUnit, alreadyCollectedSpecimen)); |
|
536 |
derivedUnitDTO.addAllDerivatives(getDerivedUnitDTOsFor(derivedUnitDTO, derivedUnit, alreadyCollectedSpecimen));
|
|
537 | 537 |
fieldUnitDTOs.addAll(findFieldUnitDTO(derivedUnitDTO, alreadyCollectedSpecimen)); |
538 | 538 |
} else { |
539 | 539 |
// FIXME FieldUnits are not yet handled here !!! |
... | ... | |
580 | 580 |
if (dnaSample != null){ |
581 | 581 |
derivedUnitDTO = new DNASampleDTO(dnaSample); |
582 | 582 |
alreadyCollectedSpecimen.put(derivedUnitDTO.getUuid(), derivedUnitDTO); |
583 |
derivedUnitDTO.addAllDerivates(getDerivedUnitDTOsFor(derivedUnitDTO, dnaSample, alreadyCollectedSpecimen)); |
|
583 |
derivedUnitDTO.addAllDerivatives(getDerivedUnitDTOsFor(derivedUnitDTO, dnaSample, alreadyCollectedSpecimen));
|
|
584 | 584 |
Collection<FieldUnitDTO> fieldUnitDTOs = this.findFieldUnitDTO(derivedUnitDTO, alreadyCollectedSpecimen); |
585 | 585 |
// FIXME change return type to Collection<FieldUnitDTO> |
586 | 586 |
if(fieldUnitDTOs.isEmpty()) { |
... | ... | |
793 | 793 |
// by removing it from the derivatives of its original |
794 | 794 |
// but let the derivate to be added to the original which is closer to the FieldUnit (below at originalDTO.addDerivate(derivedUnitDTO);) |
795 | 795 |
for(SpecimenOrObservationBaseDTO seenOriginal: cycleDetectionMap.values()){ |
796 |
for(SpecimenOrObservationBaseDTO derivateDTO : seenOriginal.getDerivates()){ |
|
796 |
for(SpecimenOrObservationBaseDTO derivateDTO : seenOriginal.getDerivatives()){
|
|
797 | 797 |
if(derivateDTO.equals(originalDTO)){ |
798 |
seenOriginal.getDerivates().remove(originalDTO); |
|
798 |
seenOriginal.getDerivatives().remove(originalDTO);
|
|
799 | 799 |
} |
800 | 800 |
} |
801 | 801 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivedUnitDTO.java | ||
---|---|---|
72 | 72 |
|
73 | 73 |
/** |
74 | 74 |
* Constructs a new DerivedUnitDTO. All derivatives of the passed <code>DerivedUnit entity</code> will be collected and |
75 |
* added as DerivedUnitDTO to the {@link SpecimenOrObservationBaseDTO#getDerivates() derivative DTOs}. |
|
75 |
* added as DerivedUnitDTO to the {@link SpecimenOrObservationBaseDTO#getDerivatives() derivative DTOs}.
|
|
76 | 76 |
* |
77 | 77 |
* @param entity |
78 | 78 |
* The entity to create the dto for |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java | ||
---|---|---|
48 | 48 |
/** |
49 | 49 |
* Factory method for the construction of a FieldUnitDTO. |
50 | 50 |
* <p> |
51 |
* The direct derivatives are added to the field {@link #getDerivates() derivates}. |
|
51 |
* The direct derivatives are added to the field {@link #getDerivatives() derivates}.
|
|
52 | 52 |
* |
53 | 53 |
* |
54 | 54 |
* @param fieldUnit |
55 | 55 |
* The FieldUnit entity to create a DTO for. Is null save. |
56 | 56 |
* @param specimenOrObservationTypeFilter |
57 |
* Set of SpecimenOrObservationType to be included into the collection of {@link #getDerivates() derivative DTOs} |
|
57 |
* Set of SpecimenOrObservationType to be included into the collection of {@link #getDerivatives() derivative DTOs}
|
|
58 | 58 |
*/ |
59 | 59 |
public static FieldUnitDTO fromEntity(FieldUnit entity, EnumSet<SpecimenOrObservationType> specimenOrObservationTypeFilter){ |
60 | 60 |
if(entity == null) { |
... | ... | |
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
/** |
67 |
* The direct derivatives are added to the field {@link #getDerivates() derivates}. |
|
67 |
* The direct derivatives are added to the field {@link #getDerivatives() derivates}.
|
|
68 | 68 |
* |
69 | 69 |
* @param fieldUnit |
70 | 70 |
* The FieldUnit entity to create a DTO for |
71 | 71 |
* @param specimenOrObservationTypeFilter |
72 |
* Set of SpecimenOrObservationType to be included into the collection of {@link #getDerivates() derivative DTOs} |
|
72 |
* Set of SpecimenOrObservationType to be included into the collection of {@link #getDerivatives() derivative DTOs}
|
|
73 | 73 |
*/ |
74 | 74 |
private FieldUnitDTO(FieldUnit fieldUnit, EnumSet<SpecimenOrObservationType> specimenOrObservationTypeFilter ) { |
75 | 75 |
super(fieldUnit); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/SpecimenOrObservationBaseDTO.java | ||
---|---|---|
59 | 59 |
private String collectorsNumber; |
60 | 60 |
private String barcode; |
61 | 61 |
private String preservationMethod; |
62 |
// TODO rename to derivatives!!! |
|
63 |
private Set<DerivedUnitDTO> derivates; |
|
62 |
private Set<DerivedUnitDTO> derivatives; |
|
64 | 63 |
|
65 | 64 |
private Set<SpecimenTypeDesignationDTO> specimenTypeDesignations; |
66 | 65 |
|
... | ... | |
307 | 306 |
|
308 | 307 |
|
309 | 308 |
|
310 |
public Set<DerivedUnitDTO> getDerivates() { |
|
311 |
if (this.derivates == null){ |
|
312 |
this.derivates = new HashSet<>(); |
|
309 |
public Set<DerivedUnitDTO> getDerivatives() {
|
|
310 |
if (this.derivatives == null){
|
|
311 |
this.derivatives = new HashSet<>();
|
|
313 | 312 |
} |
314 |
return derivates; |
|
313 |
return derivatives;
|
|
315 | 314 |
} |
316 | 315 |
|
317 |
public void setDerivates(Set<DerivedUnitDTO> derivates) {
|
|
318 |
this.derivates = derivates;
|
|
316 |
public void setDerivatives(Set<DerivedUnitDTO> derivatives) {
|
|
317 |
this.derivatives = derivatives;
|
|
319 | 318 |
} |
320 | 319 |
|
321 | 320 |
public void addDerivate(DerivedUnitDTO derivate){ |
322 |
if (this.derivates == null){ |
|
323 |
this.derivates = new HashSet<>(); |
|
321 |
if (this.derivatives == null){
|
|
322 |
this.derivatives = new HashSet<>();
|
|
324 | 323 |
} |
325 |
this.derivates.add(derivate); |
|
324 |
this.derivatives.add(derivate);
|
|
326 | 325 |
} |
327 |
public void addAllDerivates(Set<DerivedUnitDTO> derivates){
|
|
328 |
if (this.derivates == null){ |
|
329 |
this.derivates = new HashSet<>(); |
|
326 |
public void addAllDerivatives(Set<DerivedUnitDTO> derivatives){
|
|
327 |
if (this.derivatives == null){
|
|
328 |
this.derivatives = new HashSet<>();
|
|
330 | 329 |
} |
331 |
this.derivates.addAll(derivates);
|
|
330 |
this.derivatives.addAll(derivatives);
|
|
332 | 331 |
} |
333 | 332 |
|
334 | 333 |
/** |
... | ... | |
344 | 343 |
* @param dtos |
345 | 344 |
*/ |
346 | 345 |
private Collection<DerivedUnitDTO> collectDerivatives(Set<DerivedUnitDTO> dtos) { |
347 |
dtos.addAll(getDerivates()); |
|
348 |
if(derivates != null) { |
|
349 |
for(SpecimenOrObservationBaseDTO subDto : derivates) { |
|
346 |
dtos.addAll(getDerivatives());
|
|
347 |
if(derivatives != null) {
|
|
348 |
for(SpecimenOrObservationBaseDTO subDto : derivatives) {
|
|
350 | 349 |
dtos.addAll(subDto.collectDerivatives(dtos)); |
351 | 350 |
} |
352 | 351 |
} |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java | ||
---|---|---|
1172 | 1172 |
FieldUnitDTO findByAccessionNumber = occurrenceService.findByAccessionNumber("ACC_DNA", null, propertyPath); |
1173 | 1173 |
|
1174 | 1174 |
assertNotNull(findByAccessionNumber); |
1175 |
assertTrue(findByAccessionNumber.getDerivates().size() == 1); |
|
1175 |
assertTrue(findByAccessionNumber.getDerivatives().size() == 1);
|
|
1176 | 1176 |
// assertTrue(findByAccessionNumber.contains(derivedUnit1)); |
1177 | 1177 |
// assertTrue(findByAccessionNumber.get(0).get.equals(dnaSampleWithSequence)); |
1178 | 1178 |
} |
Also available in: Unified diff
ref #9252 renaming property derivates to derivatives