if (o2 instanceof DescriptionElementSource){
isDescriptionElementSource2 = true;
}
+ int result = 0;
if (isDescriptionElementSource1 != isDescriptionElementSource2){
if (isDescriptionElementSource1){
return -1;
Reference citation1 = o1.getCitation();
Reference citation2 = o2.getCitation();
- int result = 0;
+
// the newly created should always be on top
if (id1 == 0){
if(id2!=0) {
- result = -1;
+ return -1;
}
else{
result = 0;
}
} else if(id2==0){
- result = 1;
+ return 1;
}
// sort by type (Primary taxonomic > Primary Media > others
result = 0;
}
else{
- result = 1;
+ result = -1;
}
} else if (type2 == null){
- result = -1;
+ result = 1;
} else if(type1.equals(type2)){
result = 0;
} else if (type1.equals(OriginalSourceType.PrimaryTaxonomicSource)){
- result = -1;
- } else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){
result = 1;
- } else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){
+ } else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){
result = -1;
- } else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){
+ } else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){
result = 1;
+ } else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){
+ result = -1;
}
//sort by citation title cache if types are equal
}
if(o2.getCreated()!=null && o1.getCreated()!=null){
- result = o2.getCreated().compareTo(o1.getCreated());
+ result = o1.getCreated().compareTo(o2.getCreated());
+ }else if (o1.getCreated() == null ){
+ if (o2.getCreated() == null){
+ result = 0;
+ }else{
+ return -1;
+ }
+ }else if (o2.getCreated() == null){
+ return 1;
}
if (result == 0){
//default fallback
- return o1.getId() - o2.getId();
+ return o1.getUuid().compareTo(o2.getUuid());
}
}
return result;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.INameService;
import eu.etaxonomy.cdm.api.service.UpdateResult;
-import eu.etaxonomy.cdm.api.service.name.TypeDesignationComparator;
+import eu.etaxonomy.cdm.api.service.name.TypeDesignationStatusComparator;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
import eu.etaxonomy.cdm.model.name.Rank;
@Override
public Comparator<TypeDesignationBase> getComparator() {
- return new TypeDesignationComparator();
+ return new Comparator<TypeDesignationBase>(){
+
+ //TODO: this is only a workaround to avoid a cdmlib hotfix this needs to be reverted for next release!!
+ private TypeDesignationStatusComparator statusComparator = new TypeDesignationStatusComparator();
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compare(TypeDesignationBase o1, TypeDesignationBase o2) {
+
+ if (o1 == null && o2 == null){
+ return 0;
+ }
+ if(o1==null){
+ return 1;
+ }
+ if(o2==null){
+ return -1;
+ }
+ int result = 0;
+ if(o1.getTypeStatus()==null ){
+ if (o2.getTypeStatus() != null){
+ return 1;
+ }
+ }
+ if (o2.getTypeStatus() == null){
+ return -1;
+ }
+ if(result == 0 && (o1.getTypeStatus() == null || o2.getTypeStatus() == null)){
+ return o1.getUuid().compareTo(o2.getUuid());
+ }
+ return statusComparator.compare(o1.getTypeStatus(), o2.getTypeStatus()) ;
+ }
+ };
}
@Override