Search in sources :

Example 1 with JobScriptsManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager 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 JobScriptsManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager 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 3 with JobScriptsManager

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager 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 JobScriptsManager

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

the class ExportServiceAction method exportJobsBundle.

private void exportJobsBundle(IProgressMonitor monitor, FeaturesModel feature) throws InvocationTargetException, InterruptedException {
    String directoryName = serviceManager.getRootFolderName(tempFolder);
    for (IRepositoryViewObject node : nodes) {
        JobScriptsManager manager = serviceManager.getJobManager(exportChoiceMap, tempFolder, node, getGroupId(), getServiceVersion());
        JobExportAction job = new JobExportAction(Collections.singletonList(new RepositoryNode(node, null, ENodeType.REPOSITORY_ELEMENT)), node.getVersion(), getBundleVersion(), manager, directoryName, //$NON-NLS-1$
        "Service");
        job.run(monitor);
        feature.addBundle(new BundleModel(getGroupId(), serviceManager.getNodeLabel(node), getServiceVersion(), new File(manager.getDestinationPath())));
    }
}
Also used : JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) BundleModel(org.talend.designer.publish.core.models.BundleModel) RepositoryNode(org.talend.repository.model.RepositoryNode) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 5 with JobScriptsManager

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

the class JavaJobScriptsExportWSWizardPage method createJobScriptsManager.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWizardPage#createJobScriptsManager()
     */
@Override
public JobScriptsManager createJobScriptsManager() {
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
    String log4jLevel = "";
    String launcher = (getCurrentExportType1() == JobExportType.POJO) ? launcherCombo.getText() : "all";
    String context = (contextCombo == null || contextCombo.isDisposed()) ? IContext.DEFAULT : contextCombo.getText();
    JobScriptsManager manager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, context, launcher, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, getCurrentExportType1());
    manager.setDestinationPath(getDestinationValue());
    if (log4jLevelCombo != null && !log4jLevelCombo.isDisposed()) {
        if (log4jLevelCombo.isEnabled()) {
            log4jLevel = log4jLevelCombo.getText();
        } else {
            log4jLevel = null;
        }
    } else {
        log4jLevel = null;
    }
    manager.setLog4jLevel(log4jLevel);
    return manager;
}
Also used : JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)

Aggregations

JobScriptsManager (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager)5 File (java.io.File)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)3 IOException (java.io.IOException)2 URL (java.net.URL)2 EnumMap (java.util.EnumMap)2 IFile (org.eclipse.core.resources.IFile)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 ProcessorException (org.talend.designer.runprocess.ProcessorException)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 Map (java.util.Map)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 IContext (org.talend.core.model.process.IContext)1 Item (org.talend.core.model.properties.Item)1 SalesforceModuleRepositoryObject (org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject)1 BundleModel (org.talend.designer.publish.core.models.BundleModel)1