Changeset 5667
- Timestamp:
- Jun 23, 2011, 2:06:39 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ExtractImporter.java
r5663 r5667 26 26 import java.util.Set; 27 27 28 import net.sf.basedb.core.BioMaterial; 28 29 import net.sf.basedb.core.BioMaterialEvent; 29 30 import net.sf.basedb.core.BioMaterialEventSource; … … 37 38 import net.sf.basedb.core.PluginParameter; 38 39 import net.sf.basedb.core.Protocol; 39 import net.sf.basedb.core.Sample;40 40 import net.sf.basedb.core.SystemItems; 41 41 import net.sf.basedb.core.Tag; 42 42 import net.sf.basedb.core.plugin.GuiContext; 43 import net.sf.basedb.util.Values;44 43 import net.sf.basedb.util.parser.FlatFileParser; 45 44 import net.sf.basedb.util.parser.Mapper; … … 96 95 private Mapper createdMapper; 97 96 private Mapper protocolMapper; 98 private Mapper p ooledMapper;97 private Mapper parentTypeMapper; 99 98 private Mapper parentMapper; 100 99 private Mapper usedQuantityMapper; … … 143 142 parameters.add(SampleImporter.createdColumnMapping); 144 143 parameters.add(SampleImporter.originalQuantityColumnMapping); 145 parameters.add(SampleImporter.p ooledColumnMapping);144 parameters.add(SampleImporter.parentTypeColumnMapping); 146 145 parameters.add(SampleImporter.parentColumnMapping); 147 146 parameters.add(SampleImporter.usedQuantityColumnMapping); … … 174 173 createdMapper = getMapper(ffp, (String)job.getValue("createdColumnMapping"), null, null); 175 174 protocolMapper = getMapper(ffp, (String)job.getValue("protocolColumnMapping"), null, null); 176 p ooledMapper = getMapper(ffp, (String)job.getValue("pooledColumnMapping"), null, null);175 parentTypeMapper = getMapper(ffp, (String)job.getValue("parentTypeColumnMapping"), null, null); 177 176 parentMapper = getMapper(ffp, (String)job.getValue("parentColumnMapping"), null, null); 178 177 usedQuantityMapper = getMapper(ffp, (String)job.getValue("usedQuantityColumnMapping"), null, null); … … 200 199 if (createdMapper != null) creationEvent.setEventDate(parseDate(createdMapper.getValue(data))); 201 200 updateItemSubtype(dc, extract, data); 202 if (pooledMapper != null)203 {204 //extract.setPooled(Values.getBoolean(pooledMapper.getValue(data)));205 }206 201 207 202 if (tagMapper != null) … … 232 227 } 233 228 } 234 /* 235 if (!extract.isPooled()) 236 { 237 */ 238 if (parentMapper != null) 239 { 240 String nameOrId = parentMapper.getValue(data); 241 ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.SAMPLE, 0); 242 Sample sample = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 243 Float usedQuantity = usedQuantityMapper == null ? 244 null : usedQuantityMapper.getFloat(data); 245 if (nameOrId == null || sample != null) 229 230 231 if (parentMapper != null) 232 { 233 // Try to find a parent type 234 Item parentType = extract.getParentType(); 235 // Is it specified in the imported file? 236 if (parentTypeMapper != null) 237 { 238 String type = parentTypeMapper.getValue(data); 239 if (type != null) parentType = Item.valueOf(type); 240 } 241 242 // See if we can find a related subtype 243 ItemSubtype type = null; 244 if (parentType == null) 245 { 246 // If we don't know the parent type, check for both biosurce and sample types 247 type = ItemSubtype.getRelatedSubtype(dc, extract, Item.SAMPLE, Item.BIOSOURCE); 248 if (type != null) parentType = type.getMainItemType(); 249 } 250 else 251 { 252 type = ItemSubtype.getRelatedSubtype(dc, extract, parentType); 253 } 254 255 // Try to find either a sample or a biosource 256 String nameOrId = parentMapper.getValue(data); 257 BioMaterial parent = null; 258 if (parentType == Item.EXTRACT) 259 { 260 parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 261 } 262 else 263 { 264 parent = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 265 } 266 if (nameOrId == null || parent != null) 267 { 268 BioMaterialEventSource evtSrc = extract.getCreationEvent().setSource(parent); 269 if (evtSrc != null) 246 270 { 247 BioMaterialEventSource evtSrc = extract.getCreationEvent().setSource(sample);248 if (evtSrc != null)evtSrc.setUsedQuantity(usedQuantity);271 Float usedQuantity = usedQuantityMapper == null ? null : usedQuantityMapper.getFloat(data); 272 evtSrc.setUsedQuantity(usedQuantity); 249 273 } 250 274 } 251 /* 252 } 253 else 254 { 255 updateMultiLineItem(dc, extract, data, 0); 256 } 257 */ 275 } 258 276 } 259 277 … … 265 283 FlatFileParser.Data data, int multiLineNum) 266 284 { 267 if (parentMapper != null ) // && extract.isPooled())285 if (parentMapper != null && extract.getParentType() == Item.EXTRACT) 268 286 { 269 287 String nameOrId = parentMapper.getValue(data); -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/LabeledExtractImporter.java
r5663 r5667 43 43 import net.sf.basedb.core.query.Hql; 44 44 import net.sf.basedb.core.query.Restrictions; 45 import net.sf.basedb.util.Values;46 45 import net.sf.basedb.util.parser.FlatFileParser; 47 46 import net.sf.basedb.util.parser.Mapper; … … 99 98 private Mapper createdMapper; 100 99 private Mapper protocolMapper; 101 private Mapper pooledMapper;102 100 private Mapper parentMapper; 103 101 private Mapper usedQuantityMapper; … … 139 137 parameters.add(SampleImporter.createdColumnMapping); 140 138 parameters.add(SampleImporter.originalQuantityColumnMapping); 141 parameters.add(SampleImporter.pooledColumnMapping);142 139 parameters.add(SampleImporter.parentColumnMapping); 143 140 parameters.add(SampleImporter.usedQuantityColumnMapping); … … 178 175 createdMapper = getMapper(ffp, (String)job.getValue("createdColumnMapping"), null, null); 179 176 protocolMapper = getMapper(ffp, (String)job.getValue("protocolColumnMapping"), null, null); 180 pooledMapper = getMapper(ffp, (String)job.getValue("pooledColumnMapping"), null, null);181 177 parentMapper = getMapper(ffp, (String)job.getValue("parentColumnMapping"), null, null); 182 178 usedQuantityMapper = getMapper(ffp, (String)job.getValue("usedQuantityColumnMapping"), null, null); … … 204 200 BioMaterialEvent creationEvent = extract.getCreationEvent(); 205 201 if (createdMapper != null) creationEvent.setEventDate(parseDate(createdMapper.getValue(data))); 206 if (pooledMapper != null) 207 { 208 //extract.setPooled(Values.getBoolean(pooledMapper.getValue(data))); 209 } 202 210 203 if (protocolMapper != null) 211 204 { … … 236 229 } 237 230 } 238 /* 239 if (!extract.isPooled()) 240 { 241 */ 242 if (parentMapper != null) 231 232 if (parentMapper != null) 233 { 234 String nameOrId = parentMapper.getValue(data); 235 Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId); 236 Float usedQuantity = usedQuantityMapper == null ? 237 null : usedQuantityMapper.getFloat(data); 238 if (nameOrId == null || parent != null) 243 239 { 244 String nameOrId = parentMapper.getValue(data); 245 Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId); 246 Float usedQuantity = usedQuantityMapper == null ? 247 null : usedQuantityMapper.getFloat(data); 248 if (nameOrId == null || parent != null) 249 { 250 BioMaterialEventSource evtSrc = extract.getCreationEvent().setSource(parent); 251 if (evtSrc != null) evtSrc.setUsedQuantity(usedQuantity); 252 } 240 BioMaterialEventSource evtSrc = extract.getCreationEvent().setSource(parent); 241 if (evtSrc != null) evtSrc.setUsedQuantity(usedQuantity); 253 242 } 254 /* 255 } 256 else 257 { 258 updateMultiLineItem(dc, extract, data, 0); 259 } 260 */ 243 } 261 244 } 262 245 … … 268 251 FlatFileParser.Data data, int multiLineNum) 269 252 { 270 if (parentMapper != null) // && extract.isPooled())253 if (parentMapper != null) 271 254 { 272 255 String nameOrId = parentMapper.getValue(data); -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/SampleImporter.java
r5663 r5667 26 26 import java.util.Set; 27 27 28 import net.sf.basedb.core.BioMaterial; 28 29 import net.sf.basedb.core.BioMaterialEvent; 29 30 import net.sf.basedb.core.BioPlate; 30 import net.sf.basedb.core.BioSource;31 31 import net.sf.basedb.core.BioWell; 32 32 import net.sf.basedb.core.DbControl; … … 39 39 import net.sf.basedb.core.SystemItems; 40 40 import net.sf.basedb.core.plugin.GuiContext; 41 import net.sf.basedb.util.Values;42 41 import net.sf.basedb.util.parser.FlatFileParser; 43 42 import net.sf.basedb.util.parser.Mapper; … … 85 84 86 85 /** 87 Column mapping parameter for the pooled property. 88 */ 89 protected static final PluginParameter<String> pooledColumnMapping = 90 new PluginParameter<String>( 91 "pooledColumnMapping", 92 "Pooled", 93 "Mapping that picks the data column specifying if an item is pooled or not. " + 94 "Recognised values are empty, 0, 1, true, false, yes and no. Other values will be " + 95 "treated as pooled. Example: \\Pooled\\", 96 optionalColumnMapping 97 ); 98 99 /** 100 Column mapping parameter for the parent (biosource OR pooled sample) 86 Column mapping parameter for the parent type. 87 */ 88 protected static final PluginParameter<String> parentTypeColumnMapping = 89 new PluginParameter<String>( 90 "parentTypeColumnMapping", 91 "Parent type", 92 "Mapping that picks the data column specifying the type of parent item. " + 93 "Recognised values are BIOSOURCE, SAMPLE and EXTRACT, but only two of them are " + 94 "valid for each importer. If the parent type is not specified, the importer will " + 95 "try to guess a parent type from the item subtype. Example: \\Parent type\\", 96 optionalColumnMapping 97 ); 98 99 /** 100 Column mapping parameter for the parent (biosource OR sample) 101 101 */ 102 102 protected static final PluginParameter<String> parentColumnMapping = … … 193 193 private Mapper createdMapper; 194 194 private Mapper protocolMapper; 195 private Mapper p ooledMapper;195 private Mapper parentTypeMapper; 196 196 private Mapper parentMapper; 197 197 private Mapper usedQuantityMapper; … … 239 239 parameters.add(createdColumnMapping); 240 240 parameters.add(originalQuantityColumnMapping); 241 parameters.add(p ooledColumnMapping);241 parameters.add(parentTypeColumnMapping); 242 242 parameters.add(parentColumnMapping); 243 243 parameters.add(usedQuantityColumnMapping); … … 269 269 createdMapper = getMapper(ffp, (String)job.getValue("createdColumnMapping"), null, null); 270 270 protocolMapper = getMapper(ffp, (String)job.getValue("protocolColumnMapping"), null, null); 271 p ooledMapper = getMapper(ffp, (String)job.getValue("pooledColumnMapping"), null, null);271 parentTypeMapper = getMapper(ffp, (String)job.getValue("parentTypeColumnMapping"), null, null); 272 272 parentMapper = getMapper(ffp, (String)job.getValue("parentColumnMapping"), null, null); 273 273 usedQuantityMapper = getMapper(ffp, (String)job.getValue("usedQuantityColumnMapping"), null, null); … … 295 295 if (createdMapper != null) creationEvent.setEventDate(parseDate(createdMapper.getValue(data))); 296 296 updateItemSubtype(dc, sample, data); 297 if (pooledMapper != null)298 {299 //sample.setPooled(Values.getBoolean(pooledMapper.getValue(data)));300 }301 297 if (protocolMapper != null) 302 298 { … … 318 314 } 319 315 } 320 /* 321 if ( !sample.isPooled())316 317 if (parentMapper != null) 322 318 { 323 */ 324 if (parentMapper != null) 325 { 326 String nameOrId = parentMapper.getValue(data); 327 ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.BIOSOURCE, 0); 328 BioSource bioSource = findBioSource(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 329 if (nameOrId == null || bioSource != null) sample.getCreationEvent().setSource(bioSource); 330 } 331 /* 319 // Try to find a parent type 320 Item parentType = sample.getParentType(); 321 // Is it specified in the imported file? 322 if (parentTypeMapper != null) 323 { 324 String type = parentTypeMapper.getValue(data); 325 if (type != null) parentType = Item.valueOf(type); 326 } 327 328 // See if we can find a related subtype 329 ItemSubtype type = null; 330 if (parentType == null) 331 { 332 // If we don't know the parent type, check for both biosurce and sample types 333 type = ItemSubtype.getRelatedSubtype(dc, sample, Item.BIOSOURCE, Item.SAMPLE); 334 if (type != null) parentType = type.getMainItemType(); 335 } 336 else 337 { 338 type = ItemSubtype.getRelatedSubtype(dc, sample, parentType); 339 } 340 341 // Try to find either a sample or a biosource 342 String nameOrId = parentMapper.getValue(data); 343 BioMaterial parent = null; 344 if (parentType == Item.SAMPLE) 345 { 346 parent = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 347 } 348 else 349 { 350 parent = findBioSource(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type); 351 } 352 if (nameOrId == null || parent != null) sample.getCreationEvent().setSource(parent); 332 353 } 333 else334 {335 updateMultiLineItem(dc, sample, data, 0);336 }337 */338 354 } 339 355 … … 345 361 FlatFileParser.Data data, int multiLineNum) 346 362 { 347 if (parentMapper != null ) // && sample.isPooled())363 if (parentMapper != null && sample.getParentType() == Item.SAMPLE) 348 364 { 349 365 String nameOrId = parentMapper.getValue(data); -
trunk/src/test/TestItemImporter.java
r5652 r5667 140 140 ok &= TestJob.test_execute(hybJobId, false); 141 141 TestPhysicalBioAssay.test_list(3); 142 142 143 143 // Import scans 144 144 /* … … 208 208 TestJob.test_delete(extractJobId); 209 209 TestFile.test_delete(extractFileId); 210 210 211 211 // Delete samples 212 212 TestSample.test_delete_all(); … … 351 351 request.setParameterValue("createdColumnMapping", "\\Created\\"); 352 352 request.setParameterValue("originalQuantityColumnMapping", "\\Original quantity\\"); 353 request.setParameterValue("p ooledColumnMapping", "\\Pooled\\");353 request.setParameterValue("parentTypeColumnMapping", "\\Parent type\\"); 354 354 request.setParameterValue("parentColumnMapping", "\\Parent\\"); 355 355 request.setParameterValue("usedQuantityColumnMapping", "\\Used quantity\\"); … … 358 358 { 359 359 request.setParameterValue("tagColumnMapping", "\\Label\\"); 360 request.setParameterValue("parentTypeColumnMapping", "EXTRACT"); 360 361 request.setParameterValue("subtypeColumnMapping", "Labeled extract"); 361 request.setParameterValue("pooledColumnMapping", "1");362 362 } 363 363 if (itemType == Item.PHYSICALBIOASSAY) -
trunk/src/test/data/test.batchimport.extracts.txt
r4372 r5667 1 Name Description External ID P ooledParent Used quantity Created Original quantity Protocol1 Name Description External ID Parent type Parent Used quantity Created Original quantity Protocol 2 2 Extract 1.1 First extract from smp.1.1 ext.1.1 Sample 1.1 50 2008-01-01 200 Extraction 3 3 Extract 2.1 Second sample from smp.1.1 ext.2.1 Sample 2.1 50 2008-01-01 350 Extraction 4 4 Extract X An extract with no parent or other info 5 Pooled extract A pool of 1.1 and 2.1 ext.pooled 1Extract 1.1 50 2008-01-02 150 Pooling5 Pooled extract A pool of 1.1 and 2.1 ext.pooled EXTRACT Extract 1.1 50 2008-01-02 150 Pooling 6 6 Pooled extract Extract 2.1 100 -
trunk/src/test/data/test.batchimport.labeledextracts.txt
r4423 r5667 1 Name Label Description External ID P ooled Parent Used quantity Created Original quantity Protocol2 Labeled 1.1 cy3 cy3 labeled from ext.1.1 lbl.1.1 3 Labeled 1.2 cy5 cy5 labeled from ext.1.1 lbl.1.2 4 Labeled 2.1 cy3 cy3 labeled from ext.2.1 lbl.2.1 5 Labeled 2.2 cy5 cy5 labeled from ext.2.1 lbl.2.2 1 Name Label Description External ID Parent Used quantity Created Original quantity Protocol 2 Labeled 1.1 cy3 cy3 labeled from ext.1.1 lbl.1.1 Extract 1.1 50 2008-01-01 200 Labeling 3 Labeled 1.2 cy5 cy5 labeled from ext.1.1 lbl.1.2 Extract 1.1 50 2008-01-01 200 Labeling 4 Labeled 2.1 cy3 cy3 labeled from ext.2.1 lbl.2.1 Extract 2.1 50 2008-01-01 200 Labeling 5 Labeled 2.2 cy5 cy5 labeled from ext.2.1 lbl.2.2 Extract 2.1 50 2008-01-01 200 Labeling 6 6 Labeled X Biotin A labeled extract with no parent or other info 7 Pooled labeled 1 A pool of 1.1 and 2.1 lbl.pooled.1 1Labeled 1.1 100 2008-01-02 200 Pooling7 Pooled labeled 1 A pool of 1.1 and 2.1 lbl.pooled.1 Labeled 1.1 100 2008-01-02 200 Pooling 8 8 Pooled labeled 1 Labeled 2.1 100 9 Pooled labeled 2 A pool of 1.2 and 2.2 lbl.pooled.2 1Labeled 1.2 100 2008-01-02 200 Pooling9 Pooled labeled 2 A pool of 1.2 and 2.2 lbl.pooled.2 Labeled 1.2 100 2008-01-02 200 Pooling 10 10 Pooled labeled 2 Labeled 2.2 100 -
trunk/src/test/data/test.batchimport.samples.txt
r5249 r5667 1 Name Description External ID P ooledParent Used quantity Created Original quantity Protocol1 Name Description External ID Parent type Parent Used quantity Created Original quantity Protocol 2 2 Sample 1.1 First sample from bs.1 smp.1.1 Biosource 1 2008-01-01 200 Sampling.id 3 3 Sample 2.1 Second sample from bs.1 smp.2.1 Biosource 2 2008-01-01 350 Sampling 4 4 Sample X A sample with no parent or other info 5 Pooled sample A pool of 1.1 and 2.1 smp.pooled 1Sample 1.1 50 2008-01-02 150 Pooling5 Pooled sample A pool of 1.1 and 2.1 smp.pooled SAMPLE Sample 1.1 50 2008-01-02 150 Pooling 6 6 Pooled sample Sample 2.1 100 -
trunk/www/biomaterials/extracts/list_extracts.jsp
r5666 r5667 353 353 /> 354 354 <tbl:columndef 355 id="tag" 356 property="tag.name" 357 datatype="string" 358 title="Tag" 359 sortable="true" 360 filterable="true" 361 exportable="true" 362 /> 363 <tbl:columndef 355 364 id="protocol" 356 365 property="creationEvent.protocol" … … 386 395 <% 387 396 Enumeration<String, String> parentTypes = new Enumeration<String, String>(); 397 parentTypes.add("", "-none-"); 388 398 parentTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString()); 389 399 parentTypes.add(Integer.toString(Item.EXTRACT.getValue()), Item.EXTRACT.toString()); … … 734 744 <tbl:cell column="originalQuantity"><%=Values.formatNumber(item.getOriginalQuantity(), 2)%></tbl:cell> 735 745 <tbl:cell column="remainingQuantity"><%=Values.formatNumber(item.getRemainingQuantity(), 2)%></tbl:cell> 746 <tbl:cell column="tag" 747 ><base:propertyvalue 748 item="<%=item%>" 749 property="tag" 750 enableEditLink="<%=mode.hasEditLink()%>" 751 enablePropertyLink="<%=mode.hasPropertyLink()%>" 752 /></tbl:cell> 736 753 <tbl:cell column="protocol" 737 754 ><base:propertyvalue -
trunk/www/biomaterials/extracts/view_extract.jsp
r5664 r5667 326 326 <td class="prompt">Registered</td> 327 327 <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td> 328 </tr> 329 <tr> 330 <td class="prompt">Tag</td> 331 <td><base:propertyvalue item="<%=extract%>" property="tag"/></td> 328 332 </tr> 329 333 <tr> -
trunk/www/biomaterials/samples/list_samples.jsp
r5666 r5667 384 384 <% 385 385 Enumeration<String, String> parentTypes = new Enumeration<String, String>(); 386 parentTypes.add("", "-none-"); 386 387 parentTypes.add(Integer.toString(Item.BIOSOURCE.getValue()), Item.BIOSOURCE.toString()); 387 388 parentTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString());
Note: See TracChangeset
for help on using the changeset viewer.