package de.mpg.mpiz_koeln.featureClient.test;

import java.util.Collection;

import org.biomoby.shared.MobyException;
import org.biomoby.shared.MobyService;
import org.biomoby.shared.datatypes.MobyObject;

import de.mpg.mpiz_koeln.featureClient.FeatureClient;
import de.mpg.mpiz_koeln.featureClient.FeatureClientException;
import de.mpg.mpiz_koeln.featureClient.FeatureClientResult;

/**
 * This example shows how to call more service one with one input.
 */
class SingleMultiServiceCall {
    public static void main( String[] args ) throws FeatureClientException, MobyException {
        FeatureClient client = new FeatureClient();
        client.setTimeout( 30 );
        // add the first service to the client which shall be called
        client.addService( "getPMCIDsByAGI" );
        // add the second service
        client.addService( "Locus2Publications" );

        // set the input of the service
        client.setSingleCallInput( "AGI_LocusCode", "AT1G12000" );

        // call the service
        Collection< FeatureClientResult > result = client.call();

        for ( FeatureClientResult mobyServiceResult : result ) {
            // you can get which service returned the current result
            MobyService mobyService = mobyServiceResult.getMobyService();

            System.out.println( "The service " + mobyService.getName() + " returned:" );

            // prints out the result of the service
            Collection< MobyObject > objects = mobyServiceResult.getSingleCallResult();
            for ( MobyObject mobyObject : objects ) {
                System.out.println( mobyObject.getId() );
            }
        }
        System.exit( 0 );
    }
}
