Changeset 3820
- Timestamp:
- Oct 12, 2007, 12:03:18 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 73 edited
- 51 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/dist/raw-data-types.xml
r3675 r3820 649 649 </intensity-formula> 650 650 </raw-data-type> 651 652 <raw-data-type 653 id="affymetrix" 654 channels="1" 655 name="Affymetrix" 656 storage="file" 657 > 658 </raw-data-type> 659 651 660 652 <raw-data-type 661 653 id="agilent" -
trunk/src/clients/migrate/net/sf/basedb/clients/migrate/ArrayTypeTransfer.java
r3683 r3820 31 31 import net.sf.basedb.core.CommonItem; 32 32 import net.sf.basedb.core.DbControl; 33 import net.sf.basedb.core.Platform; 34 33 35 import java.sql.PreparedStatement; 34 36 import java.sql.ResultSet; … … 61 63 */ 62 64 private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("net.sf.basedb.clients.migrate.ArrayTypeTransfer"); 65 66 private Platform generic = null; 63 67 64 68 /** … … 99 103 { 100 104 DbControl dc = newDbControl(); 101 boolean isAffyChip = false;102 ArrayDesign arrayDesign = ArrayDesign.getNew(dc, isAffyChip);105 if (generic == null) generic = Platform.getByExternalId(dc, Platform.GENERIC); 106 ArrayDesign arrayDesign = ArrayDesign.getNew(dc, generic); 103 107 setCommonItemData(dc, (CommonItem) arrayDesign, rs); 104 108 dc.saveItem(arrayDesign); -
trunk/src/clients/migrate/net/sf/basedb/clients/migrate/RawBioAssayDataTransfer.java
r3725 r3820 136 136 { 137 137 log.info("Skipping since it already has data"); 138 progress.increase(rawBioAssay.get Spots());138 progress.increase(rawBioAssay.getNumDbSpots()); 139 139 } 140 140 progress.decrease(); // We do not want to count the RawBioAssays -
trunk/src/clients/migrate/net/sf/basedb/clients/migrate/RawBioAssayTransfer.java
r3725 r3820 30 30 import net.sf.basedb.core.BaseException; 31 31 import net.sf.basedb.core.DbControl; 32 import net.sf.basedb.core.Platform; 32 33 import net.sf.basedb.core.RawBioAssay; 33 34 import net.sf.basedb.core.RawDataTypes; … … 62 63 private SoftwareTransfer softwareT = null; 63 64 private SampleTransfer sampleT = null; 65 private Platform generic = null; 64 66 65 67 RawBioAssayTransfer() … … 122 124 { 123 125 if (log.isDebugEnabled()) log.debug("transfer RawBioAssay with id:" + rs.getInt(1) + " from BASE1"); 126 if (generic == null) generic = Platform.getByExternalId(dc, Platform.GENERIC); 124 127 RawBioAssay rawBioAssay = RawBioAssay.getNew( 125 dc, RawDataTypes.getRawDataType("genepix"));128 dc, generic, RawDataTypes.getRawDataType("genepix")); 126 129 setCommonItemData(dc, rawBioAssay, rs); 127 130 // File file = uploadFT.getRawBioAssayFileById(dc, rs.getInt(1)); -
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r3775 r3820 27 27 28 28 import net.sf.basedb.core.Coloring; 29 import net.sf.basedb.core.DataFileType; 29 30 import net.sf.basedb.core.DateUtil; 30 31 import net.sf.basedb.core.File; 32 import net.sf.basedb.core.FileSet; 33 import net.sf.basedb.core.FileStoreEnabled; 31 34 import net.sf.basedb.core.Location; 35 import net.sf.basedb.core.Path; 36 import net.sf.basedb.core.Platform; 37 import net.sf.basedb.core.PlatformVariant; 32 38 import net.sf.basedb.core.Protocol; 33 39 import net.sf.basedb.core.SessionControl; … … 826 832 } 827 833 834 /** 835 Get a query that returns all data file types for a specific 836 platform/variant that can be used on a given item type. 837 @param itemType The item type 838 @param platform The platform to get file types for, or null 839 @param variant The platform variant to get file types for, or null 840 @return An <code>ItemQuery</code> object 841 @since 2.5 842 */ 843 public static ItemQuery<DataFileType> getDataFileTypes(Item itemType, Platform platform, PlatformVariant variant) 844 { 845 ItemQuery<DataFileType> q = DataFileType.getQuery(); 846 q.restrict( 847 Restrictions.eq( 848 Hql.property("itemType"), 849 Expressions.integer(itemType.getValue()) 850 ) 851 ); 852 if (platform != null) 853 { 854 q.join(Hql.innerJoin("platforms", "pft")); 855 q.restrict(Restrictions.eq(Hql.property("pft", "platform"), Hql.entity(platform))); 856 if (variant != null) 857 { 858 q.restrict(Restrictions.or( 859 Restrictions.eq(Hql.property("pft", "variant"), null), 860 Restrictions.eq(Hql.property("pft", "variant"), Hql.entity(variant)) 861 )); 862 } 863 else 864 { 865 q.restrict(Restrictions.eq(Hql.property("pft", "variant"), null)); 866 } 867 } 868 q.order(Orders.asc(Hql.property("name"))); 869 q.setCacheResult(true); 870 return q; 871 } 872 828 873 private static final Float defaultScale = 1.0f; 829 874 /** … … 1066 1111 1067 1112 /** 1113 Update files that are associated with a {@link FileStoreEnabled} 1114 item. The <code>request</code> parameter is checked for parameters 1115 with a name like <code>datafile.id</code> where <code>id</code> is 1116 the numeric id of a {@link DataFileType}. The parameter value is the 1117 path of the file to associated with the data file type, or null 1118 to remove an existing association. 1119 1120 @param dc A DbControl to access the database 1121 @param item The item the files should be associated with 1122 @param request The request object containing the selected files 1123 @param validate If {@link FileSet#validate(DbControl, boolean)} 1124 should be called or not 1125 @param extractMetadata If meta data should be extracted or not 1126 (requires that validate is true) 1127 @since 2.5 1128 */ 1129 @SuppressWarnings("unchecked") 1130 public static void updateFiles(DbControl dc, FileStoreEnabled item, 1131 HttpServletRequest request, boolean validate, boolean extractMetadata, 1132 ItemContext cc, int maxRecent) 1133 { 1134 Enumeration<String> names = (Enumeration<String>)request.getParameterNames(); 1135 FileSet fileSet = null; 1136 while (names.hasMoreElements()) 1137 { 1138 String param = names.nextElement(); 1139 if (param.startsWith("datafile.")) 1140 { 1141 int dataFileTypeId = Values.getInt(param.substring(9)); 1142 DataFileType dft = DataFileType.getById(dc, dataFileTypeId); 1143 String filePath = Values.getStringOrNull(request.getParameter(param)); 1144 if (fileSet == null) fileSet = item.getFileSet(); 1145 if (filePath == null) 1146 { 1147 fileSet.removeMember(dft); 1148 } 1149 else 1150 { 1151 File file = File.getByPath(dc, new Path(filePath, Path.Type.FILE), false); 1152 fileSet.setMember(file, dft); 1153 if (cc != null) 1154 { 1155 cc.setRecent(file, dft.getExternalId(), maxRecent); 1156 } 1157 } 1158 } 1159 } 1160 if (validate) 1161 { 1162 fileSet.validate(dc, extractMetadata); 1163 } 1164 } 1165 1166 /** 1068 1167 @see #getEncodedName(Nameable, boolean, String) 1069 1168 */ -
trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java
r3679 r3820 145 145 Item.BIOASSAYSET, Item.BIOASSAY, Item.TRANSFORMATION, Item.EXTRAVALUE, 146 146 Item.VIRTUALDB, Item.DATACUBE, Item.DATACUBELAYER, Item.DATACUBECOLUMN, Item.DATACUBEFILTER, 147 Item.DATACUBEEXTRAVALUE 147 Item.DATACUBEEXTRAVALUE, 148 Item.FILESET, Item.FILESETMEMBER, 149 Item.PLATFORMVARIANT, Item.PLATFORMFILETYPE 148 150 ); 149 151 … … 169 171 Item.PROTOCOL, Item.PROTOCOLTYPE, Item.HARDWARE, Item.HARDWARETYPE, Item.SOFTWARE, Item.SOFTWARETYPE, 170 172 Item.ANNOTATIONTYPE, Item.ANNOTATIONTYPECATEGORY, Item.FILETYPE, Item.MIMETYPE, Item.REPORTER, 171 Item.REPORTERLIST, Item.REPORTERTYPE, Item.EXTRAVALUETYPE 173 Item.REPORTERLIST, Item.REPORTERTYPE, Item.EXTRAVALUETYPE, 174 Item.PLATFORM, Item.DATAFILETYPE 172 175 }) 173 176 ); -
trunk/src/core/common-queries.xml
r3741 r3820 2715 2715 </query> 2716 2716 2717 <query id="UPDATE_PROPERTY_FILTER_VALUE" type="SQL"> 2718 <sql> 2719 UPDATE [PropertyFilters] 2720 SET [value] = :newValue 2721 WHERE [property] = :property AND [value] = :oldValue 2722 </sql> 2723 <description> 2724 An SQL query that changes the property for all PropertyFilters 2725 with a given value. 2726 </description> 2727 </query> 2728 2717 2729 <query id="SET_AUTOCOMPRESS_ON_MIMETYPES" type="HQL"> 2718 2730 <sql> … … 2756 2768 <sql> 2757 2769 UPDATE ArrayDesignData ad 2758 SET ad.num Features = 02759 WHERE ad.num Features IS NULL2760 </sql> 2761 <description> 2762 A HQL query that sets the number of f eatures to 02770 SET ad.numDbFeatures = 0, ad.numFileFeatures = 0 2771 WHERE ad.numDbFeatures IS NULL OR ad.numFileFeatures IS NULL 2772 </sql> 2773 <description> 2774 A HQL query that sets the number of file and db features to 0 2763 2775 on all array designs with a null value. 2764 2776 </description> 2765 2777 </query> 2778 2779 <query id="SET_NUMFILESPOTS_ON_RAWBIOASSAY" type="HQL"> 2780 <sql> 2781 UPDATE RawBioAssayData rbd 2782 SET rbd.numFileSpots = 0 2783 WHERE rbd.numFileSpots IS NULL 2784 </sql> 2785 <description> 2786 A HQL query that sets the number of file aspots to 0 2787 on all raw bioassays with a null value. 2788 </description> 2789 </query> 2790 2791 <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL"> 2792 <sql> 2793 SELECT {1} 2794 FROM RawBioAssayData rba 2795 WHERE rba.platform = :platform 2796 </sql> 2797 <description> 2798 A Hibernate query that gets raw bioassays 2799 with a given platform. 2800 </description> 2801 </query> 2802 2803 <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL"> 2804 <sql> 2805 SELECT {1} 2806 FROM ArrayDesignData ad 2807 WHERE ad.platform = :platform 2808 </sql> 2809 <description> 2810 A Hibernate query that gets array designs 2811 with a given platform. 2812 </description> 2813 </query> 2814 2815 <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL"> 2816 <sql> 2817 SELECT {1} 2818 FROM RawBioAssayData rba 2819 WHERE rba.variant = :variant 2820 </sql> 2821 <description> 2822 A Hibernate query that gets raw bioassays 2823 with a given platform variant. 2824 </description> 2825 </query> 2826 2827 <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL"> 2828 <sql> 2829 SELECT {1} 2830 FROM ArrayDesignData ad 2831 WHERE ad.variant = :variant 2832 </sql> 2833 <description> 2834 A Hibernate query that gets array designs 2835 with a given platform variant. 2836 </description> 2837 </query> 2838 2839 <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL"> 2840 <sql> 2841 SELECT plf 2842 FROM PlatformData plf 2843 WHERE plf.externalId = :externalId 2844 </sql> 2845 <description> 2846 A Hibernate query that loads a platform by external ID. 2847 </description> 2848 </query> 2849 2850 <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL"> 2851 <sql> 2852 SELECT plv 2853 FROM PlatformVariantData plv 2854 WHERE plv.externalId = :externalId 2855 </sql> 2856 <description> 2857 A Hibernate query that loads a platform variant by external ID. 2858 </description> 2859 </query> 2860 2861 <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL"> 2862 <sql> 2863 SELECT dft 2864 FROM DataFileTypeData dft 2865 WHERE dft.externalId = :externalId 2866 </sql> 2867 <description> 2868 A Hibernate query that loads a data file type by external ID. 2869 </description> 2870 </query> 2871 2872 <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL"> 2873 <sql> 2874 SELECT {1} 2875 FROM FileSetMemberData mbr 2876 WHERE mbr.dataFileType = :dataFileType 2877 </sql> 2878 <description> 2879 A Hibernate query that gets file set members of a specific 2880 data file type. 2881 </description> 2882 </query> 2883 2884 <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL"> 2885 <sql> 2886 SELECT {1} 2887 FROM PlatformFileTypeData pft 2888 WHERE pft.dataFileType = :dataFileType 2889 </sql> 2890 <description> 2891 A Hibernate query that gets platform file types of a specific 2892 data file type. 2893 </description> 2894 </query> 2895 2896 <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL"> 2897 <sql> 2898 SELECT mbr 2899 FROM FileSetMemberData mbr 2900 WHERE mbr.dataFileType.externalId = :externalId 2901 AND mbr.fileSet = :fileSet 2902 </sql> 2903 <description> 2904 A Hibernate query that loads a member in a given file set 2905 if we know the external ID of the data file type. 2906 </description> 2907 </query> 2908 2909 2910 <query id="DELETE_PROPERTY_FILTER" type="SQL"> 2911 <sql> 2912 DELETE FROM [PropertyFilters] 2913 WHERE [property] = :property 2914 </sql> 2915 <description> 2916 An SQL query that delete all PropertyFilters 2917 which filter on a given property. 2918 </description> 2919 </query> 2920 2921 <query id="GET_PLUGINS_WITH_KEYS" type="HQL"> 2922 <sql> 2923 SELECT DISTINCT pk.pluginDefinitionId 2924 FROM PluginKeys pk WHERE pk.keyId IN (:keys) 2925 </sql> 2926 <description> 2927 A HQL query that has been granted a specific permission. Used by 2928 update scripts when new item types are added to make sure existing 2929 plug-ins can continue to work. 2930 </description> 2931 </query> 2932 2933 <query id="CHANGE_EXPERIMENT_RAWDATATYPE" type="HQL"> 2934 <sql> 2935 UPDATE ExperimentData 2936 SET rawDataType = :newRawDataType 2937 WHERE rawDataType = :oldRawDataType 2938 </sql> 2939 <description> 2940 A HQL query that changes all raw data type for experiments from 2941 an old value to a new value. 2942 </description> 2943 </query> 2944 2766 2945 2767 2946 </predefined-queries> -
trunk/src/core/net/sf/basedb/core/Affymetrix.java
r3741 r3820 26 26 27 27 import net.sf.basedb.core.data.ReporterData; 28 import net.sf.basedb.core.filehandler.CdfFileHandler; 29 import net.sf.basedb.core.filehandler.CelFileHandler; 28 30 import affymetrix.fusion.cdf.FusionCDFData; 29 31 import affymetrix.fusion.cel.FusionCELData; … … 44 46 The name of the {@link AnyToAny} link between an array design 45 47 and a file that contains the CDF information. 48 @deprecated See {@link DataFileType#AFFYMETRIX_CDF} 46 49 */ 47 50 public static final String CDF_LINK_NAME = "cdf-file"; … … 50 53 The name of the {@link AnyToAny} link between a raw bioassay 51 54 and a file that contains the CEL information. 55 @deprecated See {@link DataFileType#AFFYMETRIX_CEL} 52 56 */ 53 57 public static final String CEL_LINK_NAME = "cel-file"; … … 56 60 The name of the {@link AnyToAny} link between a raw bioassay 57 61 and a file that contains the CHP information. 62 @deprecated See {@link DataFileType} 58 63 */ 59 64 public static final String CHP_LINK_NAME = "chp-file"; … … 75 80 Affymetrix chip or if the file is not a CDF file 76 81 @throws BaseException If there is another error 82 @deprecated Use {@link FileStoreUtil#setDataFile(DbControl, FileStoreEnabled, String, File)} 83 instead with {@link DataFileType#AFFYMETRIX_CDF} as the file 84 type 77 85 */ 78 86 public static void setCdfFile(ArrayDesign design, File file) … … 80 88 { 81 89 if (design == null) throw new InvalidUseOfNullException("design"); 82 if (!design.is AffyChip())90 if (!design.isPlatform(Platform.AFFYMETRIX)) 83 91 { 84 92 throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design); 85 93 } 86 design.checkPermission(Permission.WRITE);87 94 DbControl dc = design.getDbControl(); 88 if (file != null) 89 { 90 file.checkPermission(Permission.USE); 91 92 // Verify that the file is a CDF file 93 FusionCDFData cdf = loadCdfFile(file); 94 95 AnyToAny ata = AnyToAny.getNewOrExisting(dc, design, CDF_LINK_NAME, file, true); 96 if (!ata.isInDatabase()) dc.saveItem(ata); 97 design.getData().setHasFeatures(true); 98 design.getData().setNumFeatures(cdf.getHeader().getNumProbeSets()); 99 } 100 else 101 { 102 AnyToAny.unlinkFrom(dc, design, CDF_LINK_NAME); 103 design.getData().setHasFeatures(false); 104 } 95 FileStoreUtil.setDataFile(dc, design, DataFileType.AFFYMETRIX_CDF, file); 96 if (file != null) design.getFileSet().validate(dc, true); 105 97 } 106 98 107 99 /** 108 100 Get the file that has been specified as the CDF file for an 109 array design. 101 array design. This method has been deprecated with the 102 implementation of the {@link Platform} and {@link DataFileType} 103 which solves the problem in a more generic way. 104 <p> 105 This method is equivalent to: 106 <pre class="code"> 107 DataFileType cdfType = 108 DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CDF); 109 File cdfFile = design.getFileSet().getMember(cdfType.getFile()); 110 </pre> 110 111 111 112 @param design The design to get the CDF file from, it must … … 117 118 Affymetrix chip 118 119 @throws BaseException If there is another error 120 @deprecated Use {@link FileStoreUtil#getDataFile(DbControl, FileStoreEnabled, String)} 121 with a data file type of {@link DataFileType#AFFYMETRIX_CDF} 122 instead 119 123 */ 120 124 public static File getCdfFile(ArrayDesign design) … … 122 126 { 123 127 if (design == null) throw new InvalidUseOfNullException("design"); 124 if (!design.is AffyChip())125 { 126 throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design );128 if (!design.isPlatform(Platform.AFFYMETRIX)) 129 { 130 throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design.getName()); 127 131 } 128 132 DbControl dc = design.getDbControl(); 129 File cdfFile = null; 130 try 131 { 132 AnyToAny ata = AnyToAny.getByName(dc, design, CDF_LINK_NAME); 133 if (ata.getToType() == Item.FILE) 134 { 135 cdfFile = (File)ata.getTo(); 136 } 137 } 138 catch (ItemNotFoundException ex) 139 {} 140 return cdfFile; 133 return FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF); 141 134 } 142 135 … … 170 163 raw data type 171 164 @throws BaseException If there is another error 165 @deprecated Use {@link FileStoreUtil#setDataFile(DbControl, FileStoreEnabled, String, File)} 166 instead with {@link DataFileType#AFFYMETRIX_CEL} as the file 167 type 172 168 */ 173 169 public static void setCelFile(RawBioAssay rawBioAssay, File file) 174 170 throws PermissionDeniedException, InvalidDataException, BaseException 175 171 { 176 // Validate raw bioassay177 172 if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay"); 178 if (!rawBioAssay.getRawDataType().isAffymetrix())179 {180 throw new InvalidDataException("Raw data type for " + rawBioAssay.getName() +181 " is not an Affymetrix raw data type");182 }183 173 rawBioAssay.checkPermission(Permission.WRITE); 184 174 175 if (!rawBioAssay.isPlatform(Platform.AFFYMETRIX)) 176 { 177 throw new InvalidDataException("Raw bioassay isn't an Affymetrix chip: " + rawBioAssay.getName()); 178 } 185 179 DbControl dc = rawBioAssay.getDbControl(); 186 if (file != null) 187 { 188 // Validate array design 189 ArrayDesign design = rawBioAssay.getArrayDesign(); 190 if (design == null) 191 { 192 throw new InvalidDataException("Raw bioassay " + rawBioAssay.getName() + 193 " must have an array design to set CEL file"); 194 } 195 if (!design.isAffyChip()) 196 { 197 throw new InvalidDataException("The array design " + design.getName() + 198 " is not an Affymterix design"); 199 } 200 201 // Verify that CEL chip type match CDF type 202 FusionCELData cel = loadCelFile(file); 203 File cdfFile = getCdfFile(design); 204 FusionCDFData cdf = loadCdfFile(cdfFile); 205 validateCelAndCdf(cel, cdf, cdfFile.getName()); 206 207 file.checkPermission(Permission.USE); 208 AnyToAny ata = AnyToAny.getNewOrExisting(dc, rawBioAssay, CEL_LINK_NAME, file, true); 209 if (!ata.isInDatabase()) dc.saveItem(ata); 210 211 // Set headers 212 setHeader(rawBioAssay, "Algorithm", cel.getAlg()); 213 for (int i = 0; i < cel.getNumberAlgorithmParameters(); ++i) 214 { 215 String name = cel.getAlgorithmParameterTag(i); 216 setHeader(rawBioAssay, "Algorithm parameter: " + name, cel.getAlgorithmParameter(name)); 217 } 218 setHeader(rawBioAssay, "Dat header", cel.getDatHeader()); 219 setHeader(rawBioAssay, "Chip type", cel.getChipType()); 220 221 // Set number of spots 222 rawBioAssay.getData().setHasData(true); 223 rawBioAssay.getData().setSpots(cel.getCells()); 224 225 } 226 else 227 { 228 AnyToAny.unlinkFrom(dc, rawBioAssay, CEL_LINK_NAME); 229 rawBioAssay.getData().setHasData(false); 230 rawBioAssay.getData().setSpots(0); 231 } 232 } 233 234 private static void setHeader(RawBioAssay rba, String name, String value) 235 { 236 if (name == null || value == null) return; 237 rba.setHeader(name, value); 180 FileStoreUtil.setDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL, file); 181 if (file != null) rawBioAssay.getFileSet().validate(dc, true); 238 182 } 239 183 … … 250 194 Affymetrix raw data type 251 195 @throws BaseException If there is another error 196 @deprecated 252 197 */ 253 198 public static File getCelFile(RawBioAssay rawBioAssay) … … 255 200 { 256 201 if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay"); 257 if (!rawBioAssay. getRawDataType().isAffymetrix())202 if (!rawBioAssay.isPlatform(Platform.AFFYMETRIX)) 258 203 { 259 204 throw new InvalidDataException("Raw data type for " + rawBioAssay.getName() + 260 " is not an Affymetrix raw data type");205 " is not an Affymetrix raw data type"); 261 206 } 262 207 DbControl dc = rawBioAssay.getDbControl(); 263 File celFile = null; 264 try 265 { 266 AnyToAny ata = AnyToAny.getByName(dc, rawBioAssay, CEL_LINK_NAME); 267 if (ata.getToType() == Item.FILE) 268 { 269 celFile = (File)ata.getTo(); 270 } 271 } 272 catch (ItemNotFoundException ex) 273 {} 274 return celFile; 208 return FileStoreUtil.getDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL); 275 209 } 276 210 … … 289 223 public static void validateCelAndCdf(RawBioAssay rawBioAssay, ArrayDesign design, boolean required) 290 224 { 291 File celFile = getCelFile(rawBioAssay); 292 File cdfFile = getCdfFile(design); 225 DbControl dc = rawBioAssay.getDbControl(); 226 File celFile = FileStoreUtil.getDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL);; 227 File cdfFile = FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF); 293 228 if (celFile != null && cdfFile != null) 294 229 { 295 230 String cdfChipType = cdfFile.getName(); 296 FusionCELData cel = loadCelFile(celFile);297 FusionCDFData cdf = loadCdfFile(cdfFile);231 FusionCELData cel = new CelFileHandler().loadCelFile(celFile); 232 FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile); 298 233 validateCelAndCdf(cel, cdf, cdfChipType); 299 234 } … … 338 273 @throws InvalidDataException If the file is not a CDF file 339 274 @since 2.4 275 @deprecated Use {@link CdfFileHandler#loadCdfFile(File)} instead 340 276 */ 341 277 public static FusionCDFData loadCdfFile(File cdfFile) 342 278 throws ItemNotFoundException, InvalidDataException 343 279 { 344 if (cdfFile == null) throw new InvalidUseOfNullException("cdfFile"); 345 if (cdfFile.getLocation() != Location.PRIMARY) 346 { 347 throw new ItemNotFoundException("File data is not online for file '" + 348 cdfFile.getName() + "'; location=" + cdfFile.getLocation()); 349 } 350 FusionCDFData cdf = new FusionCDFData(); 351 cdf.setFileName(cdfFile.getName()); 352 cdf.setInputStream(cdfFile.getDownloadStream(0)); 353 if (!cdf.readHeader()) 354 { 355 throw new InvalidDataException("Could not read CDF file '" + 356 cdfFile.getPath()+"': " + cdf.getError()); 357 } 358 return cdf; 280 return new CdfFileHandler().loadCdfFile(cdfFile); 359 281 } 360 282 … … 368 290 @throws InvalidDataException If the file is not a CEL file 369 291 @since 2.4 292 @deprecated Use {@link CdfFileHandler#loadCdfFile(File)} instead 370 293 */ 371 294 public static FusionCELData loadCelFile(File celFile) 372 295 throws InvalidDataException 373 296 { 374 if (celFile == null) throw new InvalidUseOfNullException("celFile"); 375 if (celFile.getLocation() != Location.PRIMARY) 376 { 377 throw new ItemNotFoundException("File data is not online for file '" + 378 celFile.getName() + "'; location=" + celFile.getLocation()); 379 } 380 FusionCELData cel = new FusionCELData(); 381 cel.setFileName(celFile.getName()); 382 cel.setInputStream(celFile.getDownloadStream(0)); 383 if (!cel.readHeader()) 384 { 385 throw new InvalidDataException("Could not read CEL file '" + 386 celFile.getPath()+"': " + cel.getError()); 387 } 388 return cel; 297 return new CelFileHandler().loadCelFile(celFile); 389 298 } 390 299 -
trunk/src/core/net/sf/basedb/core/Application.java
r3765 r3820 468 468 Keyring.init(); 469 469 HibernateUtil.testTransactions(); 470 RawDataTypes.initPlatforms(); 470 471 471 472 // Adding a task that cleans the session control cache at regular intervale -
trunk/src/core/net/sf/basedb/core/ArrayDesign.java
r3741 r3820 32 32 import net.sf.basedb.core.query.Restrictions; 33 33 34 import java.util.Collection; 34 35 import java.util.HashMap; 35 36 import java.util.HashSet; … … 59 60 public class ArrayDesign 60 61 extends AnnotatedItem<ArrayDesignData> 62 implements FileStoreEnabled 61 63 { 62 64 … … 78 80 @return The new <code>ArrayDesign</code> item 79 81 @throws BaseException If there is an error 82 @deprecated Use {@link #getNew(DbControl, Platform)} instead 80 83 */ 81 84 public static ArrayDesign getNew(DbControl dc, boolean affyChip) 82 85 throws BaseException 83 86 { 87 Platform platform = Platform.getByExternalId(dc, 88 affyChip ? Platform.AFFYMETRIX : Platform.GENERIC); 89 return getNew(dc, platform); 90 } 91 92 /** 93 Create a new <code>ArrayDesign</code> item for a given platform. 94 95 @param dc The <code>DbControl</code> which will be used for 96 permission checking and database access 97 @param platform The platform of the array design 98 @return The new <code>ArrayDesign</code> item 99 @throws BaseException If there is an error 100 @since 2.5 101 */ 102 public static ArrayDesign getNew(DbControl dc, Platform platform) 103 { 84 104 ArrayDesign ad = dc.newItem(ArrayDesign.class); 85 105 ad.setName("New array design"); 86 ad. getData().setAffyChip(affyChip);106 ad.setPlatform(platform); 87 107 return ad; 88 108 } 89 109 110 /** 111 Create a new <code>ArrayDesign</code> item for a given platform 112 variant. 113 114 @param dc The <code>DbControl</code> which will be used for 115 permission checking and database access 116 @param variant The platform variant of the array design 117 @return The new <code>ArrayDesign</code> item 118 @throws BaseException If there is an error 119 @since 2.5 120 */ 121 public static ArrayDesign getNew(DbControl dc, PlatformVariant variant) 122 { 123 ArrayDesign ad = dc.newItem(ArrayDesign.class); 124 ad.setName("New array design"); 125 ad.setVariant(variant); 126 return ad; 127 } 128 90 129 /** 91 130 Get an <code>ArrayDesign</code> item when you know the ID. … … 154 193 } 155 194 // ------------------------------------------- 156 195 /* 196 From the FileStoreEnabled interface 197 ------------------------------------------- 198 */ 199 /** 200 @since 2.5 201 */ 202 public FileSet getFileSet() 203 { 204 DbControl dc = getDbControl(); 205 FileSet fs = dc.getItem(FileSet.class, getData().getFileSet(), this); 206 if (fs == null) 207 { 208 fs = FileSet.getNew(dc, this); 209 getData().setFileSet(fs.getData()); 210 dc.saveItemIf(this, fs, false); 211 } 212 return fs; 213 } 214 /** 215 @since 2.5 216 */ 217 public boolean hasFileSet() 218 { 219 return getData().getFileSet() != null; 220 } 221 /** 222 @since 2.5 223 */ 224 public Platform getPlatform() 225 { 226 return getDbControl().getItem(Platform.class, getData().getPlatform()); 227 } 228 /** 229 @since 2.5 230 */ 231 public PlatformVariant getVariant() 232 { 233 return getDbControl().getItem(PlatformVariant.class, getData().getVariant()); 234 } 235 /** 236 There are no parent file sets. 237 @return Always null 238 @since 2.5 239 */ 240 public Collection<FileSet> getParentFileSets() 241 { 242 return null; 243 } 244 // ------------------------------------------- 157 245 /* 158 246 From the BasicItem class … … 228 316 229 317 /** 230 @return TRUE if this is an AffyChip, FALSE otherwise. 318 Set the platform of the array design. This method will set the variant 319 to null. Use {@link #setVariant(PlatformVariant)} if you want to 320 set a specific variant. 321 @param platform The new platform 322 @throws PermissionDeniedException If the logged in user doesn't have 323 write permission 324 @throws InvalidDataException If platform is null 325 @since 2.5 326 */ 327 @SuppressWarnings("deprecation") 328 public void setPlatform(Platform platform) 329 { 330 checkPermission(Permission.WRITE); 331 if (platform == null) throw new InvalidUseOfNullException("platform"); 332 getData().setPlatform(platform.getData()); 333 getData().setVariant(null); 334 getData().setAffyChip(isPlatform(Platform.AFFYMETRIX)); 335 } 336 337 /** 338 Set the platform and variant of the array design. This method will 339 automatically set the platform to {@link PlatformVariant#getPlatform()}. 340 341 @param variant The new platform variant, or null to remove 342 the variant and keep the platform as it is 343 @throws PermissionDeniedException If the logged in user doesn't have 344 write permission 345 @since 2.5 346 */ 347 @SuppressWarnings("deprecation") 348 public void setVariant(PlatformVariant variant) 349 { 350 checkPermission(Permission.WRITE); 351 if (variant != null) 352 { 353 getData().setVariant(variant.getData()); 354 getData().setPlatform(variant.getData().getPlatform()); 355 } 356 else 357 { 358 getData().setVariant(null); 359 } 360 getData().setAffyChip(isPlatform(Platform.AFFYMETRIX)); 361 } 362 363 /** 364 Check if the platform/variant of this array design has the 365 given external ID. 366 @param externalId The external ID to match 367 @return TRUE if either the variant of platform matches the 368 external ID 369 @since 2.5 370 */ 371 public boolean isPlatform(String externalId) 372 { 373 if (externalId == null) return false; 374 if (externalId.equals(getData().getPlatform().getExternalId())) return true; 375 if (getData().getVariant() != null) 376 { 377 if (externalId.equals(getData().getVariant().getExternalId())) return true; 378 } 379 return false; 380 } 381 382 /** 383 Check if this array design uses a file-only platform or variant. 384 If the array design has a platform variant, the setting from the 385 variant is returned, otherwise the setting from the platform. 386 @return TRUE if this array design use a file-only variant / platform 387 @since 2.5 388 */ 389 public boolean isFileOnlyPlatform() 390 { 391 if (getData().getVariant() != null) 392 { 393 return getData().getVariant().isFileOnly(); 394 } 395 else 396 { 397 return getData().getPlatform().isFileOnly(); 398 } 399 } 400 401 /** 402 @return TRUE if this is an Affymetrix chip, FALSE otherwise. 403 @deprecated Use {@link #isPlatform(String)} instead with 404 {@link Platform#AFFYMETRIX} as the parameter 231 405 */ 232 406 public boolean isAffyChip() 233 407 { 234 return getData().isAffyChip(); 235 } 236 237 /** 408 return isPlatform(Platform.AFFYMETRIX); 409 } 410 411 /** 412 Check if this array design has information about features, either 413 in the database or in files. 238 414 @return TRUE if this object has features, FALSE otherwise 239 415 */ … … 421 597 that can add features to the new block. 422 598 <p> 423 It is not possible to add blocks to an Affymetrix chip. It stores 424 it's feature in a CDF file instead. See {@link Affymetrix#setCdfFile(ArrayDesign, File)}. 599 It is not possible to add blocks to an array design which uses a 600 file-only platform. The must store feature information in files 601 instead. See {@link Platform} and {@link DataFileType}. 425 602 426 603 @param bi The information for the new block … … 433 610 throws PermissionDeniedException, BaseException 434 611 { 612 if (getData().getPlatform().isFileOnly()) 613 { 614 throw new PermissionDeniedException("Can't add blocks to a file-only array design: " + this.getName()); 615 } 435 616 if (hasFeatures()) 436 617 { 437 throw new PermissionDeniedException("Can't add blocks to a design that already has features: " + this); 438 } 439 if (isAffyChip()) 440 { 441 throw new PermissionDeniedException("Can't add blocks to an Affymetrix chip: " + this); 618 throw new PermissionDeniedException("Can't add blocks to a design that already has features: " + this.getName()); 442 619 } 443 620 checkPermission(Permission.WRITE); … … 461 638 array design. 462 639 <p> 463 It is not possible to add features to an Affymetrix chip. It stores 464 it's feature in a CDF file instead. See {@link Affymetrix#setCdfFile(ArrayDesign, File)}. 640 It is not possible to add blocks to an array design which uses a 641 file-only platform. The must store feature information in files 642 instead. See {@link Platform} and {@link DataFileType}. 465 643 466 644 @throws PermissionDeniedException If raw data has already been added … … 472 650 { 473 651 checkPermission(Permission.WRITE); 652 if (isFileOnlyPlatform()) 653 { 654 throw new PermissionDeniedException("Can't add features to a file-only array design: " + this.getName()); 655 } 474 656 if (hasFeatures()) 475 657 { 476 throw new PermissionDeniedException("Features has already been added to "+this); 477 } 478 if (isAffyChip()) 479 { 480 throw new PermissionDeniedException("Can't add features to an Affymetrix chip: " + this); 658 throw new PermissionDeniedException("Features has already been added to "+this.getName()); 481 659 } 482 660 if (featureBatcher == null) … … 528 706 /** 529 707 Get the number of features added to this array design. If the 530 array design is an Affymetrix design information in the CDF file is531 used, otherwise the database is queried.708 array design has features in the database the value from {@link #getNumDbFeatures()} 709 is returned, otherwise the value from {@link #getNumFileFeatures()} 532 710 @return The number of features or probesets 533 711 @since 2.4 534 @deprecated Use {@link #getNumFeatures()} instead 712 @deprecated Use {@link #getNumDbFeatures()} and/or {@link #getNumFileFeatures()} 713 instead 535 714 */ 536 715 public long getNumFeatures(DbControl dc) 537 716 { 538 return getNumFeatures();539 }540 541 /**542 Get the number of features on this array design. Depending on the543 type of array design, this may or may not correspond to the number544 of featuresin the database.717 int dbFeatures = getNumDbFeatures(); 718 return dbFeatures > 0 ? dbFeatures : getNumFileFeatures(); 719 } 720 721 /** 722 Get the number of features on this array design that are 723 stored in the database. 545 724 @return The number of features or probesets 546 725 @since 2.5 547 726 */ 548 public int getNumFeatures() 549 { 550 return getData().getNumFeatures(); 727 public int getNumDbFeatures() 728 { 729 return getData().getNumDbFeatures(); 730 } 731 732 /** 733 Get the number of features on this array design that are 734 stored inside files. 735 @return The number of features or probesets 736 @since 2.5 737 */ 738 public int getNumFileFeatures() 739 { 740 return getData().getNumFileFeatures(); 741 } 742 743 /** 744 Set the number of features that are stored in files. 745 @param numFeatures The number of features 746 @since 2.5 747 */ 748 public void setNumFileFeatures(int numFeatures) 749 { 750 checkPermission(Permission.WRITE); 751 getData().setNumFileFeatures(numFeatures); 752 getData().setHasFeatures(numFeatures > 0 || getNumDbFeatures() > 0); 551 753 } 552 754 -
trunk/src/core/net/sf/basedb/core/Experiment.java
r3679 r3820 545 545 for the raw bioassay 546 546 @throws InvalidDataException If the rawBioAssay is null, 547 doesn't have and data,or has a different raw data type547 or has a different raw data type 548 548 */ 549 549 public void addRawBioAssay(RawBioAssay rawBioAssay) … … 553 553 if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay"); 554 554 rawBioAssay.checkPermission(Permission.USE); 555 if (!rawBioAssay.hasData())556 {557 throw new InvalidDataException("No raw data has been added to the raw bioassay: "+rawBioAssay);558 }559 555 String experimentDataType = getData().getRawDataType(); 560 556 String bioAssayDataType = rawBioAssay.getData().getRawDataType(); -
trunk/src/core/net/sf/basedb/core/FeatureBatcher.java
r3775 r3820 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 } -
trunk/src/core/net/sf/basedb/core/Install.java
r3784 r3820 28 28 import net.sf.basedb.core.data.ColoringData; 29 29 import net.sf.basedb.core.data.DirectoryData; 30 import net.sf.basedb.core.data.DataFileTypeData; 30 31 import net.sf.basedb.core.data.FileTypeData; 31 32 import net.sf.basedb.core.data.FormulaData; … … 33 34 import net.sf.basedb.core.data.HardwareTypeData; 34 35 import net.sf.basedb.core.data.MimeTypeData; 36 import net.sf.basedb.core.data.PlatformData; 37 import net.sf.basedb.core.data.PlatformFileTypeData; 35 38 import net.sf.basedb.core.data.PluginConfigurationData; 36 39 import net.sf.basedb.core.data.ProtocolTypeData; … … 104 107 method. 105 108 */ 106 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(4 3).intValue();109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(44).intValue(); 107 110 108 111 public static synchronized void createTables(boolean update, final ProgressReporter progress) … … 162 165 throws BaseException 163 166 { 164 final int total_progress_steps = 2 4;167 final int total_progress_steps = 26; 165 168 final float progress_factor = 100 / total_progress_steps; 166 169 if (progress != null) progress.display(0, "Initialising database..."); … … 323 326 createRoleKey(Item.SOFTWARETYPE, "Software types", "Gives access to software types", all_use_administrators_write); 324 327 createRoleKey(Item.SOFTWARE, "Software", "Gives access to software", power_users_create); 325 328 329 // Platforms, platform variants, platform file types 330 createRoleKey(Item.PLATFORM, "Platforms", "Gives access to platforms", guests_use_administrators_all); 331 createRoleKey(Item.DATAFILETYPE, "Data file types", "Gives access to data file types", guests_use_administrators_all); 332 326 333 // Annotations 327 334 createRoleKey(Item.ANNOTATIONTYPE, "Annotation types", "Gives access to annotation types", power_users_create); … … 667 674 if (progress != null) progress.display((int)(24*progress_factor), "--Creating job agents..."); 668 675 // TODO 676 677 // File set member types 678 if (progress != null) progress.display((int)(25*progress_factor), "--Creating data file types..."); 679 DataFileTypeData celFile = createDataFileType( 680 DataFileType.AFFYMETRIX_CEL, "CEL file", "Affymetrix CEL file", 681 Item.RAWBIOASSAY, "cel", rawDataType, 682 "net.sf.basedb.core.filehandler.CelFileHandler", 683 "net.sf.basedb.core.filehandler.CelFileHandler"); 684 DataFileTypeData cdfFile = createDataFileType( 685 DataFileType.AFFYMETRIX_CDF, "CDF file", "Affymetrix CDF file", 686 Item.ARRAYDESIGN, "cdf", reporterMapType, 687 "net.sf.basedb.core.filehandler.CdfFileHandler", 688 "net.sf.basedb.core.filehandler.CdfFileHandler"); 689 DataFileTypeData reporterMapFile = createDataFileType( 690 DataFileType.GENERIC_REPORTER_MAP, "Reporter map", 691 "Generic file that contains information about the reporters present on an array design", 692 Item.ARRAYDESIGN, null, reporterMapType, null, null); 693 DataFileTypeData printMapFile = createDataFileType( 694 DataFileType.GENERIC_PRINT_MAP, "Print map", 695 "Generic file that contains information about how the plates was printed on the array design", 696 Item.ARRAYDESIGN, null, printMapType, null, null); 697 DataFileTypeData rawDataFile = createDataFileType( 698 DataFileType.GENERIC_RAW_DATA, "Generic raw data", 699 "Generic file that contains the raw data of this raw bioassay", 700 Item.RAWBIOASSAY, null, rawDataType, null, null); 701 702 // Platforms and variants 703 if (progress != null) progress.display((int)(26*progress_factor), "--Creating platforms..."); 704 createPlatform("generic", "Generic", "Generic platform which expects data to be imported into the database", 705 false, null, 0, 706 new PlatformFT(reporterMapFile, false), 707 new PlatformFT(printMapFile, false), 708 new PlatformFT(rawDataFile, false) 709 ); 710 createPlatform("affymetrix", "Affymetrix", "Affymetrix platform", true, null, 1, 711 new PlatformFT(celFile, true), 712 new PlatformFT(cdfFile, true) 713 ); 669 714 670 715 if (progress != null) progress.display(100, "Database initialised successfully."); … … 2156 2201 } 2157 2202 return formula; 2203 } 2204 2205 /** 2206 Create a {@link Platform}. 2207 */ 2208 private static PlatformData createPlatform(String externalId, String name, String description, 2209 boolean fileOnly, String rawDataType, int channels, PlatformFT... fileTypes) 2210 throws BaseException 2211 { 2212 org.hibernate.Transaction tx = null; 2213 PlatformData platform = null; 2214 try 2215 { 2216 tx = HibernateUtil.newTransaction(session); 2217 2218 if (platform == null) 2219 { 2220 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 2221 "GET_PLATFORM_FOR_EXTERNAL_ID"); 2222 query.setString("externalId", externalId); 2223 platform = HibernateUtil.loadData(PlatformData.class, query); 2224 } 2225 2226 if (platform != null) 2227 { 2228 log.info("createPlatform: EXISTS [externalId="+externalId+"]"); 2229 HibernateUtil.commit(tx); 2230 } 2231 else 2232 { 2233 platform = new PlatformData(); 2234 platform.setExternalId(externalId); 2235 platform.setName(name); 2236 platform.setDescription(description); 2237 platform.setFileOnly(fileOnly); 2238 if (fileOnly) 2239 { 2240 platform.setChannels(channels); 2241 platform.setRawDataType("platform." + externalId); 2242 } 2243 else 2244 { 2245 platform.setRawDataType(rawDataType); 2246 } 2247 HibernateUtil.saveData(session, platform); 2248 2249 if (fileTypes != null) 2250 { 2251 for (PlatformFT pft : fileTypes) 2252 { 2253 PlatformFileTypeData platformFile = new PlatformFileTypeData(); 2254 platformFile.setPlatform(platform); 2255 platformFile.setDataFileType(pft.fileType); 2256 platformFile.setRequired(pft.required); 2257 HibernateUtil.saveData(session, platformFile); 2258 } 2259 } 2260 2261 HibernateUtil.commit(tx); 2262 log.info("createPlatform: OK [externalId="+externalId+"]"); 2263 } 2264 } 2265 catch (BaseException ex) 2266 { 2267 if(tx != null) HibernateUtil.rollback(tx); 2268 log.error("createPlatform: FAILED [externalId="+externalId+"]", ex); 2269 throw ex; 2270 } 2271 return platform; 2272 } 2273 2274 /** 2275 Create a {@link DataFileType}. 2276 */ 2277 private static DataFileTypeData createDataFileType( 2278 String externalId, String name, String description, 2279 Item itemType, String extension, FileTypeData genericType, 2280 String validatorClass, String metadataReaderClass) 2281 throws BaseException 2282 { 2283 org.hibernate.Transaction tx = null; 2284 DataFileTypeData fileType = null; 2285 try 2286 { 2287 tx = HibernateUtil.newTransaction(session); 2288 2289 if (fileType == null) 2290 { 2291 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 2292 "GET_DATAFILETYPE_FOR_EXTERNAL_ID"); 2293 query.setString("externalId", externalId); 2294 fileType = HibernateUtil.loadData(DataFileTypeData.class, query); 2295 } 2296 2297 if (fileType != null) 2298 { 2299 log.info("createDataFileType: EXISTS [externalId="+externalId+"]"); 2300 HibernateUtil.commit(tx); 2301 } 2302 else 2303 { 2304 fileType = new DataFileTypeData(); 2305 fileType.setExternalId(externalId); 2306 fileType.setName(name); 2307 fileType.setDescription(description); 2308 fileType.setItemType(itemType.getValue()); 2309 fileType.setExtension(extension); 2310 fileType.setGenericType(genericType); 2311 fileType.setValidatorClass(validatorClass); 2312 fileType.setMetadataReaderClass(metadataReaderClass); 2313 2314 HibernateUtil.saveData(session, fileType); 2315 HibernateUtil.commit(tx); 2316 log.info("createDataFileType: OK [externalId="+externalId+"]"); 2317 } 2318 } 2319 catch (BaseException ex) 2320 { 2321 if(tx != null) HibernateUtil.rollback(tx); 2322 log.error("createDataFileType: FAILED [externalId="+externalId+"]", ex); 2323 throw ex; 2324 } 2325 return fileType; 2158 2326 } 2327 2328 private static class PlatformFT 2329 { 2330 private final DataFileTypeData fileType; 2331 private final boolean required; 2332 2333 private PlatformFT(DataFileTypeData fileType, boolean required) 2334 { 2335 this.fileType = fileType; 2336 this.required = required; 2337 } 2338 } 2339 2159 2340 } -
trunk/src/core/net/sf/basedb/core/Item.java
r3679 r3820 496 496 */ 497 497 DATACUBEEXTRAVALUE(326, "Data cube extra value", "dev", DataCubeExtraValue.class, DataCubeExtraValueData.class, null, 498 250); 498 250), 499 500 /** 501 The item is a {@link Platform} 502 */ 503 PLATFORM(350, "Platform", "plf", Platform.class, PlatformData.class, DefinedPermissions.basic, 504 970), 505 506 /** 507 The item is a {@link PlatformVariant} 508 */ 509 PLATFORMVARIANT(351, "Platform variant", "plv", PlatformVariant.class, PlatformVariantData.class, null, 510 965), 511 512 /** 513 The item is a {@link PlatformFileType} 514 */ 515 PLATFORMFILETYPE(352, "Platform file type", "pft", PlatformFileType.class, PlatformFileTypeData.class, null, 516 960), 517 518 /** 519 The item is a {@link FileSet} 520 */ 521 FILESET(353, "File set", "fs", FileSet.class, FileSetData.class, null, 522 950), 523 524 /** 525 The item is a {@link FileSetMember} 526 */ 527 FILESETMEMBER(354, "File set member", "fsm", FileSetMember.class, FileSetMemberData.class, null, 528 955), 529 530 /** 531 The item is a {@link DataFileType} 532 */ 533 DATAFILETYPE(355, "Data file type", "dft", DataFileType.class, DataFileTypeData.class, DefinedPermissions.basic, 534 980) 535 536 ; 499 537 500 538 static int MAX_VALUE = 0; -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r3789 r3820 614 614 615 615 /** 616 Add an item to the "recently used items" list. Each type of item 617 has their own list and sublists which may contain at 618 most <code>maxInList</code> items. 619 <p> 620 Note! The lists are stored as string of colon-separated ID:s in 621 the setting given by the item type and sublist name. For example the 622 recently used protocols are found in the setting: 623 <code>getSetting("PROTOCOL.subList.recent")</code>. Client code is advised to 624 not change these settings. 625 626 @param item The item to add 627 @param subList The sublist 628 @param maxInList The maximum number of items in the list 629 @since 2.5 630 */ 631 public void setRecent(BasicItem item, String subList, int maxInList) 632 { 633 setRecent(item.getType().name() + "." + subList, Integer.toString(item.getId()), maxInList); 634 } 635 636 /** 616 637 Add a value to the list of recently used values for the specified key. 617 638 Each key has it's own list of values which may contain at most … … 649 670 650 671 /** 672 Get the number of recently used items in a list with a sublist. 673 @param itemType The type of items 674 @param subList The name of the sublist 675 @since 2.5 676 */ 677 public int getNumRecent(Item itemType, String subList) 678 { 679 return getRecent(itemType.name() + "." + subList).size(); 680 } 681 682 /** 651 683 Get the number of recently used value in the list. 652 684 @param key The key to the list … … 670 702 public List<? extends BasicItem> getRecent(DbControl dc, Item itemType) 671 703 { 672 List<String> recentIds = getRecent(itemType.name()); 704 return loadRecent(dc, itemType, itemType.name()); 705 } 706 707 /** 708 Get all recently used items of the specified type in a given sublist. 709 The list only contains items that the logged in user has read permission 710 to and that hasn't been deleted. Thus, the {@link #getNumRecent(Item)} 711 may return a larger number than what is actually returned in this 712 list. 713 714 @param dc The DbControl used to access the database 715 @param itemType The type of items 716 @param subList The name of the sublist 717 @return A list with the items 718 @since 2.5 719 */ 720 public List<? extends BasicItem> getRecent(DbControl dc, Item itemType, String subList) 721 { 722 return loadRecent(dc, itemType, itemType.name() + "." + subList); 723 } 724 725 private List<? extends BasicItem> loadRecent(DbControl dc, Item itemType, String key) 726 { 727 List<String> recentIds = getRecent(key); 673 728 List<BasicItem> recent = new ArrayList<BasicItem>(recentIds.size()); 674 729 for (String id : recentIds) … … 687 742 } 688 743 744 689 745 public BasicItem getRecent(DbControl dc, Item itemType, int index) 690 746 { 691 List<String> recentIds = getRecent(itemType.name()); 747 return loadRecent(dc, itemType, itemType.name(), index); 748 } 749 750 public BasicItem getRecent(DbControl dc, Item itemType, String subList, int index) 751 { 752 return loadRecent(dc, itemType, itemType.name() + "." + subList, index); 753 } 754 755 private BasicItem loadRecent(DbControl dc, Item itemType, String key, int index) 756 { 757 List<String> recentIds = getRecent(key); 692 758 BasicItem item = null; 693 759 if (index >= 0 && index < recentIds.size()) … … 707 773 return item; 708 774 } 775 709 776 710 777 /** … … 742 809 { 743 810 setRecent(itemType.name(), null); 811 } 812 813 /** 814 Clear the recently used items sublist from items of the specified type. 815 @param itemType The type of items 816 @param subList The name of the sublist 817 */ 818 public void clearRecent(Item itemType, String subList) 819 { 820 setRecent(itemType.name() + "." + subList, null); 744 821 } 745 822 -
trunk/src/core/net/sf/basedb/core/Metadata.java
r3679 r3820 54 54 private static Set<Item> ownableItems; 55 55 private static Set<Item> diskConsumableItems; 56 private static Set<Item> fileStoreEnabledItems; 56 57 57 58 private static boolean isInitialised = false; … … 65 66 ownableItems = Collections.unmodifiableSet(getImplementingItems(Ownable.class)); 66 67 diskConsumableItems = Collections.unmodifiableSet(getImplementingItems(DiskConsumable.class)); 68 fileStoreEnabledItems = Collections.unmodifiableSet(getImplementingItems(FileStoreEnabled.class)); 67 69 isInitialised = true; 68 70 } … … 79 81 ownableItems = null; 80 82 diskConsumableItems = null; 83 fileStoreEnabledItems = null; 81 84 } 82 85 … … 171 174 } 172 175 176 /** 177 Get a set containing all {@link FileStoreEnabled} item types. 178 The set cannot be modified. 179 */ 180 public static Set<Item> getFileStoreEnabledItems() 181 { 182 return fileStoreEnabledItems; 183 } 184 185 173 186 /** 174 187 Cache of Metadata instances. Only one instance for each type -
trunk/src/core/net/sf/basedb/core/PluginDefinition.java
r3679 r3820 976 976 if (unloadBefore) JarClassLoader.unload(jarPath); 977 977 ClassLoader cl = JarClassLoader.getInstance(jarPath, Application.autoUnloadPlugins()); 978 c = cl.loadClass(className); 979 } 980 if (!Plugin.class.isAssignableFrom(c)) 981 { 982 throw new InvalidDataException("Class does not implement net.sf.basedb.core.plugin.Plugin: "+className); 978 c = ClassUtil.checkAndLoadClass(cl, className, true, Plugin.class); 983 979 } 984 980 return (Plugin)c.newInstance(); -
trunk/src/core/net/sf/basedb/core/RawBioAssay.java
r3775 r3820 27 27 28 28 import net.sf.basedb.core.data.FeatureData; 29 import net.sf.basedb.core.data.PlatformData; 30 import net.sf.basedb.core.data.PlatformVariantData; 29 31 import net.sf.basedb.core.data.RawBioAssayData; 30 32 import net.sf.basedb.core.data.RawData; … … 37 39 import net.sf.basedb.core.query.Expressions; 38 40 41 import java.util.Collection; 39 42 import java.util.HashMap; 40 43 import java.util.Map; … … 62 65 public class RawBioAssay 63 66 extends AnnotatedItem<RawBioAssayData> 64 implements DiskConsumable 67 implements DiskConsumable, FileStoreEnabled 65 68 { 66 69 /** … … 88 91 89 92 /** 90 Create a new <code>RawBioAssay</code> item. 93 Create a new <code>RawBioAssay</code> item. The platform/variant will 94 automatically be set to the values returned by {@link RawDataType#getPlatform(DbControl)} 95 and {@link RawDataType#getVariant(DbControl)}. If both return null 96 the {@link Platform#GENERIC} is used. 91 97 92 98 @param dc The <code>DbControl</code> which will be used for … … 95 101 @return The new <code>RawBioAssay</code> item 96 102 @throws BaseException If there is an error 103 @deprecated Use {@link #getNew(DbControl, Platform, RawDataType)} or 104 {@link #getNew(DbControl, PlatformVariant, RawDataType)} instead. 105 This method will set the platform to {@link Platform#GENERIC}. 97 106 */ 98 107 public static RawBioAssay getNew(DbControl dc, RawDataType rawDataType) 99 108 throws BaseException 100 109 { 110 Platform platform = rawDataType.getPlatform(dc); 111 PlatformVariant variant = rawDataType.getVariant(dc); 112 RawBioAssay rba = null; 113 if (variant != null) 114 { 115 rba = getNew(dc, variant, rawDataType); 116 } 117 else 118 { 119 if (platform == null) platform = Platform.getByExternalId(dc, Platform.GENERIC); 120 rba = getNew(dc, platform, rawDataType); 121 } 122 return rba; 123 } 124 125 /** 126 Create a new raw bioassay for a specific platform and/or raw data type. 127 If the platform is locked to a specific raw data type, the <code>rawDataType</code> 128 parameter is ignored. If the platform isn't locked the raw data type 129 is required and must be a database-based raw data type. Ie. 130 {@link RawDataType#isStoredInDb()} must return true. 131 132 @param dc The <code>DbControl</code> which will be used for 133 permission checking and database access 134 @param platform The platform of the new raw bioassay, null is not allowed 135 @param rawDataType The raw data type of the raw bioassay (required if 136 the platform isn't locked to a specific raw data type) 137 @return The new <code>RawBioAssay</code> item 138 @since 2.5 139 */ 140 public static RawBioAssay getNew(DbControl dc, Platform platform, RawDataType rawDataType) 141 { 101 142 RawBioAssay rba = dc.newItem(RawBioAssay.class); 102 rba.set RawDataType(rawDataType);143 rba.setPlatform(platform, rawDataType); 103 144 rba.setName("New raw bioassay"); 104 145 return rba; 146 } 147 148 /** 149 Create a new raw bioassay for a specific platform variant. 150 If the variant is locked to a specific raw data type, the <code>rawDataType</code> 151 parameter is ignored. If the variant isn't locked the raw data type 152 is required and must be a database-based raw data type. Ie. 153 {@link RawDataType#isStoredInDb()} must return true. 154 155 156 @param dc The <code>DbControl</code> which will be used for 157 permission checking and database access 158 @param variant The platform variant of the new raw bioassay, null is not allowed 159 @param rawDataType The raw data type of the raw bioassay (required if 160 the platform isn't locked to a specific raw data type) 161 @return The new <code>RawBioAssay</code> item 162 @since 2.5 163 */ 164 public static RawBioAssay getNew(DbControl dc, PlatformVariant variant, RawDataType rawDataType) 165 { 166 RawBioAssay rba = dc.newItem(RawBioAssay.class); 167 rba.setVariant(variant, rawDataType); 168 rba.setName("New raw bioassay"); 169 return rba; 105 170 } 106 171 … … 204 269 } 205 270 // ------------------------------------------- 271 /* 272 From the FileStoreEnabled interface 273 ------------------------------------------- 274 */ 275 /** 276 @since 2.5 277 */ 278 public FileSet getFileSet() 279 { 280 DbControl dc = getDbControl(); 281 FileSet fs = dc.getItem(FileSet.class, getData().getFileSet(), this); 282 if (fs == null) 283 { 284 fs = FileSet.getNew(dc, this); 285 getData().setFileSet(fs.getData()); 286 dc.saveItemIf(this, fs, false); 287 } 288 return fs; 289 } 290 /** 291 @since 2.5 292 */ 293 public boolean hasFileSet() 294 { 295 return getData().getFileSet() != null; 296 } 297 /** 298 @since 2.5 299 */ 300 public Platform getPlatform() 301 { 302 return getDbControl().getItem(Platform.class, getData().getPlatform()); 303 } 304 /** 305 @since 2.5 306 */ 307 public PlatformVariant getVariant() 308 { 309 return getDbControl().getItem(PlatformVariant.class, getData().getVariant()); 310 } 311 /** 312 Get the file set from the array design, if it exists. 313 @since 2.5 314 */ 315 public Collection<FileSet> getParentFileSets() 316 { 317 Collection<FileSet> parents = null; 318 ArrayDesign design = getArrayDesign(); 319 if (design != null && design.hasFileSet()) 320 { 321 parents = Collections.singleton(design.getFileSet()); 322 } 323 return parents; 324 } 325 // ------------------------------------------- 206 326 207 327 /* … … 213 333 <ul> 214 334 <li>An {@link Experiment} is using this raw bioassay 215 <li>A {@link Transformation} is using this raw bioassay 335 <li>A {@link Transformation} is using this raw bio raw data type will also be updated. The platform can't be changed 336 if raw data has been imported to the database.assay 216 337 </ul> 217 338 */ … … 303 424 304 425 /** 426 Set the platform and raw data type of the raw bioassay. This method will 427 set the variant to null. Use {@link #setVariant(PlatformVariant, RawDataType)} if you 428 want to set a specific variant. If the platform is locked to a raw data type, 429 the <code>rawDataType</code> parameter is ignored. If the platform isn't 430 locked the raw data type must be a database-based raw data type. Ie. 431 {@link RawDataType#isStoredInDb()} must return true. 432 433 @param platform The new platform, null is not allowes 434 @param rawDataType The raw data type, required if the platform 435 doesn't specify a raw data type 436 @throws PermissionDeniedException If the logged in user doesn't have 437 write permission 438 @throws InvalidDataException If platform is null or if the raw data 439 type is not properly specified 440 @since 2.5 441 */ 442 public void setPlatform(Platform platform, RawDataType rawDataType) 443 { 444 checkPermission(Permission.WRITE); 445 if (platform == null) throw new InvalidUseOfNullException("platform"); 446 if (getData().getSpots() > 0) 447 { 448 throw new PermissionDeniedException("Not allowed to change the platform after raw data has been added"); 449 } 450 RawDataType rdt = platform.getRawDataType(); 451 if (rdt == null) 452 { 453 if (rawDataType == null) 454 { 455 throw new InvalidUseOfNullException("rawDataType must be specified for platform: " + 456 platform.getName()); 457 } 458 if (!rawDataType.isStoredInDb()) 459 { 460 throw new InvalidDataException("rawDataType can't store data in the database: " + 461 rawDataType.getName()); 462 } 463 rdt = rawDataType; 464 } 465 getData().setPlatform(platform.getData()); 466 getData().setVariant(null); 467 getData().setRawDataType(rdt.getId()); 468 } 469 470 /** 471 Set the platform and variant of the raw bioassay. This method will 472 automatically set the platform to {@link PlatformVariant#getPlatform()}. 473 If the platform variant is locked to a raw data type, the raw data 474 type is also updated. The platform variant can't be changed 475 if raw data has been imported to the database. 476 477 @param variant The new platform variant 478 @throws PermissionDeniedException If the logged in user doesn't have 479 write permission 480 @throws InvalidDataException If variant is null 481 @since 2.5 482 */ 483 public void setVariant(PlatformVariant variant, RawDataType rawDataType) 484 { 485 checkPermission(Permission.WRITE); 486 if (variant == null) throw new InvalidUseOfNullException("variant"); 487 if (getData().getSpots() > 0) 488 { 489 throw new PermissionDeniedException("Not allowed to change the platform after raw data has been added"); 490 } 491 RawDataType rdt = variant.getRawDataType(); 492 if (rdt == null) 493 { 494 if (rawDataType == null) 495 { 496 throw new InvalidUseOfNullException("rawDataType must be specified for platform variant: " + 497 variant.getName()); 498 } 499 if (!rawDataType.isStoredInDb()) 500 { 501 throw new InvalidDataException("rawDataType can't store data in the database: " + 502 rawDataType.getName()); 503 } 504 rdt = rawDataType; 505 } 506 getData().setVariant(variant.getData()); 507 getData().setPlatform(variant.getData().getPlatform()); 508 getData().setRawDataType(rdt.getId()); 509 } 510 511 /** 512 Check if the platform/variant of this raw bioassay has the 513 given external ID. 514 @param externalId The external ID to match 515 @return TRUE if either the variant of platform matches the 516 external ID 517 @since 2.5 518 */ 519 public boolean isPlatform(String externalId) 520 { 521 if (externalId == null) return false; 522 if (externalId.equals(getData().getPlatform().getExternalId())) return true; 523 if (getData().getVariant() != null) 524 { 525 if (externalId.equals(getData().getVariant().getExternalId())) return true; 526 } 527 return false; 528 } 529 530 /** 531 Check if this raw bioassay uses a file-only platform or variant. 532 If the raw bioassay has a platform variant, the setting from the 533 variant is returned, otherwise the setting from the platform. 534 @return TRUE if this raw bioassay use a file-only variant / platform 535 @since 2.5 536 */ 537 public boolean isFileOnlyPlatform() 538 { 539 if (getData().getVariant() != null) 540 { 541 return getData().getVariant().isFileOnly(); 542 } 543 else 544 { 545 return getData().getPlatform().isFileOnly(); 546 } 547 } 548 549 /** 305 550 Get the raw data type this raw bioassay uses for the raw data. 306 551 The raw data type cannot be changed once the raw bioassay has been created. … … 314 559 /** 315 560 Set the raw data type. The raw data type cannot be changed if raw 316 data has been added. 561 data has been added to the database. 562 317 563 @param rawDataType The raw data type, null is not allowed 318 564 @throws PermissionDeniedException If the logged in user doesn't have 319 565 write permission for the raw bioassay or spots has already been added 566 @deprecated Use {@link #setPlatform(Platform, RawDataType)} or 567 {@link #setVariant(PlatformVariant, RawDataType)} instead 320 568 */ 321 569 public void setRawDataType(RawDataType rawDataType) … … 328 576 throw new PermissionDeniedException("Not allowed to change the raw data type after raw data has been added"); 329 577 } 578 579 PlatformData platform = rawDataType.getPlatformProxy(); 580 PlatformVariantData variant = rawDataType.getVariantProxy(); 581 582 getData().setPlatform(platform); 583 getData().setVariant(variant); 330 584 getData().setRawDataType(rawDataType.getId()); 331 585 } … … 454 708 checkPermission(Permission.WRITE); 455 709 if (arrayDesign != null) arrayDesign.checkPermission(Permission.USE); 456 if (getData().get Spots() > 0)710 if (getData().getHasData()) 457 711 { 458 712 throw new PermissionDeniedException("Not allowed to change the array design after raw data has been added"); … … 481 735 checkPermission(Permission.WRITE); 482 736 if (arrayDesign != null) arrayDesign.checkPermission(Permission.USE); 737 738 // No need to validate if there is no change 739 if (arrayDesign == null && getData().getArrayDesign() == null) return; 740 if (arrayDesign != null && arrayDesign.getData().equals(getData().getArrayDesign())) return; 741 742 // Re-validate data in database if we already have db data 483 743 if (getData().getSpots() > 0 && arrayDesign != null) 484 744 { 485 // No need to validate if there is no change 486 if (arrayDesign.getData().equals(getData().getArrayDesign())) return; 487 488 if (getRawDataType().isAffymetrix()) 489 { 490 // Verify CEL and CDF files 491 Affymetrix.validateCelAndCdf(this, arrayDesign, false); 492 } 493 else if (getRawDataType().isStoredInDb()) 494 { 495 validateFeatures(getDbControl(), arrayDesign, true, progress); 496 } 745 validateFeatures(getDbControl(), arrayDesign, true, progress); 497 746 } 498 747 getData().setArrayDesign(arrayDesign == null ? null : arrayDesign.getData()); 748 749 // Re-validate files 750 if (hasFileSet()) getFileSet().validate(getDbControl(), true); 499 751 } 500 752 … … 512 764 raw bioassay. 513 765 @return The number of spots 766 @deprecated Use {@link #getNumDbSpots()} or {@link #getNumFileSpots()} 767 instead. This method first checks the database and if not 0, it 768 returns that value, otherwise it returns the number of file spots 514 769 */ 515 770 public int getSpots() 516 771 { 772 int dbSpots = getNumDbSpots(); 773 return dbSpots > 0 ? dbSpots : getNumFileSpots(); 774 } 775 776 /** 777 Get the number of spots on this raw bioassay that are 778 stored in the database. 779 @return The number of spots in the database 780 @since 2.5 781 */ 782 public int getNumDbSpots() 783 { 517 784 return getData().getSpots(); 518 785 } 519 786 520 787 /** 788 Get the number of spots on this raw bioassay that are 789 stored inside files. 790 @return The number of spots in files 791 @since 2.5 792 */ 793 public int getNumFileSpots() 794 { 795 return getData().getNumFileSpots(); 796 } 797 798 /** 799 Set the number of spots that are stored in files. 800 @param numSpots The number of spots 801 @since 2.5 802 */ 803 public void setNumFileSpots(int numSpots) 804 { 805 checkPermission(Permission.WRITE); 806 getData().setNumFileSpots(numSpots); 807 getData().setHasData(numSpots > 0 || getNumDbSpots() > 0); 808 } 809 810 811 /** 521 812 If raw data has been added to this raw bioassay or not. Note that this method 522 can return true even if the {@link #getSpots()} returns 0 if the raw data 523 type uses files to store it's data. 813 checks both data in the database and data in the form of files. 524 814 */ 525 815 public boolean hasData() … … 587 877 { 588 878 checkPermission(Permission.WRITE); 589 if (getData().getSpots() > 0)590 {591 throw new PermissionDeniedException("Not allowed to change the headers after raw data has been added");592 }593 879 if (name == null) throw new InvalidUseOfNullException("header.name"); 594 880 if (name.length() > MAX_HEADER_NAME_LENGTH) … … 603 889 getData().getHeaders().put(name, value); 604 890 } 891 892 /** 893 Remove all headers from the raw bioassay. 894 @since 2.5 895 */ 896 public void removeHeaders() 897 { 898 checkPermission(Permission.WRITE); 899 getData().getHeaders().clear(); 900 } 901 902 /** 903 Remove a specific header from the raw bioassay. 904 @param name The name of the header 905 @since 2.5 906 */ 907 public void removeHeader(String name) 908 { 909 checkPermission(Permission.WRITE); 910 getData().getHeaders().remove(name); 911 } 912 605 913 /** 606 914 Get the names of all raw data headers. The set is sorted by name. … … 653 961 654 962 /** 655 Delete the raw data that has been added to the raw bioassay. You should not656 call this method in the same transaction as adding raw data with the657 batcher from {@link #getRawDataBatcher()}.963 Delete the raw data that has been added to the database for this 964 raw bioassay. You should not call this method in the same transaction as 965 adding raw data with the batcher from {@link #getRawDataBatcher()}. 658 966 659 967 @throws PermissionDeniedException If the logged in user doesn't have … … 675 983 throw new PermissionDeniedException("The raw bioassay is used in one or more experiments: "+this); 676 984 } 677 if (get Spots() > 0)985 if (getNumDbSpots() > 0) 678 986 { 679 987 RawDataBatcher rdb = RawDataBatcher.getNew(getDbControl(), this); … … 750 1058 private void validateFeatures(DbControl dc, ArrayDesign design, boolean update, ProgressReporter progress) 751 1059 { 752 if (design.isAffyChip())753 {754 throw new InvalidDataException("The array design is an Affymetrix chip: " + design.getName());755 }756 1060 if (design.hasFeatures()) 757 1061 { … … 796 1100 DataResultIterator<RawData> result = rawQuery.iterate(dc); 797 1101 int numValidated = 0; 798 int numTotal = get Spots();1102 int numTotal = getNumDbSpots(); 799 1103 while (result.hasNext()) 800 1104 { -
trunk/src/core/net/sf/basedb/core/RawDataBatcher.java
r3775 r3820 308 308 rawBioAssayData.setSpots(rawBioAssayData.getSpots() + getTotalInsertCount()); 309 309 rawBioAssayData.setBytes(rawBioAssayData.getBytes() + bytes); 310 rawBioAssayData.setHasData(rawBioAssayData.getSpots() > 0 );310 rawBioAssayData.setHasData(rawBioAssayData.getSpots() > 0 || rawBioAssayData.getNumFileSpots() > 0); 311 311 if (preloaded != null) preloaded.clear(); 312 312 } … … 443 443 rawBioAssayData.setSpots(0); 444 444 rawBioAssayData.setBytes(0); 445 rawBioAssayData.setHasData( false);445 rawBioAssayData.setHasData(rawBioAssayData.getNumFileSpots() > 0); 446 446 } 447 447 catch (SQLException ex) -
trunk/src/core/net/sf/basedb/core/RawDataType.java
r3679 r3820 29 29 import java.util.Collections; 30 30 31 import net.sf.basedb.core.data.PlatformData; 32 import net.sf.basedb.core.data.PlatformVariantData; 31 33 import net.sf.basedb.core.data.RawData; 32 34 … … 48 50 { 49 51 50 private final boolean isAffymetrix;51 52 private final String id; 52 53 private final String name; 53 54 private final String description; 54 private final String storage;55 private final boolean is StoredInDb;55 private final boolean fileOnly; 56 private final boolean isAffymetrix; 56 57 private final int channels; 57 private final String table; 58 private final List<RawDataProperty> properties; 59 private final Map<String, RawDataProperty> namedProperties; 60 private final List<IntensityFormula> formulas; 61 private final Map<String, IntensityFormula> namedFormulas; 62 63 private final RealTable realTable; 58 private final PlatformData platform; 59 private final PlatformVariantData variant; 60 private String table; 61 private RealTable realTable; 62 private List<RawDataProperty> properties; 63 private Map<String, RawDataProperty> namedProperties; 64 private List<IntensityFormula> formulas; 65 private Map<String, IntensityFormula> namedFormulas; 66 64 67 65 68 /** … … 67 70 See the getter methods for a description of the parameters 68 71 */ 69 RawDataType(String id, String name, String description, int channels, String storage, 72 RawDataType(String id, String name, String description, int channels, 73 String table, List<RawDataProperty> properties, List<IntensityFormula> formulas) 74 { 75 this(id, name, description, channels, false, null, null, false, table, properties, formulas); 76 } 77 78 /** 79 Create a new raw data type representing a file-only platform. 80 @param platform The platform 81 */ 82 RawDataType(PlatformData platform) 83 { 84 this("platform." + platform.getExternalId(), platform.getName(), 85 platform.getDescription(), platform.getChannels(), true, 86 platform, null, 87 Platform.AFFYMETRIX.equals(platform.getExternalId()), 88 null, null, null); 89 } 90 91 /** 92 Create a new raw data type representing a file-only platform variant. 93 @param variant The platform variant 94 */ 95 RawDataType(PlatformVariantData variant) 96 { 97 this("variant." + variant.getExternalId(), variant.getName(), 98 variant.getDescription(), variant.getChannels(), true, 99 variant.getPlatform(), variant, 100 Platform.AFFYMETRIX.equals(variant.getPlatform().getExternalId()), 101 null, null, null); 102 } 103 104 private RawDataType(String id, String name, String description, int channels, 105 boolean fileOnly, PlatformData platform, PlatformVariantData variant, boolean isAffymetrix, 70 106 String table, List<RawDataProperty> properties, List<IntensityFormula> formulas) 71 107 { … … 73 109 this.name = name; 74 110 this.description = description; 75 this.storage = storage;76 111 this.channels = channels; 77 this.isStoredInDb = "database".equals(storage); 78 this.table = isStoredInDb ? table : null; 79 this.properties = Collections.unmodifiableList(properties); 80 this.formulas = formulas; 81 this.realTable = isStoredInDb ? new RealTable(table, "raw") : null; 112 this.fileOnly = fileOnly; 113 this.platform = platform; 114 this.variant = variant; 115 this.isAffymetrix = isAffymetrix; 82 116 83 // This is an ugly hack to support affymetrix data 84 this.isAffymetrix = "affymetrix".equals(id); 85 86 if (isStoredInDb && table == null) 117 // For database raw data types 118 if (!fileOnly) 87 119 { 88 throw new InvalidDataException("No table specified for raw data type: " + id); 89 } 90 91 this.namedProperties = new HashMap<String, RawDataProperty>(properties.size()); 92 for (RawDataProperty property : properties) 93 { 94 if (namedProperties.put(property.getName(), property) != null) 120 if (table == null) 95 121 { 96 throw new BaseException("RawDataProperty[name="+property.getName()+"] is already defined for raw data type: "+name); 122 throw new InvalidDataException("No table specified for raw data type: " + id); 123 } 124 this.table = table; 125 this.realTable = new RealTable(table, "raw"); 126 127 // Extended properties (=columns) of the table 128 if (properties != null) 129 { 130 this.properties = Collections.unmodifiableList(properties); 131 this.namedProperties = new HashMap<String, RawDataProperty>(); 132 for (RawDataProperty property : properties) 133 { 134 if (namedProperties.put(property.getName(), property) != null) 135 { 136 throw new BaseException("RawDataProperty[name="+property.getName()+"] is already defined for raw data type: "+name); 137 } 138 } 139 } 140 141 // Intensity formulas 142 if (formulas != null) 143 { 144 this.formulas = Collections.unmodifiableList(formulas); 145 this.namedFormulas = new HashMap<String, IntensityFormula>(); 146 for (IntensityFormula formula : formulas) 147 { 148 if (namedFormulas.put(formula.getName(), formula) != null) 149 { 150 throw new BaseException("IntensityFormula[name="+formula.getName()+"] is already defined for raw data type: "+name); 151 } 152 } 97 153 } 98 154 } 99 this.namedFormulas = new HashMap<String, IntensityFormula>(formulas.size()); 100 for (IntensityFormula formula : formulas) 101 { 102 if (namedFormulas.put(formula.getName(), formula) != null) 103 { 104 throw new BaseException("IntensityFormula[name="+formula.getName()+"] is already defined for raw data type: "+name); 105 } 106 } 107 108 } 109 155 if (this.formulas == null) this.formulas = Collections.emptyList(); 156 if (this.properties == null) this.properties = Collections.emptyList(); 157 } 158 110 159 /** 111 160 Get the id of this raw data type. This value is the same as the … … 121 170 /** 122 171 If this raw data type is the Affymetrix raw data type. 172 @deprecated Use {@link #getPlatform(DbControl)} and compare 173 the external ID with {@link Platform#AFFYMETRIX} 123 174 */ 124 175 public boolean isAffymetrix() 125 176 { 126 177 return isAffymetrix; 178 } 179 180 /** 181 Get the platform that this raw data type is associated with. Only 182 raw data types representing file-only platforms are associated 183 with that platform. If {@link #isStoredInDb()} returns true this 184 method will always return null. 185 186 @param dc The DbControl to use for database access 187 @return A Platform item or null if this raw data type 188 isn't associated with a platform 189 @since 2.5 190 */ 191 public Platform getPlatform(DbControl dc) 192 { 193 return platform == null ? null : Platform.getById(dc, platform.getId()); 194 } 195 196 /** 197 Get the platform variant that this raw data type is associated with. Only 198 raw data types representing file-only variants are associated 199 with that variant. 200 201 @param dc The DbControl to use for database access 202 @return A Platform item or null if this raw data type 203 isn't associated with a variant 204 @since 2.5 205 */ 206 public PlatformVariant getVariant(DbControl dc) 207 { 208 return variant == null ? null : PlatformVariant.getById(dc, variant.getId()); 209 } 210 211 /** 212 Needed to make {@link RawBioAssay#setRawDataType(RawDataType)} 213 backwards compatible. Platforms that are not file-only will 214 get the {@link Platform#GENERIC} platform. 215 @since 2.5 216 */ 217 PlatformData getPlatformProxy() 218 { 219 return platform == null ? RawDataTypes.generic : platform; 220 } 221 222 /** 223 Needed to make {@link RawBioAssay#setRawDataType(RawDataType)} 224 backwards compatible. 225 @since 2.5 226 */ 227 PlatformVariantData getVariantProxy() 228 { 229 return variant; 127 230 } 128 231 … … 169 272 170 273 /** 171 If the raw data of this raw data type isstored in the database274 If the raw data of this raw data type can be stored in the database 172 275 or not. 173 276 @see #getTableName() … … 175 278 public boolean isStoredInDb() 176 279 { 177 return isStoredInDb;280 return !fileOnly; 178 281 } 179 282 … … 205 308 206 309 /** 207 Get a list of {@link RawDataProperty} s with definitions for the310 Get a list of {@link RawDataProperty}:s with definitions for the 208 311 extra properties that has been defined for this raw data type. 209 312 -
trunk/src/core/net/sf/basedb/core/RawDataTypes.java
r3679 r3820 26 26 package net.sf.basedb.core; 27 27 28 import net.sf.basedb.core.data.PlatformData; 29 import net.sf.basedb.core.data.PlatformVariantData; 28 30 import net.sf.basedb.core.dbengine.DbEngine; 29 31 import net.sf.basedb.util.Values; 30 32 import net.sf.basedb.util.XMLUtil; 31 33 34 import java.util.HashMap; 32 35 import java.util.HashSet; 33 36 import java.util.List; … … 66 69 private static Map<String, RawDataType> rawDataTypes = null; 67 70 71 private static Map<String, RawDataType> platformTypes = null; 72 73 private static Set<RawDataType> all = null; 74 75 static PlatformData generic = null; 76 68 77 /** 69 78 The DTD which is used to validate the XML file. … … 82 91 if (isInitialised) return; 83 92 rawDataTypes = new TreeMap<String, RawDataType>(); 93 all = new HashSet<RawDataType>(); 84 94 loadRawDataTypesFile(); 85 95 isInitialised = true; 96 } 97 98 /** 99 Load file-only platforms and create raw data types for them. 100 @since 2.5 101 */ 102 static synchronized void initPlatforms() 103 { 104 org.hibernate.Session session = null; 105 org.hibernate.Transaction tx = null; 106 107 try 108 { 109 platformTypes = new HashMap<String, RawDataType>(); 110 session = HibernateUtil.newSession(); 111 tx = HibernateUtil.newTransaction(session); 112 113 org.hibernate.Query query = HibernateUtil.createQuery(session, 114 "FROM PlatformData pfd WHERE pfd.fileOnly = true"); 115 for (PlatformData platform : HibernateUtil.loadList(PlatformData.class, query)) 116 { 117 RawDataType rdt = new RawDataType(platform); 118 platformTypes.put(rdt.getId(), rdt); 119 all.add(rdt); 120 } 121 122 query = HibernateUtil.createQuery(session, 123 "FROM PlatformVariantData pfv WHERE pfv.fileOnly = true"); 124 for (PlatformVariantData variant : HibernateUtil.loadList(PlatformVariantData.class, query)) 125 { 126 RawDataType rdt = new RawDataType(variant); 127 platformTypes.put(rdt.getId(), rdt); 128 all.add(rdt); 129 } 130 131 query = HibernateUtil.getPredefinedQuery(session, 132 "GET_PLATFORM_FOR_EXTERNAL_ID"); 133 query.setString("externalId", Platform.GENERIC); 134 generic = HibernateUtil.loadData(PlatformData.class, query); 135 } 136 finally 137 { 138 if (tx != null) HibernateUtil.commit(tx); 139 if (session != null) HibernateUtil.close(session); 140 } 86 141 } 87 142 … … 94 149 if (rawDataTypes != null) rawDataTypes.clear(); 95 150 rawDataTypes = null; 151 if (platformTypes != null) platformTypes.clear(); 152 platformTypes = null; 153 if (all != null) all.clear(); 154 all = null; 96 155 } 97 156 … … 119 178 120 179 /** 121 Get a collection with all raw data types that has been defined. 180 Get a collection with all raw data types that has been defined. This method 181 only returns both database and file-only raw data types. To 182 get file-only raw data types use {@link #getFileOnlyRawDataTypes()} 122 183 @return A <code>Collection</code> containing {@link RawDataType} objects 184 where {@link RawDataType#isStoredInDb()} returns true 123 185 */ 124 186 public static Collection<RawDataType> getRawDataTypes() 125 187 { 126 return Collections.unmodifiableCollection(rawDataTypes.values()); 188 return Collections.unmodifiableCollection(all); 189 } 190 191 /** 192 Get the raw data types that are representations of file-only 193 {@link Platform}:s. 194 @return A <code>Collection</code> containing {@link RawDataType} objects 195 where {@link RawDataType#isStoredInDb()} returns false 196 @since 2.5 197 */ 198 public static Collection<RawDataType> getFileOnlyRawDataTypes() 199 { 200 return Collections.unmodifiableCollection(platformTypes.values()); 127 201 } 128 202 … … 136 210 public static RawDataType getRawDataType(String id) 137 211 { 138 return id == null ? null : rawDataTypes.get(id); 212 if (id == null) return null; 213 if (id.startsWith("platform.")) 214 { 215 return getPlatformRawDataType(id); 216 } 217 else if (id.startsWith("variant.")) 218 { 219 return getVariantRawDataType(id); 220 } 221 else 222 { 223 return rawDataTypes.get(id); 224 } 225 } 226 227 private static RawDataType getPlatformRawDataType(String id) 228 { 229 RawDataType rdt = platformTypes.get(id); 230 if (rdt != null) return rdt; 231 232 org.hibernate.Session session = null; 233 org.hibernate.Transaction tx = null; 234 try 235 { 236 session = HibernateUtil.newSession(); 237 tx = HibernateUtil.newTransaction(session); 238 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 239 "GET_PLATFORM_FOR_EXTERNAL_ID"); 240 query.setString("externalId", id.substring(9)); 241 PlatformData platform = HibernateUtil.loadData(PlatformData.class, query); 242 if (platform == null || !platform.isFileOnly()) return null; 243 rdt = new RawDataType(platform); 244 platformTypes.put(id, rdt); 245 all.add(rdt); 246 } 247 finally 248 { 249 if (tx != null) HibernateUtil.commit(tx); 250 if (session != null) HibernateUtil.close(session); 251 } 252 return rdt; 253 } 254 255 private static RawDataType getVariantRawDataType(String id) 256 { 257 RawDataType rdt = platformTypes.get(id); 258 if (rdt != null) return rdt; 259 260 org.hibernate.Session session = null; 261 org.hibernate.Transaction tx = null; 262 try 263 { 264 session = HibernateUtil.newSession(); 265 tx = HibernateUtil.newTransaction(session); 266 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 267 "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID"); 268 query.setString("externalId", id.substring(9)); 269 PlatformVariantData variant = HibernateUtil.loadData(PlatformVariantData.class, query); 270 if (variant == null || !variant.isFileOnly()) return null; 271 rdt = new RawDataType(variant); 272 platformTypes.put(id, rdt); 273 all.add(rdt); 274 } 275 finally 276 { 277 if (tx != null) HibernateUtil.commit(tx); 278 if (session != null) HibernateUtil.close(session); 279 } 280 return rdt; 139 281 } 140 282 … … 182 324 usedNames.add("table:" + table); 183 325 } 326 else 327 { 328 throw new ConfigurationException("Attribute storage='" + storage + 329 "' is no longer supported. Please remove declaration for <rawdatatype id='" + id + 330 "'> from " + Application.getRawDataTypesFile()); 331 } 184 332 if (channels <= 0) 185 333 { … … 189 337 List<RawDataProperty> properties = loadProperties(el, channels); 190 338 List<IntensityFormula> formulas = loadIntensityFormulas(el, channels); 191 RawDataType rdt = new RawDataType(id, name, description, channels, storage, table, properties, formulas); 339 RawDataType rdt = new RawDataType(id, name, description, channels, 340 table, properties, formulas); 192 341 rawDataTypes.put(id, rdt); 342 all.add(rdt); 193 343 } 194 344 } -
trunk/src/core/net/sf/basedb/core/Scan.java
r3679 r3820 299 299 use permission for the scan 300 300 @throws BaseException If there is another error 301 @deprecated Use {@link RawBioAssay#getNew(DbControl, Platform, RawDataType)} 302 or {@link RawBioAssay#getNew(DbControl, PlatformVariant, RawDataType)} instead 301 303 */ 302 304 public RawBioAssay newRawBioAssay(RawDataType rawDataType) -
trunk/src/core/net/sf/basedb/core/SpotImages.java
r3679 r3820 452 452 final float halfSpotsize = -spotsize / 2; 453 453 final int spotImagesPerImage = NUM_SPOT_IMAGES * NUM_SPOT_IMAGES; 454 final int totalSpots = getRawBioAssay().get Spots();454 final int totalSpots = getRawBioAssay().getNumDbSpots(); 455 455 int lastImageNumber = 0; 456 456 -
trunk/src/core/net/sf/basedb/core/SystemItem.java
r3679 r3820 24 24 */ 25 25 package net.sf.basedb.core; 26 27 import net.sf.basedb.core.data.SystemData; 26 28 27 29 /** … … 56 58 { 57 59 /** 60 The maximum length of the system ID that can be stored in the database. 61 @see #getSystemId() 62 */ 63 public static final int MAX_SYSTEM_ID_LENGTH = 64 SystemData.MAX_SYSTEM_ID_LENGTH; 65 66 67 /** 58 68 Get the system id for the item. 59 69 @return The id of the item or null if it is not a system item -
trunk/src/core/net/sf/basedb/core/Update.java
r3784 r3820 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 <ul> 1663 <li>Set a platform for array designs and raw bioassays 1664 <li>Change experiment raw data type if it is "affymetrix" to "platform.affymetrix" 1665 <li>Move CEL and CDF files into FileSet:s 1666 <li>Remove filters on ArrayDesign.isAffyChip property 1667 <li>Add READ permission to PLATFORM and DATAFILETYPE for all plug-ins 1668 working with ARRAYDESIGN or RAWBIOASSAY 1669 </ul> 1670 */ 1671 @SuppressWarnings("deprecation") 1672 private static int updateToSchemaVersion44(SessionControl sc) 1673 { 1674 final int schemaVersion = 44; 1675 DbControl dc = null; 1676 try 1677 { 1678 dc = sc.newDbControl(); 1679 org.hibernate.Session session = dc.getHibernateSession(); 1680 1681 // Items that we need 1682 Platform affymetrix = Platform.getByExternalId(dc, Platform.AFFYMETRIX); 1683 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 1684 DataFileType cdfType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CDF); 1685 DataFileType celType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CEL); 1686 RawDataType affyRaw = affymetrix.getRawDataType(); 1687 1688 // Query to count number of features in db 1689 org.hibernate.Query countQuery = HibernateUtil.getPredefinedQuery(session, 1690 "COUNT_FEATURES_FOR_ARRAYDESIGN"); 1691 1692 // Load array designs 1693 org.hibernate.Query designQuery = HibernateUtil.createQuery(session, 1694 "SELECT ad FROM ArrayDesignData ad WHERE ad.platform is null"); 1695 List<ArrayDesignData> arrayDesigns = 1696 HibernateUtil.loadList(ArrayDesignData.class, designQuery); 1697 for (ArrayDesignData dd : arrayDesigns) 1698 { 1699 ArrayDesign design = dc.getItem(ArrayDesign.class, dd); 1700 if (design.getData().isAffyChip()) 1701 { 1702 design.setPlatform(affymetrix); 1703 AnyToAny anyCdf = null; 1704 try 1705 { 1706 anyCdf = AnyToAny.getByName(dc, design, Affymetrix.CDF_LINK_NAME); 1707 } 1708 catch (Throwable t) 1709 {} 1710 AnyToAny.unlinkFrom(dc, design, Affymetrix.CDF_LINK_NAME); 1711 if (anyCdf != null) 1712 { 1713 File cdfFile = (File)anyCdf.getTo(); 1714 FileSet fileSet = design.getFileSet(); 1715 fileSet.setMember(cdfFile, cdfType); 1716 fileSet.validate(dc, true); 1717 } 1718 } 1719 else 1720 { 1721 design.setPlatform(generic); 1722 countQuery.setInteger("arrayDesign", design.getId()); 1723 int dbFeatures = HibernateUtil.loadData(Long.class, countQuery).intValue(); 1724 design.getData().setNumDbFeatures(dbFeatures); 1725 } 1726 } 1727 1728 // Load rawbioassays 1729 org.hibernate.Query rbaQuery = HibernateUtil.createQuery(session, 1730 "SELECT rba FROM RawBioAssayData rba WHERE rba.platform is null"); 1731 List<RawBioAssayData> rawBioAssays = 1732 HibernateUtil.loadList(RawBioAssayData.class, rbaQuery); 1733 for (RawBioAssayData dd : rawBioAssays) 1734 { 1735 RawBioAssay rba = dc.getItem(RawBioAssay.class, dd); 1736 if ("affymetrix".equals(rba.getData().getRawDataType())) 1737 { 1738 rba.getData().setPlatform(affymetrix.getData()); 1739 rba.getData().setRawDataType(affyRaw.getId()); 1740 rba.getData().setSpots(0); // No db spots in affy files 1741 AnyToAny anyCel = null; 1742 try 1743 { 1744 anyCel = AnyToAny.getByName(dc, rba, Affymetrix.CEL_LINK_NAME); 1745 } 1746 catch (Throwable t) 1747 {} 1748 AnyToAny.unlinkFrom(dc, rba, Affymetrix.CEL_LINK_NAME); 1749 if (anyCel != null) 1750 { 1751 File celFile = (File)anyCel.getTo(); 1752 FileSet fileSet = rba.getFileSet(); 1753 fileSet.setMember(celFile, celType); 1754 fileSet.validate(dc, true); 1755 } 1756 } 1757 else 1758 { 1759 rba.getData().setPlatform(generic.getData()); 1760 } 1761 } 1762 1763 // Change raw data type for 'affymetrix' experiments to 'platform.affymetrix' 1764 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 1765 "CHANGE_EXPERIMENT_RAWDATATYPE"); 1766 /* 1767 UPDATE ExperimentData 1768 SET rawDataType = :newRawDataType 1769 WHERE rawDataType = :oldRawDataType 1770 */ 1771 query.setString("oldRawDataType", "affymetrix"); 1772 query.setString("newRawDataType", affyRaw.getId()); 1773 HibernateUtil.executeUpdate(query); 1774 1775 // Update property filters on 'rawDataType=affymetrix' to 'platform.affymetrix' 1776 query = HibernateUtil.getPredefinedSQLQuery(session, 1777 "UPDATE_PROPERTY_FILTER_VALUE"); 1778 /* 1779 UPDATE [PropertyFilters] 1780 SET [value] = :newValue 1781 WHERE [property] = :property AND [value] = :oldValue 1782 */ 1783 query.setString("property", "rawDataType"); 1784 query.setString("oldValue", "affymetrix"); 1785 query.setString("newValue", affyRaw.getId()); 1786 HibernateUtil.executeUpdate(query); 1787 1788 // Remove filters on the 'affyChip' property 1789 query = HibernateUtil.getPredefinedSQLQuery(session, 1790 "DELETE_PROPERTY_FILTER"); 1791 /* 1792 DELETE FROM PropertyFilters pf 1793 WHERE pf.property = :property 1794 */ 1795 query.setString("property", "affyChip"); 1796 HibernateUtil.executeUpdate(query); 1797 1798 // Add READ permission to PLATFORM and DATAFILETYPE for all plug-ins 1799 // working with ARRAYDESIGN or RAWBIOASSAY 1800 int adKeyId = SystemItems.getRoleKeyId(Item.ARRAYDESIGN); 1801 int rbaKeyId = SystemItems.getRoleKeyId(Item.RAWBIOASSAY); 1802 1803 org.hibernate.Query pQuery = HibernateUtil.getPredefinedQuery(session, 1804 "GET_PLUGINS_WITH_KEYS"); 1805 /* 1806 SELECT DISTINCT pk.pluginDefinitionId 1807 FROM PluginKeys pk WHERE pk.keyId IN (:keys) 1808 */ 1809 pQuery.setParameterList("keys", 1810 Arrays.asList( new Integer[] { adKeyId, rbaKeyId }), Type.INT.getHibernateType()); 1811 List<Integer> pluginIds = HibernateUtil.loadList(Integer.class, pQuery); 1812 for (int pluginId : pluginIds) 1813 { 1814 addPluginPermission(session, pluginId, Item.PLATFORM, 0, 2046); 1815 addPluginPermission(session, pluginId, Item.DATAFILETYPE, 0, 2046); 1816 } 1817 1818 // Update the schema version number 1819 setSchemaVersion(session, schemaVersion); 1820 1821 // Commit the changes 1822 dc.commit(); 1823 log.info("updateToSchemaVersion44: OK"); 1824 } 1825 catch (BaseException ex) 1826 { 1827 log.error("updateToSchemaVersion44: FAILED", ex); 1828 throw ex; 1829 } 1830 finally 1831 { 1832 if (dc != null) dc.close(); 1833 } 1834 return schemaVersion; 1835 } 1836 1837 private static void addPluginPermission(org.hibernate.Session session, int pluginId, Item itemType, int granted, int denied) 1838 { 1839 PluginKeys pk = new PluginKeys(); 1840 pk.setPluginDefinitionId(pluginId); 1841 pk.setKeyId(SystemItems.getRoleKeyId(itemType)); 1842 if (session.get(PluginKeys.class, pk) == null) 1843 { 1844 pk.setGranted(granted); 1845 pk.setDenied(denied); 1846 session.save(pk); 1847 } 1848 } 1849 1730 1850 /** 1731 1851 Adjust the existing items in the database to be compatible with the latest mappings. … … 2062 2182 } 2063 2183 2064 if (schemaVersion < 4 2)2065 { 2066 // Set num Features to 0 for all ArrayDesign2184 if (schemaVersion < 44) 2185 { 2186 // Set numDbFeatures and numFileFeatures to 0 for all ArrayDesign 2067 2187 // Later we will count or check the CDF file. 2068 2188 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, … … 2070 2190 /* 2071 2191 UPDATE ArrayDesignData ad 2072 SET ad.numFeatures = 0 2073 WHERE ad.numFeatures IS NULL 2192 SET ad.numDbFeatures = 0, ad.numFileFeatures = 0 2193 WHERE ad.numDbFeatures IS NULL OR ad.numFileFeatures IS NULL 2194 */ 2195 HibernateUtil.executeUpdate(query); 2196 2197 // Set numFileSpots to 0 for all RawBioassays 2198 // Later we will count or check the CEL file. 2199 query = HibernateUtil.getPredefinedQuery(session, 2200 "SET_NUMFILESPOTS_ON_RAWBIOASSAY"); 2201 /* 2202 UPDATE RawBioAssayData rbd 2203 SET rbd.numFileSpots = 0 2204 WHERE rbd.numFileSpots IS NULL 2074 2205 */ 2075 2206 HibernateUtil.executeUpdate(query); -
trunk/src/core/net/sf/basedb/core/data/ArrayDesignData.java
r3741 r3820 40 40 public class ArrayDesignData 41 41 extends AnnotatedData 42 implements FileStoreEnabledData 42 43 { 43 44 public ArrayDesignData() 44 45 {} 45 46 47 /* 48 From the FileStoreEnabledData interface 49 ------------------------------------------- 50 */ 51 private FileSetData fileSet; 52 public FileSetData getFileSet() 53 { 54 return fileSet; 55 } 56 public void setFileSet(FileSetData fileSet) 57 { 58 this.fileSet = fileSet; 59 } 60 // ------------------------------------------- 61 62 private PlatformData platform; 63 /** 64 Get the platform this raw bioassay uses 65 @since 2.5 66 @hibernate.many-to-one outer-join="false" 67 @hibernate.column name="`platform_id`" not-null="true" 68 */ 69 public PlatformData getPlatform() 70 { 71 return platform; 72 } 73 public void setPlatform(PlatformData platform) 74 { 75 this.platform = platform; 76 } 77 78 private PlatformVariantData variant; 79 /** 80 Get the platform variant this raw bioassay uses, or null. 81 @since 2.5 82 @hibernate.many-to-one outer-join="false" 83 @hibernate.column name="`variant_id`" 84 */ 85 public PlatformVariantData getVariant() 86 { 87 return variant; 88 } 89 public void setVariant(PlatformVariantData variant) 90 { 91 this.variant = variant; 92 } 93 46 94 private boolean affyChip; 47 95 /** 48 96 Check if this design is an Affymetrix chip. 49 @hibernate.property column="`affy_chip`" type="boolean" not-null="true" update="false" 97 @hibernate.property column="`affy_chip`" type="boolean" not-null="true" 98 @deprecated Has been replaced by platform 50 99 */ 51 100 public boolean isAffyChip() … … 53 102 return affyChip; 54 103 } 104 /** 105 @deprecated Has been replaced by platform 106 */ 55 107 public void setAffyChip(boolean affyChip) 56 108 { … … 72 124 } 73 125 74 private int features; 75 /** 76 The number of features on this array design 77 @hibernate.property column="`features`" type="int" not-null="true" 78 */ 79 public int getNumFeatures() 80 { 81 return features; 82 } 83 public void setNumFeatures(int features) 84 { 85 this.features = features; 126 private int dbFeatures; 127 /** 128 The number of features on this array design that are stored in 129 the database. 130 @hibernate.property column="`db_features`" type="int" not-null="true" 131 @since 2.5 132 */ 133 public int getNumDbFeatures() 134 { 135 return dbFeatures; 136 } 137 public void setNumDbFeatures(int dbFeatures) 138 { 139 this.dbFeatures = dbFeatures; 140 } 141 142 private int fileFeatures; 143 /** 144 The number of features on this array design that are stored inside 145 files. 146 @hibernate.property column="`file_features`" type="int" not-null="true" 147 @since 2.5 148 */ 149 public int getNumFileFeatures() 150 { 151 return fileFeatures; 152 } 153 public void setNumFileFeatures(int fileFeatures) 154 { 155 this.fileFeatures = fileFeatures; 86 156 } 87 157 -
trunk/src/core/net/sf/basedb/core/data/RawBioAssayData.java
r3679 r3820 43 43 public class RawBioAssayData 44 44 extends AnnotatedData 45 implements DiskConsumableData 45 implements DiskConsumableData, FileStoreEnabledData 46 46 { 47 47 … … 64 64 } 65 65 // ------------------------------------------- 66 66 /* 67 From the FileStoreEnabledData interface 68 ------------------------------------------- 69 */ 70 private FileSetData fileSet; 71 public FileSetData getFileSet() 72 { 73 return fileSet; 74 } 75 public void setFileSet(FileSetData fileSet) 76 { 77 this.fileSet = fileSet; 78 } 79 // ------------------------------------------- 80 81 private PlatformData platform; 82 /** 83 Get the platform this raw bioassay uses. 84 @since 2.5 85 @hibernate.many-to-one outer-join="false" 86 @hibernate.column name="`platform_id`" not-null="true" 87 */ 88 public PlatformData getPlatform() 89 { 90 return platform; 91 } 92 public void setPlatform(PlatformData platform) 93 { 94 this.platform = platform; 95 } 96 97 private PlatformVariantData variant; 98 /** 99 Get the platform variant this raw bioassay uses, or null. 100 @since 2.5 101 @hibernate.many-to-one outer-join="false" 102 @hibernate.column name="`variant_id`" 103 */ 104 public PlatformVariantData getVariant() 105 { 106 return variant; 107 } 108 public void setVariant(PlatformVariantData variant) 109 { 110 this.variant = variant; 111 } 112 67 113 private ScanData scan; 68 114 /** … … 166 212 private int spots; 167 213 /** 168 The number of data spots in this raw bio assay. 214 The number of data spots in this raw bio assay, that 215 are stored in the database. 169 216 @hibernate.property column="`spots`" type="int" not-null="true" 217 @since 2.5 170 218 */ 171 219 public int getSpots() … … 178 226 } 179 227 228 private int fileSpots; 229 /** 230 The number of spots on this raw bioassay that are stored inside 231 files. 232 @hibernate.property column="`file_spots`" type="int" not-null="true" 233 @since 2.5 234 */ 235 public int getNumFileSpots() 236 { 237 return fileSpots; 238 } 239 public void setNumFileSpots(int fileSpots) 240 { 241 this.fileSpots = fileSpots; 242 } 243 180 244 private long bytes; 181 245 /** -
trunk/src/core/net/sf/basedb/core/data/SystemData.java
r3679 r3820 65 65 extends IdentifiableData 66 66 { 67 68 /** 69 The maximum length of the system ID of the item that can be 70 stored in the database. 71 @see #getSystemId() 72 @since 2.5 73 */ 74 public static int MAX_SYSTEM_ID_LENGTH = 255; 75 67 76 /** 68 77 Get the system id for the item. -
trunk/src/core/net/sf/basedb/core/query/Hql.java
r3679 r3820 46 46 { 47 47 48 /** 49 Log core events. 50 */ 51 private static final org.apache.log4j.Logger log = 52 org.apache.log4j.LogManager.getLogger("net.sf.basedb.core.query.Hql"); 53 54 48 55 /** 49 56 A property can only contain the characters a-zA-Z0-9 and period(.) … … 158 165 { 159 166 if (property == null && alias == null) throw new InvalidUseOfNullException("property and alias"); 160 if (property != null && !PROPERTY_REGEXP.matcher(property).matches()) 161 { 162 throw new InvalidDataException("Property '"+property+"' has one or more invalid characters. Only a-z, A-Z, 0-9 and . is allowed."); 167 if (property != null) 168 { 169 if (!PROPERTY_REGEXP.matcher(property).matches()) 170 { 171 throw new InvalidDataException("Property '"+property+"' has one or more invalid characters. Only a-z, A-Z, 0-9 and . is allowed."); 172 } 173 if (property.endsWith("affyChip")) 174 { 175 log.warn("Property 'affyChip' has been deprecated. " + 176 "Use 'platform.externalId' and compare it to Platform.AFFYMETRIX"); 177 } 163 178 } 164 179 if (alias != null && !ALIAS_REGEXP.matcher(alias).matches()) -
trunk/src/core/net/sf/basedb/util/ClassUtil.java
r3679 r3820 106 106 } 107 107 108 /** 109 Check if a specified class exists and, optionally, if it has public no-argument 110 constructor and implements a set of specific interfaces or superclasses. 111 112 @param loader The classloader used to load the class, or null 113 to use the default classloader 114 @param name The fully qualified name of class to check 115 @param publicNoArgConstructor TRUE to check if a public no-argument constructor exists 116 @param interfaces An array of class objects representing interfaces or superclasses 117 that the class to check must implement or extend 118 @return The <code>Class</code> object for the named class 119 @throws ClassNotFoundException If a class with the specified name isn't found 120 @throws NoSuchMethodException If a public no-argument constructor isn't found 121 @throws ClassCastException If the class doesn't implement or extend all of 122 the interfaces/superclasses 123 @since 2.5 124 */ 125 public static Class<?> checkAndLoadClass(ClassLoader loader, String name, 126 boolean publicNoArgConstructor, Class<?>... interfaces) 127 throws ClassNotFoundException, NoSuchMethodException, ClassCastException 128 { 129 if (loader == null) loader = ClassUtil.class.getClassLoader(); 130 Class<?> clazz = loader.loadClass(name); 131 if (publicNoArgConstructor) 132 { 133 clazz.getConstructor((Class<?>[])null); 134 } 135 if (interfaces != null) 136 { 137 for (Class<?> iFace : interfaces) 138 { 139 if (iFace != null && !iFace.isAssignableFrom(clazz)) 140 { 141 throw new ClassCastException("Class '" + name + "' is not a '" + iFace.getName() + "'"); 142 } 143 } 144 } 145 return clazz; 146 } 108 147 109 148 } -
trunk/src/core/net/sf/basedb/util/IntensityCalculatorUtil.java
r3679 r3820 197 197 if (progress != null) 198 198 { 199 progress.display((int)percent, "Mapping reporters for " + rba.get Spots() + " spots");199 progress.display((int)percent, "Mapping reporters for " + rba.getNumDbSpots() + " spots"); 200 200 percent += stepSize; 201 201 } … … 306 306 for (RawBioAssay rba : rawBioAssays) 307 307 { 308 totalSpots += rba.get Spots();308 totalSpots += rba.getNumDbSpots(); 309 309 } 310 310 interval = totalSpots / 50; -
trunk/src/plugins/core/net/sf/basedb/plugins/CdfFileReporterImporter.java
r3675 r3820 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 } -
trunk/src/plugins/core/net/sf/basedb/plugins/IlluminaRawDataImporter.java
r3675 r3820 40 40 import net.sf.basedb.core.BaseException; 41 41 import net.sf.basedb.core.BasicItem; 42 import net.sf.basedb.core.DataFileType; 42 43 import net.sf.basedb.core.DbControl; 43 44 import net.sf.basedb.core.Experiment; 45 import net.sf.basedb.core.File; 44 46 import net.sf.basedb.core.Include; 45 47 import net.sf.basedb.core.InvalidDataException; … … 50 52 import net.sf.basedb.core.Job; 51 53 import net.sf.basedb.core.Permission; 54 import net.sf.basedb.core.Platform; 52 55 import net.sf.basedb.core.PluginParameter; 53 56 import net.sf.basedb.core.Protocol; … … 380 383 protected void beginData() 381 384 { 385 File rawDataFile = (File)job.getValue("file"); 382 386 this.dc = sc.newDbControl(); 383 387 try 384 388 { 385 this.rawBioAssays = extractAndCreateRawBioAssays(dc, ffp.getColumnHeaders(), verifyColumns );389 this.rawBioAssays = extractAndCreateRawBioAssays(dc, ffp.getColumnHeaders(), verifyColumns, rawDataFile); 386 390 // We must commit to be able to insert raw data 387 391 // In case of a later failure the end() method should delete the raw bioassays again … … 452 456 { 453 457 if (experiment != null) experiment = Experiment.getById(dc, experiment.getId()); 458 DataFileType rawDataType = DataFileType.getByExternalId(dc, DataFileType.GENERIC_RAW_DATA); 454 459 for (BatchAndMapHolder holder : holders) 455 460 { … … 459 464 experiment.addRawBioAssay(holder.rba); 460 465 } 466 holder.rba.getFileSet().getMember(rawDataType).setValid(true, null); 461 467 } 462 468 dc.commit(); … … 499 505 error. 500 506 */ 501 private List<RawBioAssay> extractAndCreateRawBioAssays(DbControl dc, List<String> headers, boolean verifyColumns) 502 { 507 private List<RawBioAssay> extractAndCreateRawBioAssays(DbControl dc, List<String> headers, 508 boolean verifyColumns, File rawDataFile) 509 { 510 // Holds the created raw bioassays 503 511 List<RawBioAssay> list = new LinkedList<RawBioAssay>(); 512 // Load the generic raw data file type 513 DataFileType rawDataType = DataFileType.getByExternalId(dc, DataFileType.GENERIC_RAW_DATA); 504 514 // Maps: array name -> set of extended property names 505 515 Map<String, Set<String>> arrayNames = new HashMap<String, Set<String>>(); … … 528 538 { 529 539 arrayNames.put(arrayName, new HashSet<String>()); 530 RawBioAssay rba = RawBioAssay.getNew(dc, illumina); 540 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 541 RawBioAssay rba = RawBioAssay.getNew(dc, generic, illumina); 531 542 rba.setName(arrayName); 532 543 if (scan != null) rba.setScan(scan); 533 544 if (protocol != null) rba.setProtocol(protocol); 534 545 if (software != null) rba.setSoftware(software); 546 if (rawDataFile != null) rba.getFileSet().setMember(rawDataFile, rawDataType); 535 547 for (Line headerLine : headerLines) 536 548 { -
trunk/src/plugins/core/net/sf/basedb/plugins/IntensityCalculatorPlugin.java
r3679 r3820 365 365 "' is not part of the experiment '" + experiment.getName()+"'"); 366 366 } 367 numSpots += rba.get Spots();367 numSpots += rba.getNumDbSpots(); 368 368 } 369 369 } -
trunk/src/plugins/core/net/sf/basedb/plugins/PrintMapFlatFileImporter.java
r3679 r3820 30 30 import net.sf.basedb.core.BaseException; 31 31 import net.sf.basedb.core.BlockInfo; 32 import net.sf.basedb.core.DataFileType; 32 33 import net.sf.basedb.core.DbControl; 33 34 import net.sf.basedb.core.FeatureBatcher; 35 import net.sf.basedb.core.File; 36 import net.sf.basedb.core.FileParameterType; 37 import net.sf.basedb.core.FileSetMember; 38 import net.sf.basedb.core.FileStoreUtil; 34 39 import net.sf.basedb.core.FileType; 35 40 import net.sf.basedb.core.IntegerUtil; … … 122 127 123 128 private ArrayDesign arrayDesign; 129 private FileSetMember printMapMember; 124 130 private ItemParameterType<ArrayDesign> arrayDesignType; 125 131 private PluginParameter<ArrayDesign> arrayDesignParameter; … … 150 156 } 151 157 /** 152 Request write access to ArrayDesign:s, read access to Plate:s, Reporter:s 153 and File:s.158 Request write access to ArrayDesign:s, read access to Plate:s, Reporter:s, 159 DataFileType:s, Platform:s and File:s. 154 160 */ 155 161 public Collection<Permissions> getPermissions() … … 161 167 permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ))); 162 168 permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ))); 169 permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ))); 170 permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ))); 163 171 } 164 172 return permissions; … … 188 196 { 189 197 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())198 if (ad.isFileOnlyPlatform()) 199 { 200 message = "Array design is using a file-only platform"; 201 } 202 else if (ad.getNumDbFeatures() > 0) 195 203 { 196 204 throw new PermissionDeniedException("The array design already has features"); … … 301 309 arrayDesign = (ArrayDesign)job.getValue("arrayDesign"); 302 310 arrayDesign = ArrayDesign.getById(dc, arrayDesign.getId()); 303 if (arrayDesign.hasFeatures()) 311 File reporterMapFile = (File)job.getValue("file"); 312 printMapMember = FileStoreUtil.setGenericDataFile(dc, arrayDesign, 313 FileType.PRINT_MAP, DataFileType.GENERIC_PRINT_MAP, reporterMapFile); 314 if (arrayDesign.getNumDbFeatures() > 0) 304 315 { 305 316 throw new PermissionDeniedException("The array design already has features: " + arrayDesign.getName()+" ["+arrayDesign.getId()+"]"); … … 447 458 throws BaseException 448 459 { 460 if (printMapMember != null) printMapMember.setValid(success, null); 449 461 if (blocks != null) blocks.clear(); 450 462 try … … 503 515 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 504 516 parameters.add(arrayDesignParameter); 517 518 ArrayDesign design = null; 519 int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId(); 520 List<File> printMapFiles = null; 521 dc = sc.newDbControl(); 522 try 523 { 524 design = ArrayDesign.getById(dc, currentArrayDesignId); 525 printMapFiles = FileStoreUtil.getGenericDataFiles(dc, design, FileType.PRINT_MAP); 526 } 527 catch (Throwable t) 528 {} 529 finally 530 { 531 if (dc != null) dc.close(); 532 } 533 534 // The print map file to import from - if a file already hase 535 // been attached to the array design use it as a default choice 536 PluginParameter<File> fileParameter = new PluginParameter<File>( 537 "file", 538 "Print map file", 539 "The file with printing information to import features from", 540 new FileParameterType(printMapFiles == null || printMapFiles.isEmpty() ? 541 null : printMapFiles.get(0), true, 1) 542 ); 505 543 parameters.add(fileParameter); 506 544 parameters.add(getCharsetParameter(null, null, null)); -
trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java
r3679 r3820 26 26 27 27 import net.sf.basedb.core.BaseException; 28 import net.sf.basedb.core.DataFileType; 28 29 import net.sf.basedb.core.DbControl; 30 import net.sf.basedb.core.File; 31 import net.sf.basedb.core.FileParameterType; 32 import net.sf.basedb.core.FileSetMember; 33 import net.sf.basedb.core.FileStoreUtil; 29 34 import net.sf.basedb.core.FileType; 30 35 import net.sf.basedb.core.Item; … … 215 220 private RawDataBatcher batcher; 216 221 private RawBioAssay rawBioAssay; 217 222 private FileSetMember rawDataMember; 223 218 224 private Mapper reporterMapper; 219 225 private Mapper blockMapper; … … 243 249 } 244 250 /** 245 Request write access to RawBioAssay:s and read access to ArrayDesign:s, File:s 246 and Reporter:s.251 Request write access to RawBioAssay:s and read access to ArrayDesign:s, File:s, 252 Reporter:s, Platform:s and DataFileType:s 247 253 */ 248 254 public Collection<Permissions> getPermissions() … … 254 260 permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ))); 255 261 permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ))); 262 permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ))); 263 permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ))); 256 264 } 257 265 return permissions; … … 297 305 message = "Raw data for raw data type '" + rdt + "' is not stored in the database"; 298 306 } 299 else if (rba. hasData())307 else if (rba.getNumDbSpots() > 0) 300 308 { 301 309 throw new PermissionDeniedException("The raw bioassay already has data."); … … 450 458 dc = sc.newDbControl(); 451 459 rawBioAssay = (RawBioAssay)job.getValue("rawBioAssay"); 452 dc.reattachItem(rawBioAssay); 460 File rawDataFile = (File)job.getValue("file"); 461 rawBioAssay = RawBioAssay.getById(dc, rawBioAssay.getId()); 462 rawDataMember = FileStoreUtil.setGenericDataFile(dc, rawBioAssay, 463 FileType.RAW_DATA, DataFileType.GENERIC_RAW_DATA, rawDataFile); 464 453 465 batcher = rawBioAssay.getRawDataBatcher(); 454 466 numInserted = 0; … … 514 526 throws BaseException 515 527 { 528 if (rawDataMember != null) rawDataMember.setValid(success, null); 529 516 530 try 517 531 { … … 630 644 ); 631 645 parameters.add(rawBioAssayParameter); 632 parameters.add(fileParameter); 646 647 RawBioAssay rba = null; 648 int currentRawBioAssayId = sc.getCurrentContext(Item.RAWBIOASSAY).getId(); 649 List<File> rawDataFiles = null; 650 dc = sc.newDbControl(); 651 try 652 { 653 rba = RawBioAssay.getById(dc, currentRawBioAssayId); 654 rawDataFiles = FileStoreUtil.getGenericDataFiles(dc, rba, FileType.RAW_DATA); 655 } 656 catch (Throwable t) 657 {} 658 finally 659 { 660 if (dc != null) dc.close(); 661 } 662 663 // The raw data file to import from - if a file already hase 664 // been attached to the raw bioassay use it as a default choice 665 PluginParameter<File> fileParameter = new PluginParameter<File>( 666 "file", 667 "Raw data file", 668 "The file that contains the raw data that you want to import", 669 new FileParameterType(rawDataFiles == null || rawDataFiles.isEmpty() ? 670 null : rawDataFiles.get(0), true, 1) 671 ); 672 parameters.add(fileParameter); 633 673 parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET))); 634 674 parameters.add(getDecimalSeparatorParameter(null, null, (String)configuration.getValue(DECIMAL_SEPARATOR))); -
trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java
r3679 r3820 30 30 import net.sf.basedb.core.BaseException; 31 31 import net.sf.basedb.core.BlockInfo; 32 import net.sf.basedb.core.DataFileType; 32 33 import net.sf.basedb.core.DbControl; 33 34 import net.sf.basedb.core.FeatureBatcher; 35 import net.sf.basedb.core.File; 36 import net.sf.basedb.core.FileParameterType; 37 import net.sf.basedb.core.FileSetMember; 38 import net.sf.basedb.core.FileStoreUtil; 34 39 import net.sf.basedb.core.FileType; 35 40 import net.sf.basedb.core.InvalidUseOfNullException; … … 173 178 private FeatureBatcher batcher; 174 179 private ReporterBatcher reporterBatcher; 180 private FileSetMember reporterMapMember; 175 181 private ArrayDesign arrayDesign; 176 182 private Map<BlockInfo, ArrayDesignBlock> blocks; … … 216 222 } 217 223 /** 218 Request write access to ArrayDesign:s, read access to Reporter:s 219 and File:s.224 Request write access to ArrayDesign:s, read access to Reporter:s, 225 DataFileType:s, Platform:s and File:s. 220 226 */ 221 227 public Collection<Permissions> getPermissions() … … 226 232 permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ))); 227 233 permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ))); 234 permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ))); 235 permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ))); 228 236 } 229 237 return permissions; … … 263 271 { 264 272 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())273 if (ad.isFileOnlyPlatform()) 274 { 275 message = "Array design is using a file-only platform"; 276 } 277 else if (ad.getNumDbFeatures() > 0) 270 278 { 271 279 throw new PermissionDeniedException("The array design already has features"); … … 398 406 dc = sc.newDbControl(); 399 407 arrayDesign = (ArrayDesign)job.getValue("arrayDesign"); 400 dc.reattachItem(arrayDesign); 401 if (arrayDesign.hasFeatures()) 408 File reporterMapFile = (File)job.getValue("file"); 409 arrayDesign = ArrayDesign.getById(dc, arrayDesign.getId()); 410 reporterMapMember = FileStoreUtil.setGenericDataFile(dc, arrayDesign, 411 FileType.REPORTER_MAP, DataFileType.GENERIC_REPORTER_MAP, reporterMapFile); 412 if (arrayDesign.getNumDbFeatures() > 0) 402 413 { 403 414 throw new PermissionDeniedException("The array design already has features. "+arrayDesign.getName()+"["+arrayDesign.getId()+"]"); … … 486 497 { 487 498 if (blocks != null) blocks.clear(); 499 if (reporterMapMember != null) reporterMapMember.setValid(success, null); 488 500 try 489 501 { … … 542 554 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 543 555 parameters.add(arrayDesignParameter); 556 557 ArrayDesign design = null; 558 int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId(); 559 List<File> reporterMapFiles = null; 560 dc = sc.newDbControl(); 561 try 562 { 563 design = ArrayDesign.getById(dc, currentArrayDesignId); 564 reporterMapFiles = FileStoreUtil.getGenericDataFiles(dc, design, FileType.REPORTER_MAP); 565 } 566 catch (Throwable t) 567 {} 568 finally 569 { 570 if (dc != null) dc.close(); 571 } 572 573 // The reporter map file to import from - if a file already hase 574 // been attached to the array design use it as a default choice 575 PluginParameter<File> fileParameter = new PluginParameter<File>( 576 "file", 577 "Reporter map file", 578 "The file with reporter information to import features from", 579 new FileParameterType(reporterMapFiles == null || reporterMapFiles.isEmpty() ? 580 null : reporterMapFiles.get(0), true, 1) 581 ); 544 582 parameters.add(fileParameter); 545 583 parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET))); -
trunk/src/test/TestAll.java
r3700 r3820 102 102 results.put("TestPlateMapping", TestPlateMapping.test_all()); 103 103 104 // Experimental platforms and data file types 105 results.put("TestDataFileType", TestDataFileType.test_all()); 106 results.put("TestPlatform", TestPlatform.test_all()); 107 104 108 // Array LIMS -- Arrays 105 109 results.put("TestArrayDesign", TestArrayDesign.test_all()); 106 // results.put("TestAffyChip", TestAffyChip.test_all());107 110 results.put("TestArrayBatch", TestArrayBatch.test_all()); 108 111 results.put("TestArraySlide", TestArraySlide.test_all()); -
trunk/src/test/TestAnalyzePluginUtil.java
r3679 r3820 31 31 import net.sf.basedb.core.Item; 32 32 import net.sf.basedb.core.Permission; 33 import net.sf.basedb.core.Platform; 33 34 import net.sf.basedb.core.RawBioAssay; 34 35 import net.sf.basedb.core.RawDataBatcher; … … 59 60 for (int i = 0; i < rawBioAssays; i++) 60 61 { 61 int rawBioAssayId = TestRawBioAssay.test_create( "genepix", 0, 0, 0, 0, false);62 int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, 0, false); 62 63 63 64 FlatFileParser parser = new FlatFileParser(); -
trunk/src/test/TestAnnotation.java
r3789 r3820 61 61 int booleanId = TestAnnotationType.test_create(null, Type.BOOLEAN, true, null, Item.ARRAYDESIGN, 1, null, true); 62 62 int enumId = TestAnnotationType.test_create(null, Type.INT, 3, null, Item.ARRAYDESIGN, 1, new Object[] { 1, 2, 3, 4, 5 }, false); 63 int arrayDesignId = TestArrayDesign.test_create( true, false);63 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, true); 64 64 65 65 // Annotate the array design and list the annotations … … 76 76 77 77 // Test: inherit annotations 78 int rawBioAssayId = TestRawBioAssay.test_create( "genepix", 0, 0, 0, arrayDesignId, false);78 int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false); 79 79 test_inherit_annotation(rawBioAssayId, intAnnotationId); 80 80 test_inherit_annotation(rawBioAssayId, stringAnnotationId); -
trunk/src/test/TestArrayBatch.java
r3679 r3820 34 34 import net.sf.basedb.core.ItemQuery; 35 35 import net.sf.basedb.core.ItemResultList; 36 import net.sf.basedb.core.Platform; 36 37 37 38 public class TestArrayBatch … … 52 53 write_header(); 53 54 // Standard tests: create, load, list 54 int arraydesign_id = TestArrayDesign.test_create( false, false);55 int arraydesign_id = TestArrayDesign.test_create(Platform.GENERIC, false); 55 56 int id = test_create(arraydesign_id, true); 56 57 int id2 = test_create(arraydesign_id, false); -
trunk/src/test/TestArrayDesign.java
r3679 r3820 31 31 import net.sf.basedb.core.Feature; 32 32 import net.sf.basedb.core.FeatureBatcher; 33 import net.sf.basedb.core.File; 34 import net.sf.basedb.core.FileSetMember; 35 import net.sf.basedb.core.DataFileType; 33 36 import net.sf.basedb.core.Item; 34 37 import net.sf.basedb.core.Permission; … … 36 39 import net.sf.basedb.core.DataResultIterator; 37 40 import net.sf.basedb.core.Plate; 41 import net.sf.basedb.core.Platform; 38 42 import net.sf.basedb.core.Reporter; 39 43 import net.sf.basedb.core.ReporterBatcher; … … 66 70 write_header(); 67 71 // Standard tests: create, load, list 68 int id = test_create( true, false);69 int id2 = test_create( false, false);70 int id3 = test_create( true, true);71 int id4 = test_create( false, true);72 int id = test_create(Platform.GENERIC, true); 73 int id2 = test_create(Platform.GENERIC, false); 74 int id3 = test_create(Platform.AFFYMETRIX, true); 75 int id4 = test_create(Platform.AFFYMETRIX, false); 72 76 test_load(id); 73 77 test_list(-1); … … 90 94 int[] plateIds = TestPlate.test_import_from_file("data/test.plate96.import.txt", 91 95 "Plate\\tRow\\tColumn\\tCluster ID\\tClone ID\\tGene Symbol\\tBarcode", plateType, 0, 1, 2, 4); 92 int id5 = test_create( false, false);96 int id5 = test_create(Platform.GENERIC, false); 93 97 test_add_plates(id5, plateIds); 94 98 … … 98 102 test_add_features_from_wells(id5, plateIds, 10); 99 103 104 // Array designs with data in files 105 int cdfId = TestFile.test_create("data/test.affymetrix.cdf", false, false); 106 test_set_file(id3, DataFileType.AFFYMETRIX_CDF, cdfId); 107 test_list_files(id3, 1); 108 100 109 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); 101 110 // Standard test: Delete … … 109 118 TestPlateType.test_delete(plateType); 110 119 TestPlateGeometry.test_delete(plateGeometry); 111 120 TestFile.test_delete(cdfId); 112 121 TestReporter.test_delete(); 113 122 … … 116 125 } 117 126 118 static int test_create( boolean setAll, boolean affyChip)127 static int test_create(String platformId, boolean setAll) 119 128 { 120 129 if (!TestUtil.hasPermission(Permission.CREATE, Item.ARRAYDESIGN)) return 0; … … 124 133 { 125 134 dc = TestUtil.getDbControl(); 126 ArrayDesign ad = ArrayDesign.getNew(dc, affyChip); 135 Platform platform = Platform.getByExternalId(dc, platformId); 136 ArrayDesign ad = ArrayDesign.getNew(dc, platform); 127 137 if (setAll) 128 138 { … … 133 143 dc.commit(); 134 144 id = ad.getId(); 145 dc = TestUtil.getDbControl(); 146 dc.reattachItem(ad); 135 147 write_item(0, ad); 136 148 write("--Create array design OK"); … … 260 272 if (!TestUtil.getSilent()) 261 273 { 262 write(i+":\t"+ad.getId()+"\t"+ad.getName()+"\t"+ad.getDescription()+"\t"+ad.isAnnotated()+"\t"+ad. isAffyChip());274 write(i+":\t"+ad.getId()+"\t"+ad.getName()+"\t"+ad.getDescription()+"\t"+ad.isAnnotated()+"\t"+ad.getPlatform()); 263 275 } 264 276 } … … 282 294 } 283 295 296 static void write_item(int i, FileSetMember member) 297 throws BaseException 298 { 299 if (!TestUtil.getSilent()) 300 { 301 System.out.println(i+":\t"+member.getId()+"\t"+member.getFile().getName()+"\t"+ 302 member.getDataFileType().getName()); 303 } 304 } 305 284 306 static void write(String message) 285 307 { … … 363 385 dc = TestUtil.getDbControl(); 364 386 ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId); 365 if ( ad.isAffyChip())387 if (Platform.AFFYMETRIX.equals(ad.getPlatform().getExternalId())) 366 388 { 367 389 throw new BaseException("Cannot add features from wells on an affy arraydesign"); … … 434 456 } 435 457 dc.commit(); 436 write_item(0, ad);437 458 write("--Add plates to array design OK"); 438 459 } … … 574 595 } 575 596 597 static void test_set_file(int arrayDesignId, String fileType, int fileId) 598 { 599 if (arrayDesignId == 0 || fileId == 0) return; 600 DbControl dc = null; 601 try 602 { 603 dc = TestUtil.getDbControl(); 604 ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId); 605 DataFileType type = DataFileType.getByExternalId(dc, fileType); 606 File file = File.getById(dc, fileId); 607 ad.getFileSet().setMember(file, type); 608 ad.getFileSet().validate(dc, true); 609 dc.commit(); 610 write("--Set file OK ("+fileType+")"); 611 } 612 catch (Throwable ex) 613 { 614 write("--Set file FAILED ("+fileType+")"); 615 ex.printStackTrace(); 616 ok = false; 617 } 618 finally 619 { 620 if (dc != null) dc.close(); 621 } 622 } 623 624 static void test_list_files(int arrayDesignId, int expectedResults) 625 { 626 if (arrayDesignId == 0) return; 627 DbControl dc = null; 628 try 629 { 630 dc = TestUtil.getDbControl(); 631 ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId); 632 ItemResultList<FileSetMember> l = ad.getFileSet().getMembers().list(dc); 633 for (int i = 0; i<l.size(); i++) 634 { 635 write_item(i, l.get(i)); 636 } 637 if (expectedResults >= 0 && expectedResults != l.size()) 638 { 639 throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); 640 } 641 write("--List files OK ("+l.size()+")"); 642 } 643 catch (Throwable ex) 644 { 645 write("--List files FAILED"); 646 ex.printStackTrace(); 647 ok = false; 648 } 649 finally 650 { 651 if (dc != null) dc.close(); 652 } 653 } 576 654 } 577 655 -
trunk/src/test/TestArrayDesignBlock.java
r3679 r3820 30 30 import net.sf.basedb.core.DbControl; 31 31 import net.sf.basedb.core.ItemResultList; 32 import net.sf.basedb.core.Platform; 32 33 33 34 … … 55 56 write("++Testing array design block"); 56 57 write_header(); 57 int arrayDesignId = TestArrayDesign.test_create( false, false);58 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 58 59 // Standard tests: create, load, list 59 60 int nbr = 10; -
trunk/src/test/TestArraySlide.java
r3679 r3820 9 9 import net.sf.basedb.core.ItemQuery; 10 10 import net.sf.basedb.core.ItemResultList; 11 import net.sf.basedb.core.Platform; 11 12 12 13 /* … … 50 51 write_header(); 51 52 // Standard tests: create, load, list 52 int arraydesign_id = TestArrayDesign.test_create( true, false);53 int arraydesign_id = TestArrayDesign.test_create(Platform.GENERIC, true); 53 54 int arraybatch_id = TestArrayBatch.test_create(arraydesign_id, false); 54 55 int id = test_create(arraybatch_id, true); -
trunk/src/test/TestBioAsssaySetExporter.java
r3675 r3820 12 12 import net.sf.basedb.core.Item; 13 13 import net.sf.basedb.core.ItemQuery; 14 import net.sf.basedb.core.Platform; 14 15 import net.sf.basedb.core.RawBioAssay; 15 16 import net.sf.basedb.core.RawDataBatcher; … … 277 278 { 278 279 dc = TestUtil.getDbControl(); 279 RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix")); 280 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 281 RawBioAssay rba = RawBioAssay.getNew(dc, generic, RawDataTypes.getRawDataType("genepix")); 280 282 AnnotationType at = AnnotationType.getById(dc, annotationTypeId); 281 283 -
trunk/src/test/TestDirty.java
r3719 r3820 73 73 74 74 // Test import raw data 75 int arrayDesignId = TestArrayDesign.test_create( false, false);75 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 76 76 TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.import.dirty.txt", 77 77 "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", 0, 2, 1, 4); 78 78 79 int rawBioAssayId = TestRawBioAssay.test_create( "genepix", 0, 0, 0, arrayDesignId, false);79 int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false); 80 80 int fileId = TestFile.test_create("data/test.import.dirty.txt", false, false); 81 81 … … 92 92 TestJob.test_delete(jobId); 93 93 TestPluginConfiguration.test_delete(pluginConfigurationId); 94 TestFile.test_delete(fileId);95 94 TestRawBioAssay.test_delete(rawBioAssayId); 96 95 TestArrayDesign.test_delete(arrayDesignId); 96 TestFile.test_delete(fileId); 97 97 TestReporter.test_delete(); 98 98 write("++Testing import of dirty data "+(ok ? "OK" : "Failed")+"\n"); -
trunk/src/test/TestExperiment.java
r3679 r3820 78 78 "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3); 79 79 80 int arrayDesignId = TestArrayDesign.test_create( false, false);80 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 81 81 TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.rawdata.import.txt", 82 82 "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", 0, 2, 1, 4); 83 83 84 int rbaId1 = TestRawBioAssay.test_create( "genepix", 0, 0, 0, arrayDesignId, false);85 int rbaId2 = TestRawBioAssay.test_create( "genepix", 0, 0, 0, arrayDesignId, false);84 int rbaId1 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false); 85 int rbaId2 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false); 86 86 TestRawBioAssay.test_import_from_file(rbaId1, "data/test.rawdata.import.txt"); 87 87 TestRawBioAssay.test_import_from_file(rbaId2, "data/test.rawdata.import.txt"); … … 293 293 { 294 294 System.out.println(i+":\t"+rba.getId()+"\t"+rba.getName()+"\t"+rba.getDescription()+ 295 "\t"+rba.getRawDataType().getName()+"\t"+rba.get Spots()+"\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+295 "\t"+rba.getRawDataType().getName()+"\t"+rba.getNumDbSpots()+"\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+ 296 296 "\t"+rba.getSoftware()+"\t"+rba.getProtocol()); 297 297 } -
trunk/src/test/TestHybridization.java
r3679 r3820 48 48 test_load(id); 49 49 50 int arrayDesignId = TestArrayDesign.test_create( false, false);50 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 51 51 int arrayBatchId = TestArrayBatch.test_create(arrayDesignId, false); 52 52 int arraySlideId = TestArraySlide.test_create(arrayBatchId, false); -
trunk/src/test/TestPrintMapFlatFileImporter.java
r3719 r3820 9 9 import net.sf.basedb.core.ParameterType; 10 10 import net.sf.basedb.core.Permission; 11 import net.sf.basedb.core.Platform; 11 12 import net.sf.basedb.core.PluginConfigurationRequest; 12 13 import net.sf.basedb.core.PluginDefinition; … … 63 64 64 65 // Create ArrayDesign needed for print map import 65 int arrayDesignId = TestArrayDesign.test_create( false, false);66 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 66 67 int plateGeometryId = TestPlateGeometry.test_create(16, 24, false); 67 68 int plateTypeId = TestPlateType.test_create(plateGeometryId, false); -
trunk/src/test/TestProject.java
r3679 r3820 100 100 { 101 101 dc = TestUtil.getDbControl(); 102 int adId = TestArrayDesign.test_create( false, false);102 int adId = TestArrayDesign.test_create(Platform.GENERIC, false); 103 103 ArrayDesign ad = ArrayDesign.getById(dc, adId); 104 104 Project p = Project.getById(dc, id); -
trunk/src/test/TestRawBioAssay.java
r3679 r3820 53 53 int hybridizationId = TestHybridization.test_create(0, false); 54 54 int scanId = TestScan.test_create(hybridizationId, 0, 0, false); 55 int arrayDesignId = TestArrayDesign.test_create( false, false);55 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 56 56 TestReporter.test_import_from_file("data/test.rawdata.import.txt", 57 57 "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3); … … 62 62 63 63 // Standard tests: create, load, list 64 int id = test_create("genepix", scanId, softwareId, protocolId, arrayDesignId, true); 65 int id2 = test_create("genepix", 0, 0, 0, 0, false); 64 int id = test_create(Platform.GENERIC, "genepix", scanId, softwareId, protocolId, arrayDesignId, true); 65 int id2 = test_create(Platform.GENERIC, "genepix", 0, 0, 0, 0, false); 66 int id3 = test_create(Platform.AFFYMETRIX, null, 0, 0, 0, 0, false); 66 67 67 68 test_load(id); 68 69 69 // Test adding raw data 70 70 // Test adding raw data -- stored in database 71 71 test_add_rawdata(id2, 10); 72 72 test_import_from_file(id, "data/test.rawdata.import.txt"); 73 74 73 test_load(id); 75 76 74 test_list(-1); 77 75 write_raw_data_header(); 78 76 test_list_raw_data(id, 10, 5, 0, true); 79 77 78 // Test adding raw data -- stored in files 79 int celId = TestFile.test_create("data/test.affymetrix.cel", false, false); 80 test_set_file(id3, "affymetrix.cel", celId); 81 test_list_files(id3, 1); 82 test_list_file_types(id3, 1); 83 80 84 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); 81 85 test_delete_raw_data(id); … … 84 88 test_delete(id); 85 89 test_delete(id2); 86 90 test_delete(id3); 91 92 TestFile.test_delete(celId); 87 93 TestScan.test_delete(scanId); 88 94 TestHybridization.test_delete(hybridizationId); … … 95 101 } 96 102 97 static int test_create(String rawDataType, int scanId, int softwareId, int protocolId, int arrayDesignId, boolean setAll)103 static int test_create(String platformId, String rawDataType, int scanId, int softwareId, int protocolId, int arrayDesignId, boolean setAll) 98 104 { 99 105 if (!TestUtil.hasPermission(Permission.CREATE, Item.RAWBIOASSAY)) return 0; … … 103 109 { 104 110 dc = TestUtil.getDbControl(); 105 RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType(rawDataType)); 111 Platform platform = Platform.getByExternalId(dc, platformId); 112 RawBioAssay rba = RawBioAssay.getNew(dc, platform, RawDataTypes.getRawDataType(rawDataType)); 106 113 if (setAll) 107 114 { … … 234 241 if (!TestUtil.getSilent()) 235 242 { 236 write(" \tID \tName \tDescription\tData type\t Spots\tBytes\tArray Design\tSoftware\tProtocol");237 write("-- \t-- \t--------- \t-----------\t---------\t----- \t-----\t------------\t--------\t--------");243 write(" \tID \tName \tDescription\tData type\tDb spots\tFile spots\tBytes\tArray Design\tSoftware\tProtocol"); 244 write("-- \t-- \t--------- \t-----------\t---------\t--------\t-----------\t-----\t------------\t--------\t--------"); 238 245 } 239 246 } … … 252 259 { 253 260 System.out.println(i+":\t"+rba.getId()+"\t"+rba.getName()+"\t"+rba.getDescription()+ 254 "\t"+rba.getRawDataType().getName()+"\t"+rba.getSpots()+"\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+ 261 "\t"+rba.getRawDataType().getName()+"\t"+rba.getNumDbSpots()+"\t"+rba.getNumFileSpots() + 262 "\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+ 255 263 "\t"+rba.getSoftware()+"\t"+rba.getProtocol()); 256 264 } … … 268 276 } 269 277 } 278 279 static void write_item(int i, FileSetMember member) 280 throws BaseException 281 { 282 if (!TestUtil.getSilent()) 283 { 284 System.out.println(i+":\t"+member.getId()+"\t"+member.getFile().getName()+"\t"+ 285 member.getDataFileType().getName()); 286 } 287 } 288 289 static void write_item(int i, DataFileType type) 290 throws BaseException 291 { 292 if (!TestUtil.getSilent()) 293 { 294 System.out.println(i+":\t"+type.getId()+"\t"+type.getName()+"\t"+ 295 type.getDescription()); 296 } 297 } 298 270 299 271 300 static void write(String message) … … 500 529 } 501 530 531 static void test_set_file(int rawBioAssayId, String fileType, int fileId) 532 { 533 if (rawBioAssayId == 0 || fileId == 0) return; 534 DbControl dc = null; 535 try 536 { 537 dc = TestUtil.getDbControl(); 538 RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); 539 DataFileType type = DataFileType.getByExternalId(dc, fileType); 540 File file = File.getById(dc, fileId); 541 rba.getFileSet().setMember(file, type); 542 dc.commit(); 543 write("--Set file OK ("+fileType+")"); 544 } 545 catch (Throwable ex) 546 { 547 write("--Set file FAILED ("+fileType+")"); 548 ex.printStackTrace(); 549 ok = false; 550 } 551 finally 552 { 553 if (dc != null) dc.close(); 554 } 555 } 556 557 static void test_list_files(int rawBioAssayId, int expectedResults) 558 { 559 if (rawBioAssayId == 0) return; 560 DbControl dc = null; 561 try 562 { 563 dc = TestUtil.getDbControl(); 564 RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); 565 ItemResultList<FileSetMember> l = rba.getFileSet().getMembers().list(dc); 566 for (int i = 0; i<l.size(); i++) 567 { 568 write_item(i, l.get(i)); 569 } 570 if (expectedResults >= 0 && expectedResults != l.size()) 571 { 572 throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); 573 } 574 write("--List files OK ("+l.size()+")"); 575 } 576 catch (Throwable ex) 577 { 578 write("--List files FAILED"); 579 ex.printStackTrace(); 580 ok = false; 581 } 582 finally 583 { 584 if (dc != null) dc.close(); 585 } 586 } 587 588 static void test_list_file_types(int rawBioAssayId, int expectedResults) 589 { 590 if (rawBioAssayId == 0) return; 591 DbControl dc = null; 592 try 593 { 594 dc = TestUtil.getDbControl(); 595 RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); 596 ItemResultList<DataFileType> l = rba.getFileSet().getMemberTypes().list(dc); 597 for (int i = 0; i<l.size(); i++) 598 { 599 write_item(i, l.get(i)); 600 } 601 if (expectedResults >= 0 && expectedResults != l.size()) 602 { 603 throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); 604 } 605 write("--List file types OK ("+l.size()+")"); 606 } 607 catch (Throwable ex) 608 { 609 write("--List file types FAILED"); 610 ex.printStackTrace(); 611 ok = false; 612 } 613 finally 614 { 615 if (dc != null) dc.close(); 616 } 617 } 502 618 } -
trunk/src/test/TestRawDataFlatFileImporter.java
r3719 r3820 45 45 TestReporter.test_import_from_file("data/test.rawdata.import.txt", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3); 46 46 int fileId = TestFile.test_create("data/test.rawdata.import.txt", false, false); 47 int arrayDesignId = TestArrayDesign.test_create( false, false);47 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 48 48 TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.rawdata.import.txt", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", 0, 2, 1, 4); 49 int rawBioAssayId = TestRawBioAssay.test_create( "genepix", 0, 0, 0, arrayDesignId, true);49 int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, true); 50 50 51 51 // Create plugin configuration and job -
trunk/src/test/TestReporterMapFlatFileImporter.java
r3719 r3820 32 32 import net.sf.basedb.core.ParameterType; 33 33 import net.sf.basedb.core.Permission; 34 import net.sf.basedb.core.Platform; 34 35 import net.sf.basedb.core.PluginConfiguration; 35 36 import net.sf.basedb.core.PluginDefinition; … … 61 62 // Create reporter type and upload file 62 63 int reporterTypeId = TestReporterType.test_create(); 63 int arrayDesignId = TestArrayDesign.test_create( false, false);64 int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); 64 65 int fileId = TestFile.test_create("data/test.reportermap.import.txt", false, false); 65 66 -
trunk/src/test/TestSpotImages.java
r3719 r3820 61 61 write("++Testing spot images import"); 62 62 63 int rawBioAssayId = TestRawBioAssay.test_create( "genepix", 0, 0, 0, 0, false);63 int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, 0, false); 64 64 TestReporter.test_import_from_file("data/test.rawdata.import.txt", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3); 65 65 TestRawBioAssay.test_import_from_file(rawBioAssayId, "data/test.rawdata.import.txt"); -
trunk/src/test/net/sf/basedb/test/merge/MergeTest.java
r2938 r3820 46 46 import net.sf.basedb.core.Job; 47 47 import net.sf.basedb.core.MappingBatcher; 48 import net.sf.basedb.core.Platform; 48 49 import net.sf.basedb.core.PluginDefinition; 49 50 import net.sf.basedb.core.PositionBatcher; … … 104 105 // Array design 105 106 dc = TestUtil.getDbControl(); 106 ArrayDesign design = createArrayDesign(dc, "Array design for merge test"); 107 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 108 ArrayDesign design = createArrayDesign(dc, generic, "Array design for merge test"); 107 109 dc.commit(); 108 110 … … 113 115 // Raw bioassays 114 116 dc = TestUtil.getDbControl(); 115 RawBioAssay rba1 = createRawBioAssay(dc, "Raw bioassay for merge test #1", design); 116 RawBioAssay rba2 = createRawBioAssay(dc, "Raw bioassay for merge test #2", design); 117 RawDataType genepix = RawDataTypes.getRawDataType("genepix"); 118 RawBioAssay rba1 = createRawBioAssay(dc, generic, genepix, "Raw bioassay for merge test #1", design); 119 RawBioAssay rba2 = createRawBioAssay(dc, generic, genepix, "Raw bioassay for merge test #2", design); 117 120 dc.commit(); 118 121 … … 182 185 Create an array design. 183 186 */ 184 public static ArrayDesign createArrayDesign(DbControl dc, String name)187 public static ArrayDesign createArrayDesign(DbControl dc, Platform platform, String name) 185 188 { 186 189 TestUtil.write("--Creating array design: " + name + "\n"); 187 ArrayDesign design = ArrayDesign.getNew(dc, false);190 ArrayDesign design = ArrayDesign.getNew(dc, platform); 188 191 design.setName(name); 189 192 … … 220 223 Create a raw bioassay. 221 224 */ 222 public static RawBioAssay createRawBioAssay(DbControl dc, String name, ArrayDesign design)225 public static RawBioAssay createRawBioAssay(DbControl dc, Platform platform, RawDataType rawDataType, String name, ArrayDesign design) 223 226 { 224 227 TestUtil.write("--Creating raw bioassay: " + name + "\n"); 225 RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));228 RawBioAssay rba = RawBioAssay.getNew(dc, platform, rawDataType); 226 229 rba.setName(name); 227 230 rba.setArrayDesign(design); -
trunk/src/test/net/sf/basedb/test/performance/PrepareTest.java
r3675 r3820 38 38 import net.sf.basedb.core.ItemQuery; 39 39 import net.sf.basedb.core.Job; 40 import net.sf.basedb.core.Platform; 40 41 import net.sf.basedb.core.PluginConfiguration; 41 42 import net.sf.basedb.core.ProgressReporter; … … 87 88 dc = TestUtil.getDbControl(); 88 89 90 // We use the GENERIC platform 91 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 92 89 93 // Create experiment 90 94 experiment = Util.findExperiment(dc, "PerformanceTest"); … … 98 102 if (design == null) 99 103 { 100 design = Util.createArrayDesign(dc, "PerformanceTest");104 design = Util.createArrayDesign(dc, generic, "PerformanceTest"); 101 105 } 102 106 -
trunk/src/test/net/sf/basedb/test/performance/RawDataTest.java
r3675 r3820 31 31 import net.sf.basedb.core.ItemParameterType; 32 32 import net.sf.basedb.core.Job; 33 import net.sf.basedb.core.Platform; 33 34 import net.sf.basedb.core.PluginConfiguration; 34 35 import net.sf.basedb.core.RawBioAssay; 36 import net.sf.basedb.core.RawDataType; 35 37 import net.sf.basedb.core.RawDataTypes; 36 38 import net.sf.basedb.core.StringParameterType; … … 64 66 // Create raw bioassays 65 67 dc = TestUtil.getDbControl(); 68 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 69 RawDataType genepix = RawDataTypes.getRawDataType("genepix"); 66 70 67 71 // Load prepared items … … 76 80 for (int i = 0; i < numIterations; ++i) 77 81 { 78 rba[i] = createRawBioAssay(dc, "PerformanceTest #" + (startNum + i), design);82 rba[i] = createRawBioAssay(dc, generic, genepix, "PerformanceTest #" + (startNum + i), design); 79 83 } 80 84 dc.commit(); … … 134 138 Create a raw bioassay. 135 139 */ 136 public static RawBioAssay createRawBioAssay(DbControl dc, String name, ArrayDesign design)140 public static RawBioAssay createRawBioAssay(DbControl dc, Platform platform, RawDataType rawDataType, String name, ArrayDesign design) 137 141 { 138 142 TestUtil.write("--Creating raw bioassay: " + name + "\n"); 139 RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));143 RawBioAssay rba = RawBioAssay.getNew(dc, platform, rawDataType); 140 144 rba.setName(name); 141 145 rba.setArrayDesign(design); -
trunk/src/test/net/sf/basedb/test/performance/Util.java
r3675 r3820 33 33 import net.sf.basedb.core.Include; 34 34 import net.sf.basedb.core.ItemQuery; 35 import net.sf.basedb.core.Platform; 35 36 import net.sf.basedb.core.RawDataType; 36 37 import net.sf.basedb.core.RawDataTypes; … … 89 90 Create an array design. 90 91 */ 91 public static ArrayDesign createArrayDesign(DbControl dc, String name)92 public static ArrayDesign createArrayDesign(DbControl dc, Platform platform, String name) 92 93 { 93 94 TestUtil.write("--Creating array design: " + name + "\n"); 94 ArrayDesign design = ArrayDesign.getNew(dc, false);95 ArrayDesign design = ArrayDesign.getNew(dc, platform); 95 96 design.setName(name); 96 97 dc.saveItem(design); -
trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java
r3675 r3820 48 48 import net.sf.basedb.core.PlateGeometry; 49 49 import net.sf.basedb.core.PlateType; 50 import net.sf.basedb.core.Platform; 50 51 import net.sf.basedb.core.PluginConfiguration; 51 52 import net.sf.basedb.core.PluginDefinition; … … 75 76 <li>Create file formats for import: 76 77 <li>Import plates: 77 <li>Create array design: {@link #createArrayDesign(DbControl, String)}78 <li>Create array design: {@link #createArrayDesign(DbControl, Platform, String)} 78 79 <li>Import features: 79 80 <li>Create array batch: {@link #createArrayBatch(DbControl, String, ArrayDesign, Hardware, Protocol)} … … 156 157 157 158 dc = TestUtil.getDbControl(); 158 ArrayDesign design = createArrayDesign(dc, "Array design A"); 159 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 160 ArrayDesign design = createArrayDesign(dc, generic, "Array design A"); 159 161 dc.commit(); 160 162 … … 283 285 Create an array design. 284 286 */ 285 public static ArrayDesign createArrayDesign(DbControl dc, String name)287 public static ArrayDesign createArrayDesign(DbControl dc, Platform platform, String name) 286 288 { 287 289 TestUtil.write("--Creating array design: " + name + "\n"); 288 ArrayDesign design = ArrayDesign.getNew(dc, false);290 ArrayDesign design = ArrayDesign.getNew(dc, platform); 289 291 design.setName(name); 290 292 -
trunk/src/test/net/sf/basedb/test/roles/UserTest.java
r2938 r3820 42 42 import net.sf.basedb.core.Label; 43 43 import net.sf.basedb.core.LabeledExtract; 44 import net.sf.basedb.core.Platform; 44 45 import net.sf.basedb.core.PluginConfiguration; 45 46 import net.sf.basedb.core.Project; 46 47 import net.sf.basedb.core.RawBioAssay; 48 import net.sf.basedb.core.RawDataType; 47 49 import net.sf.basedb.core.RawDataTypes; 48 50 import net.sf.basedb.core.Sample; … … 121 123 122 124 // Raw bioassays 123 RawBioAssay rba1 = createRawBioAssay(dc, "Raw bioassay A.00h", sc1); 124 RawBioAssay rba2 = createRawBioAssay(dc, "Raw bioassay A.24h", sc2); 125 RawBioAssay rba1DyeSwap = createRawBioAssay(dc, "Raw bioassay A.00h (dye-swap)", sc1DyeSwap); 126 RawBioAssay rba2DyeSwap = createRawBioAssay(dc, "Raw bioassay A.24h (dye-swap)", sc2DyeSwap); 125 Platform generic = Platform.getByExternalId(dc, Platform.GENERIC); 126 RawDataType genepix = RawDataTypes.getRawDataType("genepix"); 127 RawBioAssay rba1 = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.00h", sc1); 128 RawBioAssay rba2 = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.24h", sc2); 129 RawBioAssay rba1DyeSwap = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.00h (dye-swap)", sc1DyeSwap); 130 RawBioAssay rba2DyeSwap = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.24h (dye-swap)", sc2DyeSwap); 127 131 inheritAnnotations(dc, rba1, s1, bioSource); 128 132 inheritAnnotations(dc, rba2, s2, bioSource); … … 281 285 Create a raw bioassay. 282 286 */ 283 public static RawBioAssay createRawBioAssay(DbControl dc, String name, Scan scan)287 public static RawBioAssay createRawBioAssay(DbControl dc, Platform platform, RawDataType rawDataType, String name, Scan scan) 284 288 { 285 289 TestUtil.write("--Creating raw bioassay: " + name + "\n"); 286 RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));290 RawBioAssay rba = RawBioAssay.getNew(dc, platform, rawDataType); 287 291 rba.setName(name); 288 292 rba.setScan(scan); -
trunk/www/include/menu.jsp
r3679 r3820 666 666 } 667 667 %> 668 <% 669 // Administrate -> Platforms menu 670 final boolean hasPlatforms = sc.hasPermission(Permission.READ, Item.PLATFORM); 671 final boolean hasFileSetMemberTypes = sc.hasPermission(Permission.READ, Item.DATAFILETYPE); 672 final boolean hasTopPlatforms = hasPlatforms || hasFileSetMemberTypes; 673 if (hasTopPlatforms) 674 { 675 %> 676 <m:menu 677 id="platforms" 678 style="display: none" 679 > 680 <m:menuitem 681 title="Experimental platforms" 682 onclick="<%="Menu.openUrl('"+root+"admin/platforms/index.jsp?ID="+ID+"')"%>" 683 tooltip="<%=hasPlatforms ? "Administrate experimental platforms" : "You do not have permission to administrate experimental platforms"%>" 684 enabled="<%=hasPlatforms%>" 685 /> 686 <m:menuitem 687 title="Data file types" 688 onclick="<%="Menu.openUrl('"+root+"admin/datafiletypes/index.jsp?ID="+ID+"')"%>" 689 tooltip="<%=hasFileSetMemberTypes ? "Administrate data file types" : "You do not have permission to administrate data file types"%>" 690 enabled="<%=hasFileSetMemberTypes%>" 691 /> 692 </m:menu> 693 <% 694 } 695 %> 668 696 669 697 <% … … 731 759 hasUsers || hasGroups || hasRoles || hasQuota || hasTypes || hasPlugins || 732 760 hasSoftware || hasHardware || hasProtocols || hasClients || hasNews || 733 hasDiskUsage || hasServer ;761 hasDiskUsage || hasServer || hasTopPlatforms; 734 762 735 763 if (hasAdministrate) … … 803 831 /> 804 832 <m:menuseparator /> 833 <m:submenu 834 subid="platforms" 835 title="Platforms" 836 tooltip="Administrate experimental platforms" 837 enabled="<%=hasTopPlatforms%>" 838 /> 805 839 <m:submenu 806 840 subid="types" -
trunk/www/include/scripts/main.js
r3719 r3820 263 263 var regExp = new RegExp(className); 264 264 obj.className = obj.className.replace(className, ''); 265 } 266 267 this.addOrRemoveClass = function(obj, className, addIfTrue) 268 { 269 if (addIfTrue) 270 { 271 this.addClass(obj, className); 272 } 273 else 274 { 275 this.removeClass(obj, className); 276 } 265 277 } 266 278 … … 425 437 this.controllers['EXTRAVALUETYPE'] = { url:'admin/extravaluetypes/index.jsp', width:500, height:360 }; 426 438 this.controllers['EXTRAVALUE'] = { url:'views/experiments/extravalues/index.jsp', width:500, height:340, edit:false }; 439 this.controllers['PLATFORM'] = { url:'admin/platforms/index.jsp', width:540, height:400 }; 440 this.controllers['PLATFORMVARIANT'] = { url:'admin/platforms/variants/index.jsp', width:540, height:400 }; 441 this.controllers['DATAFILETYPE'] = { url:'admin/datafiletypes/index.jsp', width:600, height:480 }; 427 442 } 428 443 … … 1091 1106 this.isInteger = function(value) 1092 1107 { 1093 return (value.search(/^\ d+$/) != -1);1108 return (value.search(/^\-?\d+$/) != -1); 1094 1109 } 1095 1110 -
trunk/www/include/styles/main.css
r3719 r3820 168 168 background: #D0F0FF; 169 169 } 170 170 input.unchangeable, select.unchangeable, textarea.unchangeable { 171 background: #FFF0D0; 172 } 171 173 a.disabled { 172 174 color: #666666; … … 205 207 .selectoptionheader, .defaultheader { 206 208 font-weight: bold; 209 } 210 211 .selectoptionindent { 212 padding-left: 1em; 207 213 } 208 214 -
trunk/www/lims/arraydesigns/edit_design.jsp
r3679 r3820 35 35 import="net.sf.basedb.core.ArrayDesign" 36 36 import="net.sf.basedb.core.File" 37 import="net.sf.basedb.core.Affymetrix" 37 import="net.sf.basedb.core.Platform" 38 import="net.sf.basedb.core.PlatformVariant" 39 import="net.sf.basedb.core.RawDataType" 38 40 import="net.sf.basedb.core.ItemQuery" 39 41 import="net.sf.basedb.core.ItemResultList" … … 65 67 ArrayDesign design = null; 66 68 67 boolean readCurrentCdfFile = true; 68 File currentCdfFile = null; 69 70 // Load recently used items 71 List<File> recentFiles = (List<File>)cc.getRecent(dc, Item.FILE); 69 boolean deniedPlatform = false; 70 Platform currentPlatform = null; 71 PlatformVariant currentVariant = null; 72 72 73 73 if (itemId == 0) … … 82 82 title = "Edit array design -- " + HTML.encodeTags(design.getName()); 83 83 84 if (design.isAffyChip()) 85 { 86 try 87 { 88 currentCdfFile = Affymetrix.getCdfFile(design); 89 } 90 catch (PermissionDeniedException ex) 91 { 92 readCurrentCdfFile = false; 93 } 94 } 84 try 85 { 86 currentPlatform = design.getPlatform(); 87 currentVariant = design.getVariant(); 88 } 89 catch (PermissionDeniedException ex) 90 { 91 deniedPlatform = true; 92 } 93 design.checkPermission(Permission.WRITE); 95 94 } 96 if (design != null && !design.hasPermission(Permission.WRITE)) 97 { 98 throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); 99 } 95 96 ItemQuery<Platform> platformQuery = Platform.getQuery(); 97 platformQuery.order(Orders.asc(Hql.property("name"))); 98 platformQuery.setCacheResult(true); 99 ItemResultList<Platform> platforms = platformQuery.list(dc); 100 101 ItemQuery<PlatformVariant> variantQuery = PlatformVariant.getQuery(); 102 variantQuery.order(Orders.asc(Hql.property("name"))); 103 variantQuery.setCacheResult(true); 104 ItemResultList<PlatformVariant> variants = variantQuery.list(dc); 105 100 106 final String clazz = "class=\"text\""; 101 107 final String requiredClazz = "class=\"text required\""; … … 103 109 104 110 <base:page type="popup" title="<%=title%>"> 105 <base:head scripts="tabcontrol.js,annotations.js " styles="tabcontrol.css">111 <base:head scripts="tabcontrol.js,annotations.js,platforms.js" styles="tabcontrol.css"> 106 112 <script language="JavaScript"> 107 113 // Validate the "ArrayDesign" tab … … 132 138 Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm); 133 139 } 140 if (dataFilesLoaded) 141 { 142 Platforms.addDataFilesToForm(frames.datafiles, frm); 143 } 134 144 frm.submit(); 135 145 } … … 139 149 var inheritedAnnotationsLoaded = false; 140 150 var parentsChanged = false; 151 var dataFilesLoaded = false; 152 var platformChanged = false; 141 153 function switchTab(tabControlId, tabId) 142 154 { 155 var frm = document.forms['design']; 143 156 if (TabControl.setActiveTab(tabControlId, tabId)) 144 157 { … … 155 168 parentsChanged = false; 156 169 } 170 else if (tabId == 'datafiles' && (platformChanged || !dataFilesLoaded)) 171 { 172 var platform = Platforms.getSelectedPlatform(frm.platform); 173 var variant = Platforms.getSelectedVariant(frm.platform); 174 Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=design == null ? 0 : design.getId()%>, platform == null ? 0 : platform.id, variant == null ? 0 : variant.id); 175 dataFilesLoaded = true; 176 platformChanged = false; 177 } 157 178 } 158 179 } … … 162 183 return new Array(); 163 184 } 164 165 function selectFileOnClick() 166 { 167 var frm = document.forms['design']; 168 if (frm.affy_chip && !frm.affy_chip.checked) 169 { 170 if (!confirm('CDF-files are only used for Affymetrix chips.\nDo you want to activate the checkbox')) 171 { 172 return; 173 } 174 frm.affy_chip.checked = true; 175 } 176 var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setFileCallback'; 177 if (frm.cdffile_id.length > 1) 178 { 179 var id = Math.abs(parseInt(frm.cdffile_id[1].value)); 180 url += '&item_id='+id; 181 } 182 url += '&filter:STRING:name=%25.cdf'; 183 Main.openPopup(url, 'SelectFile', 1000, 700); 184 } 185 function setFileCallback(id, name) 186 { 187 var frm = document.forms['design']; 188 var list = frm.cdffile_id; 189 if (list.length < 2 || list[1].value == '0') // > 190 { 191 Forms.addListOption(list, 1, new Option()); 192 } 193 list[1].value = id; 194 list[1].text = name; 195 list.selectedIndex = 1; 196 } 197 198 function affyChipOnClick() 199 { 200 var frm = document.forms['design']; 201 if (!frm.affy_chip.checked) 202 { 203 frm.cdffile_id.selectedIndex = 0; 204 } 205 else if (frm.cdffile_id.length > 1) 206 { 207 frm.cdffile_id.selectedIndex = 1; 208 } 185 186 function platformOnChange() 187 { 188 platformChanged = true; 209 189 } 210 190 … … 221 201 } 222 202 %> 203 initPlatforms(<%=currentPlatform == null ? 0 : currentPlatform.getId()%>, <%=currentVariant == null ? 0 : currentVariant.getId()%>); 204 } 205 206 function initPlatforms(platformId, variantId) 207 { 208 <% 209 for (Platform p : platforms) 210 { 211 RawDataType rdt = p.isFileOnly() ? null : p.getRawDataType(); 212 %> 213 var p<%=p.getId()%> = new Platform(<%=p.getId()%>, '<%=HTML.javaScriptEncode(p.getExternalId())%>', '<%=HTML.javaScriptEncode(p.getName())%>', <%=p.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>'); 214 <% 215 } 216 for (PlatformVariant v : variants) 217 { 218 RawDataType rdt = v.isFileOnly() ? null : v.getRawDataType(); 219 Platform p = v.getPlatform(); 220 %> 221 var v<%=v.getId()%> = new Variant(p<%=p.getId()%>, <%=v.getId()%>, '<%=HTML.javaScriptEncode(v.getExternalId())%>', '<%=HTML.javaScriptEncode(v.getName())%>', <%=v.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>'); 222 <% 223 } 224 %> 225 var frm = document.forms['design']; 226 Platforms.populateList(frm.platform, platformId, variantId); 223 227 } 224 228 </script> … … 241 245 </tr> 242 246 <tr> 243 <td class="prompt"> Affy chip</td>247 <td class="prompt">Platform</td> 244 248 <td> 249 <select name="platform" onchange="platformOnChange()" class="required" 250 <%=deniedPlatform ? "disabled" : "" %>> 245 251 <% 246 if (de sign != null)252 if (deniedPlatform) 247 253 { 248 254 %> 249 <%=design.isAffyChip() ? "yes" : "no"%> 250 <% 251 } 252 else 253 { 254 %> 255 <input type="checkbox" name="affy_chip" value="1" 256 onclick="affyChipOnClick()" 257 <%=Values.getBoolean(cc.getPropertyValue("affyChip")) ? "checked" : ""%>> 258 (can't be changed later) 255 <option value="-1">- denied - 259 256 <% 260 257 } 261 258 %> 259 </select> 262 260 </td> 263 261 </tr> 264 <%265 if (design == null || design.isAffyChip())266 {267 %>268 <tr id="cdfFile">269 <td class="prompt">CDF file</td>270 <td>271 <base:select272 id="cdffile_id"273 clazz="selectionlist"274 required="false"275 current="<%=currentCdfFile%>"276 denied="<%=!readCurrentCdfFile%>"277 recent="<%=recentFiles%>"278 newitem="<%=design == null%>"279 onselect="selectFileOnClick()"280 />281 </td>282 </tr>283 <%284 }285 %>286 262 <tr valign=top> 287 263 <td class="prompt">Description</td> … … 295 271 </table> 296 272 <div align=right> <i><base:icon image="required.gif" /> = required information</i></div> 273 </t:tab> 274 275 <t:tab id="datafiles" title="Data files" helpid="datafiles.edit"> 276 <iframe name="datafiles" id="idDatafiles" src="../../common/datafiles/wait.jsp" 277 width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 278 marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe> 297 279 </t:tab> 298 280 -
trunk/www/lims/arraydesigns/index.jsp
r3741 r3820 34 34 import="net.sf.basedb.core.ArrayDesign" 35 35 import="net.sf.basedb.core.Affymetrix" 36 import="net.sf.basedb.core.Platform" 37 import="net.sf.basedb.core.PlatformVariant" 36 38 import="net.sf.basedb.core.Plate" 37 39 import="net.sf.basedb.core.File" 38 40 import="net.sf.basedb.core.FileType" 41 import="net.sf.basedb.core.FileSet" 42 import="net.sf.basedb.core.Path" 43 import="net.sf.basedb.core.DataFileType" 39 44 import="net.sf.basedb.core.ItemQuery" 40 45 import="net.sf.basedb.core.ItemResultIterator" … … 60 65 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 61 66 <%! 62 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name, affyChip,numFeatures,description");67 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,platform,numDbFeatures,numFileFeatures,description"); 63 68 private static final Item itemType = Item.ARRAYDESIGN; 64 69 %> … … 135 140 dc = sc.newDbControl(); 136 141 ArrayDesign design = (ArrayDesign)cc.getObject("item"); 142 143 String[] pv = request.getParameter("platform").split(":"); 144 int platformId = Values.getInt(pv[0], -1); 145 int variantId = pv.length > 1 ? Values.getInt(pv[1], -1) : -1; 146 Platform platform = platformId > 0 ? Platform.getById(dc, platformId) : null; 147 PlatformVariant variant = variantId > 0 ? PlatformVariant.getById(dc, variantId) : null; 137 148 if (design == null) 138 149 { 139 boolean isAffy = Values.getBoolean(request.getParameter("affy_chip")); 140 design = ArrayDesign.getNew(dc, isAffy); 150 if (variant != null) 151 { 152 design = ArrayDesign.getNew(dc, variant); 153 } 154 else 155 { 156 design = ArrayDesign.getNew(dc, platform); 157 } 141 158 message = "Array design created"; 142 159 dc.saveItem(design); … … 145 162 { 146 163 dc.reattachItem(design); 164 if (variant != null) 165 { 166 design.setVariant(variant); 167 } 168 else 169 { 170 design.setPlatform(platform); 171 } 147 172 message = "Array design updated"; 148 173 } 149 174 design.setName(Values.getStringOrNull(request.getParameter("name"))); 150 175 design.setDescription(Values.getStringOrNull(request.getParameter("description"))); 151 if (design.isAffyChip()) 152 { 153 int cdfFileId = Values.getInt(request.getParameter("cdffile_id"), -1); 154 if (cdfFileId >= 0) // < 0 = denied or unchanged 155 { 156 File cdfFile = cdfFileId == 0 ? null : File.getById(dc, cdfFileId); 157 Affymetrix.setCdfFile(design, cdfFile); 158 if (cdfFile != null) cc.setRecent(cdfFile, maxRecent); 159 } 160 } 161 176 177 // Data files tab 178 boolean validate = Values.getBoolean(request.getParameter("datafiles.validate")); 179 boolean metadata = Values.getBoolean(request.getParameter("datafiles.metadata")); 180 Base.updateFiles(dc, design, request, validate, metadata, cc, maxRecent); 181 162 182 // Annotations tab 163 183 Base.updateAnnotations(dc, design, design, request); -
trunk/www/lims/arraydesigns/list_designs.jsp
r3741 r3820 33 33 import="net.sf.basedb.core.ArrayBatch" 34 34 import="net.sf.basedb.core.Affymetrix" 35 import="net.sf.basedb.core.Platform" 36 import="net.sf.basedb.core.PlatformVariant" 35 37 import="net.sf.basedb.core.File" 36 38 import="net.sf.basedb.core.AnnotationType" … … 95 97 final boolean createBatchPermission = sc.hasPermission(Permission.CREATE, Item.ARRAYBATCH); 96 98 99 // Get all platforms 100 final ItemQuery<Platform> platformQuery = Platform.getQuery(); 101 platformQuery.order(Orders.asc(Hql.property("name"))); 102 platformQuery.setCacheResult(true); 103 Enumeration<String, String> platforms = new Enumeration<String, String>(); 104 for (Platform p : platformQuery.list(dc)) 105 { 106 platforms.add(Integer.toString(p.getId()), p.getName()); 107 } 108 97 109 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 98 110 annotationTypes = annotationTypeQuery.list(dc); … … 242 254 /> 243 255 <tbl:columndef 244 id="affyChip"245 property="affyChip"246 datatype="boolean"247 title="Affy chip"248 sortable="true"249 filterable="true"250 exportable="true"251 />252 <tbl:columndef253 id="cdfFile"254 title="CDF file"255 />256 <tbl:columndef257 256 id="hasFeatures" 258 257 property="hasFeatures" … … 264 263 /> 265 264 <tbl:columndef 266 id="num Features"267 property="num Features"265 id="numDbFeatures" 266 property="numDbFeatures" 268 267 datatype="int" 269 title=" Numfeatures"268 title="Db features" 270 269 sortable="true" 271 270 filterable="true" 272 271 exportable="true" 273 272 /> 273 <tbl:columndef 274 id="numFileFeatures" 275 property="numFileFeatures" 276 datatype="int" 277 title="File features" 278 sortable="true" 279 filterable="true" 280 exportable="true" 281 /> 282 <tbl:columndef 283 id="platform" 284 property="platform" 285 sortproperty="platform.name" 286 exportproperty="platform.name" 287 datatype="int" 288 enumeration="<%=platforms%>" 289 title="Platform" 290 sortable="true" 291 filterable="true" 292 exportable="true" 293 /> 294 <tbl:columndef 295 id="variant" 296 property="variant.name" 297 datatype="string" 298 title="Variant" 299 sortable="true" 300 filterable="true" 301 exportable="true" 302 /> 274 303 <tbl:columndef 275 304 id="batches" … … 493 522 onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" 494 523 title="<%=tooltip%>"><%=name%></div></tbl:cell> 495 <tbl:cell column="affyChip"><%=item.isAffyChip()%></tbl:cell> 496 <tbl:cell column="cdfFile"> 497 <% 498 if (item.isAffyChip()) 499 { 500 File cdfFile = null; 501 boolean readCdfFile = true; 502 try 503 { 504 cdfFile = Affymetrix.getCdfFile(item); 505 } 506 catch (PermissionDeniedException ex) 507 { 508 readCdfFile = false; 509 } 510 %> 511 <%=Base.getLinkedFile(ID, cdfFile, !readCdfFile, true, true, root)%> 512 <% 513 } 514 %> 515 </tbl:cell> 524 <tbl:cell column="platform" 525 ><base:propertyvalue 526 item="<%=item%>" 527 property="platform" 528 enableEditLink="<%=mode.hasEditLink()%>" 529 enablePropertyLink="<%=mode.hasPropertyLink()%>" 530 /></tbl:cell> 531 <tbl:cell column="variant" 532 ><base:propertyvalue 533 item="<%=item%>" 534 property="variant" 535 enableEditLink="<%=mode.hasEditLink()%>" 536 enablePropertyLink="<%=mode.hasPropertyLink()%>" 537 /></tbl:cell> 516 538 <tbl:cell column="hasFeatures"><%=item.hasFeatures() ? "yes" : "no"%></tbl:cell> 517 <tbl:cell column="numFeatures"><%=item.getNumFeatures()%></tbl:cell> 539 <tbl:cell column="numDbFeatures"><%=item.getNumDbFeatures()%></tbl:cell> 540 <tbl:cell column="numFileFeatures"><%=item.getNumFileFeatures()%></tbl:cell> 518 541 <tbl:cell column="batches"> 519 542 <% -
trunk/www/lims/arraydesigns/view_design.jsp
r3741 r3820 36 36 import="net.sf.basedb.core.Permission" 37 37 import="net.sf.basedb.core.AnnotationType" 38 import="net.sf.basedb.core.FileSet" 39 import="net.sf.basedb.core.FileSetMember" 40 import="net.sf.basedb.core.DataFileType" 38 41 import="net.sf.basedb.core.AnnotationSet" 39 42 import="net.sf.basedb.core.ArrayDesign" … … 268 271 </tr> 269 272 <tr> 270 <td class="prompt"> Affy chip</td>271 <td>< %=design.isAffyChip() ? "yes" : "no"%></td>273 <td class="prompt">Platform</td> 274 <td><base:propertyvalue item="<%=design%>" property="platform" /></td> 272 275 </tr> 273 <% 274 if (design.isAffyChip()) 275 { 276 boolean readCurrentCdfFile = true; 277 File currentCdfFile = null; 278 try 279 { 280 currentCdfFile = Affymetrix.getCdfFile(design); 281 } 282 catch (PermissionDeniedException ex) 283 { 284 readCurrentCdfFile = false; 285 } 286 %> 287 <tr> 288 <td class="prompt">CDF file</td> 289 <td> 290 <%=Base.getLinkedFile(ID, currentCdfFile, !readCurrentCdfFile, true, true, root)%> 291 <% 292 if (currentCdfFile != null) 293 { 294 try 295 { 296 PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.CdfFileReporterImporter"); 297 %> 298 [<a href="javascript:verifyReporters()">verify reporters</a>] 299 <% 300 } 301 catch (Throwable t) 302 {} 303 } 304 %> 305 </td> 306 </tr> 307 <% 308 } 309 %> 276 <tr> 277 <td class="prompt">Variant</td> 278 <td><base:propertyvalue item="<%=design%>" property="variant" /></td> 279 </tr> 310 280 <tr> 311 281 <td class="prompt">Features</td> 312 <td><%=design.hasFeatures() ? "yes ( " + design.getNumFeatures() + ")" : "no"%></td>282 <td><%=design.hasFeatures() ? "yes (db: " + design.getNumDbFeatures() + "; file: " + design.getNumFileFeatures() + ")" : "no"%></td> 313 283 </tr> 314 284 <tr> … … 321 291 </tr> 322 292 </table> 293 294 295 <jsp:include page="../../common/datafiles/list_files.jsp"> 296 <jsp:param name="item_type" value="<%=itemType.name()%>" /> 297 <jsp:param name="item_id" value="<%=itemId%>" /> 298 <jsp:param name="ID" value="<%=ID%>" /> 299 </jsp:include> 323 300 324 301 <% -
trunk/www/views/experiments/edit_experiment.jsp
r3679 r3820 54 54 import="net.sf.basedb.clients.web.util.HTML" 55 55 import="net.sf.basedb.util.Values" 56 import="net.sf.basedb.util.Enumeration" 56 57 import="net.sf.basedb.util.formatter.Formatter" 57 58 import="net.sf.basedb.clients.web.formatter.FormatterFactory" … … 152 153 return false; 153 154 } 155 if (frm.rawdatatype) 156 { 157 if (frm.rawdatatype[frm.rawdatatype.selectedIndex].value == '') 158 { 159 alert("You must select a raw data type"); 160 frm.rawdatatype.focus(); 161 return false; 162 } 163 } 154 164 return true; 155 165 }