Last change
on this file since 2 was
2,
checked in by robert@…, 12 years ago
|
Initial import of basic functionality
|
File size:
1.5 KB
|
Line | |
---|
1 | package nl.tno.metagenomics |
---|
2 | |
---|
3 | import org.codehaus.groovy.grails.commons.ConfigurationHolder |
---|
4 | |
---|
5 | /** |
---|
6 | * Holds data belonging to a sequencing run |
---|
7 | * |
---|
8 | * @author Robert Horlings (robert@isdat.nl) |
---|
9 | * |
---|
10 | */ |
---|
11 | class Run { |
---|
12 | def fileService |
---|
13 | |
---|
14 | String name |
---|
15 | Date date |
---|
16 | String machine |
---|
17 | String supplier |
---|
18 | String parameterFile |
---|
19 | |
---|
20 | static hasMany = [sequenceData: SequenceData, assays: Assay] |
---|
21 | static belongsTo = Assay // Only used to determine the owner of the many-to-many relationship assay-run |
---|
22 | |
---|
23 | static mapping = { |
---|
24 | columns { |
---|
25 | name index:'runname_idx' |
---|
26 | } |
---|
27 | } |
---|
28 | static constraints = { |
---|
29 | name(unique:true) |
---|
30 | date(nullable:true) |
---|
31 | machine(nullable:true) |
---|
32 | supplier(nullable:true) |
---|
33 | parameterFile(nullable:true) |
---|
34 | } |
---|
35 | |
---|
36 | def beforeDelete = { |
---|
37 | // Remove the file if the object is deleted |
---|
38 | if( this.parameterFile ) |
---|
39 | fileService.delete( this.parameterFile, fileService.absolutePath( ConfigurationHolder.config.metagenomics.fileDir ) ) |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * Sets the properties of this run from a form |
---|
44 | * @param params |
---|
45 | * @return |
---|
46 | */ |
---|
47 | public setPropertiesFromForm( params ) { |
---|
48 | this.properties = params.run |
---|
49 | |
---|
50 | // Enter date or default NULL |
---|
51 | if( params.run_date ) { |
---|
52 | this.date = Date.parse( "yyyy-mm-dd", params.run_date ); |
---|
53 | } else { |
---|
54 | this.date = null |
---|
55 | } |
---|
56 | |
---|
57 | // Enter filename if needed |
---|
58 | if( params.parameterFile ) { |
---|
59 | this.parameterFile = fileService.handleUploadedFile( |
---|
60 | fileService.get( params.parameterFile ), |
---|
61 | "", |
---|
62 | fileService.absolutePath( ConfigurationHolder.config.metagenomics.fileDir ) |
---|
63 | ); |
---|
64 | } |
---|
65 | } |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.