Changeset 5732
- Timestamp:
- Sep 12, 2011, 12:57:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.17-stable/src/test/net/sf/basedb/test/roles/ExtraTest.java
r5702 r5732 29 29 import net.sf.basedb.core.BioMaterial; 30 30 import net.sf.basedb.core.BioWell.LockMode; 31 import net.sf.basedb.core.Application; 31 32 import net.sf.basedb.core.BioMaterialEvent; 32 33 import net.sf.basedb.core.BioMaterialList; 33 34 import net.sf.basedb.core.DbControl; 34 35 import net.sf.basedb.core.Extract; 36 import net.sf.basedb.core.File; 37 import net.sf.basedb.core.FileType; 38 import net.sf.basedb.core.HardwareType; 35 39 import net.sf.basedb.core.Hybridization; 40 import net.sf.basedb.core.Image; 36 41 import net.sf.basedb.core.Include; 37 42 import net.sf.basedb.core.Item; 43 import net.sf.basedb.core.ItemContext; 38 44 import net.sf.basedb.core.ItemParameterType; 39 45 import net.sf.basedb.core.ItemQuery; … … 42 48 import net.sf.basedb.core.LabeledExtract; 43 49 import net.sf.basedb.core.MeasuredBioMaterial; 50 import net.sf.basedb.core.Operator; 44 51 import net.sf.basedb.core.Platform; 45 52 import net.sf.basedb.core.PluginConfiguration; 46 53 import net.sf.basedb.core.PluginDefinition; 47 54 import net.sf.basedb.core.Project; 55 import net.sf.basedb.core.PropertyFilter; 56 import net.sf.basedb.core.ProtocolType; 48 57 import net.sf.basedb.core.RawBioAssay; 49 58 import net.sf.basedb.core.RawDataType; … … 51 60 import net.sf.basedb.core.Sample; 52 61 import net.sf.basedb.core.Scan; 62 import net.sf.basedb.core.SessionControl; 63 import net.sf.basedb.core.SoftwareType; 64 import net.sf.basedb.core.SystemItems; 53 65 import net.sf.basedb.core.Type; 54 66 import net.sf.basedb.core.query.Expressions; 55 67 import net.sf.basedb.core.query.Hql; 56 68 import net.sf.basedb.core.query.Restrictions; 69 import net.sf.basedb.test.FileUtil; 57 70 import net.sf.basedb.test.TestUtil; 58 71 import net.sf.basedb.util.ArrayIterator; … … 74 87 { 75 88 DbControl dc = null; 89 SessionControl sc = null; 76 90 TestUtil.write("++Entering extra tests\n"); 77 91 try 78 92 { 93 // Fake that we are using the web client since we want to 94 // create context settings for the list pages 95 sc = Application.newSessionControl("net.sf.basedb.clients.web", TestUtil.getLocalIp(), null); 96 sc.login("extra", "extra", "Running extra test program", false); 97 dc = sc.newDbControl(); 98 79 99 // Activate project 80 TestUtil.login("extra", "extra", false);81 dc = TestUtil.getDbControl();82 100 Project p = Util.findProject(dc, "Project A"); 83 TestUtil.getSessionControl().setActiveProject(p);101 sc.setActiveProject(p); 84 102 85 103 // Create annotation types, for Labeled extract, Hybridization and … … 98 116 Platform affymetrix = Platform.getByExternalId(dc, Platform.AFFYMETRIX); 99 117 RawDataType genepix = RawDataTypes.getSafeRawDataType("genepix"); 118 File redFile = FileUtil.uploadFile(dc, "/data", "spots.tif", FileType.IMAGE); 119 File greenFile = FileUtil.uploadFile(dc, "/data", "test.upload.png", FileType.IMAGE); 100 120 101 121 // Create biomaterials with no parent items … … 111 131 poolBioMaterial(dc, ple, "Labeled extract A.%h"); 112 132 113 // Create hyb , scanand raw bioassays133 // Create hybs, scans, images and raw bioassays 114 134 Hybridization hyb = UserTest.createHybridization(dc, "Hyb2Channel-3.0", null, false, le, ple); 115 135 Hybridization hyb2 = UserTest.createHybridization(dc, "HybMultiArray-3.0", null, true, le, ple); 116 136 Scan scan = UserTest.createScan(dc, "Scan2Channel-3.0", hyb, null, null); 117 137 Scan scan2 = UserTest.createScan(dc, "ScanMultiArray-3.0", hyb2, null, null); 138 createImage(dc, "RedImage-3.0", scan, redFile); 139 createImage(dc, "GreenImage-3.0", scan, greenFile); 118 140 RawBioAssay rba1 = UserTest.createRawBioAssay(dc, generic, genepix, "RawBioAssay-3.0", scan, null); 119 141 RawBioAssay rba2 = UserTest.createRawBioAssay(dc, affymetrix, null, "RawBioAssay[1]-3.0", scan2, null); … … 143 165 createBioMaterialList(dc, "Labeled extracts", le); 144 166 167 // Set filter, sort order, etc. on some contexts 168 TestUtil.write("--Creating context for: PROTOCOL\n"); 169 ItemContext cc = sc.getCurrentContext(Item.PROTOCOL); 170 cc.setSortProperty("protocolType.name"); 171 cc.setPropertyFilter(new PropertyFilter("protocolType", Operator.IN, 172 SystemItems.getId(ProtocolType.EXTRACTION) + "|"+SystemItems.getId(ProtocolType.SAMPLING), Type.INT)); 173 TestUtil.write("--Creating context for: PROTOCOLTYPE\n"); 174 cc = sc.getCurrentContext(Item.PROTOCOLTYPE); 175 cc.setSortProperty("name"); 176 cc.setSetting("base-3.0", "should be gone after update"); 177 178 TestUtil.write("--Creating context for: SOFTWARE\n"); 179 cc = sc.getCurrentContext(Item.SOFTWARE); 180 cc.setSortProperty("softwareType.name"); 181 cc.setPropertyFilter(new PropertyFilter("softwareType", Operator.EQ, 182 SystemItems.getId(SoftwareType.FEATURE_EXTRACTION) + "", Type.INT)); 183 TestUtil.write("--Creating context for: SOFTWARETYPE\n"); 184 cc = sc.getCurrentContext(Item.SOFTWARETYPE); 185 cc.setSortProperty("name"); 186 cc.setSetting("base-3.0", "should be gone after update"); 187 188 TestUtil.write("--Creating context for: HARDWARE\n"); 189 cc = sc.getCurrentContext(Item.HARDWARE); 190 cc.setSortProperty("hardwareType.name"); 191 cc.setPropertyFilter(new PropertyFilter("hardwareType", Operator.IN, 192 SystemItems.getId(HardwareType.SCANNER) + "|" + SystemItems.getId(HardwareType.FREEZER), Type.INT)); 193 TestUtil.write("--Creating context for: HARDWARETYPE\n"); 194 cc = sc.getCurrentContext(Item.HARDWARETYPE); 195 cc.setSortProperty("name"); 196 cc.setSetting("base-3.0", "should be gone after update"); 197 198 TestUtil.write("--Creating context for: FILE\n"); 199 cc = sc.getCurrentContext(Item.FILE); 200 cc.setSortProperty("fileType.name"); 201 cc.setPropertyFilter(new PropertyFilter("fileType", Operator.IN, 202 SystemItems.getId(FileType.IMAGE) + "|" + SystemItems.getId(FileType.RAW_DATA), Type.INT)); 203 TestUtil.write("--Creating context for: FILETYPE\n"); 204 cc = sc.getCurrentContext(Item.FILETYPE); 205 cc.setSortProperty("name"); 206 cc.setSetting("base-3.0", "should be gone after update"); 207 208 TestUtil.write("--Creating context for: MIMETYPE\n"); 209 cc = sc.getCurrentContext(Item.MIMETYPE); 210 cc.setSortProperty("fileType.name"); 211 cc.setPropertyFilter(new PropertyFilter("fileType", Operator.IN, 212 SystemItems.getId(FileType.IMAGE) + "|" + SystemItems.getId(FileType.RAW_DATA), Type.INT)); 213 214 TestUtil.write("--Creating context for: DATAFILETYPE\n"); 215 cc = sc.getCurrentContext(Item.DATAFILETYPE); 216 cc.setSortProperty("genericType.name"); 217 cc.setPropertyFilter(new PropertyFilter("genericType", Operator.IN, 218 SystemItems.getId(FileType.IMAGE) + "|" + SystemItems.getId(FileType.RAW_DATA), Type.INT)); 219 145 220 dc.commit(); 146 TestUtil.logout(); 221 TestUtil.write("--Logging out\n"); 222 sc.logout(); 147 223 } 148 224 catch (Throwable t) … … 171 247 String name, PluginDefinition plugin, BasicItem... parameters) 172 248 { 249 TestUtil.write("--Creating fake plug-in configuration: " + name + " for plug-in " + plugin.getName() + "\n"); 173 250 PluginConfiguration config = plugin.newPluginConfiguration(); 174 251 config.setName(name); … … 186 263 public static Job createJob(DbControl dc, String name, BasicItem... parameters) 187 264 { 265 TestUtil.write("--Creating fake job: " + name + "\n"); 188 266 Job job = Job.getNew(dc, null, null, null); 189 267 job.setName(name); … … 201 279 BioMaterial... items) 202 280 { 281 TestUtil.write("--Creating biomaterial list: " + name + "\n"); 203 282 BioMaterialList list = BioMaterialList.getNew(dc, items[0].getType()); 204 283 list.setName(name); … … 211 290 String parentNamePattern) 212 291 { 292 TestUtil.write("--Creating pooled biomaterial: " + bioMaterial.getName() + "\n"); 213 293 bioMaterial.setPooled(true); 214 294 BioMaterialEvent event = bioMaterial.getCreationEvent(); … … 237 317 } 238 318 } 319 320 /** 321 Create an image. 322 */ 323 public static Image createImage(DbControl dc, String name, Scan scan, File file) 324 { 325 TestUtil.write("--Creating image: " + name + "\n"); 326 Image img = Image.getNew(dc, scan); 327 img.setFile(file); 328 dc.saveItem(img); 329 return img; 330 } 331 239 332 }
Note: See TracChangeset
for help on using the changeset viewer.