// MabuhayClient2.java
//
//    Created: August 2005
//
// This file is a component of the BioMoby project.
// Copyright Martin Senger (martin.senger@gmail.com).
//

package org.jmoby.tutorial.client;

import org.biomoby.client.BaseCmdLineClient;
import org.biomoby.shared.MobyException;
import org.biomoby.shared.parser.MobyPackage;
import org.biomoby.shared.parser.MobyJob;
import org.biomoby.shared.datatypes.MobyObject;
import org.biomoby.shared.datatypes.*;

/**
 * This is an example of a client. It calls a Biomoby service
 * Mabuhay. It shows how to extend a general command-line client to
 * keep all its features, but add some own features (in this case it
 * is a better formatting of the output. <p>
 *
 * @author <A HREF="mailto:martin.senger@gmail.com">Martin Senger</A>
 * @version $Id: MabuhayClient2.java,v 1.1 2005/08/29 13:22:00 senger Exp $
 */

public class MabuhayClient2
    extends BaseCmdLineClient {

    /**************************************************************************
     * Constructor. Pass everything to the parent.
     *************************************************************************/
    public MabuhayClient2 (String[] args) {
	super (args);
    }

    /**************************************************************************
     * An entry point - again, pass everything to the parent.
     *************************************************************************/
    public static void main (String [] args) {
	new MabuhayClient2 (args).doEverything();
    }

    /**************************************************************************
     * Here is your job done: print the result better than the parent.
     *************************************************************************/
    public boolean useResponse (MobyJob response,
				MobyPackage responseContext)
	throws MobyException {
	System.out.println ("Results of job: " + response.getId());
	MobyObject[] results = response.getDataSet();
	for (int i = 0; i < results.length; i++) {
	    simple_key_value_pair pair = (simple_key_value_pair)results[i];
	    System.out.println (pair.get_key() + "\t" + pair.get_the_value());
	}
	return true;
    }

}
