Changeset 6696


Ignore:
Timestamp:
2004-02-02T16:06:45+13:00 (20 years ago)
Author:
cs025
Message:

Comments, modifications to BuildManager, corrections to CollectionManager
reading of collectConfigure.xml.

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

Legend:

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

    r6454 r6696  
    101101
    102102  public void run()
    103   {
     103  { // Initialise collection manager - note start of build
    104104    this.collectionManager.startBuild();
     105
     106    // TODO: add expansion (e.g. Zip files)
    105107
    106108    for (int i = 0; i < this.inputRoots.size(); i ++)
     
    109111      fileCrawler.crawl();
    110112    }
    111     this.indexerManager.indexDocuments();
    112113    this.extractorManager.extractDocuments();
    113114    this.classifierManager.classifyDocuments();
     115    this.indexerManager.indexDocuments();
     116
     117    // TODO: validation phase
    114118
    115119    if (this.archiveDir != null) {
     
    120124    this.collectionManager.setCollectionMetadata("gsdl3", "documentCount", Integer.toString(this.docList.getCount()));
    121125
     126    // TODO: write out collection configuration file (service lists, etc.)
     127   
    122128    this.collectionManager.endBuild();
    123129  }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/CollectionManager.java

    r6345 r6696  
    9494    public ClassifierInterface getClassifier()
    9595    {
     96      if (this.type == null) {
     97    return null;
     98      }
    9699      if (this.type.toLowerCase().equals("hierarchy")) {
    97100    return new HierarchyClassifier(this.file, this.fields, this.sort);
     101      }
     102      else if (this.type.toLowerCase().equals("azlist")) {
     103    return new AZListClassifier(this.fields);
    98104      }
    99105
     
    140146    { IndexerInterface indexer = null;
    141147
     148      System.out.println("Index: " + this.type);
     149
    142150      if (!indexerMap.containsKey(this.type)) {
    143151    if (this.type.toLowerCase().equals("mg")) {
    144       indexer = new MGIndexer();
     152      indexer = new MGIndexer();     
    145153    }
    146154    if (indexer != null) {
     
    165173 
    166174    this.database = GS3SQLConnectionFactory.createConnection(collection);
    167     if (this.database != null) {
     175    /*    if (this.database != null) {
    168176      this.database.clearCollection(collection);
    169177      this.database = null;
    170178    }
     179    */
    171180    if (this.database == null) {
    172181      this.database = GS3SQLConnectionFactory.createConnection("test");
     
    201210
    202211    this.buildDocNo = 1;
     212  }
     213
     214  private void configureBrowsers(BuildManager buildManager, Node node)
     215  { CollectionClassifier classifier = null;
     216
     217    NodeList children = node.getChildNodes();
     218    for (int c = 0; c < children.getLength(); c ++)
     219    { // assume that non-element children are irrelevant
     220      if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
     221      { continue;
     222      }
     223
     224      String name = children.item(c).getNodeName();
     225      System.out.println(name);
     226
     227      if (name.equals("classifier"))
     228      {
     229    NamedNodeMap atts = children.item(c).getAttributes();
     230    Node attribute = atts.getNamedItem("type");
     231    if (attribute == null) {
     232      continue;
     233    }
     234
     235    String type = attribute.getNodeValue();
     236    classifier = new CollectionClassifier(type, children.item(c));
     237   
     238    System.out.println("Found classifier " + type);
     239   
     240    // attach the classifier
     241    ClassifierInterface classify = classifier.getClassifier();
     242    buildManager.getClassifierManager().addClassifier(classify);
     243      } 
     244    }
    203245  }
    204246
     
    213255      Document document = builder.parse(collectionConfig);
    214256
    215       CollectionClassifier classifier = null;
    216 
    217257      Map                  indexerMap = new HashMap();
    218258
     
    228268      { // TODO: throw exception
    229269      }
     270
     271      System.out.println("Configuring collection");
    230272
    231273      NodeList children = rootElement.getChildNodes();
     
    239281
    240282    // the name is a plugin element
    241     if (name.equals("index"))
    242     { NamedNodeMap atts = children.item(c).getAttributes();
    243       Node attribute = atts.getNamedItem("type");
    244       String type = attribute.getNodeValue();
    245 
    246       attribute = atts.getNamedItem("name");
    247       String indexName = attribute.getNodeValue();
    248 
    249       // create the local indexer representation
    250       CollectionIndexer indexer = new CollectionIndexer(type, indexName, children.item(c));
    251 
    252       // prepare it...
    253       indexer.prepareIndexer(indexerMap);
     283    if (name.equals("search")) {
     284      NodeList indexChildren = children.item(c).getChildNodes();
     285
     286      for (int i = 0; i < indexChildren.getLength(); i ++) {
     287        String childName = indexChildren.item(i).getNodeName();
     288
     289        if (childName.equals("index"))
     290        { NamedNodeMap atts = indexChildren.item(i).getAttributes();
     291          Node attribute = atts.getNamedItem("type");
     292          String type = attribute.getNodeValue();
     293
     294          attribute = atts.getNamedItem("name");
     295          String indexName = attribute.getNodeValue();
     296         
     297          // create the local indexer representation
     298          CollectionIndexer indexer = new CollectionIndexer(type, indexName, indexChildren.item(i));
     299         
     300          // prepare it...
     301          indexer.prepareIndexer(indexerMap);
     302        }
     303      }
    254304    }
    255305    else if (name.equals("browse"))
    256     {
    257     }
    258     else if (name.equals("classifier"))
    259     {
    260       NamedNodeMap atts = children.item(c).getAttributes();
    261       Node attribute = atts.getNamedItem("type");
    262       String type = attribute.getNodeValue();
    263       classifier = new CollectionClassifier(type, children.item(c));
    264 
    265       // attach the classifier
    266       ClassifierInterface classify = classifier.getClassifier();
    267       buildManager.getClassifierManager().addClassifier(classify);
     306    { this.configureBrowsers(buildManager, children.item(c));
    268307    }
    269308    // TODO: other elements - make a factory-method approach here...
     
    278317
    279318    // attach the classifier
    280     buildManager.getIndexerManager().addIndexer(indexer);   
     319    buildManager.addIndexer(indexer);   
    281320      }
    282321    }
Note: See TracChangeset for help on using the changeset viewer.