source: trunk/src/org/expeditee/agents/SearchGreenstoneByTitle.java@ 1444

Last change on this file since 1444 was 919, checked in by jts21, 10 years ago

Added license headers to all files, added full GPL3 license file, moved license header generator script to dev/bin/scripts

File size: 2.4 KB
Line 
1/**
2 * SearchGreenstoneByTitle.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.agents;
20
21import java.util.Collections;
22import java.util.Map;
23import java.util.Vector;
24
25import org.expeditee.greenstone.Result;
26import org.expeditee.greenstone.ResultDocument;
27import org.expeditee.gui.FrameCreator;
28
29public class SearchGreenstoneByTitle extends SearchGreenstone {
30
31 public SearchGreenstoneByTitle(int resultsCount, String searchText) {
32 super(resultsCount, searchText);
33 }
34
35 public SearchGreenstoneByTitle(String searchText) {
36 super(searchText);
37 }
38
39 public SearchGreenstoneByTitle() {
40 super();
41 }
42
43 protected void createResults() {
44 if (_titleMap.isEmpty()) {
45 initialiseTitleMap(_currentResultSet);
46 }
47 viewByTitle(_titleMap, _results);
48 }
49
50 public void initialiseTitleMap(Vector<Result> results) {
51 for (Result result : results) {
52 String docID = result.getDocID();
53
54 ResultDocument rd = _gsdl.getDocument(docID);
55
56 if (rd.metadataExists("Title")) {
57 _titleMap.put(rd.getTitle(), docID);
58 }
59 }
60 }
61
62 /**
63 * This method provides an alternative view of the result set It uses the
64 * dateMap which organises results according to the year in which they were
65 * published
66 *
67 * You will need to write a similar method for any additional view that you
68 * implement
69 *
70 * You may wish to modify this method to provide a better layout of the
71 * output
72 */
73 private void viewByTitle(Map<String, String> titleMap,
74 FrameCreator results) {
75 Vector<String> theTitles = new Vector<String>(titleMap.keySet());
76 Collections.sort(theTitles);
77
78 for (String title : theTitles) {
79 String id = titleMap.get(title);
80
81 ResultDocument rd = _gsdl.getDocument(id);
82
83 addText(rd, results, rd.getTitle());
84 }
85 }
86}
Note: See TracBrowser for help on using the repository browser.