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 | |
---|
44 | //ArrayList rows = new ArrayList(); |
---|
45 | |
---|
46 | for (i in fileReader.readLines()){ |
---|
47 | render(i); |
---|
48 | String line = i.toString() ; |
---|
49 | ArrayList tmp_list = new ArrayList(); |
---|
50 | def parsedTab = line.split("\t"); |
---|
51 | |
---|
52 | for (j in parsedTab) { |
---|
53 | tmp_list.add(j); |
---|
54 | } |
---|
55 | |
---|
56 | if (tmp_list.size() > 1){ |
---|
57 | if (tmp_list[0]=="Investigation Title"){ |
---|
58 | investigationDesign.title = tmp_list[1]; |
---|
59 | } |
---|
60 | else if (tmp_list[0]=="Comment[AEMIAMESCORE]") { |
---|
61 | comment.aemiameScore = tmp_list[1]; |
---|
62 | } |
---|
63 | else if (tmp_list[0]=="Comment[SecondaryAccession]") { |
---|
64 | comment.secondaryAccession = tmp_list[1]; |
---|
65 | } |
---|
66 | else if (tmp_list[0]=="Comment[ArrayExpressReleaseDate]") { |
---|
67 | comment.arrayExpressReleaseDate = tmp_list[1]; |
---|
68 | } |
---|
69 | else if (tmp_list[0]=="Comment[ArrayExpressAccession]") { |
---|
70 | comment.arrayExpressAccession = tmp_list[1]; |
---|
71 | } |
---|
72 | else if (tmp_list[0]=="Comment[MAGETAB TimeStamp_Version]") { |
---|
73 | comment.timestamp_version = tmp_list[1]; |
---|
74 | } |
---|
75 | else if (tmp_list[0]=="Experimental Design") { |
---|
76 | String design = tmp_list[1]; |
---|
77 | for (a in 2..tmp_list.size()-1){ |
---|
78 | design = design + " , " +tmp_list[a]; |
---|
79 | } |
---|
80 | experimentalInfo.design = design; |
---|
81 | } |
---|
82 | else if (tmp_list[0]=="Experimental Design Term Source REF") { |
---|
83 | String value = get_string(tmp_list); |
---|
84 | experimentalInfo.design_term_source_ref = value; |
---|
85 | render("value : " + value ); |
---|
86 | println("value : "+value); |
---|
87 | } |
---|
88 | else if (tmp_list[0]=="Experimental Factor Name") { |
---|
89 | String factor_name = tmp_list[1]; |
---|
90 | for (a in 2..tmp_list.size()-1){ |
---|
91 | factor_name = factor_name + " , " +tmp_list[a]; |
---|
92 | } |
---|
93 | experimentalInfo.factor_name = factor_name; |
---|
94 | } |
---|
95 | else if (tmp_list[0]=="Experimental Factor Type") { |
---|
96 | String factor_type = tmp_list[1]; |
---|
97 | for (a in 2..tmp_list.size()-1){ |
---|
98 | factor_type = factor_type + " , " +tmp_list[a]; |
---|
99 | } |
---|
100 | experimentalInfo.factor_type = factor_type; |
---|
101 | } |
---|
102 | else if (tmp_list[0]=="Experimental Factor Term Source REF") { |
---|
103 | String exp_ref = tmp_list[1]; |
---|
104 | for (a in 2..tmp_list.size()-1){ |
---|
105 | exp_ref = exp_ref + " , " +tmp_list[a]; |
---|
106 | } |
---|
107 | experimentalInfo.factor_term_source_ref = exp_ref; |
---|
108 | } |
---|
109 | else if (tmp_list[0]=="Person Last Name") { |
---|
110 | person.lastName = tmp_list[1]; |
---|
111 | } |
---|
112 | else if (tmp_list[0]=="Person First Name") { |
---|
113 | person.firstName = tmp_list[1]; |
---|
114 | } |
---|
115 | else if (tmp_list[0]=="Person Mid Initials") { |
---|
116 | person.midInitials = tmp_list[1]; |
---|
117 | } |
---|
118 | else if (tmp_list[0]=="Person Email") { |
---|
119 | person.email = tmp_list[1]; |
---|
120 | } |
---|
121 | else if (tmp_list[0]=="Person Phone") { |
---|
122 | person.phone = tmp_list[1]; |
---|
123 | } |
---|
124 | else if (tmp_list[0]=="Person Fax") { |
---|
125 | person.fax = tmp_list[1]; |
---|
126 | } |
---|
127 | else if (tmp_list[0]=="Person Address") { |
---|
128 | person.address = tmp_list[1]; |
---|
129 | } |
---|
130 | else if (tmp_list[0]=="Person Affiliation") { |
---|
131 | person.affiliation = tmp_list[1]; |
---|
132 | } |
---|
133 | else if (tmp_list[0]=="Person Roles") { |
---|
134 | person.roles = tmp_list[1]; |
---|
135 | } |
---|
136 | else if (tmp_list[0]=="Person Roles Term Source REF") { |
---|
137 | person.roles_ref = tmp_list[1]; |
---|
138 | } |
---|
139 | else if (tmp_list[0]=="Quality Control Type") { |
---|
140 | |
---|
141 | } |
---|
142 | else if (tmp_list[0]=="Quality Control Term Source REF") { |
---|
143 | |
---|
144 | } |
---|
145 | else if (tmp_list[0]=="Replicate Type") { |
---|
146 | |
---|
147 | } |
---|
148 | else if (tmp_list[0]=="Replicate Term Source REF") { |
---|
149 | |
---|
150 | } |
---|
151 | else if (tmp_list[0]=="Normalization Type") { |
---|
152 | normalization.type = tmp_list[1]; |
---|
153 | } |
---|
154 | else if (tmp_list[0]=="Normalization Term Source REF") { |
---|
155 | normalization.term_source_ref = tmp_list[1]; |
---|
156 | } |
---|
157 | else if (tmp_list[0]=="Date Of Experiment") { |
---|
158 | investigationDesign.dateOfExperiment = tmp_list[1]; |
---|
159 | } |
---|
160 | else if (tmp_list[0]=="Public Release Date") { |
---|
161 | investigationDesign.publicReleaseDate = tmp_list[1]; |
---|
162 | } |
---|
163 | else if (tmp_list[0]=="PubMed ID") { |
---|
164 | publication.pubMedID = tmp_list[1]; |
---|
165 | } |
---|
166 | else if (tmp_list[0]=="Publication DOI") { |
---|
167 | publication.DOI = tmp_list[1]; |
---|
168 | } |
---|
169 | else if (tmp_list[0]=="Publication Author List") { |
---|
170 | publication.authors_list = tmp_list[1]; |
---|
171 | } |
---|
172 | else if (tmp_list[0]=="Publication Title") { |
---|
173 | publication.title = tmp_list[1]; |
---|
174 | } |
---|
175 | else if (tmp_list[0]=="Publication Status") { |
---|
176 | def status = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
177 | status.text = tmp_list[1]; |
---|
178 | status.save(); |
---|
179 | publication.status = status; |
---|
180 | } |
---|
181 | else if (tmp_list[0]=="Publication Status Term Source REF") { |
---|
182 | publication.status_term_source_ref = tmp_list[1]; |
---|
183 | } |
---|
184 | else if (tmp_list[0]=="Experiment Description") { |
---|
185 | investigationDesign.experimentDescription = tmp_list[1]; |
---|
186 | } |
---|
187 | else if (tmp_list[0]=="Protocol Name") { |
---|
188 | String protocol_name = tmp_list[1]; |
---|
189 | for (a in 2..tmp_list.size()-1){ |
---|
190 | protocol_name = protocol_name + " , " +tmp_list[a]; |
---|
191 | } |
---|
192 | protocol.name = protocol_name; |
---|
193 | } |
---|
194 | //todo list of type |
---|
195 | else if (tmp_list[0]=="Protocol Type") { |
---|
196 | def type = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
197 | for (j in 1..tmp_list.size()){ |
---|
198 | type.text = tmp_list[j]; |
---|
199 | type.save(); |
---|
200 | } |
---|
201 | protocol.type = type; |
---|
202 | } |
---|
203 | else if (tmp_list[0]=="Protocol Description") { |
---|
204 | String protocol_description = tmp_list[1]; |
---|
205 | for (a in 2..tmp_list.size()-1){ |
---|
206 | protocol_description = protocol_description + " , " +tmp_list[a]; |
---|
207 | } |
---|
208 | protocol.description = protocol_description; |
---|
209 | } |
---|
210 | else if (tmp_list[0]=="Protocol Parameters") { |
---|
211 | String protocol_parameters = tmp_list[1]; |
---|
212 | for (a in 2..tmp_list.size()-1){ |
---|
213 | protocol_parameters = protocol_parameters + " , " +tmp_list[a]; |
---|
214 | } |
---|
215 | protocol.parameters = protocol_parameters; |
---|
216 | } |
---|
217 | else if (tmp_list[0]=="Protocol Hardware") { |
---|
218 | protocol.hardware = tmp_list[1]; |
---|
219 | } |
---|
220 | else if (tmp_list[0]=="Protocol Software") { |
---|
221 | protocol.software = tmp_list[1]; |
---|
222 | } |
---|
223 | else if (tmp_list[0]=="Protocol Contact") { |
---|
224 | protocol.contact = tmp_list[1]; |
---|
225 | } |
---|
226 | else if (tmp_list[0]=="Protocol Term Source REF") { |
---|
227 | protocol.term_source_ref = tmp_list[1]; |
---|
228 | } |
---|
229 | else if (tmp_list[0]=="SDRF File") { |
---|
230 | investigationDesign.sdrf_file = tmp_list[1]; |
---|
231 | } |
---|
232 | else if (tmp_list[0]=="Term Source Name") { |
---|
233 | //termSource.name = tmp_list[1]; |
---|
234 | } |
---|
235 | else if (tmp_list[0]=="Term Source File") { |
---|
236 | //termSource.file = tmp_list[1]; |
---|
237 | } |
---|
238 | else if (tmp_list[0]=="Term Source Version") { |
---|
239 | //termSource.version = tmp_list[1]; |
---|
240 | } |
---|
241 | } |
---|
242 | |
---|
243 | person.save(); |
---|
244 | protocol.save(); |
---|
245 | publication.save(); |
---|
246 | normalization.save(); |
---|
247 | investigationDesign.save(); |
---|
248 | comment.save(); |
---|
249 | experimentalInfo.save(); |
---|
250 | //termSource.save(); |
---|
251 | |
---|
252 | } |
---|
253 | |
---|
254 | } |
---|
255 | |
---|
256 | } |
---|
257 | |
---|