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