Search in sources :

Example 1 with JobExportAction

use of org.talend.repository.ui.wizards.exportjob.action.JobExportAction in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method finish.

// protected String getDestinationValueSU() {
//        return this.suDestinationFilePath != null ? this.suDestinationFilePath : ""; //$NON-NLS-1$
//
// }
/**
     * 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() {
    // TODO
    if (treeViewer != null) {
        treeViewer.removeCheckStateListener(checkStateListener);
    }
    saveWidgetValues();
    if (manager == null) {
        manager = createJobScriptsManager();
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    if (ensureLog4jSettingIsValid()) {
        MessageDialog dialog = new MessageDialog(getShell(), "Question", null, Messages.getString("Log4jSettingPage.IlleagalBuild"), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    JobExportType jobExportType = getCurrentExportType1();
    if (JobExportType.POJO.equals(jobExportType)) {
        IRunnableWithProgress worker = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                buildJobWithMaven(JobExportType.POJO, monitor);
            }
        };
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    } else {
        List<ContextParameterType> contextEditableResultValuesList = null;
        if (manager != null) {
            contextEditableResultValuesList = manager.getContextEditableResultValuesList();
        }
        if (nodes.length == 1) {
            RepositoryNode node = nodes[0];
            if (node.getType() == ENodeType.SYSTEM_FOLDER) {
                manager.setTopFolderName(ProjectManager.getInstance().getCurrentProject().getLabel());
            } else {
                manager.setTopFolderName(getDefaultFileNameWithType());
            }
        } else {
            manager.setTopFolderName(getDefaultFileNameWithType());
        }
        // for feature:11976, recover back the old default manager value with ContextParameters
        if (contextEditableResultValuesList == null) {
            manager.setContextEditableResultValuesList(new ArrayList<ContextParameterType>());
        } else {
            manager.setContextEditableResultValuesList(contextEditableResultValuesList);
        }
        manager.setMultiNodes(isMultiNodes());
        // achen modify to fix bug 0006222
        IRunnableWithProgress worker = new JobExportAction(Arrays.asList(getCheckNodes()), getSelectedJobVersion(), manager, originalRootFolderName, getProcessType());
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    }
    // see bug 7181
    if (zipOption != null && zipOption.equals("true")) {
        // unzip
        try {
            String zipFile;
            if (manager != null) {
                zipFile = manager.getDestinationPath();
            } else {
                zipFile = getDestinationValue();
                int separatorIndex = zipFile.lastIndexOf(File.separator);
                if (separatorIndex == -1) {
                    //$NON-NLS-1$
                    String userDir = System.getProperty("user.dir");
                    zipFile = userDir + File.separator + zipFile;
                }
            }
            // Added by Marvin Wang on Feb.1, 2012 for bug TDI-18824
            File file = new File(zipFile);
            if (file.exists()) {
                ZipToFile.unZipFile(zipFile, file.getParentFile().getAbsolutePath());
            }
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e, getShell());
            return false;
        }
    }
    if (treeViewer != null) {
        treeViewer.dispose();
    }
    // end
    return true;
}
Also used : JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobExportType(org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Example 2 with JobExportAction

use of org.talend.repository.ui.wizards.exportjob.action.JobExportAction in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method exportRouteUsedJobBundle.

protected void exportRouteUsedJobBundle(IRepositoryNode node, File filePath, String jobVersion, String bundleName, String bundleSymbolicName, String bundleVersion, String routeName, String routeVersion, String context) throws InvocationTargetException, InterruptedException {
    RouteDedicatedJobManager talendJobManager = new RouteDedicatedJobManager(getExportChoice(), context);
    talendJobManager.setJobVersion(jobVersion);
    talendJobManager.setBundleName(bundleName);
    talendJobManager.setBundleSymbolicName(bundleSymbolicName);
    talendJobManager.setBundleVersion(bundleVersion);
    talendJobManager.setDestinationPath(filePath.getAbsolutePath());
    talendJobManager.setRouteName(routeName);
    talendJobManager.setRouteVersion(routeVersion);
    talendJobManager.setGroupId(getGroupId());
    talendJobManager.setArtifactId(getArtifactId());
    talendJobManager.setArtifactVersion(getArtifactVersion());
    JobExportAction action = new JobExportAction(Collections.singletonList(node), jobVersion, bundleVersion, talendJobManager, getTempDir(), "Job");
    action.run(monitor);
}
Also used : RouteDedicatedJobManager(org.talend.camel.designer.ui.wizards.export.RouteDedicatedJobManager) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction)

Example 3 with JobExportAction

use of org.talend.repository.ui.wizards.exportjob.action.JobExportAction in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWithMavenAction method exportMavenResources.

private void exportMavenResources(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    scriptsManager.setMultiNodes(false);
    scriptsManager.setDestinationPath(destinationPath);
    RepositoryNode node = new RepositoryNode(routeObject, null, ENodeType.REPOSITORY_ELEMENT);
    JobExportAction action = new JobExportAction(Collections.singletonList(node), version, bundleVersion, scriptsManager, getTempDir(), // $NON-NLS-1$
    "Route");
    action.run(monitor);
}
Also used : JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 4 with JobExportAction

use of org.talend.repository.ui.wizards.exportjob.action.JobExportAction in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method exportRouteUsedJobBundle.

protected void exportRouteUsedJobBundle(IRepositoryViewObject object, File filePath, String jobVersion, String bundleName, String bundleSymbolicName, String bundleVersion, String routeName, String routeVersion, String context) throws InvocationTargetException, InterruptedException {
    RouteDedicatedJobManager talendJobManager = new RouteDedicatedJobManager(getExportChoice(), context);
    talendJobManager.setJobVersion(jobVersion);
    talendJobManager.setBundleName(bundleName);
    talendJobManager.setBundleSymbolicName(bundleSymbolicName);
    talendJobManager.setBundleVersion(bundleVersion);
    talendJobManager.setDestinationPath(filePath.getAbsolutePath());
    talendJobManager.setRouteName(routeName);
    talendJobManager.setRouteVersion(routeVersion);
    talendJobManager.setGroupId(getGroupId());
    talendJobManager.setArtifactId(getArtifactId());
    talendJobManager.setArtifactVersion(getArtifactVersion());
    RepositoryNode node = new RepositoryNode(object, null, ENodeType.REPOSITORY_ELEMENT);
    if (!jobVersion.equals(node.getObject().getProperty().getVersion())) {
        node.getObject().getProperty().setVersion(jobVersion);
    }
    JobExportAction action = new RouteBundleExportAction(Collections.singletonList(node), jobVersion, bundleVersion, talendJobManager, getTempDir(), "Job");
    action.run(monitor);
}
Also used : RouteDedicatedJobManager(org.talend.camel.designer.ui.wizards.export.RouteDedicatedJobManager) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RouteBundleExportAction(org.talend.camel.designer.build.RouteBundleExportAction)

Example 5 with JobExportAction

use of org.talend.repository.ui.wizards.exportjob.action.JobExportAction in project tesb-studio-se by Talend.

the class ExportServiceWithMavenAction method addJobFilesToExport.

private void addJobFilesToExport(IProgressMonitor monitor) throws Exception {
    String directoryName = serviceManager.getRootFolderName(tempFolder);
    exportChoiceMap.put(ExportChoice.needJobItem, false);
    for (IRepositoryViewObject node : nodes) {
        JobScriptsManager osgiManager = new OSGIJavaScriptForESBWithMavenManager(exportChoiceMap, IContext.DEFAULT, JobScriptsManager.LAUNCHER_ALL, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES) {

            @Override
            protected Map<String, String> getMainMavenProperties(Item item) {
                Map<String, String> mavenPropertiesMap = super.getMainMavenProperties(item);
                mavenPropertiesMap.put(EMavenBuildScriptProperties.ItemGroupName.getVarScript(), getGroupId());
                return mavenPropertiesMap;
            }

            @Override
            protected void setMavenBuildScriptProperties(Document pomDocument, Map<String, String> mavenPropertiesMap) {
                super.setMavenBuildScriptProperties(pomDocument, mavenPropertiesMap);
                String itemName = mavenPropertiesMap.get(EMavenBuildScriptProperties.ItemName.getVarScript());
                if (itemName != null && pomDocument != null) {
                    Element rootElement = pomDocument.getRootElement();
                    // Because re-use the osgi bundle for service, but for artifactId, there is no "-bundle"
                    // suffix. TDI-23491
                    // $NON-NLS-1$
                    Element artifactIdEle = rootElement.element("artifactId");
                    if (artifactIdEle != null) {
                        artifactIdEle.setText(itemName);
                    }
                }
            }
        };
        String artefactName = serviceManager.getNodeLabel(node);
        String version = node.getVersion();
        // String fileName = artefactName + "-" + version;
        File destFile = new File(tempFolder + PATH_SEPERATOR + artefactName + osgiManager.getOutputSuffix());
        String destinationPath = destFile.getAbsolutePath();
        osgiManager.setDestinationPath(destinationPath);
        JobExportAction job = new JobExportAction(Collections.singletonList(new RepositoryNode(node, null, ENodeType.REPOSITORY_ELEMENT)), version, osgiManager, directoryName);
        job.run(monitor);
        ZipToFile.unZipFile(destinationPath, tempFolder + PATH_SEPERATOR + ServiceExportWithMavenManager.OPERATIONS_PATH + artefactName);
        FilesUtils.removeFile(destFile);
    }
}
Also used : ServiceItem(org.talend.repository.services.model.services.ServiceItem) Item(org.talend.core.model.properties.Item) OSGIJavaScriptForESBWithMavenManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager) JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) Element(org.dom4j.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) Document(org.dom4j.Document) RepositoryNode(org.talend.repository.model.RepositoryNode) HashMap(java.util.HashMap) Map(java.util.Map) ZipToFile(org.talend.repository.ui.utils.ZipToFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

JobExportAction (org.talend.repository.ui.wizards.exportjob.action.JobExportAction)9 RepositoryNode (org.talend.repository.model.RepositoryNode)6 File (java.io.File)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 RouteBundleExportAction (org.talend.camel.designer.build.RouteBundleExportAction)2 RouteDedicatedJobManager (org.talend.camel.designer.ui.wizards.export.RouteDedicatedJobManager)2 RouteJavaScriptOSGIForESBManager (org.talend.camel.designer.ui.wizards.export.RouteJavaScriptOSGIForESBManager)2 Item (org.talend.core.model.properties.Item)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 ZipToFile (org.talend.repository.ui.utils.ZipToFile)2 OSGIJavaScriptForESBWithMavenManager (org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager)2 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ZipFile (java.util.zip.ZipFile)1