package org.flymine.dataconversion;

/*
 * Copyright (C) 2002-2003 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import java.io.File;

import org.flymine.sql.Database;
import org.flymine.sql.DatabaseFactory;
import org.flymine.metadata.Model;
import org.flymine.objectstore.ObjectStoreWriterFactory;
import org.flymine.objectstore.ObjectStoreWriter;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;

import org.apache.log4j.Logger;

/**
 * Initiates retrieval and conversion of data from a source database
 *
 * @author Andrew Varley
 * @author Mark Woodbridge
 */
public class DBRetrieverTask extends Task
{
    protected static final Logger LOG = Logger.getLogger(DBRetrieverTask.class);

    protected String database;
    protected String model;
    protected String osName;
    protected File destFile;

    /**
     * Set the database name
     * @param database the database name
     */
    public void setDatabase(String database) {
        this.database = database;
    }

    /**
     * Set the model name
     * @param model the model name
     */
    public void setModel(String model) {
        this.model = model;
    }

    /**
     * Set the objectstore name
     * @param osName the model name
     */
    public void setOsName(String osName) {
        this.osName = osName;
    }

    /**
     * Set the destination file
     * @param destFile the destination file
     */
    public void setDestFile(File destFile) {
        this.destFile = destFile;
    }

    /**
     * Run the task
     * @throws BuildException if a problem occurs
     */
    public void execute() throws BuildException {
        if (database == null) {
            throw new BuildException("database attribute is not set");
        }
        if (model == null) {
            throw new BuildException("model attribute is not set");
        }
        if (destFile == null) {
            throw new BuildException("destFile attribute is not set");
        }

        try {
            Database db = DatabaseFactory.getDatabase(database);
            Model m = Model.getInstanceByName(model);
            ObjectStoreWriter osw = ObjectStoreWriterFactory.getObjectStoreWriter(osName);
            new DBConverter(m, db,
                            new BufferedItemWriter(
                                                   new ObjectStoreItemWriter(osw))).process();
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }
}

@@ -1027,37 +1027,8 @@
 ame;
-%0A    protected File destFile;
 %0A%0A  
@@ -1520,186 +1520,8 @@
  %7D%0A%0A
-    /**%0A     * Set the destination file%0A     * @param destFile the destination file%0A     */%0A    public void setDestFile(File destFile) %7B%0A        this.destFile = destFile;%0A    %7D%0A%0A
     
@@ -1786,32 +1786,32 @@
 odel == null) %7B%0A
+
             thro
@@ -1875,121 +1875,8 @@
    %7D
-%0A        if (destFile == null) %7B%0A            throw new BuildException(%22destFile attribute is not set%22);%0A        %7D
 %0A%0A  

Remove destFile parameter