summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKjetil Ørbekk <orbekk@pvv.ntnu.no>2010-09-04 02:04:34 -0400
committerKjetil Ørbekk <orbekk@pvv.ntnu.no>2010-09-04 02:05:20 -0400
commit69dd5ce3fdc53d35da12837ac67451c159546b97 (patch)
tree36a2ff271b0471d35823bb29a47b68da8377c492 /src
parentec11abe2f142c45240fe9ff172aa13a2e089019f (diff)
Improve ordering on the quote page.
By default, order by timestamp (= quote submit time). Remove ordering by id.
Diffstat (limited to 'src')
-rw-r--r--src/lq/Doubles.java15
-rw-r--r--src/lq/QuoteUtil.java11
2 files changed, 26 insertions, 0 deletions
diff --git a/src/lq/Doubles.java b/src/lq/Doubles.java
new file mode 100644
index 0000000..551e65a
--- /dev/null
+++ b/src/lq/Doubles.java
@@ -0,0 +1,15 @@
+package lq;
+
+public class Doubles {
+ public static final int signum(Double d) {
+ if (d < 0.0) {
+ return -1;
+ }
+ else if (d > 0.0) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+}
diff --git a/src/lq/QuoteUtil.java b/src/lq/QuoteUtil.java
index 37f857b..82ff932 100644
--- a/src/lq/QuoteUtil.java
+++ b/src/lq/QuoteUtil.java
@@ -89,6 +89,17 @@ public class QuoteUtil {
return quotes;
}
+ public static List<Quote> getQuotesOrderedByTimestampDesc() {
+ List<Quote> quotes = getQuotes();
+ Collections.sort(quotes,
+ new Comparator<Quote>() {
+ public int compare(Quote q1, Quote q2) {
+ return q2.getTimestamp().compareTo(q1.getTimestamp());
+ }
+ });
+ return quotes;
+ }
+
public static void approveQuote(Long id) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {