Changeset 5574
- Timestamp:
- Feb 18, 2011, 1:19:38 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/ItemContext.java
r5527 r5574 40 40 import net.sf.basedb.core.data.UserData; 41 41 import net.sf.basedb.core.data.ClientData; 42 import net.sf.basedb.util.StringLengthComparator; 42 43 import net.sf.basedb.util.encode.EncodeUtil; 43 44 import net.sf.basedb.util.encode.TabCrLfEncoderDecoder; … … 59 60 import java.util.EnumSet; 60 61 import java.util.List; 62 import java.util.TreeSet; 61 63 62 64 /** … … 1102 1104 1103 1105 // Temporary storage for all associations that must be left joined 1104 Set<String> leftJoins = autoLeftJoin ? new HashSet<String>() : null;1106 Set<String> leftJoins = autoLeftJoin ? new TreeSet<String>(new StringLengthComparator()) : null; 1105 1107 Set<String> sortedProperties = autoLeftJoin ? new HashSet<String>() : null; 1106 1108 -
trunk/src/core/net/sf/basedb/core/Platform.java
r4517 r5574 24 24 import java.util.Set; 25 25 26 import net.sf.basedb.core.Transactional.Action; 26 27 import net.sf.basedb.core.data.FileTypeIndex; 27 28 import net.sf.basedb.core.data.PlatformData; … … 207 208 checkPermission(Permission.WRITE); 208 209 NameableUtil.setName(getData(), name); 210 if (isFileOnly() && isInDatabase()) 211 { 212 getRawDataType().setName(name); 213 } 209 214 } 210 215 public String getDescription() … … 318 323 super.initPermissions(granted, denied); 319 324 } 325 /** 326 Register file-only platforms as raw data type after insert and unregister 327 after delete. 328 @since 2.16.2 329 */ 330 @Override 331 void onAfterCommit(Action action) 332 { 333 super.onAfterCommit(action); 334 if (action == Action.CREATE) 335 { 336 if (isFileOnly()) RawDataTypes.registerFileOnlyRawDataType(new RawDataType(getData())); 337 } 338 else if (action == Action.DELETE) 339 { 340 if (isFileOnly()) RawDataTypes.unregisterFileOnlyRawDataType(getRawDataType()); 341 } 342 } 320 343 // ------------------------------------------- 321 344 322 345 /** 323 346 The maximum length of the external ID that can be stored in the database. -
trunk/src/core/net/sf/basedb/core/PlatformVariant.java
r4517 r5574 24 24 import java.util.Set; 25 25 26 import net.sf.basedb.core.Transactional.Action; 26 27 import net.sf.basedb.core.data.PlatformVariantData; 27 28 … … 211 212 checkPermission(Permission.WRITE); 212 213 NameableUtil.setName(getData(), name); 214 if (isFileOnly() && isInDatabase()) 215 { 216 getRawDataType().setName(name); 217 } 213 218 } 214 219 public String getDescription() … … 308 313 return using; 309 314 } 315 /** 316 Register file-only platforms as raw data type after insert and unregister 317 after delete. 318 @since 2.16.2 319 */ 320 @Override 321 void onAfterCommit(Action action) 322 { 323 super.onAfterCommit(action); 324 if (action == Action.CREATE) 325 { 326 if (isFileOnly()) RawDataTypes.registerFileOnlyRawDataType(new RawDataType(getData())); 327 } 328 else if (action == Action.DELETE) 329 { 330 if (isFileOnly()) RawDataTypes.unregisterFileOnlyRawDataType(getRawDataType()); 331 } 332 } 310 333 // ------------------------------------------- 311 334 /* -
trunk/src/core/net/sf/basedb/core/RawDataType.java
r5384 r5574 50 50 51 51 private final String id; 52 private finalString name;52 private String name; 53 53 private final String description; 54 54 private final boolean fileOnly; … … 243 243 244 244 /** 245 Update the name. Used mainly for file-only representations of 246 raw data types when the underlying platform is changed. 247 @since 2.16.2 248 */ 249 void setName(String name) 250 { 251 this.name = name; 252 } 253 254 /** 245 255 Get a description of this raw data type. This value is the same as the 246 256 <code>description</code> attribute of the <code><raw-data-type></code> … … 354 364 355 365 /** 356 Compare the names of the raw data types. If the names are 357 equal the id:s are also compared. 366 Compare the id:s of the raw data types. 367 Note! Before 2.16.2 the name was used for comparing but this 368 led to issues when changing the name of file-only plaforms. See 369 ticket #1567. 358 370 @since 2.5 359 371 */ … … 361 373 public int compareTo(RawDataType o) 362 374 { 363 int r = name.compareTo(o.name);364 if (r != 0) return r;365 375 return id.compareTo(o.id); 366 376 } -
trunk/src/core/net/sf/basedb/core/RawDataTypes.java
r4889 r5574 30 30 import net.sf.basedb.util.XMLUtil; 31 31 32 import java.util.Comparator; 32 33 import java.util.HashMap; 33 34 import java.util.HashSet; … … 115 116 for (PlatformData platform : HibernateUtil.loadList(PlatformData.class, query, null)) 116 117 { 117 RawDataType rdt = new RawDataType(platform); 118 platformTypes.put(rdt.getId(), rdt); 119 all.add(rdt); 118 registerFileOnlyRawDataType(new RawDataType(platform)); 120 119 } 121 120 … … 124 123 for (PlatformVariantData variant : HibernateUtil.loadList(PlatformVariantData.class, query, null)) 125 124 { 126 RawDataType rdt = new RawDataType(variant); 127 platformTypes.put(rdt.getId(), rdt); 128 all.add(rdt); 125 registerFileOnlyRawDataType(new RawDataType(variant)); 129 126 } 130 127 … … 181 178 /** 182 179 Get a collection with all raw data types that has been defined. This method 183 onlyreturns both database and file-only raw data types. To180 returns both database and file-only raw data types. To 184 181 get file-only raw data types use {@link #getFileOnlyRawDataTypes()} 185 182 @return A <code>Collection</code> containing {@link RawDataType} objects … … 189 186 { 190 187 return Collections.unmodifiableCollection(all); 188 } 189 190 /** 191 Get all raw data types sorted according to the given comparator. 192 @param comparator A compartor 193 @return A sorted collection 194 @since 2.16.2 195 */ 196 public static Collection<RawDataType> getSortedRawDataTypes(Comparator<RawDataType> comparator) 197 { 198 Set<RawDataType> sorted = new TreeSet<RawDataType>(comparator); 199 sorted.addAll(all); 200 return sorted; 191 201 } 192 202 … … 261 271 if (platform == null || !platform.isFileOnly()) return null; 262 272 rdt = new RawDataType(platform); 263 platformTypes.put(id, rdt); 264 all.add(rdt); 273 registerFileOnlyRawDataType(rdt); 265 274 } 266 275 finally … … 289 298 if (variant == null || !variant.isFileOnly()) return null; 290 299 rdt = new RawDataType(variant); 291 platformTypes.put(id, rdt); 292 all.add(rdt); 300 registerFileOnlyRawDataType(rdt); 293 301 } 294 302 finally … … 300 308 } 301 309 310 static void registerFileOnlyRawDataType(RawDataType rdt) 311 { 312 platformTypes.put(rdt.getId(), rdt); 313 all.add(rdt); 314 } 315 316 static void unregisterFileOnlyRawDataType(RawDataType rdt) 317 { 318 platformTypes.remove(rdt.getId()); 319 all.remove(rdt); 320 } 321 302 322 /** 303 323 Load the raw data types and put the information in the … … 498 518 } 499 519 520 /** 521 Comparator implementation that sorts raw data types 522 according to their name. Use this with a TreeSet if you need 523 raw data types returned from {@link RawDataTypes#getRawDataTypes()} 524 to be in the same order as before 2.16.2. 525 526 @author Nicklas 527 @since 2.16.2 528 @base.modified $Date$ 529 */ 530 public static class NameComparator 531 implements Comparator<RawDataType> 532 { 533 534 public NameComparator() 535 {} 536 537 @Override 538 public int compare(RawDataType o1, RawDataType o2) 539 { 540 int r = o1.getName().compareTo(o2.getName()); 541 if (r != 0) return r; 542 return o1.getId().compareTo(o2.getId()); 543 } 544 545 } 500 546 } -
trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java
r5481 r5574 1190 1190 } 1191 1191 } 1192 types.sortValues(); 1192 1193 rawDataTypeType = new StringParameterType(255, null, true, 1, 0, 0, types); 1193 1194 rawDataTypeParameter = new PluginParameter<String> -
trunk/src/plugins/core/net/sf/basedb/plugins/executor/ExternalProgramExecutor.java
r5534 r5574 1001 1001 } 1002 1002 } 1003 rawDataTypes.sortValues(); 1003 1004 parameters.add(new PluginParameter<String>( 1004 1005 PARAMETER_RAW_DATA_TYPE, -
trunk/www/admin/platforms/edit_platform.jsp
r5508 r5574 287 287 <option value="">- any - 288 288 <% 289 for (RawDataType rdt : RawDataTypes.get RawDataTypes())289 for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) 290 290 { 291 291 if (rdt.isStoredInDb()) -
trunk/www/admin/platforms/variants/edit_variant.jsp
r5508 r5574 296 296 <option value="">- any - 297 297 <% 298 for (RawDataType rdt : RawDataTypes.get RawDataTypes())298 for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) 299 299 { 300 300 if (rdt.isStoredInDb()) -
trunk/www/my_base/projects/edit_project.jsp
r5501 r5574 829 829 <option value="">- none -</option> 830 830 <% 831 for (RawDataType rdt : RawDataTypes.get RawDataTypes())831 for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) 832 832 { 833 833 if (rdt.isStoredInDb()) -
trunk/www/views/formulas/edit_formula.jsp
r5501 r5574 457 457 <option value="">- none - 458 458 <% 459 for (RawDataType rdt : RawDataTypes.getRawDataTypes())459 for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) 460 460 { 461 461 String selected = rdt == currentRawDataType ? "selected" : ""; -
trunk/www/views/formulas/list_formulas.jsp
r5426 r5574 102 102 rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName())); 103 103 } 104 rawEnumeration.sortValues(); 104 105 } 105 106 %> -
trunk/www/views/rawbioassays/edit_rawbioassay.jsp
r5558 r5574 709 709 <%=hasDbSpots ? "disabled" : "" %>> 710 710 <% 711 for (RawDataType rdt : RawDataTypes.get RawDataTypes())711 for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) 712 712 { 713 713 if (rdt.isStoredInDb())
Note: See TracChangeset
for help on using the changeset viewer.