package ubic.gemma.web.taglib.displaytag;

import java.util.Collection;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.displaytag.decorator.TableDecorator;

import ubic.gemma.model.common.description.OntologyEntry;

/**
 * used for proper decoration of the ontologyEntry
 * <p>
 * See http://displaytag.sourceforge.net/10/tut_decorators.html and http://displaytag.sourceforge.net/10/tut_links.html
 * for explanation of how this works.
 * 
 * @author klc
 * @version $Id $
 */
public class OntologyWrapper extends TableDecorator {

    Log log = LogFactory.getLog( this.getClass() );

    public String getValue() {
        Map.Entry oe = ( Map.Entry ) getCurrentRowObject();
        return ( ( OntologyEntry ) oe.getKey() ).getValue();
    }

    public String getDescription() {
        Map.Entry oe = ( Map.Entry ) getCurrentRowObject();
        return ( ( OntologyEntry ) oe.getKey() ).getDescription();
    }

    public String getCategory() {
        Map.Entry oe = ( Map.Entry ) getCurrentRowObject();
        return ( ( OntologyEntry ) oe.getKey() ).getCategory();
    }
    
    public String getAccession() {
        OntologyEntry oe = (OntologyEntry ) (( Map.Entry ) getCurrentRowObject()).getKey();
  
        return  "<a target='_blank' href='http://www.godatabase.org/cgi-bin/amigo/go.cgi?view=details&query=" + oe.getAccession()  + "'>" + oe.getAccession() + "</a>";
  
    }


    public String getParents() {
        Map.Entry oe = ( Map.Entry ) getCurrentRowObject();
        
        String parents = "";
        for ( Object obj : (Collection) oe.getValue() )             
              parents += ( ( OntologyEntry ) obj ).getValue() + " &nbsp;";        
        
        return parents;
    }
    

}

@@ -40,60 +40,8 @@
 g;%0A%0A
-import java.util.Collection;%0Aimport java.util.Map;%0A%0A
 impo
@@ -483,17 +483,16 @@
 sion $Id
- 
 $%0A */%0Apu
@@ -596,24 +596,27 @@
 ss() );%0A%0A   
+ //
  public Stri
@@ -631,32 +631,35 @@
 lue() %7B%0A    
-    Map.
+// Ontology
 Entry oe = (
@@ -650,37 +650,40 @@
 logyEntry oe = (
- Map.
+Ontology
 Entry ) getCurre
@@ -697,35 +697,34 @@
 ject();%0A    
-   
+//
  return 
 ( ( Ontology
@@ -715,41 +715,10 @@
 urn 
-( ( OntologyEntry ) oe.getKey() )
+oe
 .get
@@ -722,38 +722,50 @@
 getValue();%0A    
-%7D%0A
+// %7D%0A    //
 %0A   
+ //
  public String g
@@ -782,32 +782,35 @@
 ion() %7B%0A    
-    Map.
+// Ontology
 Entry oe = (
@@ -801,37 +801,40 @@
 logyEntry oe = (
- Map.
+Ontology
 Entry ) getCurre
@@ -848,35 +848,34 @@
 ject();%0A    
-   
+//
  return 
 ( ( Ontology
@@ -866,41 +866,10 @@
 urn 
-( ( OntologyEntry ) oe.getKey() )
+oe
 .get
@@ -891,14 +891,26 @@
     
-%7D%0A
+// %7D%0A    //
 %0A   
+ //
  pub
@@ -936,32 +936,35 @@
 ory() %7B%0A    
-    Map.
+// Ontology
 Entry oe = (
@@ -955,37 +955,40 @@
 logyEntry oe = (
- Map.
+Ontology
 Entry ) getCurre
@@ -1006,27 +1006,26 @@
 ();%0A    
-  
- 
+//
  return 
 ( ( Onto
@@ -1020,41 +1020,10 @@
 urn 
-( ( OntologyEntry ) oe.getKey() )
+oe
 .get
@@ -1038,22 +1038,21 @@
 ();%0A    
-%7D%0A    
+// %7D%0A
 %0A    pub
@@ -1099,32 +1099,33 @@
 logyEntry oe = (
+ 
 OntologyEntry ) 
@@ -1127,23 +1127,8 @@
 ry )
- (( Map.Entry )
  get
@@ -1149,22 +1149,10 @@
 ct()
-).getKey();%0A  
+;%0A
 %0A   
@@ -1163,17 +1163,16 @@
  return 
- 
 %22%3Ca targ
@@ -1256,16 +1256,32 @@
 &query=%22
+%0A               
  + oe.ge
@@ -1292,17 +1292,16 @@
 ession()
- 
  + %22'%3E%22 
@@ -1334,18 +1334,16 @@
 %3E%22;%0A
-  
 %0A    %7D%0A%0A
 %0A   
@@ -1342,335 +1342,6 @@
  %7D%0A%0A
-%0A    public String getParents() %7B%0A        Map.Entry oe = ( Map.Entry ) getCurrentRowObject();%0A        %0A        String parents = %22%22;%0A        for ( Object obj : (Collection) oe.getValue() )             %0A              parents += ( ( OntologyEntry ) obj ).getValue() + %22 &nbsp;%22;        %0A        %0A        return parents;%0A    %7D%0A    %0A%0A
 %7D%0A

fix way rows map to objects; comment out unneeded methods