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 get_string(ArrayList tmp_list) { |
---|
19 | String value = tmp_list[1]; |
---|
20 | for (a in 2..tmp_list.size()-1){ |
---|
21 | value = value + " , " +tmp_list[a]; |
---|
22 | } |
---|
23 | return value; |
---|
24 | } |
---|
25 | |
---|
26 | def load = { |
---|
27 | |
---|
28 | //ArrayList attributes = new ArrayList(); |
---|
29 | |
---|
30 | render("Loading ...<br>"); |
---|
31 | |
---|
32 | InputStream inputStream = request.getFile("uploadfile").inputStream; |
---|
33 | BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream)); |
---|
34 | |
---|
35 | def investigationDesign = new dbnp.transcriptomics.magetab.idf.InvestigationDesign(); |
---|
36 | def person = new dbnp.transcriptomics.magetab.idf.Person(); |
---|
37 | def protocol = new dbnp.transcriptomics.magetab.idf.MAGEProtocol(); |
---|
38 | def publication = new dbnp.transcriptomics.magetab.idf.Publication(); |
---|
39 | def normalization = new dbnp.transcriptomics.magetab.sdrf.Normalization(); |
---|
40 | //def termSource = new dbnp.transcriptomics.magetab.adf.Termsource(); |
---|
41 | def comment = new dbnp.transcriptomics.magetab.idf.Comment(); |
---|
42 | def experimentalInfo = new dbnp.transcriptomics.magetab.idf.ExperimentalInfo(); |
---|
43 | def factor = new dbnp.transcriptomics.magetab.idf.Factor(); |
---|
44 | |
---|
45 | //ArrayList rows = new ArrayList(); |
---|
46 | |
---|
47 | for (i in fileReader.readLines()){ |
---|
48 | //render(i); |
---|
49 | String line = i.toString() ; |
---|
50 | ArrayList tmp_list = new ArrayList(); |
---|
51 | def parsedTab = line.split("\t"); |
---|
52 | |
---|
53 | for (j in parsedTab) { |
---|
54 | tmp_list.add(j); |
---|
55 | } |
---|
56 | |
---|
57 | if (tmp_list.size() > 1){ |
---|
58 | if (tmp_list[0]=="Investigation Title"){ |
---|
59 | investigationDesign.title = tmp_list[1]; |
---|
60 | } |
---|
61 | else if (tmp_list[0]=="Comment[AEMIAMESCORE]") { |
---|
62 | comment.aemiameScore = tmp_list[1]; |
---|
63 | } |
---|
64 | else if (tmp_list[0]=="Comment[SecondaryAccession]") { |
---|
65 | comment.secondaryAccession = tmp_list[1]; |
---|
66 | } |
---|
67 | else if (tmp_list[0]=="Comment[ArrayExpressReleaseDate]") { |
---|
68 | comment.arrayExpressReleaseDate = tmp_list[1]; |
---|
69 | } |
---|
70 | else if (tmp_list[0]=="Comment[ArrayExpressAccession]") { |
---|
71 | comment.arrayExpressAccession = tmp_list[1]; |
---|
72 | } |
---|
73 | else if (tmp_list[0]=="Comment[MAGETAB TimeStamp_Version]") { |
---|
74 | comment.timestamp_version = tmp_list[1]; |
---|
75 | } |
---|
76 | else if (tmp_list[0]=="Experimental Design") { |
---|
77 | String design = tmp_list[1]; |
---|
78 | for (a in 2..tmp_list.size()-1){ |
---|
79 | design = design + " , " +tmp_list[a]; |
---|
80 | } |
---|
81 | experimentalInfo.design = design; |
---|
82 | } |
---|
83 | else if (tmp_list[0]=="Experimental Design Term Source REF") { |
---|
84 | String value = get_string(tmp_list); |
---|
85 | experimentalInfo.design_term_source_ref = value; |
---|
86 | //render("value : " + value ); |
---|
87 | println("value : "+value); |
---|
88 | } |
---|
89 | else if (tmp_list[0]=="Experimental Factor Name") { |
---|
90 | String factor_name = tmp_list[1]; |
---|
91 | for (a in 2..tmp_list.size()-1){ |
---|
92 | factor_name = factor_name + " , " +tmp_list[a]; |
---|
93 | } |
---|
94 | factor.name = factor_name; |
---|
95 | } |
---|
96 | //else if (tmp_list[0]=="Experimental Factor Type") { |
---|
97 | // String factor_type = tmp_list[1]; |
---|
98 | // for (a in 2..tmp_list.size()-1){ |
---|
99 | // factor_type = factor_type + " , " +tmp_list[a]; |
---|
100 | // } |
---|
101 | // factor.type = factor_type; |
---|
102 | //} |
---|
103 | else if (tmp_list[0]=="Experimental Factor Term Source REF") { |
---|
104 | String exp_ref = tmp_list[1]; |
---|
105 | for (a in 2..tmp_list.size()-1){ |
---|
106 | exp_ref = exp_ref + " , " +tmp_list[a]; |
---|
107 | } |
---|
108 | experimentalInfo.factor_term_source_ref = exp_ref; |
---|
109 | } |
---|
110 | else if (tmp_list[0]=="Person Last Name") { |
---|
111 | String last_name = tmp_list[1]; |
---|
112 | for (a in 2..tmp_list.size()-1){ |
---|
113 | last_name = last_name + " , " +tmp_list[a]; |
---|
114 | } |
---|
115 | person.lastName = last_name; |
---|
116 | } |
---|
117 | else if (tmp_list[0]=="Person First Name") { |
---|
118 | String first_name = tmp_list[1]; |
---|
119 | for (a in 2..tmp_list.size()-1){ |
---|
120 | first_name = first_name + " , " +tmp_list[a]; |
---|
121 | } |
---|
122 | person.firstName = first_name; |
---|
123 | } |
---|
124 | else if (tmp_list[0]=="Person Mid Initials") { |
---|
125 | String mid_initials = tmp_list[1]; |
---|
126 | for (a in 2..tmp_list.size()-1){ |
---|
127 | mid_initials = mid_initials + " , " +tmp_list[a]; |
---|
128 | } |
---|
129 | person.midInitials = mid_initials; |
---|
130 | } |
---|
131 | else if (tmp_list[0]=="Person Email") { |
---|
132 | String pemail = tmp_list[1]; |
---|
133 | for (a in 2..tmp_list.size()-1){ |
---|
134 | pemail = pemail + " , " +tmp_list[a]; |
---|
135 | } |
---|
136 | person.email = pemail; |
---|
137 | } |
---|
138 | else if (tmp_list[0]=="Person Phone") { |
---|
139 | String pphone = tmp_list[1]; |
---|
140 | for (a in 2..tmp_list.size()-1){ |
---|
141 | pphone = pphone + " , " +tmp_list[a]; |
---|
142 | } |
---|
143 | person.phone = pphone; |
---|
144 | } |
---|
145 | else if (tmp_list[0]=="Person Fax") { |
---|
146 | String pfax = tmp_list[1]; |
---|
147 | for (a in 2..tmp_list.size()-1){ |
---|
148 | pfax = pfax + " , " +tmp_list[a]; |
---|
149 | } |
---|
150 | person.fax = pfax; |
---|
151 | } |
---|
152 | else if (tmp_list[0]=="Person Address") { |
---|
153 | String paddress = tmp_list[1]; |
---|
154 | for (a in 2..tmp_list.size()-1){ |
---|
155 | paddress = paddress + " , " +tmp_list[a]; |
---|
156 | } |
---|
157 | person.address = paddress; |
---|
158 | } |
---|
159 | else if (tmp_list[0]=="Person Affiliation") { |
---|
160 | String paffiliation = tmp_list[1]; |
---|
161 | for (a in 2..tmp_list.size()-1){ |
---|
162 | paffiliation = paffiliation + " , " +tmp_list[a]; |
---|
163 | } |
---|
164 | person.affiliation = paffiliation; |
---|
165 | } |
---|
166 | else if (tmp_list[0]=="Person Roles") { |
---|
167 | String proles = tmp_list[1]; |
---|
168 | for (a in 2..tmp_list.size()-1){ |
---|
169 | proles = proles + " , " +tmp_list[a]; |
---|
170 | } |
---|
171 | person.roles = proles; |
---|
172 | } |
---|
173 | else if (tmp_list[0]=="Person Roles Term Source REF") { |
---|
174 | person.roles_ref = tmp_list[1]; |
---|
175 | } |
---|
176 | else if (tmp_list[0]=="Quality Control Type") { |
---|
177 | |
---|
178 | } |
---|
179 | else if (tmp_list[0]=="Quality Control Term Source REF") { |
---|
180 | |
---|
181 | } |
---|
182 | else if (tmp_list[0]=="Replicate Type") { |
---|
183 | |
---|
184 | } |
---|
185 | else if (tmp_list[0]=="Replicate Term Source REF") { |
---|
186 | |
---|
187 | } |
---|
188 | else if (tmp_list[0]=="Normalization Type") { |
---|
189 | normalization.type = tmp_list[1]; |
---|
190 | } |
---|
191 | else if (tmp_list[0]=="Normalization Term Source REF") { |
---|
192 | normalization.term_source_ref = tmp_list[1]; |
---|
193 | } |
---|
194 | else if (tmp_list[0]=="Date Of Experiment") { |
---|
195 | investigationDesign.dateOfExperiment = tmp_list[1]; |
---|
196 | } |
---|
197 | else if (tmp_list[0]=="Public Release Date") { |
---|
198 | investigationDesign.publicReleaseDate = tmp_list[1]; |
---|
199 | } |
---|
200 | else if (tmp_list[0]=="PubMed ID") { |
---|
201 | publication.pubMedID = tmp_list[1]; |
---|
202 | } |
---|
203 | else if (tmp_list[0]=="Publication DOI") { |
---|
204 | String doi = tmp_list[1]; |
---|
205 | for (a in 2..tmp_list.size()-1){ |
---|
206 | doi = doi + " , " +tmp_list[a]; |
---|
207 | } |
---|
208 | publication.DOI = doi; |
---|
209 | } |
---|
210 | else if (tmp_list[0]=="Publication Author List") { |
---|
211 | publication.authors_list = tmp_list[1]; |
---|
212 | } |
---|
213 | else if (tmp_list[0]=="Publication Title") { |
---|
214 | String pubTitle = tmp_list[1]; |
---|
215 | for (a in 2..tmp_list.size()-1){ |
---|
216 | pubTitle = pubTitle + " , " +tmp_list[a]; |
---|
217 | } |
---|
218 | publication.title = pubTitle; |
---|
219 | } |
---|
220 | else if (tmp_list[0]=="Publication Status") { |
---|
221 | def status = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
222 | status.text = tmp_list[1]; |
---|
223 | status.save(); |
---|
224 | publication.status = status; |
---|
225 | } |
---|
226 | else if (tmp_list[0]=="Publication Status Term Source REF") { |
---|
227 | publication.status_term_source_ref = tmp_list[1]; |
---|
228 | } |
---|
229 | else if (tmp_list[0]=="Experiment Description") { |
---|
230 | investigationDesign.experimentDescription = tmp_list[1]; |
---|
231 | } |
---|
232 | else if (tmp_list[0]=="Protocol Name") { |
---|
233 | String protocol_name = tmp_list[1]; |
---|
234 | for (a in 2..tmp_list.size()-1){ |
---|
235 | protocol_name = protocol_name + " , " +tmp_list[a]; |
---|
236 | } |
---|
237 | protocol.name = protocol_name; |
---|
238 | } |
---|
239 | //todo list of type |
---|
240 | else if (tmp_list[0]=="Protocol Type") { |
---|
241 | def type = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
242 | for (j in 1..tmp_list.size()){ |
---|
243 | type.text = tmp_list[j]; |
---|
244 | type.save(); |
---|
245 | } |
---|
246 | protocol.type = type; |
---|
247 | } |
---|
248 | else if (tmp_list[0]=="Protocol Description") { |
---|
249 | String protocol_description = tmp_list[1]; |
---|
250 | for (a in 2..tmp_list.size()-1){ |
---|
251 | protocol_description = protocol_description + " , " +tmp_list[a]; |
---|
252 | } |
---|
253 | protocol.description = protocol_description; |
---|
254 | } |
---|
255 | else if (tmp_list[0]=="Protocol Parameters") { |
---|
256 | String protocol_parameters = tmp_list[1]; |
---|
257 | for (a in 2..tmp_list.size()-1){ |
---|
258 | protocol_parameters = protocol_parameters + " , " +tmp_list[a]; |
---|
259 | } |
---|
260 | protocol.parameters = protocol_parameters; |
---|
261 | } |
---|
262 | else if (tmp_list[0]=="Protocol Hardware") { |
---|
263 | String phardware = tmp_list[1]; |
---|
264 | for (a in 2..tmp_list.size()-1){ |
---|
265 | phardware = phardware + " , " +tmp_list[a]; |
---|
266 | } |
---|
267 | protocol.hardware = phardware; |
---|
268 | } |
---|
269 | else if (tmp_list[0]=="Protocol Software") { |
---|
270 | String psoftware = tmp_list[1]; |
---|
271 | for (a in 2..tmp_list.size()-1){ |
---|
272 | psoftware = psoftware + " , " +tmp_list[a]; |
---|
273 | } |
---|
274 | protocol.software = psoftware; |
---|
275 | } |
---|
276 | else if (tmp_list[0]=="Protocol Contact") { |
---|
277 | String pcontact = tmp_list[1]; |
---|
278 | for (a in 2..tmp_list.size()-1){ |
---|
279 | pcontact = pcontact + " , " +tmp_list[a]; |
---|
280 | } |
---|
281 | protocol.contact = pcontact; |
---|
282 | } |
---|
283 | else if (tmp_list[0]=="Protocol Term Source REF") { |
---|
284 | protocol.term_source_ref = tmp_list[1]; |
---|
285 | } |
---|
286 | else if (tmp_list[0]=="SDRF File") { |
---|
287 | String sdrf = tmp_list[1]; |
---|
288 | for (a in 2..tmp_list.size()-1){ |
---|
289 | sdrf = sdrf + " , " +tmp_list[a]; |
---|
290 | } |
---|
291 | investigationDesign.sdrf_file = sdrf; |
---|
292 | } |
---|
293 | else if (tmp_list[0]=="Term Source Name") { |
---|
294 | //termSource.name = tmp_list[1]; |
---|
295 | } |
---|
296 | else if (tmp_list[0]=="Term Source File") { |
---|
297 | //termSource.file = tmp_list[1]; |
---|
298 | } |
---|
299 | else if (tmp_list[0]=="Term Source Version") { |
---|
300 | //termSource.version = tmp_list[1]; |
---|
301 | } |
---|
302 | } |
---|
303 | |
---|
304 | person.save(); |
---|
305 | protocol.save(); |
---|
306 | publication.save(); |
---|
307 | normalization.save(); |
---|
308 | investigationDesign.save(); |
---|
309 | comment.save(); |
---|
310 | experimentalInfo.save(); |
---|
311 | //factor.save(); |
---|
312 | //termSource.save(); |
---|
313 | } |
---|
314 | } |
---|
315 | } |
---|
316 | |
---|