Search in sources :

Example 1 with OSGIJavaScriptForESBWithMavenManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager in project tesb-studio-se by Talend.

the class KarafJavaScriptForESBWithMavenManager method getOsgiWithMavenManager.

/**
     * DOC ggu Comment method "getOsgiWithMavenManager".
     *
     * @param contextgGroup
     * @return
     */
private OSGIJavaScriptForESBWithMavenManager getOsgiWithMavenManager(final List<ExportFileResource> list, final String talendJobLabel, String contextgGroup) {
    OSGIJavaScriptForESBWithMavenManager osgiWithMavenManager = new OSGIJavaScriptForESBWithMavenManager(new EnumMap<ExportChoice, Object>(this.exportChoice), contextgGroup, JobScriptsManager.LAUNCHER_ALL, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES) {

        @Override
        protected Map<String, String> getMainMavenProperties(Item item) {
            Map<String, String> mavenPropertiesMap = super.getMainMavenProperties(item);
            // same group id with karaf
            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
                Element artifactIdEle = rootElement.element(IMavenProperties.ELE_ARTIFACT_ID);
                if (artifactIdEle != null) {
                    artifactIdEle.setText(itemName);
                }
            }
        }

        @Override
        protected String getTmpFolder() {
            return getSystemTempFolder().getAbsolutePath();
        }

        @Override
        public void setTopFolder(List<ExportFileResource> resourcesToExport) {
            super.setTopFolder(resourcesToExport);
            // TDI-23377, need reset the path and add it in for route exporting.
            for (ExportFileResource fileResource : resourcesToExport) {
                String directory = fileResource.getDirectoryName();
                fileResource.setDirectoryName(TALEND_JOBS_PATH + talendJobLabel + PATH_SEPARATOR + directory);
                // add to current route to export
                list.add(fileResource);
            }
        }
    };
    return osgiWithMavenManager;
}
Also used : CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) OSGIJavaScriptForESBWithMavenManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager) ExportFileResource(org.talend.repository.documentation.ExportFileResource) Element(org.dom4j.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) EList(org.eclipse.emf.common.util.EList) Document(org.dom4j.Document) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap)

Example 2 with OSGIJavaScriptForESBWithMavenManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager in project tesb-studio-se by Talend.

the class KarafJavaScriptForESBWithMavenManager method deleteTempFiles.

/*
     * (non-Javadoc)
     *
     * @see org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager#deleteTempFiles()
     */
@Override
public void deleteTempFiles() {
    super.deleteTempFiles();
    // delete the tmp for cTalendJob also
    for (String key : talendJobOsgiWithMavenManagersMap.keySet()) {
        OSGIJavaScriptForESBWithMavenManager manager = talendJobOsgiWithMavenManagersMap.get(key);
        manager.deleteTempFiles();
    }
}
Also used : OSGIJavaScriptForESBWithMavenManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager)

Example 3 with OSGIJavaScriptForESBWithMavenManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager 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) Map(java.util.Map) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File)

Example 4 with OSGIJavaScriptForESBWithMavenManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager in project tesb-studio-se by Talend.

the class KarafJavaScriptForESBWithMavenManager method addTalendJobsExportResources.

private void addTalendJobsExportResources(List<ExportFileResource> list) {
    // for cTalendJob
    Iterator<String> iterator = this.talendJobsMap.keySet().iterator();
    while (iterator.hasNext()) {
        String key = iterator.next();
        IRepositoryViewObject repObject = this.talendJobsMap.get(key);
        if (repObject == null) {
            continue;
        }
        final Item talendJobItem = repObject.getProperty().getItem();
        if (talendJobItem == null) {
            continue;
        }
        String contextgGroup = this.talendJobContextGroupsMap.get(key);
        if (contextgGroup == null) {
            contextgGroup = IContext.DEFAULT;
        }
        final String talendJobLabel = talendJobItem.getProperty().getLabel();
        final String talendJobVersion = talendJobItem.getProperty().getVersion();
        File talendJobDestFile = new File(getTmpFolder(), talendJobLabel + '_' + talendJobVersion + FileConstants.ZIP_FILE_SUFFIX);
        String talendJobPath = talendJobDestFile.getAbsolutePath();
        OSGIJavaScriptForESBWithMavenManager osgiWithMavenManager = getOsgiWithMavenManager(list, talendJobLabel, contextgGroup);
        osgiWithMavenManager.setDestinationPath(talendJobPath);
        osgiWithMavenManager.setJobVersion(talendJobVersion);
        talendJobOsgiWithMavenManagersMap.put(key, osgiWithMavenManager);
        //$NON-NLS-1$
        ExportFileResource talendJobResource = new ExportFileResource(talendJobItem, "");
        talendJobResource.setDirectoryName(talendJobPath);
        try {
            RepositoryNode node = new RepositoryNode(repObject, null, ENodeType.REPOSITORY_ELEMENT);
            JobExportAction job = new JobExportAction(Collections.singletonList(node), talendJobVersion, osgiWithMavenManager, talendJobPath) {

                @Override
                protected void doArchiveExport(IProgressMonitor monitor, List<ExportFileResource> resourcesToExport) {
                // TDI-23377, no need do archive, because will re-use the resources to export for route
                // super.doArchiveExport(monitor, resourcesToExport);
                }

                @Override
                protected void reBuildJobZipFile(List<ExportFileResource> processes) {
                // TDI-23377, no need do archive, because will re-use the resources to export for route
                // super.reBuildJobZipFile(processes);
                }

                @Override
                protected void clean() {
                // TDI-23377, will re-use the tmp. so don't clean
                // super.clean();
                }
            };
            job.run(this.progressMonitor != null ? this.progressMonitor : new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) RepositoryNode(org.talend.repository.model.RepositoryNode) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) OSGIJavaScriptForESBWithMavenManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) EList(org.eclipse.emf.common.util.EList) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Aggregations

OSGIJavaScriptForESBWithMavenManager (org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager)4 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 File (java.io.File)2 List (java.util.List)2 Map (java.util.Map)2 Document (org.dom4j.Document)2 Element (org.dom4j.Element)2 EList (org.eclipse.emf.common.util.EList)2 CamelProcessItem (org.talend.camel.core.model.camelProperties.CamelProcessItem)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 ExportFileResource (org.talend.repository.documentation.ExportFileResource)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 JobExportAction (org.talend.repository.ui.wizards.exportjob.action.JobExportAction)2 MalformedURLException (java.net.MalformedURLException)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 ZipFile (java.util.zip.ZipFile)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1