Changeset 2657


Ignore:
Timestamp:
02/25/10 14:05:07 (2 years ago)
Author:
erikroos
Message:

In Apply Event and View Lists plugins, now showing the corresponding targets' names for values that are in fact links to the target table.

Location:
molgenis4animaldb/handwritten/java
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • molgenis4animaldb/handwritten/java/plugin/listplugin/ListPlugin.ftl

    r2656 r2657  
    2727 
    2828<div style="float:left"> 
     29        <input type="hidden" name="ColumnToRemove" /> 
    2930        <table class='listtable'> 
    3031        <tr> 
     
    5657                <#assign i = i + 1> 
    5758        </#list> 
     59        <tr> 
     60                <td></td> 
     61                <#assign i = 0> 
     62                <#list screen.featureList as fl> 
     63                        <#if screen.featureVisibilityList[i] == 1> 
     64                                <td><div align="center"> 
     65                                        <input type="submit" value="-" class="minusbutton" onclick="ColumnToRemove.value='${i}'; __action.value='remColumn';" /> 
     66                                </div></td> 
     67                        </#if> 
     68                        <#assign i = i + 1> 
     69                </#list> 
     70        </tr> 
    5871        </table> 
    5972</div> 
  • molgenis4animaldb/handwritten/java/plugin/listplugin/ListPlugin.java

    r2656 r2657  
    104104                                valueToAdd = ""; 
    105105                                try { 
    106                                         Value tmpValue = (Value) q.find().get(0); 
    107                                         valueToAdd = tmpValue.getValuestring(); 
     106                                        Value currentValue = (Value) q.find().get(0); 
     107                                        // Get the real value: 
     108                                        valueToAdd = currentValue.getValuestring(); 
     109                                        // Find out what the unit is: 
     110                                        int unitId = currentFeature.getUnit(); 
     111                                        // Check in Ontology if it is a DatabaseLink: 
     112                                        List<Ontology> ontList = db 
     113                                                        .find(Ontology.class, new QueryRule("id", 
     114                                                                        Operator.EQUALS, unitId)); 
     115                                        Ontology currentOntTerm = ontList.get(0); 
     116                                        String termType = currentOntTerm.getTermtype(); 
     117                                        // If so, find the corresponding target: 
     118                                        if (termType.equals("DatabaseLink")) { 
     119                                                int targetId = Integer 
     120                                                                .parseInt(valueToAdd); 
     121                                                List<Target> targetList = db.find(Target.class, 
     122                                                                new QueryRule("id", Operator.EQUALS, 
     123                                                                                targetId)); 
     124                                                Target currentTarget = targetList.get(0); 
     125                                                valueToAdd = currentTarget.getName(); 
     126                                        } 
    108127                                } catch (Exception e) { 
    109128                                        e.printStackTrace(); 
     
    122141                                int selectedFeatureId = request.getInt("feature"); 
    123142                                featureVisibilityList.set(selectedFeatureId, 1); 
     143                        } 
     144                         
     145                        if (action.equals("remColumn")) { 
     146                                int selectedFeatureId = request.getInt("ColumnToRemove"); 
     147                                featureVisibilityList.set(selectedFeatureId, 0); 
    124148                        } 
    125149                         
  • molgenis4animaldb/handwritten/java/servlets/AddEventMenuServlet.java

    r2656 r2657  
    2222import animaldb.EventType_features; 
    2323import animaldb.Feature; 
     24import animaldb.Ontology; 
     25import animaldb.Target; 
    2426 
    2527public class AddEventMenuServlet extends app.servlet.MolgenisServlet 
     
    6163                                                        dummyValue = " value='Dummy'"; 
    6264                                                } 
     65                                                boolean DbLink = false; 
     66                                                List<Target> targetList = new ArrayList<Target>(); 
     67                                                // Find out what the unit is: 
     68                                                int unitId = currentFeature.getUnit(); 
     69                                                // Check in Ontology if it is a DatabaseLink: 
     70                                                List<Ontology> ontList = db.find(Ontology.class, new QueryRule("id", Operator.EQUALS, unitId)); 
     71                                                Ontology currentOntTerm = ontList.get(0); 
     72                                                String termType = currentOntTerm.getTermtype(); 
     73                                                // If so, find the corresponding target: 
     74                                                if (termType.equals("DatabaseLink")) { 
     75                                                        DbLink = true; 
     76                                                        String tmpString = currentOntTerm.getName(); 
     77                                                        String metaType = tmpString.substring(0, tmpString.length() - 4); // Remove Link-part; TO DO: solve in a nicer way! 
     78                                                        List<Ontology> ontList2 = db.find(Ontology.class, new QueryRule("name", Operator.EQUALS, metaType)); 
     79                                                        Ontology metaOntTerm = ontList2.get(0); 
     80                                                        targetList = db.find(Target.class, new QueryRule("targettype", Operator.EQUALS, metaOntTerm.getId())); 
     81                                                } 
     82                                                 
    6383                                                out.print("<div id='featurevalue_part' class='row'" + hideDiv + ">"); 
    6484                                                out.print("<label for='value"+valueNr+"'>"+currentFeature.getName()+" value: </label>"); 
    65                                                 out.print("<input type='text' class='textbox' name='value" + valueNr + "' id='value" + valueNr + "' " + dummyValue + "/>"); 
     85                                                if (DbLink) { 
     86                                                        out.print("<select name='value" + valueNr + "' id='value" + valueNr + "'>"); 
     87                                                        for (Target t : targetList) { 
     88                                                                out.print("<option value='" + t.getId() + "'>" + t.getName() + "</option>"); 
     89                                                        } 
     90                                                        out.print("</select>"); 
     91                                                } else { 
     92                                                        out.print("<input type='text' class='textbox' name='value" + valueNr + "' id='value" + valueNr + "' " + dummyValue + "/>"); 
     93                                                } 
    6694                                                out.print("<em>(unit: "+currentFeature.getUnitLabel()+")</em>"); 
    6795                                                out.print("<input type='hidden' name='feature"+valueNr+"' value='"+currentFeature.getId()+"' />"); 
Note: See TracChangeset for help on using the changeset viewer.