[63] | 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 | |
---|
[72] | 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 | |
---|
[63] | 26 | def load = { |
---|
| 27 | |
---|
[70] | 28 | //ArrayList attributes = new ArrayList(); |
---|
[63] | 29 | |
---|
[72] | 30 | render("Loading ...<br>"); |
---|
[63] | 31 | |
---|
[65] | 32 | InputStream inputStream = request.getFile("uploadfile").inputStream; |
---|
| 33 | BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream)); |
---|
[63] | 34 | |
---|
[70] | 35 | def investigationDesign = new dbnp.transcriptomics.magetab.idf.InvestigationDesign(); |
---|
| 36 | def person = new dbnp.transcriptomics.magetab.idf.Person(); |
---|
[83] | 37 | def protocol = new dbnp.transcriptomics.magetab.idf.MAGEProtocol();l |
---|
[70] | 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(); |
---|
[83] | 43 | def factor = new dbnp.transcriptomics.magetab.idf.Factor(); |
---|
[63] | 44 | |
---|
[70] | 45 | //ArrayList rows = new ArrayList(); |
---|
[63] | 46 | |
---|
[65] | 47 | for (i in fileReader.readLines()){ |
---|
[83] | 48 | //render(i); |
---|
[63] | 49 | String line = i.toString() ; |
---|
| 50 | ArrayList tmp_list = new ArrayList(); |
---|
[65] | 51 | def parsedTab = line.split("\t"); |
---|
[63] | 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"){ |
---|
[64] | 59 | investigationDesign.title = tmp_list[1]; |
---|
[63] | 60 | } |
---|
[64] | 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 | } |
---|
[63] | 76 | else if (tmp_list[0]=="Experimental Design") { |
---|
[64] | 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; |
---|
[63] | 82 | } |
---|
[64] | 83 | else if (tmp_list[0]=="Experimental Design Term Source REF") { |
---|
[72] | 84 | String value = get_string(tmp_list); |
---|
| 85 | experimentalInfo.design_term_source_ref = value; |
---|
[83] | 86 | //render("value : " + value ); |
---|
[72] | 87 | println("value : "+value); |
---|
[63] | 88 | } |
---|
| 89 | else if (tmp_list[0]=="Experimental Factor Name") { |
---|
[64] | 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 | } |
---|
[83] | 94 | factor.name = factor_name; |
---|
[63] | 95 | } |
---|
[83] | 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 | //} |
---|
[63] | 103 | else if (tmp_list[0]=="Experimental Factor Term Source REF") { |
---|
[72] | 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; |
---|
[63] | 109 | } |
---|
| 110 | else if (tmp_list[0]=="Person Last Name") { |
---|
[83] | 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; |
---|
[63] | 116 | } |
---|
| 117 | else if (tmp_list[0]=="Person First Name") { |
---|
[83] | 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; |
---|
[63] | 123 | } |
---|
| 124 | else if (tmp_list[0]=="Person Mid Initials") { |
---|
[83] | 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; |
---|
[63] | 130 | } |
---|
| 131 | else if (tmp_list[0]=="Person Email") { |
---|
[83] | 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; |
---|
[63] | 137 | } |
---|
| 138 | else if (tmp_list[0]=="Person Phone") { |
---|
[83] | 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; |
---|
[63] | 144 | } |
---|
| 145 | else if (tmp_list[0]=="Person Fax") { |
---|
[83] | 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; |
---|
[63] | 151 | } |
---|
| 152 | else if (tmp_list[0]=="Person Address") { |
---|
[83] | 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; |
---|
[63] | 158 | } |
---|
| 159 | else if (tmp_list[0]=="Person Affiliation") { |
---|
[83] | 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; |
---|
[63] | 165 | } |
---|
| 166 | else if (tmp_list[0]=="Person Roles") { |
---|
[83] | 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; |
---|
[63] | 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") { |
---|
[64] | 189 | normalization.type = tmp_list[1]; |
---|
[63] | 190 | } |
---|
| 191 | else if (tmp_list[0]=="Normalization Term Source REF") { |
---|
[64] | 192 | normalization.term_source_ref = tmp_list[1]; |
---|
[63] | 193 | } |
---|
| 194 | else if (tmp_list[0]=="Date Of Experiment") { |
---|
[64] | 195 | investigationDesign.dateOfExperiment = tmp_list[1]; |
---|
[63] | 196 | } |
---|
| 197 | else if (tmp_list[0]=="Public Release Date") { |
---|
[64] | 198 | investigationDesign.publicReleaseDate = tmp_list[1]; |
---|
[63] | 199 | } |
---|
| 200 | else if (tmp_list[0]=="PubMed ID") { |
---|
| 201 | publication.pubMedID = tmp_list[1]; |
---|
| 202 | } |
---|
| 203 | else if (tmp_list[0]=="Publication DOI") { |
---|
[83] | 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; |
---|
[63] | 209 | } |
---|
| 210 | else if (tmp_list[0]=="Publication Author List") { |
---|
[64] | 211 | publication.authors_list = tmp_list[1]; |
---|
[63] | 212 | } |
---|
| 213 | else if (tmp_list[0]=="Publication Title") { |
---|
[83] | 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; |
---|
[63] | 219 | } |
---|
| 220 | else if (tmp_list[0]=="Publication Status") { |
---|
[70] | 221 | def status = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
[64] | 222 | status.text = tmp_list[1]; |
---|
| 223 | status.save(); |
---|
| 224 | publication.status = status; |
---|
[63] | 225 | } |
---|
| 226 | else if (tmp_list[0]=="Publication Status Term Source REF") { |
---|
[64] | 227 | publication.status_term_source_ref = tmp_list[1]; |
---|
[63] | 228 | } |
---|
| 229 | else if (tmp_list[0]=="Experiment Description") { |
---|
[64] | 230 | investigationDesign.experimentDescription = tmp_list[1]; |
---|
[63] | 231 | } |
---|
| 232 | else if (tmp_list[0]=="Protocol Name") { |
---|
[72] | 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; |
---|
[63] | 238 | } |
---|
[72] | 239 | //todo list of type |
---|
[63] | 240 | else if (tmp_list[0]=="Protocol Type") { |
---|
[70] | 241 | def type = new dbnp.transcriptomics.magetab.idf.OntologyTerm(); |
---|
[64] | 242 | for (j in 1..tmp_list.size()){ |
---|
| 243 | type.text = tmp_list[j]; |
---|
| 244 | type.save(); |
---|
| 245 | } |
---|
| 246 | protocol.type = type; |
---|
[63] | 247 | } |
---|
| 248 | else if (tmp_list[0]=="Protocol Description") { |
---|
[72] | 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; |
---|
[63] | 254 | } |
---|
| 255 | else if (tmp_list[0]=="Protocol Parameters") { |
---|
[72] | 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; |
---|
[63] | 261 | } |
---|
| 262 | else if (tmp_list[0]=="Protocol Hardware") { |
---|
[83] | 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; |
---|
[63] | 268 | } |
---|
| 269 | else if (tmp_list[0]=="Protocol Software") { |
---|
[83] | 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; |
---|
[63] | 275 | } |
---|
| 276 | else if (tmp_list[0]=="Protocol Contact") { |
---|
[83] | 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; |
---|
[63] | 282 | } |
---|
| 283 | else if (tmp_list[0]=="Protocol Term Source REF") { |
---|
[64] | 284 | protocol.term_source_ref = tmp_list[1]; |
---|
[63] | 285 | } |
---|
| 286 | else if (tmp_list[0]=="SDRF File") { |
---|
[83] | 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; |
---|
[63] | 292 | } |
---|
| 293 | else if (tmp_list[0]=="Term Source Name") { |
---|
[64] | 294 | //termSource.name = tmp_list[1]; |
---|
[63] | 295 | } |
---|
| 296 | else if (tmp_list[0]=="Term Source File") { |
---|
[64] | 297 | //termSource.file = tmp_list[1]; |
---|
[63] | 298 | } |
---|
| 299 | else if (tmp_list[0]=="Term Source Version") { |
---|
[64] | 300 | //termSource.version = tmp_list[1]; |
---|
[63] | 301 | } |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | person.save(); |
---|
| 305 | protocol.save(); |
---|
| 306 | publication.save(); |
---|
[64] | 307 | normalization.save(); |
---|
| 308 | investigationDesign.save(); |
---|
| 309 | comment.save(); |
---|
| 310 | experimentalInfo.save(); |
---|
[83] | 311 | //factor.save(); |
---|
[64] | 312 | //termSource.save(); |
---|
[63] | 313 | } |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | |
---|