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);
}
}
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);
}
}
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);
}
}
Aggregations