In a project we are working on there are large number of pdf files for which field mapping data is stored in the database. In this project pdf forms are auto filled with data from Salesforce. Which PDF form field is mapped to which corresponding Salesforce object or field is the mapping information, which is stored in a MySQL database. We needed to retrieve this mapping information and store in CSV files (one CSV per form). This is the output we expect:
This is the pseudo code:
public static void main(String[] args) throws Exception { // Iterate over each form for each ($formid) { //get mapping data from database query = “select * from form_field_mapping where form_id=$formid”; //AFieldMapping is a custom class in which single row of form field mapping info is stored ListmappingInfo = obj.getData(query); //now store this data in a csv file obj.writeCsv(mappingInfo); writer.close(); }//end for loop public List getData(String query) throws Exception { List mappingInfo = new ArrayList (); //connect to database String dbUrl= "jdbc:mysql://localhost/accord_mapping_db"; String dbUsername= "root"; String dbPassword= "123456"; Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection(dbUrl, dbUsername, dbPassword); //create statement object Statement stmt = con.createStatement(); //send sql query to database ResultSet rs = stmt.executeQuery(query); // iterate ResultSet while(rs.next()){ //create new object of AFieldMapping by using data in the db record and add to mappingInfo } } public void writeCsv(List mappingInfo) throws Exception { String csv = "/home/home/Desktop/result/"+form_number+".csv"; CSVWriter writer = new CSVWriter(new FileWriter(csv)); //iterate over mappingInfo and write the objects in csv }
Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need any software development assistance please contact us at dev@webners.com