Search in sources :

Example 1 with ChangeProjectTechinicalNameMigrationTask

use of org.talend.repository.model.migration.ChangeProjectTechinicalNameMigrationTask in project tdi-studio-se by Talend.

the class TalendWizardProjectsImportPage method createProjects.

@SuppressWarnings("restriction")
@Override
public boolean createProjects() {
    // TDI-19269
    final boolean created = super.createProjects();
    //
    final Object[] selected = getProjectsList().getCheckedElements();
    XmiResourceManager xmiManager = new XmiResourceManager();
    try {
        for (Object element : selected) {
            final ProjectRecord record = (ProjectRecord) element;
            String projectName = record.getProjectName();
            final IWorkspace workspace = ResourcesPlugin.getWorkspace();
            final IProject project = workspace.getRoot().getProject(projectName);
            try {
                final Project loadProject = xmiManager.loadProject(project);
                loadProject.setLocal(true);
                loadProject.setId(0);
                loadProject.setUrl(null);
                loadProject.setCreationDate(null);
                //loadProject.setDescription(""); //$NON-NLS-1$
                loadProject.setType(null);
                xmiManager.saveResource(loadProject.eResource());
                // FIXME TDI-22786, migrate the project name.
                if (ProjectManager.enableSpecialTechnicalProjectName()) {
                    ChangeProjectTechinicalNameMigrationTask migrationTask = new ChangeProjectTechinicalNameMigrationTask();
                    migrationTask.migrateTalendProject(project, loadProject, xmiManager);
                }
            } catch (PersistenceException e) {
            //
            }
        }
    } finally {
        xmiManager.unloadResources();
    }
    return created;
//
}
Also used : Project(org.talend.core.model.properties.Project) IProject(org.eclipse.core.resources.IProject) ChangeProjectTechinicalNameMigrationTask(org.talend.repository.model.migration.ChangeProjectTechinicalNameMigrationTask) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IProject(org.eclipse.core.resources.IProject)

Aggregations

IProject (org.eclipse.core.resources.IProject)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Project (org.talend.core.model.properties.Project)1 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)1 ChangeProjectTechinicalNameMigrationTask (org.talend.repository.model.migration.ChangeProjectTechinicalNameMigrationTask)1