Project

General

Profile

Revision 26ab7583

ID26ab7583b89c109f051c9e085abbc3516c7e799a
Parent 273b0cdc
Child 603aecbe

Added by Andreas Müller about 3 years ago

ref #7745 add subtree filter to taxon search (not yet tested for subtree != null)

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
151 151
        return result;
152 152
    }
153 153

  
154
    //TODO needed? Currently only used by tests.
154 155
    public List<TaxonBase> getTaxaByName(boolean doTaxa, boolean doSynonyms, boolean includeUnpublished,
155 156
            String queryString, MatchMode matchMode, Integer pageSize, Integer pageNumber) {
156 157
        return getTaxaByName(doTaxa, doSynonyms, false, false, false,
157
                queryString, null, matchMode, null, includeUnpublished, null, pageSize, pageNumber, null);
158
                queryString, null, null, matchMode, null, includeUnpublished, null, pageSize, pageNumber, null);
158 159
    }
159 160

  
160 161
    @Override
......
175 176
    @Override
176 177
    public List<TaxonBase> getTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, boolean doCommonNames,
177 178
            boolean includeAuthors,
178
            String queryString, Classification classification,
179
            String queryString, Classification classification, TaxonNode subtree,
179 180
            MatchMode matchMode, Set<NamedArea> namedAreas, boolean includeUnpublished, NameSearchOrder order,
180 181
            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
181 182

  
182 183
        boolean doCount = false;
183 184

  
184 185
        String searchField = includeAuthors ? "titleCache" : "nameCache";
185
        Query query = prepareTaxaByName(doTaxa, doSynonyms, doMisappliedNames, doCommonNames, includeUnpublished, searchField, queryString, classification, matchMode, namedAreas, order, pageSize, pageNumber, doCount);
186
        Query query = prepareTaxaByName(doTaxa, doSynonyms, doMisappliedNames, doCommonNames, includeUnpublished, searchField, queryString, classification, subtree, matchMode, namedAreas, order, pageSize, pageNumber, doCount);
186 187

  
187 188
        if (query != null){
188 189
            @SuppressWarnings({ "unchecked", "rawtypes" })
......
204 205
    @Override
205 206
    @SuppressWarnings("unchecked")
206 207
    public List<UuidAndTitleCache<? extends IdentifiableEntity>> getTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doNamesWithoutTaxa,
207
            boolean doMisappliedNames, boolean doCommonNames, boolean includeUnpublished, String queryString, Classification classification,
208
            boolean doMisappliedNames, boolean doCommonNames, boolean includeUnpublished, String queryString, Classification classification, TaxonNode subtree,
208 209
            MatchMode matchMode, Set<NamedArea> namedAreas, NameSearchOrder order) {
209 210

  
210 211
        if (order == null){
......
230 231
        	}
231 232
        }
232 233
        Query query = prepareTaxaByNameForEditor(doTaxa, doSynonyms, doMisappliedNames, doCommonNames, includeUnpublished,
233
                "nameCache", queryString, classification, matchMode, namedAreas, doCount, order);
234
                "nameCache", queryString, classification, subtree, matchMode, namedAreas, doCount, order);
234 235

  
235 236
        if (query != null){
236 237
            List<Object[]> results = query.list();
......
291 292
     *
292 293
     */
293 294
    private Query prepareTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, boolean doCommonNames,
294
            boolean includeUnpublished, String searchField, String queryString, Classification classification,
295
            boolean includeUnpublished, String searchField, String queryString, Classification classification, TaxonNode subtree,
295 296
            MatchMode matchMode, Set<NamedArea> namedAreas, boolean doCount, NameSearchOrder order) {
296 297
        return prepareByNameQuery(doTaxa, doSynonyms, doMisappliedNames, doCommonNames, includeUnpublished,
297 298
                searchField, queryString,
298
                classification, matchMode, namedAreas, order, doCount, true);
299
                classification, subtree, matchMode, namedAreas, order, doCount, true);
299 300
    }
300 301

  
301 302

  
......
320 321
     */
321 322
    private Query prepareByNameQuery(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames,
322 323
                boolean doCommonNames, boolean includeUnpublished, String searchField, String queryString,
323
                Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas,
324
                Classification classification, TaxonNode subtree, MatchMode matchMode, Set<NamedArea> namedAreas,
324 325
                NameSearchOrder order, boolean doCount, boolean returnIdAndTitle){
325 326

  
326 327
            boolean doProParteSynonyms = doSynonyms;  //we may distinguish in future
......
356 357
            }
357 358

  
358 359
            Subselects subSelects = createByNameHQLString(doConceptRelations,
359
                    includeUnpublished, classification, areasExpanded, matchMode, searchField);
360
                    includeUnpublished, classification, subtree, areasExpanded, matchMode, searchField);
360 361
            String taxonSubselect = subSelects.taxonSubselect;
361 362
            String synonymSubselect = subSelects.synonymSubselect;
362 363
            String conceptSelect = subSelects.conceptSelect;
......
546 547
     */
547 548
    private Query prepareTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames,
548 549
            boolean doCommonNames, boolean includeUnpublished, String searchField, String queryString,
549
            Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas, NameSearchOrder order, Integer pageSize, Integer pageNumber, boolean doCount) {
550
            Classification classification, TaxonNode subtree, MatchMode matchMode, Set<NamedArea> namedAreas, NameSearchOrder order, Integer pageSize, Integer pageNumber, boolean doCount) {
550 551

  
551 552
        Query query = prepareByNameQuery(doTaxa, doSynonyms, doMisappliedNames, doCommonNames, includeUnpublished,
552
                searchField, queryString, classification, matchMode, namedAreas, order, doCount, false);
553
                searchField, queryString, classification, subtree, matchMode, namedAreas, order, doCount, false);
553 554

  
554 555
        if(pageSize != null && !doCount && query != null) {
555 556
            query.setMaxResults(pageSize);
......
592 593

  
593 594
    @Override
594 595
    public long countTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, boolean doCommonNames,
595
            boolean doIncludeAuthors, String queryString, Classification classification,
596
            boolean doIncludeAuthors, String queryString, Classification classification, TaxonNode subtree,
596 597
        MatchMode matchMode, Set<NamedArea> namedAreas, boolean includeUnpublished) {
597 598

  
598 599
        boolean doCount = true;
......
608 609
        String searchField = doIncludeAuthors ? "titleCache": "nameCache";
609 610

  
610 611
        Query query = prepareTaxaByName(doTaxa, doSynonyms, doMisappliedNames, doCommonNames, includeUnpublished,
611
                searchField, queryString, classification, matchMode, namedAreas, null, null, null, doCount);
612
                searchField, queryString, classification, subtree, matchMode, namedAreas, null, null, null, doCount);
612 613
        if (query != null) {
613 614
            return (Long)query.uniqueResult();
614 615
        }else{
......
665 666
    }
666 667

  
667 668
    @Override
668
    public List<TaxonBase> findByNameTitleCache(boolean doTaxa, boolean doSynonyms, boolean includeUnpublished, String queryString, Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas, NameSearchOrder order, Integer pageNumber, Integer pageSize, List<String> propertyPaths) {
669
    public List<TaxonBase> findByNameTitleCache(boolean doTaxa, boolean doSynonyms, boolean includeUnpublished, String queryString, Classification classification, TaxonNode subtree, MatchMode matchMode, Set<NamedArea> namedAreas, NameSearchOrder order, Integer pageNumber, Integer pageSize, List<String> propertyPaths) {
669 670

  
670 671
        boolean doCount = false;
671
        Query query = prepareTaxaByName(doTaxa, doSynonyms, false, false, includeUnpublished, "titleCache", queryString, classification, matchMode, namedAreas, order, pageSize, pageNumber, doCount);
672
        Query query = prepareTaxaByName(doTaxa, doSynonyms, false, false, includeUnpublished, "titleCache", queryString, classification, subtree, matchMode, namedAreas, order, pageSize, pageNumber, doCount);
672 673
        if (query != null){
673 674
            @SuppressWarnings({ "unchecked", "rawtypes" })
674 675
            List<TaxonBase> results = query.list();
......
1444 1445
    }
1445 1446

  
1446 1447
    private Subselects createByNameHQLString(boolean doConceptRelations,
1447
                boolean includeUnpublished, Classification classification,  Set<NamedArea> areasExpanded,
1448
                MatchMode matchMode, String searchField){
1448
                boolean includeUnpublished, Classification classification, TaxonNode subtree,
1449
                Set<NamedArea> areasExpanded, MatchMode matchMode, String searchField){
1449 1450

  
1450 1451
        boolean doAreaRestriction = areasExpanded.size() > 0;
1451 1452
        String doAreaRestrictionSubSelect =
......
1489 1490
                   " LEFT JOIN com.feature f ";
1490 1491

  
1491 1492

  
1492
        String doClassificationWhere = " tn.classification = :classification";
1493
        String doClassificationForConceptRelationsWhere = " tn2.classification = :classification";
1493
        String doTreeWhere = classification == null ? "" : " AND tn.classification = :classification";
1494
        String doTreeForConceptRelationsWhere = classification == null ? "": " AND tn2.classification = :classification";
1495

  
1496
        String doSubtreeWhere = subtree == null? "":" AND tn.treeIndex like :treeIndexLike";
1497
        String doSubtreeForConceptRelationsWhere = subtree == null? "":" AND tn2.treeindex like :treeIndexLike";
1494 1498

  
1495 1499
        String doAreaRestrictionWhere =  " e.area.uuid in (:namedAreasUuids)";
1496 1500
        String doCommonNamesRestrictionWhere = " (f.supportsCommonTaxonName = true and com.name "+matchMode.getMatchOperator()+" :queryString )";
......
1504 1508
        String conceptSelect = null;
1505 1509
        String commonNameSubselect = null;
1506 1510

  
1507
        if(classification != null ){
1511
        if(classification != null || subtree != null){
1508 1512
            if (!doConceptRelations){
1509 1513
                if(doAreaRestriction){
1510 1514
                    taxonSubselect = String.format(doAreaRestrictionSubSelect, "t") + doTaxonNameJoin +
1511
                            " WHERE " + doAreaRestrictionWhere +
1512
                            "  AND " + doClassificationWhere +
1515
                            " WHERE (1=1) AND " + doAreaRestrictionWhere +
1516
                                doTreeWhere + doSubtreeWhere +
1513 1517
                            "  AND " + String.format(doSearchFieldWhere, "n");
1514 1518
                    synonymSubselect = String.format(doAreaRestrictionSubSelect, "s") + doSynonymNameJoin +
1515
                            " WHERE " + doAreaRestrictionWhere +
1516
                            "  AND " + doClassificationWhere +
1519
                            " WHERE (1=1) AND " + doAreaRestrictionWhere +
1520
                                doTreeWhere + doSubtreeWhere +
1517 1521
                            "  AND " + String.format(doSearchFieldWhere, "sn");
1518 1522
                    commonNameSubselect =  String.format(doAreaRestrictionSubSelect, "t") + doCommonNamesJoin +
1519
                            " WHERE " +  doAreaRestrictionWhere +
1520
                            "  AND " + doClassificationWhere +
1523
                            " WHERE (1=1) AND " +  doAreaRestrictionWhere +
1524
                                 doTreeWhere + doSubtreeWhere +
1521 1525
                            "  AND " + String.format(doSearchFieldWhere, "n") +
1522 1526
                            "  AND " + doCommonNamesRestrictionWhere;
1523 1527
                } else {//no area restriction
1524 1528
                    taxonSubselect = String.format(doTaxonSubSelect, "t" )+ doTaxonNameJoin +
1525
                            " WHERE " + doClassificationWhere +
1529
                            " WHERE (1=1) " + doTreeWhere + doSubtreeWhere +
1526 1530
                            "  AND " + String.format(doSearchFieldWhere, "n");
1527 1531
                    synonymSubselect = String.format(doTaxonSubSelect, "s" ) + doSynonymNameJoin +
1528
                            " WHERE " + doClassificationWhere +
1532
                            " WHERE (1=1) " + doTreeWhere + doSubtreeWhere +
1529 1533
                            "  AND " + String.format(doSearchFieldWhere, "sn");
1530 1534
                    commonNameSubselect =String.format(doTaxonSubSelect, "t" )+ doCommonNamesJoin +
1531
                            " WHERE " + doClassificationWhere +
1535
                            " WHERE (1=1) " + doTreeWhere + doSubtreeWhere +
1532 1536
                            "  AND " + doCommonNamesRestrictionWhere;
1533 1537
                }
1534 1538
            }else{ //concept relations included
......
1536 1540
                    conceptSelect = String.format(doAreaRestrictionConceptRelationSubSelect, "t") + doTaxonNameJoin + doConceptRelationJoin  +
1537 1541
                            " WHERE " + doAreaRestrictionWhere +
1538 1542
                            "  AND " + String.format(doSearchFieldWhere, "n") +
1539
                            "  AND " + doClassificationForConceptRelationsWhere +
1543
                                 doTreeForConceptRelationsWhere + doSubtreeForConceptRelationsWhere +
1540 1544
                            "  AND " + doRelationshipTypeComparison;
1541 1545
                    taxonSubselect = String.format(doAreaRestrictionSubSelect, "t") + doTaxonNameJoin +
1542 1546
                            " WHERE " + doAreaRestrictionWhere +
1543 1547
                            "  AND " + String.format(doSearchFieldWhere, "n") +
1544
                            "  AND " + doClassificationWhere;
1548
                                doTreeWhere + doSubtreeWhere;
1545 1549
                    synonymSubselect = String.format(doAreaRestrictionSubSelect, "s") + doSynonymNameJoin +
1546 1550
                            " WHERE " + doAreaRestrictionWhere +
1547
                            "  AND " + doClassificationWhere +
1551
                                doTreeWhere + doSubtreeWhere +
1548 1552
                            "  AND " + String.format(doSearchFieldWhere, "sn");
1549 1553
                    commonNameSubselect= String.format(doAreaRestrictionSubSelect, "t")+ doCommonNamesJoin +
1550 1554
                            " WHERE " + doAreaRestrictionWhere +
1551
                            "  AND " + doClassificationWhere +
1555
                                doTreeWhere + doSubtreeWhere +
1552 1556
                            "  AND " + doCommonNamesRestrictionWhere;
1553 1557
                } else {//no area restriction
1554 1558
                    conceptSelect = String.format(doTaxonMisappliedNameSubSelect, "t" ) + doTaxonNameJoin + doConceptRelationJoin +
1555 1559
                            " WHERE " + String.format(doSearchFieldWhere, "n") +
1556
                            "  AND " + doClassificationForConceptRelationsWhere +
1560
                                  doTreeForConceptRelationsWhere + doSubtreeForConceptRelationsWhere +
1557 1561
                            "  AND " + doRelationshipTypeComparison;
1558 1562
                    taxonSubselect = String.format(doTaxonSubSelect, "t" ) + doTaxonNameJoin +
1559 1563
                            " WHERE " +  String.format(doSearchFieldWhere, "n") +
1560
                            " AND "+ doClassificationWhere;
1564
                                 doTreeWhere + doSubtreeWhere;
1561 1565
                    synonymSubselect = String.format(doTaxonSubSelect, "s" ) + doSynonymNameJoin +
1562
                            " WHERE " + doClassificationWhere +
1566
                            " WHERE (1=1) " + doTreeWhere + doSubtreeWhere +
1563 1567
                            "  AND " +  String.format(doSearchFieldWhere, "sn");
1564 1568
                    commonNameSubselect= String.format(doTaxonSubSelect, "t")+ doCommonNamesJoin +
1565
                            " WHERE " + doClassificationWhere +
1569
                            " WHERE (1=1) " + doTreeWhere + doSubtreeWhere +
1566 1570
                            "  AND " + doCommonNamesRestrictionWhere;
1567 1571
                }
1568 1572
            }
1569
        } else { //classification = null
1573
        } else { //classification = null && subtree = null
1570 1574
            if(doAreaRestriction){
1571 1575
                conceptSelect = String.format(doAreaRestrictionConceptRelationSubSelect, "t") + doTaxonNameJoin + doConceptRelationJoin +
1572 1576
                        " WHERE " + doAreaRestrictionWhere +
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonDao.java
96 96
     * @param doSynonyms
97 97
     * @param queryString
98 98
     * @param classification TODO
99
     * @param subtree
99 100
     * @param matchMode
100 101
     * @param namedAreas TODO
101 102
     * @param pageSize
......
104 105
     * @return list of found taxa
105 106
     */
106 107
    public List<TaxonBase> getTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, boolean doCommonNames,
107
            boolean includeAuthors, String queryString, Classification classification,
108
            boolean includeAuthors, String queryString, Classification classification, TaxonNode subtree,
108 109
            MatchMode matchMode, Set<NamedArea> namedAreas, boolean includeUnpublished,
109 110
            NameSearchOrder order, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
110 111

  
......
113 114
     * @param doSynonyms
114 115
     * @param queryString
115 116
     * @param classification TODO
117
     * @param subtree
116 118
     * @param matchMode
117 119
     * @param namedAreas
118 120
     * @param pageSize
......
121 123
     * @return
122 124
     */
123 125
    public long countTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, boolean doCommonNames,
124
            boolean doIncludeAuthors, String queryString, Classification classification,
126
            boolean doIncludeAuthors, String queryString, Classification classification, TaxonNode subtree,
125 127
            MatchMode matchMode, Set<NamedArea> namedAreas, boolean includeUnpublished);
126 128

  
127
//	/**
128
//	 * @param queryString
129
//	 * @param matchMode
130
//	 * @param accepted
131
//	 * @return
132
//	 */
133
//	public Integer countTaxaByName(String queryString, MatchMode matchMode,
134
//			Boolean accepted);
135

  
136
//	/**
137
//	 * Returns a count of TaxonBase instances where the
138
//	 * taxon.name properties match the parameters passed.
139
//	 *
140
//	 * @param queryString search string
141
//	 * @param matchMode way how search string shall be matched: exact, beginning, or anywhere
142
//	 * @param selectModel all taxon base, taxa, or synonyms
143
//	 */
144
//	public Integer countTaxaByName(String queryString, MatchMode matchMode, SelectMode selectMode);
145 129

  
146 130
    /**
147 131
     * Returns a count of TaxonBase instances where the
......
201 185
     * @return
202 186
     */
203 187
    public List<TaxonBase> findByNameTitleCache(boolean doTaxa, boolean doSynonyms, boolean includeUnpublished,
204
            String queryString, Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas,
188
            String queryString, Classification classification, TaxonNode subtree, MatchMode matchMode, Set<NamedArea> namedAreas,
205 189
            NameSearchOrder order, Integer pageNumber, Integer pageSize, List<String> propertyPaths) ;
206 190

  
207 191
    /**
......
368 352

  
369 353
    public List<UuidAndTitleCache<? extends IdentifiableEntity>> getTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doNamesWithoutTaxa,
370 354
            boolean doMisappliedNames, boolean doCommonNames, boolean includeUnpublished,
371
            String queryString, Classification classification,
355
            String queryString, Classification classification, TaxonNode subtree,
372 356
            MatchMode matchMode, Set<NamedArea> namedAreas, NameSearchOrder order);
373 357

  
374 358
    public List<String> taxaByNameNotInDB(List<String> taxonNames);
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java
234 234
    public void testGetTaxaByNameWithMisappliedNames(){
235 235

  
236 236
        Classification classification = classificationDao.load(classificationUuid);
237

  
237
        TaxonNode subtree = null;
238 238
        /* NOTE:
239 239
         * The testdata contains 3 misapplied names (1. nameCache = Aus, 2. nameCache = Rethera, 3. nameCache = Daphnis),
240 240
         * two contained in the classification used in this test,
......
243 243
         */
244 244
        //two accepted taxa starting with R in classification "TestBaum"
245 245
        @SuppressWarnings("rawtypes")
246
        List<TaxonBase> results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, "R*", classification, MatchMode.BEGINNING,
246
        List<TaxonBase> results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, "R*", classification, subtree, MatchMode.BEGINNING,
247 247
                null, includeUnpublished, null, null, null, null);
248 248
        Assert.assertEquals("There should be 2 Taxa", 2, results.size());
249 249

  
250 250
        //three taxa, 2 accepted and 1 misapplied name starting with R
251
        results = taxonDao.getTaxaByName(doTaxa, noSynonyms, doMisapplied, noCommonNames, false, "R*", null, MatchMode.BEGINNING,
251
        results = taxonDao.getTaxaByName(doTaxa, noSynonyms, doMisapplied, noCommonNames, false, "R*", null, subtree, MatchMode.BEGINNING,
252 252
                null, includeUnpublished, null, null, null, null);
253 253
        Assert.assertEquals("There should be 3 Taxa", 3, results.size());
254 254

  
255 255
        //one synonym has no accepted taxon
256
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "A*", null, MatchMode.BEGINNING,
256
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "A*", null, subtree, MatchMode.BEGINNING,
257 257
                null, includeUnpublished, null, null, null, null);
258 258
        Assert.assertEquals("There should be 11 Taxa",11, results.size());
259 259

  
260 260
        //two accepted taxa in classification and 1 misapplied name with accepted name in classification
261
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "R*", classification, MatchMode.BEGINNING,
261
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "R*", classification, subtree, MatchMode.BEGINNING,
262 262
                null, includeUnpublished, null, null, null, null);
263 263
        Assert.assertEquals("There should be 3 Taxa", 3, results.size());
264 264
        //same with unpublished
265 265
        includeUnpublished = false;
266
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "R*", classification, MatchMode.BEGINNING,
266
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "R*", classification, subtree, MatchMode.BEGINNING,
267 267
                null, includeUnpublished, null, null, null, null);
268 268
        Assert.assertEquals("There should be 3 Taxa", 3, results.size());
269 269
        includeUnpublished = true;
270 270

  
271 271

  
272 272
        //same as above because all taxa, synonyms and misapplied names starting with R are in the classification
273
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "R*", null, MatchMode.BEGINNING,
273
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, "R*", null, subtree, MatchMode.BEGINNING,
274 274
                null, includeUnpublished, null, null, null, null);
275 275
        Assert.assertEquals("There should be 3 Taxa", 3, results.size());
276 276

  
277 277
        //find misapplied names with accepted taxon in the classification, the accepted taxa of two misapplied names are in the classification
278
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "*", classification, MatchMode.BEGINNING,
278
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "*", classification, subtree, MatchMode.BEGINNING,
279 279
                null, includeUnpublished, null, null, null, null);
280 280
        Assert.assertEquals("There should be 2 Taxa", 2, results.size());
281 281

  
282 282
        //find misapplied names beginning with R
283
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "R*", null, MatchMode.BEGINNING,
283
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "R*", null, subtree, MatchMode.BEGINNING,
284 284
                null, includeUnpublished, null, null, null, null);
285 285
        Assert.assertEquals("There should be 1 Taxa", 1, results.size());
286 286

  
287 287
        //find all three misapplied names
288
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "*", null, MatchMode.BEGINNING,
288
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "*", null, subtree, MatchMode.BEGINNING,
289 289
                null, includeUnpublished, null, null, null, null);
290 290
        Assert.assertEquals("There should be 3 Taxa", 3, results.size());
291 291

  
......
296 296
    @Test
297 297
    @DataSet (loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
298 298
    public void testGetTaxaByNameVariants(){
299
        TaxonNode subtree = null;
299 300
        @SuppressWarnings("rawtypes")
300
        List<TaxonBase> results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", null, MatchMode.BEGINNING,
301
        List<TaxonBase> results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", null, subtree, MatchMode.BEGINNING,
301 302
                null, includeUnpublished, null, null, null, null);
302 303
        Assert.assertEquals("There should be 2 Taxa",2, results.size());
303 304

  
304
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, doCommonNames, false, "R*", null, MatchMode.BEGINNING,
305
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, doCommonNames, false, "R*", null, subtree, MatchMode.BEGINNING,
305 306
                null, includeUnpublished, null, null, null, null);
306 307
        Assert.assertEquals("There should be 1 Taxa", 1, results.size());
307 308

  
308
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, doMisapplied, doCommonNames, false, "R*", null, MatchMode.BEGINNING,
309
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, doMisapplied, doCommonNames, false, "R*", null, subtree, MatchMode.BEGINNING,
309 310
                null, includeUnpublished, null, null, null, null);
310 311
        Assert.assertEquals("There should be 1 Taxa", 1, results.size());
311 312

  
312
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, doCommonNames, false, "c*", null, MatchMode.BEGINNING,
313
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, doCommonNames, false, "c*", null, subtree, MatchMode.BEGINNING,
313 314
                null, includeUnpublished, null, null, null, null);
314 315
        Assert.assertEquals("There should be 2 Taxa", 2, results.size());
315 316

  
316
        results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", null, MatchMode.BEGINNING,
317
        results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", null, subtree, MatchMode.BEGINNING,
317 318
                null, includeUnpublished, null, null, null, null);
318 319
        Assert.assertEquals("There should be 2 Taxa", 2, results.size());
319 320

  
320 321
        Classification classification = classificationDao.load(classificationUuid);
321
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", classification, MatchMode.BEGINNING,
322
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", classification, subtree, MatchMode.BEGINNING,
322 323
                null, includeUnpublished, null, null, null, null);
323 324
        Assert.assertEquals("There should be 1 Taxa", 1, results.size());
324 325

  
325 326
        Set<NamedArea> namedAreas = new HashSet<>();
326 327
        namedAreas.add((NamedArea)definedTermDao.load(southernAmericaUuid));
327
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", null, MatchMode.BEGINNING,
328
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "c*", null, subtree, MatchMode.BEGINNING,
328 329
                namedAreas, includeUnpublished, null, null, null, null);
329 330
        Assert.assertEquals("There should be 1 Taxa", 1, results.size());
330 331
    }
......
335 336
    @Test
336 337
    @DataSet
337 338
    public void testGetTaxaByNameForEditor() {
339
        TaxonNode subtree = null;
338 340
        Reference sec = referenceDao.findById(1);
339 341
        assert sec != null : "sec must exist";
340 342

  
341 343
        @SuppressWarnings("rawtypes")
342 344
        List<UuidAndTitleCache<? extends IdentifiableEntity>> results = taxonDao.getTaxaByNameForEditor(
343
                doTaxa, doSynonyms, noMisapplied, noCommonNames, false, includeUnpublished, "Acher", null, MatchMode.BEGINNING, null, null);
345
                doTaxa, doSynonyms, noMisapplied, noCommonNames, false, includeUnpublished, "Acher", null, subtree, MatchMode.BEGINNING, null, null);
344 346
        assertNotNull("getTaxaByName should return a List", results);
345 347
        assertFalse("The list should not be empty", results.isEmpty());
346 348
        assertEquals(4, results.size());
347 349

  
348 350

  
349
        results = taxonDao.getTaxaByNameForEditor(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,includeUnpublished, "A",null, MatchMode.BEGINNING, null, null);
351
        results = taxonDao.getTaxaByNameForEditor(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,includeUnpublished, "A",null, subtree, MatchMode.BEGINNING, null, null);
350 352
        assertNotNull("getTaxaByName should return a List", results);
351 353
        assertEquals(7, results.size());
352 354

  
353 355

  
354
        results = taxonDao.getTaxaByNameForEditor(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, includeUnpublished, "A", null, MatchMode.BEGINNING, null, null);
356
        results = taxonDao.getTaxaByNameForEditor(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, includeUnpublished, "A", null, subtree, MatchMode.BEGINNING, null, null);
355 357
        assertNotNull("getTaxaByName should return a List", results);
356 358
        assertEquals(5, results.size());
357 359
        assertEquals(results.get(0).getType(), Taxon.class);
358 360

  
359
        results = taxonDao.getTaxaByNameForEditor(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, includeUnpublished, "A", null, MatchMode.BEGINNING, null, null);
361
        results = taxonDao.getTaxaByNameForEditor(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, includeUnpublished, "A", null, subtree, MatchMode.BEGINNING, null, null);
360 362
        assertNotNull("getTaxaByName should return a List", results);
361 363
        assertEquals(2, results.size());
362 364
        assertEquals(results.get(0).getType(), Synonym.class);
363 365

  
364
        results = taxonDao.getTaxaByNameForEditor(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,includeUnpublished, "Aus", null, MatchMode.EXACT, null, null);
366
        results = taxonDao.getTaxaByNameForEditor(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,includeUnpublished, "Aus", null, subtree, MatchMode.EXACT, null, null);
365 367
        assertNotNull("getTaxaByName should return a List", results);
366 368
        assertEquals("Results list should contain one entity",1,results.size());
367 369

  
368
        results = taxonDao.getTaxaByNameForEditor(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, includeUnpublished, "A", null, MatchMode.BEGINNING, null, null);
370
        results = taxonDao.getTaxaByNameForEditor(doTaxa, doSynonyms, doMisapplied, noCommonNames, false, includeUnpublished, "A", null, subtree, MatchMode.BEGINNING, null, null);
369 371
        assertNotNull("getTaxaByName should return a List", results);
370 372
        assertEquals("Results list should contain one entity", 8, results.size());
371 373

  
......
381 383
    @Test
382 384
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
383 385
    public void testGetTaxaByNameAndArea() {
384

  
386
        TaxonNode subtree = null;
385 387
        Set<NamedArea> namedAreas = new HashSet<>();
386 388
        namedAreas.add((NamedArea)definedTermDao.load(northernAmericaUuid));
387 389
        //namedAreas.add((NamedArea)definedTermDao.load(southernAmericaUuid));
388 390
        //namedAreas.add((NamedArea)definedTermDao.load(antarcticaUuid));
389 391

  
390
        Classification taxonmicTree = classificationDao.findByUuid(classificationUuid);
392
        Classification classification = classificationDao.findByUuid(classificationUuid);
391 393

  
392 394
        // prepare some synonym relation ships for some tests
393 395
        Synonym synAtroposAgassiz = (Synonym)taxonDao.findByUuid(atroposAgassiz);
......
406 408
        //long numberOfTaxa = taxonDao.countTaxaByName(Taxon.class, "Rethera", null, MatchMode.BEGINNING, namedAreas);
407 409

  
408 410
        @SuppressWarnings("rawtypes")
409
        List<TaxonBase> results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, "Rethera", null, MatchMode.BEGINNING, namedAreas,
411
        List<TaxonBase> results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, "Rethera", null, subtree, MatchMode.BEGINNING, namedAreas,
410 412
                includeUnpublished, null, null, null, null);
411 413
        assertNotNull("getTaxaByName should return a List", results);
412 414
        assertTrue("expected to find two taxa but found "+results.size(), results.size() == 2);
413 415

  
414
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "com*", null, MatchMode.BEGINNING, namedAreas,
416
        results = taxonDao.getTaxaByName(noTaxa, noSynonyms, noMisapplied, doCommonNames, false, "com*", null, subtree, MatchMode.BEGINNING, namedAreas,
415 417
                includeUnpublished, null, null, null, null);
416 418
            assertNotNull("getTaxaByName should return a List", results);
417 419
            assertTrue("expected to find one taxon but found "+results.size(), results.size() == 1);
418 420

  
419 421
        // 2. searching for a taxon (Rethera) contained in a specific classification
420
        results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, "Rethera", taxonmicTree, MatchMode.BEGINNING, namedAreas,
422
        results = taxonDao.getTaxaByName(doTaxa, noSynonyms, noMisapplied, noCommonNames, false, "Rethera", classification, subtree, MatchMode.BEGINNING, namedAreas,
421 423
                includeUnpublished, null, null, null, null);
422 424
        assertNotNull("getTaxaByName should return a List", results);
423 425
        assertTrue("expected to find one taxon but found "+results.size(), results.size() == 1);
424 426

  
425 427

  
426 428
        // 3. searching for Synonyms
427
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "Atropo", null, MatchMode.ANYWHERE, null,
429
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "Atropo", null, subtree, MatchMode.ANYWHERE, null,
428 430
                includeUnpublished, null, null, null, null);
429 431
        assertNotNull("getTaxaByName should return a List", results);
430 432
        /*System.err.println(results.get(0).getTitleCache() + " - " +results.get(1).getTitleCache() + " - " +results.get(2).getTitleCache() );
......
435 437
        assertTrue("expected to find three taxa but found "+results.size(), results.size() == 3);
436 438

  
437 439
        // 4. searching for Synonyms
438
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false,"Atropo", null, MatchMode.BEGINNING, null,
440
        results = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false,"Atropo", null, subtree, MatchMode.BEGINNING, null,
439 441
                includeUnpublished, null, null, null, null);
440 442
        assertNotNull("getTaxaByName should return a List", results);
441 443
        assertTrue("expected to find three taxa but found "+results.size(), results.size() == 3);
442 444

  
443 445

  
444 446
        // 5. searching for a Synonyms and Taxa
445
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,"A", null, MatchMode.BEGINNING, namedAreas,
447
        results = taxonDao.getTaxaByName(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,"A", null, subtree, MatchMode.BEGINNING, namedAreas,
446 448
                includeUnpublished, null, null, null, null);
447 449
        //only five taxa have a distribution
448 450
        assertNotNull("getTaxaByName should return a List", results);
......
451 453

  
452 454

  
453 455
    /**
454
     * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#findByNameTitleCache(Class<? extends TaxonBase>clazz, String queryString, Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageNumber, Integer pageSize, List<String> propertyPaths)}
456
     * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#findByNameTitleCache(Class<? extends TaxonBase>clazz, String queryString, Classification classification, TaxonNode subtree, MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageNumber, Integer pageSize, List<String> propertyPaths)}
455 457
     * restricting the search by a set of Areas.
456 458
     */
457 459
    @Test
458 460
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
459 461
    public void testFindByNameTitleCache() {
462
        TaxonNode subtree = null;
460 463

  
461 464
        Set<NamedArea> namedAreas = new HashSet<>();
462 465
        namedAreas.add((NamedArea)definedTermDao.load(northernAmericaUuid));
......
479 482
        //long numberOfTaxa = taxonDao.countTaxaByName(Taxon.class, "Rethera", null, MatchMode.BEGINNING, namedAreas);
480 483

  
481 484
        @SuppressWarnings("rawtypes")
482
        List<TaxonBase> results = taxonDao.findByNameTitleCache(true, false, includeUnpublished, "Rethera Rothschild & Jordan, 1903", null, MatchMode.EXACT, namedAreas,
485
        List<TaxonBase> results = taxonDao.findByNameTitleCache(true, false, includeUnpublished, "Rethera Rothschild & Jordan, 1903", null, subtree, MatchMode.EXACT, namedAreas,
483 486
                null, null, null, null);
484 487
        assertNotNull("getTaxaByName should return a List", results);
485 488
        assertTrue("expected to find two taxa but found "+results.size(), results.size() == 2);
486 489

  
487 490
        // 2. searching for a taxon (Rethera) contained in a specific classification
488
        results = taxonDao.findByNameTitleCache(true, false, includeUnpublished, "Rethera Rothschild & Jordan, 1903", classification, MatchMode.EXACT, namedAreas,
491
        results = taxonDao.findByNameTitleCache(true, false, includeUnpublished, "Rethera Rothschild & Jordan, 1903", classification, subtree, MatchMode.EXACT, namedAreas,
489 492
                null, null, null, null);
490 493
        assertNotNull("getTaxaByName should return a List", results);
491 494
        assertTrue("expected to find one taxon but found "+results.size(), results.size() == 1);
492 495

  
493 496

  
494 497
        // 3. searching for Synonyms
495
        results = taxonDao.findByNameTitleCache(false, true, includeUnpublished, "*Atropo", null, MatchMode.ANYWHERE, null,
498
        results = taxonDao.findByNameTitleCache(false, true, includeUnpublished, "*Atropo", null, subtree, MatchMode.ANYWHERE, null,
496 499
                null, null, null, null);
497 500
        assertNotNull("getTaxaByName should return a List", results);
498 501
        assertTrue("expected to find two taxa but found "+results.size(), results.size() == 2);
499 502

  
500 503
        // 4. searching for Synonyms
501
        results = taxonDao.findByNameTitleCache(false, true, includeUnpublished, "Atropo", null, MatchMode.BEGINNING, null,
504
        results = taxonDao.findByNameTitleCache(false, true, includeUnpublished, "Atropo", null, subtree, MatchMode.BEGINNING, null,
502 505
                null, null, null, null);
503 506
        assertNotNull("getTaxaByName should return a List", results);
504 507
        assertTrue("expected to find two taxa but found "+results.size(), results.size() == 2);
......
511 514
        tax.addSynonym(syn, SynonymType.HETEROTYPIC_SYNONYM_OF());
512 515

  
513 516
        taxonDao.save(tax);
514
        results = taxonDao.findByNameTitleCache(true, true, includeUnpublished, "A", null, MatchMode.BEGINNING, namedAreas,
517
        results = taxonDao.findByNameTitleCache(true, true, includeUnpublished, "A", null, subtree, MatchMode.BEGINNING, namedAreas,
515 518
                null, null, null, null);
516 519
        assertNotNull("getTaxaByName should return a List", results);
517 520
        assertTrue("expected to find 8 taxa but found "+results.size(), results.size() == 8);
......
520 523
    @Test
521 524
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
522 525
    public void testTaxonNameInTwoClassifications(){
526
        TaxonNode subtree = null;
523 527
        List<String> propertyPaths = new ArrayList<>();
524 528
        propertyPaths.add("taxonNodes");
525 529
        @SuppressWarnings("rawtypes")
526
        List<TaxonBase> taxa = taxonDao.getTaxaByName(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,"P", null, MatchMode.BEGINNING,
530
        List<TaxonBase> taxa = taxonDao.getTaxaByName(doTaxa, doSynonyms, noMisapplied, noCommonNames, false,"P", null, subtree, MatchMode.BEGINNING,
527 531
                null, includeUnpublished, null, null, null, null);
528 532
        Taxon taxon = (Taxon)taxa.get(0);
529 533
        Set<TaxonNode> nodes = taxon.getTaxonNodes();
......
535 539
    @Test
536 540
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
537 541
    public void testGetTaxaByNameProParteSynonym(){
538

  
542
        TaxonNode subtree = null;
539 543
        @SuppressWarnings("rawtypes")
540
        List<TaxonBase> taxa = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "A", null,
544
        List<TaxonBase> taxa = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "A", null,subtree,
541 545
                MatchMode.BEGINNING, null, includeUnpublished, null, null, null, null);
542 546
        Assert.assertEquals("2 synonyms and 1 pro parte synonym should be returned.", 3, taxa.size());
543 547
        assertTrue("Pro parte should exist", existsInCollection(taxa, acherontiaLachesis));
......
545 549
        assertTrue("2. normal synonym should exist", existsInCollection(taxa, atroposOken));
546 550
        //TODO shouldn't we also find orphaned synonyms (without accepted taxon) like Atropos Leach?
547 551

  
548
        taxa = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "A", null,
552
        taxa = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "A", null,subtree,
549 553
                MatchMode.BEGINNING, null, NO_UNPUBLISHED, null, null, null, null);
550 554
        Assert.assertEquals("2 synonyms and no pro parte synonym should be returned.", 2, taxa.size());
551 555
        assertTrue("Normal synonym should exist", existsInCollection(taxa, atroposAgassiz));
552 556
        assertTrue("2. normal synonym should exist", existsInCollection(taxa, atroposOken));
553 557

  
554
        taxa = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "A", null,
558
        taxa = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "A", null,subtree,
555 559
                MatchMode.BEGINNING, null, includeUnpublished, null, null, null, null);
556 560
        Assert.assertEquals("1 misapplied name, no pro parte synonym should be returned.", 1, taxa.size());
557 561
        assertTrue("Pro parte should exist", existsInCollection(taxa, aus));
......
592 596
    @Test
593 597
    @DataSet
594 598
    public void testCountTaxaByName() {
595
        long numberOfTaxa = taxonDao.countTaxaByName(true, false, false, false,false, "A", null, MatchMode.BEGINNING, null, includeUnpublished);
599
        TaxonNode subtree = null;
600
        long numberOfTaxa = taxonDao.countTaxaByName(true, false, false, false,false, "A", null, subtree, MatchMode.BEGINNING, null, includeUnpublished);
596 601
        assertEquals(5, numberOfTaxa);
597
        numberOfTaxa = taxonDao.countTaxaByName(true, false, false, false, false,"Smerinthus kindermannii", null, MatchMode.EXACT, null, includeUnpublished);
602
        numberOfTaxa = taxonDao.countTaxaByName(true, false, false, false, false,"Smerinthus kindermannii", null, subtree, MatchMode.EXACT, null, includeUnpublished);
598 603
        assertEquals(1, numberOfTaxa);
599
        numberOfTaxa = taxonDao.countTaxaByName(false, true, false, false, false,"A", null, MatchMode.BEGINNING, null, includeUnpublished);
604
        numberOfTaxa = taxonDao.countTaxaByName(false, true, false, false, false,"A", null, subtree, MatchMode.BEGINNING, null, includeUnpublished);
600 605
        assertEquals(2, numberOfTaxa);
601
        numberOfTaxa = taxonDao.countTaxaByName(true, true, false, false, false,"A", null, MatchMode.BEGINNING, null, includeUnpublished);
606
        numberOfTaxa = taxonDao.countTaxaByName(true, true, false, false, false,"A", null, subtree, MatchMode.BEGINNING, null, includeUnpublished);
602 607
        assertEquals(7, numberOfTaxa);
603
        numberOfTaxa = taxonDao.countTaxaByName(true, true, false, false,false, "Aasfwerfwf fffe", null, MatchMode.BEGINNING, null, includeUnpublished);
608
        numberOfTaxa = taxonDao.countTaxaByName(true, true, false, false,false, "Aasfwerfwf fffe", null, subtree, MatchMode.BEGINNING, null, includeUnpublished);
604 609
        assertEquals(0, numberOfTaxa);
605 610
//	FIXME implement test for search in specific classification
606 611
//		Reference reference = referenceDao.findByUuid(UUID.fromString("596b1325-be50-4b0a-9aa2-3ecd610215f2"));
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonListController.java
260 260
    public Pager<IdentifiableEntity> doFind(
261 261
            @RequestParam(value = "query", required = true) String query,
262 262
            @RequestParam(value = "tree", required = false) UUID treeUuid,
263
            @RequestParam(value = "subtree", required = false) UUID subtreeUuid,
263 264
            @RequestParam(value = "area", required = false) Set<NamedArea> areas,
264 265
            @RequestParam(value = "pageNumber", required = false) Integer pageNumber,
265 266
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
......
302 303
            config.setClassification(classification);
303 304
        }
304 305

  
306
        TaxonNode subtree = getSubtreeOrError(subtreeUuid, taxonNodeService, response);
307
        config.setSubtree(subtree);
308

  
305 309
        return service.findTaxaAndNames(config);
306 310

  
307 311
    }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
661 661
        if (config.isDoSynonyms() || config.isDoTaxa() || config.isDoNamesWithoutTaxa() || config.isDoTaxaByCommonNames()){
662 662
        	return dao.getTaxaByNameForEditor(config.isDoTaxa(), config.isDoSynonyms(), config.isDoNamesWithoutTaxa(),
663 663
        	        config.isDoMisappliedNames(), config.isDoTaxaByCommonNames(), config.isIncludeUnpublished(),
664
        	        config.getTitleSearchStringSqlized(), config.getClassification(), config.getMatchMode(), config.getNamedAreas(), config.getOrder());
664
        	        config.getTitleSearchStringSqlized(), config.getClassification(), config.getSubtree(),
665
        	        config.getMatchMode(), config.getNamedAreas(), config.getOrder());
665 666
        }else{
666 667
            return new ArrayList<>();
667 668
        }
......
689 690
                numberTaxaResults =
690 691
                    dao.countTaxaByName(configurator.isDoTaxa(),configurator.isDoSynonyms(), configurator.isDoMisappliedNames(),
691 692
                        configurator.isDoTaxaByCommonNames(), configurator.isDoIncludeAuthors(), configurator.getTitleSearchStringSqlized(),
692
                        configurator.getClassification(), configurator.getMatchMode(),
693
                        configurator.getClassification(), configurator.getSubtree(), configurator.getMatchMode(),
693 694
                        configurator.getNamedAreas(), configurator.isIncludeUnpublished());
694 695
            }
695 696

  
696 697
            if(configurator.getPageSize() == null || numberTaxaResults > configurator.getPageSize() * configurator.getPageNumber()){ // no point checking again if less results
697 698
                taxa = dao.getTaxaByName(configurator.isDoTaxa(), configurator.isDoSynonyms(),
698 699
                    configurator.isDoMisappliedNames(), configurator.isDoTaxaByCommonNames(), configurator.isDoIncludeAuthors(),
699
                    configurator.getTitleSearchStringSqlized(), configurator.getClassification(),
700
                    configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getSubtree(),
700 701
                    configurator.getMatchMode(), configurator.getNamedAreas(), configurator.isIncludeUnpublished(),
701 702
                    configurator.getOrder(), configurator.getPageSize(), configurator.getPageNumber(), propertyPath);
702 703
            }
......
1165 1166
        try{
1166 1167
            // 1. search for accepted taxa
1167 1168
            List<TaxonBase> taxonList = dao.findByNameTitleCache(true, false, config.isIncludeUnpublished(),
1168
                    config.getTaxonNameTitle(), null, MatchMode.EXACT, null, null, 0, null, null);
1169
                    config.getTaxonNameTitle(), null, null, MatchMode.EXACT, null, null, 0, null, null);
1169 1170
            boolean bestCandidateMatchesSecUuid = false;
1170 1171
            boolean bestCandidateIsInClassification = false;
1171 1172
            int countEqualCandidates = 0;
1172
            for(TaxonBase taxonBaseCandidate : taxonList){
1173
            for(TaxonBase<?> taxonBaseCandidate : taxonList){
1173 1174
                if(taxonBaseCandidate instanceof Taxon){
1174 1175
                    Taxon newCanditate = CdmBase.deproxy(taxonBaseCandidate, Taxon.class);
1175 1176
                    boolean newCandidateMatchesSecUuid = isMatchesSecUuid(newCanditate, config);
......
1217 1218
            // 2. search for synonyms
1218 1219
            if (config.isIncludeSynonyms()){
1219 1220
                List<TaxonBase> synonymList = dao.findByNameTitleCache(false, true, config.isIncludeUnpublished(),
1220
                        config.getTaxonNameTitle(), null, MatchMode.EXACT, null, null, 0, null, null);
1221
                        config.getTaxonNameTitle(), null, null, MatchMode.EXACT, null, null, 0, null, null);
1221 1222
                for(TaxonBase taxonBase : synonymList){
1222 1223
                    if(taxonBase instanceof Synonym){
1223 1224
                        Synonym synonym = CdmBase.deproxy(taxonBase, Synonym.class);
......
1264 1265

  
1265 1266
    @Override
1266 1267
    public Synonym findBestMatchingSynonym(String taxonName, boolean includeUnpublished) {
1267
        List<TaxonBase> synonymList = dao.findByNameTitleCache(false, true, includeUnpublished, taxonName, null, MatchMode.EXACT, null, null, 0, null, null);
1268
        List<TaxonBase> synonymList = dao.findByNameTitleCache(false, true, includeUnpublished, taxonName, null, null, MatchMode.EXACT, null, null, 0, null, null);
1268 1269
        if(! synonymList.isEmpty()){
1269 1270
            Synonym result = CdmBase.deproxy(synonymList.iterator().next(), Synonym.class);
1270 1271
            if(synonymList.size() == 1){
......
3067 3068
    @Override
3068 3069
    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config){
3069 3070
        List<TaxonBase> taxonList = dao.getTaxaByName(true, config.isIncludeSynonyms(), false, false, false,
3070
                config.getTaxonNameTitle(), null, MatchMode.EXACT, null, config.isIncludeSynonyms(), null, 0, 0, config.getPropertyPath());
3071
                config.getTaxonNameTitle(), null, null, MatchMode.EXACT, null, config.isIncludeSynonyms(), null, 0, 0, config.getPropertyPath());
3071 3072
        return taxonList;
3072 3073
    }
3073 3074

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/FindTaxaAndNamesConfiguratorImpl.java
16 16
import eu.etaxonomy.cdm.model.location.NamedArea;
17 17
import eu.etaxonomy.cdm.model.taxon.Classification;
18 18
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19 20
import eu.etaxonomy.cdm.persistence.query.MatchMode;
20 21
import eu.etaxonomy.cdm.persistence.query.NameSearchOrder;
21 22

  
......
43 44
	private boolean doMisappliedNames = false;
44 45
	private boolean doIncludeAuthors = false;
45 46
	private Classification classification = null;
46
	private List<String> taxonPropertyPath;
47
	private TaxonNode subtree = null;
48
    private List<String> taxonPropertyPath;
47 49
	private List<String> synonymPropertyPath;
48 50
	private List<String> taxonNamePropertyPath;
49 51
	private List<String> commonNamePropertyPath;
50 52
	private Set<NamedArea> namedAreas;
51 53
	private NameSearchOrder order;
52 54

  
55

  
53 56
    /**
54 57
	 * @return the taxonNamePropertyPath
55 58
	 */
......
217 220
        this.includeUnpublished = includeUnpublished;
218 221
    }
219 222

  
223
    @Override
224
    public TaxonNode getSubtree() {
225
        return subtree;
226
    }
227
    @Override
228
    public void setSubtree(TaxonNode subtree) {
229
        this.subtree = subtree;
230
    }
231

  
220 232
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/IFindTaxaAndNamesConfigurator.java
15 15
import eu.etaxonomy.cdm.model.location.NamedArea;
16 16
import eu.etaxonomy.cdm.model.taxon.Classification;
17 17
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18 19
import eu.etaxonomy.cdm.persistence.query.NameSearchOrder;
19 20

  
20 21
/**
......
38 39
    public Classification getClassification();
39 40
    public void setClassification(Classification classification);
40 41

  
42
    public TaxonNode getSubtree();
43
    public void setSubtree(TaxonNode subtree);
44

  
41 45
    public Set<NamedArea> getNamedAreas();
42 46
    public void setNamedAreas(Set<NamedArea> areas);
43 47

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)