Ignore:
Timestamp:
2004-12-21T16:18:32+13:00 (19 years ago)
Author:
schweer
Message:

started to use constants instead of strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/ProfileStore.java

    r8867 r8872  
    5454     */
    5555    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);
    6060       
    6161        Integer subId = new Integer(subscription.getId());
    6262       
    6363        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);
    6868            list.add(subId);
    6969        }
    7070        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);
    7575            list.add(subId);
    7676        }
    7777        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);
    8282            list.add(subId);
    8383        }
    8484        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);
    8989            list.add(subId);
    9090        }
     
    113113        // TODO rework algo for getting partially matched subs
    114114        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));
    116117        if (predicate != null)
    117118            result.addAll(predicate.getSubscriptionIDs());
    118119       
    119120        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));
    121123        if (predicate != null)
    122124            docIDSubs.addAll(predicate.getSubscriptionIDs());
    123         docIDSubs.addAll(getDontCareSubscriptions("documentID"));
     125        docIDSubs.addAll(getDontCareSubscriptions(Constants.DOCUMENT_ID_FIELD));
    124126        result.retainAll(docIDSubs);
    125127       
    126128        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));
    128131        if (predicate != null)
    129132            collIDSubs.addAll(predicate.getSubscriptionIDs());
    130         collIDSubs.addAll(getDontCareSubscriptions("collectionID"));
     133        collIDSubs.addAll(getDontCareSubscriptions(Constants.COLLECTION_ID_FIELD));
    131134        result.retainAll(collIDSubs);
    132135       
    133136        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));
    135139        if (predicate != null)
    136140            hostIDSubs.addAll(predicate.getSubscriptionIDs());
    137         hostIDSubs.addAll(getDontCareSubscriptions("hostID"));
     141        hostIDSubs.addAll(getDontCareSubscriptions(Constants.HOST_ID_FIELD));
    138142        result.retainAll(hostIDSubs);
    139143       
     
    154158        // predicate is matched iff the docID occurs in the query result
    155159       
    156         for (Iterator iter = PredicateFactory.getQueryPredicates("document_content").iterator(); iter.hasNext();) {
     160        for (Iterator iter = PredicateFactory.getQueryPredicates(Constants.DOCUMENT_CONTENT_FIELD).iterator(); iter.hasNext();) {
    157161            Predicate predicate = (Predicate) iter.next();
    158             String collection = (String) event.get("collectionID");
     162            String collection = (String) event.get(Constants.COLLECTION_ID_FIELD);
    159163            String query = predicate.getValue();
    160164            Set results;
    161165            try {
    162166                results = gsComm.fullTextSearch(collection, query);
    163                 if (results.contains(event.get("documentID"))) {
     167                if (results.contains(event.get(Constants.DOCUMENT_ID_FIELD))) {
    164168                    matchedPreds.add(predicate);
    165169                }
     
    368372                ResultSet predicates = stmnt.executeQuery(sqlString);
    369373                while (predicates.next()) {
    370                     String type = predicates.getString("type");
     374                    String type = predicates.getString(Constants.TYPE_FIELD);
    371375                    String field = predicates.getString("field");
    372376                    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;
    377381                        }
    378382                    }
Note: See TracChangeset for help on using the changeset viewer.