package com.munjaon.client.service;

import com.munjaon.client.cubrid.service.CubridService;
import com.munjaon.client.mariadb.service.MariaDBService;
import com.munjaon.client.mssql.service.MssqlService;
import com.munjaon.client.mysql.service.MysqlService;
import com.munjaon.client.oracle.service.OracleService;
import com.munjaon.client.postgresql.service.PostgresqlService;
import com.munjaon.client.tibero.service.TiberoService;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

@Component
public class DatabaseServiceInjector {
    @Autowired
    private CubridService cubridService;
    @Autowired
    private MariaDBService mariaDBService;
    @Autowired
    private MssqlService mssqlService;
    @Autowired
    private MysqlService mysqlService;
    @Autowired
    private OracleService oracleService;
    @Autowired
    private PostgresqlService postgresqlService;
    @Autowired
    private TiberoService tiberoService;

    @PostConstruct
    public void postConstruct() {
        for (DatabaseService svc : EnumSet.allOf(DatabaseService.class)) {
            switch (svc) {
                case CUBRID_SERVICE:        svc.setService(cubridService);
                    break;
                case MARIADB_SERVICE:       svc.setService(mariaDBService);
                    break;
                case MSSQL_SERVICE:         svc.setService(mssqlService);
                    break;
                case MYSQL_SERVICE:         svc.setService(mysqlService);
                    break;
                case ORACLE_SERVICE:        svc.setService(oracleService);
                    break;
                case POSTGRESQL_SERVICE : svc.setService(postgresqlService);
                    break;
                case TIBERO_SERVICE:        svc.setService(tiberoService);
                    break;
                default:                    break;
            }
        }
    }
}
