Project

General

Profile

Revision 12b3d645

ID12b3d6458de90cb33b7b4dd7916309520b8fa546
Parent 78e8f961
Child adc3d873

Added by Andreas Müller about 2 years ago

ref #3560 implement unpublished for taxon collection retrieval in occurrence service

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IOccurrenceService.java
477 477
     * @param propertyPaths
478 478
     * @return a collection of associated taxa
479 479
     */
480
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,
481
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
480
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen,
481
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
482
    /**
483
      * @see #listIndividualsAssociationTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)
484
      */
485
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
486
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
482 487

  
483 488
    /**
484 489
     * Retrieves all associated taxa for the given specimen (via type designations, determination, individuals associations)
......
489 494
     * @param propertyPaths
490 495
     * @return
491 496
     */
492
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
497
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
498
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
499
    /**
500
     * @see #listAssociatedTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)axa
501
     */
502
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen,
503
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
493 504

  
494 505
    /**
495 506
     * Retrieves all taxa that the given specimen is determined as
......
500 511
     * @param propertyPaths
501 512
     * @return collection of all taxa the given specimen is determined as
502 513
     */
503
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start,
504
            List<OrderHint> orderHints, List<String> propertyPaths);
514
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
515
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
516
    /**
517
     * @see #listDeterminedTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)
518
     */
519
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen,
520
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
505 521

  
506 522
    /**
507 523
     * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
......
524 540
     * @param propertyPaths
525 541
     * @return a collection of all taxa where the given specimen is the type specimen
526 542
     */
527
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, Integer limit,
528
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
543
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen,
544
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
545
    /**
546
     * @see #listTypeDesignationTaxa(DerivedUnit, Integer, Integer, List, List)a
547
     */
548
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, boolean includeUnpublished,
549
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
529 550

  
530 551
    /**
531 552
     * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimens as a type specimen.
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
1227 1227
        return dao.listIndividualsAssociations(specimen, limit, start, orderHints, propertyPaths);
1228 1228
    }
1229 1229

  
1230
    /**
1231
     * {@inheritDoc}
1232
     */
1230 1233
    @Override
1231
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start,
1232
            List<OrderHint> orderHints, List<String> propertyPaths) {
1234
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,
1235
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
1236
        return listAssociatedTaxa(specimen, INCLUDE_UNPUBLISHED, limit, start, orderHints, propertyPaths);
1237
    }
1238
    @Override
1239
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
1240
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
1233 1241
        Collection<TaxonBase<?>> associatedTaxa = new HashSet<>();
1234 1242

  
1235 1243
        //individuals associations
1236
        associatedTaxa.addAll(listIndividualsAssociationTaxa(specimen, limit, start, orderHints, propertyPaths));
1244
        associatedTaxa.addAll(listIndividualsAssociationTaxa(specimen, includeUnpublished, limit, start, orderHints, propertyPaths));
1237 1245
        //type designation
1238 1246
        if(specimen.isInstanceOf(DerivedUnit.class)){
1239
            associatedTaxa.addAll(listTypeDesignationTaxa(HibernateProxyHelper.deproxy(specimen, DerivedUnit.class), limit, start, orderHints, propertyPaths));
1247
            associatedTaxa.addAll(listTypeDesignationTaxa(HibernateProxyHelper.deproxy(specimen, DerivedUnit.class),
1248
                  includeUnpublished, limit, start, orderHints, propertyPaths));
1240 1249
        }
1241 1250
        //determinations
1242
        associatedTaxa.addAll(listDeterminedTaxa(specimen, limit, start, orderHints, propertyPaths));
1251
        associatedTaxa.addAll(listDeterminedTaxa(specimen, includeUnpublished, limit, start, orderHints, propertyPaths));
1243 1252

  
1244 1253
        return associatedTaxa;
1245 1254
    }
1246 1255

  
1247 1256

  
1257

  
1258
    /**
1259
     * {@inheritDoc}
1260
     */
1248 1261
    @Override
1249
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start,
1262
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,
1263
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
1264
        return listDeterminedTaxa(specimen, INCLUDE_UNPUBLISHED, limit, start, orderHints, propertyPaths);
1265
    }
1266
    @Override
1267
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished, Integer limit, Integer start,
1250 1268
            List<OrderHint> orderHints, List<String> propertyPaths) {
1251 1269
        Collection<TaxonBase<?>> associatedTaxa = new HashSet<>();
1252 1270
        for (DeterminationEvent determinationEvent : listDeterminationEvents(specimen, limit, start, orderHints, propertyPaths)) {
1253 1271
            if(determinationEvent.getIdentifiedUnit().equals(specimen)){
1254 1272
                if(determinationEvent.getTaxon()!=null){
1255
                    associatedTaxa.add(taxonService.load(determinationEvent.getTaxon().getUuid(), propertyPaths));
1273
                    associatedTaxa.add(taxonService.load(determinationEvent.getTaxon().getUuid(), includeUnpublished, propertyPaths));
1256 1274
                }
1257 1275
                if(determinationEvent.getTaxonName()!=null){
1258 1276
                    Collection<TaxonBase> taxonBases = determinationEvent.getTaxonName().getTaxonBases();
1259 1277
                    for (TaxonBase taxonBase : taxonBases) {
1260
                        associatedTaxa.add(taxonService.load(taxonBase.getUuid(), propertyPaths));
1278
                        associatedTaxa.add(taxonService.load(taxonBase.getUuid(), includeUnpublished, propertyPaths));
1261 1279
                    }
1262 1280
                }
1263 1281
            }
......
1265 1283
        return associatedTaxa;
1266 1284
    }
1267 1285

  
1286
    /**
1287
     * {@inheritDoc}
1288
     */
1268 1289
    @Override
1269 1290
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, Integer limit, Integer start,
1270 1291
            List<OrderHint> orderHints, List<String> propertyPaths) {
1292
        return listTypeDesignationTaxa(specimen, INCLUDE_UNPUBLISHED, limit, start, orderHints, propertyPaths);
1293
    }
1294
    @Override
1295
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, boolean includeUnpublished,
1296
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
1271 1297
        Collection<TaxonBase<?>> associatedTaxa = new HashSet<>();
1272 1298
        for (SpecimenTypeDesignation typeDesignation : listTypeDesignations(specimen, limit, start, orderHints, propertyPaths)) {
1273 1299
            if(typeDesignation.getTypeSpecimen().equals(specimen)){
......
1275 1301
                for (TaxonName taxonName : typifiedNames) {
1276 1302
                    Set<Taxon> taxa = taxonName.getTaxa();
1277 1303
                    for (Taxon taxon : taxa) {
1278
                        associatedTaxa.add(taxonService.load(taxon.getUuid(), propertyPaths));
1304
                        associatedTaxa.add(taxonService.load(taxon.getUuid(), includeUnpublished, propertyPaths));
1279 1305
                    }
1280 1306
                }
1281 1307
            }
......
1283 1309
        return associatedTaxa;
1284 1310
    }
1285 1311

  
1312
    /**
1313
     * {@inheritDoc}
1314
     */
1315
    @Override
1316
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,
1317
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
1318
        return listIndividualsAssociationTaxa(specimen, INCLUDE_UNPUBLISHED, limit, start, orderHints, propertyPaths);
1319
    }
1320

  
1286 1321
    @Override
1287
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start,
1288
            List<OrderHint> orderHints, List<String> propertyPaths) {
1322
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
1323
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
1289 1324
        Collection<TaxonBase<?>> associatedTaxa = new HashSet<>();
1290 1325
        for (IndividualsAssociation individualsAssociation : listIndividualsAssociations(specimen, null, null, null, null)) {
1291 1326
            if(individualsAssociation.getInDescription().isInstanceOf(TaxonDescription.class)){
1292 1327
                TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(individualsAssociation.getInDescription(), TaxonDescription.class);
1293 1328
                if(taxonDescription.getTaxon()!=null){
1294
                    associatedTaxa.add(taxonService.load(taxonDescription.getTaxon().getUuid(), propertyPaths));
1329
                    associatedTaxa.add(taxonService.load(taxonDescription.getTaxon().getUuid(), includeUnpublished, propertyPaths));
1295 1330
                }
1296 1331
            }
1297 1332
        }
......
1451 1486
            List<SpecimenOrObservationBase<?>> specimenWithAssociations = new ArrayList<>();
1452 1487
            if(!assignmentStatus.equals(AssignmentStatus.ALL_SPECIMENS)){
1453 1488
                for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
1454
                    Collection<TaxonBase<?>> associatedTaxa = listAssociatedTaxa(specimenOrObservationBase, null, null, null, null);
1489
                    boolean includeUnpublished = true;  //TODO not sure if this is correct, maybe we have to propagate publish flag to higher methods.
1490
                    Collection<TaxonBase<?>> associatedTaxa = listAssociatedTaxa(specimenOrObservationBase,
1491
                            includeUnpublished, null, null, null, null);
1455 1492
                    if(!associatedTaxa.isEmpty()){
1456 1493
                        specimenWithAssociations.add(specimenOrObservationBase);
1457 1494
                    }
......
1531 1568
    public List<FieldUnit> getFieldUnitsForGatheringEvent(UUID gatheringEventUuid) {
1532 1569
        return dao.getFieldUnitsForGatheringEvent(gatheringEventUuid, null, null, null, null);
1533 1570
    }
1534

  
1535 1571
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ServiceBase.java
28 28
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
29 29
import eu.etaxonomy.cdm.model.common.CdmBase;
30 30
import eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao;
31
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBase;
31 32
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
32 33
import eu.etaxonomy.cdm.persistence.query.Grouping;
33 34
import eu.etaxonomy.cdm.persistence.query.OrderHint;
......
40 41
    int flushAfterNo = 2000;
41 42
    protected ApplicationContext appContext;
42 43

  
44
    public final static boolean NO_UNPUBLISHED = DaoBase.NO_UNPUBLISHED;  //constant for unpublished
45
    public final static boolean INCLUDE_UNPUBLISHED = DaoBase.INCLUDE_UNPUBLISHED;  //constant for unpublished
46

  
43 47
    protected DAO dao;
44 48

  
45 49
    @Override

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)