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());
}
}
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;
}
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);
}
}
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())));
}
}
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;
}
Aggregations