Search in sources :

Example 6 with Project

use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.

the class BuildJobHandler method addDQDependencies.

private void addDQDependencies(IFolder parentFolder, List<Item> items) throws Exception {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
        ITDQItemService tdqItemService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
        for (Item item : items) {
            if (tdqItemService != null && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] { item }))) {
                setNeedItemDependencies(true);
                // add .Talend.definition file
                //$NON-NLS-1$
                String defIdxFolderName = "TDQ_Libraries";
                //$NON-NLS-1$
                String defIdxFileName = ".Talend.definition";
                Project pro = getProject(processItem);
                IFolder itemsProjectFolder = parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
                File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
                IProject project = ReponsitoryContextBridge.getRootProject();
                String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
                IFile defIdxFile = project.getFile(defIdxRelativePath);
                if (defIdxFile.exists()) {
                    File defIdxFileSource = new File(project.getLocation().makeAbsolute().append(defIdxFolderName).append(defIdxFileName).toFile().toURI());
                    File defIdxFileTarget = new File(itemsProjectFolder.getFile(defIdxRelativePath).getLocation().toFile().getAbsolutePath());
                    FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
                }
                // add report header image & template files
                //$NON-NLS-1$
                String reportingBundlePath = PluginChecker.getBundlePath("org.talend.dataquality.reporting");
                //$NON-NLS-1$
                File imageFolder = new File(reportingBundlePath + PATH_SEPARATOR + "images");
                if (imageFolder.exists()) {
                    FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
                }
                //$NON-NLS-1$ 
                File templateFolder = new File(reportingBundlePath + PATH_SEPARATOR + "reports");
                if (templateFolder.exists() && templateFolder.isDirectory()) {
                    FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
                }
            }
        }
        // maven command 'include-survivorship-rules' to export.
        if (!isOptionChoosed(ExportChoice.needJobItem)) {
            ExportFileResource resouece = new ExportFileResource();
            BuildExportManager.getInstance().exportDependencies(resouece, processItem);
            if (!resouece.getAllResources().isEmpty()) {
                final Iterator<String> relativepath = resouece.getRelativePathList().iterator();
                //$NON-NLS-1$
                String pathStr = "metadata/survivorship";
                IFolder targetFolder = talendProcessJavaProject.getResourcesFolder();
                if (targetFolder.exists()) {
                    IFolder survFolder = targetFolder.getFolder(new Path(pathStr));
                    // only copy self job rules, clear the 'survivorship' folder before copy.
                    if (survFolder.exists()) {
                        survFolder.delete(true, null);
                    }
                    while (relativepath.hasNext()) {
                        String relativePath = relativepath.next();
                        Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
                        for (URL sourceUrl : sources) {
                            File currentResource = new File(org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
                            if (currentResource.exists()) {
                                FilesUtils.copyDirectory(currentResource, new File(targetFolder.getLocation().toPortableString() + File.separator + pathStr));
                            }
                        }
                    }
                }
            }
            parentFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IProject(org.eclipse.core.resources.IProject) URL(java.net.URL) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) Project(org.talend.core.model.properties.Project) IProject(org.eclipse.core.resources.IProject) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IFile(org.eclipse.core.resources.IFile) File(java.io.File) ITDQItemService(org.talend.core.ITDQItemService) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with Project

use of org.talend.core.model.properties.Project 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)

Example 8 with Project

use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getChildrenJobAndContextName.

protected void getChildrenJobAndContextName(ExportFileResource[] allResources, String rootName, List<JobInfo> list, ProcessItem process, String projectName, List<ProcessItem> processedJob, List<URL> allJobScripts, ExportFileResource resource, Map<ExportChoice, Object> exportChoice, String... selectedJobVersion) {
    if (processedJob.contains(process)) {
        // prevent circle
        return;
    }
    processedJob.add(process);
    ProjectManager projectManager = ProjectManager.getInstance();
    Project project = projectManager.getProject(process);
    String childProjectName = projectName;
    if (project != null) {
        // hywang modify for 7932
        childProjectName = project.getTechnicalLabel().toLowerCase();
    }
    allJobScripts.addAll(getJobScripts(childProjectName, process.getProperty().getLabel(), process.getProperty().getVersion(), isOptionChoosed(ExportChoice.needJobScript)));
    addContextScripts(process, process.getProperty().getLabel(), process.getProperty().getVersion(), resource, isOptionChoosed(ExportChoice.needContext));
    addJobItem(allResources, process, isOptionChoosed(ExportChoice.needJobItem), resource);
    addDependencies(allResources, process, isOptionChoosed(ExportChoice.needDependencies) && isOptionChoosed(ExportChoice.needJobItem), resource);
    addSourceCode(allResources, process, isOptionChoosed(ExportChoice.needSourceCode), resource);
    addDependenciesSourceCode(allResources, resource, isOptionChoosed(ExportChoice.needSourceCode));
    Set<JobInfo> subjobInfos = ProcessorUtilities.getChildrenJobInfo(process);
    for (JobInfo subjobInfo : subjobInfos) {
        if (list.contains(subjobInfo)) {
            continue;
        }
        list.add(subjobInfo);
        getChildrenJobAndContextName(allResources, rootName, list, subjobInfo.getProcessItem(), projectName, processedJob, allJobScripts, resource, exportChoice);
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.properties.Project) IJavaProject(org.eclipse.jdt.core.IJavaProject) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) JobInfo(org.talend.core.model.process.JobInfo) ProjectManager(org.talend.repository.ProjectManager)

Example 9 with Project

use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.

the class MigrationTaskForIssue18419 method execute.

@Override
public ExecutionResult execute(final Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    //$NON-NLS-1$
    IComponentFilter filter = new NameComponentFilter("tFileUnarchive");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            @Override
            public void transform(NodeType node) {
                Project pro = ProxyRepositoryFactory.getInstance().getProject(item);
                String proName = pro.getLabel();
                //$NON-NLS-1$
                ElementParameterType zipFile = ComponentUtilities.getNodeProperty(node, "ZIPFILE");
                String zipFileName = zipFile.getValue();
                final String oldValues = getOldValues();
                if (proName != null && !proName.equals(getDemoProjectName()) && zipFileName != null && zipFileName.equals(oldValues)) {
                    zipFile.setValue(oldValues.replaceFirst(getDemoProjectName(), proName));
                }
            }
        }));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.properties.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 10 with Project

use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.

the class ChangeProjectTechinicalNameMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.migration.IWorkspaceMigrationTask#execute()
     */
@Override
public boolean execute() {
    if (!ProjectManager.enableSpecialTechnicalProjectName()) {
        // no need to do migration.
        return false;
    }
    try {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        try {
            root.refreshLocal(IResource.DEPTH_INFINITE, null);
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        }
        IProject[] projects = root.getProjects();
        for (IProject localProject : projects) {
            try {
                if (localProject.hasNature(TalendNature.ID)) {
                    // only for talend project
                    Project talendProject = xmiResManager.loadProject(localProject);
                    if (needCheckProject(localProject, talendProject)) {
                        checkTalendProject(localProject, talendProject);
                    }
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return false;
            }
        }
    } finally {
        xmiResManager.unloadResources();
    }
    // always true, no need do again.
    return true;
}
Also used : Project(org.talend.core.model.properties.Project) IProject(org.eclipse.core.resources.IProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

Project (org.talend.core.model.properties.Project)26 IProject (org.eclipse.core.resources.IProject)11 IPath (org.eclipse.core.runtime.IPath)10 Path (org.eclipse.core.runtime.Path)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 File (java.io.File)5 Item (org.talend.core.model.properties.Item)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 URI (org.eclipse.emf.common.util.URI)4 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 Property (org.talend.core.model.properties.Property)4 RoutineItem (org.talend.core.model.properties.RoutineItem)4 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 EObject (org.eclipse.emf.ecore.EObject)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 URL (java.net.URL)2