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