/**
 * Created by warlock on 20/05/16.
 */

var elasticsearch = require('elasticsearch');
var fs = require('fs');
var config = require('../../server/config.js');
var _ = require('underscore');
var data = {};

var dataFiles = fs.readdirSync('./DummyData');
_.forEach(dataFiles,function(fileName){
    var indexName = fileName.substr(0,fileName.indexOf('Data'));
    console.log("Index Name : "+ indexName);
    data[indexName] = require('./DummyData/'+fileName);
});


var esClient = elasticsearch.Client({
   'host' : config.elasticsearch.url,
    'log' : 'info'
});

var addData = function(dataObj){
    return esClient.index(dataObj);
};

var addDataWrapper = function(dataObj){
    console.log("Adding data for the type : " + dataObj.type);
    addData(dataObj).then(function(res){
            console.log("Data Added for the type : " + dataObj.type);
        },
        function(error){
            console.log("Error occured while adding data for type : " + dataObj.type + " ,Error msg : " + error.message);
        });
};

var start = function(){
    _.forEach(data,function(eachIndex){
        _.forEach(eachIndex,function(eachType){
            _.forEach(eachType,function(eachData){
                addDataWrapper(eachData);
            });
        });
    });

};

start();
@@ -1,11 +1,12 @@
 /**
+%0D
 %0A * Crea
@@ -28,21 +28,24 @@
 on 2
-0
+1
 /05/16.
+%0D
 %0A */
-%0A
+%0D%0A%0D
 %0Avar
@@ -86,16 +86,17 @@
 earch');
+%0D
 %0Avar fs 
@@ -107,24 +107,25 @@
 quire('fs');
+%0D
 %0Avar config 
@@ -160,16 +160,17 @@
 ig.js');
+%0D
 %0Avar _ =
@@ -192,16 +192,17 @@
 score');
+%0D
 %0Avar dat
@@ -208,17 +208,19 @@
 ta = %7B%7D;
-%0A
+%0D%0A%0D
 %0Avar dat
@@ -258,16 +258,17 @@
 yData');
+%0D
 %0A_.forEa
@@ -299,16 +299,17 @@
 leName)%7B
+%0D
 %0A    var
@@ -365,16 +365,17 @@
 Data'));
+%0D
 %0A    con
@@ -411,16 +411,17 @@
 exName);
+%0D
 %0A    dat
@@ -468,22 +468,26 @@
 leName);
+%0D
 %0A%7D);
-%0A%0A
+%0D%0A%0D%0A%0D
 %0Avar esC
@@ -516,16 +516,17 @@
 Client(%7B
+%0D
 %0A   'hos
@@ -555,16 +555,17 @@
 rch.url,
+%0D
 %0A    'lo
@@ -579,13 +579,16 @@
 nfo'
+%0D
 %0A%7D);
-%0A
+%0D%0A%0D
 %0Avar
@@ -612,24 +612,25 @@
 on(dataObj)%7B
+%0D
 %0A    return 
@@ -653,20 +653,23 @@
 ataObj);
+%0D
 %0A%7D;
-%0A
+%0D%0A%0D
 %0Avar add
@@ -700,16 +700,17 @@
 ataObj)%7B
+%0D
 %0A    con
@@ -760,24 +760,25 @@
 taObj.type);
+%0D
 %0A    addData
@@ -806,16 +806,17 @@
 on(res)%7B
+%0D
 %0A       
@@ -877,16 +877,17 @@
 j.type);
+%0D
 %0A       
@@ -889,16 +889,17 @@
       %7D,
+%0D
 %0A       
@@ -915,16 +915,17 @@
 (error)%7B
+%0D
 %0A       
@@ -1038,16 +1038,17 @@
 essage);
+%0D
 %0A       
@@ -1051,20 +1051,23 @@
      %7D);
+%0D
 %0A%7D;
-%0A
+%0D%0A%0D
 %0Avar sta
@@ -1082,16 +1082,17 @@
 ction()%7B
+%0D
 %0A    _.f
@@ -1123,16 +1123,17 @@
 hIndex)%7B
+%0D
 %0A       
@@ -1172,16 +1172,17 @@
 chType)%7B
+%0D
 %0A       
@@ -1224,16 +1224,17 @@
 chData)%7B
+%0D
 %0A       
@@ -1267,16 +1267,17 @@
 chData);
+%0D
 %0A       
@@ -1280,24 +1280,25 @@
          %7D);
+%0D
 %0A        %7D);
@@ -1301,16 +1301,17 @@
  %7D);
+%0D
 %0A    %7D);
 %0A%0A%7D;
@@ -1310,13 +1310,17 @@
  %7D);
-%0A%0A%7D;%0A
+%0D%0A%0D%0A%7D;%0D%0A%0D
 %0Asta

Test Commit from eclipse