Changeset 382


Ignore:
Timestamp:
11/10/08 14:07:37 (16 years ago)
Author:
ra33
Message:

update greenstone3 class to use types maps and arrays

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/greenstone/Greenstone3Connection.java

    r376 r382  
    1111import java.util.Collections;
    1212import java.util.HashMap;
     13import java.util.HashSet;
    1314import java.util.Iterator;
    1415import java.util.List;
     
    4748public class Greenstone3Connection {
    4849        /** an ordered list of {@link Query} objects */
    49         private List queryList;
     50        private List<Query> queryList;
    5051
    5152        /**
     
    6061         * with each item being NULL.
    6162         */
    62         private Map allKeywords;
    63 
    64         /**
    65          * a HashMap keyed on the author names found for all documents returned in
    66          * this session. Each item in the map is itself a HashMap, keyed on document
    67          * IDs with each item being NULL.
    68          */
    69         private Map allAuthors;
     63        private Map<String, Set<String>> allKeywords;
     64
     65        /**
     66         * a set of authors names
     67         */
     68        private Map<String, Set<String>> allAuthors;
    7069
    7170        /**
     
    7473         * document IDs with each item being NULL.
    7574         */
    76         private Map allDates;
     75        private Map<String, Set<String>> allDates;
    7776
    7877        /**
     
    8180         * IDs with each item being NULL.
    8281         */
    83         private Map allJournals;
     82        private Map<String, Set<String>> allJournals;
    8483
    8584        /**
     
    8887         * IDs with each item being NULL.
    8988         */
    90         private Map allBooktitles;
     89        private Map<String, Set<String>> allBooktitles;
    9190
    9291        /** the <i>hostname</i> where the Greenstone 3 server is running */
     
    155154                        this.SOAPrequestHeader = "POST /greenstone3/services/localsite HTTP/1.1\nHost: 130.217.220.10:8111\nSOAPAction: hcibib/PROCESSNAME\nContent-Type: text/xml;charset=utf-8\nContent-Length: ";
    156155                }
    157                 this.queryList = Collections.synchronizedList(new ArrayList());
     156                this.queryList = Collections.synchronizedList(new ArrayList<Query>());
    158157                this.allResults = Collections
    159158                                .synchronizedMap(new HashMap<String, ResultDocument>());
    160                 this.allKeywords = Collections.synchronizedMap(new HashMap());
    161                 this.allAuthors = Collections.synchronizedMap(new HashMap());
    162                 this.allDates = Collections.synchronizedMap(new HashMap());
    163                 this.allJournals = Collections.synchronizedMap(new HashMap());
    164                 this.allBooktitles = Collections.synchronizedMap(new HashMap());
     159                this.allKeywords = Collections.synchronizedMap(new HashMap<String, Set<String>>());
     160                this.allAuthors = Collections
     161                                .synchronizedMap(new HashMap<String, Set<String>>());
     162                this.allDates = Collections.synchronizedMap(new HashMap<String, Set<String>>());
     163                this.allJournals = Collections.synchronizedMap(new HashMap<String, Set<String>>());
     164                this.allBooktitles = Collections.synchronizedMap(new HashMap<String, Set<String>>());
    165165        }
    166166
     
    572572                                        String s = keywords[i].trim().toLowerCase();
    573573                                        resultDocument.addKeyword(s);
    574                                         if (allKeywords.containsKey(s)) {
    575                                                 HashMap docMap = (HashMap) allKeywords.get(s);
    576                                                 docMap.put(docID, null);
    577                                                 allKeywords.put(s, docMap);
    578                                         } else {
    579                                                 HashMap docMap = new HashMap();
    580                                                 docMap.put(docID, null);
    581                                                 allKeywords.put(s, docMap);
     574                                        Set<String> docSet = allKeywords.get(metadataval);
     575                                        if (docSet == null) {
     576                                                docSet = new HashSet<String>();
    582577                                        }
     578                                        docSet.add(docID);
     579                                        allKeywords.put(metadataval, docSet);
    583580                                }
    584581                        } else if (metadata.compareTo("Creator") == 0) {
     
    606603                                        // System.err.println(s);
    607604                                        resultDocument.addAuthor(s);
    608                                         if (allAuthors.containsKey(s)) {
    609                                                 HashMap docMap = (HashMap) allAuthors.get(s);
    610                                                 docMap.put(docID, null);
    611                                                 allAuthors.put(s, docMap);
    612                                         } else {
    613                                                 HashMap docMap = new HashMap();
    614                                                 docMap.put(docID, null);
    615                                                 allAuthors.put(s, docMap);
     605
     606                                        Set<String> docSet = allAuthors.get(s);
     607                                        if (docSet == null) {
     608                                                docSet = new HashSet<String>();
    616609                                        }
     610                                        docSet.add(docID);
     611                                        allAuthors.put(s, docSet);
    617612                                }
    618613                        } else if (metadata.compareTo("Title") == 0) {
     
    620615                        } else if (metadata.compareTo("Booktitle") == 0) {
    621616                                resultDocument.setBooktitle(metadataval);
    622                                 if (allBooktitles.containsKey(metadataval)) {
    623                                         HashMap docMap = (HashMap) allBooktitles.get(metadataval);
    624                                         docMap.put(docID, null);
    625                                         allBooktitles.put(metadataval, docMap);
    626                                 } else {
    627                                         HashMap docMap = new HashMap();
    628                                         docMap.put(docID, null);
    629                                         allBooktitles.put(metadataval, docMap);
     617                               
     618                                Set<String> docSet = allBooktitles.get(metadataval);
     619                                if (docSet == null) {
     620                                        docSet = new HashSet<String>();
    630621                                }
     622                                docSet.add(docID);
     623                                allBooktitles.put(metadataval, docSet);
    631624                        } else if (metadata.compareTo("Date") == 0) {
    632625                                resultDocument.setDate(metadataval.replaceAll("[^0-9]", ""));
    633                                 if (allDates.containsKey(metadataval)) {
    634                                         HashMap docMap = (HashMap) allDates.get(metadataval);
    635                                         docMap.put(docID, null);
    636                                         allDates.put(metadataval, docMap);
    637                                 } else {
    638                                         HashMap docMap = new HashMap();
    639                                         docMap.put(docID, null);
    640                                         allDates.put(metadataval, docMap);
     626                                Set<String> docSet = allDates.get(metadataval);
     627                                if (docSet == null) {
     628                                        docSet = new HashSet<String>();
    641629                                }
     630                                docSet.add(docID);
     631                                allDates.put(metadataval, docSet);
    642632                        } else if (metadata.compareTo("Pages") == 0) {
    643633                                resultDocument.setPages(metadataval);
    644634                        } else if (metadata.compareTo("Journal") == 0) {
    645635                                resultDocument.setJournal(metadataval);
    646                                 if (allJournals.containsKey(metadataval)) {
    647                                         HashMap docMap = (HashMap) allJournals.get(metadataval);
    648                                         docMap.put(docID, null);
    649                                         allJournals.put(metadataval, docMap);
    650                                 } else {
    651                                         HashMap docMap = new HashMap();
    652                                         docMap.put(docID, null);
    653                                         allJournals.put(metadataval, docMap);
     636                                Set<String> docSet = allJournals.get(metadataval);
     637                                if (docSet == null) {
     638                                        docSet = new HashSet<String>();
    654639                                }
     640                                docSet.add(docID);
     641                                allJournals.put(metadataval, docSet);
    655642                        } else if (metadata.compareTo("Volume") == 0) {
    656643                                resultDocument.setVolume(metadataval);
  • trunk/src/org/expeditee/io/HTMLWriter.java

    r376 r382  
    1212import org.expeditee.items.Picture;
    1313import org.expeditee.items.Text;
    14 
    15 import sun.awt.image.ToolkitImage;
    1614
    1715public class HTMLWriter extends AbstractHTMLWriter {
Note: See TracChangeset for help on using the changeset viewer.