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