[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Tue Dec 18 23:08:29 UTC 2007


gordonp
Tue Dec 18 18:08:29 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services
In directory dev.open-bio.org:/tmp/cvs-serv15286/src/main/ca/ucalgary/services

Modified Files:
	ACDService.java 
Log Message:
Added better support for nullok and non-literal int/double param values
moby-live/Java/src/main/ca/ucalgary/services ACDService.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java	2007/12/17 18:38:23	1.7
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java	2007/12/18 23:08:29	1.8
@@ -10,6 +10,7 @@
 import org.biomoby.shared.data.*;
 
 import java.io.*;
+import java.math.*;
 import java.net.URL;
 import java.util.*;
 import java.util.regex.Pattern;
@@ -912,7 +913,7 @@
 		if("boolean".equals(acdType) || "toggle".equals(acdType)){
 		    MobySecondaryData bool = new MobySecondaryData(acdName);
 		    bool.setDataType(MobySecondaryData.BOOLEAN_TYPE);
-		    bool.setDefaultValue(deFault);
+		    bool.setDefaultValue(""+Boolean.parseBoolean(deFault));
 		    bool.setDescription(block.get("help"));
 		    mobyDataType = bool;
 		}
@@ -935,10 +936,23 @@
 		else if("integer".equals(acdType)){
 		    MobySecondaryData integer = new MobySecondaryData(acdName);
 		    integer.setDataType(MobySecondaryData.INTEGER_TYPE);
-		    integer.setDefaultValue(deFault);
 		    integer.setDescription(block.get("information"));
-		    integer.setMinValue(block.get("minimum"));
-		    integer.setMaxValue(block.get("maximum"));
+		    String m = block.get("maximum");
+		    try{m = (new BigInteger(m)).toString();}catch(NumberFormatException nfe){m = ""+Integer.MAX_VALUE;}
+		    integer.setMaxValue(m);
+		    m = block.get("minimum");
+		    try{m = (new BigInteger(m)).toString();}catch(NumberFormatException nfe){m = ""+Integer.MIN_VALUE;}
+		    integer.setMinValue(m);
+		    // Set default to 0, or minimum value if it's not Integer.MIN_VALUE
+		    try{
+			deFault = (new BigInteger(deFault)).toString();
+		    }
+		    catch(NumberFormatException nfe){
+			deFault = (Integer.parseInt(m) == Integer.MIN_VALUE ? 
+				   (Integer.parseInt(integer.getMaxValue()) == Integer.MAX_VALUE ? 
+				    "0" : integer.getMaxValue()): m);
+		    }
+		    integer.setDefaultValue(deFault);
 		    mobyDataType = integer;
 		}
 		else if("float".equals(acdType)){
@@ -946,8 +960,21 @@
 		    floating.setDataType(MobySecondaryData.FLOAT_TYPE);
 		    floating.setDefaultValue(deFault);
 		    floating.setDescription(block.get("information"));
-		    floating.setMinValue(block.get("minimum"));
-		    floating.setMaxValue(block.get("maximum"));
+		    String m = block.get("maximum");
+		    try{m = (new BigDecimal(m)).toString();}catch(NumberFormatException nfe){m = ""+Double.MAX_VALUE;}
+		    floating.setMaxValue(m);
+		    m = block.get("minimum");
+		    try{m = (new BigDecimal(m)).toString();}catch(NumberFormatException nfe){m = ""+Double.MIN_VALUE;}
+		    floating.setMinValue(m);
+		    // Set default to 0, or minimum value if it's not Double.MIN_VALUE
+		    try{
+			deFault = (new BigDecimal(deFault)).toString();
+		    }
+		    catch(NumberFormatException nfe){
+			deFault = (Double.parseDouble(m) == Double.MIN_VALUE ? 
+				   (Double.parseDouble(floating.getMaxValue()) == Double.MAX_VALUE ? 
+				    "0.0" : floating.getMaxValue()): m);
+		    }
 		    mobyDataType = floating;
 		}
 		else{
@@ -963,7 +990,11 @@
 		// If it's an input or output parameter, just fill in a basic object to keep
 		// track if the name of the ACD parameter and whether it's a collection or not.
 		// The calling methods must make sure these match the MOBY service description provided
-		if(acdType.endsWith("set")){
+		String canBeNull = block.get("nullok");
+		if(canBeNull != null && canBeNull.equals("Y")){
+		    // do nothing, hence not add as parameter.  TODO: evaluate "standard" condition instead
+		}
+		else if(acdType.endsWith("set")){
 		    mobyDataType = new MobyPrimaryDataSet(acdName);
 		}
 		else{




More information about the MOBY-guts mailing list