Changeset 3586
- Timestamp:
- Jul 20, 2007, 2:40:10 PM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 5 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/AnnotationType.java
r3527 r3586 1094 1094 if (pv == null || !pv.getValues().contains(value)) 1095 1095 { 1096 throw new InvalidDataException("Value '"+value+"' is not among the list of allowed values: "+(pv == null ? "" : pv.getValues())); 1096 throw new DisallowedValueException("Value '"+value+"' is not among the list of allowed values " + 1097 "for annotation type: "+getName()); 1097 1098 } 1098 1099 } -
trunk/src/core/net/sf/basedb/core/Install.java
r3572 r3586 606 606 createPluginDefinition("net.sf.basedb.plugins.CdfFileReporterImporter", null, null, true, null, false); 607 607 createPluginDefinition("net.sf.basedb.plugins.PackedFileExporter", null, keyEveryoneUse, true, null, true); 608 createPluginDefinition("net.sf.basedb.plugins.AnnotationFlatFileImporter", null, keyEveryoneUse, true, null, false); 608 609 609 610 // Plugin configurations -
trunk/src/core/net/sf/basedb/core/PluginRequest.java
r2981 r3586 146 146 } 147 147 148 /** 149 Get the values that are currently stored in the job or plugin configuration 150 related to this request. This method will first check the job and then the 151 plugin configuration. 152 @param name The name of the parameter 153 @return The parameter values, or null if no parameter with the given name 154 exists 155 */ 148 156 public List<?> getCurrentParameterValues(String name) 149 157 { … … 153 161 values = jobParameters.getValues(name); 154 162 } 155 else if (configurationParameters != null)163 if (values == null && configurationParameters != null) 156 164 { 157 165 values = configurationParameters.getValues(name); … … 161 169 162 170 171 /** 172 Get the values that are currently stored in the plugin configuration 173 related to this request. 174 @param name The name of the parameter 175 @return The parameter values, or null if no parameter with the given name 176 exists or if this request isn't associated with a plugin configuration 177 */ 163 178 public List<?> getCurrentConfigurationParameterValues(String name) 164 179 { … … 171 186 } 172 187 188 /** 189 Get the values that are currently stored in the job related to this 190 request. 191 @param name The name of the parameter 192 @return The parameter values, or null if no parameter with the given name 193 exists or if this request isn't associated with a job 194 */ 173 195 public List<?> getCurrentJobParameterValues(String name) 174 196 { -
trunk/src/plugins/core/net/sf/basedb/plugins/AbstractFlatFileImporter.java
r3493 r3586 953 953 return mapper; 954 954 } 955 955 956 /** 957 Get the value for an error handling parameter. If no value 958 is found for the specified parameter the value for the 'defaultError' parameter 959 is returned. 960 @param parameterName The name of the error parameter 961 @return The error option or null if no option has been set 962 @since 2.4 963 */ 964 protected String getErrorOption(String parameterName) 965 { 966 Object option = null; 967 option = job.getValue(parameterName); 968 if (option == null) option = job.getValue("defaultError"); 969 return option == null ? null : option.toString(); 970 } 971 956 972 protected ErrorHandler getErrorHandler(String method, ErrorHandler defaultErrorHandler) 957 973 { -
trunk/src/test/TestAll.java
r3471 r3586 72 72 results.put("TestProtocol", TestProtocol.test_all()); 73 73 74 // Annotation types and annotations 75 results.put("TestAnnotationType", TestAnnotationType.test_all()); 76 results.put("TestAnnotationTypeCategory", TestAnnotationTypeCategory.test_all()); 77 results.put("TestAnnotation", TestAnnotation.test_all()); 78 74 // File parsing 75 results.put("TestFlatFileParser", TestFlatFileParser.test_all()); 76 79 77 // Biomaterials 80 78 results.put("TestBioSource", TestBioSource.test_all()); … … 84 82 results.put("TestLabeledExtract", TestLabeledExtract.test_all()); 85 83 86 // File parsing 87 results.put("TestFlatFileParser", TestFlatFileParser.test_all()); 88 84 // Annotation types and annotations 85 results.put("TestAnnotationType", TestAnnotationType.test_all()); 86 results.put("TestAnnotationTypeCategory", TestAnnotationTypeCategory.test_all()); 87 results.put("TestAnnotation", TestAnnotation.test_all()); 88 results.put("TestAnnotationFlatFileImporter", TestAnnotationFlatFileImporter.test_all()); 89 89 90 // Reporters 90 91 results.put("TestReporterType", TestReporterType.test_all()); -
trunk/src/test/TestAnnotation.java
r2314 r3586 48 48 // Create annotation types and array design 49 49 50 int intId = TestAnnotationType.test_create( Type.INT, 10, Item.ARRAYDESIGN, null, true);51 int longId = TestAnnotationType.test_create( Type.LONG, 1056567756767l, Item.ARRAYDESIGN, null, true);52 int floatId = TestAnnotationType.test_create( Type.FLOAT, 10.1f, Item.ARRAYDESIGN, null, true);53 int doubleId = TestAnnotationType.test_create( Type.DOUBLE, 8.13454646d, Item.ARRAYDESIGN, null, true);54 int dateId = TestAnnotationType.test_create( Type.DATE, new Date(), Item.ARRAYDESIGN, null, true);55 int textId = TestAnnotationType.test_create( Type.TEXT, "default value", Item.ARRAYDESIGN, null, true);56 int stringId = TestAnnotationType.test_create( Type.STRING, "default value", Item.ARRAYDESIGN, null, true);57 int booleanId = TestAnnotationType.test_create( Type.BOOLEAN, true, Item.ARRAYDESIGN, null, true);58 int enumId = TestAnnotationType.test_create( Type.INT, 3, Item.ARRAYDESIGN, new Object[] { 1, 2, 3, 4, 5 }, false);50 int intId = TestAnnotationType.test_create(null, Type.INT, 10, null, Item.ARRAYDESIGN, 1, null, true); 51 int longId = TestAnnotationType.test_create(null, Type.LONG, 1056567756767l, null, Item.ARRAYDESIGN, 1, null, true); 52 int floatId = TestAnnotationType.test_create(null, Type.FLOAT, 10.1f, null, Item.ARRAYDESIGN, 1, null, true); 53 int doubleId = TestAnnotationType.test_create(null, Type.DOUBLE, 8.13454646d, null, Item.ARRAYDESIGN, 1, null, true); 54 int dateId = TestAnnotationType.test_create(null, Type.DATE, new Date(), null, Item.ARRAYDESIGN, 1, null, true); 55 int textId = TestAnnotationType.test_create(null, Type.TEXT, "default value", null, Item.ARRAYDESIGN, 1, null, true); 56 int stringId = TestAnnotationType.test_create(null, Type.STRING, "default value", null, Item.ARRAYDESIGN, 1, null, true); 57 int booleanId = TestAnnotationType.test_create(null, Type.BOOLEAN, true, null, Item.ARRAYDESIGN, 1, null, true); 58 int enumId = TestAnnotationType.test_create(null, Type.INT, 3, null, Item.ARRAYDESIGN, 1, new Object[] { 1, 2, 3, 4, 5 }, false); 59 59 int arrayDesignId = TestArrayDesign.test_create(true, false); 60 60 … … 69 69 int booleanAnnotationId = test_annotatate(arrayDesignId, booleanId, false); 70 70 int enumAnnotationId = test_annotatate(arrayDesignId, enumId, 4); 71 test_list_annotations( arrayDesignId, 9);71 test_list_annotations(Item.ARRAYDESIGN, arrayDesignId, 9); 72 72 73 73 // Test: inherit annotations … … 95 95 test_remove_annotation(arrayDesignId, booleanId); 96 96 test_remove_annotation(arrayDesignId, enumId); 97 test_list_annotations( arrayDesignId, 0);97 test_list_annotations(Item.ARRAYDESIGN, arrayDesignId, 0); 98 98 99 99 // Delete annotation types and array design … … 176 176 } 177 177 178 static void test_list_annotations(int arrayDesignId, int expectedResults) 179 { 180 DbControl dc = null; 181 try 182 { 183 dc = TestUtil.getDbControl(); 184 ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId); 185 AnnotationSet as = ad.getAnnotationSet(); 178 static void test_list_annotations(Item itemType, int itemId, int expectedResults) 179 { 180 DbControl dc = null; 181 Annotatable at = null; 182 try 183 { 184 dc = TestUtil.getDbControl(); 185 at = (Annotatable)itemType.getById(dc, itemId); 186 AnnotationSet as = at.getAnnotationSet(); 186 187 ItemResultList<Annotation> l = as.getAnnotations().list(dc); 187 188 for (int i = 0; i<l.size(); i++) … … 193 194 throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); 194 195 } 195 write("--List annotations OK ("+l.size()+")");196 } 197 catch (Throwable ex) 198 { 199 write("--List annotations FAILED");196 write("--List annotations for " + at + " OK ("+l.size()+")"); 197 } 198 catch (Throwable ex) 199 { 200 write("--List annotations for " + at + " FAILED"); 200 201 ex.printStackTrace(); 201 202 ok = false; -
trunk/src/test/TestAnnotationType.java
r3527 r3586 45 45 write_header(); 46 46 // Standard tests: create, load, list 47 int id_int = test_create( Type.INT, 10, Item.SAMPLE, null, true);48 int id_long = test_create( Type.LONG, 123456789123456l, Item.SAMPLE, null, true);49 int id_float = test_create( Type.FLOAT, 10.1, Item.SAMPLE, null, false);50 int id_double = test_create( Type.DOUBLE, 8.13459187745, Item.SAMPLE, null, false);51 int id_date = test_create( Type.DATE, new Date(), Item.SAMPLE, null, false);52 int id_text = test_create( Type.TEXT, "default value", Item.SAMPLE, null, false);53 int id_string = test_create( Type.STRING, "default value", Item.SAMPLE, null, false);54 int id_boolean = test_create( Type.BOOLEAN, true, Item.SAMPLE, null, false);55 int id_enum = test_create( Type.INT, 3, Item.SAMPLE, new Object[] { 1, 2, 3, 4, 5 }, false);56 int id2_enum = test_create( Type.STRING, "one", Item.SAMPLE, new String[] { "one", "two ", "three" }, false);47 int id_int = test_create(null, Type.INT, 10, null, Item.SAMPLE, 1, null, true); 48 int id_long = test_create(null, Type.LONG, 123456789123456l, null, Item.SAMPLE, 1, null, true); 49 int id_float = test_create(null, Type.FLOAT, 10.1, null, Item.SAMPLE, 1, null, false); 50 int id_double = test_create(null, Type.DOUBLE, 8.13459187745, null, Item.SAMPLE, 1, null, false); 51 int id_date = test_create(null, Type.DATE, new Date(), null, Item.SAMPLE, 1, null, false); 52 int id_text = test_create(null, Type.TEXT, "default value", null, Item.SAMPLE, 1, null, false); 53 int id_string = test_create(null, Type.STRING, "default value", null, Item.SAMPLE, 1, null, false); 54 int id_boolean = test_create(null, Type.BOOLEAN, true, null, Item.SAMPLE, 1, null, false); 55 int id_enum = test_create(null, Type.INT, 3, null, Item.SAMPLE, 1, new Object[] { 1, 2, 3, 4, 5 }, false); 56 int id2_enum = test_create(null, Type.STRING, "one", null, Item.SAMPLE, 1, new String[] { "one", "two ", "three" }, false); 57 57 test_load(id_int); 58 58 test_load(id_long); … … 99 99 } 100 100 101 static int test_create( Type type, Object defaultValue, Item itemType, Object[] enumValues, boolean setAll)101 static int test_create(String name, Type type, Object defaultValue, Number maxValue, Item itemType, int multiplicity, Object[] enumValues, boolean setAll) 102 102 { 103 103 if (!TestUtil.hasPermission(Permission.CREATE, Item.ANNOTATIONTYPE)) return 0; … … 110 110 if(setAll) 111 111 { 112 at.setName( "Test annotation type: "+type);112 at.setName( "Test annotation type: "+type); 113 113 at.setDescription("Added at "+new Date()); 114 at.setMultiplicity(1);115 114 at.setRequiredForMiame(true); 116 115 at.setHeight(10); … … 118 117 at.setExternalId("my.external.annotationtype"); 119 118 } 119 at.setMultiplicity(multiplicity); 120 if (name != null) at.setName(name); 120 121 if (enumValues != null) 121 122 { … … 125 126 } 126 127 if (defaultValue != null) at.setDefaultValue(defaultValue.toString()); 128 if (maxValue != null) 129 { 130 if (type.isNumerical()) 131 { 132 at.setMinValueLong(0l); 133 at.setMaxValueLong(maxValue.longValue()); 134 } 135 else if (type == Type.STRING) 136 { 137 at.setMaxLength(maxValue.intValue()); 138 } 139 } 127 140 at.enableForItem(itemType); 128 141 dc.saveItem(at); -
trunk/src/test/TestAnnotationTypeCategory.java
r2517 r3586 59 59 60 60 // extra test: add categories to annotation type 61 int id_int = TestAnnotationType.test_create( Type.INT, 10, Item.SAMPLE, null, true);61 int id_int = TestAnnotationType.test_create(null, Type.INT, 10, null, Item.SAMPLE, 1, null, true); 62 62 test_add_categories(id_int, id, id2); 63 63 test_list_categories(id_int, 2); -
trunk/src/test/TestAnyToAny.java
r3454 r3586 48 48 write_header(); 49 49 // Standard tests: create, load, list 50 int sampleId = TestSample.test_create(0, true);50 int sampleId = TestSample.test_create(0, null, true); 51 51 int fileId1 = TestFile.test_create("Linked file #1", true); 52 52 int fileId2 = TestFile.test_create("Linked file #2", true); -
trunk/src/test/TestExtract.java
r2314 r3586 45 45 int id2 = test_create(0, false); 46 46 47 int sampleId = TestSample.test_create(0, true);47 int sampleId = TestSample.test_create(0, null, true); 48 48 int id3 = test_create(sampleId, false); 49 49 int id4 = test_create_pooled(id, id2, id3); -
trunk/src/test/TestSample.java
r2314 r3586 42 42 write_header(); 43 43 // Standard tests: create, load, list 44 int id = test_create(0, true);45 int id2 = test_create(0, false);44 int id = test_create(0, null, true); 45 int id2 = test_create(0, null, false); 46 46 47 47 int bioSourceId = TestBioSource.test_create(false); 48 int id3 = test_create(bioSourceId, false);48 int id3 = test_create(bioSourceId, null, false); 49 49 int id4 = test_create_pooled(id, id2, id3); 50 50 … … 71 71 } 72 72 73 static int test_create(int bioSourceId, boolean setAll)73 static int test_create(int bioSourceId, String name, boolean setAll) 74 74 { 75 75 if (!TestUtil.hasPermission(Permission.CREATE, Item.SAMPLE)) return 0; … … 87 87 s.setOriginalQuantity(500.0f); 88 88 } 89 if (name != null) s.setName(name); 89 90 if (bioSourceId != 0) 90 91 {
Note: See TracChangeset
for help on using the changeset viewer.