source: trunk/src/org/expeditee/agents/DisplayGreenstoneSession.java@ 636

Last change on this file since 636 was 419, checked in by ra33, 16 years ago

Refactored DateTime format code... so all formats are determined in a single spot.

Fixed bug preventing users from clicking a frame title of a protected frame to move to the next and previous frame.

File size: 2.0 KB
Line 
1package org.expeditee.agents;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.Comparator;
6import java.util.List;
7import java.util.Map;
8
9import org.expeditee.greenstone.ResultDocument;
10import org.expeditee.gui.FrameCreator;
11import org.expeditee.stats.Formatter;
12
13public class DisplayGreenstoneSession extends SearchGreenstone {
14
15 public DisplayGreenstoneSession(int resultsCount) {
16 super(resultsCount);
17 }
18
19 public DisplayGreenstoneSession() {
20 super();
21 }
22
23 protected void createResults() {
24 if (!_gsdl.getSessionResults().isEmpty()) {
25 viewSessionResults(_gsdl.getSessionResults(), _results);
26 }
27 }
28
29 protected String getResultsTitle() {
30 return "SessionResults at " + Formatter.getDateTime();
31 }
32
33 /**
34 * This method provides an alternative view of the result set It uses the
35 * dateMap which organises results according to the year in which they were
36 * published
37 *
38 * You will need to write a similar method for any additional view that you
39 * implement
40 *
41 * You may wish to modify this method to provide a better layout of the
42 * output
43 */
44 private void viewSessionResults(Map<String, ResultDocument> sessionResults,
45 FrameCreator results) {
46
47 List<ResultDocument> resultDocArrayList = new ArrayList<ResultDocument>(
48 sessionResults.values());
49 Collections.sort(resultDocArrayList,
50 new DescendingSessionScoreComparator());
51
52 int docRank = 1;
53
54 for(ResultDocument rd: resultDocArrayList){
55 addText(rd, results, docRank++ + ". " + rd.getTitle());
56 }
57
58 }
59
60 protected String getCursorText() {
61 return getResultsTitle();
62 }
63
64 static class DescendingSessionScoreComparator implements Comparator<ResultDocument> {
65
66 public int compare(ResultDocument d1, ResultDocument d2) {
67
68 double sessionScore1 = d1.getSessionScore();
69 double sessionScore2 = d2.getSessionScore();
70
71 if (sessionScore1 > sessionScore2) {
72 return -1;
73 } else if (sessionScore1 < sessionScore2) {
74 return 1;
75 } else {
76 return 0;
77 }
78 }
79 }
80
81 protected String getNoResultsMessage() {
82 return "The session results set is empty";
83 }
84}
Note: See TracBrowser for help on using the repository browser.