Project

General

Profile

Revision a7e45124

IDa7e4512432be8ef2eec32969da78eb7c305cffbd
Parent 6b91c396
Child fdd2fa78

Added by Katja Luther about 3 years ago

code cleaning

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
247 247
                }else{
248 248
                    csvLine[table.getIndex(CdmLightExportTable.SEC_REFERENCE)] = getTitleCache(taxon.getSec());
249 249
                }
250
                if (state.getReferenceFromStore(taxon.getSec().getId()) == null){
251
                    handleReference(state, taxon.getSec());
250
                if (taxon.getSec() != null){
251
                    if (state.getReferenceFromStore(taxon.getSec().getId()) == null){
252
                        handleReference(state, taxon.getSec());
253
                    }
252 254
                }
253 255
                csvLine[table.getIndex(CdmLightExportTable.CLASSIFICATION_ID)] = getId(state, taxonNode.getClassification());
254 256
                csvLine[table.getIndex(CdmLightExportTable.CLASSIFICATION_TITLE)] = taxonNode.getClassification().getTitleCache();
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrenceController.java
110 110
        FieldUnitDTO fieldUnitDto = null;
111 111
        if(sob instanceof DerivedUnit){
112 112

  
113
            fieldUnitDto = service.findFieldUnitDTO(PreservedSpecimenDTO.newInstance(sob, null) , new ArrayList<FieldUnitDTO>(), new HashMap<UUID, DerivateDTO>());
113
            fieldUnitDto = service.findFieldUnitDTO(PreservedSpecimenDTO.newInstance(sob) , new ArrayList<FieldUnitDTO>(), new HashMap<UUID, DerivateDTO>());
114 114

  
115 115
        }
116 116

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
48 48
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator;
49 49
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
50 50
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
51
import eu.etaxonomy.cdm.api.service.dto.DNASampleDTO;
51 52
import eu.etaxonomy.cdm.api.service.dto.DerivateDTO;
52 53
import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO;
53 54
import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO.ContigFile;
......
742 743
        for (DerivationEvent derivationEvent : specimen.getDerivationEvents()) {
743 744
            for (DerivedUnit derivative : derivationEvent.getDerivatives()) {
744 745
                if (!alreadyCollectedSpecimen.containsKey(specimenDto.getUuid())){
745
                    PreservedSpecimenDTO dto = PreservedSpecimenDTO.newInstance(derivative, null);
746
                    PreservedSpecimenDTO dto;
747
                    if (derivative instanceof DnaSample) {
748
                        dto = new DNASampleDTO(derivative);
749
                    } else {
750
                        dto = PreservedSpecimenDTO.newInstance(derivative);
751
                    }
746 752
                    alreadyCollectedSpecimen.put(dto.getUuid(), dto);
747 753
                    dto.addAllDerivates(getDerivedUnitDTOsFor(dto, derivative, alreadyCollectedSpecimen));
748 754
                    derivedUnits.add(dto);
......
849 855
            List<SpecimenOrObservationBase> perTaxonOccurrences = dao.listByAssociatedTaxon(null,taxon, null, null, null, null);
850 856
            for (SpecimenOrObservationBase<?> o : perTaxonOccurrences) {
851 857
                if (o.isInstanceOf(DerivedUnit.class)){
852
                    DerivedUnit derivedUnit = HibernateProxyHelper.deproxy(o, DerivedUnit.class);
853
                    DerivateDTO derivedUnitDTO = PreservedSpecimenDTO.newInstance(derivedUnit, taxon.getName());
858
                    DerivedUnit derivedUnit;
859
                    DerivateDTO derivedUnitDTO;
860
                    if (o.isInstanceOf(DnaSample.class)) {
861
                         derivedUnit = HibernateProxyHelper.deproxy(o, DnaSample.class);
862
                        derivedUnitDTO = new DNASampleDTO(derivedUnit);
863
                    } else {
864
                        derivedUnit = HibernateProxyHelper.deproxy(o, DerivedUnit.class);
865
                        derivedUnitDTO = PreservedSpecimenDTO.newInstance(derivedUnit);
866
                    }
854 867
                    if (alreadyCollectedSpecimen.get(derivedUnitDTO.getUuid()) == null){
855 868
                        alreadyCollectedSpecimen.put(derivedUnitDTO.getUuid(), derivedUnitDTO);
856 869
                    }
......
865 878

  
866 879
    }
867 880

  
868
//=======
869
//<<<<<<< Updated upstream
870
//=======
871
//    @SuppressWarnings("unchecked")
872
//    @Override
873
//    public List<FieldUnitDTO> findFieldUnitDTOByAssociatedTaxon(Set<TaxonRelationshipEdge> includedRelationships,
874
//            UUID associatedTaxonUuid) {
875
//
876
//        Set<Taxon> taxa = new HashSet<>();
877
//        Set<Integer> occurrenceIds = new HashSet<>();
878
//        List<FieldUnitDTO> fieldUnitDTOs = new ArrayList<>();
879
//        HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen = new HashMap<>();
880
//        List<SpecimenOrObservationBase> occurrences = new ArrayList<>();
881
//        boolean includeUnpublished = INCLUDE_UNPUBLISHED;
882
//
883
//        // Integer limit = PagerUtils.limitFor(pageSize);
884
//        // Integer start = PagerUtils.startFor(pageSize, pageNumber);
885
//
886
//        Taxon associatedTaxon = (Taxon) taxonService.load(associatedTaxonUuid);
887
//
888
//
889
//        if (includedRelationships != null) {
890
//            taxa = taxonService.listRelatedTaxa(associatedTaxon, includedRelationships, null, includeUnpublished, null, null, null);
891
//        }
892
//
893
//        taxa.add(associatedTaxon);
894
//
895
//        for (Taxon taxon : taxa) {
896
//            List<SpecimenOrObservationBase> perTaxonOccurrences = dao.listByAssociatedTaxon(null,taxon, null, null, null, null);
897
//            for (SpecimenOrObservationBase<?> o : perTaxonOccurrences) {
898
//                if (o.isInstanceOf(DerivedUnit.class)){
899
//                    DerivedUnit derivedUnit = HibernateProxyHelper.deproxy(o, DerivedUnit.class);
900
//                    DerivateDTO derivedUnitDTO;
901
//                    //DNASampleDTO dnaDto;
902
//                    if (derivedUnit instanceof DnaSample){
903
//                        derivedUnitDTO = DNASampleDTO.newInstance((DnaSample)derivedUnit);
904
//                    }else{
905
//                        derivedUnitDTO = PreservedSpecimenDTO.newInstance(derivedUnit);
906
//                    }
907
//                    if (alreadyCollectedSpecimen.get(derivedUnitDTO.getUuid()) == null){
908
//                        alreadyCollectedSpecimen.put(derivedUnitDTO.getUuid(), derivedUnitDTO);
909
//                    }
910
//                    derivedUnitDTO.addAllDerivates(getDerivedUnitDTOsFor(derivedUnitDTO, derivedUnit, alreadyCollectedSpecimen));
911
//                    FieldUnitDTO dto = this.findFieldUnitDTO(derivedUnitDTO, fieldUnitDTOs, alreadyCollectedSpecimen);
912
//                    if (dto != null){
913
//                        dto.addTaxonRelatedDerivedUnits(derivedUnitDTO);
914
//                    }
915
//                }
916
//            }
917
//
918
//        }
919
//
920
//        return fieldUnitDTOs;
921
//
922
//    }
923
//
924
//>>>>>>> Stashed changes
925
//>>>>>>> Stashed changes
881

  
882

  
926 883
    @Override
927 884
    public  List<DerivedUnit> findByAccessionNumber(
928 885
            String accessionNumberString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
......
1073 1030
                fieldUnitDto.addDerivate(derivedUnitDTO);
1074 1031
                fieldUnits.add(fieldUnitDto);
1075 1032
            }else{
1076
                DerivateDTO originalDTO = PreservedSpecimenDTO.newInstance((DerivedUnit)specimen, null);
1033
                DerivateDTO originalDTO;
1034
                if (specimen instanceof DnaSample){
1035
                    originalDTO = new DNASampleDTO((DnaSample)specimen);
1036
                } else {
1037
                    originalDTO = PreservedSpecimenDTO.newInstance((DerivedUnit)specimen);
1038
                }
1077 1039
                originalDTO.addDerivate(derivedUnitDTO);
1078 1040
                fieldUnitDto = findFieldUnitDTO(originalDTO, fieldUnits, alreadyCollectedSpecimen);
1079 1041
            }
......
1089 1051
    }
1090 1052

  
1091 1053
    @Override
1092
//=======
1093
//<<<<<<< Updated upstream
1094
//=======
1095
//
1096
//    public FieldUnitDTO findFieldUnitDTO(DerivateDTO derivedUnitDTO, Collection<FieldUnitDTO> fieldUnits, HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen) {
1097
//        //It will search recursively over all {@link DerivationEvent}s and get the "originals" ({@link SpecimenOrObservationBase})
1098
//        //from which this DerivedUnit was derived until all FieldUnits are found.
1099
//        List<SpecimenOrObservationBase> specimens = new ArrayList<>();
1100
//        List<String> propertyPaths = new ArrayList<>();
1101
//        propertyPaths.add("descriptions.elements.media.title");
1102
//
1103
//        specimens = dao.findOriginalsForDerivedUnit(derivedUnitDTO.getUuid(), propertyPaths);
1104
//
1105
//        if (specimens.size() > 1){
1106
//            logger.debug("The derived unit with uuid " + derivedUnitDTO.getUuid() + "has more than one orginal");
1107
//        }
1108
//      //  for (SpecimenOrObservationBase specimen: specimens){
1109
//        SpecimenOrObservationBase specimen = null;
1110
//        if (specimens.size() > 0){
1111
//            specimen = specimens.get(0);
1112
//        }else{
1113
//            return null;
1114
//        }
1115
//        FieldUnitDTO fieldUnitDto = null;
1116
//        if (alreadyCollectedSpecimen.get(specimen.getUuid()) != null){
1117
//            alreadyCollectedSpecimen.get(specimen.getUuid()).addDerivate(derivedUnitDTO);
1118
//            if (specimen instanceof FieldUnit){
1119
//                return (FieldUnitDTO)alreadyCollectedSpecimen.get(specimen.getUuid());
1120
//            }else{
1121
//                fieldUnitDto = findFieldUnitDTO(alreadyCollectedSpecimen.get(specimen.getUuid()), fieldUnits, alreadyCollectedSpecimen);
1122
//            }
1123
//
1124
////            if ( alreadyCollectedSpecimen.get(specimen.getUuid()) instanceof FieldUnitDTO){
1125
////                ((FieldUnitDTO)alreadyCollectedSpecimen.get(specimen.getUuid())).getTaxonRelatedDerivedUnits().add(derivedUnitDTO.getUuid());
1126
////            }
1127
//        }else{
1128
//            if (specimen.isInstanceOf(FieldUnit.class)){
1129
//                fieldUnitDto = FieldUnitDTO.newInstance((FieldUnit)specimen);
1130
//
1131
//                fieldUnitDto.addPreservedSpecimenDTO((PreservedSpecimenDTO)derivedUnitDTO);
1132
//                fieldUnits.add(fieldUnitDto);
1133
//            }else{
1134
//                DerivateDTO originalDTO = PreservedSpecimenDTO.newInstance((DerivedUnit)specimen);
1135
//                originalDTO.addDerivate(derivedUnitDTO);
1136
//                fieldUnitDto = findFieldUnitDTO(originalDTO, fieldUnits, alreadyCollectedSpecimen);
1137
//            }
1138
//
1139
//        }
1140
//      //  }
1141
//        alreadyCollectedSpecimen.put(derivedUnitDTO.getUuid(), derivedUnitDTO);
1142
//
1143
//        return fieldUnitDto;
1144
//
1145
//    }
1146
//
1147
//    @Override
1148
//>>>>>>> Stashed changes
1149
//>>>>>>> Stashed changes
1150 1054
    @Transactional(readOnly = false)
1151 1055
    public UpdateResult moveSequence(DnaSample from, DnaSample to, Sequence sequence) {
1152 1056
        return moveSequence(from.getUuid(), to.getUuid(), sequence.getUuid());

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)