Skip to content

Commit

Permalink
change mapper output to generate the file according to the latest parser
Browse files Browse the repository at this point in the history
requirement.
  • Loading branch information
suyesh-amatya committed Oct 19, 2015
1 parent 7a6df05 commit afa72e5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 43 deletions.
52 changes: 29 additions & 23 deletions Map.csv
Original file line number Diff line number Diff line change
@@ -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
61 changes: 41 additions & 20 deletions src/my/mapper/MapperUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -1169,30 +1169,51 @@ 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();
System.out.println(" row "+nRow+" cols "+nCol);
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());
Expand Down

0 comments on commit afa72e5

Please sign in to comment.