1 | /* |
---|
2 | * To change this template, choose Tools | Templates |
---|
3 | * and open the template in the editor. |
---|
4 | */ |
---|
5 | |
---|
6 | /** |
---|
7 | * |
---|
8 | * @author ademcan |
---|
9 | */ |
---|
10 | class LoadController { |
---|
11 | |
---|
12 | String path; |
---|
13 | String delim; |
---|
14 | static Map att_list = new HashMap<String, ArrayList>(); |
---|
15 | |
---|
16 | def index = {} |
---|
17 | |
---|
18 | def load = { |
---|
19 | |
---|
20 | //ArrayList attributes = new ArrayList(); |
---|
21 | |
---|
22 | render("Loading ...\n"); |
---|
23 | |
---|
24 | InputStream inputStream = request.getFile("uploadfile").inputStream; |
---|
25 | BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream)); |
---|
26 | |
---|
27 | def investigationDesign = new dbnp.transcriptomics.magetab.idf.InvestigationDesign(); |
---|
28 | def person = new dbnp.transcriptomics.magetab.idf.Person(); |
---|
29 | def protocol = new dbnp.transcriptomics.magetab.idf.MAGEProtocol(); |
---|
30 | def publication = new dbnp.transcriptomics.magetab.idf.Publication(); |
---|
31 | def normalization = new dbnp.transcriptomics.magetab.sdrf.Normalization(); |
---|
32 | //def termSource = new dbnp.transcriptomics.magetab.adf.Termsource(); |
---|
33 | def comment = new dbnp.transcriptomics.magetab.idf.Comment(); |
---|
34 | def experimentalInfo = new dbnp.transcriptomics.magetab.idf.ExperimentalInfo(); |
---|
35 | |
---|
36 | //ArrayList rows = new ArrayList(); |
---|
37 | |
---|
38 | for (i in fileReader.readLines()){ |
---|
39 | String line = i.toString() ; |
---|
40 | ArrayList tmp_list = new ArrayList(); |
---|
41 | def parsedTab = line.split("\t"); |
---|
42 | |
---|
43 | for (j in parsedTab) { |
---|
44 | tmp_list.add(j); |
---|
45 | } |
---|
46 | |
---|
47 | if (tmp_list.size() > 1){ |
---|
48 | if (tmp_list[0]=="Investigation Title"){ |
---|
49 | investigationDesign.title = tmp_list[1]; |
---|
50 | } |
---|
51 | else if (tmp_list[0]=="Comment[AEMIAMESCORE]") { |
---|
52 | comment.aemiameScore = tmp_list[1]; |
---|
53 | } |
---|
54 | else if (tmp_list[0]=="Comment[SecondaryAccession]") { |
---|
55 | comment.secondaryAccession = tmp_list[1]; |
---|
56 | } |
---|
57 | else if (tmp_list[0]=="Comment[ArrayExpressReleaseDate]") { |
---|
58 | comment.arrayExpressReleaseDate = tmp_list[1]; |
---|
59 | } |
---|
60 | else if (tmp_list[0]=="Comment[ArrayExpressAccession]") { |
---|
61 | comment.arrayExpressAccession = tmp_list[1]; |
---|
62 | } |
---|
63 | else if (tmp_list[0]=="Comment[MAGETAB TimeStamp_Version]") { |
---|
64 | comment.timestamp_version = tmp_list[1]; |
---|
65 | } |
---|
66 | else if (tmp_list[0]=="Experimental Design") { |
---|
67 | String design = tmp_list[1]; |
---|
68 | for (a in 2..tmp_list.size()-1){ |
---|
69 | design = design + " , " +tmp_list[a]; |
---|
70 | } |
---|
71 | experimentalInfo.design = design; |
---|
72 | } |
---|
73 | else if (tmp_list[0]=="Experimental Design Term Source REF") { |
---|
74 | String term_ref = tmp_list[1]; |
---|
75 | for (a in 2..tmp_list.size()-1){ |
---|
76 | term_ref = term_ref + " , " +tmp_list[a]; |
---|
77 | } |
---|
78 | experimentalInfo.design_term_source_ref = term_ref; |
---|
79 | } |
---|
80 | else if (tmp_list[0]=="Experimental Factor Name") { |
---|
81 | String factor_name = tmp_list[1]; |
---|
82 | for (a in 2..tmp_list.size()-1){ |
---|
83 | factor_name = factor_name + " , " +tmp_list[a]; |
---|
84 | } |
---|
85 | experimentalInfo.factor_name = factor_name; |
---|
86 | } |
---|
87 | else if (tmp_list[0]=="Experimental Factor Type") { |
---|
88 | String factor_type = tmp_list[1]; |
---|
89 | for (a in 2..tmp_list.size()-1){ |
---|
90 | factor_type = factor_type + " , " +tmp_list[a]; |
---|
91 | } |
---|
92 | experimentalInfo.factor_type = factor_type; |
---|
93 | } |
---|
94 | else if (tmp_list[0]=="Experimental Factor Term Source REF") { |
---|
95 | experimentalInfo.factor_term_source_ref = tmp_list[1]; |
---|
96 | } |
---|
97 | else if (tmp_list[0]=="Person Last Name") { |
---|
98 | person.lastName = tmp_list[1]; |
---|
99 | } |
---|
100 | else if (tmp_list[0]=="Person First Name") { |
---|
101 | person.firstName = tmp_list[1]; |
---|
102 | } |
---|
103 | else if (tmp_list[0]=="Person Mid Initials") { |
---|
104 | person.midInitials = tmp_list[1]; |
---|
105 | } |
---|
106 | else if (tmp_list[0]=="Person Email") { |
---|
107 | person.email = tmp_list[1]; |
---|
108 | } |
---|
109 | else if (tmp_list[0]=="Person Phone") { |
---|
110 | person.phone = tmp_list[1]; |
---|
111 | } |
---|
112 | else if (tmp_list[0]=="Person Fax") { |
---|
113 | person.fax = tmp_list[1]; |
---|
114 | } |
---|
115 | else if (tmp_list[0]=="Person Address") { |
---|
116 | person.address = tmp_list[1]; |
---|
117 | } |
---|
118 | else if (tmp_list[0]=="Person Affiliation") { |
---|
119 | person.affiliation = tmp_list[1]; |
---|
120 | } |
---|
121 | else if (tmp_list[0]=="Person Roles") { |
---|
122 | person.roles = tmp_list[1]; |
---|
123 | } |
---|
124 | else if (tmp_list[0]=="Person Roles Term Source REF") { |
---|
125 | person.roles_ref = tmp_list[1]; |
---|
126 | } |
---|
127 | else if (tmp_list[0]=="Quality Control Type") { |
---|
128 | |
---|
129 | } |
---|
130 | else if (tmp_list[0]=="Quality Control Term Source REF") { |
---|
131 | |
---|
132 | } |
---|
133 | else if (tmp_list[0]=="Replicate Type") { |
---|
134 | |
---|
135 | } |
---|
136 | else if (tmp_list[0]=="Replicate Term Source REF") { |
---|
137 | |
---|
138 | } |
---|
139 | else if (tmp_list[0]=="Normalization Type") { |
---|
140 | normalization.type = tmp_list[1]; |
---|
141 | } |
---|
142 | else if (tmp_list[0]=="Normalization Term Source REF") { |
---|
143 | normalization.term_source_ref = tmp_list[1]; |
---|
144 | } |
---|
145 | else if (tmp_list[0]=="Date Of Experiment") { |
---|
146 | investigationDesign.dateOfExperiment = tmp_list[1]; |
---|
147 | } |
---|
148 | else if (tmp_list[0]=="Public Release Date") { |
---|
149 | investigationDesign.publicReleaseDate = tmp_list[1]; |
---|
150 | } |
---|
151 | else if (tmp_list[0]=="PubMed ID") { |
---|
152 | publication.pubMedID = tmp_list[1]; |
---|
153 | } |
---|
154 | else if (tmp_list[0]=="Publication DOI") { |
---|
155 | publication.DOI = tmp_list[1]; |
---|
156 | } |
---|
157 | else if (tmp_list[0]=="Publication Author List") { |
---|
158 | publication.authors_list = tmp_list[1]; |
---|
159 | } |
---|
160 | else if (tmp_list[0]=="Publication Title") { |
---|
161 | publication.title = tmp_list[1]; |
---|
162 | } |
---|
163 | else if (tmp_list[0]=="Publication Status") { |
---|
164 | def status = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
165 | status.text = tmp_list[1]; |
---|
166 | status.save(); |
---|
167 | publication.status = status; |
---|
168 | } |
---|
169 | else if (tmp_list[0]=="Publication Status Term Source REF") { |
---|
170 | publication.status_term_source_ref = tmp_list[1]; |
---|
171 | } |
---|
172 | else if (tmp_list[0]=="Experiment Description") { |
---|
173 | investigationDesign.experimentDescription = tmp_list[1]; |
---|
174 | } |
---|
175 | else if (tmp_list[0]=="Protocol Name") { |
---|
176 | protocol.name = tmp_list[1]; |
---|
177 | } |
---|
178 | else if (tmp_list[0]=="Protocol Type") { |
---|
179 | def type = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
180 | for (j in 1..tmp_list.size()){ |
---|
181 | type.text = tmp_list[j]; |
---|
182 | type.save(); |
---|
183 | } |
---|
184 | protocol.type = type; |
---|
185 | } |
---|
186 | else if (tmp_list[0]=="Protocol Description") { |
---|
187 | protocol.description = tmp_list[1]; |
---|
188 | } |
---|
189 | else if (tmp_list[0]=="Protocol Parameters") { |
---|
190 | protocol.parameters = tmp_list[1]; |
---|
191 | } |
---|
192 | else if (tmp_list[0]=="Protocol Hardware") { |
---|
193 | protocol.hardware = tmp_list[1]; |
---|
194 | } |
---|
195 | else if (tmp_list[0]=="Protocol Software") { |
---|
196 | protocol.software = tmp_list[1]; |
---|
197 | } |
---|
198 | else if (tmp_list[0]=="Protocol Contact") { |
---|
199 | protocol.contact = tmp_list[1]; |
---|
200 | } |
---|
201 | else if (tmp_list[0]=="Protocol Term Source REF") { |
---|
202 | protocol.term_source_ref = tmp_list[1]; |
---|
203 | } |
---|
204 | else if (tmp_list[0]=="SDRF File") { |
---|
205 | |
---|
206 | } |
---|
207 | else if (tmp_list[0]=="Term Source Name") { |
---|
208 | //termSource.name = tmp_list[1]; |
---|
209 | } |
---|
210 | else if (tmp_list[0]=="Term Source File") { |
---|
211 | //termSource.file = tmp_list[1]; |
---|
212 | } |
---|
213 | else if (tmp_list[0]=="Term Source Version") { |
---|
214 | //termSource.version = tmp_list[1]; |
---|
215 | } |
---|
216 | } |
---|
217 | |
---|
218 | person.save(); |
---|
219 | protocol.save(); |
---|
220 | publication.save(); |
---|
221 | normalization.save(); |
---|
222 | investigationDesign.save(); |
---|
223 | comment.save(); |
---|
224 | experimentalInfo.save(); |
---|
225 | //termSource.save(); |
---|
226 | |
---|
227 | } |
---|
228 | |
---|
229 | } |
---|
230 | |
---|
231 | } |
---|
232 | |
---|