From afa72e5d991cc756275cbcf7596cb5aa0d8f11f9 Mon Sep 17 00:00:00 2001 From: suyeshamatya Date: Mon, 19 Oct 2015 22:21:53 +0200 Subject: [PATCH] change mapper output to generate the file according to the latest parser requirement. --- Map.csv | 52 +++++++++++++++++-------------- src/my/mapper/MapperUI.java | 61 +++++++++++++++++++++++++------------ 2 files changed, 70 insertions(+), 43 deletions(-) diff --git a/Map.csv b/Map.csv index 26e03fd..cea8eaf 100644 --- a/Map.csv +++ b/Map.csv @@ -1,23 +1,29 @@ -1,PROJECT_ID,Sample Collection,ID -2,name,Sample Collection,Name -3,TITLE,Sample Collection,Acronym -4,DESCRIPTION,Sample Collection,Description -9,CONTACT_ID,Sample Collection,Contact Information ID -1,STUDY_CODE,Study,ID -2,NAME,Study,Name -4,DESCRIPTION,Study,Description -5,KI_STUDY_TYPE,Study,Study Design -9,CONTACT_ID,Study,Contact Information ID -1,provid,Sample,Sample ID -3,SAMPLE_TYPE,Sample,Material Type -7,T_GENDER,Sample,Sex -13,PROJECT_ID,Sample,Sample Collection ID -14,STUDY_CODE,Sample,Study ID -2,FIRST_NAME,Contact Information,First Name -3,LAST_NAME,Contact Information,Last Name -4,PHONE_NO,Contact Information,Phone -5,EMAIL_ADDRESS,Contact Information,Email -6,ADDRESS,Contact Information,Address -7,ZIPCODE,Contact Information,ZIP -8,CITY,Contact Information,City -9,COUNTRY,Contact Information,Country +#Sample Collection +sampleCollection.ID=PROJECT_ID +sampleCollection.Name=name +sampleCollection.Acronym=TITLE +sampleCollection.Description=DESCRIPTION +sampleCollection.Contact Information ID=CONTACT_ID +#Study +study.ID=STUDY_CODE +study.Name=NAME +study.Description=DESCRIPTION +study.Study Design=KI_STUDY_TYPE +study.Principal Investigator=GROUP_NAME +study.Contact Information ID=CONTACT_ID +#Sample +sample.Sample ID=provid +sample.Material Type=SAMPLE_TYPE +sample.Sex=T_GENDER +sample.Sample Collection ID=PROJECT_ID +sample.Study ID=STUDY_CODE +#Contact Information + +contactInformation.First Name=FIRST_NAME +contactInformation.Last Name=LAST_NAME +contactInformation.Phone=PHONE_NO +contactInformation.Email=EMAIL_ADDRESS +contactInformation.Address=ADDRESS +contactInformation.ZIP=ZIPCODE +contactInformation.City=CITY +contactInformation.Country=COUNTRY diff --git a/src/my/mapper/MapperUI.java b/src/my/mapper/MapperUI.java index 87ce522..a1430e2 100644 --- a/src/my/mapper/MapperUI.java +++ b/src/my/mapper/MapperUI.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package src.my.mapper; +package my.mapper; import java.io.BufferedReader; import java.io.File; @@ -1151,10 +1151,10 @@ private void saveMapToFile(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sav try { mappingFile.createNewFile(); fw = new FileWriter(mappingFile); - writeMapToFile(TableSCBiobank, fw); - writeMapToFile(TableSTBiobank, fw); - writeMapToFile(TableSABiobank, fw); - writeMapToFile(TableCIBiobank, fw); + writeMapToFile(TableSCBiobank, fw, "Sample Collection"); + writeMapToFile(TableSTBiobank, fw, "Study"); + writeMapToFile(TableSABiobank, fw, "Sample"); + writeMapToFile(TableCIBiobank, fw, "Contact Information"); } catch (IOException ex) { Logger.getLogger(MapperUI.class.getName()).log(Level.SEVERE, null, ex); } @@ -1169,7 +1169,7 @@ private void saveMapToFile(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sav }//GEN-LAST:event_saveMapToFile - private void writeMapToFile(JTable jTable, FileWriter fw) throws IOException{ + private void writeMapToFile(JTable jTable, FileWriter fw, String entityName) throws IOException{ DefaultTableModel dtm = (DefaultTableModel) jTable.getModel(); int nRow = dtm.getRowCount(), nCol = dtm.getColumnCount(); @@ -1177,22 +1177,43 @@ private void writeMapToFile(JTable jTable, FileWriter fw) throws IOException{ System.out.println(" dtm.getValueAt(0,0) "+dtm.getValueAt(0,0)); System.out.println(" dtm.getValueAt(0,3) "+dtm.getValueAt(0,3)); int prevRow = 0; + fw.write("#"+entityName); + fw.write(System.lineSeparator()); + StringBuffer miabisEntityName = new StringBuffer(); + String[] strArr = entityName.split("\\s"); + int count = 0; + for (String str : strArr) { + char[] stringArray = str.trim().toCharArray(); + if(count == 0){ + stringArray[0] = Character.toLowerCase(stringArray[0]); + } + else{ + stringArray[0] = Character.toUpperCase(stringArray[0]); + } + str = new String(stringArray); + miabisEntityName.append(str); + count++; + } for (int i = 0 ; i < nRow ; i++){ - for (int j = 0 ; j < nCol ; j++){ - //if(j != 1){ - if(dtm.getValueAt(i,2) != null && dtm.getValueAt(i,3) != null){ - if(i > prevRow){ - fw.write(System.lineSeparator()); - } - fw.write(dtm.getValueAt(i,j).toString()); - if(j == 0 || j==1 || j==2){ - fw.write(","); - } - prevRow = i; - } - + //for (int j = 0 ; j < nCol ; j++){ + //if(j != 1){ + if(dtm.getValueAt(i,2) != null && dtm.getValueAt(i,3) != null){ + if(i > prevRow){ + fw.write(System.lineSeparator()); + } + fw.write(miabisEntityName.toString()); + fw.write("."); + fw.write(dtm.getValueAt(i,3).toString()); + fw.write("="); + fw.write(dtm.getValueAt(i,1).toString()); + /*if(j == 0 || j==1 || j==2){ + fw.write(","); + }*/ + prevRow = i; + } + + //} //} - } } fw.write(System.lineSeparator());