package gov.nih.nci.evs.browser.utils;

import java.util.*;

public class OntologyInfo {
    private String _displayName = "";
    private int _sortCategory = 0;
    
    public OntologyInfo(String displayName, String sortCategory) {
        if (sortCategory == null || sortCategory.trim().length() <= 0) {
            System.out.println("Warning: vocabulary_sort_category metadata value not set:");
            System.out.println("Warning:   * Defaulting " + displayName + " to sort category 0.");
            init(displayName, 0);
            return;
        }

        try {
            int category = Integer.parseInt(sortCategory);
            System.out.println("FYI: * " + displayName + " set to sort category " + category);
            init(displayName, category);
        } catch (Exception e) {
            System.out.println("Error: " + e.getClass().getSimpleName() + ": " + e.getMessage());
            System.out.println("Error:   * Defaulting " + displayName + " to sort category 0.");
            init(displayName, 0);
        }
    }

    public OntologyInfo(String displayName, int sortCategory) {
        init(displayName, sortCategory);
    }
    
    private void init(String displayName, int sortCategory) {
        _displayName = displayName;
        _sortCategory = sortCategory;
    }

    public String getDisplayName() {
        return _displayName;
    }
    
    public int getSortCategory() {
        return _sortCategory;
    }
    
    public static class ComparatorImpl implements Comparator<OntologyInfo> {
        public int compare(OntologyInfo value1, OntologyInfo value2) {
            int sortCategory1 = value1.getSortCategory();
            int sortCategory2 = value2.getSortCategory();
            if (sortCategory1 != sortCategory2)
                return sortCategory2 - sortCategory1;

            String displayName1 = value1.getDisplayName();
            String displayName2 = value2.getDisplayName();
            return displayName1.compareToIgnoreCase(displayName2);
        }
    }
}

@@ -162,20 +162,16 @@
 y = 0;%0D%0A
-    
 %0D%0A    pu
@@ -322,700 +322,213 @@
     
-System.out.println(%22Warning: vocabulary_sort_category metadata value not set:%22);%0D%0A            System.out.println(%22Warning:   * Defaulting %22 + displayName + %22 to sort category 0.%22);%0D%0A            init(displayName, 0);%0D%0A            return;%0D%0A        %7D%0D%0A%0D%0A        try %7B%0D%0A            int category = Integer.parseInt(sortCategory);%0D%0A            System.out.println(%22FYI: * %22 + displayName + %22 set to sort category %22 + category);%0D%0A            init(displayName, category);%0D%0A        %7D catch (Exception e) %7B%0D%0A            System.out.println(%22Error: %22 + e.getClass().getSimpleName() + %22: %22 + e.getMessage());%0D%0A            System.out.println(%22Error:   * Defaulting %22 + displayName + %22 to sort category 0.%22);
+init(displayName, 0);%0D%0A            return;%0D%0A        %7D%0D%0A%0D%0A        try %7B%0D%0A            int category = Integer.parseInt(sortCategory);%0D%0A            init(displayName, category);%0D%0A        %7D catch (Exception e) %7B
 %0D%0A  
@@ -690,28 +690,24 @@
 y);%0D%0A    %7D%0D%0A
-    
 %0D%0A    privat
@@ -911,36 +911,32 @@
 ayName;%0D%0A    %7D%0D%0A
-    
 %0D%0A    public int
@@ -995,20 +995,16 @@
 %0A    %7D%0D%0A
-    
 %0D%0A    pu

Support the search and display of mapping data. [KLO, 093010]