package egovframework.com.mtdata.schema.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import egovframework.com.mtdata.database.vo.DatabaseInfoVO;
import egovframework.com.mtdata.schema.service.DatabaseSchemaViewer;

@Service("viService")
public class DatabaseSchemaViewerService {
	private DatabaseSchemaViewer mysqlSchemaViewer;
	private DatabaseSchemaViewer postgreSchemViewer;

	@Resource(name = "mysqlSchemaViewer")
	public void setMysqlSchemaViewer(DatabaseSchemaViewer mysqlSchemaViewer) {
		this.mysqlSchemaViewer = mysqlSchemaViewer;
	}

	@Resource(name = "postgreSchemViewer")
	public void setPostgreSchemViewer(DatabaseSchemaViewer postgreSchemViewer) {
		this.postgreSchemViewer = postgreSchemViewer;
	}

	public void selectSchema(DatabaseInfoVO vo) {
		if ("mysql".equals(vo.getDbType())) {
			mysqlSchemaViewer.viewSchema(vo);
		} else if ("postgresql".equals(vo.getDbType())) {
			postgreSchemViewer.viewSchema(vo);
		}
	}
}
