Search in sources :

Example 1 with IMigrationTask

use of org.talend.dataprofiler.migration.IMigrationTask 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);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) MigrationTaskManager(org.talend.dataprofiler.migration.manager.MigrationTaskManager) AbstractWorksapceUpdateTask(org.talend.dataprofiler.core.migration.AbstractWorksapceUpdateTask) ArrayList(java.util.ArrayList) IMigrationTask(org.talend.dataprofiler.migration.IMigrationTask) ProductVersion(org.talend.utils.ProductVersion)

Example 2 with IMigrationTask

use of org.talend.dataprofiler.migration.IMigrationTask in project tdq-studio-se by Talend.

the class MigrationTaskManager method doMigrationTask.

/**
 * DOC bZhou Comment method "doMigrationTask".
 *
 * @param tasks
 * @param monitor
 */
public static void doMigrationTask(List<IMigrationTask> tasks, IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    // $NON-NLS-1$
    monitor.beginTask("Migration...", tasks.size());
    for (IMigrationTask task : tasks) {
        if (monitor.isCanceled()) {
            break;
        }
        monitor.subTask(task.getName());
        if (task.valid()) {
            if (!task.execute()) {
                // $NON-NLS-1$
                log.error("Migration Task failed: " + task.getName());
            } else {
                if (log.isInfoEnabled()) {
                    // $NON-NLS-1$
                    log.info("Migration Task success: " + task.getId());
                }
            }
        }
        monitor.worked(1);
    }
    monitor.done();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IMigrationTask(org.talend.dataprofiler.migration.IMigrationTask)

Example 3 with IMigrationTask

use of org.talend.dataprofiler.migration.IMigrationTask in project tdq-studio-se by Talend.

the class MigrationTaskManagerWithoutUI method getWorksapceTasks.

/**
 * DOC bZhou Comment method "getWorksapceTasks".
 *
 * @param wVersion
 *
 * @return
 */
public List<IMigrationTask> getWorksapceTasks() {
    List<IMigrationTask> validTasks = getValidTasks(workspaceVersion, currentVersion, allMigrationTask);
    Iterator<IMigrationTask> it = validTasks.iterator();
    while (it.hasNext()) {
        IMigrationTask task = it.next();
        if (task.getMigrationTaskType() == MigrationTaskType.DATABASE) {
            it.remove();
        }
    }
    List<IMigrationTask> resortList = new ArrayList<IMigrationTask>();
    for (IMigrationTask task : validTasks) {
        if (task.isModelTask()) {
            resortList.add(task);
        }
    }
    for (IMigrationTask task : validTasks) {
        if (!task.isModelTask()) {
            resortList.add(task);
        }
    }
    return resortList;
}
Also used : ArrayList(java.util.ArrayList) IMigrationTask(org.talend.dataprofiler.migration.IMigrationTask)

Example 4 with IMigrationTask

use of org.talend.dataprofiler.migration.IMigrationTask 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)

Aggregations

IMigrationTask (org.talend.dataprofiler.migration.IMigrationTask)4 ArrayList (java.util.ArrayList)3 ProductVersion (org.talend.utils.ProductVersion)2 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 AbstractWorksapceUpdateTask (org.talend.dataprofiler.core.migration.AbstractWorksapceUpdateTask)1 IWorkspaceMigrationTask (org.talend.dataprofiler.migration.IWorkspaceMigrationTask)1 MigrationTaskManager (org.talend.dataprofiler.migration.manager.MigrationTaskManager)1