/*  XspanSoapClient.java version 1 * *  Copyright (c) all rights reserved xspan.org, december 2004  */package org.xspan.client;import org.xspan.webService.*;import java.util.Vector;import java.io.*;/** * Class to test the XSPAN axis webservice access * * @author kcm, xspan.org */public class XspanSoapClient {        public XspanSoapClient() {    }	/**	 * will return list of organisms in database	 *	 * @return each element in array will be name of organism in the database	 */    public String[] getOrganisms() {			String answer[] = null;		try {	    	org.xspan.webService.XspanService service =			new org.xspan.webService.XspanServiceLocator();	    	org.xspan.webService.Xspan xs = service.getxspan();      	    	answer = xs.getOrganisms();		} catch (Exception e) { System.out.println(e); e.printStackTrace(); }        return answer;    } // end getSpecies()            /**     * will return the names of the high-level structure mapping types     *     * @return each element in array is a name     */    public String[] getMappingTypes() {		String[] answer = null;		try {		    org.xspan.webService.XspanService service =			new org.xspan.webService.XspanServiceLocator();		    org.xspan.webService.Xspan xs = service.getxspan();      		    answer = xs.getMappingTypes();		} catch (Exception e) { System.out.println(e); e.printStackTrace(); }		return answer;    } // end getMappingTypes        /**     * will return a list of subtypes based on a high-level mapping type from getMappingTypes     *     *@param 	in 	the type you wish the subtypes for, will come from output of     *          	getMappingTypes()     *     * @return 	each element in array is the name of a subtype     */    public String[] getMappingSubTypes(String in) {		String[] answer = {"empty"};		try {		    org.xspan.webService.XspanService service =			new org.xspan.webService.XspanServiceLocator();		    org.xspan.webService.Xspan xs = service.getxspan();      		    answer = xs.getSubMappingTypes(in);	   		} catch (Exception e) { System.out.println(e); e.printStackTrace(); }        return answer;    } // end getMappingSubTypes            /**     * will return the anatomy of the organism you specify     *     * @param 	in 	the name of the organism you want the anatomy for     *     * @return 	an Anatomy object containing the organism's anatomy, look     *         	at wsdl file for details of Anatomy object     */    public org.xspan.webService.Anatomy getAnatomy(String in) {    		org.xspan.webService.Anatomy answer = new org.xspan.webService.Anatomy();		try {		    org.xspan.webService.XspanService service =			new org.xspan.webService.XspanServiceLocator();		    org.xspan.webService.Xspan xs = service.getxspan();      		    answer = xs.getAnatomy(in);   	   		} catch (Exception e) { System.out.println(e); e.printStackTrace(); }        return answer;    } // end getAnatomy            /**     * method to get mappings     *     * @param 	id 			the tissue id you wish to find mappings for eg FBbt:0001234     * @param 	species 	the organism you want to find mappings in. this can be     *        				specified eg "Celegans" or can be "none"     * @param 	type 		the type of mapping you want to search for. this can be     *        				"ALL" or one of the names returned from the getSubMappingTypes     *     * @return 	an array of Mapping objects with each element being a single Mapping between      *			two structures, see wsdl file for more details on Mapping.java     */    public org.xspan.webService.Mapping[] getMapping(String id, String species, String type) {		org.xspan.webService.Mapping[] map = new org.xspan.webService.Mapping[1];		try {	    	org.xspan.webService.XspanService service =			new org.xspan.webService.XspanServiceLocator();	    	org.xspan.webService.Xspan xs = service.getxspan();      	    	map = xs.getMappings(id, species, type);   	   		} catch (Exception e) { System.out.println(e); e.printStackTrace(); }		return map;    } // end getMapping                                   /*      * used to test above methods     */    public static void main(String[] args) {        XspanSoapClient dem = new XspanSoapClient();        	        System.out.println("Test getOrganisms:");        String[] answer = dem.getOrganisms();		System.out.println("Length of answer: "+answer.length);        	for(int i=0; i<answer.length; i++) {	    	System.out.println("  "+answer[i]);		}        System.out.println("\n\n\n ******** \n\n\n");                        System.out.println("Test getMappingTypes:");        answer = dem.getMappingTypes();        for(int i=0; i<answer.length; i++) {            System.out.println("Type " + (i+1) + ": " + answer[i]);        }                System.out.println("\n\n\n ******** \n\n\n");                            System.out.println("Test getSubMappingTypes(Expert):");        answer = dem.getMappingSubTypes("Expert");        for(int i=0; i<answer.length; i++) {            System.out.println("SubType " + (i+1) + ": " + answer[i]);        }                System.out.println("Test getSubMappingTypes(Derived):");        answer = dem.getMappingSubTypes("Derived");        for(int i=0; i<answer.length; i++) {            System.out.println("SubType " + (i+1) + ": " + answer[i]);        }                System.out.println("\n\n\n ******** \n\n\n");   				System.out.println("query(WBdag:0005775, ALL,  ALL)");        m = dem.getMapping("WBdag:0005775", "ALL",  "ALL");        for(int i=0; i<m.length; i++) {            org.xspan.webService.Mapping m2 = m[i];            System.out.println("Mapping " + (i+1) +":");            System.out.println("  Tissue1: "+m2.getTissueId1()+" : "+m2.getTissueName1()+":"+m2.getOrganism1());	    System.out.println("  Tissue2: "+m2.getTissueId2()+" : "+m2.getTissueName2()+":"+m2.getOrganism2());	    System.out.println("  Mapping: "+m2.getMapName()+" : "+m2.getMapType());	    System.out.println("           "+m2.getCreator()+" : "+m2.getDate());	    System.out.println("           "+m2.getDefn()+" : "+m2.getMappingId());        }			System.out.println("\n\n\n ******** \n\n\n"); 	        		System.out.println("getAnatomy(Abstract Mouse)");		org.xspan.webService.Anatomy an = dem.getAnatomy("Abstract Mouse");		org.xspan.webService.Tissue[] tAll = an.getTissues();		org.xspan.webService.TissueRelationship[] rAll = an.getRelationships();		System.out.println("  tissues:");		for(int i=0; i<tAll.length; i++) {		    org.xspan.webService.Tissue t = tAll[i];		    System.out.println("    "+t.getId()+" "+t.getName()+" "+t.getOrganism());		}		System.out.println("  relationships:");		for(int i=0; i<rAll.length; i++) {	    	org.xspan.webService.TissueRelationship r = rAll[i];	    	System.out.println("    "+r.getTissueId1()+" "+r.getTissueId2()+" "+r.getRelationship());		}			            } // end main             } // end XspanClient
