Project

General

Profile

« Previous | Next » 

Revision acd1721b

Added by Patrick Plitzner over 4 years ago

ref #6526 Added comparator for type designations

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
18 18
import java.util.ArrayList;
19 19
import java.util.Calendar;
20 20
import java.util.Collection;
21
import java.util.Comparator;
21 22
import java.util.LinkedHashMap;
22 23
import java.util.List;
23 24
import java.util.Map;
......
60 61
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
61 62
import eu.etaxonomy.cdm.api.service.UpdateResult;
62 63
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
64
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
63 65
import eu.etaxonomy.cdm.io.common.ExportDataWrapper;
64 66
import eu.etaxonomy.cdm.io.common.ExportResult;
65 67
import eu.etaxonomy.cdm.io.common.ExportResultType;
66 68
import eu.etaxonomy.cdm.io.common.ExportType;
67 69
import eu.etaxonomy.cdm.model.common.IEnumTerm;
70
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
68 71
import eu.etaxonomy.taxeditor.event.EventUtility;
69 72
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
70 73
import eu.etaxonomy.taxeditor.operation.IFeedbackGenerator;
......
759 762
        return Status.OK_STATUS;
760 763
        }
761 764

  
765
    public static Comparator<TypeDesignationBase> getTypeDesignationComparator(){
766
        return new Comparator<TypeDesignationBase>() {
767
            @Override
768
            public int compare(TypeDesignationBase o1, TypeDesignationBase o2) {
769
                if(o1==null){
770
                    return 1;
771
                }
772
                if(o2==null){
773
                    return -1;
774
                }
775
                if(o1.getTypeStatus()==null){
776
                    return 1;
777
                }
778
                if(o2.getTypeStatus()==null){
779
                    return-1;
780
                }
781
                return HibernateProxyHelper.deproxy(o2, TypeDesignationBase.class).getTypeStatus().compareTo(HibernateProxyHelper.deproxy(o1, TypeDesignationBase.class).getTypeStatus());
782
            }
783
        };
784
    }
785

  
762 786
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TypeDesignationSection.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.ui.section.name;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.Collection;
14
import java.util.Collections;
15
import java.util.List;
13 16

  
14 17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15 18
import eu.etaxonomy.cdm.api.service.INameService;
......
20 23
import eu.etaxonomy.cdm.model.name.TaxonName;
21 24
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
22 25
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
26
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23 27
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
24 28
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
25 29
import eu.etaxonomy.taxeditor.store.CdmStore;
......
73 77
		if (entity == null){
74 78
			return null;
75 79
		}
76
		return entity.getTypeDesignations();
80
		List<TypeDesignationBase> typeDesignations = new ArrayList<>(entity.getTypeDesignations());
81
		Collections.sort(typeDesignations, AbstractUtility.getTypeDesignationComparator());
82
		return typeDesignations;
77 83
	}
78 84

  
79 85
	/** {@inheritDoc} */

Also available in: Unified diff