Changeset 3562 for trunk/src/core/net/sf
- Timestamp:
- Jul 16, 2007, 2:35:29 PM (15 years ago)
- Location:
- trunk/src/core/net/sf/basedb/core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
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 >
Note: See TracChangeset
for help on using the changeset viewer.