Changeset 3491


Ignore:
Timestamp:
09/09/10 16:45:43 (17 months ago)
Author:
erikroos
Message:
  • Corrected date parsing error in loader
  • Began work on report 5
Location:
molgenis_projects/molgenis4phenotype/handwritten/java/plugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • molgenis_projects/molgenis4phenotype/handwritten/java/plugin/fillanimaldb/LoadAnimalDB.java

    r3374 r3491  
    583583                                ct.MarkGroup(invid, decappid, actorid, now, "DecApplication"); 
    584584                                 
    585                                 SimpleDateFormat sdf = new SimpleDateFormat("d-M-yyyy", Locale.US); 
     585                                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); 
    586586                                //applicationstartdate -> time 
    587587                                String appStartDateString = tuple.getString("applicationstartdate"); 
  • molgenis_projects/molgenis4phenotype/handwritten/java/plugin/yearlyreportplugin/VWAReport4.java

    r3489 r3491  
    218218                                                if (endstatus.equals("B. Gedood na beeindiging van de proef") || endstatus.equals("C. Na einde proef in leven gelaten")) col13 = true; 
    219219                                        } 
     220                                         
     221                                        // TODO: handle 'afgevoerde' animals! (col 14-17) 
    220222                                } 
    221223                                 
     
    442444                for (int col = 1; col <= nrCol; col++) { 
    443445                        output += "<th"; 
    444                         if (col == 10 || col == 17) output += " style='border-right-width:2'"; 
     446                        if (col == 2 || col == 10 || col == 17) output += " style='border-right-width:2'"; 
    445447                        output += (">" + col + "</th>"); 
    446448                } 
     
    448450                output += "<tr>"; 
    449451                output += "<td>Codenummer/diersoort en/of naam</td>"; 
    450                 output += "<td>aanwezig op 1 jan. " + year + "</td>"; 
     452                output += "<td style='border-right-width:2'>aanwezig op 1 jan. " + year + "</td>"; 
    451453                output += "<td>eigen fok</td>"; 
    452454                output += "<td>organisatorische eenheid RuG</td>"; 
     
    470472                        for (int col = 1; col <= nrCol; col++) { 
    471473                                output += "<td"; 
    472                                 if (col == 10 || col == 17) output += " style='border-right-width:2'"; 
     474                                if (col == 2 || col == 10 || col == 17) output += " style='border-right-width:2'"; 
    473475                                output += (">" + matrix[idx][col - 1] + "</td>"); 
    474476                        } 
  • molgenis_projects/molgenis4phenotype/handwritten/java/plugin/yearlyreportplugin/VWAReport5.java

    r3374 r3491  
    11package plugin.yearlyreportplugin; 
    22 
     3import java.text.SimpleDateFormat; 
     4import java.util.ArrayList; 
     5import java.util.Date; 
    36import java.util.List; 
     7import java.util.Locale; 
    48 
    59import org.molgenis.framework.db.Database; 
     10import org.molgenis.framework.db.Query; 
     11import org.molgenis.framework.db.QueryRule; 
     12import org.molgenis.framework.db.QueryRule.Operator; 
    613 
    714import commontasks.CommonTasks; 
    815 
    916import pheno.target.ObservationTarget; 
     17import pheno.value.ObservedValue; 
    1018 
    1119public class VWAReport5 extends AnimalDBReport { 
     20         
     21        private int nrCol = 17; 
     22        private List<String[]> matrix = new ArrayList<String[]>(); 
     23        List<String> expSpecList = new ArrayList<String>(); 
     24        private int year; 
    1225         
    1326        public VWAReport5(Database db) { 
     
    2033        public void makeReport(int year, String type) { 
    2134                try { 
    22                         // 
     35                        this.year = year; 
     36                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); 
     37                        Date startOfYear = sdf.parse(year + "-01-01"); 
     38                        Date endOfYear = sdf.parse((year + 1) + "-01-01"); 
     39                         
     40                        List<ObservationTarget> decappList = ct.GetAllMarkedGroups("DecApplication"); 
     41                        for (ObservationTarget d : decappList) { 
     42                                // Check if the DEC application was (partly) in this year 
     43                                int featid = ct.GetObservableFeatureId("DecNr"); 
     44                                Query q = db.query(ObservedValue.class); 
     45                                q.addRules(new QueryRule("observationTarget", Operator.EQUALS, d.getId())); 
     46                                q.addRules(new QueryRule("observableFeature", Operator.EQUALS, featid)); 
     47                                List<ObservedValue> valueList = q.find(); 
     48                                if (valueList.size() > 0) { 
     49                                        String decNr = valueList.get(0).getValue(); 
     50                                        Date startOfDec = valueList.get(0).getTime(); 
     51                                        Date endOfDec = valueList.get(0).getEndtime(); 
     52                                        if (startOfDec.after(endOfYear) || endOfDec.before(startOfYear)) { 
     53                                                continue; 
     54                                        } 
     55                                        // Find the experiments belonging to this DEC 
     56                                        featid = ct.GetObservableFeatureId("DecApplication"); 
     57                                        q = db.query(ObservedValue.class); 
     58                                        q.addRules(new QueryRule("relatedObservationTarget", Operator.EQUALS, d.getId())); 
     59                                        q.addRules(new QueryRule("observableFeature", Operator.EQUALS, featid)); 
     60                                        valueList = q.find(); 
     61                                        for (ObservedValue v : valueList) { 
     62                                                int expid = v.getObservationTarget(); 
     63                                                ObservationTarget exp = ct.GetObservationTargetById(expid); 
     64                                                 
     65                                                // Get the experiment subcode 
     66                                                String expCode = ""; 
     67                                                featid = ct.GetObservableFeatureId("ExperimentNr"); 
     68                                                q = db.query(ObservedValue.class); 
     69                                                q.addRules(new QueryRule("observationTarget", Operator.EQUALS, expid)); 
     70                                                q.addRules(new QueryRule("observableFeature", Operator.EQUALS, featid)); 
     71                                                valueList = q.find(); 
     72                                                if (valueList.size() > 0) { 
     73                                                        expCode = valueList.get(0).getValue(); 
     74                                                } 
     75                                                 
     76                                                // Get the animals that are/were in the experiment 
     77                                                featid = ct.GetObservableFeatureId("Experiment"); 
     78                                                q = db.query(ObservedValue.class); 
     79                                                q.addRules(new QueryRule("relatedObservationTarget", Operator.EQUALS, expid)); 
     80                                                q.addRules(new QueryRule("observableFeature", Operator.EQUALS, featid)); 
     81                                                valueList = q.find(); 
     82                                                for (ObservedValue v2 : valueList) { 
     83                                                        Date entryDate = v2.getTime(); 
     84                                                        Date exitDate = v2.getEndtime(); 
     85                                                        // Check dates 
     86                                                        if (entryDate.after(endOfYear) || exitDate.before(startOfYear)) { 
     87                                                                continue; 
     88                                                        } 
     89                                                        // Get the data about the animal in the experiment 
     90                                                        // TODO: find out prot.app.ID so we find the right values 
     91                                                        // Bijzonderheid dier (animal's AnimalType) 
     92                                                        // Diersoort (animal's Species) 
     93                                                        // Herkomst en hergebruik (animal's Source, except for reuse!) 
     94                                                        // Aantal dieren (count later on!) 
     95                                                        // Doel vd proef (experiment's Goal) 
     96                                                        // Belang van de proef (experiment's Concern) 
     97                                                        // Wettelijke bepalingen (experiment's LawDef) 
     98                                                        // Toxicologisch / veiligheidsonderzoek (experiment's ToxRes) 
     99                                                        // Technieken byzondere (experiment's SpecialTechn) 
     100                                                        // Anesthesie (animal's Anaesthesia) 
     101                                                        // Pijnbestrijding, postoperatief (animal's PainManagement) 
     102                                                        // Ongerief (animal's ActualDiscomfort) 
     103                                                        // Toestand dier na beeindiging proef (animal's ActualAnimalEndStatus) 
     104                                                         
     105                                                        // TODO: if the above values are exactly the same as an earlier row, aggregate them 
     106                                                         
     107                                                        String[] newRow = new String[nrCol]; 
     108                                                        newRow[0] = decNr + expCode + " - " + d.getName(); 
     109                                                        newRow[1] = endOfDec.toString(); 
     110                                                        newRow[15] = decNr + expCode; 
     111                                                        matrix.add(newRow); 
     112                                                } 
     113                                        } 
     114                                } 
     115                        } 
    23116                } catch (Exception e) { 
    24117                        e.printStackTrace(); 
     
    28121        @Override 
    29122        public String toString() { 
    30                 return "<br /><br /><strong>VWAReport5</strong>"; 
     123                String output = "<br /><p><strong>JAARSTAAT DIERPROEVEN registratiejaar " + year + " - Registratieformulier 5</strong></p>"; 
     124                output += "<br /><table border='1' cellpadding='5' cellspacing='5'>"; 
     125                output += "<tr>"; 
     126                output += "<th></th>"; 
     127                output += "<th></th>"; 
     128                for (int col = 1; col < 15; col++) { 
     129                        output += ("<th>" + col + "</th>"); 
     130                } 
     131                output += "<th></th>"; 
     132                output += "</tr>"; 
     133                output += "<tr>"; 
     134                output += "<td>DEC-nr.</td>"; 
     135                output += "<td>DEC verlopen op</td>"; 
     136                output += "<td>Bijzonderheid dier</td>"; 
     137                output += "<td>Diersoort</td>"; 
     138                output += "<td>Herkomst en hergebruik</td>"; 
     139                output += "<td>Aantal dieren</td>"; 
     140                output += "<td>Doel vd proef</td>"; 
     141                output += "<td>Belang van de proef</td>"; 
     142                output += "<td>Wettelijke bepalingen</td>"; 
     143                output += "<td>Toxicologisch / veiligheidsonderzoek</td>"; 
     144                output += "<td>Bijzondere technieken</td>"; 
     145                output += "<td>Anesthesie</td>"; 
     146                output += "<td>Pijnbestrijding, postoperatief</td>"; 
     147                output += "<td>Ongerief</td>"; 
     148                output += "<td>Toestand dier na beeindiging proef</td>"; 
     149                output += "<td>DEC-nummer / Onderzoeksprotocol</td>"; 
     150                output += "<td>Naam (wetenschappelijke naam)</td>"; 
     151                output += "</tr>"; 
     152                for (String [] currentRow : matrix) { 
     153                        output += "<tr>"; 
     154                        for (int col = 0; col < nrCol; col++) { 
     155                                output += ("<td>" + currentRow[col] + "</td>"); 
     156                        } 
     157                        output += "</tr>"; 
     158                } 
     159                output += "</table>"; 
     160                return output; 
    31161        } 
    32162} 
Note: See TracChangeset for help on using the changeset viewer.