Changeset 6736


Ignore:
Timestamp:
2004-02-05T12:05:50+13:00 (20 years ago)
Author:
cs025
Message:

Added factory method, abstract indexer. Also modified Manager and
Interface to support naming of indexers, and MG and MGPP altered
accordingly.

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/indexers
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/indexers/IndexerInterface.java

    r6349 r6736  
    1212  public static final String GS2_INDEX_LABEL = "Index"; 
    1313
     14  public String  getIndexType();
     15  public String  getName();
     16  public int     getNumberOfPasses();
     17  // TODO: add a function call to provide appropriate XML for the service description
     18  public void    tidyup();
     19
    1420  public boolean configure(String label, String value);
    15   public boolean addIndex(String level, String field);
     21  public boolean configure(org.w3c.dom.Node node);
     22  public boolean addIndex(String name, String level, String field);
     23
    1624  public boolean startPass(int passNumber);
    1725  public boolean indexDocument(DocumentID id, DocumentInterface document);
    1826  public boolean endPass(int passNumber);
    19   public void    tidyup();
    20   public int getNumberOfPasses();
     27
    2128}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/indexers/MGIndexer.java

    r6698 r6736  
    1818import org.greenstone.gsdl3.gs3build.xpointer.XPointer;
    1919
    20 public class MGIndexer implements IndexerInterface
     20public class MGIndexer extends AbstractIndexer
    2121{
    2222  int          pass;
     
    3737  String       level;
    3838  String       field;
     39  String       name;
    3940
    4041  static final char END_OF_DOCUMENT = (char) 2;
     
    4243  static final char END_OF_STREAM   = (char) 4;
    4344
     45  public static final String MG_INDEX_TYPE = "mg";
     46
    4447  class MGIndex
    45   { String level;
     48  { String name;
     49    String level;
    4650    String field;
    4751
    48     public MGIndex(String level, String field)
    49     { this.level = level;
     52    public MGIndex(String name, String level, String field)
     53    { this.name  = name;
     54      this.level = level;
    5055      this.field = field;
    5156    }
     
    5560   
    5661      if (colonAt >= 0)
    57       { field = indexLabel.substring(colonAt+1);
    58         level = indexLabel.substring(0, colonAt);
    59       }
     62      { this.field = indexLabel.substring(colonAt+1);
     63        this.level = indexLabel.substring(0, colonAt);
     64      }
     65      this.name = null;
    6066    }
    6167
     
    6773    { return this.field;
    6874    }
    69   }
    70 
    71   public MGIndexer()
     75
     76    public String getName()
     77    { return this.name;
     78    }
     79  }
     80
     81  public MGIndexer(String name)
    7282  { this.indexes = new ArrayList();
     83    this.name    = name;
     84  }
     85
     86  public String getIndexType()
     87  { return MG_INDEX_TYPE;
     88  }
     89
     90  public String getName()
     91  { return this.name;
    7392  }
    7493
     
    131150  }
    132151
    133   public boolean addIndex(String level, String field)
     152  public boolean addIndex(String name, String level, String field)
    134153  {
    135     MGIndex index = new MGIndex(level, field);
     154    MGIndex index = new MGIndex(name, level, field);
    136155    this.indexes.add(index);
    137156    return true;
     
    160179    }
    161180
    162     descriptive.setMetadata("gsdl3", "mgseqno", indexName + "." + Integer.toString(this.sectionSeqNo));
     181    descriptive.addMetadata("gsdl3", "mgseqno", indexName + "." + Integer.toString(this.sectionSeqNo));
    163182    metsDoc.setModified(true);
    164183    //  System.out.println("Assigning " + this.sectionSeqNo + " to " + metsDoc.getID() + " " + division.getLabel());
     
    269288  public boolean indexDocument(DocumentID docID, DocumentInterface document)
    270289  {
     290    if (this.pass == 0) {
     291      document.removeAllMetadata("gsdl3", "mgseqno");
     292    }
     293
    271294    if (!this.firstDocument)
    272295    { // Send a 'CTRL-B' before the document itself
     
    280303      }
    281304    }
     305
    282306    String docText = null;
    283307
     
    421445    this.level = index.getLevel();
    422446    this.field = index.getField();
    423     this.indexName = this.getIndexDirectory(index.getLevel(), index.getField());
     447    this.indexName = index.getName();
     448    if (this.indexName == null || this.indexName.length() == 0) {
     449      this.indexName = this.getIndexDirectory(index.getLevel(), index.getField());
     450    }
    424451    this.indexStem = this.outputDirectory + File.separatorChar +
    425452      this.indexName + File.separatorChar + "index"; // TODO: modify for index
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/indexers/MGPPIndexer.java

    r6349 r6736  
    88import java.io.IOException;
    99
    10 public class MGPPIndexer implements IndexerInterface
     10public class MGPPIndexer extends AbstractIndexer
    1111{
    1212  int          pass;
     13  String       name;
    1314  boolean      firstDocument;
    1415  String       outputDirectory;
     
    1920  Process      mgpp_passes;
    2021  static final String documentSeparator = "<Document>";
     22
     23  public static final String MGPP_INDEX_TYPE = "mgpp";
    2124 
    22   public MGPPIndexer()
    23   {
     25  public MGPPIndexer(String name)
     26  { this.name = name;
     27  }
     28
     29  public String getName()
     30  { return this.name;
    2431  }
    2532
     
    3845  }
    3946
    40   public boolean addIndex(String level, String field)
     47  public String getIndexType()
     48  { return MGPP_INDEX_TYPE;
     49  }
     50
     51  public boolean addIndex(String name, String level, String field)
    4152  { return true;
    4253  }
Note: See TracChangeset for help on using the changeset viewer.