Changeset 5201
- Timestamp:
- Dec 16, 2009, 10:33:25 AM (13 years ago)
- Location:
- branches/2.14-stable/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.14-stable/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java
r4835 r5201 312 312 "If no value is specified the default error handling is used.\n\n"+ 313 313 "skip = Skip the current annotation and continue\n"+ 314 "crop = Use as many values as the annotation type allows and discard the rest\n" + 314 315 "fail = Stop with an error message", 315 new StringParameterType(255, null, false, 1, 0, 0,316 Arrays.asList( new String[] { "skip", " fail"} ))316 new StringParameterType(255, "crop", false, 1, 0, 0, 317 Arrays.asList( new String[] { "skip", "crop", "fail"} )) 317 318 ); 318 319 … … 617 618 private boolean failIfMultipleFoundItems; 618 619 private boolean failIfTooManyValues; 620 private boolean cropTooManyValues; 619 621 620 622 // Messaging … … 680 682 this.cropStrings = "crop".equals(job.getValue("stringTooLongError")); 681 683 this.failIfTooManyValues = "fail".equals(getErrorOption("tooManyValuesError")); 684 this.cropTooManyValues = "crop".equals(job.getValue("tooManyValuesError")); 682 685 683 686 ErrorHandler defaultErrorHandler = new SimpleErrorHandler("skip".equals(job.getValue("defaultError"))); … … 855 858 { 856 859 // Add annotation value to the cache 857 item.addValue(at, annotationValue, unit );860 item.addValue(at, annotationValue, unit, cropTooManyValues); 858 861 } 859 862 } … … 1270 1273 error before calling this method. 1271 1274 */ 1272 void addValue(AnnotationType at, Object value, Unit unit )1275 void addValue(AnnotationType at, Object value, Unit unit, boolean limitToMultiplicty) 1273 1276 { 1274 1277 List<AnnotationValue> listOfValues = values.get(at); … … 1277 1280 listOfValues = new LinkedList<AnnotationValue>(); 1278 1281 values.put(at, listOfValues); 1282 } 1283 // If "Too many values"=crop we check how many is allowed by the annotation type 1284 // and don't allow the list to grow larger 1285 if (limitToMultiplicty) 1286 { 1287 int multiplicity = at.getMultiplicity(); 1288 if (multiplicity > 0 && listOfValues.size() >= multiplicity) value = null; 1279 1289 } 1280 1290 if (value != null) -
branches/2.14-stable/src/test/TestAnnotationFlatFileImporter.java
r4822 r5201 89 89 // Test: list the result 90 90 TestAnnotation.test_list_annotations(Item.SAMPLE, sample1, 4); 91 TestAnnotation.test_list_annotations(Item.SAMPLE, sample2, 2);91 TestAnnotation.test_list_annotations(Item.SAMPLE, sample2, 3); 92 92 TestAnnotation.test_list_annotations(Item.SAMPLE, sample3, 2); 93 93 TestAnnotation.test_list_annotations(Item.SAMPLE, sample4, 2); 94 94 TestAnnotation.test_list_annotations(Item.SAMPLE, sampleDup1, 4); 95 95 TestAnnotation.test_list_annotations(Item.SAMPLE, sampleDup2, 4); 96 ok &= TestAnnotation.ok; 96 97 97 98 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); … … 168 169 request.setParameterValue("numberOutOfRangeError", "skip"); 169 170 request.setParameterValue("invalidEnumError", "skip"); 170 request.setParameterValue("tooManyValuesError", " skip");171 request.setParameterValue("tooManyValuesError", "crop"); 171 172 request.setParameterValue("multipleItemsFoundError", "all"); 172 173 response = request.invoke(); -
branches/2.14-stable/src/test/data/test.annotation.import.txt
r4822 r5201 5 5 Sample #2 24 xx BETA Bad Not so bad 6 6 # Test: multiple annotations on separate lines; long string that should be cropped 7 # 'Too many values = crop' option should keep the 24 from previous line 7 8 Sample #2 18 Yet another comment And one more which is too long and will be cropped 8 9 # Test: number out of range: -12; float conversion to int; invalid enum: Gamm
Note: See TracChangeset
for help on using the changeset viewer.