[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu May 8 17:44:48 UTC 2003


mwilkinson
Thu May  8 13:44:48 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv1830/Perl/MOBY/Client

Modified Files:
	Central.pm 
Log Message:
got the perl client to create correct XML for service registration
moby-live/Perl/MOBY/Client Central.pm,1.14,1.15
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2003/05/08 15:47:08	1.14
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2003/05/08 17:44:48	1.15
@@ -502,37 +502,38 @@
      contactEmail => "your at mail.address",      
      description => $human_readable_description, 
      category  =>  "moby" | "cgi" | "soap" (currently only moby supported)
+     URL    =>  $URL_TO_SERVICE
                 
  Category Specific Args:
 	 
    input:	 
-      moby: input =>[
-					 [objType1 => [ns1, ns2...], articleName], # Simple
-                     [[objType1 => [ns1, ns2...]], articleName] # Collection (one object Class)
-                     [[objType2 => [ns1, ns2...],
-					   objType3 => [ns1, ns2...]], articleName] # Collection (two object Classes)
-                     ]
-      moby: secondary =>[articleName => {
-		                    datatype => TYPE,
-							default => DEFAULT
-							max => MAX
-							min => MIN
-							enum => [ENUM1, ENUM2...]
-							},
-                         articleName2 => {...},
-                         articleName3 => {...}]
+		input =>{
+					 articleName1 => [objType1 => [ns1, ns2...]], # Simple
+                    articleName2 => [[objType2 => [ns3, ns4...]]], # collection of one object type
+                    articleName3 => [[objType3 => [ns3, ns4...]], [objType4 => [ns5, ns6]]], # collection of multiple object types
+               }
    
 
    output:
-      moby: output =>[
-					 [objType1 => [ns1, ns2...], articleName], # Simple
-                     [[objType1 => [ns1, ns2...]], articleName] # Collection (one object Class)
-                     [[objType2 => [ns1, ns2...],
-					   objType3 => [ns1, ns2...]], articleName] # Collection (two object Classes)
-                     ]
+		output =>{
+					 articleName1 => [objType1 => [ns1, ns2...]], # Simple
+                    articleName2 => [[objType2 => [ns3, ns4...]]], # collection of one object type
+                    articleName3 => [[objType3 => [ns3, ns4...]], [objType4 => [ns5, ns6]]], # collection of multiple object types
+               }
             
-	 URL:
-		 moby: URL    =>  $URL_TO_SERVICE
+    secondary:
+		secondary => {parametername1 => {datatype => TYPE,
+										default => DEFAULT,
+										max => MAX,
+										min => MIN,
+										enum => [one, two]},
+					parametername2 => {datatype => TYPE,
+										default => DEFAULT,
+										max => MAX,
+										min => MIN,
+										enum => [one, two]}
+					  }
+		
 
 
 =cut
@@ -592,69 +593,73 @@
 			<authURI>$authURI</authURI>";
 
 	if ($Category eq "moby") {
-		my @IN = @{$a{input}}; 
-		my @OUT = @{$a{output}};
-		my @SEC = @{$a{secondary}};
-		$message .= "<Input>\n";
-		foreach my $Article(@IN){
-			my ($Objects, $articleName) = @{$Article};
-			my @Objects;				
-			if (ref($Objects) =~ /array/i){
-				@Objects = @{$Objects};
-				$message .="<Collection articleName='$articleName'>\n";
-				$articleName="";
-			} else {
-				@Objects = $Objects;
-			}
-			foreach my $Object(@Objects){
-				$message .="<Simple articleName='$articleName'>\n";
-				my ($type, $Namespaces) = @{$Object};
-				$message .="<objectType>$type</objectType>\n";
-				foreach my $ns(@{$Namespaces}){
-					$message .="<Namespace>$ns</Namespace>\n";
+		my %IN = %{$a{input}}; 
+		my %OUT = %{$a{output}};
+		my %SEC = %{$a{secondary}};
+		my %funkyhash = ( Input => \%IN, Output => \%OUT);
+		while (my ($inout, $param) = each %funkyhash){
+			my $inout_lc = lc ($inout);
+			my %PARAM = %{$param};
+			$message .= "<${inout_lc}Objects><${inout}>\n";
+		
+#		input =>{
+#					 articleName1 => [objType1 => [ns1, ns2...]],
+#                    articleName2 => [[objType2 => [ns3, ns4...]]],
+#                    articleName3 => [[objType3 => [ns3, ns4...]], [objType4 => [ns5, ns6],
+#               }
+
+			while (my ($articleName, $def) = each %PARAM){
+				my @Objects; #
+				unless (ref($def) =~ /array/i){return $self->errorRegXML("invalid structure of $inout objects, expected arrayref for article $articleName")}
+				my @objectdefs;			
+				if ((ref $def->[0]) =~ /array/i){ # collection
+					# def= [[objType2 => [ns3, ns4...]], ...]
+					$message .="<Collection>\n";
+					@objectdefs = @{$def};					
+				} else {  # Nipple
+					@objectdefs = ($def);
+					# def = [objType1 => [ns1, ns2...]],
 				}
-				$message .="</Simple>\n";
-			}
-			if (ref($Objects) =~ /array/i){
-				$message .="</Collection>\n";
-			}
-		}
-		$message .= "
-			   </Input>\n";
-		$message .= "<Output>\n";
-		foreach my $Article(@OUT){
-			my ($Objects, $articleName) = @{$Article};
-			my @Objects;
-			if (ref($Objects) =~ /array/i){
-				@Objects = @{$Objects};
-				$message .="<Collection articleName='$articleName'>\n";
-				$articleName="";
-			} else {
-				@Objects = $Objects;
-			}
-			foreach my $Object(@Objects){
-				$message .="<Simple articleName='$articleName'>\n";
-				my ($type, $Namespaces) = @{$Object};
-				$message .="<objectType>$type</objectType>\n";
-				foreach my $ns(@{$Namespaces}){
-					$message .="<Namespace>$ns</Namespace>\n";
+				
+				foreach my $objectdef(@objectdefs){
+					$message .="<Simple articleName='$articleName'>\n";
+					my ($type, $Namespaces) = @{$objectdef};
+					$message .="<objectType>$type</objectType>\n";
+					unless (ref($Namespaces) =~ /array/i){return $self->errorRegXML("invalid structure of $inout namespaces for object $type in article $articleName; expected arrayref")}
+					foreach my $ns(@{$Namespaces}){
+						$message .="<Namespace>$ns</Namespace>\n";
+					}
+					$message .="</Simple>\n";
+				}
+				if ((ref($def->[0])) =~ /array/i){
+					$message .="</Collection>\n";
 				}
-				$message .="</Simple>\n";
-			}
-			if (ref($Objects) =~ /array/i){
-				$message .="</Collection>\n";
 			}
+			$message .= "</${inout}></${inout_lc}Objects>\n";
 		}
-		$message .= "</Output>\n";
-			$message .="<secondaryArticles>\n";
-		foreach my $Sec(@SEC){
-			my ($param, $data) = @{$Sec};
-			my %data = %{$data};
+#		secondary => {parametername1 => {datatype => TYPE,
+#										default => DEFAULT,
+#										max => MAX,
+#										min => MIN,
+#										enum => [one, two]},
+#					parametername2 => {datatype => TYPE,
+#										default => DEFAULT,
+#										max => MAX,
+#										min => MIN,
+#										enum => [one, two]}
+#					  }
+#
+
+		$message .="<secondaryArticles>\n";
+		while (my ($param, $desc) = each %SEC){
+			unless ((ref($desc)) =~ /hash/i){return $self->errorRegXML("invalid structure of secondary article $param; expected hashref of limitations")}
+			my %data = %{$desc};
 			my $default = $data{default};
 			my $max = $data{max};
 			my $min = $data{min};
 			my $datatype = $data{datatype};
-			return $self->errorRegXML("a secondaryArticle must contain at least a datatype value");
+			unless ($datatype){return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param");}
+			unless ((ref($data{enum})) =~ /array/i){return $self->errorRegXML("invalid structure of enum limits in secondary article $param; expected arrayref")}
 			my @enums = @{$data{enum}};
 			$message .="<Parameter articleName='$param'>\n";
 			$message .="<default>$default</default>\n";
@@ -663,7 +668,8 @@
 			$message .="<min></min>\n";
 			foreach (@enums){
 				$message .="<enum>$_</enum>\n";
-			}			
+			}
+			$message .="</Parameter>\n";
 		}
 		$message .= "</secondaryArticles>\n";
 		$message .= "</registerService>";




More information about the MOBY-guts mailing list