Changeset 313
- Timestamp:
- 09/23/08 15:05:41 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r311 r313 7 7 import java.lang.reflect.Modifier; 8 8 import java.net.URL; 9 import java.rmi.UnexpectedException; 9 10 import java.util.ArrayList; 10 11 import java.util.Collection; … … 506 507 params = new Object[paramCount]; 507 508 String[] paramStrings = parameters.split("\\s+"); 508 if (paramCount != paramStrings.length) 509 /** 510 * Any extra parametres will be treated as the rest of the 511 * string if the last param is a string 512 */ 513 if (paramCount > paramStrings.length) 509 514 continue; 510 for (int i = 0; i < paramCount; i++) { 511 SString nextParam = new SString(paramStrings[i]); 512 try { 515 /** 516 * If there are extra parametres the last param must be a 517 * String 518 */ 519 int lastParam = paramTypes.length - 1; 520 521 if (paramCount < paramStrings.length 522 && !paramTypes[lastParam].equals(String.class)) 523 continue; 524 try { 525 for (int i = 0; i < paramCount; i++) { 526 SString nextParam = new SString(paramStrings[i]); 513 527 params[i] = null; 514 528 if (paramTypes[i].equals(int.class) … … 531 545 params[i] = nextParam.stringValue(); 532 546 } else { 533 continue; 547 throw new UnexpectedException( 548 "Unexpected type " 549 + paramTypes[i].getClass() 550 .toString()); 534 551 } 535 } catch (Exception e) {536 continue;537 552 } 553 } catch (Exception e) { 554 continue; 538 555 } 556 /** Append extra params on the end of the last string param */ 557 String s = params[lastParam].toString(); 558 for (int i = paramCount; i < paramStrings.length; i++) { 559 s += ' ' + paramStrings[i]; 560 } 561 params[lastParam] = s; 562 539 563 con = c; 540 564 break; … … 861 885 try { 862 886 return PerformAction(current, launcher, command); 863 } catch (RuntimeException e) {887 } catch (RuntimeException e) { 864 888 MessageBay.errorMessage("Action failed: " + e.getMessage()); 865 889 } catch (Exception e) { 866 MessageBay.errorMessage("Action failed: " + e.getClass().getSimpleName()); 890 MessageBay.errorMessage("Action failed: " 891 + e.getClass().getSimpleName()); 867 892 } 868 893 return null; -
trunk/src/org/expeditee/actions/Simple.java
r311 r313 933 933 // The fast search does not do replacement 934 934 if (bReplace) { 935 searchAgent = new SearchFrameset( null, firstFrame, maxFrame);935 searchAgent = new SearchFrameset(firstFrame, maxFrame, null); 936 936 } else { 937 searchAgent = new SearchFramesetFast( null, firstFrame, maxFrame);937 searchAgent = new SearchFramesetFast(firstFrame, maxFrame, null); 938 938 } 939 939 searchAgent.initialise(null, null, frameset, resultsFrameset, -
trunk/src/org/expeditee/agents/DefaultAgent.java
r179 r313 107 107 108 108 public boolean hasResultFrame() { 109 return _end!= null;109 return getResultFrame() != null; 110 110 } 111 111 -
trunk/src/org/expeditee/agents/SearchFrameset.java
r292 r313 8 8 private long _maxFrame = Integer.MAX_VALUE; 9 9 10 public SearchFrameset(String searchText) { 11 super(searchText); 12 } 13 14 public SearchFrameset(String searchText, long firstFrame, long maxFrame) { 10 public SearchFrameset(long firstFrame, long maxFrame, String searchText) { 15 11 this(searchText); 16 12 _firstFrame = firstFrame; 17 13 _maxFrame = maxFrame; 14 } 15 16 public SearchFrameset(String searchText) { 17 super(searchText); 18 18 } 19 19 -
trunk/src/org/expeditee/agents/SearchFramesetFast.java
r298 r313 12 12 private long _maxFrame = Integer.MAX_VALUE; 13 13 14 public SearchFramesetFast(String searchText) { 15 super(searchText); 16 } 17 18 public SearchFramesetFast(String searchText, long firstFrame, long maxFrame) { 14 public SearchFramesetFast(long firstFrame, long maxFrame, String searchText) { 19 15 this(searchText); 20 16 _firstFrame = firstFrame; 21 17 _maxFrame = maxFrame; 18 } 19 20 public SearchFramesetFast(String searchText) { 21 super(searchText); 22 22 } 23 23 -
trunk/src/org/expeditee/agents/SearchFramesetNoResults.java
r298 r313 13 13 private Map<String, Collection<String>> _results = new HashMap<String, Collection<String>>(); 14 14 15 public SearchFramesetNoResults(String searchText) { 16 super(searchText); 17 } 18 19 public SearchFramesetNoResults(String searchText, long firstFrame, long maxFrame) { 15 public SearchFramesetNoResults(long firstFrame, long maxFrame, String searchText) { 20 16 this(searchText); 21 17 _firstFrame = firstFrame; 22 18 _maxFrame = maxFrame; 19 } 20 21 public SearchFramesetNoResults(String searchText) { 22 super(searchText); 23 23 } 24 24 -
trunk/src/org/expeditee/agents/SearchGreenstone.java
r312 r313 1 1 package org.expeditee.agents; 2 2 3 import java.util.Collections;4 3 import java.util.Enumeration; 5 4 import java.util.HashMap; 5 import java.util.Map; 6 6 import java.util.Vector; 7 7 … … 12 12 import org.expeditee.greenstone.ResultDocument; 13 13 import org.expeditee.gui.AttributeValuePair; 14 import org.expeditee.gui.DisplayIO; 14 15 import org.expeditee.gui.Frame; 15 16 import org.expeditee.gui.FrameCreator; 16 17 import org.expeditee.gui.FrameGraphics; 18 import org.expeditee.gui.FrameMouseActions; 19 import org.expeditee.gui.MessageBay; 17 20 import org.expeditee.items.Text; 18 21 19 22 public class SearchGreenstone extends SearchAgent { 20 23 24 private static String _fullCaseSearchQuery = null; 25 21 26 private static boolean _doCasefolding = true; 22 27 … … 27 32 private static String _maxResults = "10"; 28 33 34 private static boolean _showAbstract = false; 35 private static boolean _showKeywords = false; 36 private static boolean _showAuthors = false; 37 private static boolean _showDate = false; 38 39 private String _thisMaxResults = "10"; 40 29 41 private int _indexChoice = 1; 30 42 … … 35 47 private static String[] _indexKeys = { "TX", "TI", "JO", "BO", "CR", "KE" }; 36 48 37 protected static Vector<Result> _currentResultSet; 49 protected static Vector<Result> _currentResultSet = null; 50 51 private boolean _useLastSearchResults = false; 52 53 /** 54 * dateMap is a hash table. The keys are year values. the data associated 55 * with each key is a Vector of document IDs therefore, for the current 56 * result set you can get the set of years in which the results were 57 * published, and for each year you can get the set of documents published 58 * in that year 59 * 60 * If you want to introduce additional mappings (eg document written by 61 * authors) you should introduce additional structures here (HashMap used in 62 * the same way as dateMap will probably suffice 63 * 64 */ 65 protected static Map<String, Vector<String>> _dateMap = new HashMap<String, Vector<String>>(); 66 67 protected static Map<Integer, Vector<String>> _pageCountMap = new HashMap<Integer, Vector<String>>(); 68 69 protected static Map<String, String> _titleMap = new HashMap<String, String>(); 70 71 public SearchGreenstone(int resultsCount, String searchText) { 72 super(searchText); 73 _thisMaxResults = resultsCount + ""; 74 _fullCaseSearchQuery = searchText; 75 } 38 76 39 77 public SearchGreenstone(String searchText) { 40 78 super(searchText); 41 } 42 43 public SearchGreenstone(int resultsCount, String searchText) { 44 this(searchText); 45 _maxResults = resultsCount + ""; 79 _thisMaxResults = _maxResults; 80 _fullCaseSearchQuery = searchText; 81 } 82 83 public SearchGreenstone() { 84 super(null); 85 _useLastSearchResults = true; 46 86 } 47 87 … … 61 101 if (attribute.equals("campus")) 62 102 _locationChoice = 0; 63 if (attribute.equals("autoconnect"))103 else if (attribute.equals("autoconnect")) 64 104 connect(); 65 105 66 if (attribute.equals("maxresults")) {106 else if (attribute.equals("maxresults")) { 67 107 try { 68 108 _maxResults = avp.getValue(); … … 71 111 } 72 112 73 if (attribute.equals("dostemming"))113 else if (attribute.equals("dostemming")) 74 114 _doStemming = true; 115 else if (attribute.startsWith("showabstract")) 116 _showAbstract = true; 117 else if (attribute.startsWith("showauthor")) 118 _showAuthors = true; 119 else if (attribute.startsWith("showkeyword")) 120 _showKeywords = true; 121 else if (attribute.startsWith("showdate")) 122 _showDate = true; 75 123 } 76 124 } … … 83 131 @Override 84 132 protected Frame process(Frame frame) { 85 _results.setTitle("SearchGreenstone [" + _pattern + "]"); 86 87 connect(); 88 89 doQuery(_pattern); 133 String resultsTitle = this.getClass().getSimpleName() + "[" 134 + _fullCaseSearchQuery + "]"; 135 _results.setTitle(resultsTitle); 136 137 if (!_useLastSearchResults) { 138 connect(); 139 doQuery(_pattern); 140 } else if (_currentResultSet != null) { 141 Text newText = DisplayIO.getCurrentFrame().createNewText( 142 _fullCaseSearchQuery); 143 _clicked = newText; 144 FrameMouseActions.pickup(newText); 145 } 146 147 if (_currentResultSet == null) { 148 MessageBay.errorMessage("Could not find Greenstone query text"); 149 return null; 150 } 90 151 91 152 createResults(); 92 153 93 154 _results.save(); 94 155 95 156 String resultFrameName = _results.getName(); 96 if (_clicked != null) 157 if (_clicked != null) { 97 158 _clicked.setLink(resultFrameName); 159 _clicked.setText(resultsTitle); 160 } 98 161 99 162 return _results.getFirstFrame(); … … 104 167 } 105 168 169 /** 170 * TODO make this more efficient so the maps are loaded on demand... 171 * 172 * @param queryText 173 */ 106 174 protected void doQuery(String queryText) { 175 _pageCountMap.clear(); 176 _dateMap.clear(); 177 _titleMap.clear(); 178 107 179 Query query = createQuery(queryText); 108 180 QueryOutcome queryOutcome = _gsdl.issueQueryToServer(query); … … 113 185 114 186 Query query = new Query(); 115 116 187 // set the query options 117 188 query.setQueryText(queryText); 118 119 189 query.setIndex(_indexKeys[_indexChoice]); 120 query.setMaxDocsToReturn(_ maxResults);190 query.setMaxDocsToReturn(_thisMaxResults); 121 191 122 192 if (_doStemming) { … … 138 208 139 209 Vector<Result> results = queryOutcome.getResults(); 140 for (Enumeration<Result> e = results.elements(); e.hasMoreElements();) { 141 Result result = e.nextElement(); 210 for (Result result : results) { 142 211 getResultMetadata(result); 143 212 } … … 193 262 ResultDocument rd = _gsdl.getDocument(docID); 194 263 int docRank = result.getRank(); 195 // Put the details on a separate frame 196 FrameCreator details = new FrameCreator(rd.getTitle()); 197 details.addText(getDetails(rd), null, null, null, true); 198 199 resultsCreator.addText((docRank + 1) + ". " + rd.getTitle(), null, 200 details.getName(), "getTextFromChildFrame", false); 201 202 FrameGraphics.requestRefresh(true); 264 265 addText(rd, resultsCreator, (docRank + 1) + ". " + rd.getTitle()); 203 266 } 204 267 } … … 252 315 } 253 316 317 @Override 318 public Frame getResultFrame() { 319 if (_useLastSearchResults && _currentResultSet == null) 320 return null; 321 322 return super.getResultFrame(); 323 } 324 325 protected void addText(ResultDocument rd, FrameCreator results, String text) { 326 // Put the details on a separate frame 327 FrameCreator details = new FrameCreator(rd.getTitle()); 328 details.addText(getDetails(rd), null, null, null, true); 329 330 if (_showDate && rd.metadataExists("Date")) 331 text += ", " + rd.getDate(); 332 333 if (_showAbstract && rd.metadataExists("Abstract")) 334 text += "\n " + rd.getAbstract(); 335 336 if (_showAuthors && rd.metadataExists("Creator")) 337 text += "\nAuthors" + rd.getAuthors().toString(); 338 339 if (_showKeywords && rd.getKeywords().size() > 0) 340 text += "\nKeywords" + rd.getKeywords().toString(); 341 342 results.addText(text, null, details.getName(), "getTextFromChildFrame", 343 false); 344 345 FrameGraphics.requestRefresh(true); 346 } 347 254 348 } -
trunk/src/org/expeditee/agents/SearchGreenstoneByDate.java
r312 r313 2 2 3 3 import java.util.Collections; 4 import java.util. HashMap;4 import java.util.Map; 5 5 import java.util.Vector; 6 6 … … 12 12 public class SearchGreenstoneByDate extends SearchGreenstone { 13 13 14 public SearchGreenstoneByDate(int resultsCount, String searchText) { 15 super(resultsCount, searchText); 16 } 17 14 18 public SearchGreenstoneByDate(String searchText) { 15 19 super(searchText); 16 20 } 17 18 public SearchGreenstoneByDate(int resultsCount, String searchText) { 19 super(resultsCount, searchText); 20 } 21 22 /** 23 * dateMap is a hash table. The keys are year values. the data associated 24 * with each key is a Vector of document IDs therefore, for the current 25 * result set you can get the set of years in which the results were 26 * published, and for each year you can get the set of documents published 27 * in that year 28 * 29 * If you want to introduce additional mappings (eg document written by 30 * authors) you should introduce additional structures here (HashMap used in 31 * the same way as dateMap will probably suffice 32 * 33 */ 34 private static HashMap<String, Vector<String>> _dateMap = new HashMap<String, Vector<String>>(); 35 36 protected void doQuery(String queryText) { 37 _dateMap.clear(); 38 39 super.doQuery(queryText); 40 41 initialiseDateMap(_currentResultSet); 21 22 public SearchGreenstoneByDate() { 23 super(); 42 24 } 43 25 44 26 protected void createResults() { 27 if(_dateMap.isEmpty()){ 28 initialiseDateMap(_currentResultSet); 29 } 45 30 viewByDate(_dateMap, _results); 46 31 } … … 83 68 * output 84 69 */ 85 private void viewByDate( HashMap<String, Vector<String>> dateMap,70 private void viewByDate(Map<String, Vector<String>> dateMap, 86 71 FrameCreator results) { 87 72 Vector<String> theDates = new Vector<String>(dateMap.keySet()); … … 96 81 for (String docID : ids) { 97 82 ResultDocument rd = _gsdl.getDocument(docID); 98 99 // Put the details on a separate frame 100 FrameCreator details = new FrameCreator(rd.getTitle()); 101 details.addText(getDetails(rd), null, null, null, true); 102 103 results.addText(date + "- " + rd.getTitle(), null, details 104 .getName(), "getTextFromChildFrame", false); 105 106 FrameGraphics.requestRefresh(true); 83 addText(rd, results, date + "- " + rd.getTitle()); 107 84 } 108 85 } -
trunk/src/org/expeditee/greenstone/Greenstone3Connection.java
r312 r313 426 426 InputSource is = new InputSource(sr); 427 427 DOMParser p = new DOMParser(); 428 428 429 try { 429 430 p.parse(is); -
trunk/src/org/expeditee/greenstone/ResultDocument.java
r312 r313 110 110 111 111 public void setTitle(String title) { 112 this.title = new String(title);112 this.title = removeHTML(title); 113 113 this.retrievedMetadata.add("Title"); 114 114 } … … 226 226 return this.retrievedMetadata.contains(metadataTag); 227 227 } 228 229 230 protected String removeHTML(String s){ 231 return s.replaceAll(""", "\""); 232 } 228 233 229 234 } -
trunk/src/org/expeditee/items/widgets/DataFrameWidget.java
r294 r313 54 54 addSubject(_dataFrame); 55 55 } else { 56 // If the dataFrame has not been saved yet because it has just 57 // been 58 // created via TDFC this chart needs to be marked as changed so 59 // it will 60 // be refreshed when the user goes back 61 update(); 56 /** 57 * If the dataFrame has not been saved yet because it has just 58 * been created via TDFC this widget needs to be marked as 59 * changed so it will be refreshed when the user goes back 60 */ 61 assert(false); 62 //_needsUpdating = true; 63 // update(); 62 64 } 63 65 } … … 98 100 public void update() { 99 101 Frame parent = getParentFrame(); 100 if (parent != null && parent == DisplayIO.getCurrentFrame()){102 if (parent != null && parent == DisplayIO.getCurrentFrame()) { 101 103 refresh(); 102 104 } 103 105 104 106 _needsUpdating = true; 105 107 } … … 115 117 clearSubjects(); 116 118 setDataFrame(null); 117 refresh(); 119 if (oldLink == null) { 120 _needsUpdating = true; 121 } else { 122 refresh(); 123 } 118 124 } 119 125 … … 141 147 protected void paintInFreeSpace(Graphics g) { 142 148 super.paintInFreeSpace(g); 143 g.setFont(((Text) getSource()).getFont());149 g.setFont(((Text) getSource()).getFont()); 144 150 g.setColor(Color.WHITE); 145 151 g.drawString(this.getClass().getSimpleName(), getX() + 10, getY() + 20); -
trunk/src/org/expeditee/items/widgets/DataFrameWidget1.java
r214 r313 25 25 return stateArgs; 26 26 } 27 27 28 28 @Override 29 29 public void refresh() { 30 30 super.refresh(); 31 31 Frame frame = getDataFrame(); 32 if (frame != null) {32 if (frame != null) { 33 33 _combo.removeAllItems(); 34 for (Text text: frame.getBodyTextItems(false)) {34 for (Text text : frame.getBodyTextItems(false)) { 35 35 _combo.addItem(text.getText()); 36 36 } 37 _combo.setSelectedIndex(0); 37 if (_combo.getItemCount() > 0) 38 _combo.setSelectedIndex(0); 38 39 } 39 40 }
Note:
See TracChangeset
for help on using the changeset viewer.