[MOBY-guts] biomoby commit
michael ng
mng at pub.open-bio.org
Fri Aug 26 20:55:13 UTC 2005
mng
Fri Aug 26 16:55:13 EDT 2005
Update of /home/repository/moby/moby-live/Accessories
In directory pub.open-bio.org:/tmp/cvs-serv8437
Modified Files:
code-generator0.6.cgi
Log Message:
with new interface and comment
moby-live/Accessories code-generator0.6.cgi,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Accessories/code-generator0.6.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Accessories/code-generator0.6.cgi 2005/08/09 22:23:46 1.3
+++ /home/repository/moby/moby-live/Accessories/code-generator0.6.cgi 2005/08/26 20:55:13 1.4
@@ -7,6 +7,14 @@
#
#********************************************************************************
+#####################################################################################################################################
+#####################################################################################################################################
+
+# Main Function Section
+
+#####################################################################################################################################
+#####################################################################################################################################
+
use strict;
use LWP::UserAgent;
use LWP::Simple;
@@ -160,7 +168,7 @@
$sqlORalgor_rad = "" if (!$sqlORalgor_rad);
$contactEmail = "" if (!$contactEmail) ;
$description = "" if (!$description);
- $directory = "" if (!$directory);
+ $directory = "/moby/moby-live/Perl/MOBY" if (!$directory);
$genORcom = "" if (!$genORcom);
$simORcollInput = "" if (!$simORcollInput);
$simORcollOutput = "" if (!$simORcollOutput);
@@ -256,6 +264,8 @@
my $simORcollOutput_rad_sim_sel = $simORcollOutput eq "SIMPLE" ? " checked" : "";
my $simORcollOutput_rad_coll_sel = $simORcollOutput eq "COLLECTION" ? " checked" : "";
+ my $UI_string = UI_template("1");
+
#Print the HTML form out
print <<HTML_FORM1;
<html>
@@ -272,14 +282,10 @@
javascript_functions();
#style="overflow:hidden"
print <<HTML_FORM2;
- </head>
-
- <body style="overflow:scroll">
- <div align="center">
- <p><font size="+3"><strong>Webservice Properties</strong></font></p>
- <p> </p>
-
- Below are some properties that you have to fill about your webservice. If there is anything you do not understand, just simply put your mouse over the [?] and a short description will appear.<br>
+$UI_string
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ Below are some properties that you have to fill about your webservice.<br>
+ If there is anything you do not understand, click on the [?] and a short description will appear.<br>
Once you have finished filling in this form, click on the 'Next' button to continue.
<p align="left">Please fill in the required fields</p>
@@ -305,7 +311,6 @@
<input type="radio" name="genORcom" id="genORcom" value="serviceInputParser"$genORcom_rad_gen_sel>Objects without Secondary<A HREF="javascript:openHelp('withoutSecondary')">[?]</A></span>
<input type="radio" name="genORcom" id="genORcom" value="complexInputParser"$genORcom_rad_com_sel>Objects with Secondary <A HREF="javascript:openHelp('withSecondary')">[?]</A><br>
<input type="radio" name="simORcollInput" id="simORcollInput" value="SIMPLE"$simORcollInput_rad_sim_sel>Simple <A HREF="javascript:openHelp('simple')">[?]</A>
- <input type="radio" name="simORcollInput" id="simORcollInput" value="COLLECTION"$simORcollInput_rad_coll_sel>Collection <A HREF="javascript:openHelp('collection')">[?]</A>
<br>
<select name="nameSpace" id="nameSpace">
$nameSpace_html
@@ -360,11 +365,11 @@
<td>Location of MOBY directory</td>
<td>
<input name="directory" type="text" id="directory" value="$directory">
- Directory of MOBY Modules (Default: /moby/moby-live/Perl/MOBY) [?]
+ Directory of MOBY Modules <br>(Default: /moby/moby-live/Perl/MOBY) [?]
</td>
</tr>
<tr>
- <td>SQL Query of Algorithm</td>
+ <td>SQL Query or Algorithm</td>
<td>
<div align="left">
<input type="radio" name="sqlORalgor_rad" value="sql"$sqlORalgor_rad_sql_sel>
@@ -379,20 +384,22 @@
<hr>
<table width="50%" align="center">
<tr>
- <td><div align="center"><input type="reset" name="Reset" value="Start Over" align="left"></div></td>
- <td><div align="center"><input type="submit" name="Submit" value="Next" align="right"></div></td>
+ <td><div align="center"><input type="submit" name="Submit" value="Next" align="left"></div></td>
+ <td><div align="center"><input type="reset" name="Reset" value="Reset" align="right"></div></td>
</tr>
</table>
<p align="left"> </p>
<p align="left"> </p>
</form>
</div>
- </body>
- </html>
+ </td></tr>
+</body>
+</html>
HTML_FORM2
}
+
#**********************************************************************************
#
# THIS FUNCTION VALIDATES THE FORM AND CHECKS IF ALL THE VALUES HAVE BEEN ENTERED
@@ -779,25 +786,16 @@
$dbType_html .= ">$dbTypes_option</option>";
}
+ my $UI_string = UI_template("2");
#Print the HTML form out
print <<HTML_FORM;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - Database Properties</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
-
- <body>
- <div align="center">
- <p><font size="+3"><strong>Database Properties</strong></font></p>
- <p> </p>
- Since your have selected your service as an database base SQL service, you are required to enter your database information inorder to make a connection.<br>
- Once you have finished filling in the form click on the 'Next' button to continue.
- <p align="left">Please fill in the required fields</p>
-
+ Since your have selected your service as an database base SQL service, you are required to enter your database information in order to make a connection. Once you have finished filling in the form click on the 'Next' button to continue.<br>
+ <br>
+
<form method="get" action="/cgi-bin/code-generator0.6.cgi">
<input type="hidden" name="properties" value="DBAccess Properties">
-
<input type="hidden" name="serviceType" value="$serviceType">
<input type="hidden" name="objectConsumed" value="$objectConsumed">
<input type="hidden" name="objectProduced" value="$objectProduced">
@@ -858,8 +856,8 @@
<hr>
<table width="50%" align="center">
<tr>
- <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
<td><div align="center"><input type="submit" name="Submit" value="Next"></div></td>
+ <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
</tr>
</table>
<br>
@@ -875,6 +873,145 @@
}
+#***********************************************************************************************************
+#
+# SQL INPUT MAPPING FUNCTION
+# - description: THIS FUNCTION asks users to provide the names of each of the Input Variable
+# Then, we will be associating the Input Parameters' names in the Service URL with the MobyObject id,articels.... so that the MOBY service can retrieve data correctly
+# eg. The Service URL has two inputs, X and Y
+# MobyObject: GO_Term, GO has String called Term AND has string called Definition
+# The user will have to associate "X" with "Term" and "Y" with "Definition"
+#
+#************************************************************************************************************
+sub mapSQLinput{
+
+ my $error_msg = shift;
+ @InParam = shift;
+
+ my $serviceType = $query->param("serviceType");
+ my $objectConsumed = $query->param("objectConsumed");
+ my $objectProduced = $query->param("objectProduced");
+ my $nameSpace = $query->param("nameSpace");
+ my $serviceName = $query->param("serviceName");
+ my $authURI = $query->param("authURI");
+ my $sqlORalgor_rad = $query->param("sqlORalgor_rad");
+ my $contactEmail = $query->param("contactEmail");
+ my $description = $query->param("description");
+ my $directory = $query->param("directory");
+ my $outnameSpace = $query->param("outnameSpace");
+ my $dbType = $query->param("dbType");
+ my $dbInstance = $query->param("dbInstance");
+ my $host_port = $query->param("host_port");
+ my $username = $query->param("username");
+ my $password1 = $query->param("password1");
+ my $password2 = $query->param("password2");
+ my $prefixed = $query->param("prefixed");
+ my $genORcom = $query->param("genORcom");
+ my $simORcollInput = $query->param("simORcollInput");
+ my $simORcollOutput = $query->param("simORcollOutput");
+ my $serviceCode = $query->param("sqlStatement");
+ my $InputParam = $query->param("InputParam");
+
+ #Displaying the different input text boxes for user to type the names of parameters
+
+ for(my $s=0; $s<$InputParam;$s++){
+ push(@InParam, "") if (!$InParam[$s]);
+ }
+
+ my @object_articles_opts = mygetArticles($objectConsumed);
+ my $articles_length = @object_articles_opts;
+
+ #Displaying all the field, id and article names, in a selection box in the right column of the table for mapping purpose
+ my $object_articles_html;
+ foreach my $object_article_option (@object_articles_opts)
+ {
+ $object_articles_html .= "<option value =\"$object_article_option\"";
+ $object_articles_html .= ">$object_article_option</option>";
+ }
+
+ $object_articles_html .= "<option value =\"id\">id</option>";
+ $articles_length += 1;
+
+ my $InputParam_html = "";
+ for(my $i=0; $i<$InputParam;$i++){
+ my $s = $i + 1;
+ $InputParam_html .= " <tr><td>Parameters $s:</td>
+ <td><input type=\"text\" name=\"InputParam$i\" id=\"InputParam$i\" value=\"$InParam[$i]\"></A></td>
+ <td><select name=\"inputobject_articles$i\" id=\"inputobject_articles$i\">". $object_articles_html . "</select></td>
+</tr>";
+ }
+ my $UI_string = UI_template("2");
+
+print <<MAP;
+ $UI_string
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <p><font size="+2"><strong>Mapping your SQL columns with MOBY Object Articles</strong></font></p>
+ For SQL Service, you are required to associate each column in your SQL statement with the corrosponding MOBY object article. Once you have mapped out each column with an article click on the 'Next' button to continue.
+ <br>
+ <p><font color="FF000"> <b>$error_msg</b></font></p>
+ <form method="get" action="/cgi-bin/code-generator0.6.cgi">
+ <input type="hidden" name="properties" value="mapSQLinput">
+ <input type="hidden" name="serviceType" value="$serviceType">
+ <input type="hidden" name="objectConsumed" value="$objectConsumed">
+ <input type="hidden" name="objectProduced" value="$objectProduced">
+ <input type="hidden" name="nameSpace" value="$nameSpace">
+ <input type="hidden" name="serviceName" value="$serviceName">
+ <input type="hidden" name="authURI" value="$authURI">
+ <input type="hidden" name="sqlORalgor_rad" value="$sqlORalgor_rad">
+ <input type="hidden" name="serviceCode" value="$serviceCode">
+ <input type="hidden" name="contactEmail" value="$contactEmail">
+ <input type="hidden" name="description" value="$description">
+ <input type="hidden" name="directory" value="$directory">
+ <input type="hidden" name="dbType" value="$dbType">
+ <input type="hidden" name="dbInstance" value="$dbInstance">
+ <input type="hidden" name="host_port" value="$host_port">
+ <input type="hidden" name="username" value="$username">
+ <input type="hidden" name="password1" value="$password1">
+ <input type="hidden" name="password2" value="$password2">
+ <input type="hidden" name="prefixed" value="$prefixed">
+ <input type="hidden" name="InputParam" value="$InputParam">
+ <input type="hidden" name="outnameSpace" value="$outnameSpace">
+ <input type="hidden" name="genORcom" value="$genORcom">
+ <input type="hidden" name="simORcollInput" value="$simORcollInput">
+ <input type="hidden" name="simORcollOutput" value="$simORcollOutput">
+ <br>
+ <table width="40%" border="1">
+ <tr>
+ <td></td>
+ <td><div align="center"><b>SQL Variable Name</b></div></td>
+ <td><div align="center"><b>Moby Object Article</b></div></td>
+ </tr>
+ $InputParam_html
+ </table>
+ <br>
+ <hr>
+ <input type="Submit" name="Submit" value="Next">
+ </form>
+ </body>
+ </html>
+MAP
+
+}
+
+#******************************************************************************
+# This Function get the output column of a SQL query using pattern Matching
+# ARGS: A String of SQL query
+# Return: An Array of output Column Names
+#******************************************************************************
+sub outMap{
+
+ my $code = shift;
+ my @list;
+ $code =~ s/\n//g; #remove all the new line symbol
+ $code =~ s/select|from.*|,//ig; #remove all un-needed information
+ $code =~ s/\./_/g;
+
+ while($code =~ m/(\w+)/g){
+ push(@list,$1);
+ }
+ return @list;
+}
+
#*********************************************************************************************************
#
# In this form we will be associating the fields in the SQL query with the MobyObject
@@ -950,20 +1087,14 @@
$column_html .= "<td><select name=\"outputobject_articles$n\" id=\"outputobject_articles$n\">". $object_articles_html . "</select></td>";
$column_html .= "</tr>";
}
+ my $UI_string = UI_template("2");
print <<MAP;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - SQL MAPPER</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <div align="center">
- <p><font size="+3"><strong>Mapping your SQL columns with MOBY Object Articles</strong></font></p>
- <p> </p>
-
- Because you have selected your service to be an SQL service, you are required to associate each column in your SQL statement with the corrosponding MOBY object article.<br>
- Once you have mapped out each column with an article click on the 'Next' button to continue.
+ $UI_string
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <p><font size="+2"><strong>Mapping your SQL columns with MOBY Object Articles</strong></font></p>
+ Please associate each column in your SQL statement with the corrosponding output MOBY object article. Once you have mapped out each column with an article click on the 'Next' button to continue.
+ <br>
<form method="get" action="/cgi-bin/code-generator0.6.cgi">
<input type="hidden" name="serviceType" value="$serviceType">
@@ -1014,92 +1145,14 @@
}
-#*****************************************************************************
-#
-# name: mygetArticles
-# description: FUNCTION THAT GETS THE ARTICLES GIVEN AN OBJECT NAME, the URL returns an XML and it is parsed to get the articles
-# args: objectProduced
-# returns: an array with the elements being each article in the mobyObject
-#
-#*****************************************************************************
-sub mygetArticles
-{
- my $objectProduced = shift;
-
- my $URL = 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY_display_object_xml.cgi?obj=' . $objectProduced;
-
- my $XML = get $URL;
- die "Couldn't get to $URL" unless defined $XML;
-
- $XML =~ s/\n//g;
- $XML =~ s/> </></g;
-
- #Now we need to parse the XML so that we only get the articles in the MOBY Object
- #Place the articles into an array, then print them out one by one
- my $parser = new XML::DOM::Parser;
- my $theNode = $parser->parse($XML) or die "Could not parse";
-
- #Gets the parameter
- #my ($theNode) = @_;
-
- my @articles;
- #the first Node is #document
- my $nodeList = $theNode->getChildNodes(); #nodeList is an object reference of the childnodes
- my $length = $nodeList->getLength; #number of children
-
- # $node is actually the moby object type, eg. Go_term
- # we now assign the new current node to that.
- my $node = $nodeList->item(0);
-
- # We need to get the number of children this node has, because these are the elements/properties of the mobby object
- my $objectLength = $node->getChildNodes->getLength;
- #We also need to get the childNodes of the current node, which are the tags, such as "String" for articleName "Term"
- my $newNodeList = $node->getChildNodes;
-
- #Using a for loop we have to go thru each element of the object
- for (my $i=0; $i<$objectLength; $i++)
- {
- my $newNode = $newNodeList->item($i);
-
- #within each element there are attributes, which include the namespace, id and articlename
- my $attLength; #This is the length of the attributes in the element
- my $attList = $newNode->getAttributes; #gets the list of attributes in the element
-
- #check if are attributes
- if( $attList )
- {
- #assign the attribute length if there are attributes
- $attLength = $attList->getLength;
- }
- if( $attLength)
- {
- #We go thru each attribute and only get the articleName
- for( my $i=0; $i<$attLength; $i++)
- {
- my $attnode = $attList->item($i);
- if ($attnode->getName eq "articleName")
- {
- push(@articles, $attnode->getValue);
- }
- }
- }
- }
-
- return @articles;
-}
-
-
#*******************************************************************
#
# THIS FUNCTION GENERATES THE DISPATCHER FOR THE SERVICE
# - Currently there are two implementations of saving the dispatcher
-# 1) Click on the "Save Dispatcher To" will open the save as window and the user will need to rename the file to dispatcher.cgi
-# 2) Click on the "Save Dispatcher To (as name)" will also open the save as window, but the name is already entered
-# - Obviously the second implementation is better than the first one, but we cannot use this idea when saving the actual webservice code, since
+# Click on the "Save Dispatcher To" will open the save as window and the user will need to rename the file to dispatcher.cgi
# the name of the file should be the name of the service
#
#*******************************************************************
-
sub generate_dispatcher{
my $error_msg = shift;
@@ -1170,20 +1223,20 @@
}
else{
- if($htmlORcom eq "htmlWrapper"){
+ if($htmlORcom eq "htmlWrapper"){ #need to keep passing the Default Values for HTML Wrapper Input Mapping
for(my $i=1;$i <= $DV_count;$i++){
$temp = $query->param("DValue$i");
$parse_html .= "<input type=\"hidden\" name=\"DValue$i\" value=\"$temp\">";
}
}
+ #Algorithm Output Mapping
$temp2 = $query->param("outputobject_articles0");
$parse_html .= "<input type=\"hidden\" name=\"outputobject_articles0\" value=\"$temp2\">";
}
+ my $UI_string = UI_template("4");
print <<HTML;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - Dispatcher File</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT TYPE="text/javascript">
@@ -1200,14 +1253,11 @@
return (errs==0);
};
</SCRIPT>
-
- </head>
- <body>
+
<div align="center">
- <p><font size="+3"><strong>Dispatcher File
+ <p><font size="+2"><strong>Dispatcher File
<div align="center">
</strong></font></p>
- <p> </p>
This is the dispatcher for your service, it is required during registation. Check over the code and make any changes if needed. Once you the code is correct click on the "Save As Dispatcher" button and save this file as 'dispatcher.cgi' and save it into the directory of your service.<br><br>
<font color="FF000"> <b>$error_msg</b></font>
<form method="get" action="/cgi-bin/code-generator0.6.cgi" onsubmit="return validateOnSubmit()" name="dispatcher">
@@ -1243,12 +1293,11 @@
<input type="hidden" name="perlModules" value="$perlModules">
<table width="%75" border="1">
<tr>
- <td width="%25">
- <br>
+ <td style="width: 25%; vertical-align: top;" >
Click on the "Save Dispatcher To" button and save the file as <b>"dispatcher.cgi"</b> to the directory where you will be installing your webservice. <br>eg. c:/tomcat/webapps/ROOT/WEB-INF/cgi/dispatcher.cgi<br><br>
Once you have saved the dispatcher onto your local computer, enter the URL of your dispatcher saved on your webserver. This URL is used during registation.
- <td>
- <textarea name="dispatcher" cols="100%" rows="20" id="dispatcher">
+ <td width="75%">
+ <textarea name="dispatcher" cols="80%" rows="20" id="dispatcher">
#!/usr/bin/env perl
use SOAP::Transport::HTTP;
@@ -1264,7 +1313,7 @@
</tr>
<tr>
<td>Dispatcher URL</td>
-<td><input type="text" id="URL"name="URL" value="$URL" size="60">Enter the URL of your dispatcher code</td>
+<td><input type="text" id="URL"name="URL" value="$URL" size="60"><br>Enter the URL of your dispatcher code</td>
</tr>
</table>
<br>
@@ -1272,7 +1321,7 @@
<input type="submit" name="Generate" value="Generate Code">
</form>
<form method="post" action="/cgi-bin/dispatcher.cgi">
- <input type="submit" name="Save Dispatcher" value="Save Dispatcher To (as name)">
+ <input type="submit" name="Save Dispatcher" value="Save Dispatcher To">
<input type="hidden" name="serviceName" value="$serviceName">
<input type="hidden" name="directory" value="$directory">
<input type="hidden" name="properties" value="generateDispatcher">
@@ -1533,8 +1582,9 @@
(prefixedORnot=>$executeString));
}
- else{
+ else{ #Implementation of the Algorithm Service (HTML and Command Line Wrapper)
+ #initializing all necessary variables
$temp2 = $query->param("outputobject_articles0");
my @outmap;
my @outmap2;
@@ -1543,8 +1593,8 @@
push(@outmap2,$temp2);
$MobyObject = getXMLObject($objectProduced, \@outmap, \@outmap2, $outnameSpace);
-
- if ($htmlORcom eq "htmlWrapper"){
+ #HTML Wrapper Section - geting all the code such as setDValues, input mapping, and main code from the code-book
+ if ($htmlORcom eq "htmlWrapper"){
my @DVlist;
$DefaultValue .= $code->get("setDefaultValue",(InputParam=>"\$ServiceURL",DValue=>$ServiceURL));
@@ -1555,18 +1605,19 @@
}
my $DC=0;
+
for(my $s=0; $s<$InputParam;$s++){
$temp = $InParam[$s];
$temp2 = $mapArticles[$s];
- if($temp2 eq "id"){
+ if($temp2 eq "id"){ #retrieve data from article id
$DefaultValue .= $code->get("validateAccession",
(response=>"simpleResponse"));
$getString .= $temp .'=$accession';
}
- elsif ($temp2 eq "other"){
+ elsif ($temp2 eq "other"){ #set default values
$DefaultValue .= $code->get("setDefaultValue",(InputParam=>"\$$temp",DValue=>$DVlist[$DC]));
$getString .= "$temp=\$$temp";
$DC++;
@@ -1588,7 +1639,7 @@
}
- else{
+ else{ #Command Line Section
for(my $s=0; $s<$InputParam;$s++){
$temp = $InParam[$s];
$temp2 = $mapArticles[$s];
@@ -1608,9 +1659,10 @@
$CommandLine_main = $code->get("CommandLine_main",(comline=>$comline,reader=>'<Reader>',MobyObject=>$MobyObject,namespace=>$outnameSpace ));
}
}
-
+ my $UI_string = UI_template("5");
#Printing out the HTML form
print <<HTML;
+ $UI_string
<form method="post" action="/cgi-bin/code-generator0.6.cgi">
<input type="hidden" name="serviceType" value="$serviceType">
@@ -1623,11 +1675,10 @@
<input type="hidden" name="URL" value="$URL">
<input type="hidden" name="contactEmail" value="$contactEmail">
<input type="hidden" name="description" value="$description">
+ <h2>THE FOLLOWING IS THE PERL MODULE FOR YOUR SERVICE</h2>
+ Confirm that the code below are correct, click on the 'Save Code As' button and save the perl module onto your server. Save the service as XXX.pm (where XXX is your service name). Place the file in the same folder as the dispatcher.cgi. Then click on the 'Register' button to register the service.<br>
- <h1>THE FOLLOWING IS THE PERL MODULE FOR YOUR SERVICE</h1>
- Confirm that the values above and the code below are correct, click on the 'Save Code As' button and save the perl module onto your server. Save the service as XXX.pm (where XXX is your service name). Place the file in the same folder as the dispatcher.cgi. Then click on the 'Register' button to register the service.
-
- <textarea name="webServiceCode" cols="150" rows="25" id="webServiceCode">
+ <textarea name="webServiceCode" cols="100" rows="25" id="webServiceCode">
$packages_modules
sub $serviceName {
@@ -1692,7 +1743,7 @@
<hr>
<input type="submit" name="Save Code" value="Save Webservice To">
<input type="submit" name="Register" value="Register Service">
-<input type="reset" name="reset" value="restart">
+<input type="reset" name="reset" value="Restart">
</form>
HTML
@@ -1705,116 +1756,6 @@
}
-#********************************************************************************
-#
-# name: getXMLObject
-# description: THIS FUNCTION TAKES IN THE MOBY OBJECT PRODUCED, mapping arrays (objectArticles array and sqlColumns) and spits back the MOBY Object needed to be produced
-# args: objectProduced, objectArticles (array), sqlColumns (array)
-# returns: an XML of the MobyObject Produced with the correct mappings onto each article
-#
-#********************************************************************************
-sub getXMLObject
-{
- my ($objectProduced, $objectArticles, $sqlColumns, $namespace) = @_;
-
- my $URL = 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY_display_object_xml.cgi?obj=' . $objectProduced;
-
- my $XML = get $URL;
- die "Couldn't get to $URL" unless defined $XML;
-
- #We first need to get rid of the new lines, to get a proper XML
- #Then we get change all texts that are "> <" to "><" to get a proper XML
- $XML =~ s/\n//g;
- $XML =~ s/> </></g;
-
- #Creating a new XML parser
- my $parser = new XML::DOM::Parser;
- my $theNode = $parser->parse($XML) or die "Could not parse";
-
- my $objectArticlesLength = @$objectArticles;
- my $sqlColumnsLength = @$sqlColumns;
-
- my $thisType = $theNode->getNodeType; #thisType is the type of node
- my $nodeList = $theNode->getChildNodes; #nodeList is an object reference of the childnodes
- my $name = $theNode->getNodeName; #name is the name of the node
-
- my $length = $nodeList->getLength; #number of children
-
- #$item(0) is the first node after #document, which is the MobyObject name, ie Go_Term
- my $node = $nodeList->item(0);
- my $objectLength = $node->getChildNodes->getLength;
-
-
- #Get the childnodes as an array
- my $newNodeList = $node->getChildNodes;
- my $find = 0;
- my $result = "";
-
- #Going thru each child
- for (my $i=0; $i<$objectLength; $i++)
- {
- my $newNode = $newNodeList->item($i);
-
- #NEED TO COMPARE THE ARTICLES WITH THE MAPPING ARTICLES, THEN WE CAN CHANGE THE CONTEXT
- my $attLength; #This is the length of the attributes in the element
- my $attList = $newNode->getAttributes; #gets the list of attributes in the element
-
- if( $attList ){ $attLength = $attList->getLength }; #assign the attribute length if there are attributes
-
- if( $attLength)
- {
- #We go thru each attribute in the object, which is usually the 'namespace', 'id' and 'articleName'
- for( my $i=0; $i<$attLength; $i++)
- {
- my $attnode = $attList->item($i);
- #We need to check if the attribute is 'articleName'
- if ($attnode->getName eq "articleName")
- {
- #And if it is 'articleName' we go thru the objectArticles array and compare the value of the articleName
- #with the element in the array
- for(my $i=0; $i<$objectArticlesLength; $i++)
- {
- #If the articleName is the same as the objectArticles we add a new textnode
- if($attnode->getValue eq @$objectArticles[$i])
- {
- #adds the new text node to the element node, this text will be the sql column name
- $newNode->addText('$' . (@$sqlColumns[$i]));
- $find++;
- }
- }
- }
- }
- }
- }
-
- #Setting the object attributes namespace, id to $namespace and $accession respectively
- my $objectAtt = $node->getAttributes;
- my $objectAttLength = $objectAtt->getLength;
- for (my $i=0; $i<$objectAttLength; $i++)
- {
- my $objectAttNode = $objectAtt->item($i);
- if($objectAttNode->getName eq "namespace")
- {
- $objectAttNode->setValue("$namespace");
- }
- elsif ($objectAttNode->getName eq "id")
- {
- if ($find == $sqlColumnsLength){
- $objectAttNode->setValue('$accession');
- }
- else{
- for(my $i=0;$i<$sqlColumnsLength;$i++){
- $objectAttNode->setValue("\$@$sqlColumns[$i]") if (@$objectArticles[$i] eq "id");
- }
-
- }
- }
- }
-
- #Returns the whole XML back
- return ($theNode->toString);
-}
-
#This function saves the webservice code
sub saveCode
{
@@ -1919,295 +1860,124 @@
}
}
-#**************************************************************************************
+
+
+#***************************************************************************
#
-# name: fetcharray_columns
-# description: THIS FUNCTION OBTAINS THE COLUMNS IN THE SQL QUERY AND RETURNS IT AS A STRING EACH COLUMN SEPARATED WITH A COMMA
-# args: an array with the sql columns as it's elements
-# returns: one string which will contain all elements in the form $column_name and separated by a comma
+# THIS FUNCTION DISPLAYS THE ALGORITHM PROPERTIES
+# - description: THIS FUNCTION prompt user, using radio button,
+# for which algorithm (Html Wrapper and Command Line) they want to work with
+# Note: The Command Line Algorithm still in progress
#
-#**************************************************************************************
-sub fetcharray_columns
+#***************************************************************************
+sub algorithm_properties
{
- my @fields_array = @_;
- my $fields_string = "";
- my $length = @fields_array;
+ my $error_msg = shift;
+
+ #WE ALSO NEED TO CONTINUE PASSING THE OTHER VARIABLES
+ my $serviceType = $query->param("serviceType");
+ my $objectConsumed = $query->param("objectConsumed");
+ my $objectProduced = $query->param("objectProduced");
+ my $nameSpace = $query->param("nameSpace");
+ my $outnameSpace = $query->param("outnameSpace");
+ my $serviceName = $query->param("serviceName");
+ my $authURI = $query->param("authURI");
+ my $sqlORalgor_rad = $query->param("sqlORalgor_rad");
+ my $contactEmail = $query->param("contactEmail");
+ my $description = $query->param("description");
+ my $directory = $query->param("directory");
+ my $genORcom = $query->param("genORcom");
+ my $simORcollInput = $query->param("simORcollInput");
+ my $simORcollOutput = $query->param("simORcollOutput");
+
+ my $UI_string = UI_template("2");
+javascript_functions();
+ #Print the HTML form out
+ print <<HTML_FORM;
+ $UI_string
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ </head>
+ <div align="center">
+ <p><font size="+2"><strong>Algorithm Properties</strong></font></p>
+ Since your have selected your service as an Algorithm service, Please select one of the following:.
+ <p><font color="FF000"> <b>$error_msg</b></font></p>
+ <form method="get" action="/cgi-bin/code-generator0.6.cgi">
+ <input type="hidden" name="properties" value="Algorithm Properties">
+ <input type="hidden" name="serviceType" value="$serviceType">
+ <input type="hidden" name="objectConsumed" value="$objectConsumed">
+ <input type="hidden" name="objectProduced" value="$objectProduced">
+ <input type="hidden" name="nameSpace" value="$nameSpace">
+ <input type="hidden" name="outnameSpace" value="$outnameSpace">
+ <input type="hidden" name="serviceName" value="$serviceName">
+ <input type="hidden" name="authURI" value="$authURI">
+ <input type="hidden" name="sqlORalgor_rad" value="$sqlORalgor_rad">
+ <input type="hidden" name="contactEmail" value="$contactEmail">
+ <input type="hidden" name="description" value="$description">
+ <input type="hidden" name="directory" value="$directory">
+ <input type="hidden" name="genORcom" value="$genORcom">
+ <input type="hidden" name="simORcollInput" value="$simORcollInput">
+ <input type="hidden" name="simORcollOutput" value="$simORcollOutput">
+ <input type="radio" name="htmlORcom" id="htmlORcom" value="htmlWrapper">HTML Wrapper <A HREF="javascript:openHelp('HTMLWrapper')">[?]</A>
+ <input type="radio" name="htmlORcom" id="htmlORcom" value="CommandLine">Command Line <A HREF="javascript:openHelp('CommandLine_al')">[?]</A>
+ <hr>
+ <table width="50%" align="center">
+ <tr>
+ <td><div align="center"><input type="submit" name="Submit" value="Next"></div></td>
+ <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
+ </tr>
+ </table>
+ </form>
+ </body>
+ </html>
+
+HTML_FORM
- for (my $n=0; $n < $length; $n++)
- {
- if ($n eq ($length - 1))
- {
- $fields_string .= '$' . $fields_array[$n];
- }
- else
- {
- $fields_string .= '$'. $fields_array[$n] . ", ";
- }
- }
-
- return lc($fields_string);
}
-#**********************************************************************************
+#***************************************************************************
#
-# name: first_column
-# description: THIS FUNCTION GRABS THE FIRST COLUMN IN THE SQL QUERY, MAIN USE OF THIS IS USE WHEN GETTING THE CODE FOR dbaccess_main
-# args: an array with the sql columns as it's elements
-# returns: the first element of the array in the form $column_name
+# THIS FUNCTION DISPLAYS THE ALGORITHM PROPERTIES
+# - description: THIS FUNCTION asks users to provide their Web Service URL (eg. The Location of the cgi file)
+# and the number of Input Parameters needed to execute the Service
#
-#*********************************************************************************
-sub first_column
+#***************************************************************************
+sub HTMLWrapper_properties
{
- my @fields_array = @_;
-
- my $first_field = '$' . $fields_array[0];
- return lc($first_field);
-}
+ my $error_msg = shift;
+ my $ServiceURL = shift;
+ my $InputParam = shift;
-#*********************************************************************************
-#
-# name: parserSQL
-# description: THIS FUNCTION HELPS PARSE THE SQL STATEMENT TO GET THE FIELDS
-# args: an sql statement
-# returns: an array with each element being each sql column in the sql statement
-#
-#*********************************************************************************
-sub parseSQL {
- my $sqlQuery = shift;
+ #WE ALSO NEED TO CONTINUE PASSING THE OTHER VARIABLES
+ my $serviceType = $query->param("serviceType");
+ my $objectConsumed = $query->param("objectConsumed");
+ my $objectProduced = $query->param("objectProduced");
+ my $nameSpace = $query->param("nameSpace");
+ my $serviceName = $query->param("serviceName");
+ my $authURI = $query->param("authURI");
+ my $sqlORalgor_rad = $query->param("sqlORalgor_rad");
+ my $contactEmail = $query->param("contactEmail");
+ my $description = $query->param("description");
+ my $directory = $query->param("directory");
+ my $genORcom = $query->param("genORcom");
+ my $simORcollInput = $query->param("simORcollInput");
+ my $simORcollOutput = $query->param("simORcollOutput");
+ my $htmlORcom = $query->param("htmlORcom");
+ my $outnameSpace = $query->param("outnameSpace");
+ my $serviceCode = $query->param("serviceCode");
-# Create a parser
- my($parser) = SQL::Statement->new('SQL::Statement');
+ my $service_html ="";
+ my $service_html2 ="";
+ my $service_html3 = "Command Line";
+ my $temp = "";
- # Parse an SQL statement
- $@ = '';
- my ($stmt) = eval {
- SQL::Statement->new($sqlQuery,
- $parser);
- };
- #Check if we can parse the statement
- if ($@) {
- die "Cannot parse statement: $@";
- }
+ javascript_functions();
- #Get the columns
- my @columns = $stmt->columns();
-
- #Foreach column create a new array with the column names
- my @column_opts;
- foreach (@columns)
- {
- push (@column_opts, $_->name());
- }
-
- return @column_opts;
-}
-
-
-#USED TO PARSE XML FILES - THERE IS NO NEED FOR THESE FUNCTIONS, Since they take a long time and have duplicate coding.
-#There is a way to get all the these elements already!!! >__< time well wasted though..lol
-# REFERENCE ON HOW TO PARSE XML FILES
-sub getServiceTypesArray {
-
- my $names = MOBY::Central->retrieveServiceTypes(); #Replace retrievelServiceNames to get diff XML
-
- my $parser = new XML::DOM::Parser;
- my $doc = $parser->parse($names);
-
- my $nodes = $doc->getElementsByTagName("serviceType"); #Replace serviceName with other things to get array
- my $n = $nodes->getLength;
-
- #print $n . "\n";
-
- my @items;
- for (my $i = 0; $i < $n; $i++)
- {
- my $node = $nodes->item ($i); #item method is in XML::DOM:NodeList
- my $item = $node->getAttributeNode ("name"); #getAttributeNode method is in XML::DOM::Element
- if (defined($item))
- {
- #print $item->getValue . "\n"; #getValue method is in XML::DOM::Attr
- push @items, $item->getValue();
- }
- }
- return @items;
-}
-
-
-sub getObjectsArray {
-
- my $names = MOBY::Central->retrieveObjectNames(); #Replace retrievelServiceNames to get diff XML
-
- my $parser = new XML::DOM::Parser;
- my $doc = $parser->parse($names);
-
- my $nodes = $doc->getElementsByTagName("Object"); #Replace serviceName with other things to get array
- my $n = $nodes->getLength;
-
- #print $n . "\n";
-
- my @items;
- for (my $i = 0; $i < $n; $i++)
- {
- my $node = $nodes->item ($i); #item method is in XML::DOM:NodeList
- my $item = $node->getAttributeNode ("name"); #getAttributeNode method is in XML::DOM::Element
- if (defined($item))
- {
- #print $item->getValue . "\n"; #getValue method is in XML::DOM::Attr
- push @items, $item->getValue();
- }
- }
- return @items;
-}
-
-sub getNamespacesArray {
-
- my $names = MOBY::Central->retrieveNamespaces(); #Replace retrievelServiceNames to get diff XML
-
- my $parser = new XML::DOM::Parser;
- my $doc = $parser->parse($names);
-
- my $nodes = $doc->getElementsByTagName("Namespace"); #Replace serviceName with other things to get array
- my $n = $nodes->getLength;
-
- #print $n . "\n";
-
- my @items;
- for (my $i = 0; $i < $n; $i++)
- {
- my $node = $nodes->item ($i); #item method is in XML::DOM:NodeList
- my $item = $node->getAttributeNode ("name"); #getAttributeNode method is in XML::DOM::Element
- if (defined($item))
- {
- #print $item->getValue . "\n"; #getValue method is in XML::DOM::Attr
- push @items, $item->getValue();
- }
- }
- return @items;
-}
-
-
-#***************************************************************************
-#
-# THIS FUNCTION DISPLAYS THE ALGORITHM PROPERTIES
-# - description: THIS FUNCTION prompt user, using radio button,
-# for which algorithm (Html Wrapper and Command Line) they want to work with
-# Note: The Command Line Algorithm still in progress
-#
-#***************************************************************************
-sub algorithm_properties
-{
-
- my $error_msg = shift;
-
- #WE ALSO NEED TO CONTINUE PASSING THE OTHER VARIABLES
- my $serviceType = $query->param("serviceType");
- my $objectConsumed = $query->param("objectConsumed");
- my $objectProduced = $query->param("objectProduced");
- my $nameSpace = $query->param("nameSpace");
- my $outnameSpace = $query->param("outnameSpace");
- my $serviceName = $query->param("serviceName");
- my $authURI = $query->param("authURI");
- my $sqlORalgor_rad = $query->param("sqlORalgor_rad");
- my $contactEmail = $query->param("contactEmail");
- my $description = $query->param("description");
- my $directory = $query->param("directory");
- my $genORcom = $query->param("genORcom");
- my $simORcollInput = $query->param("simORcollInput");
- my $simORcollOutput = $query->param("simORcollOutput");
-
-javascript_functions();
- #Print the HTML form out
- print <<HTML_FORM;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - Algorithm Properties</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
-
- <body>
- <div align="center">
- <p><font size="+3"><strong>Algorithm Properties</strong></font></p>
- <p> </p>
-
- Since your have selected your service as an Algorithm service, Please select one of the following:.<br>
- Once you have finished filling in the form click on the 'Next' button to continue.
- <p><font color="FF000"> <b>$error_msg</b></font></p>
- <p align="left">Please fill in the required fields</p>
- <form method="get" action="/cgi-bin/code-generator0.6.cgi">
- <input type="hidden" name="properties" value="Algorithm Properties">
- <input type="hidden" name="serviceType" value="$serviceType">
- <input type="hidden" name="objectConsumed" value="$objectConsumed">
- <input type="hidden" name="objectProduced" value="$objectProduced">
- <input type="hidden" name="nameSpace" value="$nameSpace">
- <input type="hidden" name="outnameSpace" value="$outnameSpace">
- <input type="hidden" name="serviceName" value="$serviceName">
- <input type="hidden" name="authURI" value="$authURI">
- <input type="hidden" name="sqlORalgor_rad" value="$sqlORalgor_rad">
- <input type="hidden" name="contactEmail" value="$contactEmail">
- <input type="hidden" name="description" value="$description">
- <input type="hidden" name="directory" value="$directory">
- <input type="hidden" name="genORcom" value="$genORcom">
- <input type="hidden" name="simORcollInput" value="$simORcollInput">
- <input type="hidden" name="simORcollOutput" value="$simORcollOutput">
- <input type="radio" name="htmlORcom" id="htmlORcom" value="htmlWrapper">HTML Wrapper <A HREF="javascript:openHelp('HTMLWrapper')">[?]</A>
- <input type="radio" name="htmlORcom" id="htmlORcom" value="CommandLine">Command Line <A HREF="javascript:openHelp('CommandLine_al')">[?]</A>
- <hr>
- <table width="50%" align="center">
- <tr>
- <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
- <td><div align="center"><input type="submit" name="Submit" value="Next"></div></td>
- </tr>
- </table>
- </form>
- </body>perl javascript calling methods
- </html>
-
-HTML_FORM
-
-}
-
-#***************************************************************************
-#
-# THIS FUNCTION DISPLAYS THE ALGORITHM PROPERTIES
-# - description: THIS FUNCTION asks users to provide their Web Service URL (eg. The Location of the cgi file)
-# and the number of Input Parameters needed to execute the Service
-#
-#***************************************************************************
-sub HTMLWrapper_properties
-{
-
- my $error_msg = shift;
- my $ServiceURL = shift;
- my $InputParam = shift;
-
- #WE ALSO NEED TO CONTINUE PASSING THE OTHER VARIABLES
- my $serviceType = $query->param("serviceType");
- my $objectConsumed = $query->param("objectConsumed");
- my $objectProduced = $query->param("objectProduced");
- my $nameSpace = $query->param("nameSpace");
- my $serviceName = $query->param("serviceName");
- my $authURI = $query->param("authURI");
- my $sqlORalgor_rad = $query->param("sqlORalgor_rad");
- my $contactEmail = $query->param("contactEmail");
- my $description = $query->param("description");
- my $directory = $query->param("directory");
- my $genORcom = $query->param("genORcom");
- my $simORcollInput = $query->param("simORcollInput");
- my $simORcollOutput = $query->param("simORcollOutput");
- my $htmlORcom = $query->param("htmlORcom");
- my $outnameSpace = $query->param("outnameSpace");
- my $serviceCode = $query->param("serviceCode");
-
- my $service_html ="";
- my $service_html2 ="";
- my $temp = "";
-
-javascript_functions();
#For the HTML Wrapper, the program will ask user to provide the location of their Service URL
#For the Command Line, the program will ask user to provide the command with the variable names in order to execute the program
if ($htmlORcom eq "htmlWrapper"){
+ $service_html3 = "HTML Wrapper";
$service_html = 'Service URL';
$temp = 'http://';
}
@@ -2215,25 +1985,16 @@
$service_html = 'Command Line';
$service_html2 = "<br><font color=\"FF000\">Note: Please provide a name (eg. var1) for each of the mapping variable in the Command</font>";
}
+ my $UI_string = UI_template("2");
#Print the HTML form out
print <<HTML_FORM;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - Command Line / HTML Wrapper Properties</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
-
- <body>
<div align="center">
- <p><font size="+3"><strong>Command Line / HTML Wrapper Properties</strong></font></p>
- <p> </p>
-
- Since you have selected an HTML Wrapper Algorithm. Please provide the following information:.<br>
- Once you have finished filling in the form click on the 'Next' button to continue.
+ <p><font size="+2"><strong>$service_html3 Properties</strong></font></p>
+ Please provide the following information. Once you have finished filling in the form click on the 'Next' button to continue.
<p><font color="FF000"> <b>$error_msg</b></font></p>
- <p align="left">Please fill in the required fields</p>
-
<form method="get" action="/cgi-bin/code-generator0.6.cgi">
<input type="hidden" name="properties" value="HTML Wrapper Properties">
<input type="hidden" name="serviceType" value="$serviceType">
@@ -2257,15 +2018,14 @@
<td width="60%">$temp<input type="text" name="ServiceURL" id="ServiceURL" value="$ServiceURL"><A HREF="javascript:openHelp('$service_html')">[?]</A></td></tr>
<tr>
<td width="40%" height="28">Number of Input Parameters: </td>
- <td width="60%"><input type="text" name="InputParam" id="InputParam" value="$InputParam"><A HREF="javascript:openHelp('InputParam')">[?]</A></td></tr>
+ <td width="60%"><input type="text" name="InputParam" id="InputParam" value="$InputParam"><A HREF="javascript:openHelp('InputParam')">[?]</A></td></tr></table>
<hr>
<table width="50%" align="center">
<tr>
- <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
<td><div align="center"><input type="submit" name="Submit" value="Next"></div></td>
+ <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
</tr>
- </table>
- $service_html2
+ </table>$service_html2
</form>
</body>
</html>
@@ -2329,41 +2089,32 @@
$object_articles_html .= "<option value =\"other\">other</option>";
$articles_length += 2;
+ # creating text box for default values
my $InputParam_html = "";
for(my $i=0; $i<$InputParam;$i++){
- $InputParam_html .= " <tr><td>Parameters $i:</td>
+ my $s = $i + 1;
+ $InputParam_html .= " <tr><td>Parameters $s:</td>
<td><input type=\"text\" name=\"InputParam$i\" id=\"InputParam$i\" value=\"$InParam[$i]\"></A></td>
<td><select name=\"inputobject_articles$i\" id=\"inputobject_articles$i\">". $object_articles_html . "</select></td>
</tr>";
}
- my $service_html ="";
+ my $service_html2 = "Command Line";
if ($htmlORcom eq "htmlWrapper"){
+ $service_html2 = "HTML Wrapper";
# check the Service URL prefix, if it isn't prefixed With (http://) , then prefix it for the purposes of the html call
unless ($ServiceURL =~/^http:\/\//){
$ServiceURL = "http://$ServiceURL";
}
-
- $service_html = qq{<p>Service URL: $ServiceURL</p>};
- }
-
- else{
- $service_html = qq{<p>Command Line: $comline</p>};
- }
-
-
+ }
+ my $UI_string = UI_template("2");
+
#Print the HTML form out
print <<HTML_FORM;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - HTML/Command Line Input Mapping</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
-
- <body>
<div align="center">
- <p><font size="+3"><strong>HTML/Command Line Input Mapping</strong></font></p>
- <p> </p>
+ <p><font size="+2"><strong>HTML/Command Line Input Mapping</strong></font></p>
Please specify the names of the input Parameters:.<br>
Once you have finished filling in the form click on the 'Next' button to continue.
<p><font color="FF000"> <b>$error_msg</b></font></p>
@@ -2387,8 +2138,6 @@
<input type="hidden" name="InputParam" value="$InputParam">
<input type="hidden" name="outnameSpace" value="$outnameSpace">
<input type="hidden" name="comline" value="$comline">
- <br>You have entered:
- $service_html
<p align="left">Please fill in the required fields</p>
<table width="75%" border="1">
<tr>
@@ -2397,12 +2146,12 @@
<td><div align="center"><b>Moby Object Article</b></div></td>
</tr>
$InputParam_html
+ </table>
<hr>
-
<table width="50%" align="center">
<tr>
- <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
<td><div align="center"><input type="submit" name="Submit" value="Next"></div></td>
+ <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
</tr>
</table>
</form>
@@ -2469,26 +2218,17 @@
<td width=\"60%\">$temp2</td></tr>";
}
}
-
+ my $UI_string = UI_template("2");
#Print the HTML form out
print <<HTML_FORM;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - HTML Wrapper Input Mapping 2</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
-
- <body>
<div align="center">
- <p><font size="+3"><strong>HTML Input Mapping - Default Value</strong></font></p>
- <p> </p>
-
- Because you have selected your service to be a HTML Wrapper, you are required to associate each Input Parameters with the corrosponding MOBY object article.<br>
- Once you have mapped out each parameter with an article click on the 'Next' button to continue.
+ <p><font size="+2"><strong>HTML Input Mapping - Default Value</strong></font></p>
+ In order to build your service, you are required to associate each Input Parameters with the corrosponding MOBY object article.<br>
+ Once you have mapped out each parameter with an article click on the 'Next' button to continue.
<p><font color="FF000"> <b>$error_msg</b></font></p>
- <p align="left">Please fill in the required fields</p>
-
<form method="get" action="/cgi-bin/code-generator0.6.cgi">
<input type="hidden" name="properties" value="MapHTMLinput2">
@@ -2518,12 +2258,12 @@
<td width="60%">$ServiceURL</td></tr>
$object_articles_html
-
+ </table>
<hr>
<table width="50%" align="center">
<tr>
- <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
<td><div align="center"><input type="submit" name="Submit" value="Next"></div></td>
+ <td><div align="center"><input type="reset" name="Reset" value="Start Over"></div></td>
</tr>
</table>
</form>
@@ -2535,226 +2275,7 @@
}
-#*****************************************************************************
-#
-# name: getTagNAmebyArticles
-# description: FUNCTION THAT GETS THE TAG NAME that associated with AN OBJECT NAME and an ArticlesName,
-# args: objectProduced/objectConsumed, ArticleName
-# returns: Tag name
-#********************************************************************************
-sub getTagNamebyArticles
-{
- my $objectProduced = shift;
- my $aname = shift;
-
- my $URL = 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY_display_object_xml.cgi?obj=' . $objectProduced;
- my $XML = get $URL;
- die "Couldn't get to $URL" unless defined $XML;
-
- $XML =~ s/\n//g;
- $XML =~ s/> </></g;
-
- #Now we need to parse the XML so that we only get the articles in the MOBY Object
- #Place the articles into an array, then print them out one by one
- my $parser = new XML::DOM::Parser;
- my $theNode = $parser->parse($XML) or die "Could not parse";
-
- #Gets the parameter
- #my ($theNode) = @_;
-
- my @articles;
- #the first Node is #document
- my $nodeList = $theNode->getChildNodes(); #nodeList is an object reference of the childnodes
- my $length = $nodeList->getLength; #number of children
-
- # $node is actually the moby object type, eg. Go_term
- # we now assign the new current node to that.
- my $node = $nodeList->item(0);
-
- # We need to get the number of children this node has, because these are the elements/properties of the mobby object
- my $objectLength = $node->getChildNodes->getLength;
- #We also need to get the childNodes of the current node, which are the tags, such as "String" for articleName "Term"
- my $newNodeList = $node->getChildNodes;
-
- #Using a for loop we have to go thru each element of the object
- for (my $i=0; $i<$objectLength; $i++)
- {
- my $newNode = $newNodeList->item($i);
- my $name = $newNode->getNodeName;
- #within each element there are attributes, which include the namespace, id and articlename
- my $attLength; #This is the length of the attributes in the element
- my $attList = $newNode->getAttributes; #gets the list of attributes in the element
-
- #check if are attributes
- if( $attList )
- {
- #assign the attribute length if there are attributes
- $attLength = $attList->getLength;
- }
- if( $attLength)
- {
- #We go thru each attribute and articleName to get the Tag Name
- for( my $i=0; $i<$attLength; $i++)
- {
- my $attnode = $attList->item($i);
- if (($attnode->getName eq "articleName") and ($attnode->getValue eq $aname))
- {
- return $name;
- }
- }
- }
- }
-}
-#***********************************************************************************************************
-#
-# SQL INPUT MAPPING FUNCTION
-# - description: THIS FUNCTION asks users to provide the names of each of the Input Variable
-# Then, we will be associating the Input Parameters' names in the Service URL with the MobyObject id,articels.... so that the MOBY service can retrieve data correctly
-# eg. The Service URL has two inputs, X and Y
-# MobyObject: GO_Term, GO has String called Term AND has string called Definition
-# The user will have to associate "X" with "Term" and "Y" with "Definition"
-#
-#************************************************************************************************************
-sub mapSQLinput{
-
- my $error_msg = shift;
- @InParam = shift;
-
- my $serviceType = $query->param("serviceType");
- my $objectConsumed = $query->param("objectConsumed");
- my $objectProduced = $query->param("objectProduced");
- my $nameSpace = $query->param("nameSpace");
- my $serviceName = $query->param("serviceName");
- my $authURI = $query->param("authURI");
- my $sqlORalgor_rad = $query->param("sqlORalgor_rad");
- my $contactEmail = $query->param("contactEmail");
- my $description = $query->param("description");
- my $directory = $query->param("directory");
- my $outnameSpace = $query->param("outnameSpace");
- my $dbType = $query->param("dbType");
- my $dbInstance = $query->param("dbInstance");
- my $host_port = $query->param("host_port");
- my $username = $query->param("username");
- my $password1 = $query->param("password1");
- my $password2 = $query->param("password2");
- my $prefixed = $query->param("prefixed");
- my $genORcom = $query->param("genORcom");
- my $simORcollInput = $query->param("simORcollInput");
- my $simORcollOutput = $query->param("simORcollOutput");
- my $serviceCode = $query->param("sqlStatement");
- my $InputParam = $query->param("InputParam");
-
- #Displaying the different input text boxes for user to type the names of parameters
-
- for(my $s=0; $s<$InputParam;$s++){
- push(@InParam, "") if (!$InParam[$s]);
- }
-
- my @object_articles_opts = mygetArticles($objectConsumed);
- my $articles_length = @object_articles_opts;
-
- #Displaying the All the field, id and article names, in a selection box in the right column of the table for mapping purpose
- my $object_articles_html;
- foreach my $object_article_option (@object_articles_opts)
- {
- $object_articles_html .= "<option value =\"$object_article_option\"";
- $object_articles_html .= ">$object_article_option</option>";
- }
-
- $object_articles_html .= "<option value =\"id\">id</option>";
- $articles_length += 1;
-
- my $InputParam_html = "";
- for(my $i=0; $i<$InputParam;$i++){
- $InputParam_html .= " <tr><td>Parameters $i:</td>
- <td><input type=\"text\" name=\"InputParam$i\" id=\"InputParam$i\" value=\"$InParam[$i]\"></A></td>
- <td><select name=\"inputobject_articles$i\" id=\"inputobject_articles$i\">". $object_articles_html . "</select></td>
-</tr>";
- }
-
-print <<MAP;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - SQL INPUT MAPPER</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <div align="center">
- <p><font size="+3"><strong>Mapping your SQL columns with MOBY Object Articles</strong></font></p>
- <p> </p>
-
- Because you have selected your service to be an SQL service, you are required to associate each column in your SQL statement with the corrosponding MOBY object article.<br>
- Once you have mapped out each column with an article click on the 'Next' button to continue.
- <p><font color="FF000"> <b>$error_msg</b></font></p>
- <form method="get" action="/cgi-bin/code-generator0.6.cgi">
- <input type="hidden" name="properties" value="mapSQLinput">
- <input type="hidden" name="serviceType" value="$serviceType">
- <input type="hidden" name="objectConsumed" value="$objectConsumed">
- <input type="hidden" name="objectProduced" value="$objectProduced">
- <input type="hidden" name="nameSpace" value="$nameSpace">
- <input type="hidden" name="serviceName" value="$serviceName">
- <input type="hidden" name="authURI" value="$authURI">
- <input type="hidden" name="sqlORalgor_rad" value="$sqlORalgor_rad">
- <input type="hidden" name="serviceCode" value="$serviceCode">
- <input type="hidden" name="contactEmail" value="$contactEmail">
- <input type="hidden" name="description" value="$description">
- <input type="hidden" name="directory" value="$directory">
- <input type="hidden" name="dbType" value="$dbType">
- <input type="hidden" name="dbInstance" value="$dbInstance">
- <input type="hidden" name="host_port" value="$host_port">
- <input type="hidden" name="username" value="$username">
- <input type="hidden" name="password1" value="$password1">
- <input type="hidden" name="password2" value="$password2">
- <input type="hidden" name="prefixed" value="$prefixed">
- <input type="hidden" name="InputParam" value="$InputParam">
- <input type="hidden" name="outnameSpace" value="$outnameSpace">
- <input type="hidden" name="genORcom" value="$genORcom">
- <input type="hidden" name="simORcollInput" value="$simORcollInput">
- <input type="hidden" name="simORcollOutput" value="$simORcollOutput">
-
- <br>
- <font size="+2"><strong>The SQL statement entered was:</strong></font><br>
- <strong>$serviceCode</strong>
- <br>
- <br>
- <table width="40%" border="1">
- <tr>
- <td></td>
- <td><div align="center"><b>SQL Variable Name</b></div></td>
- <td><div align="center"><b>Moby Object Article</b></div></td>
- </tr>
- $InputParam_html
- </table>
- <br>
- <hr>
- <input type="Submit" name="Submit" value="Next">
- </form>
- </body>
- </html>
-MAP
-
-}
-
-#******************************************************************************
-# This Function get the output column of a SQL query using pattern Matching
-# ARGS: A String of SQL query
-# Return: An Array of output Column Names
-#******************************************************************************
-sub outMap{
-
- my $code = shift;
- my @list;
- $code =~ s/\n//g;
- $code =~ s/select|from.*|,//ig;
- $code =~ s/\./_/g;
-
- while($code =~ m/(\w+)/g){
- push(@list,$1);
- }
- return @list;
-}
-
-#***********************************************************************************************************
+#***********************************************************************************************************
#
# HTML WRAPPER OUTPUT MAPPING FUNCTION
# - description: THIS FUNCTION asks users to map the output to an Object Articles
@@ -2789,7 +2310,8 @@
my $parse_html = "";
my $temp;
my $temp2;
-
+ my $service_html = "Command Line";
+
#keep on passing the inout parameters to then next page
for(my $s=0; $s<$InputParam;$s++){
$temp = $query->param("InputParam$s");
@@ -2802,6 +2324,7 @@
#addition data passing (Default Values) for the html wrapper
if($htmlORcom eq "htmlWrapper"){
+ $service_html = "HTML Wrapper";
my $ServiceURL = $query->param("ServiceURL");
my $DV_count = $query->param("DV_count");
@@ -2830,22 +2353,16 @@
$articles_length += 1;
#Displaying the the drop down menu for users to select which article goes with which column
-
+ my $UI_string = UI_template("2");
print <<MAP;
- <html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - Command Line & HTML Wrapper Output MAPPING</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
<div align="center">
- <p><font size="+3"><strong>Mapping your Output/Result with MOBY Object Articles</strong></font></p>
- <p> </p>
-
- Because you have selected your service to be a Command Line service, you are required to associate each column in your Program output/result with the corrosponding MOBY object article.<br>
+ <p><font size="+2"><strong>Mapping your Output/Result with MOBY Object Articles</strong></font></p>
+ You are required to associate each column in your Program output/result with the corrosponding MOBY object article.<br>
Once you have mapped out each column with an article click on the 'Next' button to continue.
-
+
<form method="get" action="/cgi-bin/code-generator0.6.cgi">
<input type="hidden" name="properties" value="MapCOMoutput">
<input type="hidden" name="serviceType" value="$serviceType">
@@ -2867,9 +2384,6 @@
<input type="hidden" name="htmlORcom" value="$htmlORcom">
$parse_html
<br>
- <font size="+2"><strong>The Command Line entered was:</strong></font><br>
- <strong>$comline</strong>
- <br>
<table width="40%" border="1">
<tr>
<td><div align="center"><b>Output</b></div></td>
@@ -2946,8 +2460,8 @@
my @DV_list=();
#Print out all the Input Parameters with the associated MOBY Articles
- my $input_html= "<table width=\"50%\" border=\"1\"><tr><td width=\"40%\" height=\"28\">Number of Input Parameters :</td>
- <td width=\"60%\">$InputParam</td></tr>";
+ my $input_html= "<table width=\"50%\" border=\"1\"><tr><td width=\"45%\" height=\"28\">Number of Input Parameters :</td>
+ <td width=\"55%\">$InputParam</td></tr>";
for(my $s=0; $s<$InputParam;$s++){
$temp = $query->param("InputParam$s");
@@ -2958,7 +2472,7 @@
if ($temp2 eq "other"){
push(@DV_list,$temp);
}
- $input_html .= "<tr><td width=\"40%\" height=\"28\">Input Parameters $temp:</td>
+ $input_html .= "<tr><td width=\"45%\" height=\"28\">Input Parameters $temp:</td>
<td width=\"60%\">$temp2</td></tr>";
}
@@ -3021,19 +2535,12 @@
$Outmapping_html = "<table width=\"50%\" border=\"1\"><tr><td width=\"40%\" height=\"28\">Output Article :</td>
<td width=\"60%\">$temp2</td></tr>";
}
+ my $UI_string = UI_template("3");
print <<MAP;
<html>
- <head>
- <title>MOBY-S Web Service Auto-Generator - Data Confirmation</title>
+ $UI_string
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <div align="center">
- <p><font size="+3"><strong>Data Confirmation
- <div align="center">
- </strong></font></p>
- <p> </p>
The following are the values you have entered from the previous steps. If the data is correct, please click "next".<br>
If the data is incorrect, please go back the make the change<br>
<form method="get" action="/cgi-bin/code-generator0.6.cgi">
@@ -3068,7 +2575,6 @@
<input type="hidden" name="DV_count" value="$DV_count">
<input type="hidden" name="comline" value="$comline">
<input type="hidden" name="perlModules" value="$perlModules">
-
<div align="left">
<h2>General Web Services Data</h2>
<p>
@@ -3083,7 +2589,7 @@
<tr><td width="40%" height="28">Authority URI:</td><td width="60%">$authURI</td></tr>
<tr><td width="40%" height="28">Contact Email:</td><td width="60%">$contactEmail</td></tr>
<tr><td width="40%" height="28">Service Description:</td><td width="60%">$description</td></tr>
- <tr><td width="40%" height="28">SQL or Algorithm:</td><td width="60%">$htmlORcom</td></tr>
+ <tr><td width="40%" height="28">SQL or Algorithm:</td><td width="60%">$sqlORalgor_rad $htmlORcom</td></tr>
</table>
<p>
@@ -3101,6 +2607,7 @@
<h2>HTML Wrapper Default Value</h2>
$DV_html</table>
<p>
+ <hr>
<input type="Submit" name="Generate Dispatcher" value="Next">
</form>
</body>
@@ -3108,3 +2615,516 @@
MAP
}
+
+#####################################################################################################################################
+#####################################################################################################################################
+
+#Helper Function Section
+
+#####################################################################################################################################
+#####################################################################################################################################
+
+
+#*****************************************************************************
+#
+# name: mygetArticles
+# description: FUNCTION THAT GETS THE ARTICLES GIVEN AN OBJECT NAME, the URL returns an XML and it is parsed to get the articles
+# args: objectProduced
+# returns: an array with the elements being each article in the mobyObject
+#
+#*****************************************************************************
+sub mygetArticles
+{
+ my $objectProduced = shift;
+
+ my $URL = 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY_display_object_xml.cgi?obj=' . $objectProduced;
+
+ my $XML = get $URL;
+ die "Couldn't get to $URL" unless defined $XML;
+
+ $XML =~ s/\n//g;
+ $XML =~ s/> </></g;
+
+ #Now we need to parse the XML so that we only get the articles in the MOBY Object
+ #Place the articles into an array, then print them out one by one
+ my $parser = new XML::DOM::Parser;
+ my $theNode = $parser->parse($XML) or die "Could not parse";
+
+ #Gets the parameter
+ #my ($theNode) = @_;
+
+ my @articles;
+ #the first Node is #document
+ my $nodeList = $theNode->getChildNodes(); #nodeList is an object reference of the childnodes
+ my $length = $nodeList->getLength; #number of children
+
+ # $node is actually the moby object type, eg. Go_term
+ # we now assign the new current node to that.
+ my $node = $nodeList->item(0);
+
+ # We need to get the number of children this node has, because these are the elements/properties of the mobby object
+ my $objectLength = $node->getChildNodes->getLength;
+ #We also need to get the childNodes of the current node, which are the tags, such as "String" for articleName "Term"
+ my $newNodeList = $node->getChildNodes;
+
+ #Using a for loop we have to go thru each element of the object
+ for (my $i=0; $i<$objectLength; $i++)
+ {
+ my $newNode = $newNodeList->item($i);
+
+ #within each element there are attributes, which include the namespace, id and articlename
+ my $attLength; #This is the length of the attributes in the element
+ my $attList = $newNode->getAttributes; #gets the list of attributes in the element
+
+ #check if are attributes
+ if( $attList )
+ {
+ #assign the attribute length if there are attributes
+ $attLength = $attList->getLength;
+ }
+ if( $attLength)
+ {
+ #We go thru each attribute and only get the articleName
+ for( my $i=0; $i<$attLength; $i++)
+ {
+ my $attnode = $attList->item($i);
+ if ($attnode->getName eq "articleName")
+ {
+ push(@articles, $attnode->getValue);
+ }
+ }
+ }
+ }
+
+ return @articles;
+}
+#********************************************************************************
+#
+# name: getXMLObject
+# description: THIS FUNCTION TAKES IN THE MOBY OBJECT PRODUCED, mapping arrays (objectArticles array and sqlColumns) and spits back the MOBY Object needed to be produced
+# args: objectProduced, objectArticles (array), sqlColumns (array)
+# returns: an XML of the MobyObject Produced with the correct mappings onto each article
+#
+#********************************************************************************
+sub getXMLObject
+{
+ my ($objectProduced, $objectArticles, $sqlColumns, $namespace) = @_;
+
+ my $URL = 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY_display_object_xml.cgi?obj=' . $objectProduced;
+
+ my $XML = get $URL;
+ die "Couldn't get to $URL" unless defined $XML;
+
+ #We first need to get rid of the new lines, to get a proper XML
+ #Then we get change all texts that are "> <" to "><" to get a proper XML
+ $XML =~ s/\n//g;
+ $XML =~ s/> </></g;
+
+ #Creating a new XML parser
+ my $parser = new XML::DOM::Parser;
+ my $theNode = $parser->parse($XML) or die "Could not parse";
+
+ my $objectArticlesLength = @$objectArticles;
+ my $sqlColumnsLength = @$sqlColumns;
+
+ my $thisType = $theNode->getNodeType; #thisType is the type of node
+ my $nodeList = $theNode->getChildNodes; #nodeList is an object reference of the childnodes
+ my $name = $theNode->getNodeName; #name is the name of the node
+
+ my $length = $nodeList->getLength; #number of children
+
+ #$item(0) is the first node after #document, which is the MobyObject name, ie Go_Term
+ my $node = $nodeList->item(0);
+ my $objectLength = $node->getChildNodes->getLength;
+
+
+ #Get the childnodes as an array
+ my $newNodeList = $node->getChildNodes;
+ my $find = 0;
+ my $result = "";
+
+ #Going thru each child
+ for (my $i=0; $i<$objectLength; $i++)
+ {
+ my $newNode = $newNodeList->item($i);
+
+ #NEED TO COMPARE THE ARTICLES WITH THE MAPPING ARTICLES, THEN WE CAN CHANGE THE CONTEXT
+ my $attLength; #This is the length of the attributes in the element
+ my $attList = $newNode->getAttributes; #gets the list of attributes in the element
+
+ if( $attList ){ $attLength = $attList->getLength }; #assign the attribute length if there are attributes
+
+ if( $attLength)
+ {
+ #We go thru each attribute in the object, which is usually the 'namespace', 'id' and 'articleName'
+ for( my $i=0; $i<$attLength; $i++)
+ {
+ my $attnode = $attList->item($i);
+ #We need to check if the attribute is 'articleName'
+ if ($attnode->getName eq "articleName")
+ {
+ #And if it is 'articleName' we go thru the objectArticles array and compare the value of the articleName
+ #with the element in the array
+ for(my $i=0; $i<$objectArticlesLength; $i++)
+ {
+ #If the articleName is the same as the objectArticles we add a new textnode
+ if($attnode->getValue eq @$objectArticles[$i])
+ {
+ #adds the new text node to the element node, this text will be the sql column name
+ $newNode->addText('$' . (@$sqlColumns[$i]));
+ $find++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #Setting the object attributes namespace, id to $namespace and $accession respectively
+ my $objectAtt = $node->getAttributes;
+ my $objectAttLength = $objectAtt->getLength;
+ for (my $i=0; $i<$objectAttLength; $i++)
+ {
+ my $objectAttNode = $objectAtt->item($i);
+ if($objectAttNode->getName eq "namespace")
+ {
+ $objectAttNode->setValue("$namespace");
+ }
+ elsif ($objectAttNode->getName eq "id")
+ {
+ if ($find == $sqlColumnsLength){
+ $objectAttNode->setValue('$accession');
+ }
+ else{
+ for(my $i=0;$i<$sqlColumnsLength;$i++){
+ $objectAttNode->setValue("\$@$sqlColumns[$i]") if (@$objectArticles[$i] eq "id");
+ }
+
+ }
+ }
+ }
+
+ #Returns the whole XML back
+ return ($theNode->toString);
+}
+
+#**************************************************************************************
+#
+# name: fetcharray_columns
+# description: THIS FUNCTION OBTAINS THE COLUMNS IN THE SQL QUERY AND RETURNS IT AS A STRING EACH COLUMN SEPARATED WITH A COMMA
+# args: an array with the sql columns as it's elements
+# returns: one string which will contain all elements in the form $column_name and separated by a comma
+#
+#**************************************************************************************
+sub fetcharray_columns
+{
+ my @fields_array = @_;
+
+ my $fields_string = "";
+ my $length = @fields_array;
+
+ for (my $n=0; $n < $length; $n++)
+ {
+ if ($n eq ($length - 1))
+ {
+ $fields_string .= '$' . $fields_array[$n];
+ }
+ else
+ {
+ $fields_string .= '$'. $fields_array[$n] . ", ";
+ }
+ }
+
+ return lc($fields_string);
+}
+
+#**********************************************************************************
+#
+# name: first_column
+# description: THIS FUNCTION GRABS THE FIRST COLUMN IN THE SQL QUERY, MAIN USE OF THIS IS USE WHEN GETTING THE CODE FOR dbaccess_main
+# args: an array with the sql columns as it's elements
+# returns: the first element of the array in the form $column_name
+#
+#*********************************************************************************
+sub first_column
+{
+ my @fields_array = @_;
+
+ my $first_field = '$' . $fields_array[0];
+
+ return lc($first_field);
+}
+
+#*********************************************************************************
+#
+# name: parserSQL
+# description: THIS FUNCTION HELPS PARSE THE SQL STATEMENT TO GET THE FIELDS
+# args: an sql statement
+# returns: an array with each element being each sql column in the sql statement
+#
+#*********************************************************************************
+sub parseSQL {
+ my $sqlQuery = shift;
+
+# Create a parser
+ my($parser) = SQL::Statement->new('SQL::Statement');
+
+ # Parse an SQL statement
+ $@ = '';
+ my ($stmt) = eval {
+ SQL::Statement->new($sqlQuery,
+ $parser);
+ };
+ #Check if we can parse the statement
+ if ($@) {
+ die "Cannot parse statement: $@";
+ }
+
+ #Get the columns
+ my @columns = $stmt->columns();
+
+ #Foreach column create a new array with the column names
+ my @column_opts;
+ foreach (@columns)
+ {
+ push (@column_opts, $_->name());
+ }
+
+ return @column_opts;
+}
+
+
+#USED TO PARSE XML FILES - THERE IS NO NEED FOR THESE FUNCTIONS, Since they take a long time and have duplicate coding.
+#There is a way to get all the these elements already!!! >__< time well wasted though..lol
+# REFERENCE ON HOW TO PARSE XML FILES
+sub getServiceTypesArray {
+
+ my $names = MOBY::Central->retrieveServiceTypes(); #Replace retrievelServiceNames to get diff XML
+
+ my $parser = new XML::DOM::Parser;
+ my $doc = $parser->parse($names);
+
+ my $nodes = $doc->getElementsByTagName("serviceType"); #Replace serviceName with other things to get array
+ my $n = $nodes->getLength;
+
+ #print $n . "\n";
+
+ my @items;
+ for (my $i = 0; $i < $n; $i++)
+ {
+ my $node = $nodes->item ($i); #item method is in XML::DOM:NodeList
+ my $item = $node->getAttributeNode ("name"); #getAttributeNode method is in XML::DOM::Element
+ if (defined($item))
+ {
+ #print $item->getValue . "\n"; #getValue method is in XML::DOM::Attr
+ push @items, $item->getValue();
+ }
+ }
+ return @items;
+}
+
+sub getObjectsArray {
+
+ my $names = MOBY::Central->retrieveObjectNames(); #Replace retrievelServiceNames to get diff XML
+
+ my $parser = new XML::DOM::Parser;
+ my $doc = $parser->parse($names);
+
+ my $nodes = $doc->getElementsByTagName("Object"); #Replace serviceName with other things to get array
+ my $n = $nodes->getLength;
+
+ #print $n . "\n";
+
+ my @items;
+ for (my $i = 0; $i < $n; $i++)
+ {
+ my $node = $nodes->item ($i); #item method is in XML::DOM:NodeList
+ my $item = $node->getAttributeNode ("name"); #getAttributeNode method is in XML::DOM::Element
+ if (defined($item))
+ {
+ #print $item->getValue . "\n"; #getValue method is in XML::DOM::Attr
+ push @items, $item->getValue();
+ }
+ }
+ return @items;
+}
+
+sub getNamespacesArray {
+
+ my $names = MOBY::Central->retrieveNamespaces(); #Replace retrievelServiceNames to get diff XML
+
+ my $parser = new XML::DOM::Parser;
+ my $doc = $parser->parse($names);
+
+ my $nodes = $doc->getElementsByTagName("Namespace"); #Replace serviceName with other things to get array
+ my $n = $nodes->getLength;
+
+ #print $n . "\n";
+
+ my @items;
+ for (my $i = 0; $i < $n; $i++)
+ {
+ my $node = $nodes->item ($i); #item method is in XML::DOM:NodeList
+ my $item = $node->getAttributeNode ("name"); #getAttributeNode method is in XML::DOM::Element
+ if (defined($item))
+ {
+ #print $item->getValue . "\n"; #getValue method is in XML::DOM::Attr
+ push @items, $item->getValue();
+ }
+ }
+ return @items;
+}
+
+#*****************************************************************************
+#
+# name: getTagNAmebyArticles
+# description: FUNCTION THAT GETS THE TAG NAME that associated with AN OBJECT NAME and an ArticlesName,
+# args: objectProduced/objectConsumed, ArticleName
+# returns: Tag name
+#********************************************************************************
+sub getTagNamebyArticles
+{
+ my $objectProduced = shift;
+ my $aname = shift;
+
+ my $URL = 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY_display_object_xml.cgi?obj=' . $objectProduced;
+ my $XML = get $URL;
+ die "Couldn't get to $URL" unless defined $XML;
+
+ $XML =~ s/\n//g;
+ $XML =~ s/> </></g;
+
+ #Now we need to parse the XML so that we only get the articles in the MOBY Object
+ #Place the articles into an array, then print them out one by one
+ my $parser = new XML::DOM::Parser;
+ my $theNode = $parser->parse($XML) or die "Could not parse";
+
+ #Gets the parameter
+ #my ($theNode) = @_;
+
+ my @articles;
+ #the first Node is #document
+ my $nodeList = $theNode->getChildNodes(); #nodeList is an object reference of the childnodes
+ my $length = $nodeList->getLength; #number of children
+
+ # $node is actually the moby object type, eg. Go_term
+ # we now assign the new current node to that.
+ my $node = $nodeList->item(0);
+
+ # We need to get the number of children this node has, because these are the elements/properties of the mobby object
+ my $objectLength = $node->getChildNodes->getLength;
+ #We also need to get the childNodes of the current node, which are the tags, such as "String" for articleName "Term"
+ my $newNodeList = $node->getChildNodes;
+
+ #Using a for loop we have to go thru each element of the object
+ for (my $i=0; $i<$objectLength; $i++)
+ {
+ my $newNode = $newNodeList->item($i);
+ my $name = $newNode->getNodeName;
+ #within each element there are attributes, which include the namespace, id and articlename
+ my $attLength; #This is the length of the attributes in the element
+ my $attList = $newNode->getAttributes; #gets the list of attributes in the element
+
+ #check if are attributes
+ if( $attList )
+ {
+ #assign the attribute length if there are attributes
+ $attLength = $attList->getLength;
+ }
+ if( $attLength)
+ {
+ #We go thru each attribute and articleName to get the Tag Name
+ for( my $i=0; $i<$attLength; $i++)
+ {
+ my $attnode = $attList->item($i);
+ if (($attnode->getName eq "articleName") and ($attnode->getValue eq $aname))
+ {
+ return $name;
+ }
+ }
+ }
+ }
+}
+
+###################################################################
+# Name: UI_template
+# Description: A Function that will return the User Interface of the Program
+# args: a number indicate the current procedure
+# returns: a user interface of the current state
+#
+###################################################################
+sub UI_template{
+
+ my $ver = shift;
+ my $title_html = "Step 1: Service Properties";
+ my $steps = qq{<p style="text-align: left;"><big><span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">1. Service Properties</span> </span> > 2. Service Algorithm > 3. Data Confirmation > 4. Dispatcher > 5. Code Generation<br></big></p>};
+
+ if ($ver == "2"){
+ $title_html = "Step 2: Service Algorithm";
+ $steps = qq{<p style="text-align: left;"><big>1. Service Properties > <span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">2. Service Algorithm </span></span> > 3. Data Confirmation > 4. Dispatcher > 5. Code Generation<br></big></p>};
+ }
+ elsif ($ver == "3"){
+ $title_html = "Step 3: Data Confirmation";
+ $steps = qq{<p style="text-align: left;"><big>1. Service Properties > 2. Service Algorithm > <span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);"> 3. Data Confirmation </span></span>> 4. Dispatcher > 5. Code Generation<br></big></p>};
+ }
+ elsif ($ver == "4"){
+ $title_html = "Step 4: Dispatcher";
+ $steps = qq{<p style="text-align: left;"><big>1. Service Properties > 2. Service Algorithm > 3. Data Confirmation > <span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">4. Dispatcher </span></span>> 5. Code Generation<br></big></p>};
+ }
+ elsif ($ver == "5"){
+ $title_html = "Step 5: Code Generation";
+ $steps = qq{<p style="text-align: left;"><big>1. Service Properties > 2. Service Algorithm > 3. Data Confirmation > 4. Dispatcher > <span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">5. Code Generation</span></span><br></big></p>};
+ }
+
+ my $UI_string = qq{
+<html>
+<head>
+ <title>Code Generator V0.6 : Web Service Properties</title>
+</head>
+<body>
+<div style="text-align: right;">
+<table cellpadding="0" cellspacing="0" border="0"
+ style="text-align: left; width: 100%; background-color: rgb(255, 255, 255);">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top; width: 80px;"><img
+ style="height: 67px; width: 137px;"
+ src="http://www.biomoby.org/moby1.gif" title="" alt=""></td>
+ <td style="vertical-align: top; text-align: center;"><big><big><big><big><big><small>Code
+Generator 0.6</small></big></big></big></big></big></td>
+ <td style="vertical-align: top; width: 80px;"><img
+ src="http://biomoby.org/powered_by_MOBY-S.jpg" title="" alt=""
+ style="width: 144px; height: 57px;"></td>
+ </tr>
+ </tbody>
+</table>
+</div>
+<table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
+ <tbody>
+ <tr>
+ <td colspan="2" bgcolor="#006699"
+ style="background-color: rgb(192, 192, 192);"> </td>
+ <td bgcolor="#006699"><br>
+ </td>
+ </tr>
+ <tr>
+ <td
+ style="vertical-align: top; height: 800px; width: 150px; background-color: rgb(192, 192, 192);"><br>
+ <center><a href="http://www.biomoby.org">BioMOBY</a><br>
+ <br><a href="http://bioinfo.icapture.ubc.ca/mng/Documentation.html">Code Generator Documentation</a><br>
+ <br>
+ <a href="http://www.biomoby.org/tutorials.html">MOBY Web Services
+Tutorial</a><br>
+ <br>
+ <a href="http://bioinfo.icapture.ubc.ca/mng">About</a><br>
+ </center>
+ </td>
+ <td valign="top" align="center">
+ $steps
+ <h2 style="background-color: rgb(192, 192, 192);">$title_html<br>
+ </h2>
+ <br>
+ };
+
+ return $UI_string;
+}
More information about the MOBY-guts
mailing list