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