Project

General

Profile

« Previous | Next » 

Revision 97cae9c2

Added by Patrick Plitzner about 6 years ago

Enhance source comparator #3185

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java
26 26
        if (id1 == 0 && id2!=0) {
27 27
            return -1;
28 28
        }
29
        if (id1 != 0 && id2==0) {
29
        else if (id2==0) {
30 30
            return 1;
31 31
        }
32 32

  
33 33
        // sort by type (Primary taxonomic > Primary Media > others
34 34
        // alphabetically by reference title cache)
35 35
        if (type1 != null && type1.equals(OriginalSourceType.PrimaryTaxonomicSource)
36
                && type2 != null && !type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
36
                && (type2 == null || !type2.equals(OriginalSourceType.PrimaryTaxonomicSource))) {
37 37
            return -1;
38 38
        }
39
        if (type1 != null && !type1.equals(OriginalSourceType.PrimaryTaxonomicSource)
39
        if ((type1 == null || !type1.equals(OriginalSourceType.PrimaryTaxonomicSource))
40 40
                && type2 != null && type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
41 41
            return 1;
42 42
        }
43
        if (type1 != null && type1.equals(OriginalSourceType.PrimaryMediaSource)
44
                && type2!=null && !type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
43

  
44
        if ((type1 == null || type1.equals(OriginalSourceType.PrimaryMediaSource))
45
                && (type2==null || !type2.equals(OriginalSourceType.PrimaryMediaSource))) {
45 46
            return -1;
46 47
        }
47 48
        if (type2 != null && type2.equals(OriginalSourceType.PrimaryMediaSource)
48
                && type1!=null && !type1.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
49
                && type1!=null && !type1.equals(OriginalSourceType.PrimaryMediaSource)) {
49 50
            return 1;
50 51
        }
51 52

  
......
53 54
        if(citation1!=null && citation2!=null){
54 55
            return citation1.getTitleCache().compareTo(citation2.getTitleCache());
55 56
        }
56
        return o2.getCreated().compareTo(o1.getCreated());
57

  
58
        if(o2.getCreated()!=null && o1.getCreated()!=null){
59
            return o2.getCreated().compareTo(o1.getCreated());
60
        }
61

  
62
        //default fallback
63
        return o1.getId() - o2.getId();
64

  
57 65
    }
58 66
}

Also available in: Unified diff