Mercurial > repos > ganjoo > webservice_toolsuite
comparison WebServiceToolWorkflow/generateClient1.py @ 0:d5cd409b8a18 default tip
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
| author | ganjoo |
|---|---|
| date | Tue, 07 Jun 2011 18:00:50 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d5cd409b8a18 |
|---|---|
| 1 import warnings | |
| 2 | |
| 3 with warnings.catch_warnings(): | |
| 4 warnings.simplefilter("ignore") | |
| 5 import platform | |
| 6 | |
| 7 from jpype._jpackage import JPackage | |
| 8 from jpype import * | |
| 9 import os.path | |
| 10 import sys | |
| 11 import string | |
| 12 from edit_tool_conf1 import * | |
| 13 | |
| 14 class ClientGenerator1(object): | |
| 15 | |
| 16 #instantiate a client for one time invocation of the selected method of a Web service | |
| 17 def __init__(self,url,methodName,resourceName,fileName): | |
| 18 self.methodName = methodName | |
| 19 self.resourceName=resourceName | |
| 20 self.Ofile = fileName | |
| 21 #replace '__tilda__' with '~' | |
| 22 if(url.find('__tilda__')>-1): | |
| 23 ulist = url.split('__tilda__') | |
| 24 url = '~'.join(ulist) | |
| 25 self.url = url | |
| 26 | |
| 27 #replace '**' with ' ' | |
| 28 def formatString(self,string): | |
| 29 l = string.split(' ') | |
| 30 return '**'.join(l) | |
| 31 | |
| 32 #generates a xml describing a client capable of invoking a Web service described | |
| 33 #using a WADL document. Places this xml tool under ./clients/ | |
| 34 def wadlClient(self): | |
| 35 ##parse wadl | |
| 36 #javahome = os.environ.get('JAVA_HOME') | |
| 37 #galaxyhome=os.environ.get('GALAXY_HOME') | |
| 38 #classpath= galaxyhome + '/tools/WebServiceToolWorkflow/ParserForWADL/bin' | |
| 39 #jarpath = galaxyhome + '/tools/WebServiceToolWorkflow/ParserForWADL/lib/' | |
| 40 #machine = platform.machine() | |
| 41 | |
| 42 #if machine == 'x86_64' : | |
| 43 # print 'a' | |
| 44 # startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 45 #elif machine == 'i686' : | |
| 46 # print 'b' | |
| 47 # startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 48 #elif machine == 'sun4u' : | |
| 49 # startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 50 #else : | |
| 51 # print 'c' | |
| 52 # System.exit("Could not identify machine, please specify path to libjvm.so") | |
| 53 | |
| 54 | |
| 55 pkg=JPackage('lsdis') | |
| 56 urlToPass=java.net.URL(self.url) | |
| 57 wadlUrl = self.url | |
| 58 | |
| 59 webserviceId = self.methodName | |
| 60 resUrl = self.resourceName | |
| 61 | |
| 62 urls = [] | |
| 63 methods = [] | |
| 64 params = [] | |
| 65 docs = [] | |
| 66 | |
| 67 WADLParserDriver=pkg.WADLParserDriver | |
| 68 wPD=WADLParserDriver() | |
| 69 wPD.parse(urlToPass) | |
| 70 urls = wPD.getUrl() | |
| 71 methods = wPD.getCompleteMethodList() | |
| 72 | |
| 73 #write into the output file information about the method and Web service to be invoked. | |
| 74 f=open(self.Ofile,'w') | |
| 75 f.write(wadlUrl) | |
| 76 f.write('\n'+ resUrl) | |
| 77 f.write('\n'+webserviceId) | |
| 78 | |
| 79 | |
| 80 #get parameters for the selected method of the Web service | |
| 81 i=0 | |
| 82 for method in methods: | |
| 83 f.write('in for loop') | |
| 84 x = str(method.getId()) | |
| 85 y = str(urls.get(i)) | |
| 86 if x == webserviceId : | |
| 87 f.write('method matched') | |
| 88 if y == resUrl : | |
| 89 f.write('res matched') | |
| 90 params = method.getRequest().getParams() | |
| 91 break | |
| 92 i=i+1 | |
| 93 | |
| 94 galaxyhome=os.environ.get('GALAXY_HOME') | |
| 95 | |
| 96 #./clients/ClientCount.xml keeps the count of the clients/tools currently registered in Galaxy for Web service invocation. | |
| 97 #read the count and increment it. | |
| 98 clientCountFile=open(galaxyhome+'/tools/WebServiceToolWorkflow/clients/ClientCount.xml','r') | |
| 99 clientCountFile.readline() | |
| 100 clientCountStr = clientCountFile.read(1) | |
| 101 clientCount=string.atoi(clientCountStr) | |
| 102 clientCount=clientCount+1 | |
| 103 clientCountFile.close() | |
| 104 | |
| 105 clientCountFile=open(galaxyhome+'/tools/WebServiceToolWorkflow/clients/ClientCount.xml','w') | |
| 106 | |
| 107 clientCountFile.write('<count> \n') | |
| 108 clientCountFile.write(str(clientCount)) | |
| 109 clientCountFile.write('</count> \n') | |
| 110 | |
| 111 #include the count in the tool's name and id to uniquely identify it. | |
| 112 clientName = 'client_'+ str(clientCount) | |
| 113 | |
| 114 #create a new xml file under ./clients/ | |
| 115 clientXml=open(galaxyhome+'/tools/WebServiceToolWorkflow/clients/'+clientName+'.xml','w') | |
| 116 clientXml.seek(0,0) | |
| 117 | |
| 118 #write the tool id, name and description | |
| 119 clientXml.write('<tool id="' + clientName+'1" name="' + self.methodName +' ">\n') | |
| 120 clientXml.write(' <description> Client for method: '+self.methodName+' , Web service: '+self.url+' </description>\n') | |
| 121 | |
| 122 #the one-time invocation tool/client for a REST Web service invokes ./clients/client_1.py to invoke the Web service | |
| 123 #write the command tag to specify the arguments passed to this client_1.py | |
| 124 clientXml.write(' <command interpreter="python">\n #if $cond_source.optional_param_source=="no" #client_1.py'+' $output ' +resUrl) | |
| 125 | |
| 126 j=0 | |
| 127 | |
| 128 for param in params: | |
| 129 if param.isRequired(): | |
| 130 clientXml.write(' '+self.formatString(param.getName())) | |
| 131 clientXml.write(' $param' + str(j)) | |
| 132 j=j+1 | |
| 133 clientXml.write(' #else #client_1.py'+' $output ' +resUrl) | |
| 134 j=0 | |
| 135 for param in params: | |
| 136 if param.isRequired(): | |
| 137 clientXml.write(' '+self.formatString(param.getName())) | |
| 138 clientXml.write(' $param' + str(j)) | |
| 139 j=j+1 | |
| 140 | |
| 141 for param in params: | |
| 142 if not param.isRequired(): | |
| 143 clientXml.write(' '+self.formatString(param.getName())) | |
| 144 clientXml.write(' $cond_source.param' + str(j)) | |
| 145 j=j+1 | |
| 146 clientXml.write(' #end if \n</command>\n') | |
| 147 | |
| 148 #start writing inputs | |
| 149 clientXml.write(' <inputs>\n') | |
| 150 | |
| 151 #create a param for each required parameter described in the WADL. Check if defaults and options are specified in the WADL | |
| 152 j=0 | |
| 153 for param in params: | |
| 154 if param.isRequired(): | |
| 155 pName = param.getName() | |
| 156 for doc in param.getDocs(): | |
| 157 if doc.getTitle()=="prompt" or doc.getTitle()=="Prompt" or doc.getTitle()=="PROMPT": | |
| 158 pName = doc.getInnerText() | |
| 159 if param.getOptions().size()==0: | |
| 160 clientXml.write('<param format="text" size = "150" name = "param'+str(j)+'" ') | |
| 161 if not param.getDefault1() == None: | |
| 162 clientXml.write('value="'+param.getDefault1()+'" ') | |
| 163 clientXml.write('type="text" label="Enter '+pName+'" help="see tip below" />\n') | |
| 164 j=j+1 | |
| 165 else: | |
| 166 clientXml.write('<param name="param'+str(j)+'" type="select" label="Select '+pName+'" help="see tip below">\n' ) | |
| 167 for option in param.getOptions(): | |
| 168 clientXml.write(' <option value="'+self.formatString(option.getName())+'" ') | |
| 169 if option.getName() == param.getDefault1(): | |
| 170 clientXml.write('selected="true"') | |
| 171 clientXml.write('>'+option.getName()+'</option>\n ') | |
| 172 clientXml.write(' </param> \n') | |
| 173 j=j+1 | |
| 174 | |
| 175 #create a conditional param for each optional parameter described in the WADL. | |
| 176 clientXml.write('\n <conditional name="cond_source"> \n <param name="optional_param_source" type="select" label="Show Additional Parameters">\n <option value="no" selected="true">no</option> \n <option value="yes">yes</option> \n </param>\n') | |
| 177 clientXml.write('<when value="no"> \n </when>') | |
| 178 clientXml.write('<when value="yes"> \n') | |
| 179 for param in params: | |
| 180 if not param.isRequired(): | |
| 181 pName = param.getName() | |
| 182 for doc in param.getDocs(): | |
| 183 if doc.getTitle()=="prompt" or doc.getTitle()=="Prompt" or doc.getTitle()=="PROMPT": | |
| 184 pName = doc.getInnerText() | |
| 185 if param.getOptions().size()==0: | |
| 186 clientXml.write('<param format="text" size = "150" name = "param'+str(j)+'" ') | |
| 187 if not param.getDefault1() == None: | |
| 188 clientXml.write('value="'+param.getDefault1()+'" ') | |
| 189 clientXml.write('type="text" label="Enter '+pName+'" help="see tip below" />\n') | |
| 190 j=j+1 | |
| 191 else: | |
| 192 clientXml.write('<param name="param'+str(j)+'" type="select" label="Select '+pName+'" help="see tip below">\n' ) | |
| 193 for option in param.getOptions(): | |
| 194 clientXml.write(' <option value="'+self.formatString(option.getName())+'" ') | |
| 195 if option.getName() == param.getDefault1(): | |
| 196 clientXml.write('selected="true"') | |
| 197 clientXml.write('>'+option.getName()+'</option>\n ') | |
| 198 clientXml.write(' </param> \n') | |
| 199 j=j+1 | |
| 200 | |
| 201 | |
| 202 clientXml.write('</when>\n</conditional>') | |
| 203 clientXml.write('</inputs>\n <outputs>\n <data format="tabular" name="output" />\n </outputs>\n') | |
| 204 | |
| 205 #write information about each parameter in the help section | |
| 206 clientXml.write(' <help>\n') | |
| 207 | |
| 208 clientXml.write('Replace white space with ** in all parameter values\n') | |
| 209 | |
| 210 for param in params: | |
| 211 if param.isRequired(): | |
| 212 pName = param.getName() | |
| 213 for doc in param.getDocs(): | |
| 214 if doc.getTitle()=="prompt" or doc.getTitle()=="Prompt" or doc.getTitle()=="PROMPT": | |
| 215 pName = doc.getInnerText() | |
| 216 clientXml.write('\n.. class:: infomark\n\n**TIP:** '+ pName +' type is ' + param.getType()+'\n') | |
| 217 | |
| 218 clientXml.write(' </help>\n</tool>') | |
| 219 | |
| 220 #adds the newly created tool to tool_conf.xml in Galaxy under the 'Web Service Tools' section. | |
| 221 editor = editToolConfig1() | |
| 222 editor.addTool(clientName) | |
| 223 | |
| 224 ##later add help feature | |
| 225 | |
| 226 def sawadlClient(self): | |
| 227 ##parse sawadl | |
| 228 javahome = os.environ.get('JAVA_HOME') | |
| 229 galaxyhome=os.environ.get('GALAXY_HOME') | |
| 230 classpath= galaxyhome + '/tools/WebServiceTool/lib/SAWADLParser/bin' | |
| 231 jarpath = galaxyhome + '/tools/WebServiceTool/lib/' | |
| 232 machine = platform.machine() | |
| 233 | |
| 234 #if machine == 'x86_64' : | |
| 235 # print 'a' | |
| 236 # startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 237 #elif machine == 'i686' : | |
| 238 # print 'b' | |
| 239 # startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 240 #elif machine == 'sun4u' : | |
| 241 # startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 242 #else : | |
| 243 # print 'c' | |
| 244 # System.exit("Could not identify machine, please specify path to libjvm.so") | |
| 245 | |
| 246 | |
| 247 pkg=JPackage('edu.uga.cs.lsdis.meteors.wadls') | |
| 248 pkgModel =JPackage('org.semanticweb.owlapi.model') | |
| 249 pkgApiBinding =JPackage('org.semanticweb.owlapi.apibinding') | |
| 250 pkgVocab = JPackage('org.semanticweb.owlapi.vocab') | |
| 251 | |
| 252 DOCUMENT_IRI = "http://cs.uga.edu/~ganjoo/galaxy/EDAM.owl" | |
| 253 | |
| 254 sawadlUrl = self.url | |
| 255 | |
| 256 webserviceId = self.methodName | |
| 257 resUrl = self.resourceName | |
| 258 | |
| 259 urls = [] | |
| 260 methods = [] | |
| 261 params = [] | |
| 262 annotationSet = [] | |
| 263 | |
| 264 SAWADLParserDriver=pkg.SAWADLParserDriver | |
| 265 sawPD=SAWADLParserDriver() | |
| 266 sawPD.parse(sawadlUrl) | |
| 267 urls = sawPD.getUrl() | |
| 268 methods = sawPD.getCompleteMethodList() | |
| 269 | |
| 270 IRI = pkgModel.IRI | |
| 271 OWLRDFVocabulary = pkgVocab.OWLRDFVocabulary | |
| 272 OWLManager = pkgApiBinding.OWLManager | |
| 273 OWLLiteral = pkgModel.OWLLiteral | |
| 274 owlOntManager = OWLManager.createOWLOntologyManager() | |
| 275 ontology = owlOntManager.loadOntologyFromOntologyDocument(IRI.create(DOCUMENT_IRI)) | |
| 276 dataFactory = owlOntManager.getOWLDataFactory() | |
| 277 propertyComment = dataFactory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI()) | |
| 278 | |
| 279 f=open(self.Ofile,'w') | |
| 280 f.write(sawadlUrl) | |
| 281 f.write('\n'+ resUrl) | |
| 282 f.write('\n'+webserviceId) | |
| 283 | |
| 284 | |
| 285 i=0 | |
| 286 for method in methods: | |
| 287 x = str(method.getName()) | |
| 288 y = str(urls.get(i)) | |
| 289 if x == webserviceId : | |
| 290 f.write('method matched') | |
| 291 if y == resUrl : | |
| 292 f.write('res matched') | |
| 293 params = method.getRequest().getParamList() | |
| 294 break | |
| 295 i=i+1 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 ##generate client's xml | |
| 301 galaxyhome=os.environ.get('GALAXY_HOME') | |
| 302 | |
| 303 clientCountFile=open(galaxyhome+'/tools/WebServiceToolWorkflow/clients/ClientCount.xml','r') | |
| 304 clientCountFile.readline() | |
| 305 clientCountStr = clientCountFile.read(1) | |
| 306 clientCount=string.atoi(clientCountStr) | |
| 307 clientCount=clientCount+1 | |
| 308 clientCountFile.close() | |
| 309 | |
| 310 clientCountFile=open(galaxyhome+'/tools/WebServiceToolWorkflow/clients/ClientCount.xml','w') | |
| 311 clientCountFile.write('<count> \n') | |
| 312 clientCountFile.write(str(clientCount)) | |
| 313 clientCountFile.write('</count> \n') | |
| 314 | |
| 315 clientName = 'client_'+ str(clientCount) | |
| 316 | |
| 317 clientXml=open(galaxyhome+'/tools/WebServiceToolWorkflow/clients/'+clientName+'.xml','w') | |
| 318 clientXml.seek(0,0) | |
| 319 | |
| 320 clientXml.write('<tool id="' + clientName+'1" name="' + self.methodName +'">\n') | |
| 321 clientXml.write(' <description> Client for method: '+self.methodName+' , Web service: '+self.url+' </description>\n') | |
| 322 | |
| 323 | |
| 324 clientXml.write(' <command interpreter="python">\n #if $cond_source.optional_param_source=="no" #client_1.py'+' $output ' +resUrl) | |
| 325 ##write such that the parameters passed to client1.py(change name to clientName.py) are dependent on a for loop | |
| 326 | |
| 327 | |
| 328 j=0 | |
| 329 for param in params: | |
| 330 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE': | |
| 331 clientXml.write(' '+self.formatString(param.getName())+'\n') | |
| 332 clientXml.write(' $param' + str(j)+'\n') | |
| 333 j=j+1 | |
| 334 | |
| 335 clientXml.write(' #else #client_1.py'+' $output ' +resUrl) | |
| 336 j=0 | |
| 337 for param in params: | |
| 338 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE': | |
| 339 clientXml.write(' '+self.formatString(param.getName())) | |
| 340 clientXml.write(' $param' + str(j)) | |
| 341 j=j+1 | |
| 342 | |
| 343 for param in params: | |
| 344 if not param.getRequired()=='true' and not param.getRequired()=='True' and not param.getRequired()=='TRUE': | |
| 345 clientXml.write(' '+self.formatString(param.getName())) | |
| 346 clientXml.write(' $cond_source.param' + str(j)) | |
| 347 j=j+1 | |
| 348 | |
| 349 clientXml.write('#end if \n </command>\n') | |
| 350 | |
| 351 ##write inputs depending on required or not. if not required den dont display | |
| 352 ##if required- den check default value, and if options exist.Depending on that | |
| 353 ##decide the type of parameter and options | |
| 354 clientXml.write(' <inputs>\n') | |
| 355 | |
| 356 j=0 | |
| 357 for param in params: | |
| 358 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE': | |
| 359 f.write('\n '+ param.getName() + ' options: '+str(param.getOptionvalue().size())) | |
| 360 if param.getOptionvalue().size()==0: | |
| 361 clientXml.write('<param format="text" size = "150" name = "param'+str(j)+'" ') | |
| 362 if not param.getDefault1() == None: | |
| 363 clientXml.write('value="'+param.getDefault1()+'" ') | |
| 364 clientXml.write('type="text" label="Enter '+param.getName()+'" help="see tip below" />\n') | |
| 365 j=j+1 | |
| 366 else: | |
| 367 clientXml.write('<param name="param'+str(j)+'" type="select" label="Select '+param.getName()+'" help="see tip below">\n' ) | |
| 368 for option in param.getOptionvalue(): | |
| 369 clientXml.write(' <option value="'+self.formatString(option)+'" ') | |
| 370 if option == param.getDefault1(): | |
| 371 clientXml.write('selected="true"') | |
| 372 clientXml.write('>'+option+'</option>\n ') | |
| 373 clientXml.write(' </param> \n') | |
| 374 j=j+1 | |
| 375 | |
| 376 | |
| 377 clientXml.write('\n <conditional name="cond_source"> \n <param name="optional_param_source" type="select" label="Display Additional Parameters">\n <option value="no" selected="true">no</option> \n <option value="yes">yes</option> \n </param>\n') | |
| 378 clientXml.write('<when value="no"> \n </when>') | |
| 379 clientXml.write('<when value="yes"> \n') | |
| 380 | |
| 381 for param in params: | |
| 382 if not param.getRequired()=='true' and not param.getRequired()=='True' and not param.getRequired()=='TRUE': | |
| 383 f.write('\n '+ param.getName() + ' options: '+str(param.getOptionvalue().size())) | |
| 384 if param.getOptionvalue().size()==0: | |
| 385 clientXml.write('<param format="text" size = "150" name = "param'+str(j)+'" ') | |
| 386 if not param.getDefault1() == None: | |
| 387 clientXml.write('value="'+param.getDefault1()+'" ') | |
| 388 clientXml.write('type="text" label="Enter '+param.getName()+'" help="see tip below" />\n') | |
| 389 j=j+1 | |
| 390 else: | |
| 391 clientXml.write('<param name="param'+str(j)+'" type="select" label="Select '+param.getName()+'" help="see tip below">\n' ) | |
| 392 for option in param.getOptionvalue(): | |
| 393 clientXml.write(' <option value="'+self.formatString(option)+'" ') | |
| 394 if option == param.getDefault1(): | |
| 395 clientXml.write('selected="true"') | |
| 396 clientXml.write('>'+option+'</option>\n ') | |
| 397 clientXml.write(' </param> \n') | |
| 398 j=j+1 | |
| 399 | |
| 400 clientXml.write('</when>\n</conditional>\n') | |
| 401 | |
| 402 clientXml.write('</inputs>\n <outputs>\n <data format="tabular" name="output" />\n </outputs>\n') | |
| 403 | |
| 404 clientXml.write(' <help>\n') | |
| 405 for param in params: | |
| 406 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE': | |
| 407 clientXml.write('\n.. class:: infomark\n\n**TIP:** About '+ param.getName() +': type is ' + param.getType()) | |
| 408 | |
| 409 modelRef = sawPD.getCompleteModelReference(param) | |
| 410 if not modelRef is None: | |
| 411 paramClass = dataFactory.getOWLClass(IRI.create(modelRef)); | |
| 412 annotationSet = paramClass.getAnnotations(ontology,propertyComment) | |
| 413 for annotation in annotationSet: | |
| 414 if isinstance(annotation.getValue(),OWLLiteral): | |
| 415 val = annotation.getValue() | |
| 416 if val.isOWLStringLiteral() and not val.isOWLTypedLiteral(): | |
| 417 print 'val.getLiteral()=' + val.getLiteral() | |
| 418 clientXml.write(', description from ontology is "' + val.getLiteral()+'"') | |
| 419 break | |
| 420 clientXml.write('\n') | |
| 421 clientXml.write(' </help>\n</tool>') | |
| 422 editor = editToolConfig1() | |
| 423 editor.addTool(clientName) | |
| 424 | |
| 425 ##later add help feature | |
| 426 | |
| 427 def wsdlClient(self): | |
| 428 ##parse wadl | |
| 429 javahome = os.environ.get('JAVA_HOME') | |
| 430 galaxyhome=os.environ.get('GALAXY_HOME') | |
| 431 classpath= galaxyhome + '/tools/WebServiceTool/WodenWSDLParser/bin' | |
| 432 jarpath = galaxyhome + '/tools/WebServiceTool/WodenWSDLParser/lib/' | |
| 433 machine = platform.machine() | |
| 434 | |
| 435 if machine == 'x86_64' : | |
| 436 print 'a' | |
| 437 startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 438 elif machine == 'i686' : | |
| 439 print 'b' | |
| 440 startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 441 elif machine == 'sun4u' : | |
| 442 startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath) | |
| 443 else : | |
| 444 print 'c' | |
| 445 System.exit("Could not identify machine, please specify path to libjvm.so") | |
| 446 | |
| 447 | |
| 448 pkg=JPackage('lsdis') | |
| 449 wsdlUrl = self.url | |
| 450 | |
| 451 webserviceId = self.methodName | |
| 452 resUrl = self.resourceName | |
| 453 | |
| 454 urls = [] | |
| 455 methods = [] | |
| 456 params = [] | |
| 457 paramTypes = [] | |
| 458 | |
| 459 WSDLParserDriver =pkg.WSDLParserDriver | |
| 460 wPD=WSDLParserDriver() | |
| 461 wPD.parse(wsdlUrl) | |
| 462 methods = wPD.getCompleteMethodList() | |
| 463 urls = wPD.getUrl() | |
| 464 | |
| 465 f=open(self.Ofile,'w') | |
| 466 f.write(wsdlUrl) | |
| 467 f.write('\n'+ resUrl) | |
| 468 f.write('\n'+webserviceId) | |
| 469 | |
| 470 | |
| 471 i=0 | |
| 472 for method in methods: | |
| 473 x = str(method.getName().getLocalPart()) | |
| 474 if x == webserviceId : | |
| 475 wPD.getParameters(x) | |
| 476 f.write('method matched') | |
| 477 paramTypes = wPD.getParamTypeList() | |
| 478 params = wPD.getParamList() | |
| 479 break | |
| 480 i=i+1 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 ##generate client's xml | |
| 486 galaxyhome=os.environ.get('GALAXY_HOME') | |
| 487 | |
| 488 clientCountFile=open(galaxyhome+'/tools/WebServiceTool/clients/ClientCount.xml','r') | |
| 489 clientCountFile.readline() | |
| 490 clientCountStr = clientCountFile.read(1) | |
| 491 clientCount=string.atoi(clientCountStr) | |
| 492 clientCount=clientCount+1 | |
| 493 clientCountFile.close() | |
| 494 | |
| 495 clientCountFile=open(galaxyhome+'/tools/WebServiceTool/clients/ClientCount.xml','w') | |
| 496 clientCountFile.write('<count> \n') | |
| 497 clientCountFile.write(str(clientCount)) | |
| 498 clientCountFile.write('</count> \n') | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 clientName = 'client_'+ str(clientCount) | |
| 504 | |
| 505 clientXml=open(galaxyhome+'/tools/WebServiceTool/clients/'+clientName+'.xml','w') | |
| 506 clientXml.seek(0,0) | |
| 507 | |
| 508 clientXml.write('<tool id="' + clientName+'" name="' + self.methodName +'">\n') | |
| 509 clientXml.write(' <description> Client for method: '+self.methodName+' , Web service: '+self.url+' </description>\n') | |
| 510 | |
| 511 | |
| 512 clientXml.write(' <command interpreter="python">\n client_1.py \n'+' $output \n ' +resUrl+'\n') | |
| 513 ##write such that the parameters passed to client1.py(change name to clientName.py) are dependent on a for loop | |
| 514 | |
| 515 j=0 | |
| 516 for param in params: | |
| 517 clientXml.write(' '+self.formatString(param)+'\n') | |
| 518 clientXml.write(' $param' + str(j)+'\n') | |
| 519 j=j+1 | |
| 520 clientXml.write('</command>\n') | |
| 521 | |
| 522 ##write inputs depending on required or not. if not required den dont display | |
| 523 ##if required- den check default value, and if options exist.Depending on that | |
| 524 ##decide the type of parameter and options | |
| 525 clientXml.write(' <inputs>\n') | |
| 526 | |
| 527 j=0 | |
| 528 for param in params: | |
| 529 clientXml.write('<param format="text" size = "150" name = "param'+str(j)+'" ') | |
| 530 clientXml.write('type="text" label="'+param+'" help="see tip below" />\n') | |
| 531 j=j+1 | |
| 532 | |
| 533 | |
| 534 | |
| 535 clientXml.write('</inputs>\n <outputs>\n <data format="tabular" name="output" />\n </outputs>\n') | |
| 536 | |
| 537 clientXml.write(' <help>\n') | |
| 538 | |
| 539 clientXml.write('** Replace white with ** in all parameter values **\n') | |
| 540 | |
| 541 j=0 | |
| 542 for param in params: | |
| 543 clientXml.write('\n.. class:: infomark\n\n**TIP:** '+ param +' type is ' + paramTypes[j] +'\n') | |
| 544 | |
| 545 clientXml.write(' </help>\n</tool>') | |
| 546 editor = editToolConfig() | |
| 547 editor.addTool(clientName) | |
| 548 | |
| 549 ##later add help feature |
