Changeset 4852


Ignore:
Timestamp:
2003-07-02T14:38:27+12:00 (21 years ago)
Author:
kjdon
Message:

changed the base constructor class a bit - the import, build, new stuff is moved into the sub class - so the constructro class can be used as a base for other building activities, such as daniels extract keywords stuff. so now you cant go CollectionConstructor.NEW, you have to use the sub class name.

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/build
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java

    r3683 r4852  
    99public abstract class CollectionConstructor
    1010    extends Thread {
    11 
    12     public static final int NEW = 0;
    13     public static final int IMPORT = 1;
    14     public static final int BUILD = 2;
    15     public static final int ACTIVATE = 3;
    1611
    1712    /** the site in which building is to take place */
     
    9994    }
    10095   
    101     public void run(){
    102     String msg;
    103     ConstructionEvent evt;
    104     if (process_type_ == -1) {
    105         msg = "Error: you must set the action type";
    106         evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
    107         sendMessage(evt);
    108         return;
    109     }
    110     if (site_home_==null) {
    111         msg = "Error: you must set site_home";
    112         evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
    113         sendMessage(evt);
    114         return;
    115     }
    116     if (process_type_ != NEW && collection_name_ ==null) {
    117         msg = "Error: you must set collection_name";
    118         evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
    119         sendMessage(evt);
    120         return;
    121     }
    122    
    123     switch (process_type_) {
    124     case NEW:
    125         newCollection();
    126         break;
    127     case IMPORT:
    128         importCollection();
    129         break;
    130     case BUILD:
    131         buildCollection();
    132         break;
    133     case ACTIVATE:
    134         activateCollection();
    135         break;
    136     default:
    137         msg = "wrong type of action specified!";
    138         evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
    139         sendMessage(evt);
    140         break;
    141     }
    142 
    143     }
    144 
    145     abstract protected void newCollection();
    146     abstract protected void importCollection();
    147     abstract protected void buildCollection();
    148     abstract protected void activateCollection();
     96    abstract public void run();
    14997}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/build/ConstructCollection.java

    r3684 r4852  
    4949        }
    5050        if (val.equals("new")) {
    51             process_mode = CollectionConstructor.NEW;
     51            process_mode = GS2PerlConstructor.NEW;
    5252        } else if (val.equals("import")) {
    53             process_mode = CollectionConstructor.IMPORT;
     53            process_mode = GS2PerlConstructor.IMPORT;
    5454        } else if (val.equals("build")) {
    55             process_mode = CollectionConstructor.BUILD;
     55            process_mode = GS2PerlConstructor.BUILD;
    5656        } else if (val.equals("activate")) {
    57             process_mode = CollectionConstructor.ACTIVATE;
     57            process_mode = GS2PerlConstructor.ACTIVATE;
    5858        }
    5959
     
    8585    // check that the collection name is valid - ie the directory exists if this is not a new one, or doesn't exist if we are creating a new one
    8686    File coll_dir = new File(GSFile.collectionBaseDir(site_home, coll_name));
    87     if (process_mode != CollectionConstructor.NEW && !coll_dir.exists()) {
     87    if (process_mode != GS2PerlConstructor.NEW && !coll_dir.exists()) {
    8888        System.out.println("ERROR: Invalid collection ("+coll_name+").");
    8989        printUsage();
    9090        return;
    91     } else if (process_mode == CollectionConstructor.NEW &&
     91    } else if (process_mode == GS2PerlConstructor.NEW &&
    9292           coll_dir.exists()) {
    9393        System.out.println("ERROR: there is already a collection named "+coll_name);
     
    9898   
    9999    ConstructCollection processor = new ConstructCollection();
    100     CollectionConstructor constructor = new GS2PerlConstructor("perl_build");
     100    GS2PerlConstructor constructor = new GS2PerlConstructor("perl_build");
    101101    if (!constructor.configure()) {
    102102        System.out.println("couldn't configure the constructor!!");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java

    r3984 r4852  
    1919public class GS2PerlConstructor
    2020    extends CollectionConstructor {
     21
     22    public static final int NEW = 0;
     23    public static final int IMPORT = 1;
     24    public static final int BUILD = 2;
     25    public static final int ACTIVATE = 3;
    2126
    2227    /** gsdlhome for greenstone 2 - we use the perl modules and building
     
    5661    }
    5762
     63    public void run() {
     64    String msg;
     65    ConstructionEvent evt;
     66    if (process_type_ == -1) {
     67        msg = "Error: you must set the action type";
     68        evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
     69        sendMessage(evt);
     70        return;
     71    }
     72    if (site_home_==null) {
     73        msg = "Error: you must set site_home";
     74        evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
     75        sendMessage(evt);
     76        return;
     77    }
     78    if (process_type_ != NEW && collection_name_ ==null) {
     79        msg = "Error: you must set collection_name";
     80        evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
     81        sendMessage(evt);
     82        return;
     83    }
     84   
     85    switch (process_type_) {
     86    case NEW:
     87        newCollection();
     88        break;
     89    case IMPORT:
     90        importCollection();
     91        break;
     92    case BUILD:
     93        buildCollection();
     94        break;
     95    case ACTIVATE:
     96        activateCollection();
     97        break;
     98    default:
     99        msg = "wrong type of action specified!";
     100        evt = new ConstructionEvent(this, GSStatus.ERROR, msg);
     101        sendMessage(evt);
     102        break;
     103    }
     104
     105    }
     106
    58107    protected void newCollection() {
    59108    sendMessage(new ConstructionEvent(this, GSStatus.INFO, "Collection construction: new collection."));
Note: See TracChangeset for help on using the changeset viewer.