Changeset 3797
- Timestamp:
- Sep 28, 2007, 8:35:54 AM (16 years ago)
- Location:
- branches/filedb/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/filedb/src/core/common-queries.xml
r3793 r3797 2813 2813 </query> 2814 2814 2815 <query id="GET_PLATFORM_FOR_ SYSTEM_ID" type="HQL">2815 <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL"> 2816 2816 <sql> 2817 2817 SELECT plf 2818 2818 FROM PlatformData plf 2819 WHERE plf.systemId = :systemId 2820 </sql> 2821 <description> 2822 A Hibernate query that loads a platform by system ID. 2823 </description> 2824 </query> 2825 2826 <query id="GET_DATAFILETYPE_FOR_SYSTEM_ID" type="HQL"> 2819 WHERE plf.externalId = :externalId 2820 </sql> 2821 <description> 2822 A Hibernate query that loads a platform by external ID. 2823 </description> 2824 </query> 2825 2826 <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL"> 2827 <sql> 2828 SELECT plv 2829 FROM PlatformVariantData plv 2830 WHERE plv.externalId = :externalId 2831 </sql> 2832 <description> 2833 A Hibernate query that loads a platform variant by external ID. 2834 </description> 2835 </query> 2836 2837 <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL"> 2827 2838 <sql> 2828 2839 SELECT dft 2829 2840 FROM DataFileTypeData dft 2830 WHERE dft. systemId = :systemId2831 </sql> 2832 <description> 2833 A Hibernate query that loads a file set member type by systemID.2841 WHERE dft.externalId = :externalId 2842 </sql> 2843 <description> 2844 A Hibernate query that loads a data file type by external ID. 2834 2845 </description> 2835 2846 </query> -
branches/filedb/src/core/net/sf/basedb/core/ArrayDesign.java
r3783 r3797 284 284 public boolean isAffyChip() 285 285 { 286 return Platform.AFFYMETRIX.equals(getData().getPlatform().get SystemId());286 return Platform.AFFYMETRIX.equals(getData().getPlatform().getExternalId()); 287 287 } 288 288 -
branches/filedb/src/core/net/sf/basedb/core/DataFileType.java
r3793 r3797 43 43 public class DataFileType 44 44 extends BasicItem<DataFileTypeData> 45 implements Nameable, Removable , SystemItem45 implements Nameable, Removable 46 46 { 47 47 … … 70 70 71 71 @param dc The DbControl to use for database access 72 @param systemId The systemID of the new type, must be72 @param externalId The external ID of the new type, must be 73 73 unique for all file types 74 74 @param itemType The type of item that files of this type can … … 77 77 @return The new file set member type object 78 78 */ 79 public static DataFileType getNew(DbControl dc, String systemId, Item itemType)79 public static DataFileType getNew(DbControl dc, String externalId, Item itemType) 80 80 { 81 81 DataFileType type = dc.newItem(DataFileType.class); 82 type.set SystemId(systemId);82 type.setExternalId(externalId); 83 83 type.setName("New data file type"); 84 84 type.setItemType(itemType); … … 107 107 108 108 /** 109 Get a <code>DataFileType</code> item when you know the external ID. 110 111 @param dc The <code>DbControl</code> which will be used for 112 permission checking and database access. 113 @param externalId The external ID of the item to load 114 @return The <code>DataFileType</code> item. 115 @throws ItemNotFoundException If an item with the specified ID is not found 116 @throws PermissionDeniedException If the logged in user doesn't have 117 read permission for the item 118 @throws BaseException If there is another error 119 */ 120 public static DataFileType getByExternalId(DbControl dc, String externalId) 121 throws ItemNotFoundException, PermissionDeniedException, BaseException 122 { 123 if (externalId != null) externalId = externalId.trim(); 124 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), 125 "GET_DATAFILETYPE_FOR_EXTERNAL_ID"); 126 /* 127 SELECT dft 128 FROM DataFileTypeData dft 129 WHERE dft.externalId = :externalId 130 */ 131 query.setString("externalId", externalId); 132 DataFileType dft = dc.getItem(DataFileType.class, HibernateUtil.loadData(DataFileTypeData.class, query)); 133 if (dft == null) throw new ItemNotFoundException("DataFileType[externalId="+externalId+"]"); 134 return dft; 135 } 136 137 /** 109 138 Get a query configured to retrieve <code>DataFileType</code> items. 110 139 @return An {@link ItemQuery} object … … 158 187 checkPermission(Permission.WRITE); 159 188 NameableUtil.setDescription(getData(), description); 160 }161 // -------------------------------------------162 /*163 From the SystemItem interface164 -------------------------------------------165 */166 public String getSystemId()167 {168 return getData().getSystemId();169 }170 public boolean isSystemItem()171 {172 return getData().getSystemId() != null;173 189 } 174 190 // ------------------------------------------- … … 239 255 240 256 /** 241 Set the system ID. Null is not allowed and the length must 242 be less than {@link #MAX_SYSTEM_ID_LENGTH}. 243 */ 244 private void setSystemId(String systemId) 245 { 246 getData().setSystemId(StringUtil.setNotNullString(systemId, "systemId", MAX_SYSTEM_ID_LENGTH)); 257 The maximum length of the external ID that can be stored in the database. 258 @see #setExternalId(String) 259 */ 260 public static final int MAX_EXTERNAL_ID_LENGTH = DataFileTypeData.MAX_EXTERNAL_ID_LENGTH; 261 262 /** 263 Get the external id for the data file type. 264 */ 265 public String getExternalId() 266 { 267 return getData().getExternalId(); 268 } 269 270 private void setExternalId(String externalId) 271 throws PermissionDeniedException, InvalidDataException, BaseException 272 { 273 getData().setExternalId(StringUtil.setNullableString( 274 externalId, "externalId", MAX_EXTERNAL_ID_LENGTH)); 247 275 } 248 276 -
branches/filedb/src/core/net/sf/basedb/core/Install.java
r3796 r3797 2191 2191 Create a {@link Platform}. 2192 2192 */ 2193 private static PlatformData createPlatform(String systemId, String name, String description,2193 private static PlatformData createPlatform(String externalId, String name, String description, 2194 2194 boolean fileOnly, String rawDataType, int channels, PlatformFT... fileTypes) 2195 2195 throws BaseException … … 2203 2203 if (platform == null) 2204 2204 { 2205 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PLATFORM_FOR_SYSTEM_ID"); 2206 query.setString("systemId", systemId); 2205 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 2206 "GET_PLATFORM_FOR_EXTERNAL_ID"); 2207 query.setString("externalId", externalId); 2207 2208 platform = HibernateUtil.loadData(PlatformData.class, query); 2208 2209 } … … 2210 2211 if (platform != null) 2211 2212 { 2212 log.info("createPlatform: EXISTS [ systemId="+systemId+"]");2213 log.info("createPlatform: EXISTS [externalId="+externalId+"]"); 2213 2214 HibernateUtil.commit(tx); 2214 2215 } … … 2216 2217 { 2217 2218 platform = new PlatformData(); 2218 platform.set SystemId(systemId);2219 platform.setExternalId(externalId); 2219 2220 platform.setName(name); 2220 2221 platform.setDescription(description); … … 2243 2244 2244 2245 HibernateUtil.commit(tx); 2245 if (systemId != null) SystemItems.add(platform); 2246 log.info("createPlatform: OK [systemId="+systemId+"]"); 2246 log.info("createPlatform: OK [externalId="+externalId+"]"); 2247 2247 } 2248 2248 } … … 2250 2250 { 2251 2251 if(tx != null) HibernateUtil.rollback(tx); 2252 log.error("createPlatform: FAILED [ systemId="+systemId+"]", ex);2252 log.error("createPlatform: FAILED [externalId="+externalId+"]", ex); 2253 2253 throw ex; 2254 2254 } … … 2260 2260 */ 2261 2261 private static DataFileTypeData createDataFileType( 2262 String systemId, String name, String description,2262 String externalId, String name, String description, 2263 2263 Item itemType, String extension, FileTypeData genericType, 2264 2264 String validatorClass, String metadataReaderClass) … … 2274 2274 { 2275 2275 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 2276 "GET_DATAFILETYPE_FOR_ SYSTEM_ID");2277 query.setString(" systemId", systemId);2276 "GET_DATAFILETYPE_FOR_EXTERNAL_ID"); 2277 query.setString("externalId", externalId); 2278 2278 fileType = HibernateUtil.loadData(DataFileTypeData.class, query); 2279 2279 } … … 2281 2281 if (fileType != null) 2282 2282 { 2283 log.info("createDataFileType: EXISTS [ systemId="+systemId+"]");2283 log.info("createDataFileType: EXISTS [externalId="+externalId+"]"); 2284 2284 HibernateUtil.commit(tx); 2285 2285 } … … 2287 2287 { 2288 2288 fileType = new DataFileTypeData(); 2289 fileType.set SystemId(systemId);2289 fileType.setExternalId(externalId); 2290 2290 fileType.setName(name); 2291 2291 fileType.setDescription(description); … … 2298 2298 HibernateUtil.saveData(session, fileType); 2299 2299 HibernateUtil.commit(tx); 2300 if (systemId != null) SystemItems.add(fileType); 2301 log.info("createDataFileType: OK [systemId="+systemId+"]"); 2300 log.info("createDataFileType: OK [externalId="+externalId+"]"); 2302 2301 } 2303 2302 } … … 2305 2304 { 2306 2305 if(tx != null) HibernateUtil.rollback(tx); 2307 log.error("createDataFileType: FAILED [ systemId="+systemId+"]", ex);2306 log.error("createDataFileType: FAILED [externalId="+externalId+"]", ex); 2308 2307 throw ex; 2309 2308 } -
branches/filedb/src/core/net/sf/basedb/core/Platform.java
r3793 r3797 42 42 public class Platform 43 43 extends BasicItem<PlatformData> 44 implements Nameable, Removable , SystemItem44 implements Nameable, Removable 45 45 { 46 46 … … 70 70 71 71 @param dc The DbControl to use for database access 72 @param systemId The systemID of the platform, must be72 @param externalId The external ID of the platform, must be 73 73 unique for all platforms 74 74 @param channels Number of channels in this platform 75 75 @return The new platform object 76 76 */ 77 public static Platform getNew(DbControl dc, String systemId, int channels)77 public static Platform getNew(DbControl dc, String externalId, int channels) 78 78 { 79 79 Platform p = dc.newItem(Platform.class); 80 80 p.getData().setFileOnly(true); 81 p.set SystemId(systemId);81 p.setExternalId(externalId); 82 82 p.setChannels(channels); 83 83 return p; … … 88 88 89 89 @param dc The DbControl to use for database access 90 @param systemId The systemID of the platform, must be90 @param externalId The external ID of the platform, must be 91 91 unique for all platforms 92 92 @param rawDataType A specific raw data type this platform will be locked … … 94 94 @return The new platform object 95 95 */ 96 public static Platform getNew(DbControl dc, String systemId, RawDataType rawDataType)96 public static Platform getNew(DbControl dc, String externalId, RawDataType rawDataType) 97 97 { 98 98 Platform p = dc.newItem(Platform.class); 99 99 p.getData().setFileOnly(false); 100 p.set SystemId(systemId);100 p.setExternalId(externalId); 101 101 p.setRawDataType(rawDataType); 102 102 return p; … … 124 124 125 125 /** 126 Get a <code>Platform</code> item when you know the external ID. 127 128 @param dc The <code>DbControl</code> which will be used for 129 permission checking and database access. 130 @param externalId The external ID of the item to load 131 @return The <code>Platform</code> item. 132 @throws ItemNotFoundException If an item with the specified ID is not found 133 @throws PermissionDeniedException If the logged in user doesn't have 134 read permission for the item 135 @throws BaseException If there is another error 136 */ 137 public static Platform getByExternalId(DbControl dc, String externalId) 138 throws ItemNotFoundException, PermissionDeniedException, BaseException 139 { 140 if (externalId != null) externalId = externalId.trim(); 141 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), 142 "GET_PLATFORM_FOR_EXTERNAL_ID"); 143 /* 144 SELECT plf 145 FROM PlatformData plf 146 WHERE plf.externalId = :externalId 147 */ 148 query.setString("externalId", externalId); 149 Platform p = dc.getItem(Platform.class, HibernateUtil.loadData(PlatformData.class, query)); 150 if (p == null) throw new ItemNotFoundException("Platform[externalId="+externalId+"]"); 151 return p; 152 } 153 154 /** 126 155 Get a query configured to retrieve <code>Platform</code> items. 127 156 @return An {@link ItemQuery} object … … 175 204 checkPermission(Permission.WRITE); 176 205 NameableUtil.setDescription(getData(), description); 177 }178 // -------------------------------------------179 /*180 From the SystemItem interface181 -------------------------------------------182 */183 public String getSystemId()184 {185 return getData().getSystemId();186 }187 public boolean isSystemItem()188 {189 return getData().getSystemId() != null;190 206 } 191 207 // ------------------------------------------- … … 275 291 return using; 276 292 } 293 /** 294 Deny deletion of the GENERIC platform. It is required by the 295 system. 296 */ 297 @Override 298 protected void initPermissions(int granted, int denied) 299 { 300 if (GENERIC.equals(getExternalId())) 301 { 302 denied |= Permission.deny(Permission.DELETE); 303 } 304 super.initPermissions(granted, denied); 305 } 277 306 // ------------------------------------------- 278 307 279 308 /** 280 Set the system ID. Null is not allowed and the length must 281 be less than {@link #MAX_SYSTEM_ID_LENGTH}. 282 */ 283 private void setSystemId(String systemId) 284 { 285 getData().setSystemId(StringUtil.setNotNullString(systemId, "systemId", MAX_SYSTEM_ID_LENGTH)); 309 The maximum length of the external ID that can be stored in the database. 310 @see #setExternalId(String) 311 */ 312 public static final int MAX_EXTERNAL_ID_LENGTH = PlatformData.MAX_EXTERNAL_ID_LENGTH; 313 314 /** 315 Get the external id for the platform. 316 */ 317 public String getExternalId() 318 { 319 return getData().getExternalId(); 320 } 321 322 private void setExternalId(String externalId) 323 throws PermissionDeniedException, InvalidDataException, BaseException 324 { 325 getData().setExternalId(StringUtil.setNullableString( 326 externalId, "externalId", MAX_EXTERNAL_ID_LENGTH)); 286 327 } 287 328 … … 338 379 { 339 380 // TODO - autogenerate a raw data type in a proper way 340 rdt = new RawDataType(get SystemId(), getName(), getDescription(), getData().getChannels(),381 rdt = new RawDataType(getExternalId(), getName(), getDescription(), getData().getChannels(), 341 382 "file", null, null, null); 342 383 } -
branches/filedb/src/core/net/sf/basedb/core/PlatformVariant.java
r3793 r3797 37 37 public class PlatformVariant 38 38 extends BasicItem<PlatformVariantData> 39 implements Nameable, Removable , SystemItem39 implements Nameable, Removable 40 40 { 41 41 … … 72 72 73 73 @param dc The DbControl to use for database access 74 @param systemId The systemID of the variant, it must be74 @param externalId The external ID of the variant, it must be 75 75 unique for all variants 76 76 @param channels Number of channels in this variant 77 77 @return The new variant object 78 78 */ 79 public static PlatformVariant getNew(DbControl dc, Platform p, String systemId, int channels)79 public static PlatformVariant getNew(DbControl dc, Platform p, String externalId, int channels) 80 80 { 81 81 PlatformVariant v = dc.newItem(PlatformVariant.class); 82 82 v.setPlatform(p); 83 83 v.getData().setFileOnly(true); 84 v.set SystemId(systemId);84 v.setExternalId(externalId); 85 85 v.setChannels(channels); 86 86 return v; … … 92 92 93 93 @param dc The DbControl to use for database access 94 @param systemId The systemID of the platform variant, must be94 @param externalId The external ID of the platform variant, must be 95 95 unique for all variants (including those for other platforms) 96 96 @param rawDataType A specific raw data type this platform will be locked … … 98 98 @return The new platform object 99 99 */ 100 public static PlatformVariant getNew(DbControl dc, Platform p, String systemId, RawDataType rawDataType)100 public static PlatformVariant getNew(DbControl dc, Platform p, String externalId, RawDataType rawDataType) 101 101 { 102 102 PlatformVariant v = dc.newItem(PlatformVariant.class); 103 103 v.setPlatform(p); 104 104 v.getData().setFileOnly(false); 105 v.set SystemId(systemId);105 v.setExternalId(externalId); 106 106 v.setRawDataType(rawDataType); 107 107 return v; … … 129 129 130 130 /** 131 Get a <code>PlatformVariant</code> item when you know the external ID. 132 133 @param dc The <code>DbControl</code> which will be used for 134 permission checking and database access. 135 @param externalId The external ID of the item to load 136 @return The <code>PlatformVariant</code> item. 137 @throws ItemNotFoundException If an item with the specified ID is not found 138 @throws PermissionDeniedException If the logged in user doesn't have 139 read permission for the item 140 @throws BaseException If there is another error 141 */ 142 public static PlatformVariant getByExternalId(DbControl dc, String externalId) 143 throws ItemNotFoundException, PermissionDeniedException, BaseException 144 { 145 if (externalId != null) externalId = externalId.trim(); 146 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), 147 "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID"); 148 /* 149 SELECT plv 150 FROM PlatformVariantData plv 151 WHERE plv.externalId = :externalId 152 */ 153 query.setString("externalId", externalId); 154 PlatformVariant v = dc.getItem(PlatformVariant.class, HibernateUtil.loadData(PlatformVariantData.class, query)); 155 if (v == null) throw new ItemNotFoundException("PlatformVariant[externalId="+externalId+"]"); 156 return v; 157 } 158 159 /** 131 160 Get a query configured to retrieve <code>Platform</code> items. 132 161 @return An {@link ItemQuery} object … … 180 209 checkPermission(Permission.WRITE); 181 210 NameableUtil.setDescription(getData(), description); 182 }183 // -------------------------------------------184 /*185 From the SystemItem interface186 -------------------------------------------187 */188 public String getSystemId()189 {190 return getData().getSystemId();191 }192 public boolean isSystemItem()193 {194 return getData().getSystemId() != null;195 211 } 196 212 // ------------------------------------------- … … 300 316 301 317 /** 302 Set the system ID. Null is not allowed and the length must 303 be less than {@link #MAX_SYSTEM_ID_LENGTH}. 304 */ 305 private void setSystemId(String systemId) 306 { 307 getData().setSystemId(StringUtil.setNotNullString(systemId, "systemId", 308 MAX_SYSTEM_ID_LENGTH)); 318 The maximum length of the external ID that can be stored in the database. 319 @see #setExternalId(String) 320 */ 321 public static final int MAX_EXTERNAL_ID_LENGTH = PlatformVariantData.MAX_EXTERNAL_ID_LENGTH; 322 323 /** 324 Get the external id for the platform variant. 325 */ 326 public String getExternalId() 327 { 328 return getData().getExternalId(); 329 } 330 331 private void setExternalId(String externalId) 332 throws PermissionDeniedException, InvalidDataException, BaseException 333 { 334 getData().setExternalId(StringUtil.setNullableString( 335 externalId, "externalId", MAX_EXTERNAL_ID_LENGTH)); 309 336 } 310 337 -
branches/filedb/src/core/net/sf/basedb/core/SystemItem.java
r3764 r3797 25 25 package net.sf.basedb.core; 26 26 27 import net.sf.basedb.core.data. PlatformData;27 import net.sf.basedb.core.data.SystemData; 28 28 29 29 /** … … 62 62 */ 63 63 public static final int MAX_SYSTEM_ID_LENGTH = 64 PlatformData.MAX_SYSTEM_ID_LENGTH;64 SystemData.MAX_SYSTEM_ID_LENGTH; 65 65 66 66 -
branches/filedb/src/core/net/sf/basedb/core/data/DataFileTypeData.java
r3793 r3797 37 37 public class DataFileTypeData 38 38 extends BasicData 39 implements NameableData, RemovableData , SystemData39 implements NameableData, RemovableData 40 40 { 41 41 … … 68 68 69 69 /* 70 From the SystemData interface71 -------------------------------------------72 */73 private String systemId;74 /**75 Get the system id for the item. We override the Hibernate declaration to make76 the column NOT NULL and UNIQUE.77 @return The id of the item78 @hibernate.property column="`system_id`" type="string" length="255"79 not-null="true" update="false" unique="true"80 */81 public String getSystemId()82 {83 return systemId;84 }85 public void setSystemId(String systemId)86 {87 this.systemId = systemId;88 }89 // -------------------------------------------90 91 /*92 70 From the RemovableData interface 93 71 ------------------------------------------- … … 104 82 // ------------------------------------------- 105 83 84 /** 85 The maximum length of the external ID that can be stored in the database. 86 @see #setExternalId(String) 87 */ 88 public static final int MAX_EXTERNAL_ID_LENGTH = 255; 89 private String externalId; 90 /** 91 Get the external id for the item. 92 @return The external id of the item 93 @hibernate.property column="`external_id`" type="string" length="255" 94 not-null="true" update="false" unique="true" 95 */ 96 public String getExternalId() 97 { 98 return externalId; 99 } 100 public void setExternalId(String externalId) 101 { 102 this.externalId = externalId; 103 } 104 106 105 /** 107 106 The maximum length of the file extension that can be stored in the -
branches/filedb/src/core/net/sf/basedb/core/data/PlatformData.java
r3793 r3797 39 39 public class PlatformData 40 40 extends BasicData 41 implements NameableData, RemovableData , SystemData41 implements NameableData, RemovableData 42 42 { 43 43 … … 70 70 71 71 /* 72 From the SystemData interface73 -------------------------------------------74 */75 private String systemId;76 /**77 Get the system id for the item. We override the Hibernate declaration to make78 the column NOT NULL and UNIQUE.79 @return The id of the item80 @hibernate.property column="`system_id`" type="string" length="255"81 not-null="true" update="false" unique="true"82 */83 public String getSystemId()84 {85 return systemId;86 }87 public void setSystemId(String systemId)88 {89 this.systemId = systemId;90 }91 // -------------------------------------------92 93 /*94 72 From the RemovableData interface 95 73 ------------------------------------------- … … 106 84 // ------------------------------------------- 107 85 86 /** 87 The maximum length of the external ID that can be stored in the database. 88 @see #setExternalId(String) 89 */ 90 public static final int MAX_EXTERNAL_ID_LENGTH = 255; 91 private String externalId; 92 /** 93 Get the external id for the item. 94 @return The external id of the item 95 @hibernate.property column="`external_id`" type="string" length="255" 96 not-null="true" update="false" unique="true" 97 */ 98 public String getExternalId() 99 { 100 return externalId; 101 } 102 public void setExternalId(String externalId) 103 { 104 this.externalId = externalId; 105 } 106 108 107 private boolean fileOnly; 109 108 /** -
branches/filedb/src/core/net/sf/basedb/core/data/PlatformVariantData.java
r3793 r3797 37 37 public class PlatformVariantData 38 38 extends BasicData 39 implements NameableData, RemovableData , SystemData39 implements NameableData, RemovableData 40 40 { 41 41 … … 68 68 69 69 /* 70 From the SystemData interface71 -------------------------------------------72 */73 private String systemId;74 /**75 Get the system id for the item. We override the Hibernate declaration to make76 the column NOT NULL and UNIQUE.77 @return The id of the item78 @hibernate.property column="`system_id`" type="string" length="255"79 not-null="true" update="false" unique="true"80 */81 public String getSystemId()82 {83 return systemId;84 }85 public void setSystemId(String systemId)86 {87 this.systemId = systemId;88 }89 // -------------------------------------------90 91 /*92 70 From the RemovableData interface 93 71 ------------------------------------------- … … 104 82 // ------------------------------------------- 105 83 84 /** 85 The maximum length of the external ID that can be stored in the database. 86 @see #setExternalId(String) 87 */ 88 public static final int MAX_EXTERNAL_ID_LENGTH = 255; 89 private String externalId; 90 /** 91 Get the external id for the item. 92 @return The external id of the item 93 @hibernate.property column="`external_id`" type="string" length="255" 94 not-null="true" update="false" unique="true" 95 */ 96 public String getExternalId() 97 { 98 return externalId; 99 } 100 public void setExternalId(String externalId) 101 { 102 this.externalId = externalId; 103 } 104 106 105 private boolean fileOnly; 107 106 /** -
branches/filedb/src/test/TestArrayDesign.java
r3793 r3797 134 134 { 135 135 dc = TestUtil.getDbControl(); 136 Platform platform = Platform.getBy Id(dc, SystemItems.getId(platformId));136 Platform platform = Platform.getByExternalId(dc, platformId); 137 137 ArrayDesign ad = ArrayDesign.getNew(dc, platform); 138 138 if (setAll) … … 386 386 dc = TestUtil.getDbControl(); 387 387 ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId); 388 if (Platform.AFFYMETRIX.equals(ad.getPlatform().get SystemId()))388 if (Platform.AFFYMETRIX.equals(ad.getPlatform().getExternalId())) 389 389 { 390 390 throw new BaseException("Cannot add features from wells on an affy arraydesign"); -
branches/filedb/src/test/TestDataFileType.java
r3793 r3797 30 30 import net.sf.basedb.core.ItemResultList; 31 31 import net.sf.basedb.core.Permission; 32 import net.sf.basedb.core.Platform;33 32 import net.sf.basedb.core.PlatformVariant; 34 import net.sf.basedb.core.RawDataTypes;35 33 import net.sf.basedb.core.SystemItems; 36 34 … … 65 63 } 66 64 67 static int test_create(String name, String systemId, Item itemType, int genericTypeId)65 static int test_create(String name, String externalId, Item itemType, int genericTypeId) 68 66 { 69 67 if (!TestUtil.hasPermission(Permission.CREATE, Item.DATAFILETYPE)) return 0; … … 74 72 dc = TestUtil.getDbControl(); 75 73 FileType genericType = genericTypeId == 0 ? null : FileType.getById(dc, genericTypeId); 76 DataFileType type = DataFileType.getNew(dc, systemId, itemType);74 DataFileType type = DataFileType.getNew(dc, externalId, itemType); 77 75 type.setGenericType(genericType); 78 76 type.setName(name); … … 174 172 if (!TestUtil.getSilent()) 175 173 { 176 write(" \tID \tName \tDescription\ tSystemID");174 write(" \tID \tName \tDescription\\tExternal ID"); 177 175 write("-- \t-- \t--------- \t-----------\t---------"); 178 176 } … … 185 183 { 186 184 System.out.println(i+":\t"+type.getId()+"\t"+type.getName()+"\t"+ 187 type.getDescription() + "\t" + type.get SystemId());185 type.getDescription() + "\t" + type.getExternalId()); 188 186 } 189 187 } … … 195 193 { 196 194 System.out.println(i+":\t"+v.getId()+"\t"+v.getName()+"\t"+ 197 v.getDescription() + "\t" + v.get SystemId() + "\t" + v.isFileOnly() + "\t" +195 v.getDescription() + "\t" + v.getExternalId() + "\t" + v.isFileOnly() + "\t" + 198 196 v.getRawDataType() + "\t" + v.getPlatform()); 199 197 } … … 205 203 } 206 204 207 static int test_create_variant(int platformId, String name, String systemId, Boolean fileOnly, int channels, String rawDataType) 208 { 209 if (platformId == 0 || !TestUtil.hasPermission(Permission.CREATE, Item.PLATFORMVARIANT)) return 0; 205 static int get_id_for_external(String externalId) 206 { 210 207 int id = 0; 211 208 DbControl dc = null; … … 213 210 { 214 211 dc = TestUtil.getDbControl(); 215 216 Platform p = Platform.getById(dc, platformId); 217 218 PlatformVariant v = null; 219 if (fileOnly == null) 220 { 221 v = PlatformVariant.getNew(dc, p, systemId); 222 } 223 else if (fileOnly == true) 224 { 225 v = PlatformVariant.getNew(dc, p, systemId, channels); 226 } 227 else 228 { 229 v = PlatformVariant.getNew(dc, p, systemId, RawDataTypes.getRawDataType(rawDataType)); 230 } 231 v.setName(name); 232 dc.saveItem(v); 233 dc.commit(); 234 id = v.getId(); 235 dc = TestUtil.getDbControl(); 236 dc.reattachItem(v); 237 write_item(0, v); 238 write("--Create platform variant OK"); 239 } 240 catch (Throwable ex) 241 { 242 write("--Create platform variant FAILED"); 243 ex.printStackTrace(); 244 ok = false; 245 } 246 finally 247 { 248 if (dc != null) dc.close(); 249 } 250 return id; 251 } 252 253 static void test_list_variants(int platformId, int expectedResults) 254 { 255 if (platformId == 0) return; 256 DbControl dc = null; 257 try 258 { 259 dc = TestUtil.getDbControl(); 260 Platform p = Platform.getById(dc, platformId); 261 ItemResultList<PlatformVariant> l = p.getVariants().list(dc); 262 for (int i = 0; i<l.size(); i++) 263 { 264 write_item(i, l.get(i)); 265 } 266 if (expectedResults >= 0 && expectedResults != l.size()) 267 { 268 throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); 269 } 270 write("--List platform variants OK ("+l.size()+")"); 271 } 272 catch (Throwable ex) 273 { 274 write("--List platform variants FAILED"); 275 ex.printStackTrace(); 276 ok = false; 277 } 278 finally 279 { 280 if (dc != null) dc.close(); 281 } 282 } 283 284 static void test_delete_variant(int variantId) 285 { 286 if (variantId == 0) return; 287 DbControl dc = null; 288 try 289 { 290 dc = TestUtil.getDbControl(); 291 PlatformVariant v = PlatformVariant.getById(dc, variantId); 292 dc.deleteItem(v); 293 dc.commit(); 294 write("--Delete platform variant OK"); 295 } 296 catch (Throwable ex) 297 { 298 write("--Delete platform variant FAILED"); 299 ex.printStackTrace(); 300 ok = false; 301 } 302 finally 303 { 304 if (dc != null) dc.close(); 305 } 212 DataFileType type = DataFileType.getByExternalId(dc, externalId); 213 id = type.getId(); 214 write("--Get data file type (" + externalId + ") OK"); 215 } 216 catch (Throwable ex) 217 { 218 write("--Get data file type (" + externalId + ") FAILED"); 219 ex.printStackTrace(); 220 ok = false; 221 } 222 finally 223 { 224 if (dc != null) dc.close(); 225 } 226 return id; 306 227 } 307 228 -
branches/filedb/src/test/TestPlatform.java
r3793 r3797 54 54 write_header(); 55 55 // Standard tests: create, load and list 56 test_load(SystemItems.getId(Platform.AFFYMETRIX)); 57 56 58 57 int id1 = test_create("Db and file", "test.db.and.file", false, 0, null); 59 58 int id2 = test_create("File-only", "test.file.only", true, 1, null); … … 70 69 // File types 71 70 int fileTypeId = TestDataFileType.test_create("test.datafile", "test.datafile", Item.RAWBIOASSAY, SystemItems.getId(FileType.RAW_DATA)); 72 test_add_filetype(id2, 0, SystemItems.getId("affymetrix.cel"), true); 73 test_add_filetype(id2, idVariant2, SystemItems.getId("affymetrix.cdf"), false); 71 int celId = TestDataFileType.get_id_for_external("affymetrix.cel"); 72 int cdfId = TestDataFileType.get_id_for_external("affymetrix.cdf"); 73 test_add_filetype(id2, 0, celId, true); 74 test_add_filetype(id2, idVariant2, cdfId, false); 74 75 test_add_filetype(id2, idVariant2b, fileTypeId, false); 75 76 test_list_filetypes(id2, 0, false, 3); … … 199 200 if (!TestUtil.getSilent()) 200 201 { 201 write(" \tID \tName \tDescription\t SystemID\tFile only\tRaw data type");202 write(" \tID \tName \tDescription\tExternal ID\tFile only\tRaw data type"); 202 203 write("-- \t-- \t--------- \t-----------\t---------\t---------\t-------------"); 203 204 } … … 210 211 { 211 212 System.out.println(i+":\t"+p.getId()+"\t"+p.getName()+"\t"+ 212 p.getDescription() + "\t" + p.get SystemId() + "\t" + p.isFileOnly() + "\t" +213 p.getDescription() + "\t" + p.getExternalId() + "\t" + p.isFileOnly() + "\t" + 213 214 p.getRawDataType()); 214 215 } … … 221 222 { 222 223 System.out.println(i+":\t"+v.getId()+"\t"+v.getName()+"\t"+ 223 v.getDescription() + "\t" + v.get SystemId() + "\t" + v.isFileOnly() + "\t" +224 v.getDescription() + "\t" + v.getExternalId() + "\t" + v.isFileOnly() + "\t" + 224 225 v.getRawDataType() + "\t" + v.getPlatform()); 225 226 } -
branches/filedb/src/test/TestRawBioAssay.java
r3793 r3797 109 109 { 110 110 dc = TestUtil.getDbControl(); 111 Platform platform = Platform.getBy Id(dc, SystemItems.getId(platformId));111 Platform platform = Platform.getByExternalId(dc, platformId); 112 112 RawBioAssay rba = RawBioAssay.getNew(dc, platform, RawDataTypes.getRawDataType(rawDataType)); 113 113 if (setAll) … … 536 536 dc = TestUtil.getDbControl(); 537 537 RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); 538 DataFileType type = DataFileType.getBy Id(dc, SystemItems.getId(fileType));538 DataFileType type = DataFileType.getByExternalId(dc, fileType); 539 539 File file = File.getById(dc, fileId); 540 540 rba.getFileSet().setMember(file, type);
Note: See TracChangeset
for help on using the changeset viewer.