Changeset 8847
- Timestamp:
- 2004-12-17T15:21:07+13:00 (19 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/greenstone3-extensions/gsdl-as/lib/templates/sub_collection.vm
r8798 r8847 43 43 <option>$collection</option> 44 44 #end 45 <option selected="selected" >any collection on host $host</option>45 <option selected="selected" value="">any collection on host $host</option> 46 46 </optgroup> 47 47 #end -
trunk/greenstone3-extensions/gsdl-as/lib/templates/sub_host.vm
r8798 r8847 42 42 <option #if($firstoption) selected="selected" #set($firstoption = false) #end>$host</option> 43 43 #end 44 <option value=" any">any host</option>44 <option value="">any host</option> 45 45 </select></li> 46 46 <li>You can enter a query in the field below. Only events coming from a host whose name matches this query will be sent to you.<br/> -
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java
r8798 r8847 305 305 String direction = (String) arguments.get("next_page"); 306 306 307 if (arguments.containsKey("host_query")) { 308 String hostQuery = (String) arguments.get("host_query"); 309 if (hostQuery != null && hostQuery.length() != 0) 310 arguments.remove("hostID"); 311 } 312 if (arguments.containsKey("collection_query")) { 313 String collQuery = (String) arguments.get("collection_query"); 314 if (collQuery != null && collQuery.length() != 0) 315 arguments.remove("collectionID"); 316 } 317 307 318 // save page arguments 308 319 savePageArgsToSession(currentPage, arguments, session); … … 318 329 // get page-specific stuff 319 330 if (nextPage.equals("host")) { 320 GreenstoneCommunicator gsComm = null;321 331 String[] hostNames; 322 332 try { 323 gsComm = new GreenstoneCommunicator();333 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(); 324 334 hostNames = gsComm.getHostNames(); 325 335 } catch (Exception e) { … … 327 337 } 328 338 context.put("hostnames", hostNames); 339 session.setAttribute("hostnames", hostNames); 329 340 } else if (nextPage.equals("collection")) { 330 341 // TODO might be query instead of just name 331 342 List hostNames = (List) arguments.get("hostID"); 332 GreenstoneCommunicator gsComm = null; 343 if (hostNames == null || hostNames.isEmpty()) { 344 hostNames = new Vector(); 345 // no host names -> use host query 346 String[] hostsFromSession = (String[]) session.getAttribute("hostnames"); 347 if (hostsFromSession == null || hostsFromSession.length == 0) { 348 try { 349 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(); 350 hostsFromSession = gsComm.getHostNames(); 351 } catch (Exception e) { 352 hostsFromSession = new String[] { "localhost" }; 353 } 354 } 355 String hostQuery = (String) arguments.get("host_query"); 356 for (int i = 0; i < hostsFromSession.length; i++) { 357 if (hostsFromSession[i] != null && hostsFromSession[i].indexOf(hostQuery) >= 0) { 358 hostNames.add(hostsFromSession[i]); 359 } 360 } 361 } 362 333 363 Map collNames = new TreeMap(); 334 364 for (Iterator iter = hostNames.iterator(); iter.hasNext();) { … … 336 366 Set collNamesForHost = new TreeSet(); 337 367 try { 338 gsComm = new GreenstoneCommunicator(new URL("http://" + host + ":8080/soap/servlet/rpcrouter")); 368 URL url = new URL("http://" + host + ":8080/soap/servlet/rpcrouter"); 369 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(url); 339 370 collNamesForHost.addAll(Arrays.asList(gsComm.getCollectionNames())); 340 371 } catch (Exception e) { -
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/GreenstoneCommunicator.java
r8798 r8847 53 53 54 54 public String[] getHostNames() { 55 // TODO method implementation 55 56 return new String[] {"localhost"}; 56 57 } -
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/PredicateFactory.java
r8798 r8847 31 31 // substring for collection_name -> SubstringMatchPredicates referring to it 32 32 private static Map collectionNameMatchPredicates = new TreeMap(); 33 private static Map hostNameMatchPredicates = new TreeMap(); 33 34 34 35 // query -> QueryPredicates referring to it … … 62 63 } else if (key.startsWith("document")) { 63 64 result = createQueryPredicate(key, value); 64 } else if (key.endsWith("_ name")) {65 } else if (key.endsWith("_query")) { 65 66 result = createSubstringMatchPredicate(key, value); 66 67 } else { … … 91 92 private static SubstringMatchPredicate createSubstringMatchPredicate(String key, String value) { 92 93 SubstringMatchPredicate predicate = null; 93 if (key.equals("collection_ name")) {94 if (key.equals("collection_query")) { 94 95 if (collectionNameMatchPredicates.containsKey(value)) { 95 96 predicate = (SubstringMatchPredicate) collectionNameMatchPredicates.get(value); 96 97 } else { 97 predicate = new SubstringMatchPredicate( key, value);98 predicate = new SubstringMatchPredicate("collectionID", value); 98 99 collectionNameMatchPredicates.put(value, predicate); 99 100 } 100 } // TODO other fields than collection_name 101 } else if (key.equals("host_query")) { 102 if (hostNameMatchPredicates.containsKey(value)) { 103 predicate = (SubstringMatchPredicate) hostNameMatchPredicates.get(value); 104 } else { 105 predicate = new SubstringMatchPredicate("hostID", value); 106 hostNameMatchPredicates.put(value, predicate); 107 } 108 } 109 // TODO other fields? 101 110 return predicate; 102 111 } … … 119 128 for (Iterator iter = values.iterator(); iter.hasNext();) { 120 129 String value = (String) iter.next(); 130 if (value == null || value.length() == 0) { 131 continue; 132 } 121 133 122 134 if (key.equals("hostID") && !(value.startsWith("http://"))) { … … 143 155 private static QueryPredicate createQueryPredicate(String field, 144 156 String query) { 145 QueryPredicate predicate = n ew QueryPredicate(field, query);157 QueryPredicate predicate = null; 146 158 if (field.equals("document_content")) { 147 documentContentQueryPredicates.put(query, predicate); 159 if (!documentContentQueryPredicates.containsKey(query)) { 160 predicate = new QueryPredicate(field, query); 161 documentContentQueryPredicates.put(query, predicate); 162 } 163 return (QueryPredicate) documentContentQueryPredicates.get(query); 148 164 } else if (field.equals("document_title")) { 149 documentTitleQueryPredicates.put(query, predicate); 165 if (!documentTitleQueryPredicates.containsKey(query)) { 166 predicate = new QueryPredicate(field, query); 167 documentTitleQueryPredicates.put(query, predicate); 168 } 169 return (QueryPredicate) documentTitleQueryPredicates.get(query); 150 170 } 151 171 return predicate; … … 170 190 171 191 public static Collection getAllSubstringMatchPredicates() { 172 return Collections.unmodifiableCollection(collectionNameMatchPredicates.values()); 192 Collection result = new Vector(); 193 result.addAll(hostNameMatchPredicates.values()); 194 result.addAll(collectionNameMatchPredicates.values()); 195 return Collections.unmodifiableCollection(result); 173 196 } 174 197 -
trunk/gsdl3/extensions/gsdl-as/lib/templates/sub_collection.vm
r8798 r8847 43 43 <option>$collection</option> 44 44 #end 45 <option selected="selected" >any collection on host $host</option>45 <option selected="selected" value="">any collection on host $host</option> 46 46 </optgroup> 47 47 #end -
trunk/gsdl3/extensions/gsdl-as/lib/templates/sub_host.vm
r8798 r8847 42 42 <option #if($firstoption) selected="selected" #set($firstoption = false) #end>$host</option> 43 43 #end 44 <option value=" any">any host</option>44 <option value="">any host</option> 45 45 </select></li> 46 46 <li>You can enter a query in the field below. Only events coming from a host whose name matches this query will be sent to you.<br/> -
trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java
r8798 r8847 305 305 String direction = (String) arguments.get("next_page"); 306 306 307 if (arguments.containsKey("host_query")) { 308 String hostQuery = (String) arguments.get("host_query"); 309 if (hostQuery != null && hostQuery.length() != 0) 310 arguments.remove("hostID"); 311 } 312 if (arguments.containsKey("collection_query")) { 313 String collQuery = (String) arguments.get("collection_query"); 314 if (collQuery != null && collQuery.length() != 0) 315 arguments.remove("collectionID"); 316 } 317 307 318 // save page arguments 308 319 savePageArgsToSession(currentPage, arguments, session); … … 318 329 // get page-specific stuff 319 330 if (nextPage.equals("host")) { 320 GreenstoneCommunicator gsComm = null;321 331 String[] hostNames; 322 332 try { 323 gsComm = new GreenstoneCommunicator();333 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(); 324 334 hostNames = gsComm.getHostNames(); 325 335 } catch (Exception e) { … … 327 337 } 328 338 context.put("hostnames", hostNames); 339 session.setAttribute("hostnames", hostNames); 329 340 } else if (nextPage.equals("collection")) { 330 341 // TODO might be query instead of just name 331 342 List hostNames = (List) arguments.get("hostID"); 332 GreenstoneCommunicator gsComm = null; 343 if (hostNames == null || hostNames.isEmpty()) { 344 hostNames = new Vector(); 345 // no host names -> use host query 346 String[] hostsFromSession = (String[]) session.getAttribute("hostnames"); 347 if (hostsFromSession == null || hostsFromSession.length == 0) { 348 try { 349 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(); 350 hostsFromSession = gsComm.getHostNames(); 351 } catch (Exception e) { 352 hostsFromSession = new String[] { "localhost" }; 353 } 354 } 355 String hostQuery = (String) arguments.get("host_query"); 356 for (int i = 0; i < hostsFromSession.length; i++) { 357 if (hostsFromSession[i] != null && hostsFromSession[i].indexOf(hostQuery) >= 0) { 358 hostNames.add(hostsFromSession[i]); 359 } 360 } 361 } 362 333 363 Map collNames = new TreeMap(); 334 364 for (Iterator iter = hostNames.iterator(); iter.hasNext();) { … … 336 366 Set collNamesForHost = new TreeSet(); 337 367 try { 338 gsComm = new GreenstoneCommunicator(new URL("http://" + host + ":8080/soap/servlet/rpcrouter")); 368 URL url = new URL("http://" + host + ":8080/soap/servlet/rpcrouter"); 369 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(url); 339 370 collNamesForHost.addAll(Arrays.asList(gsComm.getCollectionNames())); 340 371 } catch (Exception e) { -
trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/GreenstoneCommunicator.java
r8798 r8847 53 53 54 54 public String[] getHostNames() { 55 // TODO method implementation 55 56 return new String[] {"localhost"}; 56 57 } -
trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/PredicateFactory.java
r8798 r8847 31 31 // substring for collection_name -> SubstringMatchPredicates referring to it 32 32 private static Map collectionNameMatchPredicates = new TreeMap(); 33 private static Map hostNameMatchPredicates = new TreeMap(); 33 34 34 35 // query -> QueryPredicates referring to it … … 62 63 } else if (key.startsWith("document")) { 63 64 result = createQueryPredicate(key, value); 64 } else if (key.endsWith("_ name")) {65 } else if (key.endsWith("_query")) { 65 66 result = createSubstringMatchPredicate(key, value); 66 67 } else { … … 91 92 private static SubstringMatchPredicate createSubstringMatchPredicate(String key, String value) { 92 93 SubstringMatchPredicate predicate = null; 93 if (key.equals("collection_ name")) {94 if (key.equals("collection_query")) { 94 95 if (collectionNameMatchPredicates.containsKey(value)) { 95 96 predicate = (SubstringMatchPredicate) collectionNameMatchPredicates.get(value); 96 97 } else { 97 predicate = new SubstringMatchPredicate( key, value);98 predicate = new SubstringMatchPredicate("collectionID", value); 98 99 collectionNameMatchPredicates.put(value, predicate); 99 100 } 100 } // TODO other fields than collection_name 101 } else if (key.equals("host_query")) { 102 if (hostNameMatchPredicates.containsKey(value)) { 103 predicate = (SubstringMatchPredicate) hostNameMatchPredicates.get(value); 104 } else { 105 predicate = new SubstringMatchPredicate("hostID", value); 106 hostNameMatchPredicates.put(value, predicate); 107 } 108 } 109 // TODO other fields? 101 110 return predicate; 102 111 } … … 119 128 for (Iterator iter = values.iterator(); iter.hasNext();) { 120 129 String value = (String) iter.next(); 130 if (value == null || value.length() == 0) { 131 continue; 132 } 121 133 122 134 if (key.equals("hostID") && !(value.startsWith("http://"))) { … … 143 155 private static QueryPredicate createQueryPredicate(String field, 144 156 String query) { 145 QueryPredicate predicate = n ew QueryPredicate(field, query);157 QueryPredicate predicate = null; 146 158 if (field.equals("document_content")) { 147 documentContentQueryPredicates.put(query, predicate); 159 if (!documentContentQueryPredicates.containsKey(query)) { 160 predicate = new QueryPredicate(field, query); 161 documentContentQueryPredicates.put(query, predicate); 162 } 163 return (QueryPredicate) documentContentQueryPredicates.get(query); 148 164 } else if (field.equals("document_title")) { 149 documentTitleQueryPredicates.put(query, predicate); 165 if (!documentTitleQueryPredicates.containsKey(query)) { 166 predicate = new QueryPredicate(field, query); 167 documentTitleQueryPredicates.put(query, predicate); 168 } 169 return (QueryPredicate) documentTitleQueryPredicates.get(query); 150 170 } 151 171 return predicate; … … 170 190 171 191 public static Collection getAllSubstringMatchPredicates() { 172 return Collections.unmodifiableCollection(collectionNameMatchPredicates.values()); 192 Collection result = new Vector(); 193 result.addAll(hostNameMatchPredicates.values()); 194 result.addAll(collectionNameMatchPredicates.values()); 195 return Collections.unmodifiableCollection(result); 173 196 } 174 197 -
trunk/gsdl3/packages/gsdl-as/lib/templates/sub_collection.vm
r8798 r8847 43 43 <option>$collection</option> 44 44 #end 45 <option selected="selected" >any collection on host $host</option>45 <option selected="selected" value="">any collection on host $host</option> 46 46 </optgroup> 47 47 #end -
trunk/gsdl3/packages/gsdl-as/lib/templates/sub_host.vm
r8798 r8847 42 42 <option #if($firstoption) selected="selected" #set($firstoption = false) #end>$host</option> 43 43 #end 44 <option value=" any">any host</option>44 <option value="">any host</option> 45 45 </select></li> 46 46 <li>You can enter a query in the field below. Only events coming from a host whose name matches this query will be sent to you.<br/> -
trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java
r8798 r8847 305 305 String direction = (String) arguments.get("next_page"); 306 306 307 if (arguments.containsKey("host_query")) { 308 String hostQuery = (String) arguments.get("host_query"); 309 if (hostQuery != null && hostQuery.length() != 0) 310 arguments.remove("hostID"); 311 } 312 if (arguments.containsKey("collection_query")) { 313 String collQuery = (String) arguments.get("collection_query"); 314 if (collQuery != null && collQuery.length() != 0) 315 arguments.remove("collectionID"); 316 } 317 307 318 // save page arguments 308 319 savePageArgsToSession(currentPage, arguments, session); … … 318 329 // get page-specific stuff 319 330 if (nextPage.equals("host")) { 320 GreenstoneCommunicator gsComm = null;321 331 String[] hostNames; 322 332 try { 323 gsComm = new GreenstoneCommunicator();333 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(); 324 334 hostNames = gsComm.getHostNames(); 325 335 } catch (Exception e) { … … 327 337 } 328 338 context.put("hostnames", hostNames); 339 session.setAttribute("hostnames", hostNames); 329 340 } else if (nextPage.equals("collection")) { 330 341 // TODO might be query instead of just name 331 342 List hostNames = (List) arguments.get("hostID"); 332 GreenstoneCommunicator gsComm = null; 343 if (hostNames == null || hostNames.isEmpty()) { 344 hostNames = new Vector(); 345 // no host names -> use host query 346 String[] hostsFromSession = (String[]) session.getAttribute("hostnames"); 347 if (hostsFromSession == null || hostsFromSession.length == 0) { 348 try { 349 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(); 350 hostsFromSession = gsComm.getHostNames(); 351 } catch (Exception e) { 352 hostsFromSession = new String[] { "localhost" }; 353 } 354 } 355 String hostQuery = (String) arguments.get("host_query"); 356 for (int i = 0; i < hostsFromSession.length; i++) { 357 if (hostsFromSession[i] != null && hostsFromSession[i].indexOf(hostQuery) >= 0) { 358 hostNames.add(hostsFromSession[i]); 359 } 360 } 361 } 362 333 363 Map collNames = new TreeMap(); 334 364 for (Iterator iter = hostNames.iterator(); iter.hasNext();) { … … 336 366 Set collNamesForHost = new TreeSet(); 337 367 try { 338 gsComm = new GreenstoneCommunicator(new URL("http://" + host + ":8080/soap/servlet/rpcrouter")); 368 URL url = new URL("http://" + host + ":8080/soap/servlet/rpcrouter"); 369 GreenstoneCommunicator gsComm = new GreenstoneCommunicator(url); 339 370 collNamesForHost.addAll(Arrays.asList(gsComm.getCollectionNames())); 340 371 } catch (Exception e) { -
trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/GreenstoneCommunicator.java
r8798 r8847 53 53 54 54 public String[] getHostNames() { 55 // TODO method implementation 55 56 return new String[] {"localhost"}; 56 57 } -
trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/profiles/PredicateFactory.java
r8798 r8847 31 31 // substring for collection_name -> SubstringMatchPredicates referring to it 32 32 private static Map collectionNameMatchPredicates = new TreeMap(); 33 private static Map hostNameMatchPredicates = new TreeMap(); 33 34 34 35 // query -> QueryPredicates referring to it … … 62 63 } else if (key.startsWith("document")) { 63 64 result = createQueryPredicate(key, value); 64 } else if (key.endsWith("_ name")) {65 } else if (key.endsWith("_query")) { 65 66 result = createSubstringMatchPredicate(key, value); 66 67 } else { … … 91 92 private static SubstringMatchPredicate createSubstringMatchPredicate(String key, String value) { 92 93 SubstringMatchPredicate predicate = null; 93 if (key.equals("collection_ name")) {94 if (key.equals("collection_query")) { 94 95 if (collectionNameMatchPredicates.containsKey(value)) { 95 96 predicate = (SubstringMatchPredicate) collectionNameMatchPredicates.get(value); 96 97 } else { 97 predicate = new SubstringMatchPredicate( key, value);98 predicate = new SubstringMatchPredicate("collectionID", value); 98 99 collectionNameMatchPredicates.put(value, predicate); 99 100 } 100 } // TODO other fields than collection_name 101 } else if (key.equals("host_query")) { 102 if (hostNameMatchPredicates.containsKey(value)) { 103 predicate = (SubstringMatchPredicate) hostNameMatchPredicates.get(value); 104 } else { 105 predicate = new SubstringMatchPredicate("hostID", value); 106 hostNameMatchPredicates.put(value, predicate); 107 } 108 } 109 // TODO other fields? 101 110 return predicate; 102 111 } … … 119 128 for (Iterator iter = values.iterator(); iter.hasNext();) { 120 129 String value = (String) iter.next(); 130 if (value == null || value.length() == 0) { 131 continue; 132 } 121 133 122 134 if (key.equals("hostID") && !(value.startsWith("http://"))) { … … 143 155 private static QueryPredicate createQueryPredicate(String field, 144 156 String query) { 145 QueryPredicate predicate = n ew QueryPredicate(field, query);157 QueryPredicate predicate = null; 146 158 if (field.equals("document_content")) { 147 documentContentQueryPredicates.put(query, predicate); 159 if (!documentContentQueryPredicates.containsKey(query)) { 160 predicate = new QueryPredicate(field, query); 161 documentContentQueryPredicates.put(query, predicate); 162 } 163 return (QueryPredicate) documentContentQueryPredicates.get(query); 148 164 } else if (field.equals("document_title")) { 149 documentTitleQueryPredicates.put(query, predicate); 165 if (!documentTitleQueryPredicates.containsKey(query)) { 166 predicate = new QueryPredicate(field, query); 167 documentTitleQueryPredicates.put(query, predicate); 168 } 169 return (QueryPredicate) documentTitleQueryPredicates.get(query); 150 170 } 151 171 return predicate; … … 170 190 171 191 public static Collection getAllSubstringMatchPredicates() { 172 return Collections.unmodifiableCollection(collectionNameMatchPredicates.values()); 192 Collection result = new Vector(); 193 result.addAll(hostNameMatchPredicates.values()); 194 result.addAll(collectionNameMatchPredicates.values()); 195 return Collections.unmodifiableCollection(result); 173 196 } 174 197
Note:
See TracChangeset
for help on using the changeset viewer.