Project

General

Profile

« Previous | Next » 

Revision 56cf64f7

Added by Katja Luther over 3 years ago

ref #9356: hotfix solution

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java
26 26
        if (o2 instanceof DescriptionElementSource){
27 27
            isDescriptionElementSource2 = true;
28 28
        }
29
        int result = 0;
29 30
        if (isDescriptionElementSource1 != isDescriptionElementSource2){
30 31
            if (isDescriptionElementSource1){
31 32
                return -1;
......
38 39
        Reference citation1 = o1.getCitation();
39 40
        Reference citation2 = o2.getCitation();
40 41

  
41
        int result = 0;
42

  
42 43

  
43 44
        // the newly created should always be on top
44 45
        if (id1 == 0){
45 46
            if(id2!=0) {
46
                result = -1;
47
                return -1;
47 48
            }
48 49
            else{
49 50
                result = 0;
50 51
            }
51 52
        } else if(id2==0){
52
            result = 1;
53
            return 1;
53 54
        }
54 55

  
55 56
        // sort by type (Primary taxonomic > Primary Media > others
......
59 60
                result = 0;
60 61
            }
61 62
            else{
62
                result = 1;
63
                result = -1;
63 64
            }
64 65
        } else if (type2 == null){
65
            result = -1;
66
            result = 1;
66 67
        } else if(type1.equals(type2)){
67 68
            result = 0;
68 69
        } else if (type1.equals(OriginalSourceType.PrimaryTaxonomicSource)){
69
            result = -1;
70
        } else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){
71 70
            result = 1;
72
        } else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){
71
        } else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){
73 72
            result = -1;
74
        } else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){
73
        } else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){
75 74
            result = 1;
75
        } else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){
76
            result = -1;
76 77
        }
77 78

  
78 79
        //sort by citation title cache if types are equal
......
82 83
            }
83 84

  
84 85
            if(o2.getCreated()!=null && o1.getCreated()!=null){
85
                result = o2.getCreated().compareTo(o1.getCreated());
86
                result = o1.getCreated().compareTo(o2.getCreated());
87
            }else if (o1.getCreated() == null ){
88
                if (o2.getCreated() == null){
89
                    result = 0;
90
                }else{
91
                    return -1;
92
                }
93
            }else if (o2.getCreated() == null){
94
                return 1;
86 95
            }
87 96
            if (result == 0){
88 97
                //default fallback
89
                return o1.getId() - o2.getId();
98
                return o1.getUuid().compareTo(o2.getUuid());
90 99
            }
91 100
        }
92 101
        return result;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TypeDesignationSection.java
25 25
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
26 26
import eu.etaxonomy.cdm.api.service.INameService;
27 27
import eu.etaxonomy.cdm.api.service.UpdateResult;
28
import eu.etaxonomy.cdm.api.service.name.TypeDesignationComparator;
28
import eu.etaxonomy.cdm.api.service.name.TypeDesignationStatusComparator;
29 29
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
30 30
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
31 31
import eu.etaxonomy.cdm.model.name.Rank;
......
164 164

  
165 165
	@Override
166 166
	public Comparator<TypeDesignationBase> getComparator() {
167
        return new TypeDesignationComparator();
167
        return new Comparator<TypeDesignationBase>(){
168

  
169
            //TODO: this is only a workaround to avoid a cdmlib hotfix this needs to be reverted for next release!!
170
            private TypeDesignationStatusComparator statusComparator = new TypeDesignationStatusComparator();
171

  
172
            @SuppressWarnings("unchecked")
173
            @Override
174
            public int compare(TypeDesignationBase o1, TypeDesignationBase o2) {
175

  
176
                if (o1 == null && o2 == null){
177
                    return 0;
178
                }
179
                if(o1==null){
180
                    return 1;
181
                }
182
                if(o2==null){
183
                    return -1;
184
                }
185
                int result = 0;
186
                if(o1.getTypeStatus()==null ){
187
                    if (o2.getTypeStatus() != null){
188
                        return 1;
189
                    }
190
                }
191
                if (o2.getTypeStatus() == null){
192
                    return -1;
193
                }
194
                if(result == 0 && (o1.getTypeStatus() == null || o2.getTypeStatus() == null)){
195
                    return o1.getUuid().compareTo(o2.getUuid());
196
                }
197
                return statusComparator.compare(o1.getTypeStatus(), o2.getTypeStatus()) ;
198
            }
199
        };
168 200
	}
169 201

  
170 202
	@Override

Also available in: Unified diff