use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionDB2Case2.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionDB2Case2() {
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
// $NON-NLS-1$
String db2Lang = "DB2";
// $NON-NLS-1$
String db2Body = "DB2 body";
// $NON-NLS-1$
String db2NTLang = "DB2/NT";
// $NON-NLS-1$
String db2NTBody = "DB2/NT body";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
String language = db2Lang;
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression2.setLanguage(db2Lang);
tdExpression2.setBody(db2Body);
sqlGenericExpression.add(tdExpression2);
TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression3.setLanguage(db2NTLang);
tdExpression3.setBody(db2NTBody);
sqlGenericExpression.add(tdExpression3);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression2, sqlExpression);
}
use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionRedshiftCase1.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionRedshiftCase1() {
// TDQ-11558 msjian: test for get sql expresstion for redshift database
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
String redshiftLang = SupportDBUrlType.REDSHIFT.getLanguage();
// $NON-NLS-1$
String redshiftBody = "Amazon redshift body";
String postgresqlLang = SupportDBUrlType.POSTGRESQLEFAULTURL.getLanguage();
// $NON-NLS-1$
String postgresqlBody = "PostgreSQL body";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression3.setLanguage(postgresqlLang);
tdExpression3.setBody(postgresqlBody);
sqlGenericExpression.add(tdExpression3);
TdExpression tdExpression4 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression4.setLanguage(redshiftLang);
tdExpression4.setBody(redshiftBody);
sqlGenericExpression.add(tdExpression4);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, redshiftLang, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression4, sqlExpression);
}
use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionRedshiftCase3.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionRedshiftCase3() {
// TDQ-11558 msjian: test for get sql expresstion for redshift database when there is no redshift and ParAccel
// and PostgreSQL defined
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
String redshiftLang = SupportDBUrlType.REDSHIFT.getLanguage();
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, redshiftLang, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression1, sqlExpression);
}
use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.
the class FileSystemImportWriter method migration.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.imex.model.IImexWriter#migration(org.eclipse.core.runtime.IProgressMonitor)
*/
public void migration(IProgressMonitor monitor) {
List<IMigrationTask> modelTasks = new ArrayList<IMigrationTask>();
if (versionFile != null && versionFile.exists()) {
ProductVersion version = WorkspaceVersionHelper.getVesion(new Path(versionFile.getAbsolutePath()));
MigrationTaskManager manager = new MigrationTaskManager(version, MigrationTaskType.FILE);
List<IMigrationTask> taskList = manager.getValidTasks();
if (!taskList.isEmpty()) {
for (IMigrationTask task : taskList) {
if (task.isModelTask()) {
((AbstractWorksapceUpdateTask) task).setWorkspacePath(basePath);
modelTasks.add(task);
} else {
// MOD msjian TDQ-7365 2013-5-27: only added the not inclued tasks
if (!commTasks.contains(task)) {
commTasks.add(task);
}
// TDQ-7365~
}
}
}
}
if (!modelTasks.isEmpty()) {
MigrationTaskManager.doMigrationTask(modelTasks, monitor);
}
}
use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.
the class ConnectionUtils method getDatabaseVersion.
/**
* get the database product version.
*
* @param connection
* @return
*/
public static ProductVersion getDatabaseVersion(IMetadataConnection connection) {
ProductVersion version = null;
Connection conn = (Connection) connection.getCurrentConnection();
Properties props = new Properties();
String userName = JavaSqlFactory.getUsername(conn);
String password = JavaSqlFactory.getPassword(conn);
props.put(TaggedValueHelper.USER, userName);
props.put(TaggedValueHelper.PASSWORD, password);
String dbType = connection.getDbType();
if (dbType != null) {
props.put(TaggedValueHelper.DBTYPE, dbType);
}
java.sql.Connection createConnection = null;
try {
List list = ExtractMetaDataUtils.getInstance().connect(dbType, connection.getUrl(), userName, password, connection.getDriverClass(), connection.getDriverJarPath(), connection.getDbVersionString(), connection.getAdditionalParams());
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof java.sql.Connection) {
createConnection = (java.sql.Connection) list.get(i);
break;
}
}
if (createConnection != null) {
if (createConnection.getMetaData() != null) {
String temp = createConnection.getMetaData().getDatabaseProductVersion();
if (temp != null) {
version = ProductVersion.fromString(temp);
}
if (version == null) {
version = ProductVersion.fromString(createConnection.getMetaData().getDatabaseMajorVersion() + // $NON-NLS-1$
"." + createConnection.getMetaData().getDatabaseMinorVersion() + // $NON-NLS-1$
".0");
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
} finally {
if (createConnection != null) {
try {
createConnection.close();
} catch (SQLException e) {
ExceptionHandler.process(e);
}
}
}
if (version == null) {
// $NON-NLS-1$
version = ProductVersion.fromString("0.0.0");
}
return version;
}
Aggregations