[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Wed Nov 19 14:24:14 UTC 2008


kawas
Wed Nov 19 09:24:14 EST 2008
Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates
In directory dev.open-bio.org:/tmp/cvs-serv9702/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates

Modified Files:
	service.tt 
Log Message:
bug fix: when using service that consumes/outputs a primitive, certain 'use' statements are missing and service dies.
moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates service.tt,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates/service.tt,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates/service.tt	2008/03/31 18:05:17	1.4
+++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates/service.tt	2008/11/19 14:24:14	1.5
@@ -50,7 +50,68 @@
        ),
        [%- END %]
     [%- END -%]
+    
+    [%- MACRO get_use_statements (inputs, outputs) BLOCK %]
+    	[%- SET use_statements = [] -%]
+    	[%- FOREACH input IN inputs -%]
+			[%- IF NOT is_simple (input) -%]
+			    [%- found = 0 -%]
+			    [%- FOREACH e IN use_statements -%]
+			    	[%- SET found = 1 IF e == input.elements.0.datatype.name -%]
+			    [%- END -%]
+				[%- IF NOT found %]
+					[%- use_statements.push (input.elements.0.datatype.name) -%]
+					[%- get_use_statement(input.elements.0.datatype.name) -%]
+				[%- END -%]
+			[%- ELSE -%]
+				[%- found = 0 -%]
+			    [%- FOREACH e IN use_statements -%]
+			    	[%- SET found = 1 IF e == input.datatype.name -%]
+			    [%- END -%]
+				[%- IF NOT found %]
+					[%- use_statements.push (input.datatype.name) -%]
+					[%- get_use_statement(input.datatype.name) -%]
+				[%- END -%]
+			[%- END -%]
+		[%- END -%]
+		[%- FOREACH output IN outputs -%]
+			[%- IF NOT is_simple (output) -%]
+			    [%- found = 0 -%]
+			    [%- FOREACH e IN use_statements -%]
+			    	[%- SET found = 1 IF e == output.elements.0.datatype.name -%]
+			    [%- END -%]
+				[%- IF NOT found %]
+					[%- use_statements.push (output.elements.0.datatype.name) -%]
+					[%- get_use_statement(output.elements.0.datatype.name) -%]
+				[%- END -%]
+			[%- ELSE -%]
+				[%- found = 0 -%]
+			    [%- FOREACH e IN use_statements -%]
+			    	[%- SET found = 1 IF e == output.datatype.name -%]
+			    [%- END -%]
+				[%- IF NOT found %]
+					[%- use_statements.push (output.datatype.name) -%]
+					[%- get_use_statement(output.datatype.name) -%]
+				[%- END -%]
+			[%- END -%]
+		[%- END -%]
+    [%- END -%]
+    
+    [%- MACRO get_use_statement(datatype) BLOCK %]
+    	[%- IF datatype    == 'String'   %]use MOSES::MOBY::Data::String;
+
+		[%- ELSIF datatype == 'Integer'  %]use MOSES::MOBY::Data::Integer;
+
+		[%- ELSIF datatype == 'Float'    %]use MOSES::MOBY::Data::Float;
 
+		[%- ELSIF datatype == 'Boolean'  %]use MOSES::MOBY::Data::Boolean;
+
+		[%- ELSIF datatype == 'DateTime' %]use MOSES::MOBY::Data::DateTime;
+
+		[%- END -%]
+	[%- END -%]
+    
+    
     [%- MACRO no_children (datatype, value) BLOCK %]
        [%- IF datatype    == 'String'   %]value => "this is a value [% value %]",   # TO BE EDITED
        [%- ELSIF datatype == 'Integer'  %]value => 42,   # TO BE EDITED
@@ -143,6 +204,9 @@
 use MOSES::MOBY::ServiceException;
 use strict;
 
+[%# here we output use statements for our primitives %]
+[%- get_use_statements(base.inputs, base.outputs) -%]
+
 my %valid_namespaces = ( [% FOREACH ns IN input_ns %] '[%ns%]'=>1,  [% END %]);
 #-----------------------------------------------------------------
 # process_it




More information about the MOBY-guts mailing list