Changeset 2656 for molgenis4animaldb


Ignore:
Timestamp:
02/25/10 10:43:24 (2 years ago)
Author:
erikroos
Message:

Added basic version of list plugin

Location:
molgenis4animaldb
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • molgenis4animaldb/handwritten/java/servlets/AddEventMenuServlet.java

    r2636 r2656  
    5555                                        while (correspondingFeatureIterator.hasNext()) { 
    5656                                                Feature currentFeature = correspondingFeatureIterator.next(); 
    57                                                 out.print("<div id='featurevalue_part' class='row'>"); 
     57                                                String hideDiv = ""; 
     58                                                String dummyValue = ""; 
     59                                                if (currentFeature.getName().equals("Dummy")) { 
     60                                                        hideDiv = " style='display:none'"; 
     61                                                        dummyValue = " value='Dummy'"; 
     62                                                } 
     63                                                out.print("<div id='featurevalue_part' class='row'" + hideDiv + ">"); 
    5864                                                out.print("<label for='value"+valueNr+"'>"+currentFeature.getName()+" value: </label>"); 
    59                                                 out.print("<input type='text' class='textbox' name='value"+valueNr+"' id='value"+valueNr+"' />"); 
     65                                                out.print("<input type='text' class='textbox' name='value" + valueNr + "' id='value" + valueNr + "' " + dummyValue + "/>"); 
    6066                                                out.print("<em>(unit: "+currentFeature.getUnitLabel()+")</em>"); 
    6167                                                out.print("<input type='hidden' name='feature"+valueNr+"' value='"+currentFeature.getId()+"' />"); 
    6268                                                out.print("</div>"); 
    6369                                                out.print("<div id='datetimevalue_part' class='row'>"); 
    64                                                 out.print("<label for='datetime"+valueNr+"'>"+currentFeature.getName()+" date and time: </label>"); 
     70                                                out.print("<label for='datetime"+valueNr+"'>Date and time: </label>"); 
    6571                                                out.print("<input type='text' class='textbox' id='datetime"+valueNr+"' name='datetime"+valueNr+"' value='' onclick='showDateInput(this,true)' autocomplete='off' />"); 
    6672                                                out.print("</div>"); 
  • molgenis4animaldb/handwritten/java/servlets/ViewEventsServlet.java

    r2653 r2656  
    2727import animaldb.Value; 
    2828 
    29 public class ViewEventsServlet extends app.servlet.MolgenisServlet 
    30 { 
     29public class ViewEventsServlet extends app.servlet.MolgenisServlet { 
    3130        /** 
    3231         *  
     
    3534        private static Logger logger = Logger.getLogger(ViewEventsServlet.class); 
    3635 
    37         public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    38         { 
     36        public void service(HttpServletRequest request, HttpServletResponse response) 
     37                        throws ServletException, IOException { 
    3938 
    4039                PrintWriter out = response.getWriter(); 
    41                 try 
    42                 { 
     40                try { 
    4341                        Tuple req = new HttpServletRequestTuple(request); 
    44                          
     42 
    4543                        Database db = getDatabase(); 
    4644 
     
    4947                                out.print(""); 
    5048                        } else { 
    51                                 List<Value> valList = db.find(Value.class, new QueryRule("targetid", Operator.EQUALS, animalId)); 
     49                                List<Value> valList = db.find(Value.class, new QueryRule( 
     50                                                "targetid", Operator.EQUALS, animalId)); 
    5251                                if (!valList.isEmpty()) { 
    5352                                        Iterator<Value> valIterator = valList.iterator(); 
     
    5958                                                Value currentValue = valIterator.next(); 
    6059                                                int eventId = currentValue.getEventid(); 
    61                                                 List<Event> eventList = db.find(Event.class, new QueryRule("id", Operator.EQUALS, eventId)); 
     60                                                List<Event> eventList = db.find(Event.class, 
     61                                                                new QueryRule("id", Operator.EQUALS, eventId)); 
    6262                                                Event currentEvent = eventList.get(0); 
    63                                                  
    64                                                 out.print("<td>" + currentEvent.getEventtypeidLabel() + " on " + 
    65                                                                 currentValue.getTime().toString() + "</td>"); 
     63 
     64                                                out.print("<td>" + currentEvent.getEventtypeidLabel() 
     65                                                                + " on " + currentValue.getTime().toString() 
     66                                                                + "</td>"); 
    6667                                        } 
    6768                                        out.print("</tr>"); 
    68                                          
     69 
     70                                        String currentValueContents = ""; 
     71                                        String unitName = ""; 
     72 
     73                                        // Print feature names 
    6974                                        out.print("<tr class='form_listrow0'>"); 
    7075                                        valIterator = valList.iterator(); 
    7176                                        while (valIterator.hasNext()) { 
    7277                                                Value currentValue = valIterator.next(); 
    73                                                 out.print("<td>" + currentValue.getFeatureidLabel() + ":</td>"); 
     78                                                currentValueContents = currentValue.getFeatureidLabel(); 
     79                                                if (currentValueContents.equals("Dummy")) { 
     80                                                        currentValueContents = ""; 
     81                                                } 
     82                                                out.print("<td>" + currentValueContents + "</td>"); 
    7483                                        } 
    7584                                        out.print("</tr>"); 
    76                                          
     85 
     86                                        // Print contents 
    7787                                        out.print("<tr class='form_listrow1'>"); 
    7888                                        valIterator = valList.iterator(); 
    79                                         // Print contents 
    8089                                        while (valIterator.hasNext()) { 
    8190                                                Value currentValue = valIterator.next(); 
    82                                                  
    83                                                 // Get the real value: 
    84                                                 String currentValueContents = currentValue.getValuestring(); 
    85                                                 // Find out what the unit is: 
    86                                                 int featureId = currentValue.getFeatureid(); 
    87                                                 List<Feature> featList = db.find(Feature.class, new QueryRule("id", Operator.EQUALS, featureId)); 
    88                                                 Feature currentFeature = featList.get(0); 
    89                                                 int unitId = currentFeature.getUnit(); 
    90                                                 // Check in Ontology if it is a DatabaseLink: 
    91                                                 List<Ontology> ontList = db.find(Ontology.class, new QueryRule("id", Operator.EQUALS, unitId)); 
    92                                                 Ontology currentOntTerm = ontList.get(0); 
    93                                                 String termType = currentOntTerm.getTermtype(); 
    94                                                 // If so, find the corresponding target: 
    95                                                 if (termType.equals("DatabaseLink")) { 
    96                                                         int targetId = Integer.parseInt(currentValueContents); 
    97                                                         List<Target> targetList = db.find(Target.class, new QueryRule("id", Operator.EQUALS, targetId)); 
    98                                                         Target currentTarget = targetList.get(0); 
    99                                                         currentValueContents = currentTarget.getName(); 
     91 
     92                                                if (!currentValue.getFeatureidLabel().equals("Dummy")) { 
     93                                                        // Get the real value: 
     94                                                        currentValueContents = currentValue 
     95                                                                        .getValuestring(); 
     96                                                        // Find out what the unit is: 
     97                                                        int featureId = currentValue.getFeatureid(); 
     98                                                        List<Feature> featList = db.find(Feature.class, 
     99                                                                        new QueryRule("id", Operator.EQUALS, 
     100                                                                                        featureId)); 
     101                                                        Feature currentFeature = featList.get(0); 
     102                                                        unitName = "(" + currentFeature.getUnitLabel() + ")"; 
     103                                                        int unitId = currentFeature.getUnit(); 
     104                                                        // Check in Ontology if it is a DatabaseLink: 
     105                                                        List<Ontology> ontList = db 
     106                                                                        .find(Ontology.class, new QueryRule("id", 
     107                                                                                        Operator.EQUALS, unitId)); 
     108                                                        Ontology currentOntTerm = ontList.get(0); 
     109                                                        String termType = currentOntTerm.getTermtype(); 
     110                                                        // If so, find the corresponding target: 
     111                                                        if (termType.equals("DatabaseLink")) { 
     112                                                                int targetId = Integer 
     113                                                                                .parseInt(currentValueContents); 
     114                                                                List<Target> targetList = db.find(Target.class, 
     115                                                                                new QueryRule("id", Operator.EQUALS, 
     116                                                                                                targetId)); 
     117                                                                Target currentTarget = targetList.get(0); 
     118                                                                currentValueContents = currentTarget.getName(); 
     119                                                        } 
     120                                                } else { 
     121                                                        currentValueContents = ""; 
     122                                                        unitName = ""; 
    100123                                                } 
    101                                                  
    102                                                 out.print("<td>" + currentValueContents + "</td>"); 
     124 
     125                                                out.print("<td>" + currentValueContents + " " 
     126                                                                + unitName + "</td>"); 
    103127                                        } 
    104128                                        out.print("</tr>"); 
     
    106130                                } 
    107131                        } 
    108                          
     132 
    109133                        out.flush(); 
    110134 
    111135                        logger.info("serving " + request.getRequestURI()); 
    112                 } 
    113                 catch (Exception e) 
    114                 { 
     136                } catch (Exception e) { 
    115137                        e.printStackTrace(out); 
    116                 } 
    117                 finally 
    118                 { 
     138                } finally { 
    119139                        out.close(); 
    120140                } 
  • molgenis4animaldb/molgenis4animal_db.xml

    r2631 r2656  
    77 
    88        <description>This is an minimal database to show how 
    9                 AnimalDB works in combination with Molgenis. The purpose of 
    10                 this database is to administrate animals, groups of animals, 
    11                 locations, events and event types.</description> 
     9                AnimalDB works in 
     10                combination with Molgenis. The purpose of 
     11                this database is to 
     12                administrate animals, groups of animals, 
     13                locations, events and event 
     14                types.</description> 
    1215 
    1316        <!-- abstract data types --> 
     
    1518        <entity name="Identifiable" abstract="true"> 
    1619                <description>For modeling purposes only (denoted by 
    17                         abstract='true', this entity defines fields id and name centrally. 
     20                        abstract='true', 
     21                        this entity defines fields id and name centrally. 
    1822                </description> 
    1923                <field name="id" type="autoid" description="autogenerated id number (autoid)" /> 
    20                 <field name="name" unique="true" description="unique, user provided name string" label="Name"/> 
    21                 <field name="comment" nillable="true" description="optional comment string" label="Comment"/> 
     24                <field name="name" unique="true" description="unique, user provided name string" 
     25                        label="Name" /> 
     26                <field name="comment" nillable="true" description="optional comment string" 
     27                        label="Comment" /> 
    2228        </entity> 
    2329 
    2430        <!-- event structure --> 
    25          
     31 
    2632        <entity name="Ontology" xref_label="id" label="Ontology"> 
    27                 <description>This entity centrally defines the terms and their definitions  
     33                <description>This entity centrally defines the terms and their 
     34                        definitions 
    2835                        that can be used in the data model. 
    2936                </description> 
    3037                <field name="id" type="autoid" description="autogenerated id number (autoid)" /> 
    31                 <field name="name" type="string" unique="true" description="the ontology term itself" label="Name"/> 
    32                 <field name="termtype" type="string" description="the class the term belongs to, or meta" label="Term type"/> 
    33                 <field name="definition" type="text" description="the definition" nillable="true" label="Definition"/> 
    34                 <field name="path" type="text" description="path leading to the term" nillable="true" label="Path"/> 
    35                 <field name="accession" type="string" unique="true" description="link to the ontology source"  
    36                         nillable="true" label="Accession"/> 
     38                <field name="name" type="string" unique="true" 
     39                        description="the ontology term itself" label="Name" /> 
     40                <field name="termtype" type="string" 
     41                        description="the class the term belongs to, or meta" label="Term type" /> 
     42                <field name="definition" type="text" description="the definition" 
     43                        nillable="true" label="Definition" /> 
     44                <field name="path" type="text" description="path leading to the term" 
     45                        nillable="true" label="Path" /> 
     46                <field name="accession" type="string" unique="true" 
     47                        description="link to the ontology source" nillable="true" label="Accession" /> 
    3748        </entity> 
    38          
     49 
    3950        <entity name="Feature" extends="Ontology" xref_label="id" label="Features" 
    4051                decorator="decorators.FeatureDecorator"> 
    4152                <description>Features</description> 
    4253                <field name="unit" type="xref" xref_field="Ontology.id" 
    43                         xref_label="name" label="Unit"/> 
     54                        xref_label="name" label="Unit" /> 
    4455        </entity> 
    4556 
    46         <entity name="Event" implements="Identifiable" xref_label="id" label="Events"> 
     57        <entity name="Event" implements="Identifiable" xref_label="id" 
     58                label="Events"> 
    4759                <description>Events</description> 
    4860                <field name="eventtypeid" type="xref" xref_field="EventType.id" 
    49                         xref_label="name" label="Event type"/> 
     61                        xref_label="name" label="Event type" /> 
    5062                <field name="timereported" type="datetime" auto="true" 
    5163                        description="Creation date and time, with an automatic default to 'now'" 
    52                         label="Date and time"/> 
     64                        label="Date and time" /> 
    5365                <field name="actorid" type="xref" xref_field="Target.id" 
    54                         xref_label="name" label="Actor"/> 
     66                        xref_label="name" label="Actor" /> 
    5567                <field name="eventnotes" type="text" description="Additional notes about the event" 
    56                         label="Event notes" nillable="true"/> 
     68                        label="Event notes" nillable="true" /> 
    5769        </entity> 
    58          
    59         <entity name="Value" implements="Identifiable" xref_label="id" label="Values"> 
     70 
     71        <entity name="Value" implements="Identifiable" xref_label="id" 
     72                label="Values"> 
    6073                <description>Values</description> 
    6174                <field name="time" type="datetime" auto="true" 
    6275                        description="Date and time, with an automatic default to 'now'" 
    63                         label="Date and time"/> 
     76                        label="Date and time" /> 
    6477                <field name="eventid" type="xref" xref_field="Event.id" 
    65                         xref_label="name" label="Corresponding event" nillable="true"/> 
     78                        xref_label="name" label="Corresponding event" nillable="true" /> 
    6679                <field name="featureid" type="xref" xref_field="Feature.id" 
    67                         xref_label="name" label="Corresponding feature"/> 
     80                        xref_label="name" label="Corresponding feature" /> 
    6881                <field name="targetid" type="xref" xref_field="Target.id" 
    69                         xref_label="name" label="Animal (group)" nillable="true"/> 
     82                        xref_label="name" label="Animal (group)" nillable="true" /> 
    7083                <field name="valuetype" type="string" description="The type of value" 
    71                         label="Value type"/> 
     84                        label="Value type" /> 
    7285                <field name="valuestring" type="string" description="The value as a string" 
    73                         label="Value (string)" nillable="true"/> 
     86                        label="Value (string)" nillable="true" /> 
    7487                <!-- 
    75                 <field name="valuenumeric" type="int" description="The value as a numeric" 
    76                         label="Value (numeric)" nillable="true"/> 
    77                 <field name="valuexref" type="xref" xref_field="Target.id" 
    78                         xref_label="name" description="The value as an xref" 
    79                         label="Value (target reference)" nillable="true"/> 
     88                        <field name="valuenumeric" type="int" description="The value as a 
     89                        numeric" label="Value (numeric)" nillable="true"/> <field 
     90                        name="valuexref" type="xref" xref_field="Target.id" xref_label="name" 
     91                        description="The value as an xref" label="Value (target reference)" 
     92                        nillable="true"/> 
    8093                --> 
    8194        </entity> 
    82          
    83         <entity name="EventType" implements="Identifiable" xref_label="id" label="Event types"> 
     95 
     96        <entity name="EventType" implements="Identifiable" xref_label="id" 
     97                label="Event types" decorator="decorators.EventTypeDecorator"> 
    8498                <description>Event types</description> 
    8599                <field name="features" type="mref" xref_field="Feature.id" 
    86                         xref_label="name" label="Feature"/> 
     100                        xref_label="name" label="Feature" /> 
    87101                <!-- 
    88                 <field name="protocolid" type="xref" xref_field="Protocol.id" 
     102                        <field name="protocolid" type="xref" xref_field="Protocol.id" 
    89103                        xref_label="name" label="Corresponding protocol"/> 
    90                  --> 
    91         </entity> 
    92          
    93         <!-- Animals, Groups structure --> 
    94          
    95         <entity name="Target" implements="Identifiable" xref_label="id" label="Targets"> 
    96                 <description>Targets of different kinds, e.g. animals, groups, experiments</description> 
    97                 <field name="targettype" type="xref" xref_field="Ontology.id" nillable="true" 
    98                         xref_label="name" label="Type of target"/> 
    99                 <!--   
    100                 <field name="groupmembers" type="mref" xref_field="AnimalOrGroup.id" nillable="true" 
    101                         xref_label="name" label="Group members"/> 
    102104                --> 
    103105        </entity> 
    104          
    105         <!-- Authorization and Ownership structure 
    106         <entity name="Actor" implements="Identifiable" xref_label="id" label="Actors"> 
    107                 <description>Actors</description> 
    108                 <field name="role" type="string" description="The actor's role" 
    109                         label="Role"/> 
     106 
     107        <!-- Animals, Groups structure --> 
     108 
     109        <entity name="Target" implements="Identifiable" xref_label="id" 
     110                label="Targets"> 
     111                <description>Targets of different kinds, e.g. animals, groups, 
     112                        experiments</description> 
     113                <field name="targettype" type="xref" xref_field="Ontology.id" 
     114                        nillable="true" xref_label="name" label="Type of target" /> 
     115                <!-- 
     116                        <field name="groupmembers" type="mref" xref_field="AnimalOrGroup.id" 
     117                        nillable="true" xref_label="name" label="Group members"/> 
     118                --> 
    110119        </entity> 
     120 
     121        <!-- 
     122                Authorization and Ownership structure <entity name="Actor" 
     123                implements="Identifiable" xref_label="id" label="Actors"> 
     124                <description>Actors</description> <field name="role" type="string" 
     125                description="The actor's role" label="Role"/> </entity> 
    111126        --> 
    112          
     127 
    113128</molgenis> 
  • molgenis4animaldb/molgenis4animal_ui.xml

    r2636 r2656  
    88 
    99        <menu name="mainmenu" position="left" startswith="WelcomeScreen"> 
    10          
     10 
    1111                <plugin name="WelcomeScreen" type="plugin.welcome.WelcomeScreenPlugin" 
    1212                        label="Welcome" /> 
    13                          
     13 
    1414                <menu name="tablemenu" position="left" label="View/manage tables"> 
    1515                        <form name="Ontology" entity="Ontology" view="list" label="Ontology" /> 
     
    2020                        <form name="EventType" entity="EventType" view="list" label="Types of events" /> 
    2121                </menu> 
    22                  
     22 
    2323                <plugin name="AddEvent" type="plugin.addevent.AddEventPlugin" 
    2424                        label="Apply event" /> 
    25                  
     25 
    2626                <plugin name="EventViewer" type="plugin.eventviewer.EventViewerPlugin" 
    2727                        label="View events" /> 
    28                  
     28 
     29                <plugin name="ListPlugin" type="plugin.listplugin.ListPlugin" 
     30                        label="Make/view lists" /> 
     31 
    2932        </menu> 
    3033 
Note: See TracChangeset for help on using the changeset viewer.