Search in sources :

Example 1 with ExportItemUtil

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Folder(org.talend.core.model.repository.Folder) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProjectManager(org.talend.repository.ProjectManager) Project(org.talend.core.model.properties.Project) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ExportItemUtil(org.talend.repository.local.ExportItemUtil) File(java.io.File) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 2 with ExportItemUtil

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);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ExportItemUtil(org.talend.repository.local.ExportItemUtil) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException)

Example 3 with ExportItemUtil

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);
}
Also used : Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExportItemUtil(org.talend.repository.local.ExportItemUtil) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with ExportItemUtil

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);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExportItemUtil(org.talend.repository.local.ExportItemUtil) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

File (java.io.File)4 ExportItemUtil (org.talend.repository.local.ExportItemUtil)4 ArrayList (java.util.ArrayList)3 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 IFile (org.eclipse.core.resources.IFile)2 IPath (org.eclipse.core.runtime.IPath)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 IFolder (org.eclipse.core.resources.IFolder)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 Project (org.talend.core.model.properties.Project)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 Folder (org.talend.core.model.repository.Folder)1