Revision 0979f889
Added by Andreas Kohlbecker over 3 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrencePortalController.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
28 | 28 |
import eu.etaxonomy.cdm.api.service.ITermService; |
29 | 29 |
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO; |
30 |
import eu.etaxonomy.cdm.api.service.dto.PreservedSpecimenDTO;
|
|
30 |
import eu.etaxonomy.cdm.api.service.dto.DerivedUnitDTO;
|
|
31 | 31 |
import eu.etaxonomy.cdm.model.media.Media; |
32 | 32 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
33 | 33 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
... | ... | |
115 | 115 |
} |
116 | 116 |
|
117 | 117 |
@RequestMapping(value = { "specimenDerivates" }, method = RequestMethod.GET) |
118 |
public PreservedSpecimenDTO doGetSpecimenDerivates(
|
|
118 |
public DerivedUnitDTO doGetSpecimenDerivates(
|
|
119 | 119 |
@PathVariable("uuid") UUID uuid, |
120 | 120 |
HttpServletRequest request, |
121 | 121 |
HttpServletResponse response) throws IOException { |
... | ... | |
127 | 127 |
if(sob instanceof DerivedUnit){ |
128 | 128 |
DerivedUnit derivedUnit = (DerivedUnit) sob; |
129 | 129 |
if(derivedUnit.isPublish()){ |
130 |
PreservedSpecimenDTO dto = service.assemblePreservedSpecimenDTO(derivedUnit);
|
|
130 |
DerivedUnitDTO dto = service.assemblePreservedSpecimenDTO(derivedUnit);
|
|
131 | 131 |
return dto; |
132 | 132 |
} |
133 | 133 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IOccurrenceService.java | ||
---|---|---|
26 | 26 |
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator; |
27 | 27 |
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator; |
28 | 28 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator; |
29 |
import eu.etaxonomy.cdm.api.service.dto.DerivateDTO;
|
|
29 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenOrObservationBaseDTO;
|
|
30 | 30 |
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO; |
31 |
import eu.etaxonomy.cdm.api.service.dto.PreservedSpecimenDTO;
|
|
31 |
import eu.etaxonomy.cdm.api.service.dto.DerivedUnitDTO;
|
|
32 | 32 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
33 | 33 |
import eu.etaxonomy.cdm.api.service.search.LuceneParseException; |
34 | 34 |
import eu.etaxonomy.cdm.api.service.search.SearchResult; |
... | ... | |
428 | 428 |
public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit); |
429 | 429 |
|
430 | 430 |
/** |
431 |
* Assembles a {@link PreservedSpecimenDTO} for the given derived unit.
|
|
431 |
* Assembles a {@link DerivedUnitDTO} for the given derived unit.
|
|
432 | 432 |
* @param derivedUnit |
433 | 433 |
* @return a DTO with all the assembled information |
434 | 434 |
*/ |
435 |
public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit);
|
|
435 |
public DerivedUnitDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit);
|
|
436 | 436 |
|
437 | 437 |
/** |
438 | 438 |
* Deletes the specified specimen according to the setting in the {@link SpecimenDeleteConfigurator}.<br> |
... | ... | |
681 | 681 |
FindOccurrencesConfigurator config); |
682 | 682 |
|
683 | 683 |
/** |
684 |
* Returns a list of {@link PreservedSpecimenDTO} for the specimens found with the
|
|
684 |
* Returns a list of {@link DerivedUnitDTO} for the specimens found with the
|
|
685 | 685 |
* given configurator |
686 | 686 |
* @param config the configurator for the search |
687 |
* @return a list of {@link PreservedSpecimenDTO} object
|
|
687 |
* @return a list of {@link DerivedUnitDTO} object
|
|
688 | 688 |
*/ |
689 | 689 |
@Transactional(readOnly = true) |
690 |
public List<PreservedSpecimenDTO> findByTitlePreservedSpecimenDTO(
|
|
690 |
public List<DerivedUnitDTO> findByTitlePreservedSpecimenDTO(
|
|
691 | 691 |
FindOccurrencesConfigurator config); |
692 | 692 |
|
693 | 693 |
/** |
... | ... | |
719 | 719 |
* @return |
720 | 720 |
*/ |
721 | 721 |
|
722 |
FieldUnitDTO findFieldUnitDTO(DerivateDTO derivedUnitDTO, Collection<FieldUnitDTO> fieldUnits,
|
|
723 |
HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen);
|
|
722 |
FieldUnitDTO findFieldUnitDTO(SpecimenOrObservationBaseDTO derivedUnitDTO, Collection<FieldUnitDTO> fieldUnits,
|
|
723 |
HashMap<UUID, SpecimenOrObservationBaseDTO> alreadyCollectedSpecimen);
|
|
724 | 724 |
|
725 | 725 |
|
726 | 726 |
/** |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java | ||
---|---|---|
49 | 49 |
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator; |
50 | 50 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator; |
51 | 51 |
import eu.etaxonomy.cdm.api.service.dto.DNASampleDTO; |
52 |
import eu.etaxonomy.cdm.api.service.dto.DerivateDTO;
|
|
52 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenOrObservationBaseDTO;
|
|
53 | 53 |
import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO; |
54 | 54 |
import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO.ContigFile; |
55 | 55 |
import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO.Link; |
56 | 56 |
import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO.MolecularData; |
57 | 57 |
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO; |
58 |
import eu.etaxonomy.cdm.api.service.dto.PreservedSpecimenDTO;
|
|
58 |
import eu.etaxonomy.cdm.api.service.dto.DerivedUnitDTO;
|
|
59 | 59 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
60 | 60 |
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; |
61 | 61 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
... | ... | |
464 | 464 |
collectionToCountMap.put(collection, herbariumCount + 1); |
465 | 465 |
} |
466 | 466 |
if (derivedUnit.getRecordBasis().equals(SpecimenOrObservationType.PreservedSpecimen)) { |
467 |
PreservedSpecimenDTO preservedSpecimenDTO = assemblePreservedSpecimenDTO(derivedUnit, fieldUnitDTO);
|
|
467 |
DerivedUnitDTO preservedSpecimenDTO = assemblePreservedSpecimenDTO(derivedUnit, fieldUnitDTO);
|
|
468 | 468 |
fieldUnitDTO.addDerivate(preservedSpecimenDTO); |
469 | 469 |
fieldUnitDTO.setHasCharacterData(fieldUnitDTO.isHasCharacterData() || preservedSpecimenDTO.isHasCharacterData()); |
470 | 470 |
fieldUnitDTO.setHasDetailImage(fieldUnitDTO.isHasDetailImage() || preservedSpecimenDTO.isHasDetailImage()); |
... | ... | |
514 | 514 |
} |
515 | 515 |
|
516 | 516 |
@Override |
517 |
public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit) {
|
|
517 |
public DerivedUnitDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit) {
|
|
518 | 518 |
return assemblePreservedSpecimenDTO(derivedUnit, null); |
519 | 519 |
} |
520 | 520 |
|
... | ... | |
532 | 532 |
return null; |
533 | 533 |
} |
534 | 534 |
|
535 |
public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit, FieldUnitDTO fieldUnitDTO) {
|
|
535 |
public DerivedUnitDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit, FieldUnitDTO fieldUnitDTO) {
|
|
536 | 536 |
if (!getSession().contains(derivedUnit)) { |
537 | 537 |
derivedUnit = (DerivedUnit) load(derivedUnit.getUuid()); |
538 | 538 |
} |
539 |
PreservedSpecimenDTO preservedSpecimenDTO = new PreservedSpecimenDTO(derivedUnit);
|
|
539 |
DerivedUnitDTO preservedSpecimenDTO = new DerivedUnitDTO(derivedUnit);
|
|
540 | 540 |
|
541 | 541 |
//specimen identifier |
542 | 542 |
FormatKey collectionKey = FormatKey.COLLECTION_CODE; |
... | ... | |
626 | 626 |
return preservedSpecimenDTO; |
627 | 627 |
} |
628 | 628 |
|
629 |
private DerivateDataDTO assembleDerivateDataDTO(DerivateDTO derivateDTO, SpecimenOrObservationBase<?> specimenOrObservation) {
|
|
629 |
private DerivateDataDTO assembleDerivateDataDTO(SpecimenOrObservationBaseDTO derivateDTO, SpecimenOrObservationBase<?> specimenOrObservation) {
|
|
630 | 630 |
DerivateDataDTO derivateDataDTO = new DerivateDataDTO(); |
631 | 631 |
Collection<DerivedUnit> childDerivates = getDerivedUnitsFor(specimenOrObservation); |
632 | 632 |
for (DerivedUnit childDerivate : childDerivates) { |
... | ... | |
691 | 691 |
derivateDataDTO.addSpecimenScanUuid(media.getMediaSpecimen().getUuid()); |
692 | 692 |
derivateDTO.setHasSpecimenScan(true); |
693 | 693 |
String imageLinkText = "scan"; |
694 |
if (derivateDTO instanceof PreservedSpecimenDTO && ((PreservedSpecimenDTO) derivateDTO).getAccessionNumber() != null) {
|
|
695 |
imageLinkText = ((PreservedSpecimenDTO) derivateDTO).getAccessionNumber();
|
|
694 |
if (derivateDTO instanceof DerivedUnitDTO && ((DerivedUnitDTO) derivateDTO).getAccessionNumber() != null) {
|
|
695 |
imageLinkText = ((DerivedUnitDTO) derivateDTO).getAccessionNumber();
|
|
696 | 696 |
} |
697 | 697 |
derivateDataDTO.addSpecimenScan(mediaUri, imageLinkText); |
698 | 698 |
} |
... | ... | |
747 | 747 |
return derivedUnits; |
748 | 748 |
} |
749 | 749 |
|
750 |
private Set<DerivateDTO> getDerivedUnitDTOsFor(DerivateDTO specimenDto, DerivedUnit specimen, HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen) {
|
|
751 |
Set<DerivateDTO> derivedUnits = new HashSet<>();
|
|
750 |
private Set<SpecimenOrObservationBaseDTO> getDerivedUnitDTOsFor(SpecimenOrObservationBaseDTO specimenDto, DerivedUnit specimen, HashMap<UUID, SpecimenOrObservationBaseDTO> alreadyCollectedSpecimen) {
|
|
751 |
Set<SpecimenOrObservationBaseDTO> derivedUnits = new HashSet<>();
|
|
752 | 752 |
// load |
753 | 753 |
for (DerivationEvent derivationEvent : specimen.getDerivationEvents()) { |
754 | 754 |
for (DerivedUnit derivative : derivationEvent.getDerivatives()) { |
755 | 755 |
if (!alreadyCollectedSpecimen.containsKey(specimenDto.getUuid())){ |
756 |
PreservedSpecimenDTO dto;
|
|
756 |
DerivedUnitDTO dto;
|
|
757 | 757 |
if (derivative instanceof DnaSample) { |
758 | 758 |
dto = new DNASampleDTO(derivative); |
759 | 759 |
} else { |
760 |
dto = new PreservedSpecimenDTO(derivative);
|
|
760 |
dto = new DerivedUnitDTO(derivative);
|
|
761 | 761 |
} |
762 | 762 |
alreadyCollectedSpecimen.put(dto.getUuid(), dto); |
763 | 763 |
dto.addAllDerivates(getDerivedUnitDTOsFor(dto, derivative, alreadyCollectedSpecimen)); |
... | ... | |
844 | 844 |
Set<Taxon> taxa = new HashSet<>(); |
845 | 845 |
Set<Integer> occurrenceIds = new HashSet<>(); |
846 | 846 |
List<FieldUnitDTO> fieldUnitDTOs = new ArrayList<>(); |
847 |
HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen = new HashMap<>();
|
|
847 |
HashMap<UUID, SpecimenOrObservationBaseDTO> alreadyCollectedSpecimen = new HashMap<>();
|
|
848 | 848 |
List<SpecimenOrObservationBase> occurrences = new ArrayList<>(); |
849 | 849 |
boolean includeUnpublished = INCLUDE_UNPUBLISHED; |
850 | 850 |
|
... | ... | |
865 | 865 |
for (SpecimenOrObservationBase<?> o : perTaxonOccurrences) { |
866 | 866 |
if (o.isInstanceOf(DerivedUnit.class)){ |
867 | 867 |
DerivedUnit derivedUnit; |
868 |
DerivateDTO derivedUnitDTO;
|
|
868 |
SpecimenOrObservationBaseDTO derivedUnitDTO;
|
|
869 | 869 |
if (o.isInstanceOf(DnaSample.class)) { |
870 | 870 |
derivedUnit = HibernateProxyHelper.deproxy(o, DnaSample.class); |
871 | 871 |
derivedUnitDTO = new DNASampleDTO(derivedUnit); |
872 | 872 |
} else { |
873 | 873 |
derivedUnit = HibernateProxyHelper.deproxy(o, DerivedUnit.class); |
874 |
derivedUnitDTO = new PreservedSpecimenDTO(derivedUnit);
|
|
874 |
derivedUnitDTO = new DerivedUnitDTO(derivedUnit);
|
|
875 | 875 |
} |
876 | 876 |
if (alreadyCollectedSpecimen.get(derivedUnitDTO.getUuid()) == null){ |
877 | 877 |
alreadyCollectedSpecimen.put(derivedUnitDTO.getUuid(), derivedUnitDTO); |
... | ... | |
896 | 896 |
List<String> propertyPaths) { |
897 | 897 |
|
898 | 898 |
DnaSample dnaSample = dao.findByGeneticAccessionNumber(accessionNumberString, propertyPaths); |
899 |
DerivateDTO derivedUnitDTO;
|
|
900 |
HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen = new HashMap<>();
|
|
899 |
SpecimenOrObservationBaseDTO derivedUnitDTO;
|
|
900 |
HashMap<UUID, SpecimenOrObservationBaseDTO> alreadyCollectedSpecimen = new HashMap<>();
|
|
901 | 901 |
List<FieldUnitDTO> fieldUnitDTOs = new ArrayList<>(); |
902 | 902 |
if (dnaSample != null){ |
903 | 903 |
derivedUnitDTO = new DNASampleDTO(dnaSample); |
... | ... | |
1021 | 1021 |
|
1022 | 1022 |
@Override |
1023 | 1023 |
@Transactional(readOnly=true) |
1024 |
public FieldUnitDTO findFieldUnitDTO(DerivateDTO derivedUnitDTO, Collection<FieldUnitDTO> fieldUnits,
|
|
1025 |
HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen) {
|
|
1024 |
public FieldUnitDTO findFieldUnitDTO(SpecimenOrObservationBaseDTO derivedUnitDTO, Collection<FieldUnitDTO> fieldUnits,
|
|
1025 |
HashMap<UUID, SpecimenOrObservationBaseDTO> alreadyCollectedSpecimen) {
|
|
1026 | 1026 |
//It will search recursively over all {@link DerivationEvent}s and get the "originals" ({@link SpecimenOrObservationBase}) |
1027 | 1027 |
//from which this DerivedUnit was derived until all FieldUnits are found. |
1028 | 1028 |
List<SpecimenOrObservationBase> specimens = new ArrayList<>(); |
... | ... | |
1057 | 1057 |
fieldUnits.add(fieldUnitDto); |
1058 | 1058 |
|
1059 | 1059 |
}else{ |
1060 |
DerivateDTO originalDTO;
|
|
1060 |
SpecimenOrObservationBaseDTO originalDTO;
|
|
1061 | 1061 |
if (specimen instanceof DnaSample){ |
1062 | 1062 |
originalDTO = new DNASampleDTO((DnaSample)specimen); |
1063 | 1063 |
} else { |
1064 |
originalDTO = new PreservedSpecimenDTO((DerivedUnit)specimen);
|
|
1064 |
originalDTO = new DerivedUnitDTO((DerivedUnit)specimen);
|
|
1065 | 1065 |
} |
1066 | 1066 |
originalDTO.addDerivate(derivedUnitDTO); |
1067 | 1067 |
fieldUnitDto = findFieldUnitDTO(originalDTO, fieldUnits, |
... | ... | |
1083 | 1083 |
public FieldUnitDTO loadFieldUnitDTO(UUID derivedUnitUuid) { |
1084 | 1084 |
|
1085 | 1085 |
FieldUnitDTO fieldUnitDTO = null; |
1086 |
DerivateDTO derivedUnitDTO = null;
|
|
1086 |
SpecimenOrObservationBaseDTO derivedUnitDTO = null;
|
|
1087 | 1087 |
|
1088 |
Map<UUID, DerivateDTO> cycleDetectionMap = new HashMap<>();
|
|
1088 |
Map<UUID, SpecimenOrObservationBaseDTO> cycleDetectionMap = new HashMap<>();
|
|
1089 | 1089 |
SpecimenOrObservationBase derivative = dao.load(derivedUnitUuid); |
1090 | 1090 |
if(derivative != null){ |
1091 | 1091 |
if (derivative instanceof FieldUnit){ |
... | ... | |
1093 | 1093 |
return fieldUnitDTO; |
1094 | 1094 |
} else { |
1095 | 1095 |
// must be a DerivedUnit otherwise |
1096 |
derivedUnitDTO = PreservedSpecimenDTO.fromEntity((DerivedUnit)derivative);
|
|
1096 |
derivedUnitDTO = DerivedUnitDTO.fromEntity((DerivedUnit)derivative);
|
|
1097 | 1097 |
while(true){ |
1098 | 1098 |
|
1099 |
Set<DerivateDTO> originals = originalDTOs(derivedUnitDTO.getUuid());
|
|
1099 |
Set<SpecimenOrObservationBaseDTO> originals = originalDTOs(derivedUnitDTO.getUuid());
|
|
1100 | 1100 |
|
1101 | 1101 |
if(originals.isEmpty()){ |
1102 | 1102 |
break; |
... | ... | |
1105 | 1105 |
logger.debug("The derived unit with uuid " + derivedUnitUuid + "has more than one orginal, ignoring all but the first one."); |
1106 | 1106 |
} |
1107 | 1107 |
|
1108 |
DerivateDTO originalDTO = originals.iterator().next();
|
|
1108 |
SpecimenOrObservationBaseDTO originalDTO = originals.iterator().next();
|
|
1109 | 1109 |
|
1110 | 1110 |
// cycle detection and handling |
1111 | 1111 |
if(cycleDetectionMap.containsKey(originalDTO.getUuid())){ |
... | ... | |
1118 | 1118 |
// to solve the situation for the output we remove the derivate from the more distant graph node |
1119 | 1119 |
// by removing it from the derivatives of its original |
1120 | 1120 |
// but let the derivate to be added to the original which is closer to the FieldUnit (below at originalDTO.addDerivate(derivedUnitDTO);) |
1121 |
for(DerivateDTO seenOriginal: cycleDetectionMap.values()){
|
|
1122 |
for(DerivateDTO derivateDTO : seenOriginal.getDerivates()){
|
|
1121 |
for(SpecimenOrObservationBaseDTO seenOriginal: cycleDetectionMap.values()){
|
|
1122 |
for(SpecimenOrObservationBaseDTO derivateDTO : seenOriginal.getDerivates()){
|
|
1123 | 1123 |
if(derivateDTO.equals(originalDTO)){ |
1124 | 1124 |
seenOriginal.getDerivates().remove(originalDTO); |
1125 | 1125 |
} |
... | ... | |
1156 | 1156 |
* @param originalDTO |
1157 | 1157 |
* @return |
1158 | 1158 |
*/ |
1159 |
private Set<DerivateDTO> originalDTOs(UUID derivativeUuid) {
|
|
1159 |
private Set<SpecimenOrObservationBaseDTO> originalDTOs(UUID derivativeUuid) {
|
|
1160 | 1160 |
|
1161 |
Set<DerivateDTO> dtos = new HashSet<>();
|
|
1161 |
Set<SpecimenOrObservationBaseDTO> dtos = new HashSet<>();
|
|
1162 | 1162 |
List<SpecimenOrObservationBase> specimens = dao.findOriginalsForDerivedUnit(derivativeUuid, null); |
1163 | 1163 |
for(SpecimenOrObservationBase sob : specimens){ |
1164 | 1164 |
if(sob instanceof FieldUnit) { |
1165 | 1165 |
dtos.add(FieldUnitDTO.fromEntity((FieldUnit)sob)); |
1166 | 1166 |
} else { |
1167 |
dtos.add(PreservedSpecimenDTO.fromEntity((DerivedUnit)sob));
|
|
1167 |
dtos.add(DerivedUnitDTO.fromEntity((DerivedUnit)sob));
|
|
1168 | 1168 |
} |
1169 | 1169 |
} |
1170 | 1170 |
return dtos; |
... | ... | |
1717 | 1717 |
} |
1718 | 1718 |
|
1719 | 1719 |
@Override |
1720 |
public List<PreservedSpecimenDTO> findByTitlePreservedSpecimenDTO(FindOccurrencesConfigurator config) {
|
|
1720 |
public List<DerivedUnitDTO> findByTitlePreservedSpecimenDTO(FindOccurrencesConfigurator config) {
|
|
1721 | 1721 |
Taxon taxon = null; |
1722 | 1722 |
if(config.getAssociatedTaxonUuid()!=null){ |
1723 | 1723 |
TaxonBase<?> taxonBase = taxonService.load(config.getAssociatedTaxonUuid()); |
... | ... | |
1735 | 1735 |
config.getSpecimenType(), taxon, taxonName, config.getMatchMode(), null, null, |
1736 | 1736 |
config.getOrderHints(), null)); |
1737 | 1737 |
|
1738 |
List<PreservedSpecimenDTO> dtos = new ArrayList<>();
|
|
1738 |
List<DerivedUnitDTO> dtos = new ArrayList<>();
|
|
1739 | 1739 |
occurrences.forEach(derivedUnit->dtos.add(assemblePreservedSpecimenDTO(derivedUnit))); |
1740 | 1740 |
return dtos; |
1741 | 1741 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DNASampleDTO.java | ||
---|---|---|
23 | 23 |
* @since 02.08.2018 |
24 | 24 |
* |
25 | 25 |
*/ |
26 |
public class DNASampleDTO extends PreservedSpecimenDTO{
|
|
26 |
public class DNASampleDTO extends DerivedUnitDTO{
|
|
27 | 27 |
|
28 | 28 |
private static final long serialVersionUID = -1050277075084265067L; |
29 | 29 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.dto; |
|
10 |
|
|
11 |
import java.io.Serializable; |
|
12 |
import java.util.AbstractMap; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.Comparator; |
|
15 |
import java.util.HashSet; |
|
16 |
import java.util.List; |
|
17 |
import java.util.Set; |
|
18 |
import java.util.TreeSet; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
21 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
22 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
23 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
24 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
25 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
26 |
import eu.etaxonomy.cdm.model.media.Media; |
|
27 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
|
28 |
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart; |
|
29 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
30 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
31 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
32 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* @author pplitzner |
|
37 |
* @since Mar 27, 2015 |
|
38 |
*/ |
|
39 |
public abstract class DerivateDTO extends UuidAndTitleCache<SpecimenOrObservationBase>{ |
|
40 |
|
|
41 |
private static final long serialVersionUID = -7597690654462090732L; |
|
42 |
|
|
43 |
private TreeSet<AbstractMap.SimpleEntry<String, String>> characterData; |
|
44 |
private DerivateDataDTO derivateDataDTO; |
|
45 |
protected String taxonName; |
|
46 |
protected String listLabel; |
|
47 |
|
|
48 |
protected String citation; |
|
49 |
protected boolean hasDetailImage; |
|
50 |
private boolean hasCharacterData; |
|
51 |
private boolean hasDna; |
|
52 |
private boolean hasSpecimenScan; |
|
53 |
|
|
54 |
private String recordBase; |
|
55 |
private String kindOfUnit; |
|
56 |
private CollectionDTO collection; |
|
57 |
private String catalogNumber; |
|
58 |
private String collectorsNumber; |
|
59 |
private String barcode; |
|
60 |
private String preservationMethod; |
|
61 |
private Set<DerivateDTO> derivates; |
|
62 |
|
|
63 |
private Set<SpecimenTypeDesignationDTO> specimenTypeDesignations; |
|
64 |
|
|
65 |
private DerivationEventDTO derivationEvent; |
|
66 |
|
|
67 |
private Set<IdentifiableSource> sources; |
|
68 |
private List<MediaDTO> listOfMedia = new ArrayList<>(); |
|
69 |
|
|
70 |
protected DerivateDTO(SpecimenOrObservationBase specimenOrObservation) { |
|
71 |
super(specimenOrObservation.getUuid(), specimenOrObservation.getId(), specimenOrObservation.getTitleCache()); |
|
72 |
addMedia(specimenOrObservation); |
|
73 |
if (specimenOrObservation.getKindOfUnit() != null){ |
|
74 |
setKindOfUnit(specimenOrObservation.getKindOfUnit().getTitleCache()); |
|
75 |
} |
|
76 |
if (specimenOrObservation instanceof DerivedUnit){ |
|
77 |
DerivedUnit derivedUnit = (DerivedUnit)specimenOrObservation; |
|
78 |
if (derivedUnit.getSpecimenTypeDesignations() != null){ |
|
79 |
setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations()); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
} |
|
85 |
// @Override |
|
86 |
// public String getTitleCache() { |
|
87 |
// return getLabel(); |
|
88 |
// } |
|
89 |
|
|
90 |
|
|
91 |
public String getListLabel() { |
|
92 |
return listLabel; |
|
93 |
} |
|
94 |
|
|
95 |
public void setListLabel(String listLabel) { |
|
96 |
this.listLabel = listLabel; |
|
97 |
} |
|
98 |
public void setCollection(CollectionDTO collection) { |
|
99 |
this.collection = collection; |
|
100 |
} |
|
101 |
|
|
102 |
public String getCatalogNumber() { |
|
103 |
return catalogNumber; |
|
104 |
} |
|
105 |
|
|
106 |
public void setCatalogNumber(String catalogNumber) { |
|
107 |
this.catalogNumber = catalogNumber; |
|
108 |
} |
|
109 |
|
|
110 |
public String getCollectorsNumber() { |
|
111 |
return collectorsNumber; |
|
112 |
} |
|
113 |
|
|
114 |
public void setCollectorsNumber(String collectorsNumber) { |
|
115 |
this.collectorsNumber = collectorsNumber; |
|
116 |
} |
|
117 |
|
|
118 |
public String getBarcode() { |
|
119 |
return barcode; |
|
120 |
} |
|
121 |
|
|
122 |
public void setBarcode(String barcode) { |
|
123 |
this.barcode = barcode; |
|
124 |
} |
|
125 |
|
|
126 |
public String getPreservationMethod() { |
|
127 |
return preservationMethod; |
|
128 |
} |
|
129 |
|
|
130 |
public void setPreservationMethod(String preservationMethod) { |
|
131 |
this.preservationMethod = preservationMethod; |
|
132 |
} |
|
133 |
|
|
134 |
public Set<SpecimenTypeDesignationDTO> getSpecimenTypeDesignations() { |
|
135 |
return specimenTypeDesignations; |
|
136 |
} |
|
137 |
|
|
138 |
public void setSpecimenTypeDesignations(Set<SpecimenTypeDesignation> specimenTypeDesignations) { |
|
139 |
this.specimenTypeDesignations = new HashSet<>(); |
|
140 |
for (SpecimenTypeDesignation typeDes: specimenTypeDesignations){ |
|
141 |
if (typeDes != null){ |
|
142 |
this.specimenTypeDesignations.add(new SpecimenTypeDesignationDTO(typeDes)); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
public Set<IdentifiableSource> getSources() { |
|
150 |
return sources; |
|
151 |
} |
|
152 |
|
|
153 |
public void setSources(Set<IdentifiableSource> sources) { |
|
154 |
this.sources = sources; |
|
155 |
} |
|
156 |
|
|
157 |
|
|
158 |
/** |
|
159 |
* @return the derivateDataDTO |
|
160 |
*/ |
|
161 |
public DerivateDataDTO getDerivateDataDTO() { |
|
162 |
return derivateDataDTO; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* @param derivateDataDTO the derivateDataDTO to set |
|
167 |
*/ |
|
168 |
public void setDerivateDataDTO(DerivateDataDTO derivateDataDTO) { |
|
169 |
this.derivateDataDTO = derivateDataDTO; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* @return the characterData |
|
174 |
*/ |
|
175 |
public TreeSet<AbstractMap.SimpleEntry<String, String>> getCharacterData() { |
|
176 |
return characterData; |
|
177 |
} |
|
178 |
|
|
179 |
public void addCharacterData(String character, String state){ |
|
180 |
if(characterData==null){ |
|
181 |
characterData = new TreeSet<AbstractMap.SimpleEntry<String,String>>(new PairComparator()); |
|
182 |
} |
|
183 |
characterData.add(new AbstractMap.SimpleEntry<>(character, state)); |
|
184 |
} |
|
185 |
|
|
186 |
private class PairComparator implements Comparator<AbstractMap.SimpleEntry<String,String>>, Serializable { |
|
187 |
|
|
188 |
private static final long serialVersionUID = -8589392050761963540L; |
|
189 |
|
|
190 |
@Override |
|
191 |
public int compare(AbstractMap.SimpleEntry<String, String> o1, AbstractMap.SimpleEntry<String, String> o2) { |
|
192 |
if(o1==null && o2!=null){ |
|
193 |
return -1; |
|
194 |
} |
|
195 |
if(o1!=null && o2==null){ |
|
196 |
return 1; |
|
197 |
} |
|
198 |
if(o1!=null && o2!=null){ |
|
199 |
return o1.getKey().compareTo(o2.getKey()); |
|
200 |
} |
|
201 |
return 0; |
|
202 |
} |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* @return the hasCharacterData |
|
207 |
*/ |
|
208 |
public boolean isHasCharacterData() { |
|
209 |
return hasCharacterData; |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* @param hasCharacterData the hasCharacterData to set |
|
214 |
*/ |
|
215 |
public void setHasCharacterData(boolean hasCharacterData) { |
|
216 |
this.hasCharacterData = hasCharacterData; |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* @return the hasDna |
|
221 |
*/ |
|
222 |
public boolean isHasDna() { |
|
223 |
return hasDna; |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* @param hasDna the hasDna to set |
|
228 |
*/ |
|
229 |
public void setHasDna(boolean hasDna) { |
|
230 |
this.hasDna = hasDna; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* @return the hasDetailImage |
|
235 |
*/ |
|
236 |
public boolean isHasDetailImage() { |
|
237 |
return hasDetailImage; |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* @param hasDetailImage the hasDetailImage to set |
|
242 |
*/ |
|
243 |
public void setHasDetailImage(boolean hasDetailImage) { |
|
244 |
this.hasDetailImage = hasDetailImage; |
|
245 |
} |
|
246 |
|
|
247 |
/** |
|
248 |
* @return the hasSpecimenScan |
|
249 |
*/ |
|
250 |
public boolean isHasSpecimenScan() { |
|
251 |
return hasSpecimenScan; |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* @param hasSpecimenScan the hasSpecimenScan to set |
|
256 |
*/ |
|
257 |
public void setHasSpecimenScan(boolean hasSpecimenScan) { |
|
258 |
this.hasSpecimenScan = hasSpecimenScan; |
|
259 |
} |
|
260 |
/** |
|
261 |
* @return the citation |
|
262 |
*/ |
|
263 |
public String getCitation() { |
|
264 |
return citation; |
|
265 |
} |
|
266 |
/** |
|
267 |
* @param citation the citation to set |
|
268 |
*/ |
|
269 |
public void setCitation(String citation) { |
|
270 |
this.citation = citation; |
|
271 |
} |
|
272 |
|
|
273 |
|
|
274 |
public String getRecordBase() { |
|
275 |
return recordBase; |
|
276 |
} |
|
277 |
public void setRecordBase(String recordBase) { |
|
278 |
this.recordBase = recordBase; |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* @return the collection |
|
283 |
* |
|
284 |
* @deprecated TODO remove as it only duplicates the information contained in the collectionDTO |
|
285 |
*/ |
|
286 |
@Deprecated |
|
287 |
public String getCollectionCode() { |
|
288 |
if (collection != null){ |
|
289 |
return collection.getCode(); |
|
290 |
} else { |
|
291 |
return null; |
|
292 |
} |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* @return the collection |
|
297 |
*/ |
|
298 |
public CollectionDTO getCollection() { |
|
299 |
return collection; |
|
300 |
} |
|
301 |
/** |
|
302 |
* @param collection the collection to set |
|
303 |
*/ |
|
304 |
public void setCollectioDTo(CollectionDTO collection) { |
|
305 |
this.collection = collection; |
|
306 |
} |
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
public Set<DerivateDTO> getDerivates() { |
|
311 |
return derivates; |
|
312 |
} |
|
313 |
|
|
314 |
public void setDerivates(Set<DerivateDTO> derivates) { |
|
315 |
this.derivates = derivates; |
|
316 |
} |
|
317 |
|
|
318 |
public void addDerivate(DerivateDTO derivate){ |
|
319 |
if (this.derivates == null){ |
|
320 |
this.derivates = new HashSet<>(); |
|
321 |
} |
|
322 |
this.derivates.add(derivate); |
|
323 |
} |
|
324 |
public void addAllDerivates(Set<DerivateDTO> derivates){ |
|
325 |
if (this.derivates == null){ |
|
326 |
this.derivates = new HashSet<>(); |
|
327 |
} |
|
328 |
this.derivates.addAll(derivates); |
|
329 |
} |
|
330 |
|
|
331 |
public DerivationEventDTO getDerivationEvent() { |
|
332 |
return derivationEvent; |
|
333 |
} |
|
334 |
|
|
335 |
public void setDerivationEvent(DerivationEventDTO derivationEvent) { |
|
336 |
this.derivationEvent = derivationEvent; |
|
337 |
} |
|
338 |
|
|
339 |
|
|
340 |
/** |
|
341 |
* @return the listOfMedia |
|
342 |
*/ |
|
343 |
public List<MediaDTO> getListOfMedia() { |
|
344 |
return listOfMedia; |
|
345 |
} |
|
346 |
|
|
347 |
/** |
|
348 |
* @param listOfMedia the listOfMedia to set |
|
349 |
*/ |
|
350 |
public void setListOfMedia(List<MediaDTO> listOfMedia) { |
|
351 |
this.listOfMedia = listOfMedia; |
|
352 |
} |
|
353 |
|
|
354 |
public void addMedia(SpecimenOrObservationBase specimenOrObservation){ |
|
355 |
Set<DescriptionBase> descriptions = specimenOrObservation.getSpecimenDescriptionImageGallery(); |
|
356 |
for (DescriptionBase desc : descriptions){ |
|
357 |
if (desc instanceof SpecimenDescription){ |
|
358 |
SpecimenDescription specimenDesc = (SpecimenDescription)desc; |
|
359 |
for (DescriptionElementBase element : specimenDesc.getElements()){ |
|
360 |
if (element.isInstanceOf(TextData.class)&& element.getFeature().equals(Feature.IMAGE())) { |
|
361 |
for (Media media :element.getMedia()){ |
|
362 |
media.getAllTitles(); // initialize all titles!!! |
|
363 |
for (MediaRepresentation rep :media.getRepresentations()){ |
|
364 |
for(MediaRepresentationPart p : rep.getParts()){ |
|
365 |
if(p.getUri() != null){ |
|
366 |
MediaDTO dto = new MediaDTO(media.getUuid()); |
|
367 |
dto.setUri(p.getUri().toString()); |
|
368 |
this.getListOfMedia().add(dto); |
|
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
} |
|
376 |
} |
|
377 |
} |
|
378 |
public String getKindOfUnit() { |
|
379 |
return kindOfUnit; |
|
380 |
} |
|
381 |
public void setKindOfUnit(String kindOfUnit) { |
|
382 |
this.kindOfUnit = kindOfUnit; |
|
383 |
} |
|
384 |
|
|
385 |
|
|
386 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivedUnitDTO.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.dto; |
|
10 |
|
|
11 |
import java.net.URI; |
|
12 |
import java.util.AbstractMap; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.List; |
|
16 |
import java.util.Map; |
|
17 |
import java.util.Set; |
|
18 |
import java.util.UUID; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
21 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
22 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
|
23 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
24 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; |
|
25 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
26 |
|
|
27 |
|
|
28 |
/** |
|
29 |
* @author pplitzner |
|
30 |
* @since Mar 26, 2015 |
|
31 |
* |
|
32 |
*/ |
|
33 |
public class DerivedUnitDTO extends SpecimenOrObservationBaseDTO{ |
|
34 |
|
|
35 |
private static final long serialVersionUID = 2345864166579381295L; |
|
36 |
|
|
37 |
private String accessionNumber; |
|
38 |
private URI preferredStableUri; |
|
39 |
|
|
40 |
private List<AbstractMap.SimpleEntry<UUID, String>> associatedTaxa; |
|
41 |
private Map<String, List<String>> types; |
|
42 |
|
|
43 |
private List<AbstractMap.SimpleEntry<UUID, String>> determinedNames; |
|
44 |
|
|
45 |
|
|
46 |
// public DerivedUnitDTO(DerivedUnit derivedUnit){ |
|
47 |
// super(); |
|
48 |
// this.setUuid(derivedUnit.getUuid()); |
|
49 |
// this.setTitleCache(derivedUnit.getTitleCache()); |
|
50 |
// this.setAccessionNumber(derivedUnit.getAccessionNumber()); |
|
51 |
// this.setPreferredStableUri(derivedUnit.getPreferredStableUri()); |
|
52 |
// |
|
53 |
// this.setCollectioDTo(new CollectionDTO(HibernateProxyHelper.deproxy(derivedUnit.getCollection()))); |
|
54 |
// this.setBarcode(derivedUnit.getBarcode()); |
|
55 |
// this.setCatalogNumber(derivedUnit.getCatalogNumber()); |
|
56 |
// this.setCollectorsNumber(derivedUnit.getCollectorsNumber()); |
|
57 |
// if (derivedUnit.getDerivedFrom() != null){ |
|
58 |
// this.setDerivationEvent(new DerivationEventDTO(derivedUnit.getDerivedFrom() )); |
|
59 |
// } |
|
60 |
// if (derivedUnit.getPreservation()!= null){ |
|
61 |
// this.setPreservationMethod(derivedUnit.getPreservation().getMaterialMethodText()); |
|
62 |
// } |
|
63 |
// this.setRecordBase(derivedUnit.getRecordBasis().getMessage()); |
|
64 |
// this.setSources(derivedUnit.getSources()); |
|
65 |
// this.setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations()); |
|
66 |
// |
|
67 |
// } |
|
68 |
// |
|
69 |
// public static PreservedSpecimenDTO newInstance(DerivedUnit derivedUnit ){ |
|
70 |
// PreservedSpecimenDTO newInstance = new PreservedSpecimenDTO(derivedUnit); |
|
71 |
// |
|
72 |
// return newInstance; |
|
73 |
// } |
|
74 |
|
|
75 |
public static DerivedUnitDTO fromEntity(DerivedUnit entity){ |
|
76 |
if(entity == null) { |
|
77 |
return null; |
|
78 |
} |
|
79 |
return new DerivedUnitDTO(entity); |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
/** |
|
85 |
* @param derivedUnit |
|
86 |
*/ |
|
87 |
public DerivedUnitDTO(DerivedUnit derivedUnit) { |
|
88 |
super(derivedUnit); |
|
89 |
accessionNumber = derivedUnit.getAccessionNumber(); |
|
90 |
preferredStableUri = derivedUnit.getPreferredStableUri(); |
|
91 |
if (derivedUnit.getCollection() != null){ |
|
92 |
setCollectioDTo(new CollectionDTO(HibernateProxyHelper.deproxy(derivedUnit.getCollection()))); |
|
93 |
} |
|
94 |
setBarcode(derivedUnit.getBarcode()); |
|
95 |
setCatalogNumber(derivedUnit.getCatalogNumber()); |
|
96 |
listLabel = derivedUnit.getCatalogNumber(); |
|
97 |
setCollectorsNumber(derivedUnit.getCollectorsNumber()); |
|
98 |
if (derivedUnit.getDerivedFrom() != null){ |
|
99 |
setDerivationEvent(new DerivationEventDTO(HibernateProxyHelper.deproxy(derivedUnit.getDerivedFrom(), DerivationEvent.class ))); |
|
100 |
} |
|
101 |
if (derivedUnit.getPreservation()!= null){ |
|
102 |
setPreservationMethod(derivedUnit.getPreservation().getMaterialMethodText()); |
|
103 |
} |
|
104 |
setRecordBase(derivedUnit.getRecordBasis().getMessage()); |
|
105 |
setSources(derivedUnit.getSources()); |
|
106 |
setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations()); |
|
107 |
addDeterminedNames(derivedUnit.getDeterminations()); |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
public String getAccessionNumber() { |
|
113 |
return accessionNumber; |
|
114 |
} |
|
115 |
public void setAccessionNumber(String accessionNumber) { |
|
116 |
this.accessionNumber = accessionNumber; |
|
117 |
} |
|
118 |
|
|
119 |
public Map<String, List<String>> getTypes() { |
|
120 |
return types; |
|
121 |
} |
|
122 |
public void addTypes(String typeStatus, List<String> typedTaxa){ |
|
123 |
if(types==null){ |
|
124 |
types = new HashMap<String, List<String>>(); |
|
125 |
} |
|
126 |
types.put(typeStatus, typedTaxa); |
|
127 |
} |
|
128 |
|
|
129 |
public List<AbstractMap.SimpleEntry<UUID, String>> getAssociatedTaxa() { |
|
130 |
return associatedTaxa; |
|
131 |
} |
|
132 |
public void addAssociatedTaxon(Taxon taxon){ |
|
133 |
if(associatedTaxa==null){ |
|
134 |
associatedTaxa = new ArrayList<AbstractMap.SimpleEntry<UUID, String>>(); |
|
135 |
} |
|
136 |
associatedTaxa.add(new AbstractMap.SimpleEntry<UUID, String>(taxon.getUuid(), taxon.getTitleCache())); |
|
137 |
} |
|
138 |
|
|
139 |
public List<AbstractMap.SimpleEntry<UUID, String>> getDeterminedNames() { |
|
140 |
return determinedNames; |
|
141 |
} |
|
142 |
public void addDeterminedNames(Set<DeterminationEvent> determinations){ |
|
143 |
if(determinedNames==null){ |
|
144 |
determinedNames = new ArrayList<AbstractMap.SimpleEntry<UUID, String>>(); |
|
145 |
} |
|
146 |
TaxonName preferredName = null; |
|
147 |
for (DeterminationEvent event:determinations){ |
|
148 |
if (event.getPreferredFlag()){ |
|
149 |
preferredName = event.getTaxonName(); |
|
150 |
} |
|
151 |
} |
|
152 |
if (preferredName != null){ |
|
153 |
determinedNames.add(new AbstractMap.SimpleEntry<UUID, String>(preferredName.getUuid(), preferredName.getTitleCache())); |
|
154 |
}else{ |
|
155 |
for (DeterminationEvent event:determinations){ |
|
156 |
determinedNames.add(new AbstractMap.SimpleEntry<UUID, String>(event.getTaxonName().getUuid(), event.getTaxonName().getTitleCache())); |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
public void setPreferredStableUri(URI preferredStableUri) { |
|
162 |
this.preferredStableUri = preferredStableUri; |
|
163 |
} |
|
164 |
|
|
165 |
public URI getPreferredStableUri() { |
|
166 |
return preferredStableUri; |
|
167 |
} |
|
168 |
|
|
169 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DescriptionBaseDto.java | ||
---|---|---|
32 | 32 |
private static final long serialVersionUID = -1578895619195062502L; |
33 | 33 |
|
34 | 34 |
private UuidAndTitleCache<Taxon> taxonUuid; |
35 |
private DerivateDTO specimenDto;
|
|
35 |
private SpecimenOrObservationBaseDTO specimenDto;
|
|
36 | 36 |
|
37 | 37 |
private UuidAndTitleCache<TaxonName> nameUuid; |
38 | 38 |
private DescriptionBase description; // TODO use DTO instead |
... | ... | |
60 | 60 |
if(specimen instanceof FieldUnit) { |
61 | 61 |
specimenDto = FieldUnitDTO.fromEntity((FieldUnit)specimen); |
62 | 62 |
} else { |
63 |
specimenDto = PreservedSpecimenDTO.fromEntity((DerivedUnit)specimen);
|
|
63 |
specimenDto = DerivedUnitDTO.fromEntity((DerivedUnit)specimen);
|
|
64 | 64 |
} |
65 | 65 |
} |
66 | 66 |
|
... | ... | |
83 | 83 |
return taxonUuid; |
84 | 84 |
} |
85 | 85 |
|
86 |
public DerivateDTO getSpecimenDto() {
|
|
86 |
public SpecimenOrObservationBaseDTO getSpecimenDto() {
|
|
87 | 87 |
return specimenDto; |
88 | 88 |
} |
89 | 89 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
12 | 12 |
|
13 |
public class FieldUnitDTO extends DerivateDTO {
|
|
13 |
public class FieldUnitDTO extends SpecimenOrObservationBaseDTO {
|
|
14 | 14 |
|
15 | 15 |
private static final long serialVersionUID = 3981843956067273220L; |
16 | 16 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.dto; |
|
10 |
|
|
11 |
import java.net.URI; |
|
12 |
import java.util.AbstractMap; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.List; |
|
16 |
import java.util.Map; |
|
17 |
import java.util.Set; |
|
18 |
import java.util.UUID; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
21 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
22 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
|
23 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
24 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; |
|
25 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
26 |
|
|
27 |
|
|
28 |
/** |
|
29 |
* @author pplitzner |
|
30 |
* @since Mar 26, 2015 |
|
31 |
* |
|
32 |
*/ |
|
33 |
public class PreservedSpecimenDTO extends DerivateDTO{ |
|
34 |
|
|
35 |
private static final long serialVersionUID = 2345864166579381295L; |
|
36 |
|
|
37 |
private String accessionNumber; |
|
38 |
private URI preferredStableUri; |
|
39 |
|
|
40 |
private List<AbstractMap.SimpleEntry<UUID, String>> associatedTaxa; |
|
41 |
private Map<String, List<String>> types; |
|
42 |
|
|
43 |
private List<AbstractMap.SimpleEntry<UUID, String>> determinedNames; |
|
44 |
|
|
45 |
|
|
46 |
// public PreservedSpecimenDTO(DerivedUnit derivedUnit){ |
|
47 |
// super(); |
|
48 |
// this.setUuid(derivedUnit.getUuid()); |
|
49 |
// this.setTitleCache(derivedUnit.getTitleCache()); |
|
50 |
// this.setAccessionNumber(derivedUnit.getAccessionNumber()); |
|
51 |
// this.setPreferredStableUri(derivedUnit.getPreferredStableUri()); |
|
52 |
// |
|
53 |
// this.setCollectioDTo(new CollectionDTO(HibernateProxyHelper.deproxy(derivedUnit.getCollection()))); |
|
54 |
// this.setBarcode(derivedUnit.getBarcode()); |
|
55 |
// this.setCatalogNumber(derivedUnit.getCatalogNumber()); |
|
56 |
// this.setCollectorsNumber(derivedUnit.getCollectorsNumber()); |
|
57 |
// if (derivedUnit.getDerivedFrom() != null){ |
|
58 |
// this.setDerivationEvent(new DerivationEventDTO(derivedUnit.getDerivedFrom() )); |
|
59 |
// } |
|
60 |
// if (derivedUnit.getPreservation()!= null){ |
|
61 |
// this.setPreservationMethod(derivedUnit.getPreservation().getMaterialMethodText()); |
|
62 |
// } |
|
63 |
// this.setRecordBase(derivedUnit.getRecordBasis().getMessage()); |
|
64 |
// this.setSources(derivedUnit.getSources()); |
|
65 |
// this.setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations()); |
|
66 |
// |
|
67 |
// } |
|
68 |
// |
|
69 |
// public static PreservedSpecimenDTO newInstance(DerivedUnit derivedUnit ){ |
|
70 |
// PreservedSpecimenDTO newInstance = new PreservedSpecimenDTO(derivedUnit); |
|
71 |
// |
|
72 |
// return newInstance; |
|
73 |
// } |
|
74 |
|
|
75 |
public static PreservedSpecimenDTO fromEntity(DerivedUnit entity){ |
|
76 |
if(entity == null) { |
|
77 |
return null; |
|
78 |
} |
|
79 |
return new PreservedSpecimenDTO(entity); |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
/** |
|
85 |
* @param derivedUnit |
|
86 |
*/ |
|
87 |
public PreservedSpecimenDTO(DerivedUnit derivedUnit) { |
|
88 |
super(derivedUnit); |
|
89 |
accessionNumber = derivedUnit.getAccessionNumber(); |
|
90 |
preferredStableUri = derivedUnit.getPreferredStableUri(); |
|
91 |
if (derivedUnit.getCollection() != null){ |
|
92 |
setCollectioDTo(new CollectionDTO(HibernateProxyHelper.deproxy(derivedUnit.getCollection()))); |
|
93 |
} |
|
94 |
setBarcode(derivedUnit.getBarcode()); |
|
95 |
setCatalogNumber(derivedUnit.getCatalogNumber()); |
|
96 |
listLabel = derivedUnit.getCatalogNumber(); |
|
97 |
setCollectorsNumber(derivedUnit.getCollectorsNumber()); |
|
98 |
if (derivedUnit.getDerivedFrom() != null){ |
|
99 |
setDerivationEvent(new DerivationEventDTO(HibernateProxyHelper.deproxy(derivedUnit.getDerivedFrom(), DerivationEvent.class ))); |
|
100 |
} |
|
101 |
if (derivedUnit.getPreservation()!= null){ |
|
102 |
setPreservationMethod(derivedUnit.getPreservation().getMaterialMethodText()); |
|
103 |
} |
|
104 |
setRecordBase(derivedUnit.getRecordBasis().getMessage()); |
|
105 |
setSources(derivedUnit.getSources()); |
|
106 |
setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations()); |
|
107 |
addDeterminedNames(derivedUnit.getDeterminations()); |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
public String getAccessionNumber() { |
|
113 |
return accessionNumber; |
|
114 |
} |
|
115 |
public void setAccessionNumber(String accessionNumber) { |
|
116 |
this.accessionNumber = accessionNumber; |
|
117 |
} |
|
118 |
|
|
119 |
public Map<String, List<String>> getTypes() { |
|
120 |
return types; |
|
121 |
} |
|
122 |
public void addTypes(String typeStatus, List<String> typedTaxa){ |
|
123 |
if(types==null){ |
|
124 |
types = new HashMap<String, List<String>>(); |
|
125 |
} |
|
126 |
types.put(typeStatus, typedTaxa); |
|
127 |
} |
|
128 |
|
|
129 |
public List<AbstractMap.SimpleEntry<UUID, String>> getAssociatedTaxa() { |
|
130 |
return associatedTaxa; |
|
131 |
} |
|
132 |
public void addAssociatedTaxon(Taxon taxon){ |
|
133 |
if(associatedTaxa==null){ |
|
134 |
associatedTaxa = new ArrayList<AbstractMap.SimpleEntry<UUID, String>>(); |
|
135 |
} |
|
136 |
associatedTaxa.add(new AbstractMap.SimpleEntry<UUID, String>(taxon.getUuid(), taxon.getTitleCache())); |
|
137 |
} |
|
138 |
|
|
139 |
public List<AbstractMap.SimpleEntry<UUID, String>> getDeterminedNames() { |
|
140 |
return determinedNames; |
|
141 |
} |
|
142 |
public void addDeterminedNames(Set<DeterminationEvent> determinations){ |
|
143 |
if(determinedNames==null){ |
|
144 |
determinedNames = new ArrayList<AbstractMap.SimpleEntry<UUID, String>>(); |
|
145 |
} |
|
146 |
TaxonName preferredName = null; |
|
147 |
for (DeterminationEvent event:determinations){ |
|
148 |
if (event.getPreferredFlag()){ |
|
149 |
preferredName = event.getTaxonName(); |
|
150 |
} |
|
151 |
} |
|
152 |
if (preferredName != null){ |
|
153 |
determinedNames.add(new AbstractMap.SimpleEntry<UUID, String>(preferredName.getUuid(), preferredName.getTitleCache())); |
|
154 |
}else{ |
|
155 |
for (DeterminationEvent event:determinations){ |
|
156 |
determinedNames.add(new AbstractMap.SimpleEntry<UUID, String>(event.getTaxonName().getUuid(), event.getTaxonName().getTitleCache())); |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
public void setPreferredStableUri(URI preferredStableUri) { |
|
162 |
this.preferredStableUri = preferredStableUri; |
|
163 |
} |
|
164 |
|
|
165 |
public URI getPreferredStableUri() { |
|
166 |
return preferredStableUri; |
|
167 |
} |
|
168 |
|
|
169 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/SpecimenOrObservationBaseDTO.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.dto; |
|
10 |
|
|
11 |
import java.io.Serializable; |
|
12 |
import java.util.AbstractMap; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.Comparator; |
|
15 |
import java.util.HashSet; |
|
16 |
import java.util.List; |
|
17 |
import java.util.Set; |
|
18 |
import java.util.TreeSet; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
21 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
22 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
23 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
24 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
25 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
26 |
import eu.etaxonomy.cdm.model.media.Media; |
|
27 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
|
28 |
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart; |
|
29 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
30 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
31 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
32 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* @author pplitzner |
|
37 |
* @since Mar 27, 2015 |
|
38 |
*/ |
|
39 |
public abstract class SpecimenOrObservationBaseDTO extends UuidAndTitleCache<SpecimenOrObservationBase>{ |
|
40 |
|
|
41 |
private static final long serialVersionUID = -7597690654462090732L; |
|
42 |
|
|
43 |
private TreeSet<AbstractMap.SimpleEntry<String, String>> characterData; |
|
44 |
private DerivateDataDTO derivateDataDTO; |
|
45 |
protected String taxonName; |
|
46 |
protected String listLabel; |
|
47 |
|
|
48 |
protected String citation; |
|
49 |
protected boolean hasDetailImage; |
|
50 |
private boolean hasCharacterData; |
|
51 |
private boolean hasDna; |
|
52 |
private boolean hasSpecimenScan; |
|
53 |
|
|
54 |
private String recordBase; |
|
55 |
private String kindOfUnit; |
|
56 |
private CollectionDTO collection; |
|
57 |
private String catalogNumber; |
|
58 |
private String collectorsNumber; |
|
59 |
private String barcode; |
|
60 |
private String preservationMethod; |
|
61 |
private Set<SpecimenOrObservationBaseDTO> derivates; |
|
62 |
|
|
63 |
private Set<SpecimenTypeDesignationDTO> specimenTypeDesignations; |
|
64 |
|
|
65 |
private DerivationEventDTO derivationEvent; |
|
66 |
|
|
67 |
private Set<IdentifiableSource> sources; |
|
68 |
private List<MediaDTO> listOfMedia = new ArrayList<>(); |
|
69 |
|
|
70 |
protected SpecimenOrObservationBaseDTO(SpecimenOrObservationBase specimenOrObservation) { |
|
71 |
super(specimenOrObservation.getUuid(), specimenOrObservation.getId(), specimenOrObservation.getTitleCache()); |
|
72 |
addMedia(specimenOrObservation); |
|
73 |
if (specimenOrObservation.getKindOfUnit() != null){ |
|
74 |
setKindOfUnit(specimenOrObservation.getKindOfUnit().getTitleCache()); |
|
75 |
} |
|
76 |
if (specimenOrObservation instanceof DerivedUnit){ |
|
77 |
DerivedUnit derivedUnit = (DerivedUnit)specimenOrObservation; |
|
78 |
if (derivedUnit.getSpecimenTypeDesignations() != null){ |
|
79 |
setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations()); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
} |
|
85 |
// @Override |
|
86 |
// public String getTitleCache() { |
|
87 |
// return getLabel(); |
|
88 |
// } |
|
89 |
|
|
90 |
|
|
91 |
public String getListLabel() { |
|
92 |
return listLabel; |
|
93 |
} |
|
94 |
|
|
95 |
public void setListLabel(String listLabel) { |
|
96 |
this.listLabel = listLabel; |
|
97 |
} |
|
98 |
public void setCollection(CollectionDTO collection) { |
|
99 |
this.collection = collection; |
|
100 |
} |
|
101 |
|
|
102 |
public String getCatalogNumber() { |
|
103 |
return catalogNumber; |
|
104 |
} |
|
105 |
|
|
106 |
public void setCatalogNumber(String catalogNumber) { |
|
107 |
this.catalogNumber = catalogNumber; |
|
108 |
} |
|
109 |
|
|
110 |
public String getCollectorsNumber() { |
|
111 |
return collectorsNumber; |
|
112 |
} |
|
113 |
|
|
114 |
public void setCollectorsNumber(String collectorsNumber) { |
|
115 |
this.collectorsNumber = collectorsNumber; |
|
116 |
} |
|
117 |
|
|
118 |
public String getBarcode() { |
|
119 |
return barcode; |
|
120 |
} |
|
121 |
|
|
122 |
public void setBarcode(String barcode) { |
|
123 |
this.barcode = barcode; |
|
124 |
} |
|
125 |
|
|
126 |
public String getPreservationMethod() { |
|
127 |
return preservationMethod; |
|
128 |
} |
|
129 |
|
|
130 |
public void setPreservationMethod(String preservationMethod) { |
|
131 |
this.preservationMethod = preservationMethod; |
|
132 |
} |
|
133 |
|
|
134 |
public Set<SpecimenTypeDesignationDTO> getSpecimenTypeDesignations() { |
|
135 |
return specimenTypeDesignations; |
|
136 |
} |
|
137 |
|
|
138 |
public void setSpecimenTypeDesignations(Set<SpecimenTypeDesignation> specimenTypeDesignations) { |
|
139 |
this.specimenTypeDesignations = new HashSet<>(); |
|
140 |
for (SpecimenTypeDesignation typeDes: specimenTypeDesignations){ |
|
141 |
if (typeDes != null){ |
|
142 |
this.specimenTypeDesignations.add(new SpecimenTypeDesignationDTO(typeDes)); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
public Set<IdentifiableSource> getSources() { |
|
150 |
return sources; |
|
151 |
} |
|
152 |
|
|
153 |
public void setSources(Set<IdentifiableSource> sources) { |
|
154 |
this.sources = sources; |
|
155 |
} |
|
156 |
|
|
157 |
|
|
158 |
/** |
|
159 |
* @return the derivateDataDTO |
|
160 |
*/ |
|
161 |
public DerivateDataDTO getDerivateDataDTO() { |
|
162 |
return derivateDataDTO; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* @param derivateDataDTO the derivateDataDTO to set |
|
167 |
*/ |
|
168 |
public void setDerivateDataDTO(DerivateDataDTO derivateDataDTO) { |
|
169 |
this.derivateDataDTO = derivateDataDTO; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* @return the characterData |
|
174 |
*/ |
|
175 |
public TreeSet<AbstractMap.SimpleEntry<String, String>> getCharacterData() { |
|
176 |
return characterData; |
|
177 |
} |
|
178 |
|
|
179 |
public void addCharacterData(String character, String state){ |
|
180 |
if(characterData==null){ |
|
181 |
characterData = new TreeSet<AbstractMap.SimpleEntry<String,String>>(new PairComparator()); |
|
182 |
} |
|
183 |
characterData.add(new AbstractMap.SimpleEntry<>(character, state)); |
|
184 |
} |
|
185 |
|
|
186 |
private class PairComparator implements Comparator<AbstractMap.SimpleEntry<String,String>>, Serializable { |
|
187 |
|
|
188 |
private static final long serialVersionUID = -8589392050761963540L; |
|
189 |
|
|
190 |
@Override |
|
191 |
public int compare(AbstractMap.SimpleEntry<String, String> o1, AbstractMap.SimpleEntry<String, String> o2) { |
|
192 |
if(o1==null && o2!=null){ |
|
193 |
return -1; |
|
194 |
} |
|
195 |
if(o1!=null && o2==null){ |
|
196 |
return 1; |
|
197 |
} |
|
198 |
if(o1!=null && o2!=null){ |
|
199 |
return o1.getKey().compareTo(o2.getKey()); |
|
200 |
} |
|
201 |
return 0; |
|
202 |
} |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* @return the hasCharacterData |
|
207 |
*/ |
|
208 |
public boolean isHasCharacterData() { |
|
209 |
return hasCharacterData; |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* @param hasCharacterData the hasCharacterData to set |
|
214 |
*/ |
|
215 |
public void setHasCharacterData(boolean hasCharacterData) { |
|
216 |
this.hasCharacterData = hasCharacterData; |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* @return the hasDna |
|
221 |
*/ |
|
222 |
public boolean isHasDna() { |
|
223 |
return hasDna; |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* @param hasDna the hasDna to set |
|
228 |
*/ |
|
229 |
public void setHasDna(boolean hasDna) { |
|
230 |
this.hasDna = hasDna; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* @return the hasDetailImage |
|
235 |
*/ |
|
236 |
public boolean isHasDetailImage() { |
|
237 |
return hasDetailImage; |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* @param hasDetailImage the hasDetailImage to set |
|
242 |
*/ |
|
243 |
public void setHasDetailImage(boolean hasDetailImage) { |
|
244 |
this.hasDetailImage = hasDetailImage; |
|
245 |
} |
|
246 |
|
|
247 |
/** |
|
248 |
* @return the hasSpecimenScan |
|
249 |
*/ |
|
250 |
public boolean isHasSpecimenScan() { |
|
251 |
return hasSpecimenScan; |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* @param hasSpecimenScan the hasSpecimenScan to set |
|
256 |
*/ |
|
257 |
public void setHasSpecimenScan(boolean hasSpecimenScan) { |
|
258 |
this.hasSpecimenScan = hasSpecimenScan; |
|
259 |
} |
|
260 |
/** |
|
261 |
* @return the citation |
|
262 |
*/ |
|
263 |
public String getCitation() { |
|
264 |
return citation; |
|
265 |
} |
|
266 |
/** |
|
267 |
* @param citation the citation to set |
|
268 |
*/ |
|
269 |
public void setCitation(String citation) { |
|
270 |
this.citation = citation; |
|
271 |
} |
|
272 |
|
|
273 |
|
|
274 |
public String getRecordBase() { |
|
275 |
return recordBase; |
|
276 |
} |
|
277 |
public void setRecordBase(String recordBase) { |
|
278 |
this.recordBase = recordBase; |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* @return the collection |
|
283 |
* |
|
284 |
* @deprecated TODO remove as it only duplicates the information contained in the collectionDTO |
|
285 |
*/ |
|
286 |
@Deprecated |
|
287 |
public String getCollectionCode() { |
|
288 |
if (collection != null){ |
|
289 |
return collection.getCode(); |
|
290 |
} else { |
|
291 |
return null; |
|
292 |
} |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* @return the collection |
|
297 |
*/ |
|
298 |
public CollectionDTO getCollection() { |
|
299 |
return collection; |
|
300 |
} |
|
301 |
/** |
|
302 |
* @param collection the collection to set |
|
303 |
*/ |
|
304 |
public void setCollectioDTo(CollectionDTO collection) { |
|
305 |
this.collection = collection; |
|
306 |
} |
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
public Set<SpecimenOrObservationBaseDTO> getDerivates() { |
|
311 |
return derivates; |
|
312 |
} |
|
313 |
|
|
314 |
public void setDerivates(Set<SpecimenOrObservationBaseDTO> derivates) { |
|
315 |
this.derivates = derivates; |
|
316 |
} |
|
317 |
|
|
318 |
public void addDerivate(SpecimenOrObservationBaseDTO derivate){ |
|
319 |
if (this.derivates == null){ |
|
320 |
this.derivates = new HashSet<>(); |
|
321 |
} |
|
322 |
this.derivates.add(derivate); |
|
323 |
} |
|
324 |
public void addAllDerivates(Set<SpecimenOrObservationBaseDTO> derivates){ |
|
325 |
if (this.derivates == null){ |
|
326 |
this.derivates = new HashSet<>(); |
|
327 |
} |
|
328 |
this.derivates.addAll(derivates); |
|
329 |
} |
|
330 |
|
|
331 |
public DerivationEventDTO getDerivationEvent() { |
|
332 |
return derivationEvent; |
|
333 |
} |
|
334 |
|
|
335 |
public void setDerivationEvent(DerivationEventDTO derivationEvent) { |
|
336 |
this.derivationEvent = derivationEvent; |
|
337 |
} |
|
338 |
|
|
339 |
|
|
340 |
/** |
|
341 |
* @return the listOfMedia |
|
342 |
*/ |
|
343 |
public List<MediaDTO> getListOfMedia() { |
|
344 |
return listOfMedia; |
|
345 |
} |
|
346 |
|
|
347 |
/** |
|
348 |
* @param listOfMedia the listOfMedia to set |
|
349 |
*/ |
|
350 |
public void setListOfMedia(List<MediaDTO> listOfMedia) { |
|
351 |
this.listOfMedia = listOfMedia; |
|
352 |
} |
|
353 |
|
|
354 |
public void addMedia(SpecimenOrObservationBase specimenOrObservation){ |
|
355 |
Set<DescriptionBase> descriptions = specimenOrObservation.getSpecimenDescriptionImageGallery(); |
|
356 |
for (DescriptionBase desc : descriptions){ |
|
357 |
if (desc instanceof SpecimenDescription){ |
|
358 |
SpecimenDescription specimenDesc = (SpecimenDescription)desc; |
|
359 |
for (DescriptionElementBase element : specimenDesc.getElements()){ |
|
360 |
if (element.isInstanceOf(TextData.class)&& element.getFeature().equals(Feature.IMAGE())) { |
|
361 |
for (Media media :element.getMedia()){ |
|
362 |
media.getAllTitles(); // initialize all titles!!! |
|
363 |
for (MediaRepresentation rep :media.getRepresentations()){ |
|
364 |
for(MediaRepresentationPart p : rep.getParts()){ |
Also available in: Unified diff
ref #9252 harmonizing SpecimenOrOberservationBase related DTOs - renaming classes