Changeset 2942
- Timestamp:
- Nov 22, 2006, 1:34:33 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 2 deleted
- 114 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r2875 r2942 25 25 26 26 import net.sf.basedb.core.Coloring; 27 import net.sf.basedb.core.DateUtil; 27 28 import net.sf.basedb.core.File; 28 29 import net.sf.basedb.core.Location; … … 61 62 import net.sf.basedb.util.ColorGenerator; 62 63 import net.sf.basedb.util.Values; 64 import net.sf.basedb.util.formatter.Formatter; 65 import net.sf.basedb.clients.web.formatter.FormatterFactory; 63 66 import net.sf.basedb.clients.web.util.HTML; 64 67 65 68 import java.awt.Color; 69 import java.util.Date; 66 70 import java.util.Set; 67 71 import java.util.Arrays; … … 517 521 op = Operator.EQ; 518 522 value = value.substring(1); 519 if ("".equals(value)) value = null;520 523 } 521 524 else if (value.indexOf('%') >= 0) 522 525 { 523 526 op = Operator.LIKE; 527 } 528 if ("".equals(value)) value = null; 529 if (valueType == Type.DATE && value != null) 530 { 531 // Dates are stored as long timevalues to avoid problems if user 532 // changes the date format. The date is converted back when displayed 533 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 534 try 535 { 536 Date d = dateFormatter != null ? dateFormatter.parseString(value) : DateUtil.parseString(value); 537 value = d == null ? null : Long.toString(d.getTime()); 538 } 539 catch (Throwable t) 540 {} 524 541 } 525 542 /* … … 600 617 @return A displayable string (null is never returned) 601 618 */ 602 public static String getPropertyFilterString(PropertyFilter filter )619 public static String getPropertyFilterString(PropertyFilter filter, Formatter<Date> dateFormatter) 603 620 { 604 621 String result = ""; … … 607 624 Operator op = filter.getOperator(); 608 625 String value = filter.getValue(); 626 if (filter.getValueType() == Type.DATE && value != null) 627 { 628 try 629 { 630 // Dates are stored as long time values; reformat according to date formatter 631 // or as yyyy-MM-dd if no formatter is specified 632 Date d = new Date(Long.parseLong(value)); 633 if (dateFormatter != null) 634 { 635 value = dateFormatter.format(d); 636 } 637 else 638 { 639 value = DateUtil.formatDate(d); 640 } 641 } 642 catch (Throwable t) 643 {} 644 } 609 645 if (op == Operator.EQ && (value == null || (value != null && value.indexOf('%') >= 0))) 610 646 { … … 926 962 else 927 963 { 928 newAn.setValues(Arrays.asList(valueType.parseStrings(values))); 964 Object[] oValues = new Object[values.length]; 965 Formatter formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), valueType); 966 for (int j = 0; j < values.length; ++j) 967 { 968 oValues[j] = formatter.parseString(values[j]); 969 } 970 newAn.setValues(Arrays.asList(oValues)); 929 971 } 930 972 } -
trunk/src/clients/web/net/sf/basedb/clients/web/DynamicUtil.java
r2813 r2942 41 41 import net.sf.basedb.core.query.Hql; 42 42 import net.sf.basedb.core.query.Orders; 43 import net.sf.basedb.clients.web.formatter.Formatter;44 43 import net.sf.basedb.clients.web.formatter.FormatterFactory; 45 44 import net.sf.basedb.clients.web.taglib.table.TableColumn; 45 import net.sf.basedb.util.formatter.Formatter; 46 46 47 47 import java.util.ArrayList; -
trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java
r2892 r2942 35 35 36 36 import net.sf.basedb.util.Values; 37 import net.sf.basedb.clients.web.formatter.FormatterFactory; 37 38 import net.sf.basedb.core.AnnotationType; 38 39 import net.sf.basedb.core.BaseException; … … 65 66 import net.sf.basedb.core.query.Selects; 66 67 import net.sf.basedb.util.BioAssaySetUtil; 68 import net.sf.basedb.util.formatter.Formatter; 67 69 68 70 /** … … 430 432 final ItemQuery<AnnotationType> query = AnnotationType.getQuery(null); 431 433 query.join(Hql.leftJoin("experiments", Item.EXPERIMENT.getAlias())); 432 query.join(Hql.innerJoin("itemTypes", "itemType")); 434 435 // Restriction for experimental factors 433 436 Restriction ef = Restrictions.eq( 434 437 Hql.alias(Item.EXPERIMENT.getAlias()), 435 438 Hql.entity(getBioAssaySet(dc).getExperiment()) 436 439 ); 440 // Restrictions for BioAssay annotation types 437 441 if (includeBioAssayAnnotations) 438 442 { 443 query.join(Hql.innerJoin("itemTypes", "itemType")); 439 444 Restriction baa = Restrictions.eq( 440 445 Hql.alias("itemType"), … … 446 451 query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); 447 452 query.order(Orders.asc(Hql.property("name"))); 453 query.setDistinct(true); // Needed because of the left join 448 454 return query.list(dc); 449 455 } … … 830 836 private final Set<AnnotationGroup> groups; 831 837 838 @SuppressWarnings("unchecked") 832 839 private AnnotationSummary(ExperimentExplorer explorer, DbControl dc, AnnotationType annotationType) 833 840 { … … 836 843 this.groups = new LinkedHashSet<AnnotationGroup>(); 837 844 845 Formatter formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), annotationType.getValueType()); 838 846 BioAssaySet bioAssaySet = explorer.getBioAssaySet(dc); 839 847 int channels = bioAssaySet.getRawDataType().getChannels(); 840 Map<Set< Object>, AnnotationGroup> temp = new HashMap<Set<Object>, AnnotationGroup>();848 Map<Set<?>, AnnotationGroup> temp = new HashMap<Set<?>, AnnotationGroup>(); 841 849 int groupId = 0; 842 850 for (BioAssay ba : bioAssaySet.getBioAssays().list(dc)) 843 851 { 844 Set< Object> annotationValues = BioAssaySetUtil.getAnnotationValues(dc, ba, annotationType);852 Set<?> annotationValues = BioAssaySetUtil.getAnnotationValues(dc, ba, annotationType); 845 853 AnnotationGroup group = temp.get(annotationValues); 846 854 if (group == null) 847 855 { 848 group = new AnnotationGroup(++groupId, annotationValues, channels );856 group = new AnnotationGroup(++groupId, annotationValues, channels, formatter); 849 857 temp.put(annotationValues, group); 850 858 groups.add(group); … … 888 896 { 889 897 private final int id; 890 private final Set< Object> annotationValues;898 private final Set<?> annotationValues; 891 899 private final String title; 892 900 private final float[] sum; … … 894 902 private final Map<String, Float> statistics; 895 903 896 private AnnotationGroup(int id, Set<Object> annotationValues, int channels)904 private <T> AnnotationGroup(int id, Set<T> annotationValues, int channels, Formatter<T> formatter) 897 905 { 898 906 this.id = id; 899 907 this.annotationValues = annotationValues; 900 this.title = Values.getString(annotationValues, ", ", true );908 this.title = Values.getString(annotationValues, ", ", true, formatter); 901 909 this.sum = new float[channels+1]; // Channels are 1-based 902 910 this.count = new int[channels+1]; … … 929 937 @return A set containing all annotation values 930 938 */ 931 public Set< Object> getAnnotationValues()939 public Set<?> getAnnotationValues() 932 940 { 933 941 return annotationValues; -
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/ColorFormatter.java
r2794 r2942 27 27 28 28 import net.sf.basedb.util.ColorGenerator; 29 import net.sf.basedb.util.formatter.Formatter; 29 30 30 31 /** … … 80 81 return sb.toString(); 81 82 } 83 84 public Number parseString(String value) 85 { 86 return numberFormatter.parseString(value); 87 } 82 88 // ------------------------------------------- 83 89 -
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/ExtendedPropertyFormatter.java
r2733 r2942 25 25 26 26 import net.sf.basedb.core.ExtendedProperty; 27 import net.sf.basedb.util.formatter.Formatter; 27 28 28 29 /** … … 68 69 return formattedValue; 69 70 } 71 public T parseString(String value) 72 { 73 return valueFormatter.parseString(value); 74 } 70 75 // ------------------------------------------- 71 76 -
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/FormatterFactory.java
r2733 r2942 32 32 import net.sf.basedb.core.Type; 33 33 import net.sf.basedb.util.ColorGenerator; 34 import net.sf.basedb.util.formatter.BooleanFormatter; 35 import net.sf.basedb.util.formatter.DateFormatter; 36 import net.sf.basedb.util.formatter.Formatter; 37 import net.sf.basedb.util.formatter.IntegerFormatter; 38 import net.sf.basedb.util.formatter.NumberFormatter; 34 39 35 40 /** … … 174 179 /** 175 180 Get a formatter suitable for displaying values of the given type. 176 If type is <code>FLOAT</code> or <code>D ouble</code> a {@link #getNumberFormatter(SessionControl)}181 If type is <code>FLOAT</code> or <code>DOUBLE</code> a {@link #getNumberFormatter(SessionControl)} 177 182 is returned. If type is <code>LONG</code> or <code>INT</code> 178 183 a {@link #getIntFormatter(SessionControl)} is returned. If type is <code>STRING</code> -
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/FormatterSettings.java
r2795 r2942 24 24 package net.sf.basedb.clients.web.formatter; 25 25 26 import net.sf.basedb.core.InvalidDataException; 26 27 import net.sf.basedb.core.SessionControl; 27 28 import net.sf.basedb.util.Values; 29 import net.sf.basedb.util.formatter.DateFormatter; 28 30 29 31 /** … … 47 49 The default date format for a date formatter = @value 48 50 */ 49 public static final String DEFAULT_DATE_FORMAT = "yyyy- mm-dd";51 public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; 50 52 51 53 /** 52 54 The default datetime format for a datetime formatter = @value 53 55 */ 54 public static final String DEFAULT_DATETIME_FORMAT = "yyyy- mm-dd hh:nn:ss";56 public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; 55 57 56 58 /** … … 105 107 public static void setDateFormat(SessionControl sc, String dateFormat) 106 108 { 109 try 110 { 111 new DateFormatter(dateFormat); 112 } 113 catch (Throwable t) 114 { 115 throw new InvalidDataException("Invalid date format: " + dateFormat, t); 116 } 107 117 sc.setUserClientSetting("formatter.date.formatstring", dateFormat); 108 118 sc.setSessionSetting("formatter.date", null); … … 133 143 public static void setDateTimeFormat(SessionControl sc, String dateTimeFormat) 134 144 { 145 try 146 { 147 new DateFormatter(dateTimeFormat); 148 } 149 catch (Throwable t) 150 { 151 throw new InvalidDataException("Invalid date/time format: " + dateTimeFormat, t); 152 } 135 153 sc.setUserClientSetting("formatter.datetime.formatstring", dateTimeFormat); 136 154 sc.setSessionSetting("formatter.datetime", null); -
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/SpotImageFormatter.java
r2733 r2942 29 29 import net.sf.basedb.core.RawDataUtil; 30 30 import net.sf.basedb.core.data.RawData; 31 import net.sf.basedb.util.formatter.Formatter; 31 32 32 33 /** … … 53 54 } 54 55 56 /* 57 From the Formatter interface 58 ------------------------------------------- 59 */ 55 60 public String format(Integer value) 56 61 { … … 72 77 return sb.toString(); 73 78 } 79 /** 80 Not supported. 81 @since 2.2 82 */ 83 public Integer parseString(String value) 84 { 85 throw new UnsupportedOperationException("parseString"); 86 } 87 // ------------------------------------------- 74 88 75 89 } -
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/StringFormatter.java
r2733 r2942 25 25 26 26 import net.sf.basedb.clients.web.util.HTML; 27 import net.sf.basedb.util.formatter.Formatter; 27 28 28 29 /** … … 53 54 return value == null ? "" : HTML.encodeTags(value); 54 55 } 56 public String parseString(String value) 57 { 58 return value; 59 } 55 60 // ------------------------------------------- 56 61 -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/ExportedProperty.java
r2868 r2942 27 27 import net.sf.basedb.core.DbControl; 28 28 import net.sf.basedb.util.Values; 29 import net.sf.basedb.util.formatter.Formatter; 29 30 30 31 /** … … 39 40 public final String title; 40 41 public final AnnotationType annotationType; 42 public final Formatter formatter; 41 43 42 public static ExportedProperty parse(DbControl dc, String column, boolean annotatable )44 public static ExportedProperty parse(DbControl dc, String column, boolean annotatable, Formatter formatter) 43 45 { 44 46 String[] p = column.split(":"); … … 53 55 name = "annotationtype_"+annotationTypeId; 54 56 } 55 return new ExportedProperty(name, title, at );57 return new ExportedProperty(name, title, at, formatter); 56 58 } 57 59 58 public ExportedProperty(String name, String title, AnnotationType annotationType )60 public ExportedProperty(String name, String title, AnnotationType annotationType, Formatter formatter) 59 61 { 60 62 this.name = name; 61 63 this.title = title; 62 64 this.annotationType = annotationType; 65 this.formatter = formatter; 63 66 } 64 67 -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/PlainTextTemplate.java
r2868 r2942 26 26 import java.io.IOException; 27 27 import java.io.Writer; 28 import java.util.Date;29 28 import java.util.List; 30 29 import java.util.regex.Pattern; … … 101 100 Join the annotation values into a single string with a comma. 102 101 */ 102 @SuppressWarnings("unchecked") 103 103 public void writeAnnotations(ExportedProperty ep, List<?> values) 104 104 throws IOException … … 106 106 if (colNum > 0) exportStream.write("\t"); 107 107 colNum++; 108 exportStream.write(escape(Values.getString(values, ",", true )));108 exportStream.write(escape(Values.getString(values, ",", true, ep.formatter))); 109 109 } 110 110 … … 112 112 Write the data object. 113 113 */ 114 @SuppressWarnings("unchecked") 114 115 public void writeProperty(ExportedProperty ep, Object data) 115 116 throws IOException … … 117 118 if (colNum > 0) exportStream.write("\t"); 118 119 colNum++; 119 exportStream.write(escape( data));120 exportStream.write(escape(ep.formatter.format(data))); 120 121 } 121 122 … … 139 140 private static final Pattern UNSAFE = Pattern.compile("(\\r?\\n\\r?|\\t)"); 140 141 /** 141 Replace newlines and tabs with a space. Null values are converted to empty strings 142 and dates are formatted with {@link Values#formatDate(Date)}. 142 Replace newlines and tabs with a space. Null values are converted to empty strings. 143 143 */ 144 private String escape( Objectdata)144 private String escape(String data) 145 145 { 146 146 if (data == null) … … 148 148 return ""; 149 149 } 150 else if (data instanceof Date)151 {152 return Values.formatDate((Date)data);153 }154 150 else 155 151 { 156 String s = data.toString(); 157 s = UNSAFE.matcher(s).replaceAll(" "); 158 return s; 152 return UNSAFE.matcher(data).replaceAll(" "); 159 153 } 160 154 } -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java
r2873 r2942 24 24 package net.sf.basedb.clients.web.plugins; 25 25 26 import net.sf.basedb.clients.web.formatter.FormatterFactory; 26 27 import net.sf.basedb.core.Annotatable; 27 28 import net.sf.basedb.core.AnnotationSet; … … 61 62 import net.sf.basedb.util.Enumeration; 62 63 import net.sf.basedb.util.Values; 64 import net.sf.basedb.util.formatter.MultiFormatter; 65 import net.sf.basedb.util.formatter.ToStringFormatter; 63 66 64 67 import java.io.IOException; … … 67 70 import java.util.ArrayList; 68 71 import java.util.Arrays; 72 import java.util.Date; 69 73 import java.util.List; 70 74 import java.util.Set; … … 226 230 boolean annotatable = itemType.getItemClass() != null && 227 231 Annotatable.class.isAssignableFrom(itemType.getItemClass()); 232 MultiFormatter formatter = new MultiFormatter(new ToStringFormatter(), true); 233 formatter.registerFormatter(Date.class, FormatterFactory.getDateFormatter(sc)); 228 234 for (String column : columns) 229 235 { 230 ExportedProperty ep = ExportedProperty.parse(dc, column, annotatable );236 ExportedProperty ep = ExportedProperty.parse(dc, column, annotatable, formatter); 231 237 hasAnnotations |= ep.annotationType != null; 232 238 exportedProperties.add(ep); … … 332 338 for (ExportedProperty ep : exportedProperties) 333 339 { 334 if (ep.annotationType != null && as != null && as.hasAnnotation(ep.annotationType))340 if (ep.annotationType != null) 335 341 { 336 List<?> values = as.getAnnotation(ep.annotationType).getValues(); 342 List<?> values = as != null && as.hasAnnotation(ep.annotationType) ? 343 as.getAnnotation(ep.annotationType).getValues() : null; 337 344 template.writeAnnotations(ep, values); 338 345 } … … 367 374 { 368 375 exportStream.flush(); 369 exportStream.close();370 376 } 371 377 } -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/XMLTemplate.java
r2868 r2942 26 26 import java.io.IOException; 27 27 import java.io.Writer; 28 import java.util.Date;29 28 import java.util.List; 30 29 import java.util.regex.Pattern; 31 30 32 31 import net.sf.basedb.core.Item; 33 import net.sf.basedb.util.Values;34 32 35 33 import org.jdom.DocType; … … 121 119 Add annotation values to the current item element. 122 120 */ 121 @SuppressWarnings("unchecked") 123 122 public void writeAnnotations(ExportedProperty ep, List<?> values) 124 123 throws IOException … … 126 125 Element property = new Element("annotation-values"); 127 126 property.setAttribute("ref", ep.name); 128 for (Object value : values)127 if (values != null) 129 128 { 130 Element valueElement = new Element("value"); 131 valueElement.setText(escape(value)); 132 property.addContent(valueElement); 129 for (Object value : values) 130 { 131 Element valueElement = new Element("value"); 132 valueElement.setText(escape(ep.formatter.format(value))); 133 property.addContent(valueElement); 134 } 133 135 } 134 136 itemElement.addContent(property); … … 138 140 Add the property value to the current item element. 139 141 */ 142 @SuppressWarnings("unchecked") 140 143 public void writeProperty(ExportedProperty ep, Object data) 141 144 { 142 145 Element property = new Element("property-value"); 143 146 property.setAttribute("ref", ep.name); 144 property.setText(escape( data));147 property.setText(escape(ep.formatter.format(data))); 145 148 itemElement.addContent(property); 146 149 } … … 166 169 167 170 private static final Pattern NEWLINE = Pattern.compile("\\r?\\n\\r?"); 168 private String escape( Objectdata)171 private String escape(String data) 169 172 { 170 173 if (data == null) … … 172 175 return ""; 173 176 } 174 else if (data instanceof Date)175 {176 return Values.formatDate((Date)data);177 }178 177 else 179 178 { 180 String s = data.toString(); 181 s = NEWLINE.matcher(s).replaceAll("\n"); 182 return s; 179 return NEWLINE.matcher(data).replaceAll("\n"); 183 180 } 184 181 } -
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/PlotServlet.java
r2797 r2942 45 45 import net.sf.basedb.core.query.SqlResult; 46 46 import net.sf.basedb.core.query.SqlResultIterator; 47 import net.sf.basedb.clients.web.formatter.FormatterFactory; 47 48 import net.sf.basedb.clients.web.util.HTML; 48 49 import net.sf.basedb.util.BioAssaySetUtil; 49 50 import net.sf.basedb.util.Values; 51 import net.sf.basedb.util.formatter.Formatter; 50 52 import net.sf.basedb.util.jep.ChannelFunction; 51 53 import net.sf.basedb.util.jep.Jep; … … 294 296 } 295 297 298 @SuppressWarnings("unchecked") 296 299 public void doGet(HttpServletRequest request, HttpServletResponse response) 297 300 throws IOException, ServletException … … 414 417 int annotationTypeId = Values.getInt(annotation); 415 418 AnnotationType at = AnnotationType.getById(dc, annotationTypeId); 416 Map<Set<Object>, List<Integer>> groups = new HashMap<Set<Object>, List<Integer>>(); 419 Map<Set<?>, List<Integer>> groups = new HashMap<Set<?>, List<Integer>>(); 420 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 417 421 for (BioAssay bioAssay : bioAssays) 418 422 { 419 Set< Object> values = BioAssaySetUtil.getAnnotationValues(dc, bioAssay, at);423 Set<?> values = BioAssaySetUtil.getAnnotationValues(dc, bioAssay, at); 420 424 if (!groups.containsKey(values)) 421 425 { … … 424 428 groups.get(values).add((int)bioAssay.getDataCubeColumnNo()); 425 429 } 426 for (Map.Entry<Set< Object>, List<Integer>> entry : groups.entrySet())427 { 428 String name = Values.getString(entry.getKey(), ", ", true );430 for (Map.Entry<Set<?>, List<Integer>> entry : groups.entrySet()) 431 { 432 String name = Values.getString(entry.getKey(), ", ", true, formatter); 429 433 if (name == null || name.trim().equals("")) name = "null"; 430 434 annotations.add(new PlotAnnotation(name, entry.getValue())); -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Cell.java
r2733 r2942 28 28 import javax.servlet.jsp.tagext.BodyTagSupport; 29 29 30 import net.sf.basedb. clients.web.formatter.Formatter;30 import net.sf.basedb.util.formatter.Formatter; 31 31 32 32 /** -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/CellValue.java
r2733 r2942 24 24 package net.sf.basedb.clients.web.taglib.table; 25 25 26 import java.util.List; 27 26 28 import javax.servlet.jsp.JspException; 27 29 import javax.servlet.jsp.JspTagException; 28 30 import javax.servlet.jsp.tagext.TagSupport; 29 31 30 import net.sf.basedb.clients.web.formatter.Formatter; 32 import net.sf.basedb.util.formatter.Formatter; 33 import net.sf.basedb.util.formatter.ToStringFormatter; 31 34 32 35 /** … … 39 42 <tbl:cellvalue 40 43 value=... 44 list=... 45 separator=... 41 46 > 42 47 </pre> … … 52 57 <td>value</td> 53 58 <td>-</td> 54 <td> yes</td>59 <td>no</td> 55 60 <td> 56 61 A value to display in the cell. If a {@link Formatter} has been 57 62 defined for this column the value is formatted otherwise it is just 58 63 converted to a string with the toString() method. 64 </td> 65 </tr> 66 <tr> 67 <td>list</td> 68 <td>-</td> 69 <td>no</td> 70 <td> 71 A list of values to display in the cell. Each value is formatted 72 the same way as for a single value. If a single value is also specified it is 73 printed first. 74 </td> 75 </tr> 76 <tr> 77 <td>list</td> 78 <td>; </td> 79 <td>no</td> 80 <td> 81 A separator to use between each value in a list. 59 82 </td> 60 83 </tr> … … 68 91 { 69 92 93 private static final Formatter toStringFormatter = new ToStringFormatter(); 94 70 95 /** 71 96 The value to display. 72 97 */ 73 98 private Object value = null; 99 private List<?> list = null; 100 private String separator = "; "; 74 101 75 102 /* … … 85 112 return value; 86 113 } 114 115 public void setList(List<?> list) 116 { 117 this.list = list; 118 } 119 120 public List<?> getList() 121 { 122 return list; 123 } 124 125 public void setSeparator(String separator) 126 { 127 this.separator = separator; 128 } 129 130 public String getSeparator() 131 { 132 return separator; 133 } 87 134 88 135 /* … … 95 142 Cell cell = (Cell)getParent(); 96 143 Formatter formatter = cell.getFormatter(); 97 String output = formatter == null ? 98 (value == null ? "" : value.toString()) : 99 formatter.format(value); 144 if (formatter == null) formatter = toStringFormatter; 145 146 StringBuilder output = new StringBuilder(); 147 String theSeparator = ""; 148 if (value != null) 149 { 150 output.append(formatter.format(value)); 151 theSeparator = separator; 152 } 153 if (list != null && list.size() > 0) 154 { 155 for (Object o : list) 156 { 157 if (o != null) 158 { 159 output.append(theSeparator).append(formatter.format(o)); 160 theSeparator = separator; 161 } 162 } 163 } 100 164 try 101 165 { -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/ColumnDef.java
r2754 r2942 23 23 */ 24 24 package net.sf.basedb.clients.web.taglib.table; 25 26 import java.util.Date; 25 27 26 28 import net.sf.basedb.util.Enumeration; … … 31 33 import net.sf.basedb.clients.web.Base; 32 34 import net.sf.basedb.util.Values; 33 import net.sf.basedb.clients.web.formatter.Formatter; 35 import net.sf.basedb.util.formatter.Formatter; 36 import net.sf.basedb.clients.web.formatter.FormatterFactory; 34 37 import net.sf.basedb.clients.web.util.HTML; 35 38 … … 590 593 { 591 594 Type valueType = getValueType(); 595 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(table.getSc()); 592 596 593 597 if (getEnumeration() != null) 594 598 { 595 String filterValue = filter == null ? "" : filter.getValue();599 String filterValue = filter == null ? "" : Base.getPropertyFilterString(filter, dateFormatter); 596 600 sb.append("<select name=\"filter:").append(valueType.name()).append(":").append(getFilterproperty()).append("\""); 597 601 sb.append(" onchange=\"Forms.submit(event);\">\n"); … … 624 628 else 625 629 { 626 String filterValue = HTML.encodeTags(Base.getPropertyFilterString(filter ));630 String filterValue = HTML.encodeTags(Base.getPropertyFilterString(filter, dateFormatter)); 627 631 sb.append("<input class=\"text\" type=\"text\""); 628 632 sb.append(" name=\"filter:").append(valueType.name()).append(":").append(getFilterproperty()).append("\""); -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Table.java
r2890 r2942 27 27 import net.sf.basedb.core.Item; 28 28 import net.sf.basedb.core.ItemContext; 29 import net.sf.basedb.clients.web.formatter.Formatter;30 29 import net.sf.basedb.clients.web.taglib.Page; 31 30 import net.sf.basedb.clients.web.util.HTML; 31 import net.sf.basedb.util.formatter.Formatter; 32 32 33 33 import java.util.HashSet; … … 393 393 boolean alwaysShow = "always".equals(cd.getShow()); 394 394 boolean alwaysHide = "never".equals(cd.getShow()); 395 if ( "never".equals(cd.getShow()))395 if (alwaysHide) 396 396 { 397 397 visibleColumns.remove(columnId); -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/TableColumn.java
r2733 r2942 24 24 package net.sf.basedb.clients.web.taglib.table; 25 25 26 import net.sf.basedb.clients.web.formatter.Formatter;27 26 import net.sf.basedb.core.Type; 27 import net.sf.basedb.util.formatter.Formatter; 28 28 29 29 /** -
trunk/src/core/net/sf/basedb/core/Annotation.java
r2382 r2942 194 194 } 195 195 196 197 /** 198 Get the value type for this annotation type. It can't be change once 199 the object has been created. 200 @since 2.2 201 */ 202 public Type getValueType() 203 { 204 return Type.fromValue(getData().getAnnotationType().getValueType()); 205 } 206 196 207 /** 197 208 Get the values this annotation contains. The values are of a -
trunk/src/core/net/sf/basedb/core/Application.java
r2932 r2942 75 75 The build number. 76 76 @base.internal 77 The <code> @BUILD@</code> string will be replaced with the77 The <code>${base.build}</code> string will be replaced with the 78 78 current subversion revision by the <code>ant dist</code> command. 79 79 See <code>svn.revision</code>, <code>dist.init</code> and … … 81 81 82 82 */ 83 private static final int BUILD = parseBuildNumber(" @BUILD@");83 private static final int BUILD = parseBuildNumber("${base.build}"); 84 84 85 85 /** -
trunk/src/core/net/sf/basedb/core/DateUtil.java
r2610 r2942 76 76 77 77 /** 78 Parses a string to create a <code>Date</code>. 79 @param value the <code>String</code> to be parsed. 78 Parses a string to create a <code>Date</code>. This method supports 79 date in yyyy-MM-dd format or as long timevalues. 80 81 @param value the <code>String</code> to be parsed 80 82 @return a <code>Date</code> object 81 83 @throws InvalidDataException if <code>value</code> isn't a valid date. … … 105 107 return result; 106 108 } 109 110 /** 111 Formats a date in yyyy-MM-dd format. 112 @since 2.2 113 */ 114 public static String formatDate(Date d) 115 { 116 return DATE_FORMAT.format(d); 117 } 118 107 119 } -
trunk/src/core/net/sf/basedb/core/InvalidDataException.java
r2304 r2942 45 45 Create a new <code>InvalidDataException</code> object. 46 46 */ 47 public InvalidDataException( Exception ex)47 public InvalidDataException(Throwable cause) 48 48 { 49 super( ex);49 super(cause); 50 50 } 51 51 … … 60 60 super(message); 61 61 } 62 63 /** 64 Create a new <code>InvalidDataException</code> object with the 65 specified <code>message</code>. 66 67 @param message The message to throw with the exception 68 */ 69 public InvalidDataException(String message, Throwable cause) 70 { 71 super(message, cause); 72 } 62 73 63 74 } -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r2812 r2942 178 178 private Map<String, Object> objects; 179 179 private Query query; 180 181 180 182 181 /** 183 182 Create a new context. … … 555 554 propertyFilters.remove(property); 556 555 } 556 } 557 558 public Object getPropertyObject(String property) 559 { 560 Object value = null; 561 PropertyFilter filter = getPropertyFilter(property); 562 if (filter != null) 563 { 564 value = filter.getValueAsObject(); 565 } 566 return value; 557 567 } 558 568 -
trunk/src/core/net/sf/basedb/util/BioAssaySetUtil.java
r2892 r2942 75 75 @return A set containing all values 76 76 */ 77 public static Set< Object> getAnnotationValues(DbControl dc, BioAssay bioAssay, AnnotationType annotationType)77 public static Set<?> getAnnotationValues(DbControl dc, BioAssay bioAssay, AnnotationType annotationType) 78 78 { 79 79 ItemQuery<RawBioAssay> rbaQuery = bioAssay.getRawBioAssays(); -
trunk/src/core/net/sf/basedb/util/Values.java
r2752 r2942 30 30 import java.util.Collection; 31 31 32 import net.sf.basedb.util.formatter.Formatter; 33 32 34 /** 33 35 This class contains a set of static methods that may be useful … … 389 391 public static final String getString(Collection<?> values, String deliminator, boolean skipNull) 390 392 { 393 return getString(values, deliminator, skipNull, null); 394 } 395 396 public static final <T> String getString(Collection<T> values, String deliminator, boolean skipNull, Formatter<T> formatter) 397 { 391 398 StringBuilder sb = new StringBuilder(); 392 399 boolean firstElement = true; 393 400 if (values != null) 394 401 { 395 for ( Objectvalue : values)402 for (T value : values) 396 403 { 397 404 if (value == null) … … 405 412 else 406 413 { 414 String s; 407 415 if (!firstElement) sb.append(deliminator); 408 if (value instanceof Date) value = formatDate((Date)value); 409 sb.append(value); 416 if (formatter != null) 417 { 418 s = formatter.format(value); 419 } 420 /* 421 else if (value instanceof Date) 422 { 423 s = formatDate((Date)value); 424 } 425 */ 426 else 427 { 428 s = value.toString(); 429 } 430 sb.append(s); 410 431 firstElement = false; 411 432 } 412 433 } 413 434 } 414 return sb.toString(); 435 return sb.toString(); 415 436 } 416 437 … … 467 488 @param value The value to convert 468 489 @return The parsed date or null if the value can't be converted 490 @deprecated Use a {@link Formatter} for dates instead 469 491 */ 470 492 public static final Date getDate(String value) … … 478 500 @param defaultValue The value to return if the string can't be converted 479 501 @return The parsed date or the default value 502 @deprecated Use a {@link Formatter} for dates instead 480 503 */ 481 504 public static final Date getDate(String value, Date defaultValue) … … 493 516 @param values The array of strings 494 517 @return The converted values 518 @deprecated Use a {@link Formatter} for dates instead 495 519 */ 496 520 public static final Date[] getDate(String[] values) … … 526 550 } 527 551 552 public static final Date[] getDate(String[] values, Formatter<Date> dateFormatter) 553 { 554 Date[] result; 555 if (values != null) 556 { 557 Date[] temp = new Date[values.length]; 558 int j = 0; 559 for (String v : values) 560 { 561 Date i = dateFormatter.parseString(v); 562 if (i != null) 563 { 564 temp[j++] = i; 565 } 566 } 567 if (j < values.length) 568 { 569 result = new Date[j]; 570 System.arraycopy(temp, 0, result, 0, j); 571 } 572 else 573 { 574 result = temp; 575 } 576 } 577 else 578 { 579 result = new Date[0]; 580 } 581 return result; 582 } 583 528 584 /** 529 585 Formats a decimal number with the specified number of decimals. … … 667 723 @param date The date to format 668 724 @return The formatted date 725 @deprecated Use a {@link Formatter} for dates instead 669 726 */ 670 727 public static final String formatDate(Date date) … … 678 735 @param time The time to format 679 736 @return The formatted time 737 @deprecated Use a {@link Formatter} for dates instead 680 738 */ 681 739 public static final String formatTime(Date time) … … 691 749 @param datetime The date and time to format 692 750 @return The formatted date with time 751 @deprecated Use a {@link Formatter} for dates instead 693 752 */ 694 753 public static final String formatDateTime(Date datetime) -
trunk/src/core/net/sf/basedb/util/formatter/BooleanFormatter.java
r2921 r2942 22 22 Boston, MA 02111-1307, USA. 23 23 */ 24 package net.sf.basedb.clients.web.formatter; 24 package net.sf.basedb.util.formatter; 25 26 import net.sf.basedb.util.Values; 25 27 26 28 /** … … 54 56 { 55 57 return value == null ? "" : type.getString(value); 58 } 59 public Boolean parseString(String value) 60 { 61 return Values.getBoolean(value); 56 62 } 57 63 // ------------------------------------------- -
trunk/src/core/net/sf/basedb/util/formatter/DateFormatter.java
r2921 r2942 22 22 Boston, MA 02111-1307, USA. 23 23 */ 24 package net.sf.basedb. clients.web.formatter;24 package net.sf.basedb.util.formatter; 25 25 26 26 import java.text.DateFormat; 27 import java.text.ParseException; 27 28 import java.text.SimpleDateFormat; 28 29 import java.util.Date; 29 30 31 import net.sf.basedb.core.InvalidDataException; 32 33 30 34 /** 31 Format a date for output on a web page. 35 Format a date for output in a client application. This implementation 36 uses the {@link SimpleDateFormat} standard formatting routines. 32 37 33 38 @author nicklas … … 41 46 42 47 private DateFormat dateFormat; 48 private String format; 43 49 44 50 /** … … 49 55 { 50 56 this.dateFormat = dateFormat; 57 this.format = null; 51 58 } 52 59 … … 59 66 { 60 67 this.dateFormat = new SimpleDateFormat(format); 68 this.dateFormat.setLenient(true); 69 this.format = format; 61 70 } 62 71 … … 69 78 return value == null ? "" : dateFormat.format(value); 70 79 } 80 public Date parseString(String value) 81 { 82 if (value == null) return null; 83 try 84 { 85 return dateFormat.parse(value); 86 } 87 catch (ParseException ex) 88 { 89 try 90 { 91 return new Date(new Long(value)); 92 } 93 catch (Exception ex2) 94 { 95 throw new InvalidDataException(value + " is not a valid date for format: " + 96 format, ex); 97 } 98 } 99 } 71 100 // ------------------------------------------- 72 101 -
trunk/src/core/net/sf/basedb/util/formatter/Formatter.java
r2921 r2942 22 22 Boston, MA 02111-1307, USA. 23 23 */ 24 package net.sf.basedb. clients.web.formatter;24 package net.sf.basedb.util.formatter; 25 25 26 26 /** 27 27 A <code>Formatter</code> formats an object to a string suitable for 28 output on the web page. 28 output in a client application. The formatter may optionally also do 29 the reverse, ie. parse a string to an object. 29 30 30 31 @author nicklas … … 42 43 public String format(T value); 43 44 45 /** 46 Parse a string and return a value of the correct type. 47 @param value The string to parse 48 @return An object 49 @since 2.2 50 */ 51 public T parseString(String value); 52 44 53 } -
trunk/src/core/net/sf/basedb/util/formatter/IntegerFormatter.java
r2921 r2942 22 22 Boston, MA 02111-1307, USA. 23 23 */ 24 package net.sf.basedb.clients.web.formatter; 24 package net.sf.basedb.util.formatter; 25 25 26 26 27 /** … … 35 36 { 36 37 37 38 38 /** 39 39 Create a new integer formatter. … … 50 50 return value == null ? "" : String.valueOf(value.longValue()); 51 51 } 52 public Number parseString(String value) 53 { 54 return Double.valueOf(value).longValue(); 55 } 52 56 // ------------------------------------------- 53 57 -
trunk/src/core/net/sf/basedb/util/formatter/NumberFormatter.java
r2921 r2942 22 22 Boston, MA 02111-1307, USA. 23 23 */ 24 package net.sf.basedb. clients.web.formatter;24 package net.sf.basedb.util.formatter; 25 25 26 26 import net.sf.basedb.util.Values; … … 58 58 return value == null ? "" : Values.formatNumber(value.floatValue(), numDecimals); 59 59 } 60 public Number parseString(String value) 61 { 62 return Double.valueOf(value); 63 } 60 64 // ------------------------------------------- 61 65 -
trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r2839 r2942 1121 1121 out.print("\t"); 1122 1122 BioAssaySetUtil.getAnnotationValues(dc, ba, at); 1123 Set< Object> v = BioAssaySetUtil.getAnnotationValues(dc, ba, at);1123 Set<?> v = BioAssaySetUtil.getAnnotationValues(dc, ba, at); 1124 1124 if (!v.isEmpty()) 1125 1125 { -
trunk/src/plugins/core/net/sf/basedb/plugins/HelpExporter.java
r2876 r2942 26 26 27 27 import net.sf.basedb.core.BaseException; 28 import net.sf.basedb.core.BooleanParameterType;29 28 import net.sf.basedb.core.Client; 30 29 import net.sf.basedb.core.DbControl; … … 34 33 import net.sf.basedb.core.ItemQuery; 35 34 import net.sf.basedb.core.Path; 36 import net.sf.basedb.core.PathParameterType;37 35 import net.sf.basedb.core.Permission; 38 36 import net.sf.basedb.core.PluginDefinition; … … 353 351 xmlOut.output(helpRoot, helpExportStream); 354 352 helpExportStream.flush(); 355 helpExportStream.close();356 353 } 357 354 -
trunk/src/plugins/core/net/sf/basedb/plugins/PlateMappingExporter.java
r2876 r2942 292 292 } 293 293 textOut.flush(); 294 textOut.close();295 294 } 296 295 protected void end(boolean success) -
trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationExporter.java
r2876 r2942 26 26 27 27 import net.sf.basedb.core.BaseException; 28 import net.sf.basedb.core.BooleanParameterType;29 28 import net.sf.basedb.core.DbControl; 30 29 import net.sf.basedb.core.Include; … … 35 34 import net.sf.basedb.core.ItemResultIterator; 36 35 import net.sf.basedb.core.ParameterInfo; 37 import net.sf.basedb.core.PathParameterType;38 36 import net.sf.basedb.core.Permission; 39 37 import net.sf.basedb.core.PluginConfiguration; … … 42 40 import net.sf.basedb.core.ProgressReporter; 43 41 import net.sf.basedb.core.RequestInformation; 44 import net.sf.basedb.core.StringParameterType;45 42 import net.sf.basedb.core.Type; 46 43 import net.sf.basedb.core.Job.ExecutionTime; … … 336 333 xmlOut.output(configurationRoot, configurationExportStream); 337 334 configurationExportStream.flush(); 338 configurationExportStream.close();339 335 } 340 336 } -
trunk/www/WEB-INF/table.tld
r2733 r2942 624 624 <attribute> 625 625 <name>value</name> 626 <required>true</required> 626 <required>false</required> 627 <rtexprvalue>true</rtexprvalue> 628 </attribute> 629 <attribute> 630 <name>list</name> 631 <required>false</required> 632 <rtexprvalue>true</rtexprvalue> 633 </attribute> 634 <attribute> 635 <name>separator</name> 636 <required>false</required> 627 637 <rtexprvalue>true</rtexprvalue> 628 638 </attribute> -
trunk/www/admin/annotationtypes/edit_annotationtype.jsp
r2933 r2942 45 45 import="net.sf.basedb.clients.web.util.HTML" 46 46 import="net.sf.basedb.util.Values" 47 import="net.sf.basedb.util.formatter.Formatter" 48 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 49 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 50 import="java.util.Date" 47 51 import="java.util.Set" 52 import="java.util.List" 48 53 %> 49 54 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 83 88 final String clazz = "class=\"text\""; 84 89 final String requiredClazz = "class=\"text required\""; 90 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 91 String dateFormat = FormatterSettings.getDateFormat(sc); 92 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 93 String htmlDateFormat = HTML.encodeTags(dateFormat); 85 94 %> 86 95 … … 313 322 <input <%=clazz%> type="text" name="defaultValue" 314 323 value="<%=HTML.encodeTags(defaultValue)%>" 315 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)"> 324 size="20" maxlength="20 "title="Enter date in format: <%=htmlDateFormat%>"> 316 325 </td> 317 326 <td> 318 327 <base:button 319 onclick=" Dates.selectDate('Default value', 'annotationType', 'defaultValue')"328 onclick="<%="Dates.selectDate('Default value', 'annotationType', 'defaultValue', null, '"+jsDateFormat+"')"%>" 320 329 image="calendar.png" 321 330 title="Calendar…" … … 548 557 <td nowrap> 549 558 <% 550 String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); 559 String values = annotationType == null ? "" : 560 Values.getString((List<Date>)annotationType.getValues(), "\n", true, dateFormatter); 551 561 %> 552 562 <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual" 553 onkeypress="return Dates.dateOnly(event)"><%=HTML.encodeTags(values)%></textarea>563 ><%=HTML.encodeTags(values)%></textarea> 554 564 <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" title="Edit in larger window"><base:icon image="zoom.gif" /></a><br> 555 One date value ( yyyy-mm-dd) per line565 One date value (<%=htmlDateFormat%>) per line 556 566 </td> 557 567 </tr> -
trunk/www/admin/annotationtypes/index.jsp
r2933 r2942 47 47 import="net.sf.basedb.util.Values" 48 48 import="net.sf.basedb.clients.web.util.HTML" 49 import="net.sf.basedb.util.formatter.Formatter" 50 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 49 51 import="java.util.Enumeration" 50 52 import="java.util.Set" … … 221 223 if (annotationType.isEnumeration()) 222 224 { 223 Date[] values = Values.getDate(request.getParameter("values").split("[\n\r]+")); 225 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 226 Date[] values = Values.getDate(request.getParameter("values").split("[\n\r]+"), dateFormatter); 224 227 annotationType.setValues(Arrays.asList(values)); 225 228 annotationType.setDisplayAsList("list".equals(request.getParameter("interface"))); -
trunk/www/admin/annotationtypes/view_annotationtype.jsp
r2933 r2942 36 36 import="net.sf.basedb.core.AnnotationTypeCategory" 37 37 import="net.sf.basedb.core.User" 38 import="net.sf.basedb.core.Type" 38 39 import="net.sf.basedb.core.ItemQuery" 39 40 import="net.sf.basedb.core.ItemResultList" … … 48 49 import="net.sf.basedb.clients.web.util.HTML" 49 50 import="net.sf.basedb.util.Values" 51 import="net.sf.basedb.util.formatter.Formatter" 52 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 50 53 import="java.util.Map" 54 import="java.util.Date" 51 55 %> 52 56 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 77 81 final boolean setOwnerPermission = annotationType.hasPermission(Permission.SET_OWNER); 78 82 final boolean isOwner = annotationType.isOwner(); 83 Formatter dateFormatter = FormatterFactory.getDateFormatter(sc); 79 84 %> 80 85 <base:page title="<%=title%>"> … … 219 224 <td class="prompt">Enumeration</td> 220 225 <td><%=annotationType.isEnumeration() ? 221 HTML.encodeTags(Values.getString(annotationType.getValues(), ", ", true)) : "no"%></td> 226 HTML.encodeTags(Values.getString(annotationType.getValues(), ", ", true, 227 annotationType.getValueType() == Type.DATE ? dateFormatter : null)) : "no"%></td> 222 228 </tr> 223 229 <tr> -
trunk/www/admin/diskusage/list_users.jsp
r2929 r2942 56 56 import="net.sf.basedb.clients.web.PermissionUtil" 57 57 import="net.sf.basedb.clients.web.util.HTML" 58 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 58 59 import="net.sf.basedb.util.Values" 59 60 import="java.util.List" … … 240 241 filterable="true" 241 242 exportable="true" 243 formatter="<%=FormatterFactory.getDateFormatter(sc)%>" 242 244 /> 243 245 <tbl:columndef … … 560 562 <tbl:cell column="systemId"><%=Values.getString(item.getSystemId())%></tbl:cell> 561 563 <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell> 562 <tbl:cell column="expirationDate" ><%=Values.formatDate(item.getExpirationDate())%></tbl:cell>564 <tbl:cell column="expirationDate" value="<%=item.getExpirationDate()%>" /> 563 565 <tbl:cell column="disabled"><%=item.isDisabled() ? "yes" : "no" %></tbl:cell> 564 566 <tbl:cell column="multiuserAccount"><%=item.isMultiuserAccount() ? "yes" : "no" %></tbl:cell> -
trunk/www/admin/jobagents/view_agent.jsp
r2921 r2942 50 50 import="net.sf.basedb.util.Values" 51 51 import="net.sf.basedb.clients.web.util.NameablePluginAdaptor" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 54 import="java.util.Map" 53 55 import="java.util.Set" 56 import="java.util.Date" 54 57 %> 55 58 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 71 74 { 72 75 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 76 Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc); 73 77 74 78 String title = null; … … 442 446 <tbl:cell column="job"><%=Base.getLinkedName(ID, job, !readJob, true) %></tbl:cell> 443 447 <tbl:cell column="plugin"><base:propertyvalue item="<%=job%>" property="pluginDefinition"/></tbl:cell> 444 <tbl:cell column="started"><%=job == null ? "" : Values.formatDateTime(job.getStarted())%></tbl:cell>448 <tbl:cell column="started"><%=job == null ? "" : dateFormatter.format(job.getStarted())%></tbl:cell> 445 449 <tbl:cell column="percentComplete"> 446 450 <% -
trunk/www/admin/news/edit_news.jsp
r2753 r2942 36 36 import="net.sf.basedb.clients.web.Base" 37 37 import="net.sf.basedb.clients.web.util.HTML" 38 import="net.sf.basedb.util.formatter.Formatter" 39 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 40 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 38 41 import="net.sf.basedb.util.Values" 39 42 import="java.util.Date" … … 53 56 String title = null; 54 57 News news = null; 58 Date startDate = null; 59 Date newsDate = null; 55 60 56 61 if (itemId == 0) … … 58 63 title = "Create news"; 59 64 cc.removeObject("item"); 65 startDate = (Date)cc.getPropertyObject("startDate"); 66 newsDate = (Date)cc.getPropertyObject("newsDate"); 60 67 } 61 68 else … … 64 71 cc.setObject("item", news); 65 72 title = "Edit news -- " + HTML.encodeTags(news.getName()); 73 startDate = news.getStartDate(); 74 newsDate = news.getNewsDate(); 66 75 } 67 76 if (news != null && !news.hasPermission(Permission.WRITE)) … … 72 81 final String clazz = "class=\"text\""; 73 82 final String requiredClazz = "class=\"text required\""; 83 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 84 String dateFormat = FormatterSettings.getDateFormat(sc); 85 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 86 String htmlDateFormat = HTML.encodeTags(dateFormat); 74 87 %> 75 88 … … 80 93 function validateNews() 81 94 { 95 var dateFormat = '<%=jsDateFormat%>'; 82 96 var frm = document.forms['news']; 83 97 if (Main.trimString(frm.title.value) == '') … … 87 101 return false; 88 102 } 89 else if (!Dates.isDate(frm.start_date.value ))103 else if (!Dates.isDate(frm.start_date.value, dateFormat)) 90 104 { 91 105 alert("'"+frm.start_date.value+"' is not a valid value for start date"); … … 93 107 return false; 94 108 } 95 else if (!Dates.isDate(frm.news_date.value ))109 else if (!Dates.isDate(frm.news_date.value, dateFormat)) 96 110 { 97 111 alert("'"+frm.news_date.value+"' is not a valid value for news date"); … … 99 113 return false; 100 114 } 101 else if (frm.end_date.value != '' && !Dates.isDate(frm.end_date.value ))115 else if (frm.end_date.value != '' && !Dates.isDate(frm.end_date.value, dateFormat)) 102 116 { 103 117 alert("'"+frm.end_date.value+"' is not a valid value for end date"); … … 153 167 <td> 154 168 <input <%=requiredClazz%> type="text" name="start_date" 155 value="<%=Values.formatDate(news == null ? 156 Values.getDate(cc.getPropertyValue("startDate"), new Date()) : news.getStartDate())%>" 157 size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)"> 158 (yyyy-mm-dd) 169 value="<%=HTML.encodeTags(dateFormatter.format(startDate == null ? new Date() : startDate))%>" 170 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 159 171 </td> 160 172 <td> 161 173 <base:button 162 onclick=" Dates.selectDate('Start date', 'news', 'start_date')"174 onclick="<%="Dates.selectDate('Start date', 'news', 'start_date', null, '"+jsDateFormat+"')"%>" 163 175 image="calendar.png" 164 176 title="Calendar…" … … 171 183 <td> 172 184 <input <%=requiredClazz%> type="text" name="news_date" 173 value="<%=Values.formatDate(news == null ? 174 Values.getDate(cc.getPropertyValue("newsDate"), new Date()) : news.getNewsDate())%>" 175 size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)"> 176 (yyyy-mm-dd) 185 value="<%=HTML.encodeTags(dateFormatter.format(newsDate == null ? new Date() : newsDate))%>" 186 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 177 187 </td> 178 188 <td> 179 189 <base:button 180 onclick=" Dates.selectDate('News date', 'news', 'news_date')"190 onclick="<%="Dates.selectDate('News date', 'news', 'news_date', null, '"+jsDateFormat+"')"%>" 181 191 image="calendar.png" 182 192 title="Calendar…" … … 189 199 <td> 190 200 <input <%=clazz%> type="text" name="end_date" 191 value="<%=Values.formatDate(news == null ? 192 Values.getDate(cc.getPropertyValue("endDate")) : news.getEndDate())%>" 193 size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)"> 194 (yyyy-mm-dd) 201 value="<%=dateFormatter.format(news == null ? 202 (Date)cc.getPropertyObject("endDate") : news.getEndDate())%>" 203 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"><br> 195 204 </td> 196 205 <td> 197 206 <base:button 198 onclick=" Dates.selectDate('End date', 'news', 'end_date')"207 onclick="<%="Dates.selectDate('End date', 'news', 'end_date', null, '"+jsDateFormat+"')"%>" 199 208 image="calendar.png" 200 209 title="Calendar…" -
trunk/www/admin/news/index.jsp
r2811 r2942 42 42 import="net.sf.basedb.util.Values" 43 43 import="net.sf.basedb.clients.web.util.HTML" 44 import="net.sf.basedb.util.formatter.Formatter" 45 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 44 46 import="java.util.Date" 45 47 import="java.util.Set" … … 129 131 dc = sc.newDbControl(); 130 132 News news = (News)cc.getObject("item"); 131 Date startDate = Values.getDate(request.getParameter("start_date")); 132 Date newsDate = Values.getDate(request.getParameter("news_date")); 133 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 134 Date startDate = dateFormatter.parseString(request.getParameter("start_date")); 135 Date newsDate = dateFormatter.parseString(request.getParameter("news_date")); 133 136 if (news == null) 134 137 { … … 145 148 } 146 149 news.setName(Values.getStringOrNull(request.getParameter("title"))); 147 news.setEndDate( Values.getDate(request.getParameter("end_date")));150 news.setEndDate(dateFormatter.parseString(request.getParameter("end_date"))); 148 151 news.setDescription(Values.getStringOrNull(request.getParameter("description"))); 149 152 dc.commit(); -
trunk/www/admin/news/list_news.jsp
r2753 r2942 46 46 import="net.sf.basedb.clients.web.ModeInfo" 47 47 import="net.sf.basedb.clients.web.util.HTML" 48 import="net.sf.basedb.util.formatter.Formatter" 49 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 48 50 import="net.sf.basedb.util.Values" 49 51 import="java.util.List" 50 52 import="java.util.Map" 53 import="java.util.Date" 51 54 %> 52 55 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 71 74 try 72 75 { 73 final ItemQuery<News> query = Base.getConfiguredQuery(cc, true, News.getQuery(), mode);74 76 75 77 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 76 78 try 77 79 { 80 final ItemQuery<News> query = Base.getConfiguredQuery(cc, true, News.getQuery(), mode); 78 81 news = query.iterate(dc); 79 82 } … … 83 86 } 84 87 int numListed = 0; 88 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 85 89 %> 86 90 <base:page title="<%=title==null ? "News" : title%>" type="<%=mode.getPageType()%>"> … … 197 201 filterable="true" 198 202 exportable="true" 203 formatter="<%=dateFormatter%>" 199 204 /> 200 205 <tbl:columndef … … 206 211 filterable="true" 207 212 exportable="true" 213 formatter="<%=dateFormatter%>" 208 214 /> 209 215 <tbl:columndef … … 215 221 filterable="true" 216 222 exportable="true" 223 formatter="<%=dateFormatter%>" 217 224 /> 218 225 <tbl:columndef … … 366 373 onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" 367 374 title="<%=tooltip%>"><%=name%></div></tbl:cell> 368 <tbl:cell column="startDate" ><%=Values.formatDate(item.getStartDate())%></tbl:cell>369 <tbl:cell column="newsDate" ><%=Values.formatDate(item.getNewsDate())%></tbl:cell>370 <tbl:cell column="endDate" ><%=Values.formatDate(item.getEndDate())%></tbl:cell>375 <tbl:cell column="startDate" value="<%=item.getStartDate()%>" /> 376 <tbl:cell column="newsDate" value="<%=item.getNewsDate()%>" /> 377 <tbl:cell column="endDate" value="<%=item.getEndDate()%>" /> 371 378 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 372 379 </tbl:row> -
trunk/www/admin/news/view_news.jsp
r2753 r2942 40 40 import="net.sf.basedb.clients.web.PermissionUtil" 41 41 import="net.sf.basedb.clients.web.util.HTML" 42 import="net.sf.basedb.util.formatter.Formatter" 43 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 42 44 import="net.sf.basedb.util.Values" 43 45 import="java.util.Map" 46 import="java.util.Date" 44 47 %> 45 48 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 67 70 final boolean writePermission = news.hasPermission(Permission.WRITE); 68 71 final boolean deletePermission = news.hasPermission(Permission.DELETE); 72 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 69 73 %> 70 74 … … 173 177 <tr> 174 178 <td class="prompt">Start date</td> 175 <td><%= Values.formatDate(news.getStartDate())%></td>179 <td><%=dateFormatter.format(news.getStartDate())%></td> 176 180 </tr> 177 181 <tr> 178 182 <td class="prompt">News date</td> 179 <td><%= Values.formatDate(news.getNewsDate())%></td>183 <td><%=dateFormatter.format(news.getNewsDate())%></td> 180 184 </tr> 181 185 <tr> 182 186 <td class="prompt">End date</td> 183 <td><%= Values.formatDate(news.getEndDate())%></td>187 <td><%=dateFormatter.format(news.getEndDate())%></td> 184 188 </tr> 185 189 <tr valign="baseline"> -
trunk/www/admin/pluginconfigurations/view_configuration.jsp
r2921 r2942 50 50 import="net.sf.basedb.util.Values" 51 51 import="net.sf.basedb.clients.web.util.NameablePluginAdaptor" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 54 import="java.util.Map" 53 55 import="java.util.Set" … … 76 78 { 77 79 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 80 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 78 81 79 82 String title = null; … … 335 338 else if (value instanceof Date) 336 339 { 337 sb.append( Values.formatDate((Date)value));340 sb.append(dateFormatter.format((Date)value)); 338 341 } 339 342 else -
trunk/www/admin/users/edit_user.jsp
r2753 r2942 51 51 import="net.sf.basedb.clients.web.util.HTML" 52 52 import="net.sf.basedb.util.Values" 53 import="net.sf.basedb.util.formatter.Formatter" 54 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 55 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 56 import="java.util.Date" 53 57 %> 54 58 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 164 168 final String clazz = "class=\"text\""; 165 169 final String requiredClazz = "class=\"text required\""; 170 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 171 String dateFormat = FormatterSettings.getDateFormat(sc); 172 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 173 String htmlDateFormat = HTML.encodeTags(dateFormat); 166 174 %> 167 175 … … 440 448 <td> 441 449 <input <%=clazz%> type="text" name="expiration_date" 442 value="<%=user == null ? HTML.encodeTags(cc.getPropertyValue("expirationDate")) : Values.formatDate(user.getExpirationDate())%>" 443 size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)"> 444 (yyyy-mm-dd) 450 value="<%=HTML.encodeTags(dateFormatter.format( 451 user == null ? (Date)cc.getPropertyObject("expirationDate") : user.getExpirationDate()) 452 )%>" 453 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 445 454 </td> 446 455 <td> 447 456 <base:button 448 onclick=" Dates.selectDate('Expiration date', 'user', 'expiration_date')"457 onclick="<%="Dates.selectDate('Expiration date', 'user', 'expiration_date', null, '"+jsDateFormat + "')"%>" 449 458 image="calendar.png" 450 459 title="Calendar…" -
trunk/www/admin/users/index.jsp
r2900 r2942 47 47 import="net.sf.basedb.util.Values" 48 48 import="net.sf.basedb.clients.web.util.HTML" 49 import="net.sf.basedb.util.formatter.Formatter" 50 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 51 import="java.util.Date" 49 52 import="java.util.Enumeration" 50 53 import="java.util.Set" … … 186 189 } 187 190 188 user.setExpirationDate(Values.getDate(request.getParameter("expiration_date"))); 191 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 192 user.setExpirationDate(dateFormatter.parseString(request.getParameter("expiration_date"))); 189 193 user.setMultiuserAccount(Values.getBoolean(request.getParameter("multiuser_account"))); 190 194 user.setDisabled(Values.getBoolean(request.getParameter("disabled"))); -
trunk/www/admin/users/list_users.jsp
r2818 r2942 52 52 import="net.sf.basedb.clients.web.util.HTML" 53 53 import="net.sf.basedb.util.Values" 54 import="net.sf.basedb.util.formatter.Formatter" 55 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 54 56 import="java.util.List" 55 57 import="java.util.Map" 58 import="java.util.Date" 56 59 %> 57 60 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 77 80 try 78 81 { 82 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 83 79 84 // Query for groups relatated to the current user 80 85 final ItemQuery<Group> groupQuery = Group.getQuery(); … … 259 264 filterable="true" 260 265 exportable="true" 266 formatter="<%=dateFormatter%>" 261 267 /> 262 268 <tbl:columndef … … 527 533 <tbl:cell column="systemId"><%=Values.getString(item.getSystemId())%></tbl:cell> 528 534 <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell> 529 <tbl:cell column="expirationDate" ><%=Values.formatDate(item.getExpirationDate())%></tbl:cell>535 <tbl:cell column="expirationDate" value="<%=item.getExpirationDate()%>" /> 530 536 <tbl:cell column="disabled"><%=item.isDisabled() ? "yes" : "no" %></tbl:cell> 531 537 <tbl:cell column="multiuserAccount"><%=item.isMultiuserAccount() ? "yes" : "no" %></tbl:cell> -
trunk/www/admin/users/view_user.jsp
r2753 r2942 50 50 import="net.sf.basedb.clients.web.util.HTML" 51 51 import="net.sf.basedb.util.Values" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 54 import="java.util.Map" 55 import="java.util.Date" 53 56 %> 54 57 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 69 72 try 70 73 { 74 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 71 75 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 72 76 … … 225 229 <td class="prompt">Expiration date</td> 226 230 <td><%=user.getExpirationDate() == null ? "<i>- never -</i>" : 227 Values.formatDate(user.getExpirationDate())%></td>231 dateFormatter.format(user.getExpirationDate())%></td> 228 232 </tr> 229 233 <tr valign="baseline"> -
trunk/www/biomaterials/biosources/list_biosources.jsp
r2916 r2942 52 52 import="net.sf.basedb.clients.web.PermissionUtil" 53 53 import="net.sf.basedb.clients.web.util.HTML" 54 import="net.sf.basedb.util.formatter.Formatter" 55 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 54 56 import="net.sf.basedb.util.Values" 57 import="java.util.Date" 55 58 import="java.util.List" 56 59 import="java.util.Map" … … 77 80 { 78 81 final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); 79 final ItemQuery<BioSource> query = Base.getConfiguredQuery(cc, true, BioSource.getQuery(), mode);80 82 final ItemQuery<Sample> sampleQuery = Sample.getQuery(); 81 83 sampleQuery.include(cc.getInclude()); … … 88 90 try 89 91 { 92 final ItemQuery<BioSource> query = Base.getConfiguredQuery(cc, true, BioSource.getQuery(), mode); 90 93 bioSources = query.iterate(dc); 91 94 } … … 95 98 } 96 99 int numListed = 0; 100 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 97 101 %> 98 102 <base:page title="<%=title==null ? "Biosources" : title%>" type="<%=mode.getPageType()%>"> … … 263 267 { 264 268 Enumeration<String, String> annotationEnum = null; 269 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 265 270 if (at.isEnumeration()) 266 271 { … … 269 274 for (Object value : values) 270 275 { 271 String encoded = HTML.encodeTags(value.toString());276 String encoded = formatter.format(value); 272 277 annotationEnum.add(encoded, encoded); 273 278 } … … 284 289 filterable="true" 285 290 exportable="true" 291 formatter="<%=formatter%>" 286 292 /> 287 293 <% … … 497 503 <% 498 504 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 499 for (AnnotationType at : annotationTypes)505 if (as != null) 500 506 { 501 %> 502 <tbl:cell column="<%="at"+at.getId()%>"> 503 <% 504 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 505 %> 506 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 507 </tbl:cell> 508 <% 507 for (AnnotationType at : annotationTypes) 508 { 509 if (as.hasAnnotation(at)) 510 { 511 %> 512 <tbl:cell column="<%="at"+at.getId()%>" 513 ><tbl:cellvalue 514 list="<%=as.getAnnotation(at).getValues()%>" 515 /></tbl:cell> 516 <% 517 } 518 } 509 519 } 510 520 %> -
trunk/www/biomaterials/events/edit_event.jsp
r2753 r2942 39 39 import="net.sf.basedb.clients.web.util.HTML" 40 40 import="net.sf.basedb.util.Values" 41 import="net.sf.basedb.util.formatter.Formatter" 42 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 43 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 41 44 import="java.util.Date" 42 45 import="java.util.List" … … 59 62 BioMaterialEvent event = null; 60 63 MeasuredBioMaterial bioMaterial = null; 64 Date eventDate = null; 61 65 62 66 boolean readCurrentProtocol = true; … … 70 74 title = "Create event"; 71 75 cc.removeObject("item"); 76 eventDate = (Date)cc.getPropertyObject("eventDate"); 72 77 } 73 78 else 74 79 { 75 80 event = BioMaterialEvent.getById(dc, itemId); 81 eventDate = event.getEventDate(); 76 82 title = "Edit event"; 77 83 cc.setObject("item", event); … … 92 98 final String clazz = "class=\"text\""; 93 99 final String requiredClazz = "class=\"text required\""; 94 100 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 101 String dateFormat = FormatterSettings.getDateFormat(sc); 102 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 103 String htmlDateFormat = HTML.encodeTags(dateFormat); 95 104 %> 96 105 … … 173 182 <td> 174 183 <input <%=clazz%> type="text" name="event_date" 175 value="<%= Values.formatDate(event == null ? Values.getDate(cc.getPropertyValue("eventDate"), new Date()) : event.getEventDate())%>"176 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)">177 (yyyy-mm-dd) 184 value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>" 185 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 186 178 187 </td> 179 188 <td> 180 189 <base:button 181 onclick=" Dates.selectDate('Date', 'event', 'event_date')"190 onclick="<%="Dates.selectDate('Event date', 'event', 'event_date', null, '"+jsDateFormat+"')"%>" 182 191 image="calendar.png" 183 192 title="Calendar…" -
trunk/www/biomaterials/events/index.jsp
r2811 r2942 41 41 import="net.sf.basedb.clients.web.util.HTML" 42 42 import="net.sf.basedb.util.Values" 43 import="net.sf.basedb.util.formatter.Formatter" 44 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 45 import="java.util.Date" 43 46 import="java.util.List" 44 47 import="java.util.Collections" … … 134 137 message = "Event updated"; 135 138 } 139 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 136 140 event.setComment(Values.getStringOrNull(request.getParameter("comment"))); 137 event.setEventDate( Values.getDate(request.getParameter("event_date")));141 event.setEventDate(dateFormatter.parseString(request.getParameter("event_date"))); 138 142 event.setUsedQuantity(Values.getFloat(request.getParameter("used_quantity"), null)); 139 143 int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); -
trunk/www/biomaterials/events/list_events.jsp
r2875 r2942 49 49 import="net.sf.basedb.clients.web.util.HTML" 50 50 import="net.sf.basedb.util.Values" 51 import="net.sf.basedb.util.formatter.Formatter" 52 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 51 53 import="java.util.List" 52 54 import="java.util.Map" 55 import="java.util.Date" 53 56 %> 54 57 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 96 99 } 97 100 98 final ItemQuery<BioMaterialEvent> query = Base.getConfiguredQuery(cc, true, bioMaterial.getEvents(), mode);99 // Skip the creation event100 query.restrict(101 Restrictions.not(102 Restrictions.and(103 Restrictions.eq(104 Hql.property("eventType"),105 Expressions.integer(BioMaterialEvent.Type.CREATION.getValue())106 ),107 Restrictions.eq(108 Hql.property("bioMaterial"),109 Hql.entity(bioMaterial)110 )111 )112 )113 );114 115 101 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 116 102 try 117 103 { 104 final ItemQuery<BioMaterialEvent> query = Base.getConfiguredQuery(cc, true, bioMaterial.getEvents(), mode); 105 // Skip the creation event 106 query.restrict( 107 Restrictions.not( 108 Restrictions.and( 109 Restrictions.eq( 110 Hql.property("eventType"), 111 Expressions.integer(BioMaterialEvent.Type.CREATION.getValue()) 112 ), 113 Restrictions.eq( 114 Hql.property("bioMaterial"), 115 Hql.entity(bioMaterial) 116 ) 117 ) 118 ) 119 ); 118 120 events = query.iterate(dc); 119 121 } … … 123 125 } 124 126 int numListed = 0; 127 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 125 128 %> 126 129 <base:page title="<%=title%>" type="<%=mode.getPageType()%>"> … … 274 277 filterable="true" 275 278 exportable="true" 279 formatter="<%=dateFormatter%>" 276 280 /> 277 281 <tbl:columndef … … 283 287 filterable="true" 284 288 exportable="true" 289 formatter="<%=dateFormatter%>" 285 290 /> 286 291 <tbl:columndef … … 486 491 %> 487 492 </tbl:cell> 488 <tbl:cell column="eventDate" ><%=Values.formatDate(item.getEventDate())%></tbl:cell>489 <tbl:cell column="entryDate" ><%=Values.formatDate(item.getEntryDate())%></tbl:cell>493 <tbl:cell column="eventDate" value="<%=item.getEventDate()%>" /> 494 <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" /> 490 495 <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(bioMaterial), 2)%></tbl:cell> 491 496 <tbl:cell column="protocol" -
trunk/www/biomaterials/events/view_event.jsp
r2753 r2942 50 50 import="net.sf.basedb.clients.web.util.HTML" 51 51 import="net.sf.basedb.util.Values" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 54 import="java.util.Date" 53 55 import="java.util.Map" … … 73 75 try 74 76 { 77 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 75 78 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 76 79 … … 179 182 <tr> 180 183 <td class="prompt">Event date</td> 181 <td><%= Values.formatDate(event.getEventDate())%></td>184 <td><%=dateFormatter.format(event.getEventDate())%></td> 182 185 </tr> 183 186 <tr> 184 187 <td class="prompt">Registration date</td> 185 <td><%= Values.formatDate(event.getEntryDate())%></td>188 <td><%=dateFormatter.format(event.getEntryDate())%></td> 186 189 </tr> 187 190 <tr> -
trunk/www/biomaterials/extracts/edit_extract.jsp
r2875 r2942 48 48 import="net.sf.basedb.clients.web.util.HTML" 49 49 import="net.sf.basedb.util.Values" 50 import="net.sf.basedb.util.formatter.Formatter" 51 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 50 53 import="java.util.List" 51 54 import="java.util.Set" … … 68 71 Extract extract = null; 69 72 BioMaterialEvent creationEvent = null; 73 Date eventDate = null; 70 74 boolean isPooled = false; 71 75 … … 107 111 name = Values.getString(cc.getPropertyValue("name"), "New extract"); 108 112 } 113 eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate"); 109 114 } 110 115 else … … 115 120 116 121 creationEvent = extract.getCreationEvent(); 122 eventDate = creationEvent.getEventDate(); 117 123 isPooled = extract.isPooled(); 118 124 name = extract.getName(); … … 149 155 final String clazz = "class=\"text\""; 150 156 final String requiredClazz = "class=\"text required\""; 157 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 158 String dateFormat = FormatterSettings.getDateFormat(sc); 159 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 160 String htmlDateFormat = HTML.encodeTags(dateFormat); 151 161 %> 152 162 … … 456 466 </tr> 457 467 <tr> 458 <td class="prompt">Remaining quantity</td>459 <td><%=Values.formatNumber(extract == null ? null : extract.getRemainingQuantity(), 2, " µg")%></td>460 </tr>461 <tr>462 468 <td class="prompt">Created</td> 463 469 <td> … … 466 472 <td> 467 473 <input <%=clazz%> type="text" name="event_date" 468 value="<%= Values.formatDate(creationEvent == null ? Values.getDate(cc.getPropertyValue("creationEvent.eventDate"), new Date()): creationEvent.getEventDate())%>"469 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)">470 (yyyy-mm-dd) 474 value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>" 475 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 476 471 477 </td> 472 478 <td> 473 479 <base:button 474 onclick=" Dates.selectDate('Date', 'extract', 'event_date')"480 onclick="<%="Dates.selectDate('Created', 'extract', 'event_date', null, '"+jsDateFormat+"')"%>" 475 481 image="calendar.png" 476 482 title="Calendar…" … … 484 490 <tr> 485 491 <td class="prompt">Registered</td> 486 <td><%= Values.formatDate(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>492 <td><%=dateFormatter.format(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td> 487 493 </tr> 488 494 <tr> -
trunk/www/biomaterials/extracts/index.jsp
r2917 r2942 48 48 import="net.sf.basedb.util.Values" 49 49 import="net.sf.basedb.clients.web.util.HTML" 50 import="net.sf.basedb.util.formatter.Formatter" 51 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 50 52 import="java.util.Enumeration" 51 53 import="java.util.Set" … … 54 56 import="java.util.ArrayList" 55 57 import="java.util.Collections" 58 import="java.util.Date" 56 59 %> 57 60 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 161 164 162 165 BioMaterialEvent creationEvent = extract.getCreationEvent(); 163 creationEvent.setEventDate(Values.getDate(request.getParameter("event_date"))); 166 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 167 creationEvent.setEventDate(dateFormatter.parseString(request.getParameter("event_date"))); 164 168 int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); 165 169 if (protocolId >= 0) // < 0 = denied or unchanged -
trunk/www/biomaterials/extracts/list_extracts.jsp
r2917 r2942 54 54 import="net.sf.basedb.clients.web.PermissionUtil" 55 55 import="net.sf.basedb.clients.web.util.HTML" 56 import="net.sf.basedb.util.formatter.Formatter" 57 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 56 58 import="net.sf.basedb.util.Values" 57 59 import="java.util.List" 58 60 import="java.util.Map" 61 import="java.util.Date" 59 62 %> 60 63 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 97 100 } 98 101 int numListed = 0; 102 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 99 103 %> 100 104 <base:page title="<%=title==null ? "Extracts" : title%>" type="<%=mode.getPageType()%>"> … … 281 285 filterable="true" 282 286 exportable="true" 287 formatter="<%=dateFormatter%>" 283 288 /> 284 289 <tbl:columndef … … 290 295 filterable="true" 291 296 exportable="true" 297 formatter="<%=dateFormatter%>" 292 298 /> 293 299 <tbl:columndef … … 330 336 { 331 337 Enumeration<String, String> annotationEnum = null; 338 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 332 339 if (at.isEnumeration()) 333 340 { … … 336 343 for (Object value : values) 337 344 { 338 String encoded = HTML.encodeTags(value.toString());345 String encoded = formatter.format(value); 339 346 annotationEnum.add(encoded, encoded); 340 347 } … … 351 358 filterable="true" 352 359 exportable="true" 360 formatter="<%=formatter%>" 353 361 /> 354 362 <% … … 538 546 enablePropertyLink="<%=mode.hasPropertyLink()%>" 539 547 /></tbl:cell> 540 <tbl:cell column="eventDate" ><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>541 <tbl:cell column="entryDate" ><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>548 <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" /> 549 <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" /> 542 550 <tbl:cell column="parents"> 543 551 <% … … 620 628 <% 621 629 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 622 for (AnnotationType at : annotationTypes)630 if (as != null) 623 631 { 624 %> 625 <tbl:cell column="<%="at"+at.getId()%>"> 626 <% 627 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 628 %> 629 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 630 </tbl:cell> 631 <% 632 for (AnnotationType at : annotationTypes) 633 { 634 if (as.hasAnnotation(at)) 635 { 636 %> 637 <tbl:cell column="<%="at"+at.getId()%>" 638 ><tbl:cellvalue 639 list="<%=as.getAnnotation(at).getValues()%>" 640 /></tbl:cell> 641 <% 642 } 643 } 632 644 } 633 645 %> -
trunk/www/biomaterials/extracts/view_extract.jsp
r2917 r2942 54 54 import="net.sf.basedb.clients.web.util.HTML" 55 55 import="net.sf.basedb.util.Values" 56 import="net.sf.basedb.util.formatter.Formatter" 57 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 56 58 import="java.util.Date" 57 59 import="java.util.Map" … … 77 79 try 78 80 { 81 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 79 82 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 80 83 … … 253 256 <tr> 254 257 <td class="prompt">Created</td> 255 <td><%= Values.formatDate(creationEvent.getEventDate())%></td>258 <td><%=dateFormatter.format(creationEvent.getEventDate())%></td> 256 259 </tr> 257 260 <tr> 258 261 <td class="prompt">Registered</td> 259 <td><%= Values.formatDate(creationEvent.getEntryDate())%></td>262 <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td> 260 263 </tr> 261 264 <% -
trunk/www/biomaterials/labeledextracts/edit_labeledextract.jsp
r2875 r2942 49 49 import="net.sf.basedb.clients.web.util.HTML" 50 50 import="net.sf.basedb.util.Values" 51 import="net.sf.basedb.util.formatter.Formatter" 52 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 53 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 51 54 import="java.util.List" 52 55 import="java.util.Set" … … 69 72 LabeledExtract extract = null; 70 73 BioMaterialEvent creationEvent = null; 74 Date eventDate = null; 71 75 boolean isPooled = false; 72 76 … … 121 125 name = Values.getString(cc.getPropertyValue("name"), "New labeled extract"); 122 126 } 127 eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate"); 123 128 } 124 129 else … … 129 134 130 135 creationEvent = extract.getCreationEvent(); 136 eventDate = creationEvent.getEventDate(); 131 137 isPooled = extract.isPooled(); 132 138 name = extract.getName(); … … 180 186 final String clazz = "class=\"text\""; 181 187 final String requiredClazz = "class=\"text required\""; 188 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 189 String dateFormat = FormatterSettings.getDateFormat(sc); 190 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 191 String htmlDateFormat = HTML.encodeTags(dateFormat); 182 192 %> 183 193 … … 512 522 </tr> 513 523 <tr> 514 <td class="prompt">Remaining quantity</td>515 <td><%=Values.formatNumber(extract == null ? null : extract.getRemainingQuantity(), 2, " µg")%></td>516 </tr>517 <tr>518 524 <td class="prompt">Created</td> 519 525 <td> … … 522 528 <td> 523 529 <input <%=clazz%> type="text" name="event_date" 524 value="<%= Values.formatDate(creationEvent == null ? Values.getDate(cc.getPropertyValue("creationEvent.eventDate"), new Date()): creationEvent.getEventDate())%>"525 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)">526 (yyyy-mm-dd) 530 value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>" 531 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 532 527 533 </td> 528 534 <td> 529 535 <base:button 530 onclick=" Dates.selectDate('Date', 'extract', 'event_date')"536 onclick="<%="Dates.selectDate('Created', 'labeledextract', 'event_date', null, '"+jsDateFormat+"')"%>" 531 537 image="calendar.png" 532 538 title="Calendar…" … … 540 546 <tr> 541 547 <td class="prompt">Registered</td> 542 <td><%= Values.formatDate(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>548 <td><%=dateFormatter.format(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td> 543 549 </tr> 544 550 <tr> -
trunk/www/biomaterials/labeledextracts/index.jsp
r2917 r2942 49 49 import="net.sf.basedb.util.Values" 50 50 import="net.sf.basedb.clients.web.util.HTML" 51 import="net.sf.basedb.util.formatter.Formatter" 52 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 51 53 import="java.util.Enumeration" 52 54 import="java.util.Set" … … 55 57 import="java.util.ArrayList" 56 58 import="java.util.Collections" 59 import="java.util.Date" 57 60 %> 58 61 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 175 178 176 179 BioMaterialEvent creationEvent = extract.getCreationEvent(); 177 creationEvent.setEventDate(Values.getDate(request.getParameter("event_date"))); 180 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 181 creationEvent.setEventDate(dateFormatter.parseString(request.getParameter("event_date"))); 178 182 int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); 179 183 if (protocolId >= 0) // < 0 = denied or unchanged -
trunk/www/biomaterials/labeledextracts/list_labeledextracts.jsp
r2917 r2942 54 54 import="net.sf.basedb.clients.web.PermissionUtil" 55 55 import="net.sf.basedb.clients.web.util.HTML" 56 import="net.sf.basedb.util.formatter.Formatter" 57 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 56 58 import="net.sf.basedb.util.Values" 57 59 import="java.util.List" 58 60 import="java.util.Map" 61 import="java.util.Date" 59 62 %> 60 63 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 93 96 } 94 97 int numListed = 0; 98 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 95 99 %> 96 100 <base:page title="<%=title==null ? "Labeled extract" : title%>" type="<%=mode.getPageType()%>"> … … 289 293 filterable="true" 290 294 exportable="true" 295 formatter="<%=dateFormatter%>" 291 296 /> 292 297 <tbl:columndef … … 298 303 filterable="true" 299 304 exportable="true" 305 formatter="<%=dateFormatter%>" 300 306 /> 301 307 <tbl:columndef … … 338 344 { 339 345 Enumeration<String, String> annotationEnum = null; 346 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 340 347 if (at.isEnumeration()) 341 348 { … … 344 351 for (Object value : values) 345 352 { 346 String encoded = HTML.encodeTags(value.toString());353 String encoded = formatter.format(value); 347 354 annotationEnum.add(encoded, encoded); 348 355 } … … 359 366 filterable="true" 360 367 exportable="true" 368 formatter="<%=formatter%>" 361 369 /> 362 370 <% … … 560 568 enablePropertyLink="<%=mode.hasPropertyLink()%>" 561 569 /></tbl:cell> 562 <tbl:cell column="eventDate" ><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>563 <tbl:cell column="entryDate" ><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>570 <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" /> 571 <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" /> 564 572 <tbl:cell column="parents"> 565 573 <% … … 632 640 <% 633 641 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 634 for (AnnotationType at : annotationTypes)642 if (as != null) 635 643 { 636 %> 637 <tbl:cell column="<%="at"+at.getId()%>"> 638 <% 639 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 640 %> 641 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 642 </tbl:cell> 643 <% 644 for (AnnotationType at : annotationTypes) 645 { 646 if (as.hasAnnotation(at)) 647 { 648 %> 649 <tbl:cell column="<%="at"+at.getId()%>" 650 ><tbl:cellvalue 651 list="<%=as.getAnnotation(at).getValues()%>" 652 /></tbl:cell> 653 <% 654 } 655 } 644 656 } 645 657 %> -
trunk/www/biomaterials/labeledextracts/view_labeledextract.jsp
r2917 r2942 52 52 import="net.sf.basedb.clients.web.util.HTML" 53 53 import="net.sf.basedb.util.Values" 54 import="net.sf.basedb.util.formatter.Formatter" 55 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 54 56 import="java.util.Date" 55 57 import="java.util.Map" … … 76 78 { 77 79 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 80 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 78 81 79 82 String title = null; … … 255 258 <tr> 256 259 <td class="prompt">Created</td> 257 <td><%= Values.formatDate(creationEvent.getEventDate())%></td>260 <td><%=dateFormatter.format(creationEvent.getEventDate())%></td> 258 261 </tr> 259 262 <tr> 260 263 <td class="prompt">Registered</td> 261 <td><%= Values.formatDate(creationEvent.getEntryDate())%></td>264 <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td> 262 265 </tr> 263 266 <% -
trunk/www/biomaterials/samples/edit_sample.jsp
r2875 r2942 48 48 import="net.sf.basedb.clients.web.util.HTML" 49 49 import="net.sf.basedb.util.Values" 50 import="net.sf.basedb.util.formatter.Formatter" 51 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 50 53 import="java.util.List" 51 54 import="java.util.Set" … … 68 71 Sample sample = null; 69 72 BioMaterialEvent creationEvent = null; 73 Date eventDate = null; 70 74 boolean isPooled = false; 71 75 String name = null; … … 106 110 name = Values.getString(cc.getPropertyValue("name"), "New sample"); 107 111 } 112 eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate"); 108 113 } 109 114 else … … 114 119 115 120 creationEvent = sample.getCreationEvent(); 121 eventDate = creationEvent.getEventDate(); 116 122 isPooled = sample.isPooled(); 117 123 name = sample.getName(); … … 147 153 final String clazz = "class=\"text\""; 148 154 final String requiredClazz = "class=\"text required\""; 155 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 156 String dateFormat = FormatterSettings.getDateFormat(sc); 157 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 158 String htmlDateFormat = HTML.encodeTags(dateFormat); 149 159 %> 150 160 … … 440 450 </tr> 441 451 <tr> 442 <td class="prompt">Remaining quantity</td>443 <td><%=Values.formatNumber(sample == null ? null : sample.getRemainingQuantity(), 2, " µg")%></td>444 </tr>445 <tr>446 452 <td class="prompt">Created</td> 447 453 <td> … … 450 456 <td> 451 457 <input <%=clazz%> type="text" name="event_date" 452 value="<%= Values.formatDate(creationEvent == null ? Values.getDate(cc.getPropertyValue("creationEvent.eventDate"), new Date()): creationEvent.getEventDate())%>"453 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)">454 (yyyy-mm-dd) 458 value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>" 459 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 460 455 461 </td> 456 462 <td> 457 463 <base:button 458 onclick=" Dates.selectDate('Date', 'sample', 'event_date')"464 onclick="<%="Dates.selectDate('Created', 'sample', 'event_date', null, '"+jsDateFormat+"')"%>" 459 465 image="calendar.png" 460 466 title="Calendar…" … … 468 474 <tr> 469 475 <td class="prompt">Registered</td> 470 <td><%= Values.formatDate(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>476 <td><%=dateFormatter.format(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td> 471 477 </tr> 472 478 <tr> -
trunk/www/biomaterials/samples/index.jsp
r2917 r2942 48 48 import="net.sf.basedb.util.Values" 49 49 import="net.sf.basedb.clients.web.util.HTML" 50 import="net.sf.basedb.util.formatter.Formatter" 51 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 50 52 import="java.util.Enumeration" 51 53 import="java.util.Set" … … 54 56 import="java.util.ArrayList" 55 57 import="java.util.Collections" 58 import="java.util.Date" 56 59 %> 57 60 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 161 164 162 165 BioMaterialEvent creationEvent = sample.getCreationEvent(); 163 creationEvent.setEventDate(Values.getDate(request.getParameter("event_date"))); 166 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 167 creationEvent.setEventDate(dateFormatter.parseString(request.getParameter("event_date"))); 164 168 int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); 165 169 if (protocolId >= 0) // < 0 = denied or unchanged -
trunk/www/biomaterials/samples/list_samples.jsp
r2917 r2942 56 56 import="net.sf.basedb.clients.web.util.HTML" 57 57 import="net.sf.basedb.util.Values" 58 import="net.sf.basedb.util.formatter.Formatter" 59 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 58 60 import="java.util.List" 59 61 import="java.util.Map" 62 import="java.util.Date" 60 63 %> 61 64 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 80 83 { 81 84 final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); 82 final ItemQuery<Sample> query = Base.getConfiguredQuery(cc, true, Sample.getQuery(), mode);83 85 final ItemQuery<Extract> extractQuery = Extract.getQuery(); 84 86 extractQuery.include(cc.getInclude()); … … 91 93 try 92 94 { 95 final ItemQuery<Sample> query = Base.getConfiguredQuery(cc, true, Sample.getQuery(), mode); 93 96 samples = query.iterate(dc); 94 97 } … … 98 101 } 99 102 int numListed = 0; 103 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 100 104 %> 101 105 <base:page title="<%=title==null ? "Samples" : title%>" type="<%=mode.getPageType()%>"> … … 282 286 filterable="true" 283 287 exportable="true" 288 formatter="<%=dateFormatter%>" 284 289 /> 285 290 <tbl:columndef … … 291 296 filterable="true" 292 297 exportable="true" 298 formatter="<%=dateFormatter%>" 293 299 /> 294 300 <tbl:columndef … … 331 337 { 332 338 Enumeration<String, String> annotationEnum = null; 339 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 333 340 if (at.isEnumeration()) 334 341 { … … 337 344 for (Object value : values) 338 345 { 339 String encoded = HTML.encodeTags(value.toString());346 String encoded = formatter.format(value); 340 347 annotationEnum.add(encoded, encoded); 341 348 } … … 352 359 filterable="true" 353 360 exportable="true" 361 formatter="<%=formatter%>" 354 362 /> 355 363 <% … … 539 547 enablePropertyLink="<%=mode.hasPropertyLink()%>" 540 548 /></tbl:cell> 541 <tbl:cell column="eventDate" ><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>542 <tbl:cell column="entryDate" ><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>549 <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" /> 550 <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" /> 543 551 <tbl:cell column="parents"> 544 552 <% … … 616 624 <% 617 625 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 618 for (AnnotationType at : annotationTypes)626 if (as != null) 619 627 { 620 %> 621 <tbl:cell column="<%="at"+at.getId()%>"> 622 <% 623 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 624 %> 625 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 626 </tbl:cell> 627 <% 628 for (AnnotationType at : annotationTypes) 629 { 630 if (as.hasAnnotation(at)) 631 { 632 %> 633 <tbl:cell column="<%="at"+at.getId()%>" 634 ><tbl:cellvalue 635 list="<%=as.getAnnotation(at).getValues()%>" 636 /></tbl:cell> 637 <% 638 } 639 } 628 640 } 629 641 %> -
trunk/www/biomaterials/samples/view_sample.jsp
r2917 r2942 51 51 import="net.sf.basedb.clients.web.util.HTML" 52 52 import="net.sf.basedb.util.Values" 53 import="net.sf.basedb.util.formatter.Formatter" 54 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 53 55 import="java.util.Date" 54 56 import="java.util.Map" … … 74 76 try 75 77 { 78 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 76 79 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 77 80 … … 250 253 <tr> 251 254 <td class="prompt">Created</td> 252 <td><%= Values.formatDate(creationEvent.getEventDate())%></td>255 <td><%=dateFormatter.format(creationEvent.getEventDate())%></td> 253 256 </tr> 254 257 <tr> 255 258 <td class="prompt">Registered</td> 256 <td><%= Values.formatDate(creationEvent.getEntryDate())%></td>259 <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td> 257 260 </tr> 258 261 <% -
trunk/www/common/annotations/annotate.jsp
r2885 r2942 50 50 import="net.sf.basedb.clients.web.Base" 51 51 import="net.sf.basedb.clients.web.util.HTML" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 54 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 52 55 import="net.sf.basedb.util.Values" 53 56 import="java.util.ArrayList" … … 74 77 try 75 78 { 79 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 80 String dateFormat = FormatterSettings.getDateFormat(sc); 81 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 82 String htmlDateFormat = HTML.encodeTags(dateFormat); 83 76 84 final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId); 77 85 Protocol protocol = null; … … 128 136 annotationTypes = new TreeSet<AnnotationType>(new NameableComparator(false)); 129 137 annotationTypes.addAll(annotationTypeQuery.list(dc)); 138 if (annotationTypeId != 0) 139 { 140 annotationTypes.add(AnnotationType.getById(dc, annotationTypeId)); 141 } 130 142 if (parameterQuery != null) 131 143 { … … 153 165 for (Object value : values) 154 166 { 155 if (value instanceof Date) value = Values.formatDate((Date)value);167 if (value instanceof Date) value = dateFormatter.format((Date)value); 156 168 %> 157 169 values[values.length] = '<%=HTML.javaScriptEncode(value.toString())%>'; … … 573 585 { 574 586 List<?> values = at.getValues(); 575 %>587 Formatter f = FormatterFactory.getTypeFormatter(sc, at.getValueType()); %> 576 588 <b><%=HTML.encodeTags(at.getName())%></b> (<%=select%>)<br> 577 589 <% … … 595 607 for (Object value : values) 596 608 { 597 String encoded = HTML.encodeTags(value.toString());609 String encoded = f.format(value); 598 610 %> 599 611 <option value="<%=encoded%>"><%=encoded%> … … 620 632 for (Object value : values) 621 633 { 622 if (value instanceof Date) value = Values.formatDate((Date)value); 623 String encoded = HTML.encodeTags(value.toString()); 634 String encoded = f.format(value); 624 635 %> 625 636 <input name="<%=inputName%>" type="<%=checkType%>" … … 725 736 <b><%=HTML.encodeTags(at.getName())%></b> (Date)<br> 726 737 <input <%=clazz%> type="text" name="<%=inputName%>" value="" 727 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)"738 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>" 728 739 onblur="valueOnBlur(this.value)"> 729 740 </td> … … 731 742 <br> 732 743 <base:button 733 onclick="<%="Dates.selectDate('Value', 'annotations', '"+inputName+"', 'setDateCallback' )"%>"744 onclick="<%="Dates.selectDate('Value', 'annotations', '"+inputName+"', 'setDateCallback', '"+jsDateFormat+"')"%>" 734 745 image="calendar.png" 735 746 title="Calendar…" -
trunk/www/common/annotations/inherit.jsp
r2893 r2942 51 51 import="net.sf.basedb.clients.web.util.HTML" 52 52 import="net.sf.basedb.util.Values" 53 import="net.sf.basedb.util.formatter.Formatter" 54 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 53 55 import="java.util.List" 54 56 import="java.util.Set" … … 110 112 111 113 List<Annotation> annotations = as.getAnnotations().list(as.getDbControl()); 114 SessionControl sc = as.getSessionControl(); 112 115 for (Annotation a : annotations) 113 116 { 117 Formatter formatter = FormatterFactory.getTypeFormatter(sc, a.getValueType()); 114 118 boolean inherited = inheritedAnnotations != null && inheritedAnnotations.contains(a); 115 119 AnnotationType at = null; … … 124 128 catch (PermissionDeniedException ex) 125 129 {} 126 String values = HTML.encodeTags(Values.getString(a.getValues(), ", ", true));130 String values = Values.getString(a.getValues(), ", ", true, formatter); 127 131 name = HTML.javaScriptEncode(annotationName + 128 132 " [" + Values.trimString(values, 20)+"]"); -
trunk/www/common/annotations/list_annotations.jsp
r2893 r2942 43 43 import="net.sf.basedb.clients.web.Base" 44 44 import="net.sf.basedb.clients.web.util.HTML" 45 import="net.sf.basedb.util.formatter.Formatter" 46 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 45 47 import="net.sf.basedb.util.Values" 46 48 import="java.util.List" … … 145 147 for (AnnotationType at : annotationTypes) 146 148 { 147 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 149 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 150 List<?> values = as == null || !as.hasAnnotation(at) ? 151 null : as.getAnnotation(at).getValues(); 148 152 %> 149 153 <tbl:row> 150 154 <tbl:cell column="annotation"><%=Base.getLinkedName(ID, at, false, true)%></tbl:cell> 151 <tbl:cell column="values"><%=values == null || values.size() == 0 ? "<i>- no values -</i>" : HTML.encodeTags(Values.getString(values, ", ", true))%>155 <tbl:cell column="values"><%=values == null || values.size() == 0 ? "<i>- no values -</i>" : Values.getString(values, ", ", true, formatter)%> 152 156 <% 153 157 if (writePermission) … … 214 218 for (AnnotationType at : protocolParameters) 215 219 { 216 //String name = HTML.encodeTags(at.getName()); 217 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 220 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 221 List<?> values = as == null || !as.hasAnnotation(at) ? 222 null : as.getAnnotation(at).getValues(); 218 223 %> 219 224 <tbl:row> 220 225 <tbl:cell column="parameter"><%=Base.getLinkedName(ID, at, false, true)%></tbl:cell> 221 226 <tbl:cell column="values"> 222 <%=values == null || values.size() == 0 ? "<i>- no values -</i>" : HTML.encodeTags(Values.getString(values, ", ", true))%>227 <%=values == null || values.size() == 0 ? "<i>- no values -</i>" : Values.getString(values, ", ", true, formatter)%> 223 228 <% 224 229 if (writePermission) … … 292 297 boolean writeInherited = false; 293 298 String icon = "joust/annotation.gif"; 299 Formatter formatter = FormatterFactory.getTypeFormatter(sc, a.getValueType()); 294 300 try 295 301 { … … 316 322 <tbl:cell column="item"><%=Base.getLinkedName(ID, aItem, aItem == null, true)%><%=aItem != null ? " ["+aItem.getType()+"]" : ""%></tbl:cell> 317 323 <tbl:cell column="values"> 318 <%=values == null || values.size() == 0 ? "<i>- no values -</i>" : HTML.encodeTags(Values.getString(values, ", ", true))%> 324 <%=values == null || values.size() == 0 ? 325 "<i>- no values -</i>" : Values.getString(values, ", ", true, formatter)%> 319 326 <% 320 327 if (writeInherited && aItem != null) -
trunk/www/common/calendar.jsp
r2753 r2942 35 35 <%@ page 36 36 import="net.sf.basedb.util.Values" 37 import="net.sf.basedb.clients.web.util.HTML" 37 38 import="java.util.Date" 38 39 %> … … 43 44 String input = request.getParameter("input"); 44 45 String callback = request.getParameter("callback"); 46 String format = Values.getString(request.getParameter("format"), "yyyy-MM-dd"); 45 47 %> 46 48 <base:page type="popup" title="<%=title%>"> … … 60 62 var frm = window.opener.document.forms['<%=form%>']; 61 63 var dateString = frm['<%=input%>'].value; 62 var date = Dates.parseString(dateString );64 var date = Dates.parseString(dateString, '<%=HTML.javaScriptEncode(format)%>'); 63 65 if (date == null) date = new Date(); 64 66 return date; … … 67 69 function setDate(theDate) 68 70 { 71 var formattedDate = Dates.formatDate(theDate, '<%=HTML.javaScriptEncode(format)%>'); 69 72 <% 70 73 if (callback == null) … … 72 75 %> 73 76 var frm = window.opener.document.forms['<%=form%>']; 74 frm['<%=input%>'].value = theDate;77 frm['<%=input%>'].value = formattedDate; 75 78 <% 76 79 } … … 78 81 { 79 82 %> 80 window.opener.<%=callback%>('<%=form%>', '<%=input%>', theDate);83 window.opener.<%=callback%>('<%=form%>', '<%=input%>', formattedDate); 81 84 <% 82 85 } … … 87 90 function setToday() 88 91 { 89 setDate( '<%=Values.formatDate(new Date())%>');92 setDate(new Date()); 90 93 } 91 94 … … 111 114 { 112 115 cell.firstChild.nodeValue = dayOfMonth; 113 cell.theDate = Dates. formatDate(Dates.newDate(year, month, dayOfMonth));116 cell.theDate = Dates.newDate(year, month, dayOfMonth); 114 117 } 115 118 if (year == today.getFullYear() && month == today.getMonth() && dayOfMonth == today.getDate()) -
trunk/www/common/plugin/configure.jsp
r2762 r2942 56 56 import="net.sf.basedb.clients.web.WebException" 57 57 import="net.sf.basedb.clients.web.util.HTML" 58 import="net.sf.basedb.util.formatter.Formatter" 59 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 60 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 58 61 import="net.sf.basedb.util.Values" 59 62 import="java.util.Date" … … 77 80 try 78 81 { 82 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 83 String dateFormat = FormatterSettings.getDateFormat(sc); 84 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 85 String htmlDateFormat = HTML.encodeTags(dateFormat); 86 79 87 dc = sc.newDbControl(); 80 88 PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request"); … … 193 201 else 194 202 { 195 value = Values.formatDate((Date)value);203 value = dateFormatter.format((Date)value); 196 204 } 197 205 } … … 763 771 { 764 772 listValue = Long.toString(((Date)value).getTime()); 765 if (enumeration == null) listText = Values.formatDate((Date)value);773 if (enumeration == null) listText = dateFormatter.format((Date)value); 766 774 } 767 775 else if (value instanceof BasicItem) … … 935 943 <input <%=pType.getNotNull() ? requiredClazz : clazz%> 936 944 type="text" name="<%=inputName%>" value="" 937 size="20" maxlength="20" onkeypress="return Dates.dateOnly(event)"945 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>" 938 946 onblur="valueOnBlur(this.value)"> 939 947 </td> … … 941 949 <br> 942 950 <base:button 943 onclick="<%="Dates.selectDate('Value', 'configure', '"+inputName+"', 'setDateCallback' )"%>"951 onclick="<%="Dates.selectDate('Value', 'configure', '"+inputName+"', 'setDateCallback', '"+jsDateFormat+"')"%>" 944 952 image="calendar.png" 945 953 title="Calendar…" -
trunk/www/common/plugin/index.jsp
r2868 r2942 67 67 import="net.sf.basedb.clients.web.WebException" 68 68 import="net.sf.basedb.util.Values" 69 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 69 70 import="net.sf.basedb.clients.web.util.HTML" 70 71 import="net.sf.basedb.clients.web.util.ServletExportOutputStream" … … 77 78 import="java.util.Set" 78 79 import="java.util.HashSet" 80 import="java.io.PrintWriter" 79 81 %> 80 82 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 341 343 PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request"); 342 344 List<PluginParameter<?>> parameters = pcRequest.getRequestInformation().getParameters(); 345 List<Throwable> parseErrors = new LinkedList<Throwable>(); 343 346 ItemContext currentContext = (ItemContext)sc.getSessionSetting("plugin.configure.currentContext"); 344 347 if (parameters != null && parameters.size() > 0) … … 351 354 String[] sValues = request.getParameterValues("parameter:"+param.getName()); 352 355 Object[] oValues = null; 353 if (sValues != null)356 try 354 357 { 355 if ( pType instanceof StringParameterType)358 if (sValues != null) 356 359 { 357 oValues = sValues; 358 } 359 else if (pType instanceof IntegerParameterType) 360 { 361 oValues = Values.getInt(sValues); 362 } 363 else if (pType instanceof LongParameterType) 364 { 365 oValues = Values.getLong(sValues); 366 // oValues = Type.LONG.parseStrings(sValues); 367 } 368 else if (pType instanceof FloatParameterType) 369 { 370 oValues = Values.getFloat(sValues); 371 // oValues = Type.FLOAT.parseStrings(sValues); 372 } 373 else if (pType instanceof DoubleParameterType) 374 { 375 oValues = Values.getDouble(sValues); 376 // oValues = Type.DOUBLE.parseStrings(sValues); 377 } 378 else if (pType instanceof BooleanParameterType) 379 { 380 oValues = Type.BOOLEAN.parseStrings(sValues); 381 } 382 else if (pType instanceof DateParameterType) 383 { 384 oValues = Values.getDate(sValues); 385 // oValues = Type.DATE.parseStrings(sValues); 386 } 387 else if (pType instanceof ItemParameterType) 388 { 389 Integer[] itemId = Values.getInt(sValues); 390 oValues = new Object[itemId.length]; 391 Item iType = Item.fromItemClass(pType.getParameterClass()); 392 dc = sc.newDbControl(); 393 for (int i = 0; i < itemId.length; ++i) 394 { 395 Integer id = itemId[i]; 396 if (id != null && id != 0) 360 if (pType instanceof StringParameterType) 361 { 362 oValues = sValues; 363 } 364 else if (pType instanceof IntegerParameterType) 365 { 366 oValues = Values.getInt(sValues); 367 } 368 else if (pType instanceof LongParameterType) 369 { 370 oValues = Values.getLong(sValues); 371 } 372 else if (pType instanceof FloatParameterType) 373 { 374 oValues = Values.getFloat(sValues); 375 } 376 else if (pType instanceof DoubleParameterType) 377 { 378 oValues = Values.getDouble(sValues); 379 } 380 else if (pType instanceof BooleanParameterType) 381 { 382 oValues = Type.BOOLEAN.parseStrings(sValues); 383 } 384 else if (pType instanceof DateParameterType) 385 { 386 oValues = Values.getDate(sValues, FormatterFactory.getDateFormatter(sc)); 387 } 388 else if (pType instanceof ItemParameterType) 389 { 390 Integer[] itemId = Values.getInt(sValues); 391 oValues = new Object[itemId.length]; 392 Item iType = Item.fromItemClass(pType.getParameterClass()); 393 dc = sc.newDbControl(); 394 for (int i = 0; i < itemId.length; ++i) 397 395 { 398 BasicItem item = iType.getById(dc, id); 399 oValues[i] = item; 396 Integer id = itemId[i]; 397 if (id != null && id != 0) 398 { 399 BasicItem item = iType.getById(dc, id); 400 oValues[i] = item; 401 if (currentContext != null) 402 { 403 currentContext.setRecent(item, maxRecent); 404 } 405 } 406 } 407 dc.close(); 408 } 409 else if (pType instanceof FileParameterType) 410 { 411 oValues = new Object[sValues.length]; 412 dc = sc.newDbControl(); 413 for (int i = 0; i < sValues.length; ++i) 414 { 415 File file = File.getByPath(dc, new Path(sValues[i], Path.Type.FILE), false); 416 oValues[i] = file; 400 417 if (currentContext != null) 401 418 { 402 currentContext.setRecent( item, maxRecent);419 currentContext.setRecent(file, maxRecent); 403 420 } 404 421 } 405 } 406 dc.close(); 407 } 408 else if (pType instanceof FileParameterType) 409 { 410 oValues = new Object[sValues.length]; 411 dc = sc.newDbControl(); 412 for (int i = 0; i < sValues.length; ++i) 413 { 414 File file = File.getByPath(dc, new Path(sValues[i], Path.Type.FILE), false); 415 oValues[i] = file; 416 if (currentContext != null) 417 { 418 currentContext.setRecent(file, maxRecent); 419 } 420 } 421 dc.close(); 422 } 423 else if (pType instanceof PathParameterType) 424 { 425 oValues = sValues; 422 dc.close(); 423 } 424 else if (pType instanceof PathParameterType) 425 { 426 oValues = sValues; 427 } 426 428 } 427 429 } 430 catch (Throwable t) 431 { 432 parseErrors.add(t); 433 } 428 434 pcRequest.setParameterValues(param.getName(), oValues == null ? null : Arrays.asList(oValues)); 429 435 } 430 436 } 431 437 } 432 PluginResponse pluginResponse = pcRequest.invoke(); 433 Response.Status status = pluginResponse.getStatus(); 438 PluginResponse pluginResponse = null; 439 Response.Status status = null; 440 if (parseErrors.size() == 0) 441 { 442 pluginResponse = pcRequest.invoke(); 443 status = pluginResponse.getStatus(); 444 } 445 else 446 { 447 status = Response.Status.ERROR; 448 } 434 449 if (status == Response.Status.DONE || status == Response.Status.EXECUTE_IMMEDIATELY) 435 450 { … … 464 479 { 465 480 PluginDefinition plugin = (PluginDefinition)sc.getSessionSetting("plugin.configure.plugin"); 466 sc.setSessionSetting("plugin.configure.errors.message", pluginResponse.getMessage()); 467 sc.setSessionSetting("plugin.configure.errors.list", pluginResponse.getErrorList()); 481 if (parseErrors.size() > 0) 482 { 483 sc.setSessionSetting("plugin.configure.errors.message", 484 parseErrors.size() + " parameter value(s) are invalid"); 485 sc.setSessionSetting("plugin.configure.errors.list", parseErrors); 486 } 487 else 488 { 489 sc.setSessionSetting("plugin.configure.errors.message", pluginResponse.getMessage()); 490 sc.setSessionSetting("plugin.configure.errors.list", pluginResponse.getErrorList()); 491 } 468 492 forward = getJspPage(pcRequest, plugin, "configure.jsp"); 469 493 } … … 511 535 PluginResponse pluginResponse = (PluginResponse)sc.getSessionSetting("plugin.configure.response"); 512 536 ExportOutputStream exportStream = new ServletExportOutputStream(response); 513 pluginResponse.downloadImmediately(exportStream, null); 537 try 538 { 539 pluginResponse.downloadImmediately(exportStream, null); 540 } 541 catch (Throwable t) 542 { 543 PrintWriter pw = new PrintWriter(exportStream, true); 544 t.printStackTrace(pw); 545 pw.flush(); 546 pw.close(); 547 System.out.println("EXCEPTION:" + t.toString()); 548 } 514 549 exportStream.flush(); 515 550 exportStream.close(); -
trunk/www/include/scripts/main.js
r2939 r2942 523 523 var Dates = new DateClass(); 524 524 // Functions related to handling date values 525 // Implementation based on code provided by: 526 // =================================================================== 527 // Author: Matt Kruse <matt@mattkruse.com> 528 // WWW: http://www.mattkruse.com/ 529 // 530 // NOTICE: You may use this code for any purpose, commercial or 531 // private, without any further permission from the author. You may 532 // remove this notice from your final code if you wish, however it is 533 // appreciated by the author if at least my web site address is kept. 534 // 535 // You may *NOT* re-distribute this code in any way except through its 536 // use. That means, you can include it in your product, or your web 537 // site, or any other form where the code is actually being used. You 538 // may not put the plain javascript up on your site for download or 539 // include it in your javascript libraries for download. 540 // If you wish to share this code with others, please just point them 541 // to the URL instead. 542 // Please DO NOT link directly to my .js files from your site. Copy 543 // the files to your server and use them there. Thank you. 544 // =================================================================== 545 // HISTORY 546 // ------------------------------------------------------------------ 547 // May 17, 2003: Fixed bug in parseDate() for dates <1970 548 // March 11, 2003: Added parseDate() function 549 // March 11, 2003: Added "NNN" formatting option. Doesn't match up 550 // perfectly with SimpleDateFormat formats, but 551 // backwards-compatability was required. 552 553 // ------------------------------------------------------------------ 554 // These functions use the same 'format' strings as the 555 // java.text.SimpleDateFormat class, with minor exceptions. 556 // The format string consists of the following abbreviations: 557 // 558 // Field | Full Form | Short Form 559 // -------------+--------------------+----------------------- 560 // Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits) 561 // Month | MMMM(name or abbr.)| MM (2 digits), M (1 or 2 digits) 562 // | NNN (abbr.) | 563 // Day of Month | dd (2 digits) | d (1 or 2 digits) 564 // Day of Week | EE (name) | E (abbr) 565 // Hour (1-12) | hh (2 digits) | h (1 or 2 digits) 566 // Hour (0-23) | HH (2 digits) | H (1 or 2 digits) 567 // Hour (0-11) | KK (2 digits) | K (1 or 2 digits) 568 // Hour (1-24) | kk (2 digits) | k (1 or 2 digits) 569 // Minute | mm (2 digits) | m (1 or 2 digits) 570 // Second | ss (2 digits) | s (1 or 2 digits) 571 // AM/PM | a | 572 // 573 // NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm! 574 // Examples: 575 // "MMM d, y" matches: January 01, 2000 576 // Dec 1, 1900 577 // Nov 20, 00 578 // "M/d/yy" matches: 01/20/00 579 // 9/2/00 580 // "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM" 581 // ------------------------------------------------------------------ 525 582 function DateClass() 526 583 { 527 528 // formats a date as a string: yyyy-mm-dd 529 this.formatDate = function(date) 530 { 531 var year = this.getFourDigitYear(date.getFullYear()); 532 var month = date.getMonth()+1; 533 month = month < 10 ? '0'+month : month; 534 var day = date.getDate(); 535 day = day < 10 ? '0'+day : day; 536 return year+'-'+month+'-'+day; 584 this.MONTH_NAMES = new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 585 this.DAY_NAMES = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat'); 586 587 // convert a date to a string: 588 // default format is yyyy-MM-dd 589 this.formatDate = function(date, format) 590 { 591 if (!format) format = "yyyy-MM-dd"; 592 var result=""; 593 var i_format=0; 594 var c=""; 595 var token=""; 596 var y=date.getYear()+""; 597 var M=date.getMonth()+1; 598 var d=date.getDate(); 599 var E=date.getDay(); 600 var H=date.getHours(); 601 var m=date.getMinutes(); 602 var s=date.getSeconds(); 603 var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k; 604 605 // Convert real date parts into formatted versions 606 var value=new Object(); 607 if (y.length < 4) 608 { 609 y=""+(y-0+1900); 610 } 611 value["y"]=""+y; 612 value["yyyy"]=y; 613 value["yy"]=y.substring(2,4); 614 value["M"]=M; 615 value["MM"]=LZ(M); 616 value["MMM"]=this.MONTH_NAMES[M+11]; 617 value["MMMM"]=this.MONTH_NAMES[M-1]; 618 value["NNN"]=this.MONTH_NAMES[M+11]; 619 value["d"]=d; 620 value["dd"]=LZ(d); 621 value["E"]=this.DAY_NAMES[E+7]; 622 value["EE"]=this.DAY_NAMES[E]; 623 value["H"]=H; 624 value["HH"]=LZ(H); 625 if (H==0) 626 { 627 value["h"]=12; 628 } 629 else if (H>12) 630 { 631 value["h"]=H-12; 632 } 633 else 634 { 635 value["h"]=H; 636 } 637 value["hh"]=LZ(value["h"]); 638 if (H>11) 639 { 640 value["K"]=H-12; 641 } 642 else 643 { 644 value["K"]=H; 645 } 646 value["k"]=H+1; 647 value["KK"]=LZ(value["K"]); 648 value["kk"]=LZ(value["k"]); 649 if (H > 11) 650 { 651 value["a"]="PM"; 652 } 653 else 654 { 655 value["a"]="AM"; 656 } 657 value["m"]=m; 658 value["mm"]=LZ(m); 659 value["s"]=s; 660 value["ss"]=LZ(s); 661 while (i_format < format.length) 662 { 663 c=format.charAt(i_format); 664 token=""; 665 while ((format.charAt(i_format)==c) && (i_format < format.length)) 666 { 667 token += format.charAt(i_format++); 668 } 669 if (value[token] != null) 670 { 671 result=result + value[token]; 672 } 673 else 674 { 675 result=result + token; 676 } 677 } 678 return result; 537 679 } 538 680 … … 593 735 } 594 736 595 // checks if the supplied string is a date in the format: yyyy-mm-dd 596 this.isDate = function(date) 597 { 598 if (date.search(/^\d{4}\-\d{2}\-\d{2}$/) == -1) return false; 599 var parts = date.split('-'); 600 var year = Number(parts[0]); 601 var month = Number(parts[1]); 602 var day = Number(parts[2]); 603 return (month >= 1 && month <= 12 && day >= 1 && day <= this.daysInMonth(year, month)); 604 } 605 606 /* 607 Parses a string expected to hold a date in the format: yyyy-mm-dd 608 Returns null if the string is not a valid date. 609 */ 610 this.parseString = function(date) 611 { 612 if (date.search(/^\d{4}\-\d{2}\-\d{2}$/) == -1) return null; 613 var parts = date.split('-'); 614 var year = Number(parts[0]); 615 var month = Number(parts[1]); 616 var day = Number(parts[2]); 617 var result = new Date(); 618 result.setFullYear(year, month-1, day); 619 return result; 620 return new Date(year, month-1, day); 621 } 622 737 // ------------------------------------------------------------------ 738 // isDate ( date_string, format_string ) 739 // Returns true if date string matches format of format string and 740 // is a valid date. Else returns false. 741 // It is recommended that you trim whitespace around the value before 742 // passing it to this function, as whitespace is NOT ignored! 743 // ------------------------------------------------------------------ 744 this.isDate = function(val, format) 745 { 746 return this.parseString(val, format) != null; 747 } 748 749 // ------------------------------------------------------------------ 750 // parseString( date_string , format_string ) 751 // 752 // This function takes a date string and a format string. It matches 753 // If the date string matches the format string, it returns the 754 // the date object. If it does not match, it returns null. 755 // ------------------------------------------------------------------ 756 this.parseString = function(val, format) 757 { 758 if (!format) format = 'yyyy-MM-dd'; 759 var i_val=0; 760 var i_format=0; 761 var c=""; 762 var token=""; 763 var token2=""; 764 var x,y; 765 var now=new Date(); 766 var year=now.getYear(); 767 var month=now.getMonth()+1; 768 var date=1; 769 var hh=now.getHours(); 770 var mm=now.getMinutes(); 771 var ss=now.getSeconds(); 772 var ampm=""; 773 774 while (i_format < format.length) 775 { 776 // Get next token from format string 777 c=format.charAt(i_format); 778 token=""; 779 while ((format.charAt(i_format)==c) && (i_format < format.length)) 780 { 781 token += format.charAt(i_format++); 782 } 783 // Extract contents of value based on format token 784 if (token=="yyyy" || token=="yy" || token=="y") 785 { 786 if (token=="yyyy") { x=4;y=4; } 787 if (token=="yy") { x=2;y=2; } 788 if (token=="y") { x=2;y=4; } 789 year=_getInt(val,i_val,x,y); 790 if (year==null) { return null; } 791 i_val += year.length; 792 if (year.length==2) 793 { 794 if (year > 70) 795 { 796 year=1900+(year-0); 797 } 798 else 799 { 800 year=2000+(year-0); 801 } 802 } 803 } 804 else if (token=='MMMM' || token=="MMM" || token=="NNN") 805 { 806 month=0; 807 for (var i=0; i<this.MONTH_NAMES.length; i++) 808 { 809 var month_name=this.MONTH_NAMES[i]; 810 if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) 811 { 812 month=i+1; 813 if (month>12) { month -= 12; } 814 i_val += month_name.length; 815 break; 816 } 817 } 818 if ((month < 1)||(month>12)) { return null; } 819 } 820 else if (token=="EE"||token=="E") 821 { 822 for (var i=0; i<this.DAY_NAMES.length; i++) 823 { 824 var day_name=this.DAY_NAMES[i]; 825 if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) 826 { 827 i_val += day_name.length; 828 break; 829 } 830 } 831 } 832 else if (token=="MM"||token=="M") 833 { 834 month=_getInt(val,i_val,token.length,2); 835 if(month==null||(month<1)||(month>12)){return null;} 836 i_val+=month.length; 837 } 838 else if (token=="dd"||token=="d") 839 { 840 date=_getInt(val,i_val,token.length,2); 841 if(date==null||(date<1)||(date>31)){return null;} 842 i_val+=date.length; 843 } 844 else if (token=="hh"||token=="h") 845 { 846 hh=_getInt(val,i_val,token.length,2); 847 if(hh==null||(hh<1)||(hh>12)){return null;} 848 i_val+=hh.length; 849 } 850 else if (token=="HH"||token=="H") 851 { 852 hh=_getInt(val,i_val,token.length,2); 853 if(hh==null||(hh<0)||(hh>23)){return null;} 854 i_val+=hh.length; 855 } 856 else if (token=="KK"||token=="K") 857 { 858 hh=_getInt(val,i_val,token.length,2); 859 if(hh==null||(hh<0)||(hh>11)){return null;} 860 i_val+=hh.length; 861 } 862 else if (token=="kk"||token=="k") 863 { 864 hh=_getInt(val,i_val,token.length,2); 865 if(hh==null||(hh<1)||(hh>24)){return null;} 866 i_val+=hh.length;hh--; 867 } 868 else if (token=="mm"||token=="m") 869 { 870 mm=_getInt(val,i_val,token.length,2); 871 if(mm==null||(mm<0)||(mm>59)){return null;} 872 i_val+=mm.length; 873 } 874 else if (token=="ss"||token=="s") 875 { 876 ss=_getInt(val,i_val,token.length,2); 877 if(ss==null||(ss<0)||(ss>59)){return null;} 878 i_val+=ss.length; 879 } 880 else if (token=="a") 881 { 882 if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";} 883 else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";} 884 else {return null;} 885 i_val+=2; 886 } 887 else 888 { 889 if (val.substring(i_val,i_val+token.length)!=token) {return null;} 890 else {i_val+=token.length;} 891 } 892 } 893 894 // If there are any trailing characters left in the value, it doesn't match 895 if (i_val != val.length) { return null; } 896 897 // Is date valid for month? 898 if (month==2) 899 { 900 // Check for leap year 901 if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) 902 { // leap year 903 if (date > 29){ return null; } 904 } 905 else 906 { 907 if (date > 28) { return null; } 908 } 909 } 910 if ((month==4)||(month==6)||(month==9)||(month==11)) 911 { 912 if (date > 30) { return null; } 913 } 914 915 // Correct hours value 916 if (hh<12 && ampm=="PM") 917 { 918 hh=hh-0+12; 919 } 920 else if (hh>11 && ampm=="AM") 921 { 922 hh-=12; 923 } 924 return new Date(year,month-1,date,hh,mm,ss); 925 } 926 927 function _isInteger(val) { 928 var digits="1234567890"; 929 for (var i=0; i < val.length; i++) { 930 if (digits.indexOf(val.charAt(i))==-1) { return false; } 931 } 932 return true; 933 } 934 function _getInt(str,i,minlength,maxlength) { 935 for (var x=maxlength; x>=minlength; x--) { 936 var token=str.substring(i,i+x); 937 if (token.length < minlength) { return null; } 938 if (_isInteger(token)) { return token; } 939 } 940 return null; 941 } 942 function LZ(x) {return(x<0||x>9?"":"0")+x} 943 623 944 /* 624 945 Calculate the number of days in the specified month … … 677 998 of by setting the form field 678 999 */ 679 this.selectDate = function(title, form, input, callback )680 { 681 var url = getRoot()+'common/calendar.jsp?title='+escape(title)+'&form='+form+'&input='+input ;1000 this.selectDate = function(title, form, input, callback, format) 1001 { 1002 var url = getRoot()+'common/calendar.jsp?title='+escape(title)+'&form='+form+'&input='+input+'&format='+escape(format); 682 1003 url += '&ID='+Main.getIdFromLocation(); 683 1004 if (callback) url += '&callback='+callback; -
trunk/www/info/news.jsp
r2753 r2942 40 40 import="net.sf.basedb.clients.web.util.HTML" 41 41 import="net.sf.basedb.util.Values" 42 import="net.sf.basedb.util.formatter.Formatter" 43 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 44 import="java.util.Date" 42 45 %> 43 46 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 50 53 try 51 54 { 55 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 52 56 %> 53 57 <base:page type="default" title=""> … … 71 75 %> 72 76 <div class="item"> 73 <span class="date"><%= Values.formatDate(n.getNewsDate())%></span>77 <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span> 74 78 <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br> 75 79 <span class="text"><%=Values.getString(n.getDescription())%></span> -
trunk/www/lims/arraybatches/list_batches.jsp
r2919 r2942 52 52 import="net.sf.basedb.clients.web.PermissionUtil" 53 53 import="net.sf.basedb.clients.web.util.HTML" 54 import="net.sf.basedb.util.formatter.Formatter" 55 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 54 56 import="net.sf.basedb.util.Values" 55 57 import="java.util.List" … … 286 288 for (AnnotationType at : annotationTypes) 287 289 { 290 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 288 291 Enumeration<String, String> annotationEnum = null; 289 292 if (at.isEnumeration()) … … 293 296 for (Object value : values) 294 297 { 295 String encoded = HTML.encodeTags(value.toString());298 String encoded = formatter.format(value); 296 299 annotationEnum.add(encoded, encoded); 297 300 } … … 308 311 filterable="true" 309 312 exportable="true" 313 formatter="<%=formatter%>" 310 314 /> 311 315 <% … … 536 540 <% 537 541 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 538 for (AnnotationType at : annotationTypes)542 if (as != null) 539 543 { 540 %> 541 <tbl:cell column="<%="at"+at.getId()%>"> 542 <% 543 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 544 %> 545 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 546 </tbl:cell> 547 <% 544 for (AnnotationType at : annotationTypes) 545 { 546 if (as.hasAnnotation(at)) 547 { 548 %> 549 <tbl:cell column="<%="at"+at.getId()%>" 550 ><tbl:cellvalue 551 list="<%=as.getAnnotation(at).getValues()%>" 552 /></tbl:cell> 553 <% 554 } 555 } 548 556 } 549 557 %> -
trunk/www/lims/arraydesigns/features/list_features.jsp
r2753 r2942 58 58 import="net.sf.basedb.clients.web.util.HTML" 59 59 import="net.sf.basedb.util.Values" 60 import="net.sf.basedb.util.formatter.Formatter" 61 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 60 62 import="java.util.List" 61 63 import="java.util.Map" … … 85 87 final ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId); 86 88 final boolean isAffy = design.isAffyChip(); 89 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 87 90 88 91 final DataQuery<FeatureData> query = design.getFeatures(); … … 351 354 filterable="true" 352 355 exportable="true" 356 formatter="<%=dateFormatter%>" 353 357 /> 354 358 <% … … 387 391 filterable="true" 388 392 exportable="true" 393 formatter="<%=FormatterFactory.getExtendedPropertyFormatter(sc, ep)%>" 389 394 /> 390 395 <% … … 575 580 <tbl:cell column="reporter.symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell> 576 581 <tbl:cell column="reporter.description"><%=HTML.encodeTags(reporter.getDescription())%></tbl:cell> 577 <tbl:cell column="reporter.lastUpdate" ><%=Values.formatDate(reporter.getLastUpdate())%></tbl:cell>582 <tbl:cell column="reporter.lastUpdate" value="<%=reporter.getLastUpdate()%>" /> 578 583 <tbl:cell column="reporter.reporterType" 579 584 ><base:propertyvalue … … 590 595 { 591 596 String name = ep.getName(); 592 Object value = reporter.getExtended(name);593 String link = ep.getUrl(value);594 if (value instanceof Date) value = Values.formatDate((Date)value);595 value = HTML.encodeTags(value == null ? "" : value.toString());596 if (link != null)597 {598 value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>";599 }600 597 %> 601 <tbl:cell column="<%="reporter."+name%>">< %=value%></tbl:cell>598 <tbl:cell column="<%="reporter."+name%>"><tbl:cellvalue value="<%=reporter.getExtended(name)%>" /></tbl:cell> 602 599 <% 603 600 } -
trunk/www/lims/arraydesigns/features/view_feature.jsp
r2753 r2942 50 50 import="net.sf.basedb.clients.web.util.HTML" 51 51 import="net.sf.basedb.util.Values" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 54 import="java.util.Date" 53 55 import="java.util.Map" … … 72 74 try 73 75 { 76 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 74 77 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 75 78 … … 244 247 <tr> 245 248 <td class="prompt">Last update</td> 246 <td><%= Values.formatDate(reporter.getLastUpdate())%></td>249 <td><%=dateFormatter.format(reporter.getLastUpdate())%></td> 247 250 </tr> 248 251 </table> … … 259 262 { 260 263 String name = ep.getName(); 261 Object value = reporter.getExtended(name); 262 String link = ep.getUrl(value); 263 if (value instanceof Date) value = Values.formatDate((Date)value); 264 value = HTML.encodeTags(value == null ? "" : value.toString()); 265 if (link != null) 266 { 267 value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>"; 268 } 264 Formatter f = FormatterFactory.getExtendedPropertyFormatter(sc, ep); 265 String value = f.format(reporter.getExtended(name)); 269 266 %> 270 267 <%=needsTr ? "<tr valign=\"top\">" : "" %> -
trunk/www/lims/arraydesigns/list_designs.jsp
r2919 r2942 56 56 import="net.sf.basedb.clients.web.util.HTML" 57 57 import="net.sf.basedb.util.Values" 58 import="net.sf.basedb.util.formatter.Formatter" 59 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 58 60 import="java.util.List" 59 61 import="java.util.Map" … … 282 284 for (AnnotationType at : annotationTypes) 283 285 { 286 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 284 287 Enumeration<String, String> annotationEnum = null; 285 288 if (at.isEnumeration()) … … 289 292 for (Object value : values) 290 293 { 291 String encoded = HTML.encodeTags(value.toString());294 String encoded = formatter.format(value); 292 295 annotationEnum.add(encoded, encoded); 293 296 } … … 304 307 filterable="true" 305 308 exportable="true" 309 formatter="<%=formatter%>" 306 310 /> 307 311 <% … … 538 542 <% 539 543 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 540 for (AnnotationType at : annotationTypes)544 if (as != null) 541 545 { 542 %> 543 <tbl:cell column="<%="at"+at.getId()%>"> 544 <% 545 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 546 %> 547 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 548 </tbl:cell> 549 <% 546 for (AnnotationType at : annotationTypes) 547 { 548 if (as.hasAnnotation(at)) 549 { 550 %> 551 <tbl:cell column="<%="at"+at.getId()%>" 552 ><tbl:cellvalue 553 list="<%=as.getAnnotation(at).getValues()%>" 554 /></tbl:cell> 555 <% 556 } 557 } 550 558 } 551 559 %> -
trunk/www/lims/arrayslides/list_slides.jsp
r2919 r2942 51 51 import="net.sf.basedb.clients.web.util.HTML" 52 52 import="net.sf.basedb.util.Values" 53 import="net.sf.basedb.util.formatter.Formatter" 54 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 53 55 import="java.util.List" 54 56 import="java.util.Map" … … 296 298 for (AnnotationType at : annotationTypes) 297 299 { 300 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 298 301 Enumeration<String, String> annotationEnum = null; 299 302 if (at.isEnumeration()) … … 303 306 for (Object value : values) 304 307 { 305 String encoded = HTML.encodeTags(value.toString());308 String encoded = formatter.format(value); 306 309 annotationEnum.add(encoded, encoded); 307 310 } … … 318 321 filterable="true" 319 322 exportable="true" 323 formatter="<%=formatter%>" 320 324 /> 321 325 <% … … 526 530 <% 527 531 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 528 for (AnnotationType at : annotationTypes)532 if (as != null) 529 533 { 530 %> 531 <tbl:cell column="<%="at"+at.getId()%>"> 532 <% 533 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 534 %> 535 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 536 </tbl:cell> 537 <% 534 for (AnnotationType at : annotationTypes) 535 { 536 if (as.hasAnnotation(at)) 537 { 538 %> 539 <tbl:cell column="<%="at"+at.getId()%>" 540 ><tbl:cellvalue 541 list="<%=as.getAnnotation(at).getValues()%>" 542 /></tbl:cell> 543 <% 544 } 545 } 538 546 } 539 547 %> -
trunk/www/lims/plates/events/edit_event.jsp
r2753 r2942 54 54 import="net.sf.basedb.clients.web.util.HTML" 55 55 import="net.sf.basedb.util.Values" 56 import="net.sf.basedb.util.formatter.Formatter" 57 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 58 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 56 59 import="java.util.List" 57 60 import="java.util.Set" … … 76 79 Plate plate = null; 77 80 PlateEventType eventType = null; 81 Date eventDate = null; 78 82 79 83 Protocol currentProtocol = null; … … 111 115 currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("protocol.name")); 112 116 } 117 118 eventDate = (Date)cc.getPropertyObject("eventDate"); 113 119 } 114 120 else … … 116 122 event = PlateEvent.getById(dc, itemId); 117 123 eventType = event.getPlateEventType(); 124 eventDate = event.getEventDate(); 118 125 cc.setObject("item", event); 119 126 title = "Edit event -- " + HTML.encodeTags(eventType.getName()); … … 150 157 final String clazz = "class=\"text\""; 151 158 final String requiredClazz = "class=\"text required\""; 159 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 160 String dateFormat = FormatterSettings.getDateFormat(sc); 161 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 162 String htmlDateFormat = HTML.encodeTags(dateFormat); 152 163 %> 153 164 … … 309 320 <td> 310 321 <input <%=clazz%> type="text" name="event_date" 311 value="<%= Values.formatDate(event == null ? Values.getDate(cc.getPropertyValue("eventDate"), new Date()) : event.getEventDate())%>"312 size=" 12" maxlength="10" onkeypress="return Dates.dateOnly(event)">313 (yyyy-mm-dd) 322 value="<%=dateFormatter.format(eventDate == null ? new Date() : eventDate)%>" 323 size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> 324 314 325 </td> 315 326 <td> 316 327 <base:button 317 onclick=" Dates.selectDate('Date', 'event', 'event_date')"328 onclick="<%="Dates.selectDate('Date', 'event', 'event_date', null, '"+jsDateFormat+"')"%>" 318 329 image="calendar.png" 319 330 title="Calendar…" … … 327 338 <tr> 328 339 <td class="prompt">Entry date</td> 329 <td><%= Values.formatDate(event == null ? new Date() : event.getEntryDate())%></td>340 <td><%=dateFormatter.format(event == null ? new Date() : event.getEntryDate())%></td> 330 341 </tr> 331 342 <tr> -
trunk/www/lims/plates/events/index.jsp
r2811 r2942 42 42 import="net.sf.basedb.clients.web.WebException" 43 43 import="net.sf.basedb.clients.web.util.HTML" 44 import="net.sf.basedb.util.formatter.Formatter" 45 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 44 46 import="net.sf.basedb.util.Values" 45 47 import="java.util.List" 46 48 import="java.util.Collections" 49 import="java.util.Date" 47 50 %> 48 51 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 140 143 message = "Event updated"; 141 144 } 145 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 142 146 event.setComment(Values.getStringOrNull(request.getParameter("comment"))); 143 event.setEventDate( Values.getDate(request.getParameter("event_date")));147 event.setEventDate(dateFormatter.parseString(request.getParameter("event_date"))); 144 148 int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); 145 149 if (protocolId >= 0) // < 0 = denied or unchanged -
trunk/www/lims/plates/events/list_events.jsp
r2753 r2942 49 49 import="net.sf.basedb.clients.web.util.HTML" 50 50 import="net.sf.basedb.util.Values" 51 import="net.sf.basedb.util.formatter.Formatter" 52 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 51 53 import="java.util.List" 52 54 import="java.util.Map" 55 import="java.util.Date" 53 56 %> 54 57 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 77 80 final boolean deletePermission = createPermission; 78 81 79 final ItemQuery<PlateEvent> query = Base.getConfiguredQuery(cc, true, plate.getEvents(), mode);82 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 80 83 81 84 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 82 85 try 83 86 { 87 final ItemQuery<PlateEvent> query = Base.getConfiguredQuery(cc, true, plate.getEvents(), mode); 84 88 events = query.iterate(dc); 85 89 } … … 98 102 { 99 103 Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true, '&plate_id=<%=plateId%>'); 100 // Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&plate_id=<%=plateId%>', 'NewEvent', 600, 380);101 104 } 102 105 function editItem(itemId) 103 106 { 104 107 Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true); 105 // Main.openPopup('index.jsp?ID=<%=ID%>&cmd=EditItem&plate_id=<%=plateId%>&item_id='+itemId, 'EditEvent', 600, 380);106 108 } 107 109 function viewItem(itemId) 108 110 { 109 111 Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false); 110 // location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&plate_id=<%=plateId%>&item_id='+itemId;111 112 } 112 113 function itemOnClick(evt, itemId) … … 244 245 filterable="true" 245 246 exportable="true" 247 formatter="<%=dateFormatter%>" 246 248 /> 247 249 <tbl:columndef … … 253 255 filterable="true" 254 256 exportable="true" 257 formatter="<%=dateFormatter%>" 255 258 /> 256 259 <tbl:columndef … … 437 440 enablePropertyLink="<%=mode.hasPropertyLink()%>" 438 441 /></tbl:cell> 439 <tbl:cell column="entryDate" ><%=Values.formatDate(item.getEntryDate())%></tbl:cell>440 <tbl:cell column="eventDate" ><%=Values.formatDate(item.getEventDate())%></tbl:cell>442 <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" /> 443 <tbl:cell column="eventDate" value="<%=item.getEventDate()%>" /> 441 444 <tbl:cell column="comment"><%=HTML.encodeTags(item.getComment())%></tbl:cell> 442 445 <tbl:cell column="user" -
trunk/www/lims/plates/events/view_event.jsp
r2753 r2942 44 44 import="net.sf.basedb.clients.web.util.HTML" 45 45 import="net.sf.basedb.util.Values" 46 import="net.sf.basedb.util.formatter.Formatter" 47 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 46 48 import="java.util.Date" 47 49 import="java.util.Map" … … 66 68 { 67 69 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 70 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 68 71 69 72 String title = null; … … 174 177 <tr> 175 178 <td class="prompt">Event date</td> 176 <td><%= Values.formatDate(event.getEventDate())%></td>179 <td><%=dateFormatter.format(event.getEventDate())%></td> 177 180 </tr> 178 181 <tr> 179 182 <td class="prompt">Registration date</td> 180 <td><%= Values.formatDate(event.getEntryDate())%></td>183 <td><%=dateFormatter.format(event.getEntryDate())%></td> 181 184 </tr> 182 185 <tr> -
trunk/www/lims/plates/list_plates.jsp
r2919 r2942 53 53 import="net.sf.basedb.clients.web.PermissionUtil" 54 54 import="net.sf.basedb.clients.web.util.HTML" 55 import="net.sf.basedb.util.formatter.Formatter" 56 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 55 57 import="net.sf.basedb.util.Values" 56 58 import="java.util.List" … … 327 329 for (AnnotationType at : annotationTypes) 328 330 { 331 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 329 332 Enumeration<String, String> annotationEnum = null; 330 333 if (at.isEnumeration()) … … 334 337 for (Object value : values) 335 338 { 336 String encoded = HTML.encodeTags(value.toString());339 String encoded = formatter.format(value); 337 340 annotationEnum.add(encoded, encoded); 338 341 } … … 349 352 filterable="true" 350 353 exportable="true" 354 formatter="<%=formatter%>" 351 355 /> 352 356 <% … … 605 609 <% 606 610 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 607 for (AnnotationType at : annotationTypes)611 if (as != null) 608 612 { 609 %> 610 <tbl:cell column="<%="at"+at.getId()%>"> 611 <% 612 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 613 %> 614 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 615 </tbl:cell> 616 <% 613 for (AnnotationType at : annotationTypes) 614 { 615 if (as.hasAnnotation(at)) 616 { 617 %> 618 <tbl:cell column="<%="at"+at.getId()%>" 619 ><tbl:cellvalue 620 list="<%=as.getAnnotation(at).getValues()%>" 621 /></tbl:cell> 622 <% 623 } 624 } 617 625 } 618 626 %> -
trunk/www/lims/plates/wells/list_wells.jsp
r2893 r2942 57 57 import="net.sf.basedb.clients.web.util.HTML" 58 58 import="net.sf.basedb.util.Values" 59 import="net.sf.basedb.util.formatter.Formatter" 60 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 59 61 import="java.util.List" 60 62 import="java.util.Map" … … 89 91 final boolean deletePermission = createPermission; 90 92 91 final ItemQuery<Well> query = Base.getConfiguredQuery(cc, true, plate.getWells(), mode);92 if (!"row".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("row")));93 if (!"column".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("column")));94 95 93 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 96 94 final ItemQuery<ReporterType> typeQuery = ReporterType.getQuery(); … … 98 96 typeQuery.setCacheResult(true); 99 97 List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData"); 98 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 100 99 101 100 try 102 101 { 102 final ItemQuery<Well> query = Base.getConfiguredQuery(cc, true, plate.getWells(), mode); 103 if (!"row".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("row"))); 104 if (!"column".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("column"))); 103 105 wells = query.iterate(dc); 104 106 } … … 276 278 filterable="true" 277 279 exportable="true" 280 formatter="<%=dateFormatter%>" 278 281 /> 279 282 <% … … 312 315 filterable="true" 313 316 exportable="true" 317 formatter="<%=FormatterFactory.getExtendedPropertyFormatter(sc, ep)%>" 314 318 /> 315 319 <% … … 321 325 { 322 326 Enumeration<String, String> annotationEnum = null; 327 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 323 328 if (at.isEnumeration()) 324 329 { … … 327 332 for (Object value : values) 328 333 { 329 String encoded = HTML.encodeTags(value.toString());334 String encoded = formatter.format(value); 330 335 annotationEnum.add(encoded, encoded); 331 336 } … … 342 347 filterable="true" 343 348 exportable="true" 349 formatter="<%=formatter%>" 344 350 /> 345 351 <% … … 502 508 <tbl:cell column="reporter.name"><i>- none -</i></tbl:cell> 503 509 <tbl:cell column="reporter.externalId"><i>- none -</i></tbl:cell> 504 <tbl:cell column="reporter.symbol"><i>- none -</i></tbl:cell>505 <tbl:cell column="reporter.description"><i>- none -</i></tbl:cell>506 <tbl:cell column="reporter.lastUpdate"><i>- none -</i></tbl:cell>507 <tbl:cell column="reporter.reporterType"><i>- none -</i></tbl:cell>508 510 <% 509 if (reporterProperties != null)510 {511 for (ExtendedProperty ep : reporterProperties)512 {513 String name = ep.getName();514 %>515 <tbl:cell column="<%="reporter."+name%>"><i>- none -</i></tbl:cell>516 <%517 }518 }519 511 } 520 512 else … … 525 517 <tbl:cell column="reporter.symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell> 526 518 <tbl:cell column="reporter.description"><%=HTML.encodeTags(reporter.getDescription())%></tbl:cell> 527 <tbl:cell column="reporter.lastUpdate" ><%=Values.formatDate(reporter.getLastUpdate())%></tbl:cell>519 <tbl:cell column="reporter.lastUpdate" value="<%=reporter.getLastUpdate()%>" /> 528 520 <tbl:cell column="reporter.reporterType" 529 521 ><base:propertyvalue … … 540 532 { 541 533 String name = ep.getName(); 542 Object value = reporter.getExtended(name);543 String link = ep.getUrl(value);544 if (value instanceof Date) value = Values.formatDate((Date)value);545 value = HTML.encodeTags(value == null ? "" : value.toString());546 if (link != null)547 {548 value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>";549 }550 534 %> 551 <tbl:cell column="<%="reporter."+name%>">< %=value%></tbl:cell>535 <tbl:cell column="<%="reporter."+name%>"><tbl:cellvalue value="<%=reporter.getExtended(name)%>" /></tbl:cell> 552 536 <% 553 537 } 554 538 } 555 539 } 556 %>557 <%558 540 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 559 for (AnnotationType at : annotationTypes)541 if (as != null) 560 542 { 561 %> 562 <tbl:cell column="<%="at"+at.getId()%>"> 563 <% 564 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 565 %> 566 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%> 567 </tbl:cell> 568 <% 543 for (AnnotationType at : annotationTypes) 544 { 545 if (as.hasAnnotation(at)) 546 { 547 %> 548 <tbl:cell column="<%="at"+at.getId()%>" 549 ><tbl:cellvalue 550 list="<%=as.getAnnotation(at).getValues()%>" 551 /></tbl:cell> 552 <% 553 } 554 } 569 555 } 570 556 %> -
trunk/www/lims/plates/wells/view_well.jsp
r2753 r2942 46 46 import="net.sf.basedb.clients.web.util.HTML" 47 47 import="net.sf.basedb.util.Values" 48 import="net.sf.basedb.util.formatter.Formatter" 49 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 48 50 import="java.util.Date" 49 51 import="java.util.Map" … … 68 70 try 69 71 { 72 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 70 73 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 71 74 … … 254 257 <tr> 255 258 <td class="prompt">Last update</td> 256 <td><%= Values.formatDate(reporter.getLastUpdate())%></td>259 <td><%=dateFormatter.format(reporter.getLastUpdate())%></td> 257 260 </tr> 258 261 </table> … … 269 272 { 270 273 String name = ep.getName(); 271 Object value = reporter.getExtended(name); 272 String link = ep.getUrl(value); 273 if (value instanceof Date) value = Values.formatDate((Date)value); 274 value = HTML.encodeTags(value == null ? "" : value.toString()); 275 if (link != null) 276 { 277 value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>"; 278 } 274 Formatter f = FormatterFactory.getExtendedPropertyFormatter(sc, ep); 275 String value = f.format(reporter.getExtended(name)); 279 276 %> 280 277 <%=needsTr ? "<tr valign=\"top\">" : "" %> -
trunk/www/main.jsp
r2753 r2942 41 41 import="net.sf.basedb.clients.web.Base" 42 42 import="net.sf.basedb.clients.web.util.HTML" 43 import="net.sf.basedb.util.formatter.Formatter" 44 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 43 45 import="net.sf.basedb.util.Values" 46 import="java.util.Date" 44 47 %> 45 48 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 51 54 final SessionControl sc = Base.getSessionControl(pageContext, true); 52 55 final String ID = sc.getId(); 56 final Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 53 57 final DbControl dc = sc.newDbControl(); 54 58 ItemResultList<News> news = null; … … 214 218 %> 215 219 <div class="item"> 216 <span class="date"><%= Values.formatDate(n.getNewsDate())%></span>220 <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span> 217 221 <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br> 218 222 <span class="text"><%=Values.getString(n.getDescription())%></span> -
trunk/www/my_base/index.jsp
r2753 r2942 52 52 import="net.sf.basedb.clients.web.Base" 53 53 import="net.sf.basedb.clients.web.util.HTML" 54 import="net.sf.basedb.util.formatter.Formatter" 55 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 54 56 import="net.sf.basedb.util.Values" 55 57 import="java.util.Date" … … 98 100 Quota groupQuota = quotaGroup == null ? null : quotaGroup.getQuota(); 99 101 102 Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); 103 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 104 100 105 ItemQuery<Message> messageQuery = Message.getQuery(user); 101 106 messageQuery.order(Orders.desc(Hql.property("timeSent"))); … … 175 180 <a href="javascript:viewMessage(<%=m.getId()%>)" 176 181 title="<%=HTML.encodeTags(fullName)%>"> 177 <span class="date"><%= Values.formatDateTime(m.getTimeSent())%></span>182 <span class="date"><%=dateTimeFormatter.format(m.getTimeSent())%></span> 178 183 <span class="headline"><%=HTML.encodeTags(shortName)%></span></a><br> 179 184 <span class="text"><%=HTML.encodeTags(text)%></span> … … 350 355 %> 351 356 <div class="item"> 352 <span class="date"><%= Values.formatDate(n.getNewsDate())%></span>357 <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span> 353 358 <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br> 354 359 <span class="text"><%=Values.getString(n.getDescription())%></span> -
trunk/www/my_base/messages/list_messages.jsp
r2753 r2942 50 50 import="net.sf.basedb.clients.web.util.HTML" 51 51 import="net.sf.basedb.util.Values" 52 import="net.sf.basedb.util.formatter.Formatter" 53 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 52 54 import="java.util.List" 53 55 import="java.util.Map" 56 import="java.util.Date" 54 57 %> 55 58 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 85 88 } 86 89 int numListed = 0; 90 Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); 87 91 %> 88 92 <base:page title="<%=title==null ? "Messages" : title%>" type="<%=mode.getPageType()%>"> … … 212 216 filterable="true" 213 217 exportable="true" 218 formatter="<%=dateTimeFormatter%>" 214 219 /> 215 220 <tbl:columndef … … 380 385 title="<%=tooltip%>"><%=name%></div></tbl:cell> 381 386 <tbl:cell column="from"><%=HTML.encodeTags(item.getFrom())%></tbl:cell> 382 <tbl:cell column="timeSent" ><%=Values.formatDateTime(item.getTimeSent())%></tbl:cell>387 <tbl:cell column="timeSent" value="<%=item.getTimeSent()%>" /> 383 388 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 384 389 <tbl:cell column="job"><base:propertyvalue item="<%=item%>" property="job" enableEditLink="<%=editLink%>" enablePropertyLink="<%=mode.hasPropertyLink()%>"/></tbl:cell> -
trunk/www/my_base/messages/view_message.jsp
r2753 r2942 47 47 import="net.sf.basedb.clients.web.util.HTML" 48 48 import="net.sf.basedb.util.Values" 49 import="net.sf.basedb.util.formatter.Formatter" 50 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 49 51 import="java.util.Date" 50 52 import="java.util.Map" … … 98 100 99 101 String title = "Message -- " + HTML.encodeTags(message.getName());; 102 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 103 Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); 100 104 101 105 final boolean writePermission = message.hasPermission(Permission.WRITE); … … 134 138 <tr valign="top"> 135 139 <td class="prompt">Time sent</td> 136 <td><%= Values.formatDateTime(message.getTimeSent())%></td>140 <td><%=dateTimeFormatter.format(message.getTimeSent())%></td> 137 141 </tr> 138 142 <tr valign="top"> … … 205 209 <td class="prompt">Created</td> 206 210 <td> 207 <%= Values.formatDateTime(job.getCreated())%>211 <%=dateTimeFormatter.format(job.getCreated())%> 208 212 </td> 209 213 </tr> … … 211 215 <td class="prompt">Started</td> 212 216 <td> 213 <%= Values.formatDateTime(job.getStarted())%>217 <%=dateTimeFormatter.format(job.getStarted())%> 214 218 </td> 215 219 </tr> … … 217 221 <td class="prompt">Ended</td> 218 222 <td> 219 <%= Values.formatDateTime(job.getEnded())%>223 <%=dateTimeFormatter.format(job.getEnded())%> 220 224 </td> 221 225 </tr> … … 297 301 else if (value instanceof Date) 298 302 { 299 sb.append( Values.formatDate((Date)value));303 sb.append(dateFormatter.format((Date)value)); 300 304 } 301 305 else … … 384 388 else if (value instanceof Date) 385 389 { 386 sb.append( Values.formatDate((Date)value));390 sb.append(dateFormatter.format((Date)value)); 387 391 } 388 392 else -
trunk/www/my_base/user/preferences.jsp
r2907 r2942 45 45 import="net.sf.basedb.clients.web.Base" 46 46 import="net.sf.basedb.clients.web.util.HTML" 47 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 47 48 import="net.sf.basedb.util.Values" 48 49 import="java.util.List" … … 314 315 </td> 315 316 </tr> 317 <tr> 318 <td class="prompt">Date format</td> 319 <td> 320 <input class="text" type="text" name="date_format" 321 value="<%=HTML.encodeTags(FormatterSettings.getDateFormat(sc))%>" 322 size="40"> 323 </td> 324 </tr> 325 326 <tr> 327 <td class="prompt">Date-time format</td> 328 <td> 329 <input class="text" type="text" name="datetime_format" 330 value="<%=HTML.encodeTags(FormatterSettings.getDateTimeFormat(sc))%>" 331 size="40"> 332 </td> 333 </tr> 334 316 335 </table> 317 336 <div align="right"> <i><base:icon image="required.gif" /> = required information</i></div> -
trunk/www/my_base/user/submit_user.jsp
r2907 r2942 40 40 import="net.sf.basedb.clients.web.WebException" 41 41 import="net.sf.basedb.clients.web.util.HTML" 42 import="net.sf.basedb.clients.web.formatter.FormatterSettings" 42 43 import="net.sf.basedb.util.Values" 43 44 import="java.util.Arrays" … … 118 119 sc.setUserClientSetting("ratiocolor.max", maxColor); 119 120 cc.setRecent("colors", minColor + "," + midColor + "," + maxColor, maxRecent); 121 FormatterSettings.setDateFormat(sc, request.getParameter("date_format")); 122 FormatterSettings.setDateTimeFormat(sc, request.getParameter("datetime_format")); 120 123 sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0")); 121 124 -
trunk/www/plugins/net/sf/basedb/clients/web/plugins/simple_export.jsp
r2868 r2942 413 413 </tr> 414 414 </table> 415 <input type="checkbox" name="parameter:overwrite" value=" 1">415 <input type="checkbox" name="parameter:overwrite" value="true"> 416 416 <a href="javascript:Forms.toggleCheckbox(document.forms['export']['parameter:overwrite'])">Overwrite existing file</a><br> 417 417 </td> -
trunk/www/views/experiments/bioassays/list_bioassays.jsp
r2892 r2942 58 58 import="net.sf.basedb.clients.web.util.HTML" 59 59 import="net.sf.basedb.util.Values" 60 import="net.sf.basedb.util.formatter.Formatter" 61 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 60 62 import="java.util.List" 61 63 import="java.util.LinkedList" … … 273 275 { 274 276 Enumeration<String, String> annotationEnum = null; 277 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 275 278 if (at.isEnumeration()) 276 279 { … … 279 282 for (Object value : values) 280 283 { 281 String encoded = HTML.encodeTags(value.toString());284 String encoded = formatter.format(value); 282 285 annotationEnum.add(encoded, encoded); 283 286 } … … 294 297 filterable="true" 295 298 exportable="true" 299 formatter="<%=formatter%>" 296 300 /> 297 301 <% … … 464 468 <% 465 469 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; 466 for (AnnotationType at : annotationTypes)470 if (as != null) 467 471 { 468 %> 469 <tbl:cell column="<%="at"+at.getId()%>"> 470 <% 471 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues(); 472 %> 473 <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Val