Changeset 3789
- Timestamp:
- Sep 26, 2007, 10:54:39 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/InvalidPathException.java
r3679 r3789 43 43 public InvalidPathException(String path) 44 44 { 45 super( "Invalid path: " +path);45 super(path); 46 46 } 47 47 -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r3679 r3789 898 898 // Tempoarary storage for all associations that must be left joined 899 899 Set<String> leftJoins = autoLeftJoin ? new HashSet<String>() : null; 900 Set<String> sortedProperties = autoLeftJoin ? new HashSet<String>() : null; 900 901 901 902 // Add sort order information … … 930 931 if (dotIndex >= 0) 931 932 { 932 leftJoins.add(sortProperty.substring(0, dotIndex)); 933 String toJoin = sortProperty.substring(0, dotIndex); 934 leftJoins.add(toJoin); 935 sortedProperties.add(toJoin); 933 936 } 934 937 } … … 995 998 { 996 999 int i = 0; 1000 // Use fetch joins for columns appearing in the ORDER BY clause 1001 // if the query is distinct and the database requires it 1002 boolean selectOrderBy = query.isDistinct() && 1003 HibernateUtil.getDbEngine().selectOrderByColumnsIfDistinct(); 997 1004 for (String property : leftJoins) 998 1005 { 1006 boolean fetch = selectOrderBy && sortedProperties.contains(property); 999 1007 if (property.startsWith("@")) property = property.substring(1); 1000 1008 i++; 1001 query.join(Hql.leftJoin( property, "alj"+i));1009 query.join(Hql.leftJoin(null, property, "alj"+i, null, fetch)); 1002 1010 } 1003 1011 } -
trunk/src/core/net/sf/basedb/core/Job.java
r3719 r3789 997 997 throws InvalidDataException, PermissionDeniedException, BaseException 998 998 { 999 checkPermission(Permission.WRITE); 1000 if (name == null) throw new InvalidUseOfNullException("name"); 999 1001 if (getStatus() == Status.EXECUTING) 1000 1002 { … … 1002 1004 } 1003 1005 getData().setStatus(Status.WAITING.getValue()); 1004 setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value) );1006 setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value), true); 1005 1007 } 1006 1008 … … 1046 1048 throws InvalidDataException, PermissionDeniedException, BaseException 1047 1049 { 1050 checkPermission(Permission.WRITE); 1051 if (name == null) throw new InvalidUseOfNullException("name"); 1048 1052 if (getStatus() == Status.EXECUTING) 1049 1053 { … … 1051 1055 } 1052 1056 getData().setStatus(Status.WAITING.getValue()); 1053 setParameterValuesInternal(name, label, description, parameterType, values );1057 setParameterValuesInternal(name, label, description, parameterType, values, true); 1054 1058 } 1055 1059 … … 1111 1115 @param values A list containing the new values, null or empty to remove the 1112 1116 configuration values 1117 @param validate If validation by {@link ParameterType#validate(String, List)} 1118 is needed or not 1113 1119 @throws PermissionDeniedException If the logged in user doesn't have 1114 1120 write permission … … 1117 1123 @throws BaseException If there is another error 1118 1124 */ 1119 void setParameterValuesInternal(String name, String label, String description, ParameterType<?> parameterType, List<?> values) 1125 void setParameterValuesInternal(String name, String label, String description, 1126 ParameterType<?> parameterType, List<?> values, boolean validate) 1120 1127 throws InvalidDataException, PermissionDeniedException, BaseException 1121 1128 { 1122 checkPermission(Permission.WRITE);1123 if (name == null) throw new InvalidUseOfNullException("name");1124 1129 ParameterValueData old = null; 1125 1130 if (values == null || values.size() == 0) … … 1130 1135 { 1131 1136 if (parameterType == null) throw new InvalidUseOfNullException("parameterType"); 1132 parameterType.validate(name, values);1137 if (validate) parameterType.validate(name, values); 1133 1138 ParameterValueData<?> parameterValue = parameterType.newParameterValueData(); 1134 1139 parameterValue.setLabel(label); -
trunk/src/core/net/sf/basedb/core/ParameterType.java
r3679 r3789 218 218 if (!items.contains(value)) 219 219 { 220 throw new InvalidDataException("The value '" + value + "' isn't in the list of allowed values .");220 throw new InvalidDataException("The value '" + value + "' isn't in the list of allowed values for parameter '" + name + "'."); 221 221 } 222 222 } -
trunk/src/core/net/sf/basedb/core/ParameterValuesImpl.java
r3679 r3789 161 161 if (writeProtected) 162 162 { 163 throw new PermissionDeniedException(Permission.WRITE, "Job parameter: "+name); 164 } 163 throw new PermissionDeniedException(Permission.WRITE, "Parameter: "+name); 164 } 165 if (name == null) throw new InvalidUseOfNullException("name"); 166 if (type == null) throw new InvalidUseOfNullException("type[name=" + name + "]"); 165 167 if (value == null && type.getNotNull()) value = type.getDefaultValue(); 168 type.validate(name, value); 166 169 List<T> l = new ArrayList<T>(1); 167 170 l.add(value); … … 176 179 if (writeProtected) 177 180 { 178 throw new PermissionDeniedException(Permission.WRITE, "Job parameter: "+name); 179 } 181 throw new PermissionDeniedException(Permission.WRITE, "Parameter: "+name); 182 } 183 if (name == null) throw new InvalidUseOfNullException("name"); 184 if (type == null) throw new InvalidUseOfNullException("type[name=" + name + "]"); 180 185 if ((values == null || values.size() == 0) && type.getNotNull() && type.getDefaultValue() != null) 181 186 { 182 187 values = Arrays.asList(type.getDefaultValue()); 183 188 } 189 type.validate(name, values); 184 190 parameters.put(name, values); 185 191 parameterTypes.put(name, type); … … 203 209 if (pp == null) 204 210 { 205 job.setParameterValuesInternal(name, null, null, parameterTypes.get(name), parameters.get(name)); 211 job.setParameterValuesInternal(name, null, null, 212 parameterTypes.get(name), parameters.get(name), false); 206 213 } 207 214 else 208 215 { 209 job.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(), parameterTypes.get(name), parameters.get(name)); 216 job.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(), 217 parameterTypes.get(name), parameters.get(name), false); 210 218 } 211 219 } … … 223 231 if (pp == null) 224 232 { 225 config.setParameterValues(name, null, null, parameterTypes.get(name), parameters.get(name)); 233 config.setParameterValuesInternal(name, null, null, 234 parameterTypes.get(name), parameters.get(name), false); 226 235 } 227 236 else 228 237 { 229 config.setParameterValues(name, pp.getLabel(), pp.getDescription(), parameterTypes.get(name), parameters.get(name)); 238 config.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(), 239 parameterTypes.get(name), parameters.get(name), false); 230 240 } 231 241 } -
trunk/src/core/net/sf/basedb/core/Path.java
r3679 r3789 143 143 } 144 144 filename = parts[parts.length-1]; 145 if (!Path.isValidName(filename)) 146 { 147 throw new InvalidPathException("Path contains invalid characters ("+Path.INVALID_CHARACTERS+"): "+path); 148 } 145 149 parts[parts.length-1] = ""; 146 150 } -
trunk/src/core/net/sf/basedb/core/PathParameterType.java
r3675 r3789 87 87 Checks if the value is a valif {@link Path} value. 88 88 @param value The value to test 89 @throws InvalidDataException If the value is not a string or too long89 @throws InvalidDataException If the value is not a valid path 90 90 */ 91 91 void validateValue(String name, String value) 92 92 throws InvalidDataException 93 93 { 94 new Path(value, pathType); 94 try 95 { 96 new Path(value, pathType); 97 } 98 catch (InvalidPathException ex) 99 { 100 throw new InvalidPathException("Path for parameter '"+ name + "' is invalid: " + ex.getMessage()); 101 } 95 102 } 96 103 /** -
trunk/src/core/net/sf/basedb/core/PluginConfiguration.java
r3775 r3789 428 428 checkPermission(Permission.WRITE); 429 429 if (name == null) throw new InvalidUseOfNullException("name"); 430 430 setParameterValuesInternal(name, label, description, parameterType, values, true); 431 } 432 433 /** 434 Set the values of a configuration parameter. 435 @param name The name of the configuration parameter 436 @param label The label of the parameter (optional) 437 @param description A description of the parameter (optional) 438 @param parameterType The type of the parameter 439 @param values A list containing the new values, null or empty to remove the 440 configuration values 441 @param validate If validation by {@link ParameterType#validate(String, List)} 442 is needed or not 443 @throws PermissionDeniedException If the logged in user doesn't have 444 write permission 445 @throws InvalidDataException If name is null or the new value doesn't 446 validate against the parameter type 447 @throws BaseException If there is another error 448 */ 449 void setParameterValuesInternal(String name, String label, String description, 450 ParameterType<?> parameterType, List<?> values, boolean validate) 451 throws InvalidDataException, PermissionDeniedException, BaseException 452 { 453 431 454 VersionedParameter param = new VersionedParameter(name, getNewParameterVersion()); 432 433 455 if (values == null || values.size() == 0) 434 456 { … … 438 460 { 439 461 if (parameterType == null) throw new InvalidUseOfNullException("parameterType"); 440 parameterType.validate(name, values);462 if (validate) parameterType.validate(name, values); 441 463 ParameterValueData<?> parameterValue = parameterType.newParameterValueData(); 442 464 parameterValue.setLabel(label); … … 446 468 } 447 469 } 448 470 449 471 /** 450 472 Copy all parameter values from another plugin configuration. This method -
trunk/src/core/net/sf/basedb/util/overview/ExperimentOverview.java
r3675 r3789 283 283 284 284 // Load 'Required for MIAME' annotation types (parameter='false' must also be set) 285 ItemQuery<AnnotationType> query = initQuery(AnnotationType.getQuery(null), "name");285 ItemQuery<AnnotationType> query = initQuery(AnnotationType.getQuery(null), null, "name"); 286 286 query.restrict( 287 287 Restrictions.eq( … … 556 556 Node efNode = new Node("experimental.factors", "Experimental factors", rootNode); 557 557 Experiment experiment = (Experiment)rootNode.getItem(); 558 ItemQuery<AnnotationType> efQuery = initQuery(experiment.getExperimentalFactors(), "name");558 ItemQuery<AnnotationType> efQuery = initQuery(experiment.getExperimentalFactors(), null, "name"); 559 559 for (AnnotationType ef : efQuery.list(dc)) 560 560 { … … 574 574 Node rawBioAssaysNode = new Node("rawbioassays", "Raw bioassays", rootNode); 575 575 Experiment experiment = (Experiment)rootNode.getItem(); 576 ItemQuery<RawBioAssay> rbaQuery = initQuery(experiment.getRawBioAssays(), "name");576 ItemQuery<RawBioAssay> rbaQuery = initQuery(experiment.getRawBioAssays(), null, "name"); 577 577 Set<BasicItem> arrayDesigns = new HashSet<BasicItem>(); 578 578 for (RawBioAssay rba : rbaQuery.list(dc)) … … 801 801 Node imagesNode = new Node("images", "Images", scanNode); 802 802 Scan scan = (Scan)scanNode.getItem(); 803 ItemQuery<Image> imageQuery = initQuery(scan.getImages(), "name");803 ItemQuery<Image> imageQuery = initQuery(scan.getImages(), null, "name"); 804 804 for (Image image : imageQuery.list(dc)) 805 805 { … … 831 831 Hybridization hyb = (Hybridization)hybNode.getItem(); 832 832 ItemQuery<LabeledExtract> leQuery = 833 (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), "label.name");833 (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), null, "label.name"); 834 834 int added = 0; 835 835 int channels = experiment.getRawDataType().getChannels(); … … 935 935 936 936 ItemQuery<LabeledExtract> sourceQuery = 937 initQuery((ItemQuery<LabeledExtract>)product.getCreationEvent().getSources(), "name");937 initQuery((ItemQuery<LabeledExtract>)product.getCreationEvent().getSources(), null, "name"); 938 938 939 939 int added = 0; … … 1058 1058 1059 1059 ItemQuery<Extract> sourceQuery = 1060 initQuery((ItemQuery<Extract>)product.getCreationEvent().getSources(), "name");1060 initQuery((ItemQuery<Extract>)product.getCreationEvent().getSources(), null, "name"); 1061 1061 1062 1062 int added = 0; … … 1162 1162 1163 1163 ItemQuery<Sample> sourceQuery = 1164 initQuery((ItemQuery<Sample>)product.getCreationEvent().getSources(), "name");1164 initQuery((ItemQuery<Sample>)product.getCreationEvent().getSources(), null, "name"); 1165 1165 1166 1166 int added = 0; … … 1534 1534 AnnotationSet as = annotatable != null && annotatable.isAnnotated() ? 1535 1535 annotatable.getAnnotationSet() : null; 1536 ItemQuery<AnnotationType> parameterQuery = initQuery(protocol.getParameters(), "name");1536 ItemQuery<AnnotationType> parameterQuery = initQuery(protocol.getParameters(), null, "name"); 1537 1537 List<AnnotationType> parameters = parameterQuery.list(dc); 1538 1538 Node parameterNode = null; … … 1582 1582 annotationsNode = new Node("annotations", "Annotations", parentNode); 1583 1583 AnnotationSet as = parent.getAnnotationSet(); 1584 ItemQuery<Annotation> annotationQuery = initQuery(as.getAnnotations(), "annotationType.name");1584 ItemQuery<Annotation> annotationQuery = initQuery(as.getAnnotations(), null, "annotationType.name"); 1585 1585 1586 1586 for (Annotation a : annotationQuery.list(dc)) … … 1662 1662 annotationTypes.clear(); 1663 1663 AnnotationSet as = parent.getAnnotationSet(); 1664 ItemQuery<Annotation> annotationQuery = initQuery(as.getAllInheritedAnnotations(), "annotationType.name"); 1664 ItemQuery<Annotation> annotationQuery = initQuery(as.getAllInheritedAnnotations(), "at", "name"); 1665 annotationQuery.join(Hql.innerJoin(null, "annotationType", "at", true)); 1665 1666 List<Annotation> inherited = annotationQuery.list(dc); 1666 1667 if (inherited.size() > 0) … … 1727 1728 Set include options and sorting order for a query. 1728 1729 */ 1729 private <T extends BasicItem> ItemQuery<T> initQuery(ItemQuery<T> query, String sort Property)1730 private <T extends BasicItem> ItemQuery<T> initQuery(ItemQuery<T> query, String sortAlias, String sortProperty) 1730 1731 { 1731 1732 query.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS); 1732 query.order(Orders.asc(Hql.property(sort Property)));1733 query.order(Orders.asc(Hql.property(sortAlias, sortProperty))); 1733 1734 return query; 1734 1735 } -
trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r3775 r3789 1377 1377 if (bas == null) 1378 1378 { 1379 bas = t.newProduct( null, "new", false);1379 bas = t.newProduct("new", "new", false); 1380 1380 } 1381 1381 spotBatcher = bas.getSpotBatcher(); -
trunk/src/plugins/core/net/sf/basedb/plugins/PackedFileExporter.java
r3675 r3789 376 376 // Prepare for compression 377 377 String rootPath = rootDir.getPath().toString(); 378 if (!rootPath.endsWith("/")) rootPath += "/"; 378 379 out.setMimeType(packer.getMimeType()); 379 380 out.setFilename(generateDefaultName(packer, rootDir, itemsToPack)); … … 405 406 406 407 // Remove rootPath from entryPath 407 entryPath = entryPath.substring(rootPath.length() +1);408 entryPath = entryPath.substring(rootPath.length()); 408 409 409 410 // Update progress … … 657 658 private String generateDefaultPath(FilePacker packer, Directory rootDir, Collection<Nameable> selectedItems) 658 659 { 659 String defaultPath = rootDir == null ? "~/" : rootDir.getPath().toString() + "/"; 660 String defaultPath = rootDir == null ? "~/" : rootDir.getPath().toString(); 661 if (!defaultPath.endsWith("/")) defaultPath += "/"; 660 662 defaultPath += generateDefaultName(packer, rootDir, selectedItems); 661 663 return defaultPath; -
trunk/src/test/TestAnnotation.java
r3679 r3789 26 26 27 27 import net.sf.basedb.core.*; 28 import net.sf.basedb.core.query.Hql; 29 import net.sf.basedb.core.query.Orders; 28 30 29 31 import java.util.Date; … … 81 83 // Test: list inherited annotations and annotation sets 82 84 test_list_inherited_annotations(rawBioAssayId, 2); 85 test_list_allinherited_annotations(rawBioAssayId, 9); 83 86 test_list_inherited_annotationsets(rawBioAssayId, 1); 84 87 test_list_inheriting_annotationsets(arrayDesignId, 1); … … 342 345 } 343 346 } 347 348 static void test_list_allinherited_annotations(int rawBioAssayId, int expectedResults) 349 { 350 if (rawBioAssayId == 0) return; 351 DbControl dc = null; 352 try 353 { 354 dc = TestUtil.getDbControl(); 355 RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); 356 ItemQuery<Annotation> query = rba.getAnnotationSet().getAllInheritedAnnotations(); 357 query.join(Hql.innerJoin(null, "annotationType", "at", true)); 358 query.order(Orders.asc(Hql.property("at", "name"))); 359 List<Annotation> l = query.list(dc); 360 for (int i = 0; i<l.size(); i++) 361 { 362 write_item(i, l.get(i)); 363 } 364 if (expectedResults >= 0 && expectedResults != l.size()) 365 { 366 throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); 367 } 368 write("--List all inherited annotations OK ("+l.size()+")"); 369 } 370 catch (Throwable ex) 371 { 372 write("--List all inherited annotations FAILED"); 373 ex.printStackTrace(); 374 ok = false; 375 } 376 finally 377 { 378 if (dc != null) dc.close(); 379 } 380 } 344 381 345 382 static void test_list_inherited_annotationsets(int rawBioAssayId, int expectedResults) -
trunk/src/test/TestPath.java
r3679 r3789 42 42 { 43 43 write("++Testing path"); 44 test_create("/filename", Path.Type.FILE );45 test_create("/directory/filename", Path.Type.FILE );46 test_create("/directory/subdirectory/filename", Path.Type.FILE );47 test_create("~userlogin/filename", Path.Type.FILE );48 test_create("~userlogin/directory/filename", Path.Type.FILE );49 test_create("~userlogin/directory/subdirectory/filename", Path.Type.FILE );50 test_create("~/filename", Path.Type.FILE );51 test_create("~/directory/filename", Path.Type.FILE );52 test_create("~/directory/subdirectory/filename", Path.Type.FILE );44 test_create("/filename", Path.Type.FILE, false); 45 test_create("/directory/filename", Path.Type.FILE, false); 46 test_create("/directory/subdirectory/filename", Path.Type.FILE, false); 47 test_create("~userlogin/filename", Path.Type.FILE, false); 48 test_create("~userlogin/directory/filename", Path.Type.FILE, false); 49 test_create("~userlogin/directory/subdirectory/filename", Path.Type.FILE, false); 50 test_create("~/filename", Path.Type.FILE, false); 51 test_create("~/directory/filename", Path.Type.FILE, false); 52 test_create("~/directory/subdirectory/filename", Path.Type.FILE, false); 53 53 54 test_create("/", Path.Type.DIRECTORY );55 test_create("/directory", Path.Type.DIRECTORY );56 test_create("/directory/subdirectory", Path.Type.DIRECTORY );57 test_create("/directory/subdirectory/subsub", Path.Type.DIRECTORY );58 test_create("~userlogin", Path.Type.DIRECTORY );59 test_create("~userlogin/directory", Path.Type.DIRECTORY );60 test_create("~userlogin/directory/subdirectory", Path.Type.DIRECTORY );61 test_create("~userlogin/directory/subdirectory/subsub", Path.Type.DIRECTORY );62 test_create("~", Path.Type.DIRECTORY );63 test_create("~/directory", Path.Type.DIRECTORY );64 test_create("~/directory/subdirectory", Path.Type.DIRECTORY );65 test_create("~/directory/subdirectory/subsub", Path.Type.DIRECTORY );54 test_create("/", Path.Type.DIRECTORY, false); 55 test_create("/directory", Path.Type.DIRECTORY, false); 56 test_create("/directory/subdirectory", Path.Type.DIRECTORY, false); 57 test_create("/directory/subdirectory/subsub", Path.Type.DIRECTORY, false); 58 test_create("~userlogin", Path.Type.DIRECTORY, false); 59 test_create("~userlogin/directory", Path.Type.DIRECTORY, false); 60 test_create("~userlogin/directory/subdirectory", Path.Type.DIRECTORY, false); 61 test_create("~userlogin/directory/subdirectory/subsub", Path.Type.DIRECTORY, false); 62 test_create("~", Path.Type.DIRECTORY, false); 63 test_create("~/directory", Path.Type.DIRECTORY, false); 64 test_create("~/directory/subdirectory", Path.Type.DIRECTORY, false); 65 test_create("~/directory/subdirectory/subsub", Path.Type.DIRECTORY, false); 66 66 67 67 test_valid_name("abc", true); … … 77 77 test_valid_name("|abc", false); 78 78 79 test_create("/file<name>", Path.Type.FILE, true); 80 test_create("/dire<ctory>/filename", Path.Type.FILE, true); 81 test_create("/directory/file<name>", Path.Type.FILE, true); 82 test_create("/sub<dir>", Path.Type.DIRECTORY, true); 83 test_create("/directory/sub<dir>", Path.Type.DIRECTORY, true); 84 79 85 test_replace_invalid("abc", ".", "abc"); 80 86 test_replace_invalid("~abc", ".", ".abc"); … … 85 91 } 86 92 87 static void test_create(String path, Path.Type type )93 static void test_create(String path, Path.Type type, boolean shouldFail) 88 94 { 89 95 try … … 95 101 throw new Exception("Original path ("+path+") is different from path: "+pp); 96 102 } 97 write("--Path " + p.getType() + ": '"+p+"' OK"); 103 if (shouldFail) 104 { 105 write("--Path '"+path+"' FAILED"); 106 new Throwable("Expected test to fail but it didn't.").printStackTrace(); 107 ok = false; 108 } 109 else 110 { 111 write("--Path " + p.getType() + ": '"+p+"' OK"); 112 } 98 113 } 99 114 catch (Throwable ex) 100 115 { 101 write("--Path '"+path+"' FAILED"); 102 ex.printStackTrace(); 103 ok = false; 116 if (!shouldFail) 117 { 118 write("--Path '"+path+"' FAILED"); 119 ex.printStackTrace(); 120 ok = false; 121 } 122 else 123 { 124 write("--Path " + type + ": '"+path+"' OK"); 125 } 104 126 } 105 127 } -
trunk/www/common/annotations/list_annotations.jsp
r3679 r3789 83 83 { 84 84 ItemQuery<Annotation> inheritedQuery = as.getAllInheritedAnnotations(); 85 // Need FETCH JOIN because Postgres don't like the DISTINCT keyword 86 // if we sort on a non-selected column See ticket #731 87 inheritedQuery.join(Hql.innerJoin(null, "annotationType", "at", true)); 85 88 inheritedQuery.order(Orders.asc(Hql.property("annotationSet"))); 86 inheritedQuery.order(Orders.asc(Hql.property("a nnotationType.name")));89 inheritedQuery.order(Orders.asc(Hql.property("at", "name"))); 87 90 inheritedAnnotations = inheritedQuery.list(dc); 88 91 }
Note: See TracChangeset
for help on using the changeset viewer.