func importFromDB(collections []string) { // var data []map[string]interface{} for _, name := range collections { // Reads through all the collections whose transformations are in the strategy configuration file foreignEntity := source.GetForeignEntity(name) log.User(uuid, "sponge.importAll", "### Reading data to import from %s into collection '%s'. \n", foreignEntity, name) // Get the data data, err := dbsource.GetData(name, &options) //options.offset, options.limit, options.orderby, "") if err != nil { log.Error(uuid, "sponge.importAll", err, "Get external data for collection %s.", name) //RECORD to report about failing modelName if options.ReportOnFailedRecords { report.Record(name, "", "Failing to get data.", err) } continue } log.User(uuid, "sponge.importAll", "### Transforming data and sending it to Coral. \n") //transform and send to pillar the data process(name, data) } }
// ImportType gets ony data related to table, transform it and send it to pillar func importType(coralEntity string) { //dbsource source.Sourcer, limit int, offset int, orderby string, query string, modelName string, reportOnFailedRecords bool) { foreignEntity := source.GetForeignEntity(coralEntity) // Get the data log.User(uuid, "sponge.importTable", "### Reading data from table '%s'.", foreignEntity) data, err := dbsource.GetData(foreignEntity, &options) //options.offset, options.limit, options.orderby, options.query) if err != nil { log.Error(uuid, "sponge.importAll", err, "Get external data for table %s.", foreignEntity) //RECORD to report about failing modelName if options.ReportOnFailedRecords { report.Record(foreignEntity, "", "Failing to get data", err) } return } // Transform and send to pillar process(coralEntity, data) }