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.*;
|
|
|
|
|
|
|
|
@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-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
|
|
|
}
|
|
|
|
|
|
|
|
public void config(ConfigData data) {
|
2020-08-04 17:30:03 +02:00
|
|
|
FileReader reader = new FileReader(data.getFilestream());
|
|
|
|
FileData coursesData = reader.read();
|
2020-09-21 17:45:52 +02:00
|
|
|
migrator.migrate(coursesData);
|
2020-07-23 17:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|