fix #4461 fix ordering for Datasource View
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 13 Oct 2016 13:34:41 +0000 (15:34 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 10 Nov 2016 12:50:47 +0000 (13:50 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/CdmDataSourceViewerComparator.java

index 5cadc48c9d378c9b4022a77770e487177883227c..7275e7fb8ce58940767cd57c053f859965da4372 100644 (file)
@@ -59,7 +59,16 @@ public class CdmDataSourceViewerComparator extends ViewerComparator {
                                break;
                        case 8:
                                // is compatible
-                               break;  
+                               boolean c1 = d1.isDataSourceCompatible();
+                               boolean c2 = d2.isDataSourceCompatible();
+                               if (c1 == c2){
+                                       result = 0;
+                               }else if (c1 == true){
+                                       result = -1;
+                               }else{
+                                       result = 1;
+                               }
+                               break;
                        case 7:
                                result = d1.getMetaData(MetaDataPropertyName.DB_SCHEMA_VERSION).compareTo(d2.getMetaData(MetaDataPropertyName.DB_SCHEMA_VERSION));
                                break;
@@ -67,26 +76,35 @@ public class CdmDataSourceViewerComparator extends ViewerComparator {
                                result = d1.getMetaData(MetaDataPropertyName.DB_CREATE_DATE).compareTo(d2.getMetaData(MetaDataPropertyName.DB_CREATE_DATE));
                                break;
                        case 5:
-                               // is running
-                               break;
-                       case 4:
                                if(cs1 instanceof ICdmDataSource && cs2 instanceof ICdmDataSource) {
                                        result = ((ICdmDataSource)cs1).getDatabase().compareTo(((ICdmDataSource)cs2).getDatabase());
                                }
                                
                                break;
-                       case 3:
+                       case 4:
                                if(cs1 instanceof ICdmDataSource && cs2 instanceof ICdmDataSource) {
                                        result = ((ICdmDataSource)cs1).getDatabaseType().getName().compareTo(((ICdmDataSource)cs2).getDatabaseType().getName());
                                }
                                break;
+                       case 3:
+                               // is running
+                               boolean r1 = d1.isRunning();
+                               boolean r2 = d2.isRunning();
+                               if (r1 == r2){
+                                       result = 0;
+                               }else if (r1 == true){
+                                       result = -1;
+                               }else{
+                                       result = 1;
+                               }
+                               break;
                        case 2:
                                String server1 = d1.getCdmSource().getServer();
                                String server2 = d2.getCdmSource().getServer();
-                               if(server1 != null && server2 != null){
-                                       result = server1.compareTo(server2);
-                               }
                                // h2 databases do not have server entries
+                               server1 = server1 == null? "local" : server1;
+                               server2 = server2 == null? "local" : server2;
+                               result = server1.compareTo(server2);
                                break;
                        default:
                                result = d1.getCdmSource().getName().compareTo(d2.getCdmSource().getName());