Search in sources :

Example 11 with ProductVersion

use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.

the class MigrationTaskManagerWithoutUI method getValidTasks.

/**
 * DOC bZhou Comment method "getValidTasks".
 *
 * @param workspaceVersion
 * @param currentVersion
 * @param tasks
 * @return
 */
public static List<IMigrationTask> getValidTasks(ProductVersion workspaceVersion, ProductVersion currentVersion, List<IMigrationTask> tasks) {
    List<IMigrationTask> validTasks = new ArrayList<IMigrationTask>();
    for (IMigrationTask task : tasks) {
        if (task.getTaskCategory() == MigrationTaskCategory.WORKSPACE) {
            IWorkspaceMigrationTask wTask = (IWorkspaceMigrationTask) task;
            ProductVersion taskVersion = ProductVersion.fromString(wTask.getVersion());
            if (taskVersion.compareTo(workspaceVersion) > 0 && taskVersion.compareTo(currentVersion) <= 0) {
                validTasks.add(task);
            }
        }
        if (task.getTaskCategory() == MigrationTaskCategory.PROJECT) {
            validTasks.add(task);
        }
    }
    return validTasks;
}
Also used : ArrayList(java.util.ArrayList) IMigrationTask(org.talend.dataprofiler.migration.IMigrationTask) IWorkspaceMigrationTask(org.talend.dataprofiler.migration.IWorkspaceMigrationTask) ProductVersion(org.talend.utils.ProductVersion)

Example 12 with ProductVersion

use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.

the class DbmsLanguageFactory method createDbmsLanguage.

/**
 * Method "createDbmsLanguage".
 *
 * @param dbmsSubtype
 * @return the appropriate DbmsLanguage
 */
public static DbmsLanguage createDbmsLanguage(String dbmsSubtype, String databaseVersion) {
    // TODO find an appropriate place to set the database version (e.g for hive embedded)
    String dbVersionStr = databaseVersion;
    if (dbVersionStr == null) {
        // $NON-NLS-1$
        dbVersionStr = "0.0.0";
    }
    ProductVersion dbVersion = ProductVersion.fromString(dbVersionStr, true);
    DbmsLanguage dbmsLanguage = null;
    if (isMySQL(dbmsSubtype)) {
        dbmsLanguage = new MySQLDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isOracle(dbmsSubtype)) {
        dbmsLanguage = new OracleDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isDB2(dbmsSubtype)) {
        dbmsLanguage = new DB2DbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isAS400(dbmsSubtype)) {
        dbmsLanguage = new AS400DbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isMSSQL(dbmsSubtype)) {
        dbmsLanguage = new MSSqlDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isPostgresql(dbmsSubtype)) {
        dbmsLanguage = new PostgresqlDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isRedshift(dbmsSubtype)) {
        dbmsLanguage = new RedshiftDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isExasol(dbmsSubtype)) {
        dbmsLanguage = new ExasolDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isSybase(dbmsSubtype)) {
        dbmsLanguage = new SybaseASEDbmsLanguage(dbVersion);
    } else if (isSQLite(dbmsSubtype)) {
        dbmsLanguage = new SQLiteDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isTeradata(dbmsSubtype)) {
        dbmsLanguage = new TeradataDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isIngres(dbmsSubtype)) {
        dbmsLanguage = new IngresDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isDelimitedFile(dbmsSubtype)) {
        dbmsLanguage = new DelimitedFileLanguage(dbmsSubtype, dbVersion);
    } else if (isInfomix(dbmsSubtype)) {
        // MOD zshen fixed bug 11005: SQL syntax error for all analysis on Informix databases in Talend Open
        // Profiler
        dbmsLanguage = new InfomixDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isHive(dbmsSubtype) || isImpala(dbmsSubtype)) {
        dbmsLanguage = new HiveDbmsLanguage(DbmsLanguage.HIVE, dbVersion);
    } else if (isVertica(dbmsSubtype)) {
        dbmsLanguage = new VerticaDbmsLanguage(dbmsSubtype, dbVersion);
    } else if (isNetezza(dbmsSubtype)) {
        dbmsLanguage = new NetezzaDbmsLanguage(dbmsSubtype, dbVersion);
    } else {
        dbmsLanguage = new DbmsLanguage(dbmsSubtype, dbVersion);
    }
    if (PluginConstant.EMPTY_STRING.equals(dbmsLanguage.getDbQuoteString())) {
        dbmsLanguage.setDbQuoteString(dbmsLanguage.getHardCodedQuoteIdentifier());
    }
    return dbmsLanguage;
}
Also used : ProductVersion(org.talend.utils.ProductVersion)

Example 13 with ProductVersion

use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testGetSqlExpressionDB2Case5.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
 */
@Test
public void testGetSqlExpressionDB2Case5() {
    // $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();
    // $NON-NLS-1$
    String language = "unknown";
    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(tdExpression1, sqlExpression);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 14 with ProductVersion

use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testGetSqlExpressionDB2Case3.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
 */
@Test
public void testGetSqlExpressionDB2Case3() {
    // $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";
    IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    String language = db2NTLang;
    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);
    ProductVersion dbVersion = new ProductVersion(1, 0);
    TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
    Assert.assertEquals(tdExpression2, sqlExpression);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 15 with ProductVersion

use of org.talend.utils.ProductVersion in project tdq-studio-se by Talend.

the class DQStructureManager method isNeedMigration.

/**
 * DOC bZhou Comment method "isNeedMigration".
 *
 * @return
 */
public boolean isNeedMigration() {
    if (isSecludedVersion()) {
        return true;
    }
    ProductVersion wVersion = WorkspaceVersionHelper.getVesion();
    ProductVersion cVersion = CorePlugin.getDefault().getProductVersion();
    return wVersion.compareTo(cVersion) < 0;
}
Also used : ProductVersion(org.talend.utils.ProductVersion)

Aggregations

ProductVersion (org.talend.utils.ProductVersion)16 BasicEList (org.eclipse.emf.common.util.BasicEList)9 Test (org.junit.Test)9 TdExpression (org.talend.cwm.relational.TdExpression)9 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)9 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)9 ArrayList (java.util.ArrayList)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Properties (java.util.Properties)2 IMigrationTask (org.talend.dataprofiler.migration.IMigrationTask)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1