Search in sources :

Example 36 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobExportAction method getProcesses.

private static List<ExportFileResource> getProcesses(Collection<? extends IRepositoryNode> nodes, String path) {
    List<ExportFileResource> value = new ArrayList<ExportFileResource>();
    for (IRepositoryNode node : nodes) {
        if (node.getType() == ENodeType.SYSTEM_FOLDER || node.getType() == ENodeType.SIMPLE_FOLDER) {
            value.addAll(getProcesses(node.getChildren(), node.getProperties(EProperties.LABEL).toString() + '/'));
        }
        if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
            IRepositoryViewObject repositoryObject = node.getObject();
            if (repositoryObject.getProperty().getItem() instanceof ProcessItem) {
                ProcessItem processItem = (ProcessItem) repositoryObject.getProperty().getItem();
                ExportFileResource resource = new ExportFileResource(processItem, path + processItem.getProperty().getLabel());
                resource.setNode(node);
                value.add(resource);
            }
        }
    }
    return value;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 37 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobExportAction method generatedCodes.

/**
     * DOC ggu Comment method "generatedCodes".
     * 
     * @param version
     * @param monitor
     * @param processes
     */
protected boolean generatedCodes(String version, IProgressMonitor monitor, List<ExportFileResource> processes) {
    String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
    List<JobResource> jobResources = new ArrayList<JobResource>();
    for (ExportFileResource process : processes) {
        ProcessItem processItem = (ProcessItem) process.getItem();
        JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext(), version);
        jobResources.add(new JobResource(projectName, jobInfo));
        Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
        for (JobInfo subjobInfo : jobInfos) {
            jobResources.add(new JobResource(projectName, subjobInfo));
        }
    }
    JobResourceManager reManager = JobResourceManager.getInstance();
    for (JobResource r : jobResources) {
        if (reManager.isProtected(r)) {
            try {
                ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false, monitor);
            } catch (ProcessorException e) {
                MessageBoxExceptionHandler.process(e);
                return false;
            }
        }
    }
    return true;
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JobInfo(org.talend.core.model.process.JobInfo) JobResource(org.talend.core.model.repository.job.JobResource) ArrayList(java.util.ArrayList) JobResourceManager(org.talend.core.model.repository.job.JobResourceManager)

Example 38 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method setTopFolder.

@Override
public void setTopFolder(List<ExportFileResource> resourcesToExport) {
    String topFolder = getRootFolderName(this.topFolderName);
    for (ExportFileResource fileResource : resourcesToExport) {
        String directory = fileResource.getDirectoryName();
        //$NON-NLS-1$
        fileResource.setDirectoryName(topFolder + "/" + directory);
    }
}
Also used : ExportFileResource(org.talend.repository.documentation.ExportFileResource)

Example 39 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method setTopFolder.

/**
     * Comment method "setTopFolder".
     * 
     * @param resourcesToExport
     * @param topFolder
     */
public void setTopFolder(List<ExportFileResource> resourcesToExport, String topFolder) {
    for (ExportFileResource fileResource : resourcesToExport) {
        String directory = fileResource.getDirectoryName();
        //$NON-NLS-1$
        fileResource.setDirectoryName(topFolder + "/" + directory);
    }
}
Also used : ExportFileResource(org.talend.repository.documentation.ExportFileResource)

Example 40 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class BuildJobHandler method addTDMDependencies.

/**
     * DOC nrousseau Comment method "addTDMDependencies".
     * 
     * @param items
     * @param itemsFolder
     */
private void addTDMDependencies(IFolder itemsFolder, List<Item> items) {
    ITransformService tdmService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITransformService.class)) {
        tdmService = (ITransformService) GlobalServiceRegister.getDefault().getService(ITransformService.class);
    }
    if (tdmService == null) {
        return;
    }
    try {
        // add __tdm dependencies
        ExportFileResource resouece = new ExportFileResource();
        BuildExportManager.getInstance().exportDependencies(resouece, processItem);
        if (!resouece.getAllResources().isEmpty()) {
            final Iterator<String> relativepath = resouece.getRelativePathList().iterator();
            while (relativepath.hasNext()) {
                String relativePath = relativepath.next();
                // TDQ-12852 do nothing if it is DQ resources.
                if (relativePath == null || relativePath.contains("metadata/survivorship")) {
                    //$NON-NLS-1$
                    continue;
                }
                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()) {
                        // the __tdm will be out of items folder, same level for items
                        IFolder targetFolder = ((IFolder) itemsFolder.getParent()).getFolder(relativePath);
                        if (!targetFolder.exists()) {
                            targetFolder.create(true, true, new NullProgressMonitor());
                        }
                        FilesUtils.copyFile(currentResource, new File(targetFolder.getLocation().toPortableString() + File.separator + currentResource.getName()));
                    }
                }
            }
        }
        itemsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
        // make sure to export again.
        for (Item item : items) {
            if (tdmService.isTransformItem(item)) {
                setNeedItemDependencies(true);
                String itemProjectFolder = getProject(item).getTechnicalLabel();
                if (isProjectNameLowerCase()) {
                    // should be same as ExportItemUtil.getProjectOutputPath
                    itemProjectFolder = itemProjectFolder.toLowerCase();
                }
                IPath targetSettingPath = new Path(itemProjectFolder).append(RepositoryConstants.SETTING_DIRECTORY);
                IFolder targetSettingsFolder = talendProcessJavaProject.createSubFolder(null, itemsFolder, targetSettingPath.toString());
                IProject sourceProject = getCorrespondingProjectRootFolder(item);
                if (sourceProject.exists()) {
                    IFile targetTdmPropsFile = targetSettingsFolder.getFile(FileConstants.TDM_PROPS);
                    IFile sourceTdmPropsFile = sourceProject.getFolder(RepositoryConstants.SETTING_DIRECTORY).getFile(FileConstants.TDM_PROPS);
                    // if have existed, no need copy again.
                    if (sourceTdmPropsFile.exists() && !targetTdmPropsFile.exists()) {
                        sourceTdmPropsFile.copy(targetTdmPropsFile.getFullPath(), true, null);
                    }
                }
                // only deal with one time.
                break;
            }
        }
    } catch (Exception e) {
        // don't block all the export if got exception here
        ExceptionHandler.process(e);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ITransformService(org.talend.core.service.ITransformService) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

ExportFileResource (org.talend.repository.documentation.ExportFileResource)48 URL (java.net.URL)24 ProcessItem (org.talend.core.model.properties.ProcessItem)23 File (java.io.File)20 ArrayList (java.util.ArrayList)19 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 ProcessorException (org.talend.designer.runprocess.ProcessorException)11 MalformedURLException (java.net.MalformedURLException)10 IOException (java.io.IOException)8 PersistenceException (org.talend.commons.exception.PersistenceException)8 IFile (org.eclipse.core.resources.IFile)6 Item (org.talend.core.model.properties.Item)6 EList (org.eclipse.emf.common.util.EList)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Set (java.util.Set)4 Path (org.eclipse.core.runtime.Path)4 IProcess (org.talend.core.model.process.IProcess)4 ArchiveFileExportOperationFullPath (org.talend.core.ui.export.ArchiveFileExportOperationFullPath)4 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)4