2020-09-23 19:12:25 +02:00
|
|
|
package com.plannaplan.services;
|
2020-07-23 17:27:20 +02:00
|
|
|
|
|
|
|
import com.plannaplan.models.ConfigData;
|
2020-08-04 17:30:03 +02:00
|
|
|
import com.plannaplan.models.FileData;
|
2020-07-23 17:27:20 +02:00
|
|
|
|
2020-08-04 17:30:03 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import com.plannaplan.configutils.*;
|
2020-12-09 16:43:29 +01:00
|
|
|
import com.plannaplan.entities.AppConfig;
|
2020-08-04 17:30:03 +02:00
|
|
|
|
2020-11-20 13:20:44 +01:00
|
|
|
/**
|
2020-12-09 16:43:29 +01:00
|
|
|
* FileReader is used for reading xls file from input stream.
|
2020-11-20 13:20:44 +01:00
|
|
|
*/
|
2020-08-04 17:30:03 +02:00
|
|
|
@Component
|
2020-09-23 19:12:25 +02:00
|
|
|
public class ConfiguratorService {
|
2020-07-23 17:27:20 +02:00
|
|
|
|
2020-08-04 17:30:03 +02:00
|
|
|
@Autowired
|
2020-09-25 16:43:24 +02:00
|
|
|
private FileToDatabaseMigrator migrator;
|
2020-12-09 16:43:29 +01:00
|
|
|
@Autowired
|
|
|
|
private AppConfigService configService;
|
2020-08-06 14:32:41 +02:00
|
|
|
|
2020-09-23 19:12:25 +02:00
|
|
|
public ConfiguratorService() {
|
2020-07-23 17:27:20 +02:00
|
|
|
}
|
|
|
|
|
2020-12-09 16:43:29 +01:00
|
|
|
/**
|
|
|
|
* methoid to config system
|
|
|
|
*
|
|
|
|
* @param data ConfigData containng system congis
|
|
|
|
*/
|
2020-07-23 17:27:20 +02:00
|
|
|
public void config(ConfigData data) {
|
2020-08-04 17:30:03 +02:00
|
|
|
FileReader reader = new FileReader(data.getFilestream());
|
|
|
|
FileData coursesData = reader.read();
|
2020-12-09 16:43:29 +01:00
|
|
|
this.configService.save(new AppConfig(data.getFirstTour(), data.getSecondTour()));
|
2020-09-21 17:45:52 +02:00
|
|
|
migrator.migrate(coursesData);
|
2020-07-23 17:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|