Search in sources :

Example 1 with ExportFileResource

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

the class ExportProcessorHelper method exportPigudf.

public void exportPigudf(IProcessor processor, Property property, int statisticsPort, int tracePort) throws ProcessorException {
    // build java project
    CorePlugin.getDefault().getRunProcessService().buildJavaProject();
    Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
    exportChoiceMap.put(ExportChoice.needPigudf, true);
    ProcessItem processItem = (ProcessItem) property.getItem();
    ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
    ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
    JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, processor.getContext().getName(), JobScriptsManager.ALL_ENVIRONMENTS, statisticsPort, tracePort, JobExportType.POJO);
    URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
    if (url == null) {
        return;
    }
    File file = new File(url.getFile());
    File libFolder = JavaProcessorUtilities.getJavaProjectLibFolder();
    if (libFolder == null) {
        return;
    }
    File target = new File(libFolder.getAbsolutePath() + property.getLabel() + "_" + property.getVersion() + "_" + file.getName());
    try {
        FilesUtils.copyFile(file, target);
    } catch (IOException e) {
        throw new ProcessorException(e.getMessage());
    }
}
Also used : JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) ProcessorException(org.talend.designer.runprocess.ProcessorException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) IOException(java.io.IOException) EnumMap(java.util.EnumMap) File(java.io.File) URL(java.net.URL)

Example 2 with ExportFileResource

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

the class GenerateDocAsHTMLWizardPage method finish.

/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
@Override
public boolean finish() {
    String topFolder = getRootFolderName();
    String destinationFilename = getDestinationValue();
    // Save dirty editors if possible but do not stop if not all are saved
    saveDirtyEditors();
    // about to invoke the operation so save our state
    saveWidgetValues();
    File file = new File(destinationFilename);
    if (file.exists()) {
        Boolean open = //$NON-NLS-1$
        MessageDialog.openConfirm(//$NON-NLS-1$
        getShell(), //$NON-NLS-1$
        Messages.getString("GenerateDocAsHTMLWizardPage.Warning"), //$NON-NLS-1$
        Messages.getString("GenerateDocAsHTMLWizardPage.OverWrite"));
        if (open) {
            file.delete();
        } else {
            return false;
        }
    }
    List<ExportFileResource> resourcesToExport = getExportResources();
    setTopFolder(resourcesToExport, topFolder);
    ArchiveFileExportOperationFullPath runnable = new ArchiveFileExportOperationFullPath(resourcesToExport, destinationFilename);
    // output everything
    //$NON-NLS-1$
    runnable.setRegEx("*");
    boolean ok = executeExportOperation(runnable);
    // add for bug TDI-21815
    saveLastDirectoryName(runnable);
    manager.deleteTempFiles();
    return ok;
}
Also used : ExportFileResource(org.talend.repository.documentation.ExportFileResource) File(java.io.File) ArchiveFileExportOperationFullPath(org.talend.core.ui.export.ArchiveFileExportOperationFullPath)

Example 3 with ExportFileResource

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

the class RepositoryService method exportPigudf.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.model.IRepositoryService#exportPigudf(org.talend.designer.runprocess.IProcessor,
     * org.talend.core.model.properties.Property, int, int)
     */
@Override
public String exportPigudf(IProcessor processor, Property property, boolean isExport) throws ProcessorException {
    // build java project
    CorePlugin.getDefault().getRunProcessService().buildJavaProject();
    Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
    exportChoiceMap.put(ExportChoice.needPigudf, true);
    ProcessItem processItem = (ProcessItem) property.getItem();
    ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
    ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
    IContext context = processor.getContext();
    //$NON-NLS-1$
    String contextName = "Default";
    if (context != null) {
        contextName = context.getName();
    }
    JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, contextName, JobScriptsManager.ALL_ENVIRONMENTS, -1, -1, JobExportType.POJO);
    URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
    if (url == null) {
        return null;
    }
    File file = new File(url.getFile());
    // String librariesPath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA) + "/";
    //$NON-NLS-1$
    String librariesPath = processor.getCodeProject().getLocation() + "/lib/";
    String targetFileName = JobJavaScriptsManager.USERPIGUDF_JAR;
    if (!isExport) {
        targetFileName = property.getLabel() + '_' + property.getVersion() + '_' + JobJavaScriptsManager.USERPIGUDF_JAR;
    }
    File target = new File(librariesPath + targetFileName);
    try {
        FilesUtils.copyFile(file, target);
    } catch (IOException e) {
        throw new ProcessorException(e.getMessage());
    }
    return targetFileName;
}
Also used : IContext(org.talend.core.model.process.IContext) JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) ProcessorException(org.talend.designer.runprocess.ProcessorException) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) IOException(java.io.IOException) URL(java.net.URL) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JSONObject(org.talend.utils.json.JSONObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) EnumMap(java.util.EnumMap) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 4 with ExportFileResource

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

the class GenerateDocAsHTMLWizardPage method addTreeNode.

private void addTreeNode(RepositoryNode node, String path, List<ExportFileResource> list) {
    if (node != null && 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);
            resource.setNode(node);
            list.add(resource);
        }
    }
    Object[] nodes = node.getChildren().toArray();
    if (nodes.length <= 0) {
        return;
    }
    for (Object node2 : nodes) {
        addTreeNode((RepositoryNode) node2, //$NON-NLS-1$
        path + "/" + ((RepositoryNode) node2).getProperties(EProperties.LABEL).toString(), list);
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 5 with ExportFileResource

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

the class GenerateDocAsHTMLWizardPage method setTopFolder.

private 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)

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