Search in sources :

Example 1 with FeaturesModel

use of org.talend.designer.publish.core.models.FeaturesModel in project tdi-studio-se by Talend.

the class AbstractPublishJobAction method getFeatureModel.

private FeaturesModel getFeatureModel(File tmpJob) {
    ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
    FeaturesModel featuresModel = new FeaturesModel(groupId, artifactName, artifactVersion);
    featuresModel.setConfigName(node.getObject().getLabel());
    featuresModel.setContexts(JobContextUtils.getContextsMap(processItem));
    BundleModel bundleModel = new BundleModel(groupId, artifactName, artifactVersion, tmpJob);
    featuresModel.addBundle(bundleModel);
    return featuresModel;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) BundleModel(org.talend.designer.publish.core.models.BundleModel)

Example 2 with FeaturesModel

use of org.talend.designer.publish.core.models.FeaturesModel in project tdi-studio-se by Talend.

the class AbstractPublishJobAction method exportJobForOSGI.

private void exportJobForOSGI(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    File tmpJob = null;
    final ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
    try {
        tmpJob = File.createTempFile("job", ".jar", null);
        jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(JobScriptsManagerFactory.getDefaultExportChoiceMap(), processItem.getProcess().getDefaultContext(), JobScriptsManager.LAUNCHER_ALL, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, JobExportType.OSGI);
        // generate
        jobScriptsManager.setDestinationPath(tmpJob.getAbsolutePath());
        JobExportAction action = new JobExportAction(Collections.singletonList(node), jobVersion, bundleVersion, jobScriptsManager, System.getProperty("java.io.tmpdir"));
        action.run(monitor);
        if (!action.isBuildSuccessful()) {
            return;
        }
        monitor.beginTask("Deploy to Artifact Repository....", IProgressMonitor.UNKNOWN);
        FeaturesModel featuresModel = getFeatureModel(tmpJob);
        // [TESB-12036] add talend-data-mapper feature
        NodeType tHMapNode = EmfModelUtils.getComponentByName(processItem, THMAP_COMPONENT_NAME);
        if (tHMapNode != null) {
            featuresModel.addFeature(new FeatureModel(FeaturesModel.TALEND_DATA_MAPPER_FEATURE_NAME));
        }
        processModules(featuresModel, ((JobJavaScriptOSGIForESBManager) jobScriptsManager).getExcludedModuleNeededs());
        process(processItem, featuresModel, monitor);
    } catch (IOException e) {
        throw new InvocationTargetException(e);
    } finally {
        if (tmpJob != null && tmpJob.exists()) {
            tmpJob.delete();
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) IOException(java.io.IOException) File(java.io.File) FeatureModel(org.talend.designer.publish.core.models.FeatureModel) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with FeaturesModel

use of org.talend.designer.publish.core.models.FeaturesModel in project tdi-studio-se by Talend.

the class AbstractPublishJobAction method exportJobForPOJO.

private void exportJobForPOJO(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    File tmpJob = null;
    try {
        tmpJob = File.createTempFile("item", ".zip", null);
        // jobScriptsManager.setDestinationPath(tmpJob.getAbsolutePath());
        // JobExportAction action = new JobExportAction(Collections.singletonList(node), jobVersion,
        // jobScriptsManager, null,
        // "job");
        // action.run(monitor);
        // if (!action.isBuildSuccessful()) {
        // return;
        // }
        // TDI-32861, because for publish job, so means, must be binaries
        exportChoiceMap.put(ExportChoice.binaries, true);
        exportChoiceMap.put(ExportChoice.includeLibs, true);
        exportChoiceMap.put(ExportChoice.addStatistics, true);
        ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
        String contextName = (String) exportChoiceMap.get(ExportChoice.contextName);
        if (contextName == null) {
            contextName = processItem.getProcess().getDefaultContext();
        }
        BuildJobManager.getInstance().buildJob(tmpJob.getAbsolutePath(), processItem, jobVersion, contextName, exportChoiceMap, exportType, monitor);
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
            IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
            boolean hasError = service.checkExportProcess(new StructuredSelection(node), true);
            if (hasError) {
                return;
            }
        }
        monitor.beginTask("Deploy to Artifact Repository....", IProgressMonitor.UNKNOWN);
        FeaturesModel featuresModel = getFeatureModel(tmpJob);
        process(processItem, featuresModel, monitor);
    } catch (InterruptedException e) {
        throw e;
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    } finally {
        if (tmpJob != null && tmpJob.exists()) {
            tmpJob.delete();
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) File(java.io.File) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with FeaturesModel

use of org.talend.designer.publish.core.models.FeaturesModel in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method run.

@Override
public final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    this.monitor = monitor;
    String groupId = getGroupId();
    String routeName = getArtifactId();
    String routeVersion = getArtifactVersion();
    featuresModel = new FeaturesModel(groupId, routeName, routeVersion);
    try {
        // generated bundle jar first
        File routeFile;
        try {
            routeFile = File.createTempFile("route", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
            new File(getTempDir()));
        } catch (IOException e) {
            throw new InvocationTargetException(e);
        }
        BundleModel routeModel = new BundleModel(groupId, routeName, routeVersion, routeFile);
        if (featuresModel.addBundle(routeModel)) {
            final ProcessItem routeProcess = (ProcessItem) routeNode.getObject().getProperty().getItem();
            CamelFeatureUtil.addFeatureAndBundles(routeProcess, featuresModel);
            featuresModel.setConfigName(routeNode.getObject().getLabel());
            featuresModel.setContexts(JobContextUtils.getContextsMap(routeProcess));
            exportAllReferenceJobs(routeName, routeProcess);
            final Set<String> routelets = new HashSet<>();
            exportAllReferenceRoutelets(routeName, routeProcess, routelets);
            exportRouteBundle(routeNode, routeFile, version, null, null, bundleVersion, null, routelets, null);
        }
        processResults(featuresModel, monitor);
    } finally {
        // remove generated files
        removeTempFiles();
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) BundleModel(org.talend.designer.publish.core.models.BundleModel) IOException(java.io.IOException) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) HashSet(java.util.HashSet)

Example 5 with FeaturesModel

use of org.talend.designer.publish.core.models.FeaturesModel in project tesb-studio-se by Talend.

the class ExportServiceAction method run.

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    String destinationPath = serviceManager.getDestinationPath();
    if (!destinationPath.endsWith(FileConstants.KAR_FILE_SUFFIX)) {
        //$NON-NLS-1$
        destinationPath = destinationPath.replace("\\", PATH_SEPERATOR);
        if (destinationPath.indexOf(PATH_SEPERATOR) != -1) {
            String filePath = destinationPath.substring(0, destinationPath.lastIndexOf(PATH_SEPERATOR) + 1);
            String fileName = destinationPath.substring(destinationPath.lastIndexOf(PATH_SEPERATOR) + 1);
            if (fileName.indexOf('.') != -1) {
                fileName = fileName.substring(0, fileName.lastIndexOf('.'));
            }
            destinationPath = filePath + fileName + FileConstants.KAR_FILE_SUFFIX;
        }
    }
    FeaturesModel feature = new FeaturesModel(getGroupId(), getServiceName(), getServiceVersion());
    feature.setConfigName(getServiceName());
    feature.setContexts(contextValues);
    try {
        addRequiredFeatures(feature);
        exportJobsBundle(monitor, feature);
        // control bundle
        addControlBundle(feature);
        processFeature(feature);
        processFinalResult(destinationPath);
    } catch (InvocationTargetException e) {
        throw e;
    } catch (InterruptedException e) {
        throw e;
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    } finally {
        clean();
    }
}
Also used : FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

FeaturesModel (org.talend.designer.publish.core.models.FeaturesModel)5 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 File (java.io.File)3 BundleModel (org.talend.designer.publish.core.models.BundleModel)2 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)1 FeatureModel (org.talend.designer.publish.core.models.FeatureModel)1 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)1 JobExportAction (org.talend.repository.ui.wizards.exportjob.action.JobExportAction)1