Changeset 2656
- Timestamp:
- 02/25/10 10:43:24 (2 years ago)
- Location:
- molgenis4animaldb
- Files:
-
- 4 added
- 4 edited
-
handwritten/java/decorators/EventTypeDecorator.java (added)
-
handwritten/java/plugin/listplugin (added)
-
handwritten/java/plugin/listplugin/ListPlugin.ftl (added)
-
handwritten/java/plugin/listplugin/ListPlugin.java (added)
-
handwritten/java/servlets/AddEventMenuServlet.java (modified) (1 diff)
-
handwritten/java/servlets/ViewEventsServlet.java (modified) (5 diffs)
-
molgenis4animal_db.xml (modified) (2 diffs)
-
molgenis4animal_ui.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molgenis4animaldb/handwritten/java/servlets/AddEventMenuServlet.java
r2636 r2656 55 55 while (correspondingFeatureIterator.hasNext()) { 56 56 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 + ">"); 58 64 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 + "/>"); 60 66 out.print("<em>(unit: "+currentFeature.getUnitLabel()+")</em>"); 61 67 out.print("<input type='hidden' name='feature"+valueNr+"' value='"+currentFeature.getId()+"' />"); 62 68 out.print("</div>"); 63 69 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>"); 65 71 out.print("<input type='text' class='textbox' id='datetime"+valueNr+"' name='datetime"+valueNr+"' value='' onclick='showDateInput(this,true)' autocomplete='off' />"); 66 72 out.print("</div>"); -
molgenis4animaldb/handwritten/java/servlets/ViewEventsServlet.java
r2653 r2656 27 27 import animaldb.Value; 28 28 29 public class ViewEventsServlet extends app.servlet.MolgenisServlet 30 { 29 public class ViewEventsServlet extends app.servlet.MolgenisServlet { 31 30 /** 32 31 * … … 35 34 private static Logger logger = Logger.getLogger(ViewEventsServlet.class); 36 35 37 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException38 {36 public void service(HttpServletRequest request, HttpServletResponse response) 37 throws ServletException, IOException { 39 38 40 39 PrintWriter out = response.getWriter(); 41 try 42 { 40 try { 43 41 Tuple req = new HttpServletRequestTuple(request); 44 42 45 43 Database db = getDatabase(); 46 44 … … 49 47 out.print(""); 50 48 } 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)); 52 51 if (!valList.isEmpty()) { 53 52 Iterator<Value> valIterator = valList.iterator(); … … 59 58 Value currentValue = valIterator.next(); 60 59 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)); 62 62 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>"); 66 67 } 67 68 out.print("</tr>"); 68 69 70 String currentValueContents = ""; 71 String unitName = ""; 72 73 // Print feature names 69 74 out.print("<tr class='form_listrow0'>"); 70 75 valIterator = valList.iterator(); 71 76 while (valIterator.hasNext()) { 72 77 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>"); 74 83 } 75 84 out.print("</tr>"); 76 85 86 // Print contents 77 87 out.print("<tr class='form_listrow1'>"); 78 88 valIterator = valList.iterator(); 79 // Print contents80 89 while (valIterator.hasNext()) { 81 90 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 = ""; 100 123 } 101 102 out.print("<td>" + currentValueContents + "</td>"); 124 125 out.print("<td>" + currentValueContents + " " 126 + unitName + "</td>"); 103 127 } 104 128 out.print("</tr>"); … … 106 130 } 107 131 } 108 132 109 133 out.flush(); 110 134 111 135 logger.info("serving " + request.getRequestURI()); 112 } 113 catch (Exception e) 114 { 136 } catch (Exception e) { 115 137 e.printStackTrace(out); 116 } 117 finally 118 { 138 } finally { 119 139 out.close(); 120 140 } -
molgenis4animaldb/molgenis4animal_db.xml
r2631 r2656 7 7 8 8 <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> 12 15 13 16 <!-- abstract data types --> … … 15 18 <entity name="Identifiable" abstract="true"> 16 19 <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. 18 22 </description> 19 23 <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" /> 22 28 </entity> 23 29 24 30 <!-- event structure --> 25 31 26 32 <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 28 35 that can be used in the data model. 29 36 </description> 30 37 <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" /> 37 48 </entity> 38 49 39 50 <entity name="Feature" extends="Ontology" xref_label="id" label="Features" 40 51 decorator="decorators.FeatureDecorator"> 41 52 <description>Features</description> 42 53 <field name="unit" type="xref" xref_field="Ontology.id" 43 xref_label="name" label="Unit" />54 xref_label="name" label="Unit" /> 44 55 </entity> 45 56 46 <entity name="Event" implements="Identifiable" xref_label="id" label="Events"> 57 <entity name="Event" implements="Identifiable" xref_label="id" 58 label="Events"> 47 59 <description>Events</description> 48 60 <field name="eventtypeid" type="xref" xref_field="EventType.id" 49 xref_label="name" label="Event type" />61 xref_label="name" label="Event type" /> 50 62 <field name="timereported" type="datetime" auto="true" 51 63 description="Creation date and time, with an automatic default to 'now'" 52 label="Date and time" />64 label="Date and time" /> 53 65 <field name="actorid" type="xref" xref_field="Target.id" 54 xref_label="name" label="Actor" />66 xref_label="name" label="Actor" /> 55 67 <field name="eventnotes" type="text" description="Additional notes about the event" 56 label="Event notes" nillable="true" />68 label="Event notes" nillable="true" /> 57 69 </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"> 60 73 <description>Values</description> 61 74 <field name="time" type="datetime" auto="true" 62 75 description="Date and time, with an automatic default to 'now'" 63 label="Date and time" />76 label="Date and time" /> 64 77 <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" /> 66 79 <field name="featureid" type="xref" xref_field="Feature.id" 67 xref_label="name" label="Corresponding feature" />80 xref_label="name" label="Corresponding feature" /> 68 81 <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" /> 70 83 <field name="valuetype" type="string" description="The type of value" 71 label="Value type" />84 label="Value type" /> 72 85 <field name="valuestring" type="string" description="The value as a string" 73 label="Value (string)" nillable="true" />86 label="Value (string)" nillable="true" /> 74 87 <!-- 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"/> 80 93 --> 81 94 </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"> 84 98 <description>Event types</description> 85 99 <field name="features" type="mref" xref_field="Feature.id" 86 xref_label="name" label="Feature" />100 xref_label="name" label="Feature" /> 87 101 <!-- 88 <field name="protocolid" type="xref" xref_field="Protocol.id"102 <field name="protocolid" type="xref" xref_field="Protocol.id" 89 103 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"/>102 104 --> 103 105 </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 --> 110 119 </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> 111 126 --> 112 127 113 128 </molgenis> -
molgenis4animaldb/molgenis4animal_ui.xml
r2636 r2656 8 8 9 9 <menu name="mainmenu" position="left" startswith="WelcomeScreen"> 10 10 11 11 <plugin name="WelcomeScreen" type="plugin.welcome.WelcomeScreenPlugin" 12 12 label="Welcome" /> 13 13 14 14 <menu name="tablemenu" position="left" label="View/manage tables"> 15 15 <form name="Ontology" entity="Ontology" view="list" label="Ontology" /> … … 20 20 <form name="EventType" entity="EventType" view="list" label="Types of events" /> 21 21 </menu> 22 22 23 23 <plugin name="AddEvent" type="plugin.addevent.AddEventPlugin" 24 24 label="Apply event" /> 25 25 26 26 <plugin name="EventViewer" type="plugin.eventviewer.EventViewerPlugin" 27 27 label="View events" /> 28 28 29 <plugin name="ListPlugin" type="plugin.listplugin.ListPlugin" 30 label="Make/view lists" /> 31 29 32 </menu> 30 33
Note: See TracChangeset
for help on using the changeset viewer.