Changeset 3562
- Timestamp:
- Jul 16, 2007, 2:35:29 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/DynamicUtil.java
r2993 r3562 70 70 Formatter<Number> intFormatter = FormatterFactory.getIntFormatter(sc); 71 71 columns.add(new TableColumn("POSITION", "POSITION", null, Type.INT, 72 "Position", "Spot position", "always", true, true, true, false, intFormatter)); 72 "Position", "Spot position", "always", true, true, true, 73 Formula.AverageMethod.NONE, intFormatter)); 73 74 for (int channel = 1; channel <= channels; ++channel) 74 75 { 75 76 TableColumn tc = new TableColumn("ch"+channel, "%"+channel, "ch("+channel+")", 76 Type.FLOAT, "Ch "+channel, "Channel " + channel + " intensity" );77 tc.setFormatter(numberFormatter);77 Type.FLOAT, "Ch "+channel, "Channel " + channel + " intensity", "auto", true, true, true, 78 Formula.AverageMethod.ARITHMETIC_MEAN, numberFormatter); 78 79 columns.add(tc); 79 80 } … … 87 88 Formatter<Number> intFormatter = FormatterFactory.getIntFormatter(sc); 88 89 columns.add(new TableColumn(idPrefix + "position", propertyPrefix+"position", "raw('position')", 89 Type.INT, titlePrefix+"Position", "Raw spot position", "auto", true, true, true, false, intFormatter)); 90 Type.INT, titlePrefix+"Position", "Raw spot position", "auto", true, true, true, 91 Formula.AverageMethod.NONE, intFormatter)); 90 92 columns.add(new TableColumn(idPrefix + "block", propertyPrefix+"block", "raw('block')", 91 Type.INT, titlePrefix+"Block", "Block number", "auto", true, true, true, false, intFormatter)); 93 Type.INT, titlePrefix+"Block", "Block number", "auto", true, true, true, 94 Formula.AverageMethod.NONE, intFormatter)); 92 95 columns.add(new TableColumn(idPrefix + "metaGridX", propertyPrefix+"metaGridX", "raw('metaGridX')", 93 Type.INT, titlePrefix+"Meta grid X", "Meta X coordinate", "auto", true, true, true, false, intFormatter)); 96 Type.INT, titlePrefix+"Meta grid X", "Meta X coordinate", "auto", true, true, true, 97 Formula.AverageMethod.NONE, intFormatter)); 94 98 columns.add(new TableColumn(idPrefix + "metaGridY", propertyPrefix+"metaGridY", "raw('metaGridY')", 95 Type.INT, titlePrefix+"Meta grid Y", "Meta Y coordinate", "auto", true, true, true, false, intFormatter)); 99 Type.INT, titlePrefix+"Meta grid Y", "Meta Y coordinate", "auto", true, true, true, 100 Formula.AverageMethod.NONE, intFormatter)); 96 101 columns.add(new TableColumn(idPrefix + "row", propertyPrefix+"row", "raw('row')", Type.INT, 97 titlePrefix+"Row", "Row number", "auto", true, true, true, false, intFormatter)); 102 titlePrefix+"Row", "Row number", "auto", true, true, true, 103 Formula.AverageMethod.NONE, intFormatter)); 98 104 columns.add(new TableColumn(idPrefix + "column", propertyPrefix+"column", "raw('column')", 99 Type.INT, titlePrefix+"Column", "Column number", "auto", true, true, true, false, intFormatter)); 105 Type.INT, titlePrefix+"Column", "Column number", "auto", true, true, true, 106 Formula.AverageMethod.NONE, intFormatter)); 100 107 columns.add(new TableColumn(idPrefix + "x", propertyPrefix+"x", "raw('x')", Type.INT, 101 titlePrefix+"X", "X coordinate", "auto", true, true, true, false, intFormatter)); 108 titlePrefix+"X", "X coordinate", "auto", true, true, true, 109 Formula.AverageMethod.NONE, intFormatter)); 102 110 columns.add(new TableColumn(idPrefix + "y", propertyPrefix+"y", "raw('y')", Type.INT, 103 titlePrefix+"Y", "Y coordinate", "auto", true, true, true, false, intFormatter)); 111 titlePrefix+"Y", "Y coordinate", "auto", true, true, true, 112 Formula.AverageMethod.NONE, intFormatter)); 104 113 105 114 List<RawDataProperty> rdpList = rawDataType.getProperties(); … … 109 118 TableColumn tc = new TableColumn(idPrefix+rdpName, propertyPrefix+rdpName, "raw('"+rdpName+"')", rdp.getType(), 110 119 titlePrefix + rdp.getTitle(), rdp.getDescription(), "auto", true, true, true, 111 rdp. isAveragable(), FormatterFactory.getExtendedPropertyFormatter(sc, rdp));120 rdp.getAverageMethod(), FormatterFactory.getExtendedPropertyFormatter(sc, rdp)); 112 121 columns.add(tc); 113 122 } … … 121 130 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 122 131 columns.add(new TableColumn(idPrefix + "name", propertyPrefix+"name", "rep('name')", 123 Type.STRING, titlePrefix + "Name", "Reporter name", "auto", true, true, true, false, stringFormatter)); 132 Type.STRING, titlePrefix + "Name", "Reporter name", "auto", true, true, true, 133 Formula.AverageMethod.NONE, stringFormatter)); 124 134 columns.add(new TableColumn(idPrefix + "externalId", propertyPrefix+"externalId", "rep('externalId')", 125 Type.STRING, titlePrefix + "ID", "Reporter ID", "auto", true, true, true, false, stringFormatter)); 135 Type.STRING, titlePrefix + "ID", "Reporter ID", "auto", true, true, true, 136 Formula.AverageMethod.NONE, stringFormatter)); 126 137 columns.add(new TableColumn(idPrefix + "symbol", propertyPrefix+"symbol", "rep('symbol')", 127 Type.STRING, titlePrefix + "Gene symbol", "Gene symbol", "auto", true, true, true, false, stringFormatter)); 138 Type.STRING, titlePrefix + "Gene symbol", "Gene symbol", "auto", true, true, true, 139 Formula.AverageMethod.NONE, stringFormatter)); 128 140 columns.add(new TableColumn(idPrefix + "description", propertyPrefix+"description", "rep('description')", 129 Type.STRING, titlePrefix + "Description", "Reporter description", "auto", true, true, true, false, stringFormatter)); 141 Type.STRING, titlePrefix + "Description", "Reporter description", "auto", true, true, true, 142 Formula.AverageMethod.NONE, stringFormatter)); 130 143 columns.add(new TableColumn(idPrefix + "lastUpdate", propertyPrefix+"lastUpdate", "rep('lastUpdate')", 131 Type.DATE, titlePrefix + "Last update", "Last updateded", "auto", true, true, true, false, dateFormatter)); 144 Type.DATE, titlePrefix + "Last update", "Last updateded", "auto", true, true, true, 145 Formula.AverageMethod.NONE, dateFormatter)); 132 146 133 147 List<ExtendedProperty> extended = ExtendedProperties.getProperties("ReporterData"); … … 138 152 String name = ep.getName(); 139 153 TableColumn tc = new TableColumn(idPrefix + name, propertyPrefix + name, "rep('"+name+"')", 140 ep.getType(), titlePrefix + ep.getTitle(), ep.getDescription() );141 tc.setFormatter(FormatterFactory.getExtendedPropertyFormatter(sc, ep));154 ep.getType(), titlePrefix + ep.getTitle(), ep.getDescription(), "auto", true, true, true, 155 ep.getAverageMethod(), FormatterFactory.getExtendedPropertyFormatter(sc, ep)); 142 156 columns.add(tc); 143 157 } … … 158 172 int id = ev.getId(); 159 173 TableColumn tc = new TableColumn(idPrefix+id, propertyPrefix + id, "xtra('" + evt.getExternalId() + "')", ev.getValueType(), 160 titlePrefix+evt.getName(), evt.getDescription() );174 titlePrefix+evt.getName(), evt.getDescription(), "auto", true, true, true, evt.getAverageMethod(), null); 161 175 Formatter<?> formatter = FormatterFactory.getTypeFormatter(sc, evt.getValueType()); 162 176 if (evt.getValueType().isNumerical()) 163 177 { 164 // Numerical types *should* return a num beric formatter which is required by the color formatter178 // Numerical types *should* return a numeric formatter which is required by the color formatter 165 179 formatter = FormatterFactory.getColorFormatter(sc, evt.getColoring(), 166 180 (Formatter<Number>)formatter); … … 188 202 { 189 203 TableColumn tc = new TableColumn(idPrefix+f.getId(), "="+jepExpression, jepExpression, Type.FLOAT, 190 titlePrefix + f.getName(), f.getDescription()); 204 titlePrefix + f.getName(), f.getDescription(), "auto", true, true, true, 205 f.getAverageMethod(), null); 191 206 tc.setFormatter(FormatterFactory.getColorFormatter(sc, f.getColoring(), numberFormatter)); 192 207 columns.add(tc); … … 200 215 List<String> selectedIds = new ArrayList<String>(columns.size()); 201 216 List<String> selectedProperties = new ArrayList<String>(columns.size()); 217 List<TableColumn> selectedColumns = new ArrayList<TableColumn>(columns.size()); 202 218 203 219 String visibleColumns = cc.getSetting("columns"); … … 213 229 selectedProperties.add(tc.getProperty()); 214 230 selectedIds.add(tc.getId()); 231 selectedColumns.add(tc); 215 232 } 216 233 } 217 234 } 218 return new SelectedInfo(selectedProperties, selectedIds );235 return new SelectedInfo(selectedProperties, selectedIds, selectedColumns); 219 236 } 220 237 … … 223 240 public final List<String> selectedProperties; 224 241 public final List<String> selectedIds; 242 public final List<TableColumn> selectedColumns; 225 243 226 private SelectedInfo(List<String> properties, List<String> ids )244 private SelectedInfo(List<String> properties, List<String> ids, List<TableColumn> columns) 227 245 { 228 246 this.selectedIds = ids; 229 247 this.selectedProperties = properties; 248 this.selectedColumns = columns; 230 249 } 231 250 } -
trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java
r3520 r3562 36 36 import net.sf.basedb.util.Values; 37 37 import net.sf.basedb.clients.web.formatter.FormatterFactory; 38 import net.sf.basedb.clients.web.taglib.table.TableColumn; 38 39 import net.sf.basedb.core.AnnotationType; 39 40 import net.sf.basedb.core.BaseException; … … 712 713 @return A query 713 714 */ 714 public DynamicSpotQuery getSpotQuery(DbControl dc, ReporterData reporter, int positionIndex, List< String> selectionList)715 public DynamicSpotQuery getSpotQuery(DbControl dc, ReporterData reporter, int positionIndex, List<TableColumn> selectionList) 715 716 { 716 717 BioAssaySet bioAssaySet = getBioAssaySet(dc); … … 780 781 // Set additional selected columns 781 782 int i = 0; 782 for ( String selectProperty: selectionList)783 for (TableColumn tc : selectionList) 783 784 { 784 785 // Skip channel intensities since they are already selected 785 if (! selectProperty.startsWith("%"))786 if (!tc.getProperty().startsWith("%")) 786 787 { 787 Expression select = ItemContext.getDynamicExpression(dc, selectProperty);788 Expression select = ItemContext.getDynamicExpression(dc, tc.getProperty()); 788 789 if (select != null) 789 790 { … … 791 792 if (positionIndex == SPOT_AVG) 792 793 { 793 select = Aggregations.mean(select);794 select = tc.getAverageMethod().getAverageExpression(select); 794 795 } 795 796 spotQuery.select(Selects.expression(select, "e" + i)); … … 809 810 if (positionIndex == SPOT_AVG) 810 811 { 811 sortby = Aggregations.mean(sortby); 812 // Find TableColumn to know which average method to use 813 boolean found = false; 814 for (TableColumn tc : selectionList) 815 { 816 if (sortProperty.equals(tc.getProperty())) 817 { 818 sortby = tc.getAverageMethod().getAverageExpression(sortby); 819 found = true; 820 break; 821 } 822 } 823 if (!found) sortby = null; 812 824 } 813 825 if (sortby != null) -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/TableColumn.java
r3410 r3562 25 25 package net.sf.basedb.clients.web.taglib.table; 26 26 27 import net.sf.basedb.core.Formula; 27 28 import net.sf.basedb.core.Type; 28 29 import net.sf.basedb.util.formatter.Formatter; … … 71 72 private final boolean exportable; 72 73 private final String show; 73 private final boolean averagable;74 private final Formula.AverageMethod averageMethod; 74 75 private Formatter<?> formatter; 75 76 77 /** 78 Create TableColumn. 79 @param id 80 @param property 81 @param jepExpression 82 @param datatype 83 @param title 84 @param description 85 @deprecated 86 */ 76 87 public TableColumn(String id, String property, String jepExpression, Type datatype, String title, String description) 77 88 { 78 this(id, property, jepExpression, datatype, title, description, "auto", true, true, true, datatype.isNumerical(), null); 89 this(id, property, jepExpression, datatype, title, description, "auto", true, true, true, 90 datatype.isNumerical() ? Formula.AverageMethod.ARITHMETIC_MEAN : null, null); 79 91 } 80 92 81 93 public TableColumn(String id, String property, String jepExpression, Type datatype, String title, String description, String show, 82 boolean sortable, boolean filterable, boolean exportable, boolean averagable, Formatter<?> formatter)94 boolean sortable, boolean filterable, boolean exportable, Formula.AverageMethod averageMethod, Formatter<?> formatter) 83 95 { 84 96 this.id = id; … … 92 104 this.filterable = filterable; 93 105 this.exportable = exportable; 94 this.averag able = datatype.isNumerical() && averagable;106 this.averageMethod = averageMethod; 95 107 this.formatter = formatter; 96 108 } … … 148 160 public boolean isAveragable() 149 161 { 150 return averag able;162 return averageMethod != null && averageMethod != Formula.AverageMethod.NONE; 151 163 } 152 164 165 /** 166 @since 2.4 167 */ 168 public Formula.AverageMethod getAverageMethod() 169 { 170 return averageMethod; 171 } 172 153 173 /** 154 174 @since 2.0.2 -
trunk/src/core/net/sf/basedb/core/ExtendedProperties.java
r2747 r3562 205 205 if (type == Type.STRING && length > 255) type = Type.TEXT; 206 206 boolean nullable = XMLUtil.getBooleanAttribute(property, "null", true); 207 boolean insertable = XMLUtil.getBooleanAttribute(property, "insert", true); ;208 boolean updateable = XMLUtil.getBooleanAttribute(property, "update", true); ;207 boolean insertable = XMLUtil.getBooleanAttribute(property, "insert", true); 208 boolean updateable = XMLUtil.getBooleanAttribute(property, "update", true); 209 209 boolean averagable = XMLUtil.getBooleanAttribute(property, "averagable", type.isNumerical()); 210 String avgMethod = property.getAttributeValue("averagemethod"); 211 Formula.AverageMethod averageMethod = null; 212 if (avgMethod != null) 213 { 214 averageMethod = Formula.AverageMethod.valueOf(avgMethod.toUpperCase()); 215 } 216 else if (averagable) 217 { 218 averageMethod = Formula.AverageMethod.ARITHMETIC_MEAN; 219 } 220 else 221 { 222 averageMethod = Formula.AverageMethod.NONE; 223 } 210 224 211 225 List<Element> links = (List<Element>)property.getChildren("link"); … … 221 235 } 222 236 } 223 properties.add(new ExtendedProperty(name, title, description, column, type, length, nullable, insertable, updateable, averag able, epLinks));237 properties.add(new ExtendedProperty(name, title, description, column, type, length, nullable, insertable, updateable, averageMethod, epLinks)); 224 238 } 225 239 return properties; -
trunk/src/core/net/sf/basedb/core/ExtendedProperty.java
r3472 r3562 46 46 private final boolean insertable; 47 47 private final boolean updateable; 48 private final boolean isAveragable;48 private final Formula.AverageMethod averageMethod; 49 49 private final List<ExtendedPropertyLinker> linkers; 50 50 … … 55 55 ExtendedProperty(String name, String title, String description, String column, 56 56 Type type, int length, boolean nullable, boolean insertable, boolean updateable, 57 boolean isAveragable, List<ExtendedPropertyLinker> linkers)57 Formula.AverageMethod averageMethod, List<ExtendedPropertyLinker> linkers) 58 58 { 59 59 this.name = name; … … 66 66 this.insertable = insertable; 67 67 this.updateable = updateable; 68 this. isAveragable = type.isNumerical() && isAveragable;68 this.averageMethod = averageMethod; 69 69 this.linkers = linkers; 70 70 } … … 161 161 values. By default all numerical values are averagable. 162 162 @return TRUE if it makes sense to take the average, FALSE otherwise 163 @see #getAverageMethod() 163 164 */ 164 165 public boolean isAveragable() 165 166 { 166 return isAveragable; 167 return averageMethod != null && averageMethod != Formula.AverageMethod.NONE; 168 } 169 170 /** 171 Which method to use when calculating the average of a set of values. 172 Prior to 2.4 only arithmetic mean was supported. 173 @return The average method to use 174 @since 2.4 175 */ 176 public Formula.AverageMethod getAverageMethod() 177 { 178 return averageMethod; 167 179 } 168 180 -
trunk/src/core/net/sf/basedb/core/RawDataProperty.java
r2535 r3562 42 42 */ 43 43 RawDataProperty(String name, String title, String description, String column, 44 Type type, int length, boolean nullable, boolean averagable, int channel)44 Type type, int length, boolean nullable, Formula.AverageMethod averageMethod, int channel) 45 45 { 46 super(name, title, description, column, type, length, nullable, true, false, averag able, null);46 super(name, title, description, column, type, length, nullable, true, false, averageMethod, null); 47 47 this.channel = channel; 48 48 } -
trunk/src/core/net/sf/basedb/core/RawDataTypes.java
r2535 r3562 177 177 boolean nullable = XMLUtil.getBooleanAttribute(property, "null", true); 178 178 boolean averagable = XMLUtil.getBooleanAttribute(property, "averagable", type.isNumerical()); 179 String avgMethod = property.getAttributeValue("averagemethod"); 180 Formula.AverageMethod averageMethod = null; 181 if (avgMethod != null) 182 { 183 averageMethod = Formula.AverageMethod.valueOf(avgMethod.toUpperCase()); 184 } 185 else if (averagable) 186 { 187 averageMethod = Formula.AverageMethod.ARITHMETIC_MEAN; 188 } 189 else 190 { 191 averageMethod = Formula.AverageMethod.NONE; 192 } 179 193 int channel = XMLUtil.getIntAttribute(property, "channel", 0); 180 properties.add(new RawDataProperty(name, title, description, column, type, length, nullable, averag able, channel));194 properties.add(new RawDataProperty(name, title, description, column, type, length, nullable, averageMethod, channel)); 181 195 } 182 196 return properties; -
trunk/src/core/net/sf/basedb/core/data/ExtendableData.java
r2601 r3562 45 45 update="true" 46 46 insert="true" 47 averag able="false"47 averagemethod="geometric_mean" 48 48 description="An extra property for all reporters" 49 49 /> … … 156 156 <td>averagable</td> 157 157 <td> 158 <b>This attribute has been deprecated and is replaced by <code>averagemethod</code>!</b> 159 <br> 158 160 If it makes sense to take the average of multiple values for this 159 161 property. By default all numerical columns are averagable. For non-numerical 160 columns, this attribute is ignored. 162 columns, this attribute is ignored. The default method is to calculate the 163 arithmetic mean. 161 164 <ul> 162 165 <li>true … … 164 167 </ul> 165 168 See {@link net.sf.basedb.core.ExtendedProperty#isAveragable()}. 169 </td> 170 </tr> 171 <tr valign="top"> 172 <td>averagemethod</td> 173 <td> 174 The method to use when calculating the average of a set of values. 175 This attribute replaces the <code>averagable</code> attribute. 176 The following values can be used: 177 <ul> 178 <li>none: do not use this property when calculating averages 179 <li>arithmetic_mean: calculate the arithmetic mean 180 <li>geometric_mean: calculate the geometric mean 181 <li>min: use the minimum value among the values in the set 182 <li>max: use the maximum value among the values in the set 183 </ul> 184 If no value is given to this attribute the default is to use arithmetic 185 mean for all numerical value types. 186 See {@link net.sf.basedb.core.ExtendedProperty#getAverageMethod()}. 166 187 </td> 167 188 </tr> -
trunk/src/core/net/sf/basedb/core/dtd/extended-properties.dtd
r2535 r3562 43 43 update (true|false) "true" 44 44 averagable (true|false) #IMPLIED 45 averagemethod (none|arithmetic_mean|geometric_mean|min|max) #IMPLIED 45 46 > 46 47 -
trunk/src/core/net/sf/basedb/core/dtd/raw-data-types.dtd
r2535 r3562 46 46 null (true|false) "true" 47 47 averagable (true|false) #IMPLIED 48 averagemethod (none|arithmetic_mean|geometric_mean|min|max) #IMPLIED 48 49 channel CDATA #IMPLIED 49 50 > -
trunk/www/views/experiments/explorer/view/view.jsp
r3520 r3562 120 120 DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] "); 121 121 columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT, 122 "[Raw] Spotimage", "", "auto", false, false, false, false,122 "[Raw] Spotimage", "", "auto", false, false, false, null, 123 123 new SpotImageFormatter(dc, rawDataType, root))); 124 124 } … … 162 162 try 163 163 { 164 DynamicSpotQuery spotQuery = explorer.getSpotQuery(dc, reporter, positionIndex, selected.selected Properties);164 DynamicSpotQuery spotQuery = explorer.getSpotQuery(dc, reporter, positionIndex, selected.selectedColumns); 165 165 spotData = spotQuery.iterate(dc); 166 166 }
Note: See TracChangeset
for help on using the changeset viewer.