use of org.talend.repository.local.ExportItemUtil in project tdi-studio-se by Talend.
the class ExportItemWizardPage method performFinish.
public boolean performFinish() {
if (!checkExportFile()) {
return false;
}
ProjectManager pManager = ProjectManager.getInstance();
Project project = pManager.getCurrentProject().getEmfProject();
//$NON-NLS-1$
String projectPath = lastPath + "\\" + project.getTechnicalLabel();
if ((itemFromDirectoryRadio.getSelection() && new File(projectPath).exists()) || (itemFromArchiveRadio.getSelection() && new File(archivePathField.getText()).exists())) {
File oldFile = new File(projectPath).exists() ? new File(projectPath) : new File(archivePathField.getText());
if (MessageDialogWithToggle.openConfirm(null, Messages.getString("ExportItemWizardPage.waring"), Messages.getString("ExportItemWizardPage.fileAlreadyExist"))) {
//$NON-NLS-1$ //$NON-NLS-2$
deleteFile(oldFile);
} else {
return false;
}
}
Collection<Item> selectedItems = getSelectedItems();
if (exportDependencies.getSelection() && !implicitDependences.isEmpty()) {
for (IRepositoryViewObject object : implicitDependences) {
selectedItems.add(object.getProperty().getItem());
}
}
List<String> folders = new ArrayList<String>();
for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
if (obj instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) obj;
if (repositoryNode.getType() == ENodeType.SIMPLE_FOLDER && repositoryNode.getObject() instanceof Folder) {
Folder folder = (Folder) repositoryNode.getObject();
ERepositoryObjectType contentType = repositoryNode.getContentType();
IProjectRepositoryNode root = repositoryNode.getRoot();
if (root != null && root.getProject() != null) {
IPath path = new Path(root.getProject().getTechnicalLabel());
path = path.append(contentType.getFolder());
String folderPath = folder.getPath();
if (folderPath != null && !"".equals(folderPath)) {
path = path.append(folderPath);
}
path = path.append(folder.getLabel());
folders.add(path.toPortableString() + "/");
}
}
}
}
try {
ExportItemUtil exportItemUtil = new ExportItemUtil();
if (itemFromArchiveRadio.getSelection()) {
if (lastPath != null && !lastPath.endsWith(FileConstants.TAR_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.TAR_GZ_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
// set zip as default
lastPath = lastPath + FileConstants.ZIP_FILE_SUFFIX;
}
}
// MOD sgandon 31/03/2010 bug 12229: moved getAllVersion into ExportItemUtil.exportitems() method.
exportItemUtil.exportItems(new File(lastPath), selectedItems, folders, true, new NullProgressMonitor());
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
}
return true;
}
use of org.talend.repository.local.ExportItemUtil in project tdi-studio-se by Talend.
the class JobScriptsManager method addJobItem.
protected void addJobItem(ExportFileResource[] resources, ProcessItem processItem, boolean needChoice, ExportFileResource curResource, String... selectedJobVersion) {
List<URL> list = new ArrayList<URL>();
if (needChoice) {
try {
Set<File> files = new ExportItemUtil().createLocalResources(new File(getTmpFolder()), processItem);
for (File file : files) {
list.add(file.toURI().toURL());
}
curResource.addResources(JOB_SOURCE_FOLDER_NAME, list);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.local.ExportItemUtil in project tdi-studio-se by Talend.
the class BuildJobHandler method generateItemFiles.
@Override
public void generateItemFiles(boolean withDependencies, IProgressMonitor monitor) throws Exception {
IFolder baseFolder = talendProcessJavaProject.getItemsFolder();
baseFolder = baseFolder.getFolder(JavaResourcesHelper.getJobFolderName(processItem.getProperty().getLabel(), processItem.getProperty().getVersion()));
if (baseFolder.exists()) {
talendProcessJavaProject.cleanFolder(monitor, baseFolder);
} else {
baseFolder.create(true, true, null);
}
//$NON-NLS-1$
IFolder itemsFolder = baseFolder.getFolder("items");
itemsFolder.create(true, true, monitor);
List<Item> items = new ArrayList<Item>();
items.add(processItem);
ExportItemUtil exportItemUtil = new ExportItemUtil();
if (withDependencies) {
Collection<IRepositoryViewObject> allProcessDependencies = ProcessUtils.getAllProcessDependencies(items);
for (IRepositoryViewObject repositoryObject : allProcessDependencies) {
items.add(repositoryObject.getProperty().getItem());
}
}
if (isOptionChoosed(ExportChoice.executeTests)) {
IPath path = talendProcessJavaProject.getTargetFolder().getFolder("surefire-reports").getLocation();
File reports = new File(path.toOSString());
if (reports.exists()) {
FilesUtils.deleteFolder(reports, false);
}
}
if (isOptionChoosed(ExportChoice.needJobItem)) {
File destination = new File(itemsFolder.getLocation().toFile().getAbsolutePath());
exportItemUtil.setProjectNameAsLowerCase(isProjectNameLowerCase());
exportItemUtil.exportItems(destination, new ArrayList<Item>(items), false, new NullProgressMonitor());
}
addDQDependencies(itemsFolder, items);
addTDMDependencies(itemsFolder, items);
}
use of org.talend.repository.local.ExportItemUtil in project tmdm-studio-se by Talend.
the class MDMExportRepositoryItemsWizard method doexport.
// do export is need to override ,use the system of TOS to export EMF files
@Override
public void doexport(Object[] selectedNodes, IProgressMonitor monitor) {
List<IRepositoryViewObject> objs = new LinkedList<IRepositoryViewObject>();
for (Object obj : selectedNodes) {
if (obj instanceof IRepositoryViewObject) {
objs.add((IRepositoryViewObject) obj);
}
}
if (exportFolder != null) {
Collection<Item> selectedItems = getItemsToExport(objs);
try {
ExportItemUtil exportItemUtil = new ExportItemUtil();
// MOD sgandon 31/03/2010 bug 12229: moved getAllVersion into ExportItemUtil.exportitems() method.
exportItemUtil.exportItems(new File(exportFolder), selectedItems, true, monitor);
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
}
}
}
Aggregations