Project

General

Profile

Revision f2716206

IDf271620621cdd711088426b54e38849230129afc
Parent 38017a1c
Child 16345de5

Added by Katja Luther over 3 years ago

fix #7433: get specimen by genetic accession number

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/occurrence/OccurrenceDaoHibernateImpl.java
1040 1040
        return results;
1041 1041
    }
1042 1042

  
1043
    /**
1044
     * {@inheritDoc}
1045
     */
1046
    @Override
1047
    public List<DerivedUnit> getByGeneticAccessionNumber(String accessionNumberString, List<String> propertyPaths) {
1048
        String queryString = "SELECT dnaSample FROM DnaSample dnaSample join dnaSample.sequences sequence WHERE sequence.geneticAccessionNumber LIKE :accessionNumberString";
1049
        Query query = getSession().createQuery(queryString);
1050
        query.setParameter("accessionNumberString", accessionNumberString);
1051
        List results = query.list();
1052
        defaultBeanInitializer.initializeAll(results, propertyPaths);
1053
        return results;
1054
    }
1055

  
1043 1056
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/occurrence/IOccurrenceDao.java
409 409
     * @return a list of field units referencing the gathering event
410 410
     */
411 411
    public List<FieldUnit> getFieldUnitsForGatheringEvent(UUID gatheringEventUuid, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
412

  
413
    /**
414
    *
415
    * Returns {@link DerivedUNit} that has the accession number
416
    * @param accessionNumber
417
    * @param propertyPaths
418
    * @return a derived unit
419
    */
420
   public List<DerivedUnit> getByGeneticAccessionNumber(String accessionNumberString, List<String> propertyPaths);
412 421
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IOccurrenceService.java
658 658
    public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(
659 659
            FindOccurrencesConfigurator config);
660 660

  
661
    /**
662
     * @param queryString
663
     * @param propertyPaths
664
     * @return
665
     * @throws IOException
666
     */
667
    List<DerivedUnit> findByAccessionNumber(
668
             String accessionNumberString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
669
            List<String> propertyPaths);
670

  
661 671
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
790 790
    }
791 791

  
792 792
    @Override
793
    public  List<DerivedUnit> findByAccessionNumber(
794
            String accessionNumberString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
795
            List<String> propertyPaths)  {
796

  
797
        List<DerivedUnit> records = new ArrayList<>();
798
        records = dao.getByGeneticAccessionNumber(accessionNumberString, propertyPaths);
799

  
800
        return records;
801

  
802
    }
803

  
804
    @Override
793 805
    public Pager<SearchResult<SpecimenOrObservationBase>> findByFullText(
794 806
            Class<? extends SpecimenOrObservationBase> clazz, String queryString, Rectangle boundingBox, List<Language> languages,
795 807
            boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java
926 926
        UUID derivedUnit1Uuid = UUID.fromString("843bc8c9-c0fe-4735-bf40-82f1996dcefb");
927 927
        UUID derivedUnit2Uuid = UUID.fromString("40cd9cb1-7c74-4e7d-a1f8-8a1e0314e940");
928 928
        UUID dnaSampleUuid = UUID.fromString("364969a6-2457-4e2e-ae1e-29a6fcaa741a");
929
        UUID dnaSampleWithSequenceUuid = UUID.fromString("571d4e9a-0736-4da3-ad4a-a2df427a1f01");
929 930
        UUID tissueUuid = UUID.fromString("b608613c-1b5a-4882-8b14-d643b6fc5998");
930 931

  
931 932
        UUID taxonUuid = UUID.fromString("dfca7629-8a60-4d51-998d-371897f725e9");
......
999 1000
        SpecimenOrObservationBase derivedUnit2 = occurrenceService.load(derivedUnit2Uuid);
1000 1001
        SpecimenOrObservationBase tissue = occurrenceService.load(tissueUuid);
1001 1002
        SpecimenOrObservationBase dnaSample = occurrenceService.load(dnaSampleUuid);
1003
        SpecimenOrObservationBase dnaSampleWithSequence = occurrenceService.load(dnaSampleWithSequenceUuid);
1002 1004
        Taxon taxon = (Taxon) taxonService.load(taxonUuid);
1003 1005

  
1004 1006
        assertNotNull(derivedUnit1);
......
1010 1012
        // wildcard search => all derivates
1011 1013
        FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
1012 1014
        config.setTitleSearchString("*");
1013
        assertEquals(4, occurrenceService.countOccurrences(config));
1015
        assertEquals(5, occurrenceService.countOccurrences(config));
1014 1016
        List<SpecimenOrObservationBase> allDerivates = occurrenceService.findByTitle(config).getRecords();
1015
        assertEquals(4, allDerivates.size());
1017
        assertEquals(5, allDerivates.size());
1016 1018
        assertTrue(allDerivates.contains(derivedUnit1));
1017 1019
        assertTrue(allDerivates.contains(derivedUnit2));
1018 1020
        assertTrue(allDerivates.contains(tissue));
......
1031 1033
        // class search => 4 results
1032 1034
        config = new FindOccurrencesConfigurator();
1033 1035
        config.setClazz(SpecimenOrObservationBase.class);
1034
        assertEquals(4, occurrenceService.countOccurrences(config));
1036
        assertEquals(5, occurrenceService.countOccurrences(config));
1035 1037
        List<SpecimenOrObservationBase> specimenOrObservationBases = occurrenceService.findByTitle(config).getRecords();
1036
        assertEquals(4, specimenOrObservationBases.size());
1038
        assertEquals(5, specimenOrObservationBases.size());
1037 1039

  
1038 1040
        // class search => 0 results
1039 1041
        config = new FindOccurrencesConfigurator();
......
1045 1047
        // class search => 4 results
1046 1048
        config = new FindOccurrencesConfigurator();
1047 1049
        config.setClazz(DerivedUnit.class);
1048
        assertEquals(4, occurrenceService.countOccurrences(config));
1050
        assertEquals(5, occurrenceService.countOccurrences(config));
1049 1051
        List<SpecimenOrObservationBase> derivedUnits = occurrenceService.findByTitle(config).getRecords();
1050
        assertEquals(4, derivedUnits.size());
1052
        assertEquals(5, derivedUnits.size());
1051 1053
        assertTrue(derivedUnits.contains(derivedUnit1));
1052 1054
        assertTrue(derivedUnits.contains(derivedUnit2));
1053 1055
        assertTrue(derivedUnits.contains(tissue));
......
1122 1124
        //all specimen
1123 1125
        config = new FindOccurrencesConfigurator();
1124 1126
        config.setAssignmentStatus(AssignmentStatus.ALL_SPECIMENS);
1125
        assertEquals(4, occurrenceService.countOccurrences(config));
1127
        assertEquals(5, occurrenceService.countOccurrences(config));
1126 1128
        List<SpecimenOrObservationBase> allSpecimens = occurrenceService.findByTitle(config).getRecords();
1127
        assertEquals(4, allSpecimens.size());
1129
        assertEquals(5, allSpecimens.size());
1128 1130
        assertTrue(allSpecimens.contains(derivedUnit1));
1129 1131
        assertTrue(allSpecimens.contains(derivedUnit2));
1130 1132
        assertTrue(allSpecimens.contains(tissue));
......
1142 1144
        //unassigned specimen
1143 1145
        config = new FindOccurrencesConfigurator();
1144 1146
        config.setAssignmentStatus(AssignmentStatus.UNASSIGNED_SPECIMENS);
1145
        assertEquals(2, occurrenceService.countOccurrences(config));
1147
        assertEquals(3, occurrenceService.countOccurrences(config));
1146 1148
        List<SpecimenOrObservationBase> unAssignedSpecimens = occurrenceService.findByTitle(config).getRecords();
1147
        assertEquals(2, unAssignedSpecimens.size());
1149
        assertEquals(3, unAssignedSpecimens.size());
1148 1150
        assertTrue(unAssignedSpecimens.contains(derivedUnit2));
1149 1151
        assertTrue(unAssignedSpecimens.contains(dnaSample));
1150 1152

  
......
1159 1161
        assertTrue(ignoreAssignmentStatusSpecimens.contains(tissue));
1160 1162

  
1161 1163

  
1164

  
1165
        List<DerivedUnit> findByAccessionNumber = occurrenceService.findByAccessionNumber("ACC_DNA", 10, 1, null, null);
1166

  
1167
        assertEquals(1, findByAccessionNumber.size());
1168
       // assertTrue(findByAccessionNumber.contains(derivedUnit1));
1169
        assertTrue(findByAccessionNumber.contains(dnaSampleWithSequence));
1170

  
1171

  
1162 1172
    }
1163 1173

  
1164 1174
    @Test
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.testFindOcurrences.xml
4 4
  <SPECIMENOROBSERVATIONBASE DTYPE="DerivedUnit" ID="5001" CREATED="2015-05-13 06:21:28.0" UUID="364969a6-2457-4e2e-ae1e-29a6fcaa741a" UPDATED="2015-05-13 06:21:28.885" RECORDBASIS="DS" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="dna" PUBLISH="true" INDIVIDUALCOUNT="[null]" ACCESSIONNUMBER="[null]" BARCODE="[null]" CATALOGNUMBER="ACC1" COLLECTORSNUMBER="[null]" EXSICCATUM="[null]" ORIGINALLABELINFO="[null]" FIELDNOTES="[null]" FIELDNUMBER="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" LIFESTAGE_ID="[null]" SEX_ID="[null]" KINDOFUNIT_ID="[null]" COLLECTION_ID="[null]" DERIVEDFROM_ID="5000" STOREDUNDER_ID="[null]" PRESERVATION_ID="[null]" GATHERINGEVENT_ID="[null]" PRIMARYCOLLECTOR_ID="[null]" MEDIASPECIMEN_ID="[null]" DNAQUALITY_ID="[null]" PROTECTEDIDENTITYCACHE="true" IDENTITYCACHE="ID1"/>
5 5
  <SPECIMENOROBSERVATIONBASE DTYPE="DerivedUnit" ID="5002" CREATED="2015-05-13 06:21:28.0" UUID="40cd9cb1-7c74-4e7d-a1f8-8a1e0314e940" UPDATED="[null]" RECORDBASIS="PS" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="testUnit2" PUBLISH="true" INDIVIDUALCOUNT="[null]" ACCESSIONNUMBER="[null]" BARCODE="ACC2" CATALOGNUMBER="[null]" COLLECTORSNUMBER="[null]" EXSICCATUM="[null]" ORIGINALLABELINFO="[null]" FIELDNOTES="[null]" FIELDNUMBER="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" LIFESTAGE_ID="[null]" SEX_ID="[null]" KINDOFUNIT_ID="[null]" COLLECTION_ID="[null]" DERIVEDFROM_ID="[null]" STOREDUNDER_ID="[null]" PRESERVATION_ID="[null]" GATHERINGEVENT_ID="[null]" PRIMARYCOLLECTOR_ID="[null]" MEDIASPECIMEN_ID="[null]" DNAQUALITY_ID="[null]" PROTECTEDIDENTITYCACHE="true" IDENTITYCACHE="ID1"/>
6 6
  <SPECIMENOROBSERVATIONBASE DTYPE="DerivedUnit" ID="5003" CREATED="2015-05-13 06:21:28.0" UUID="b608613c-1b5a-4882-8b14-d643b6fc5998" UPDATED="[null]" RECORDBASIS="TS" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="tissue" PUBLISH="true" INDIVIDUALCOUNT="[null]" ACCESSIONNUMBER="[null]" BARCODE="[null]" CATALOGNUMBER="[null]" COLLECTORSNUMBER="[null]" EXSICCATUM="[null]" ORIGINALLABELINFO="[null]" FIELDNOTES="[null]" FIELDNUMBER="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" LIFESTAGE_ID="[null]" SEX_ID="[null]" KINDOFUNIT_ID="[null]" COLLECTION_ID="[null]" DERIVEDFROM_ID="[null]" STOREDUNDER_ID="[null]" PRESERVATION_ID="[null]" GATHERINGEVENT_ID="[null]" PRIMARYCOLLECTOR_ID="[null]" MEDIASPECIMEN_ID="[null]" DNAQUALITY_ID="[null]" PROTECTEDIDENTITYCACHE="true" IDENTITYCACHE="ID1"/>
7
  <SPECIMENOROBSERVATIONBASE DTYPE="DnaSample" ID="5004" CREATED="2015-05-13 06:21:28.0" UUID="571d4e9a-0736-4da3-ad4a-a2df427a1f01" UPDATED="[null]" RECORDBASIS="DS" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="dnaSample" PUBLISH="true" INDIVIDUALCOUNT="[null]" ACCESSIONNUMBER="[null]" BARCODE="[null]" CATALOGNUMBER="[null]" COLLECTORSNUMBER="[null]" EXSICCATUM="[null]" ORIGINALLABELINFO="[null]" FIELDNOTES="[null]" FIELDNUMBER="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" LIFESTAGE_ID="[null]" SEX_ID="[null]" KINDOFUNIT_ID="[null]" COLLECTION_ID="[null]" DERIVEDFROM_ID="[null]" STOREDUNDER_ID="[null]" PRESERVATION_ID="[null]" GATHERINGEVENT_ID="[null]" PRIMARYCOLLECTOR_ID="[null]" MEDIASPECIMEN_ID="[null]" DNAQUALITY_ID="[null]" PROTECTEDIDENTITYCACHE="true" IDENTITYCACHE="ID1"/>
8
  <SEQUENCE ID="5000" CREATED="2014-12-01 12:47:11.0" UUID="9387dc64-d547-42a7-a454-f05788996444" UPDATED="2014-12-01 12:47:11.225" CONSENSUSSEQUENCE_LENGTH="5" CONSENSUSSEQUENCE_STRING="ATTCG" GENETICACCESSIONNUMBER="ACC_DNA" DNASAMPLE_ID="5004"/>
7 9
  <SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT ORIGINALS_ID="5000" DERIVATIONEVENTS_ID="5000"/>
8 10
  <DERIVATIONEVENT ID="5000" CREATED="2015-05-13 06:21:28.0" UUID="37a56fa7-46f0-4044-93e1-2f8d246a4b32" UPDATED="2015-05-13 06:21:28.884" DESCRIPTION="[null]" TIMEPERIOD_END="[null]" TIMEPERIOD_FREETEXT="[null]" TIMEPERIOD_START="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" ACTOR_ID="[null]" INSTITUTION_ID="[null]" TYPE_ID="2001"/>
9 11
  <DESCRIPTIONELEMENTBASE DTYPE="IndividualsAssociation" ID="5000" CREATED="2015-05-13 06:21:28.0" UUID="4494efe9-ae4c-40b5-9609-eb7d7416b043" UPDATED="2015-05-13 06:21:28.902" NAME="[null]" TIMEPERIOD_START="[null]" TIMEPERIOD_END="[null]" TIMEPERIOD_FREETEXT="[null]" ORDERRELEVANT="[null]" UNKNOWNDATA="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" FEATURE_ID="2052" INDESCRIPTION_ID="5000" AREA_ID="[null]" LANGUAGE_ID="[null]" STATUS_ID="[null]" ASSOCIATEDSPECIMENOROBSERVATION_ID="5000" UNIT_ID="[null]" TAXON2_ID="[null]" FORMAT_ID="[null]"/>

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)