- Timestamp:
- 2004-12-21T16:18:32+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/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 }
Note:
See TracChangeset
for help on using the changeset viewer.