Changeset 3804
- Timestamp:
- Oct 4, 2007, 2:25:41 PM (16 years ago)
- Location:
- branches/filedb
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/filedb/src/core/common-queries.xml
r3797 r3804 2857 2857 </description> 2858 2858 </query> 2859 2860 <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL"> 2861 <sql> 2862 SELECT mbr 2863 FROM FileSetMemberData mbr 2864 WHERE mbr.dataFileType.externalId = :externalId 2865 AND mbr.fileSet = :fileSet 2866 </sql> 2867 <description> 2868 A Hibernate query that loads a member in a given file set 2869 if we know the external ID of the data file type. 2870 </description> 2871 </query> 2872 2873 2874 <query id="DELETE_PROPERTY_FILTER" type="SQL"> 2875 <sql> 2876 DELETE FROM [PropertyFilters] 2877 WHERE [property] = :property 2878 </sql> 2879 <description> 2880 An SQL query that delete all PropertyFilters 2881 which filter on a given property. 2882 </description> 2883 </query> 2884 2885 <query id="GET_PLUGINS_WITH_KEYS" type="HQL"> 2886 <sql> 2887 SELECT DISTINCT pk.pluginDefinitionId 2888 FROM PluginKeys pk WHERE pk.keyId IN (:keys) 2889 </sql> 2890 <description> 2891 A HQL query that has been granted a specific permission. Used by 2892 update scripts when new item types are added to make sure existing 2893 plug-ins can continue to work. 2894 </description> 2895 </query> 2859 2896 2860 2897 -
branches/filedb/src/core/net/sf/basedb/core/Affymetrix.java
r3802 r3804 79 79 Affymetrix chip or if the file is not a CDF file 80 80 @throws BaseException If there is another error 81 @deprecated 81 @deprecated Use {@link FileStoreUtil#setDataFile(DbControl, FileStoreEnabled, String, File)} 82 instead with {@link DataFileType#AFFYMETRIX_CDF} as the file 83 type 82 84 */ 83 85 public static void setCdfFile(ArrayDesign design, File file) … … 85 87 { 86 88 if (design == null) throw new InvalidUseOfNullException("design"); 87 if (!design.is AffyChip())89 if (!design.isPlatform(Platform.AFFYMETRIX)) 88 90 { 89 91 throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design); 90 92 } 91 design.checkPermission(Permission.WRITE);92 93 DbControl dc = design.getDbControl(); 93 if (file != null) 94 { 95 file.checkPermission(Permission.USE); 96 97 // Verify that the file is a CDF file 98 FusionCDFData cdf = loadCdfFile(file); 99 100 AnyToAny ata = AnyToAny.getNewOrExisting(dc, design, CDF_LINK_NAME, file, true); 101 if (!ata.isInDatabase()) dc.saveItem(ata); 102 design.getData().setHasFeatures(true); 103 design.getData().setNumFileFeatures(cdf.getHeader().getNumProbeSets()); 104 } 105 else 106 { 107 AnyToAny.unlinkFrom(dc, design, CDF_LINK_NAME); 108 design.getData().setHasFeatures(false); 109 } 94 FileStoreUtil.setDataFile(dc, design, DataFileType.AFFYMETRIX_CDF, file); 95 if (file != null) design.getFileSet().validate(dc, true); 110 96 } 111 97 … … 131 117 Affymetrix chip 132 118 @throws BaseException If there is another error 133 @deprecated Use {@link FileS et#getMember(DataFileType)}119 @deprecated Use {@link FileStoreUtil#getDataFile(DbControl, FileStoreEnabled, String)} 134 120 with a data file type of {@link DataFileType#AFFYMETRIX_CDF} 135 121 instead … … 139 125 { 140 126 if (design == null) throw new InvalidUseOfNullException("design"); 141 if (!design.is AffyChip())142 { 143 throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design );127 if (!design.isPlatform(Platform.AFFYMETRIX)) 128 { 129 throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design.getName()); 144 130 } 145 131 DbControl dc = design.getDbControl(); 146 File cdfFile = null; 147 if (design.hasFileSet()) 148 { 149 FileSet fileSet = design.getFileSet(); 150 DataFileType cdfType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CDF); 151 if (fileSet.hasMember(cdfType)) 152 { 153 FileSetMember member = fileSet.getMember(cdfType); 154 cdfFile = member.getFile(); 155 } 156 } 157 return cdfFile; 132 return FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF); 158 133 } 159 134 … … 211 186 " must have an array design to set CEL file"); 212 187 } 213 if (!design.is AffyChip())188 if (!design.isPlatform(Platform.AFFYMETRIX)) 214 189 { 215 190 throw new InvalidDataException("The array design " + design.getName() + -
branches/filedb/src/core/net/sf/basedb/core/ArrayDesign.java
r3802 r3804 89 89 } 90 90 91 /** 92 Create a new <code>ArrayDesign</code> item for a given platform. 93 94 @param dc The <code>DbControl</code> which will be used for 95 permission checking and database access 96 @param platform The platform of the array design 97 @return The new <code>ArrayDesign</code> item 98 @throws BaseException If there is an error 99 */ 91 100 public static ArrayDesign getNew(DbControl dc, Platform platform) 92 101 { … … 97 106 } 98 107 108 /** 109 Create a new <code>ArrayDesign</code> item for a given platform 110 variant. 111 112 @param dc The <code>DbControl</code> which will be used for 113 permission checking and database access 114 @param variant The platform variant of the array design 115 @return The new <code>ArrayDesign</code> item 116 @throws BaseException If there is an error 117 */ 99 118 public static ArrayDesign getNew(DbControl dc, PlatformVariant variant) 100 119 { … … 104 123 return ad; 105 124 } 106 107 125 108 126 /** … … 273 291 // ------------------------------------------- 274 292 293 /** 294 Set the platform of the array design. This method will set the variant 295 to null. Use {@link #setVariant(PlatformVariant)} if you want to 296 set a specific variant. 297 @param platform The new platform 298 @throws PermissionDeniedException If the logged in user doesn't have 299 write permission 300 @throws InvalidDataException If platform is null 301 */ 275 302 public void setPlatform(Platform platform) 276 303 { … … 281 308 } 282 309 310 /** 311 Set the platform and variant of the array design. This method will 312 automatically set the platform to {@link PlatformVariant#getPlatform()}. 313 314 @param variant The new platform variant, or null to remove 315 the variant and keep the platform as it is 316 @throws PermissionDeniedException If the logged in user doesn't have 317 write permission 318 */ 283 319 public void setVariant(PlatformVariant variant) 284 320 { … … 296 332 297 333 /** 298 @return TRUE if this is an AffyChip, FALSE otherwise. 299 @deprecated Use {@link #getPlatform()} instead and compare the 300 external ID with {@link Platform#AFFYMETRIX} 334 Check if the platform/variant of this array design has the 335 given external ID. 336 @param externalId The external ID to match 337 @return TRUE if either the variant of platform matches the 338 external ID 339 */ 340 public boolean isPlatform(String externalId) 341 { 342 if (externalId == null) return false; 343 if (externalId.equals(getData().getPlatform().getExternalId())) return true; 344 if (getData().getVariant() != null) 345 { 346 if (externalId.equals(getData().getVariant().getExternalId())) return true; 347 } 348 return false; 349 } 350 351 /** 352 Check if this array design uses a file-only platform or variant. 353 If the array design has a platform variant, the setting from the 354 variant is returned, otherwise the setting from the platform. 355 @return TRUE if this array design use a file-only platform 356 */ 357 public boolean isFileOnlyPlatform() 358 { 359 if (getData().getVariant() != null) 360 { 361 return getData().getVariant().isFileOnly(); 362 } 363 else 364 { 365 return getData().getPlatform().isFileOnly(); 366 } 367 } 368 369 /** 370 @return TRUE if this is an Affymetrix chip, FALSE otherwise. 371 @deprecated Use {@link #isPlatform(String)} instead with 372 {@link Platform#AFFYMETRIX} as the parameter 301 373 */ 302 374 public boolean isAffyChip() 303 375 { 304 return Platform.AFFYMETRIX.equals(getData().getPlatform().getExternalId()); 305 } 306 307 /** 376 return isPlatform(Platform.AFFYMETRIX); 377 } 378 379 /** 380 Check if this array design has information about features, either 381 in the database or in files. 308 382 @return TRUE if this object has features, FALSE otherwise 309 383 */ … … 491 565 that can add features to the new block. 492 566 <p> 493 It is not possible to add blocks to an Affymetrix chip. It stores 494 it's feature in a CDF file instead. See {@link Affymetrix#setCdfFile(ArrayDesign, File)}. 567 It is not possible to add blocks to an array design which uses a 568 file-only platform. The must store feature information in files 569 instead. See {@link Platform} and {@link DataFileType}. 495 570 496 571 @param bi The information for the new block … … 503 578 throws PermissionDeniedException, BaseException 504 579 { 580 if (getData().getPlatform().isFileOnly()) 581 { 582 throw new PermissionDeniedException("Can't add blocks to a file-only array design: " + this.getName()); 583 } 505 584 if (hasFeatures()) 506 585 { 507 throw new PermissionDeniedException("Can't add blocks to a design that already has features: " + this); 508 } 509 if (isAffyChip()) 510 { 511 throw new PermissionDeniedException("Can't add blocks to an Affymetrix chip: " + this); 586 throw new PermissionDeniedException("Can't add blocks to a design that already has features: " + this.getName()); 512 587 } 513 588 checkPermission(Permission.WRITE); … … 531 606 array design. 532 607 <p> 533 It is not possible to add features to an Affymetrix chip. It stores 534 it's feature in a CDF file instead. See {@link Affymetrix#setCdfFile(ArrayDesign, File)}. 608 It is not possible to add blocks to an array design which uses a 609 file-only platform. The must store feature information in files 610 instead. See {@link Platform} and {@link DataFileType}. 535 611 536 612 @throws PermissionDeniedException If raw data has already been added … … 542 618 { 543 619 checkPermission(Permission.WRITE); 620 if (isFileOnlyPlatform()) 621 { 622 throw new PermissionDeniedException("Can't add features to a file-only array design: " + this.getName()); 623 } 544 624 if (hasFeatures()) 545 625 { 546 throw new PermissionDeniedException("Features has already been added to "+this); 547 } 548 if (isAffyChip()) 549 { 550 throw new PermissionDeniedException("Can't add features to an Affymetrix chip: " + this); 626 throw new PermissionDeniedException("Features has already been added to "+this.getName()); 551 627 } 552 628 if (featureBatcher == null) -
branches/filedb/src/core/net/sf/basedb/core/FeatureBatcher.java
r3783 r3804 77 77 78 78 /** 79 If the array design is an affy chip which needs AffyFeatureData80 objects instead of FeatureData.81 */82 private final boolean isAffy;83 84 85 /**86 79 Keeps track of the position number. 87 80 */ … … 94 87 this.arrayDesign = arrayDesign; 95 88 this.arrayDesignData = arrayDesign.getData(); 96 this.isAffy = arrayDesign.isAffyChip();97 89 setDbControl(dc); 98 90 } … … 209 201 throws BaseException 210 202 { 211 if (getTotalInsertCount() > 0) 203 int insertCount = getTotalInsertCount(); 204 if (insertCount > 0) 212 205 { 213 206 arrayDesignData.setHasFeatures(true); 207 arrayDesignData.setNumDbFeatures(insertCount); 214 208 } 215 209 } -
branches/filedb/src/core/net/sf/basedb/core/FileSet.java
r3802 r3804 255 255 } 256 256 257 public ItemQuery<FileSetMember> getMembers(String genericType) 258 { 259 ItemQuery<FileSetMember> query = getMembers(); 260 query.restrictPermanent( 261 Restrictions.eq( 262 Hql.property("dataFileType.genericType.systemId"), 263 Expressions.string(genericType) 264 ) 265 ); 266 return query; 267 } 268 257 269 /** 258 270 Set a file of a given type as a member of this file set. 259 271 If another file of the given type already exists, it is replaced 260 272 with this file. If no member exists, a new entry is created and 261 automaticall saved to the database when {@link DbControl#commit()}273 automatically saved to the database when {@link DbControl#commit()} 262 274 is called. 263 275 @param file The file to set as a member 264 276 @param type The type of the file 277 @return The new FileSetMember item 265 278 @throws InvalidUseOfNullException If file or type is null 266 279 @throws PermissionDeniedException If the logged in user doesn't … … 268 281 file 269 282 */ 270 public voidsetMember(File file, DataFileType type)283 public FileSetMember setMember(File file, DataFileType type) 271 284 { 272 285 checkPermission(Permission.WRITE); … … 276 289 277 290 Map<DataFileTypeData, FileSetMemberData> members = getData().getMembers(); 278 FileSetMemberData member = members.get(type.getData()); 279 if (member == null) 280 { 281 FileSetMember newMember = FileSetMember.getNew(getDbControl(), this, file, type); 282 members.put(type.getData(), newMember.getData()); 283 getDbControl().saveItemIf(this, newMember, false); 291 FileSetMemberData memberData = members.get(type.getData()); 292 FileSetMember member = null; 293 if (memberData == null) 294 { 295 member = FileSetMember.getNew(getDbControl(), this, file, type); 296 members.put(type.getData(), member.getData()); 297 getDbControl().saveItemIf(this, member, false); 284 298 } 285 299 else 286 300 { 287 if (!file.getData().equals(member.getFile())) 288 { 289 member.setFile(file.getData()); 290 member.setValid(null); 291 } 292 } 301 if (!file.getData().equals(memberData.getFile())) 302 { 303 memberData.setFile(file.getData()); 304 memberData.setValid(null); 305 } 306 member = getDbControl().getItem(FileSetMember.class, memberData); 307 } 308 return member; 293 309 } 294 310 -
branches/filedb/src/core/net/sf/basedb/core/FileSetMember.java
r3802 r3804 195 195 } 196 196 197 public void setValid(Boolean valid, String errorMessage) 198 { 199 checkPermission(Permission.WRITE); 200 getData().setValid(valid); 201 getData().setErrorMessage(errorMessage); 202 } 203 197 204 /** 198 205 Get the error message if the validation failed. -
branches/filedb/src/core/net/sf/basedb/core/Install.java
r3801 r3804 107 107 method. 108 108 */ 109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(4 3).intValue();109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(44).intValue(); 110 110 111 111 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
branches/filedb/src/core/net/sf/basedb/core/RawBioAssay.java
r3783 r3804 349 349 // ------------------------------------------- 350 350 351 private void setPlatform(Platform platform) 352 { 351 public void setPlatform(Platform platform) 352 { 353 checkPermission(Permission.WRITE); 353 354 if (platform == null) throw new InvalidUseOfNullException("platform"); 354 355 getData().setPlatform(platform.getData()); 355 } 356 357 private void setVariant(PlatformVariant variant) 358 { 359 if (variant == null) throw new InvalidUseOfNullException("variant"); 360 getData().setVariant(variant.getData()); 361 } 356 getData().setVariant(null); 357 } 358 359 public void setVariant(PlatformVariant variant) 360 { 361 checkPermission(Permission.WRITE); 362 if (variant != null) 363 { 364 getData().setVariant(variant.getData()); 365 getData().setPlatform(variant.getData().getPlatform()); 366 } 367 else 368 { 369 getData().setVariant(null); 370 } 371 } 362 372 363 373 /** -
branches/filedb/src/core/net/sf/basedb/core/Update.java
r3801 r3804 29 29 import java.sql.SQLException; 30 30 import java.sql.Statement; 31 import java.util.Arrays; 31 32 import java.util.Collections; 32 33 import java.util.Date; … … 39 40 import org.hibernate.mapping.Table; 40 41 41 import affymetrix.fusion.cdf.FusionCDFData;42 43 import net.sf.basedb.core.data.AnyToAnyData;44 42 import net.sf.basedb.core.data.ArrayDesignData; 45 43 import net.sf.basedb.core.data.DataCubeData; … … 53 51 import net.sf.basedb.core.data.PluginConfigurationData; 54 52 import net.sf.basedb.core.data.PluginDefinitionData; 53 import net.sf.basedb.core.data.RawBioAssayData; 55 54 import net.sf.basedb.core.data.SchemaVersionData; 56 55 import net.sf.basedb.core.data.TransformationData; 56 import net.sf.basedb.core.data.keyring.PluginKeys; 57 57 import net.sf.basedb.core.dbengine.DbEngine; 58 58 import net.sf.basedb.core.dbengine.TableInfo; … … 491 491 </td> 492 492 </tr> 493 493 494 494 <tr> 495 495 <td>42</td> 496 496 <td> 497 <ul> 498 <li>Added {@link net.sf.basedb.core.data.ArrayDesignData#getNumFeatures()} 499 </ul> 500 The update will query the database or check the CDF file to get 501 the information. 502 </td> 503 </tr> 504 497 No longer used. 498 </td> 499 </tr> 500 505 501 <tr> 506 502 <td>43</td> … … 511 507 </td> 512 508 </tr> 509 510 <tr> 511 <td>44</td> 512 <td> 513 <ul> 514 <li>Added {@link Platform}, {@link DataFileType} and 515 a lot of related classes. 516 </ul> 517 The update will set a platform for all array designs and 518 raw bioassays. For Affymetrix data it will move the CEL and CDF files 519 from AnyToAny links into FileSet:s. 520 </td> 521 </tr> 522 513 523 514 524 </table> … … 726 736 } 727 737 728 /* 729 if (schemaVersion < 43) 730 { 731 if (progress != null) progress.display((int)(42*progress_factor), "--Updating schema version: " + schemaVersion + " -> 43..."); 732 schemaVersion = setSchemaVersionInTransaction(session, 43); 733 - or - 734 schemaVersion = updateToSchemaVersion43(session); 735 } 736 ... etc... 737 */ 738 if (schemaVersion < 44) 739 { 740 if (progress != null) progress.display((int)(43*progress_factor), "--Updating schema version: " + schemaVersion + " -> 44..."); 741 schemaVersion = updateToSchemaVersion44(sc); 742 } 738 743 739 744 sc.logout(); … … 1605 1610 1606 1611 /** 1607 Count the number of features for all array designs. For Affymetrix designs 1608 the CDF file is checked. 1612 Has been replaced with {@link #updateToSchemaVersion44(SessionControl)} 1609 1613 @return The new schema version (=42) 1610 1614 */ … … 1612 1616 { 1613 1617 final int schemaVersion = 42; 1614 org.hibernate.Transaction tx = null;1615 try1616 {1617 tx = HibernateUtil.newTransaction(session);1618 1619 org.hibernate.Query query = HibernateUtil.createQuery(session,1620 "SELECT ad FROM ArrayDesignData ad");1621 org.hibernate.Query countQuery = HibernateUtil.getPredefinedQuery(session,1622 "COUNT_FEATURES_FOR_ARRAYDESIGN");1623 org.hibernate.Query cdfQuery = HibernateUtil.getPredefinedQuery(session,1624 "GET_ANYTOANY_FOR_NAME");1625 cdfQuery.setInteger("fromType", Item.ARRAYDESIGN.getValue());1626 cdfQuery.setString("name", Affymetrix.CDF_LINK_NAME);1627 1628 List<ArrayDesignData> designs = HibernateUtil.loadList(ArrayDesignData.class, query);1629 for (ArrayDesignData design : designs)1630 {1631 int numFeatures = -1;1632 try1633 {1634 if (!design.getHasFeatures())1635 {1636 numFeatures = 0;1637 }1638 else if (design.isAffyChip())1639 {1640 // Get CDF file and the number of features1641 cdfQuery.setInteger("fromId", design.getId());1642 AnyToAnyData cdfLink = HibernateUtil.loadData(AnyToAnyData.class, cdfQuery);1643 FileData cdf = null;1644 if (cdfLink != null)1645 {1646 cdf = HibernateUtil.loadData(session, FileData.class, cdfLink.getToId());1647 }1648 if (cdf != null)1649 {1650 FusionCDFData cdfData = new FusionCDFData();1651 cdfData.setFileName(File.getAbsolutePath(cdf.getInternalName()).getPath());1652 cdfData.readHeader();1653 numFeatures = cdfData.getHeader().getNumProbeSets();1654 }1655 else1656 {1657 numFeatures = 0;1658 }1659 }1660 else1661 {1662 countQuery.setInteger("arrayDesign", design.getId());1663 numFeatures = HibernateUtil.loadData(Long.class, countQuery).intValue();1664 }1665 }1666 catch (Throwable t)1667 {1668 log.error("Could not set number of features on array design: " + design, t);1669 }1670 //design.setNumFeatures(numFeatures);1671 }1672 1673 1674 // Update the schema version number1675 setSchemaVersion(session, schemaVersion);1676 1677 // Commit the changes1678 HibernateUtil.commit(tx);1679 log.info("updateToSchemaVersion42: OK");1680 }1681 catch (BaseException ex)1682 {1683 if (tx != null) HibernateUtil.rollback(tx);1684 log.error("updateToSchemaVersion42: FAILED", ex);1685 throw ex;1686 }1687 1618 return schemaVersion; 1688 1619 } … … 1728 1659 } 1729 1660 1661 /** 1662 Set a platform for array designs and raw bioassays. 1663 Move CEL and CDF files into FileSet:s 1664 Remove filters on isAffyChip property 1665 */ 1666 @SuppressWarnings("deprecation") 1667 private static int updateToSchemaVersion44(SessionControl sc) 1668 { 1669 final int schemaVersion = 44; 1670 DbControl dc = null; 1671 try 1672 { 1673 dc = sc.newDbControl(); 1674 org.hibernate.Session session = dc.getHibernateSession(); 1675 1676 // Items that we need 1677 Platform affymetrix = Platform.getByExternalId(dc, Platform.AFFYMETRIX); 1678 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 1679 DataFileType cdfType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CDF); 1680 DataFileType celType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CEL); 1681 1682 // Query to count number of features in db 1683 org.hibernate.Query countQuery = HibernateUtil.getPredefinedQuery(session, 1684 "COUNT_FEATURES_FOR_ARRAYDESIGN"); 1685 1686 // Load array designs 1687 org.hibernate.Query designQuery = HibernateUtil.createQuery(session, 1688 "SELECT ad FROM ArrayDesignData ad WHERE ad.platform is null"); 1689 List<ArrayDesignData> arrayDesigns = 1690 HibernateUtil.loadList(ArrayDesignData.class, designQuery); 1691 for (ArrayDesignData dd : arrayDesigns) 1692 { 1693 ArrayDesign design = dc.getItem(ArrayDesign.class, dd); 1694 if (design.getData().isAffyChip()) 1695 { 1696 design.setPlatform(affymetrix); 1697 AnyToAny anyCdf = null; 1698 try 1699 { 1700 anyCdf = AnyToAny.getByName(dc, design, Affymetrix.CDF_LINK_NAME); 1701 } 1702 catch (Throwable t) 1703 {} 1704 AnyToAny.unlinkFrom(dc, design, Affymetrix.CDF_LINK_NAME); 1705 if (anyCdf != null) 1706 { 1707 File cdfFile = (File)anyCdf.getTo(); 1708 FileSet fileSet = design.getFileSet(); 1709 fileSet.setMember(cdfFile, cdfType); 1710 fileSet.validate(dc, true); 1711 } 1712 } 1713 else 1714 { 1715 design.setPlatform(generic); 1716 countQuery.setInteger("arrayDesign", design.getId()); 1717 int dbFeatures = HibernateUtil.loadData(Long.class, countQuery).intValue(); 1718 design.getData().setNumDbFeatures(dbFeatures); 1719 } 1720 } 1721 1722 // Load rawbioassays 1723 org.hibernate.Query rbaQuery = HibernateUtil.createQuery(session, 1724 "SELECT rba FROM RawBioAssayData rba WHERE rba.platform is null"); 1725 List<RawBioAssayData> rawBioAssays = 1726 HibernateUtil.loadList(RawBioAssayData.class, rbaQuery); 1727 for (RawBioAssayData dd : rawBioAssays) 1728 { 1729 RawBioAssay rba = dc.getItem(RawBioAssay.class, dd); 1730 if ("affymetrix".equals(rba.getData().getRawDataType())) 1731 { 1732 rba.setPlatform(affymetrix); 1733 AnyToAny anyCel = null; 1734 try 1735 { 1736 anyCel = AnyToAny.getByName(dc, rba, Affymetrix.CEL_LINK_NAME); 1737 } 1738 catch (Throwable t) 1739 {} 1740 AnyToAny.unlinkFrom(dc, rba, Affymetrix.CEL_LINK_NAME); 1741 if (anyCel != null) 1742 { 1743 File celFile = (File)anyCel.getTo(); 1744 FileSet fileSet = rba.getFileSet(); 1745 fileSet.setMember(celFile, cdfType); 1746 fileSet.validate(dc, true); 1747 } 1748 } 1749 else 1750 { 1751 rba.setPlatform(generic); 1752 } 1753 } 1754 1755 // Remove filters on the 'affyChip' property 1756 org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session, 1757 "DELETE_PROPERTY_FILTER"); 1758 /* 1759 DELETE FROM PropertyFilters pf 1760 WHERE pf.property = :property 1761 */ 1762 query.setString("property", "affyChip"); 1763 HibernateUtil.executeUpdate(query); 1764 1765 // Add READ permission to PLATFORM and DATAFILETYPE for all plug-ins 1766 // working with ARRAYDESIGN or RAWBIOASSAY 1767 int adKeyId = SystemItems.getRoleKeyId(Item.ARRAYDESIGN); 1768 int rbaKeyId = SystemItems.getRoleKeyId(Item.RAWBIOASSAY); 1769 1770 org.hibernate.Query pQuery = HibernateUtil.getPredefinedQuery(session, 1771 "GET_PLUGINS_WITH_KEYS"); 1772 /* 1773 SELECT DISTINCT pk.pluginDefinitionId 1774 FROM PluginKeys pk WHERE pk.keyId IN (:keys) 1775 */ 1776 pQuery.setParameterList("keys", 1777 Arrays.asList( new Integer[] { adKeyId, rbaKeyId }), Type.INT.getHibernateType()); 1778 List<Integer> pluginIds = HibernateUtil.loadList(Integer.class, pQuery); 1779 for (int pluginId : pluginIds) 1780 { 1781 addPluginPermission(session, pluginId, Item.PLATFORM, 0, 2046); 1782 addPluginPermission(session, pluginId, Item.DATAFILETYPE, 0, 2046); 1783 } 1784 1785 // Update the schema version number 1786 setSchemaVersion(session, schemaVersion); 1787 1788 // Commit the changes 1789 dc.commit(); 1790 log.info("updateToSchemaVersion44: OK"); 1791 } 1792 catch (BaseException ex) 1793 { 1794 log.error("updateToSchemaVersion44: FAILED", ex); 1795 throw ex; 1796 } 1797 finally 1798 { 1799 if (dc != null) dc.close(); 1800 } 1801 return schemaVersion; 1802 } 1803 1804 private static void addPluginPermission(org.hibernate.Session session, int pluginId, Item itemType, int granted, int denied) 1805 { 1806 PluginKeys pk = new PluginKeys(); 1807 pk.setPluginDefinitionId(pluginId); 1808 pk.setKeyId(SystemItems.getRoleKeyId(itemType)); 1809 if (session.get(PluginKeys.class, pk) == null) 1810 { 1811 pk.setGranted(granted); 1812 pk.setDenied(denied); 1813 session.save(pk); 1814 } 1815 } 1816 1730 1817 /** 1731 1818 Adjust the existing items in the database to be compatible with the latest mappings. -
branches/filedb/src/plugins/core/net/sf/basedb/plugins/CdfFileReporterImporter.java
r3675 r3804 45 45 import net.sf.basedb.core.ArrayDesign; 46 46 import net.sf.basedb.core.BaseException; 47 import net.sf.basedb.core.DataFileType; 47 48 import net.sf.basedb.core.DbControl; 48 49 import net.sf.basedb.core.File; 49 50 import net.sf.basedb.core.FileParameterType; 51 import net.sf.basedb.core.FileStoreUtil; 50 52 import net.sf.basedb.core.InvalidDataException; 51 53 import net.sf.basedb.core.Item; … … 57 59 import net.sf.basedb.core.Operator; 58 60 import net.sf.basedb.core.Permission; 61 import net.sf.basedb.core.Platform; 59 62 import net.sf.basedb.core.PluginParameter; 60 63 import net.sf.basedb.core.ProgressReporter; … … 65 68 import net.sf.basedb.core.StringParameterType; 66 69 import net.sf.basedb.core.Type; 70 import net.sf.basedb.core.filehandler.CdfFileHandler; 67 71 import net.sf.basedb.core.plugin.About; 68 72 import net.sf.basedb.core.plugin.AboutImpl; … … 156 160 /** 157 161 Request create and write access to Reporter:s 158 and read access to File:s ArrayDesign:s and ReporterType:s. 162 and read access to File:s ArrayDesign:s, ReporterType:s, 163 Platform:s and DataFileType:s 159 164 */ 160 165 public Collection<Permissions> getPermissions() … … 166 171 permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ))); 167 172 permissions.add(new Permissions(Item.ARRAYDESIGN, null, EnumSet.of(Permission.READ))); 173 permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ))); 174 permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ))); 168 175 } 169 176 return permissions; … … 178 185 File cdfFile = (File)job.getValue("file"); 179 186 cdfFile = File.getById(dc, cdfFile.getId()); 180 FusionCDFData cdf = Affymetrix.loadCdfFile(cdfFile);187 FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile); 181 188 182 189 // Import data from it … … 225 232 } 226 233 ArrayDesign design = (ArrayDesign)item; 227 if (!design.is AffyChip())234 if (!design.isPlatform(Platform.AFFYMETRIX)) 228 235 { 229 236 message = "The array design is not an Affymetrix chip"; … … 231 238 else 232 239 { 233 File cdfFile = Affymetrix.getCdfFile(design); 234 if (cdfFile == null) 235 { 236 throw new InvalidDataException("The array design doesn't have a CDF file"); 240 if (!FileStoreUtil.hasDataFile(design.getDbControl(), design, DataFileType.AFFYMETRIX_CDF, true)) 241 { 242 throw new InvalidDataException("The array design doesn't have a valid CDF file"); 237 243 } 238 244 } … … 274 280 // Verify that the file is a CDF file 275 281 File cdfFile = (File)request.getParameterValue("file"); 276 FusionCDFData cdf = Affymetrix.loadCdfFile(cdfFile);282 FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile); 277 283 278 284 storeValue(job, request, ri.getParameter("file")); … … 383 389 int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId(); 384 390 design = ArrayDesign.getById(dc, currentArrayDesignId); 385 cdfFile = Affymetrix.getCdfFile(design);391 cdfFile = FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF); 386 392 presets = Arrays.asList(new File[] { cdfFile } ); 387 393 } -
branches/filedb/src/plugins/core/net/sf/basedb/plugins/PrintMapFlatFileImporter.java
r3679 r3804 32 32 import net.sf.basedb.core.DbControl; 33 33 import net.sf.basedb.core.FeatureBatcher; 34 import net.sf.basedb.core.File; 35 import net.sf.basedb.core.FileParameterType; 36 import net.sf.basedb.core.FileSetMember; 37 import net.sf.basedb.core.FileStoreUtil; 34 38 import net.sf.basedb.core.FileType; 35 39 import net.sf.basedb.core.IntegerUtil; … … 122 126 123 127 private ArrayDesign arrayDesign; 128 private FileSetMember printMapMember; 124 129 private ItemParameterType<ArrayDesign> arrayDesignType; 125 130 private PluginParameter<ArrayDesign> arrayDesignParameter; … … 150 155 } 151 156 /** 152 Request write access to ArrayDesign:s, read access to Plate:s, Reporter:s 153 and File:s.157 Request write access to ArrayDesign:s, read access to Plate:s, Reporter:s, 158 DataFileType:s, Platform:s and File:s. 154 159 */ 155 160 public Collection<Permissions> getPermissions() … … 161 166 permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ))); 162 167 permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ))); 168 permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ))); 169 permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ))); 163 170 } 164 171 return permissions; … … 188 195 { 189 196 ArrayDesign ad = (ArrayDesign)item; 190 if (ad.is AffyChip())191 { 192 message = "A ffy array designs are not supported";193 } 194 else if (ad. hasFeatures())197 if (ad.isFileOnlyPlatform()) 198 { 199 message = "Array design is using a file-only platform"; 200 } 201 else if (ad.getNumDbFeatures() > 0) 195 202 { 196 203 throw new PermissionDeniedException("The array design already has features"); … … 301 308 arrayDesign = (ArrayDesign)job.getValue("arrayDesign"); 302 309 arrayDesign = ArrayDesign.getById(dc, arrayDesign.getId()); 303 if (arrayDesign.hasFeatures()) 310 File reporterMapFile = (File)job.getValue("file"); 311 printMapMember = 312 FileStoreUtil.setDataFile(dc, arrayDesign, "generic.printmap", reporterMapFile); 313 if (arrayDesign.getNumDbFeatures() > 0) 304 314 { 305 315 throw new PermissionDeniedException("The array design already has features: " + arrayDesign.getName()+" ["+arrayDesign.getId()+"]"); … … 447 457 throws BaseException 448 458 { 459 if (printMapMember != null) printMapMember.setValid(success, null); 449 460 if (blocks != null) blocks.clear(); 450 461 try … … 503 514 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 504 515 parameters.add(arrayDesignParameter); 516 517 ArrayDesign design = null; 518 int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId(); 519 List<File> printMapFiles = null; 520 dc = sc.newDbControl(); 521 try 522 { 523 design = ArrayDesign.getById(dc, currentArrayDesignId); 524 printMapFiles = FileStoreUtil.getGenericDataFiles(dc, design, FileType.PRINT_MAP); 525 } 526 catch (Throwable t) 527 {} 528 finally 529 { 530 if (dc != null) dc.close(); 531 } 532 533 // The print map file to import from - if a file already hase 534 // been attached to the array design use it as a default choice 535 PluginParameter<File> fileParameter = new PluginParameter<File>( 536 "file", 537 "Print map file", 538 "The file with printing information to import features from", 539 new FileParameterType(printMapFiles == null || printMapFiles.isEmpty() ? 540 null : printMapFiles.get(0), true, 1) 541 ); 505 542 parameters.add(fileParameter); 506 543 parameters.add(getCharsetParameter(null, null, null)); -
branches/filedb/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java
r3679 r3804 32 32 import net.sf.basedb.core.DbControl; 33 33 import net.sf.basedb.core.FeatureBatcher; 34 import net.sf.basedb.core.File; 35 import net.sf.basedb.core.FileParameterType; 36 import net.sf.basedb.core.FileSetMember; 37 import net.sf.basedb.core.FileStoreUtil; 34 38 import net.sf.basedb.core.FileType; 35 39 import net.sf.basedb.core.InvalidUseOfNullException; … … 173 177 private FeatureBatcher batcher; 174 178 private ReporterBatcher reporterBatcher; 179 private FileSetMember reporterMapMember; 175 180 private ArrayDesign arrayDesign; 176 181 private Map<BlockInfo, ArrayDesignBlock> blocks; … … 216 221 } 217 222 /** 218 Request write access to ArrayDesign:s, read access to Reporter:s 219 and File:s.223 Request write access to ArrayDesign:s, read access to Reporter:s, 224 DataFileType:s, Platform:s and File:s. 220 225 */ 221 226 public Collection<Permissions> getPermissions() … … 226 231 permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ))); 227 232 permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ))); 233 permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ))); 234 permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ))); 228 235 } 229 236 return permissions; … … 263 270 { 264 271 ArrayDesign ad = (ArrayDesign)item; 265 if (ad.is AffyChip())266 { 267 message = "A ffy array designs are not supported";268 } 269 else if (ad. hasFeatures())272 if (ad.isFileOnlyPlatform()) 273 { 274 message = "Array design is using a file-only platform"; 275 } 276 else if (ad.getNumDbFeatures() > 0) 270 277 { 271 278 throw new PermissionDeniedException("The array design already has features"); … … 398 405 dc = sc.newDbControl(); 399 406 arrayDesign = (ArrayDesign)job.getValue("arrayDesign"); 400 dc.reattachItem(arrayDesign); 401 if (arrayDesign.hasFeatures()) 407 File reporterMapFile = (File)job.getValue("file"); 408 arrayDesign = ArrayDesign.getById(dc, arrayDesign.getId()); 409 reporterMapMember = 410 FileStoreUtil.setDataFile(dc, arrayDesign, "generic.reportermap", reporterMapFile); 411 if (arrayDesign.getNumDbFeatures() > 0) 402 412 { 403 413 throw new PermissionDeniedException("The array design already has features. "+arrayDesign.getName()+"["+arrayDesign.getId()+"]"); … … 486 496 { 487 497 if (blocks != null) blocks.clear(); 498 if (reporterMapMember != null) reporterMapMember.setValid(success, null); 488 499 try 489 500 { … … 542 553 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 543 554 parameters.add(arrayDesignParameter); 555 556 ArrayDesign design = null; 557 int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId(); 558 List<File> reporterMapFiles = null; 559 dc = sc.newDbControl(); 560 try 561 { 562 design = ArrayDesign.getById(dc, currentArrayDesignId); 563 reporterMapFiles = FileStoreUtil.getGenericDataFiles(dc, design, FileType.REPORTER_MAP); 564 } 565 catch (Throwable t) 566 {} 567 finally 568 { 569 if (dc != null) dc.close(); 570 } 571 572 // The reporter map file to import from - if a file already hase 573 // been attached to the array design use it as a default choice 574 PluginParameter<File> fileParameter = new PluginParameter<File>( 575 "file", 576 "Reporter map file", 577 "The file with reporter information to import features from", 578 new FileParameterType(reporterMapFiles == null || reporterMapFiles.isEmpty() ? 579 null : reporterMapFiles.get(0), true, 1) 580 ); 544 581 parameters.add(fileParameter); 545 582 parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET))); -
branches/filedb/src/test/TestArrayDesign.java
r3797 r3804 43 43 import net.sf.basedb.core.ReporterBatcher; 44 44 import net.sf.basedb.core.ItemResultList; 45 import net.sf.basedb.core.SystemItems;46 45 import net.sf.basedb.core.Well; 47 46 import net.sf.basedb.core.data.FeatureData; … … 105 104 // Array designs with data in files 106 105 int cdfId = TestFile.test_create("data/test.affymetrix.cdf", false, false); 107 test_set_file(id3, "affymetrix.cdf", cdfId);106 test_set_file(id3, DataFileType.AFFYMETRIX_CDF, cdfId); 108 107 test_list_files(id3, 1); 109 108 … … 119 118 TestPlateType.test_delete(plateType); 120 119 TestPlateGeometry.test_delete(plateGeometry); 121 120 TestFile.test_delete(cdfId); 122 121 TestReporter.test_delete(); 123 122 … … 604 603 dc = TestUtil.getDbControl(); 605 604 ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId); 606 DataFileType type = DataFileType.getBy Id(dc, SystemItems.getId(fileType));605 DataFileType type = DataFileType.getByExternalId(dc, fileType); 607 606 File file = File.getById(dc, fileId); 608 607 ad.getFileSet().setMember(file, type); 608 ad.getFileSet().validate(dc, true); 609 609 dc.commit(); 610 610 write("--Set file OK ("+fileType+")"); -
branches/filedb/www/common/datafiles/list_files.jsp
r3802 r3804 184 184 { 185 185 FileSetMember member = entry.getValue(); 186 DataFileType dft = entry.getKey(); 186 187 Boolean validFile = null; 187 188 String validationMessage = ""; … … 189 190 File file = null; 190 191 boolean readDataFileType = true; 191 DataFileType dft = null;192 192 if (member != null) 193 193 {
Note: See TracChangeset
for help on using the changeset viewer.