Changeset 8872 for trunk/greenstone3-extensions
- Timestamp:
- 2004-12-21T16:18:32+13:00 (19 years ago)
- Location:
- trunk/greenstone3-extensions/gsdl-as
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java
r8870 r8872 71 71 HttpServletResponse res, Context context) { 72 72 73 String action = req.getParameter( "action");73 String action = req.getParameter(Constants.ACTION_PARAM); 74 74 75 75 Map args = req.getParameterMap(); … … 257 257 GreenstoneCommunicator gsComm = null; 258 258 try { 259 String hostID = (String) event.get( "hostID");259 String hostID = (String) event.get(Constants.HOST_ID_FIELD); 260 260 gsComm = new GreenstoneCommunicator(new URL(hostID)); 261 261 } catch (MalformedURLException e) { … … 323 323 private String showSubscriptionWizardPage(Map arguments, Context context, boolean create) throws Exception { 324 324 if (create) { 325 context.put( "action", "createSubscription");325 context.put(Constants.ACTION_PARAM, "createSubscription"); 326 326 } else { 327 context.put( "action", "editSubscription");327 context.put(Constants.ACTION_PARAM, "editSubscription"); 328 328 } 329 329 if (!arguments.containsKey("current_page")) { … … 335 335 String direction = (String) arguments.get("next_page"); 336 336 337 if (arguments.containsKey( "host_query")) {338 String hostQuery = (String) arguments.get( "host_query");337 if (arguments.containsKey(Constants.HOST_QUERY_FIELD)) { 338 String hostQuery = (String) arguments.get(Constants.HOST_QUERY_FIELD); 339 339 if (hostQuery != null && hostQuery.length() != 0) 340 arguments.remove( "hostID");341 } 342 if (arguments.containsKey( "collection_query")) {343 String collQuery = (String) arguments.get( "collection_query");340 arguments.remove(Constants.HOST_ID_FIELD); 341 } 342 if (arguments.containsKey(Constants.COLLECTION_QUERY_FIELD)) { 343 String collQuery = (String) arguments.get(Constants.COLLECTION_QUERY_FIELD); 344 344 if (collQuery != null && collQuery.length() != 0) 345 arguments.remove( "collectionID");345 arguments.remove(Constants.COLLECTION_ID_FIELD); 346 346 } 347 347 … … 370 370 } else if (nextPage.equals("collection")) { 371 371 // TODO might be query instead of just name 372 List hostNames = (List) arguments.get( "hostID");372 List hostNames = (List) arguments.get(Constants.HOST_ID_FIELD); 373 373 if (hostNames == null || hostNames.isEmpty()) { 374 374 hostNames = new Vector(); … … 383 383 } 384 384 } 385 String hostQuery = (String) arguments.get( "host_query");385 String hostQuery = (String) arguments.get(Constants.HOST_QUERY_FIELD); 386 386 for (int i = 0; i < hostsFromSession.length; i++) { 387 387 if (hostsFromSession[i] != null && hostsFromSession[i].indexOf(hostQuery) >= 0) { -
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/ProfileStore.java
r8867 r8872 54 54 */ 55 55 private void addSubscription(Subscription subscription) { 56 List documentIdPredicate = subscription.getPredicateList( "documentID");57 List collectionIdPredicate = subscription.getPredicateList( "collectionID");58 List hostIdPredicate = subscription.getPredicateList( "hostID");59 List typePredicate = subscription.getPredicateList( "type");56 List documentIdPredicate = subscription.getPredicateList(Constants.DOCUMENT_ID_FIELD); 57 List collectionIdPredicate = subscription.getPredicateList(Constants.COLLECTION_ID_FIELD); 58 List hostIdPredicate = subscription.getPredicateList(Constants.HOST_ID_FIELD); 59 List typePredicate = subscription.getPredicateList(Constants.TYPE_FIELD); 60 60 61 61 Integer subId = new Integer(subscription.getId()); 62 62 63 63 if (documentIdPredicate.isEmpty()) { 64 if (!dontCareSubscriptions.containsKey( "documentID")) {65 dontCareSubscriptions.put( "documentID", new TreeSet());66 } 67 Set list = (Set) dontCareSubscriptions.get( "documentID");64 if (!dontCareSubscriptions.containsKey(Constants.DOCUMENT_ID_FIELD)) { 65 dontCareSubscriptions.put(Constants.DOCUMENT_ID_FIELD, new TreeSet()); 66 } 67 Set list = (Set) dontCareSubscriptions.get(Constants.DOCUMENT_ID_FIELD); 68 68 list.add(subId); 69 69 } 70 70 if (collectionIdPredicate.isEmpty()) { 71 if (!dontCareSubscriptions.containsKey( "collectionID")) {72 dontCareSubscriptions.put( "collectionID", new TreeSet());73 } 74 Set list = (Set) dontCareSubscriptions.get( "collectionID");71 if (!dontCareSubscriptions.containsKey(Constants.COLLECTION_ID_FIELD)) { 72 dontCareSubscriptions.put(Constants.COLLECTION_ID_FIELD, new TreeSet()); 73 } 74 Set list = (Set) dontCareSubscriptions.get(Constants.COLLECTION_ID_FIELD); 75 75 list.add(subId); 76 76 } 77 77 if (hostIdPredicate.isEmpty()) { 78 if (!dontCareSubscriptions.containsKey( "hostID")) {79 dontCareSubscriptions.put( "hostID", new TreeSet());80 } 81 Set list = (Set) dontCareSubscriptions.get( "hostID");78 if (!dontCareSubscriptions.containsKey(Constants.HOST_ID_FIELD)) { 79 dontCareSubscriptions.put(Constants.HOST_ID_FIELD, new TreeSet()); 80 } 81 Set list = (Set) dontCareSubscriptions.get(Constants.HOST_ID_FIELD); 82 82 list.add(subId); 83 83 } 84 84 if (typePredicate.isEmpty()) { 85 if (!dontCareSubscriptions.containsKey( "type")) {86 dontCareSubscriptions.put( "type", new TreeSet());87 } 88 Set list = (Set) dontCareSubscriptions.get( "type");85 if (!dontCareSubscriptions.containsKey(Constants.TYPE_FIELD)) { 86 dontCareSubscriptions.put(Constants.TYPE_FIELD, new TreeSet()); 87 } 88 Set list = (Set) dontCareSubscriptions.get(Constants.TYPE_FIELD); 89 89 list.add(subId); 90 90 } … … 113 113 // TODO rework algo for getting partially matched subs 114 114 IdEqualsPredicate predicate; 115 predicate = PredicateFactory.getIdEqualsPredicate("type", (String)event.get("type")); 115 predicate = PredicateFactory.getIdEqualsPredicate(Constants.TYPE_FIELD, 116 (String)event.get(Constants.TYPE_FIELD)); 116 117 if (predicate != null) 117 118 result.addAll(predicate.getSubscriptionIDs()); 118 119 119 120 Set docIDSubs = new TreeSet(); 120 predicate = PredicateFactory.getIdEqualsPredicate("documentID", (String)event.get("documentID")); 121 predicate = PredicateFactory.getIdEqualsPredicate(Constants.DOCUMENT_ID_FIELD, 122 (String)event.get(Constants.DOCUMENT_ID_FIELD)); 121 123 if (predicate != null) 122 124 docIDSubs.addAll(predicate.getSubscriptionIDs()); 123 docIDSubs.addAll(getDontCareSubscriptions( "documentID"));125 docIDSubs.addAll(getDontCareSubscriptions(Constants.DOCUMENT_ID_FIELD)); 124 126 result.retainAll(docIDSubs); 125 127 126 128 Set collIDSubs = new TreeSet(); 127 predicate = PredicateFactory.getIdEqualsPredicate("collectionID", (String)event.get("collectionID")); 129 predicate = PredicateFactory.getIdEqualsPredicate(Constants.COLLECTION_ID_FIELD, 130 (String)event.get(Constants.COLLECTION_ID_FIELD)); 128 131 if (predicate != null) 129 132 collIDSubs.addAll(predicate.getSubscriptionIDs()); 130 collIDSubs.addAll(getDontCareSubscriptions( "collectionID"));133 collIDSubs.addAll(getDontCareSubscriptions(Constants.COLLECTION_ID_FIELD)); 131 134 result.retainAll(collIDSubs); 132 135 133 136 Set hostIDSubs = new TreeSet(); 134 predicate = PredicateFactory.getIdEqualsPredicate("hostID", (String)event.get("hostID")); 137 predicate = PredicateFactory.getIdEqualsPredicate(Constants.HOST_ID_FIELD, 138 (String)event.get(Constants.HOST_ID_FIELD)); 135 139 if (predicate != null) 136 140 hostIDSubs.addAll(predicate.getSubscriptionIDs()); 137 hostIDSubs.addAll(getDontCareSubscriptions( "hostID"));141 hostIDSubs.addAll(getDontCareSubscriptions(Constants.HOST_ID_FIELD)); 138 142 result.retainAll(hostIDSubs); 139 143 … … 154 158 // predicate is matched iff the docID occurs in the query result 155 159 156 for (Iterator iter = PredicateFactory.getQueryPredicates( "document_content").iterator(); iter.hasNext();) {160 for (Iterator iter = PredicateFactory.getQueryPredicates(Constants.DOCUMENT_CONTENT_FIELD).iterator(); iter.hasNext();) { 157 161 Predicate predicate = (Predicate) iter.next(); 158 String collection = (String) event.get( "collectionID");162 String collection = (String) event.get(Constants.COLLECTION_ID_FIELD); 159 163 String query = predicate.getValue(); 160 164 Set results; 161 165 try { 162 166 results = gsComm.fullTextSearch(collection, query); 163 if (results.contains(event.get( "documentID"))) {167 if (results.contains(event.get(Constants.DOCUMENT_ID_FIELD))) { 164 168 matchedPreds.add(predicate); 165 169 } … … 368 372 ResultSet predicates = stmnt.executeQuery(sqlString); 369 373 while (predicates.next()) { 370 String type = predicates.getString( "type");374 String type = predicates.getString(Constants.TYPE_FIELD); 371 375 String field = predicates.getString("field"); 372 376 if (type.equals(SubstringMatchPredicate.class.getName())) { 373 if (field.equals( "colletionID")) {374 field = "collection_query";375 } else if (field.equals( "hostID")) {376 field = "host_query";377 if (field.equals(Constants.COLLECTION_ID_FIELD)) { 378 field = Constants.COLLECTION_QUERY_FIELD; 379 } else if (field.equals(Constants.HOST_ID_FIELD)) { 380 field = Constants.HOST_QUERY_FIELD; 377 381 } 378 382 } -
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/Predicate.java
r8867 r8872 16 16 import java.util.TreeSet; 17 17 18 import org.greenstone.gsdlas.Constants; 18 19 import org.greenstone.gsdlas.database.DatabaseException; 19 20 import org.greenstone.gsdlas.database.DatabaseManager; … … 35 36 36 37 public static final String[] singleValueFields = new String[] { 37 "document_title",38 "document_content",38 Constants.DOCUMENT_TITLE_FIELD, 39 Constants.DOCUMENT_CONTENT_FIELD, 39 40 "metadata_has_field", 40 "host_query",41 "collection_query"};41 Constants.HOST_QUERY_FIELD, 42 Constants.COLLECTION_QUERY_FIELD }; 42 43 public static final String[] multiValueFields = new String[] { 43 "type",44 "hostID",45 "collectionID",46 "documentID"};44 Constants.TYPE_FIELD, 45 Constants.HOST_ID_FIELD, 46 Constants.COLLECTION_ID_FIELD, 47 Constants.DOCUMENT_ID_FIELD }; 47 48 48 49 public void addSubscription(int subscriptionID) { -
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/PredicateFactory.java
r8867 r8872 14 14 import java.util.TreeMap; 15 15 16 import org.greenstone.gsdlas.Constants; 16 17 import org.greenstone.gsdlas.database.DatabaseException; 17 18 … … 92 93 private static SubstringMatchPredicate createSubstringMatchPredicate(String key, String value) { 93 94 SubstringMatchPredicate predicate = null; 94 if (key.equals( "collection_query")) {95 if (key.equals(Constants.COLLECTION_QUERY_FIELD)) { 95 96 if (collectionNameMatchPredicates.containsKey(value)) { 96 97 predicate = (SubstringMatchPredicate) collectionNameMatchPredicates.get(value); 97 98 } else { 98 predicate = new SubstringMatchPredicate( "collectionID", value);99 predicate = new SubstringMatchPredicate(Constants.COLLECTION_ID_FIELD, value); 99 100 collectionNameMatchPredicates.put(value, predicate); 100 101 } 101 } else if (key.equals( "host_query")) {102 } else if (key.equals(Constants.HOST_QUERY_FIELD)) { 102 103 if (hostNameMatchPredicates.containsKey(value)) { 103 104 predicate = (SubstringMatchPredicate) hostNameMatchPredicates.get(value); 104 105 } else { 105 predicate = new SubstringMatchPredicate( "hostID", value);106 predicate = new SubstringMatchPredicate(Constants.HOST_ID_FIELD, value); 106 107 hostNameMatchPredicates.put(value, predicate); 107 108 } … … 132 133 } 133 134 134 if (key.equals( "hostID") && !(value.startsWith("http://"))) {135 if (key.equals(Constants.HOST_ID_FIELD) && !(value.startsWith("http://"))) { 135 136 value = "http://" + value + ":8080/soap/servlet/rpcrouter"; 136 137 } … … 156 157 String query) { 157 158 QueryPredicate predicate = null; 158 if (field.equals( "document_content")) {159 if (field.equals(Constants.DOCUMENT_CONTENT_FIELD)) { 159 160 if (!documentContentQueryPredicates.containsKey(query)) { 160 161 predicate = new QueryPredicate(field, query); … … 162 163 } 163 164 return (QueryPredicate) documentContentQueryPredicates.get(query); 164 } else if (field.equals( "document_title")) {165 } else if (field.equals(Constants.DOCUMENT_TITLE_FIELD)) { 165 166 if (!documentTitleQueryPredicates.containsKey(query)) { 166 167 predicate = new QueryPredicate(field, query); … … 181 182 public static Collection getQueryPredicates(String field) { 182 183 Set result = new TreeSet(); 183 if (field.equals( "document_title")) {184 if (field.equals(Constants.DOCUMENT_TITLE_FIELD)) { 184 185 result.addAll(documentTitleQueryPredicates.values()); 185 } else if (field.equals( "document_content")) {186 } else if (field.equals(Constants.DOCUMENT_CONTENT_FIELD)) { 186 187 result.addAll(documentContentQueryPredicates.values()); 187 188 } … … 222 223 } 223 224 } else if (predicate instanceof QueryPredicate) { 224 if (field.equals( "document_title")) {225 if (field.equals(Constants.DOCUMENT_TITLE_FIELD)) { 225 226 documentTitleQueryPredicates.remove(value); 226 } else if (field.equals( "document_content")) {227 } else if (field.equals(Constants.DOCUMENT_CONTENT_FIELD)) { 227 228 documentContentQueryPredicates.remove(value); 228 229 } else { … … 230 231 } 231 232 } else if (predicate instanceof SubstringMatchPredicate) { 232 if (field.equals( "hostID")) {233 if (field.equals(Constants.HOST_ID_FIELD)) { 233 234 hostNameMatchPredicates.remove(value); 234 } else if (field.equals( "collectionID")) {235 } else if (field.equals(Constants.COLLECTION_ID_FIELD)) { 235 236 collectionNameMatchPredicates.remove(value); 236 237 } else { -
trunk/greenstone3-extensions/gsdl-as/test-src/org/greenstone/gsdlas/AlertingServiceTest.java
r8722 r8872 39 39 40 40 Map arguments = new TreeMap(); 41 arguments.put( "type", "new_document");42 arguments.put( "collectionID", "testing");43 arguments.put( "document_content", "albatros");41 arguments.put(Constants.TYPE_FIELD, "new_document"); 42 arguments.put(Constants.COLLECTION_ID_FIELD, "testing"); 43 arguments.put(Constants.DOCUMENT_CONTENT_FIELD, "albatros"); 44 44 45 45 String template = as.createSubscription(arguments, context); … … 104 104 105 105 Map arguments = new TreeMap(); 106 arguments.put( "collectionID", "testing");107 arguments.put( "type", "new_document");108 arguments.put( "documentID", "20041124:1");109 arguments.put( "document_title", "keine albatrosse in sicht");110 arguments.put( "host_url", "http://localhost:8080/soap/servlet/rpcrouter");106 arguments.put(Constants.COLLECTION_ID_FIELD, "testing"); 107 arguments.put(Constants.TYPE_FIELD, "new_document"); 108 arguments.put(Constants.DOCUMENT_ID_FIELD, "20041124:1"); 109 arguments.put(Constants.DOCUMENT_TITLE_FIELD, "keine albatrosse in sicht"); 110 arguments.put(Constants.HOST_ID_FIELD, "http://localhost:8080/soap/servlet/rpcrouter"); 111 111 112 112 as.receiveEvent(arguments); -
trunk/greenstone3-extensions/gsdl-as/test-src/org/greenstone/gsdlas/ProfileStoreTest.java
r8798 r8872 44 44 Map event = new TreeMap(); 45 45 46 event.put( "documentID", "20041118:5");47 event.put( "collectionID", "gs3mgdemo");48 event.put( "hostID", "http://localhost:8080/soap/servlet/rpcrouter");46 event.put(Constants.DOCUMENT_ID_FIELD, "20041118:5"); 47 event.put(Constants.COLLECTION_ID_FIELD, "gs3mgdemo"); 48 event.put(Constants.HOST_ID_FIELD, "http://localhost:8080/soap/servlet/rpcrouter"); 49 49 50 50 Set result = ProfileStore.getInstance().filter(event, gsComm); … … 61 61 Map valueMap = new TreeMap(); 62 62 63 valueMap.put( "collectionID", "gs3mgdemo");64 valueMap.put( "document_content", "Tomatensalat");63 valueMap.put(Constants.COLLECTION_ID_FIELD, "gs3mgdemo"); 64 valueMap.put(Constants.DOCUMENT_CONTENT_FIELD, "Tomatensalat"); 65 65 66 66 addSubscription(valueMap); … … 68 68 valueMap.clear(); 69 69 70 valueMap.put( "collectionID", "gs3mgdemo");71 valueMap.put( "document_content", "Water+Buffalo");70 valueMap.put(Constants.COLLECTION_ID_FIELD, "gs3mgdemo"); 71 valueMap.put(Constants.DOCUMENT_CONTENT_FIELD, "Water+Buffalo"); 72 72 73 73 addSubscription(valueMap); … … 75 75 valueMap.clear(); 76 76 77 valueMap.put( "collectionID", "gs3mgdemo");78 valueMap.put( "document_content", "gender+equality");77 valueMap.put(Constants.COLLECTION_ID_FIELD, "gs3mgdemo"); 78 valueMap.put(Constants.DOCUMENT_CONTENT_FIELD, "gender+equality"); 79 79 80 80 addSubscription(valueMap);
Note:
See TracChangeset
for help on using the changeset viewer.