Project

General

Profile

Revision ead6f0f6

IDead6f0f6d3ab3f3c1ddcfb872fbfadbb74daf384
Parent 9361ce64
Child 56432bdd

Added by Andreas Kohlbecker over 2 years ago

fixing problem with empty partials in RegistrationRequiredDataInserter

View differences:

src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
358 358
                                    }
359 359
                                    Partial pubdate = partial(td.getCitation().getDatePublished());
360 360
                                    if(pubdate != null){
361
                                        if(youngestDate== null || comparePartials(youngestDate, pubdate)){
362
                                            youngestDate = pubdate;
363
                                            youngestPub = td.getCitation();
361

  
362
                                        try {
363
                                            if(youngestDate== null || earlierThanOther(youngestDate, pubdate)){
364
                                                youngestDate = pubdate;
365
                                                youngestPub = td.getCitation();
366
                                            }
367
                                        } catch (Exception e) {
368
                                            logger.error("Error comparing " + youngestDate + " with" + pubdate , e);
364 369
                                        }
365 370
                                    }
366 371
                                }
......
415 420
     * @param pubdate
416 421
     * @return
417 422
     */
418
    protected boolean comparePartials(Partial youngestDate, Partial pubdate) {
423
    protected boolean earlierThanOther(Partial basePartial, Partial other) {
419 424

  
420
        if(youngestDate.size() == pubdate.size()) {
421
            return youngestDate.compareTo(pubdate) < 0;
425
        if(basePartial == null || basePartial.getValues().length == 0){
426
            return false;
427
        }
428
        if(other == null || other.getValues().length == 0){
429
            return true;
430
        }
431
        if(basePartial.size() == other.size()) {
432
            return basePartial.compareTo(other) < 0;
422 433
        }
423
        youngestDate = youngestDate.without(DateTimeFieldType.dayOfMonth());
424
        pubdate = pubdate.without(DateTimeFieldType.dayOfMonth());
425
        if(youngestDate.size() == pubdate.size()) {
426
            return youngestDate.compareTo(pubdate) < 0;
434
        basePartial = basePartial.without(DateTimeFieldType.dayOfMonth());
435
        other = other.without(DateTimeFieldType.dayOfMonth());
436
        if(basePartial.size() == other.size()) {
437
            return basePartial.compareTo(other) < 0;
427 438
        }
428
        youngestDate = youngestDate.without(DateTimeFieldType.monthOfYear());
429
        pubdate = pubdate.without(DateTimeFieldType.monthOfYear());
430
        return youngestDate.compareTo(pubdate) < 0;
439
        basePartial = basePartial.without(DateTimeFieldType.monthOfYear());
440
        other = other.without(DateTimeFieldType.monthOfYear());
441
        return basePartial.compareTo(other) < 0;
431 442

  
432 443
    }
433 444

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)