use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutines.
protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
if (USER_BEANS_PATH.equals(type)) {
ERepositoryObjectType beansType = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
beansType = service.getBeansType();
}
try {
toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn = Collections.emptyList();
}
} else {
Set<String> allRoutinesNames = new HashSet<String>();
ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
if (USER_PIGUDF_PATH.equals(type)) {
objectType = ERepositoryObjectType.PIG_UDF;
}
if (ERepositoryObjectType.ROUTINES == objectType) {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
} else {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
}
if (allRoutinesNames.isEmpty()) {
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
} else {
toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
}
}
return toReturn;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobExportAction method reBuildJobZipFile.
/**
*
* DOC aiming Comment method "reBuildJobZipFile".
*
* @param processes
*/
protected void reBuildJobZipFile(List<ExportFileResource> processes) {
JavaJobExportReArchieveCreator creator = null;
String zipFile = getTempDestinationValue();
String destinationZipFile = manager.getDestinationPath();
String tmpFolder = ExportJobUtil.getTmpFolder();
try {
// unzip to tmpFolder
ZipToFile.unZipFile(zipFile, tmpFolder);
// build new jar
for (ExportFileResource process : processes) {
if (process != null) {
String jobFolderName = process.getDirectoryName();
//$NON-NLS-1$
int pos = jobFolderName.indexOf("/");
if (pos != -1) {
jobFolderName = jobFolderName.substring(pos + 1);
}
if (creator == null) {
creator = new JavaJobExportReArchieveCreator(zipFile, jobFolderName);
} else {
creator.setJobFolerName(jobFolderName);
}
creator.buildNewJar();
}
}
// Modified by Marvin Wang on Feb.1, 2012 for bug
if (canCreateNewFile(destinationZipFile)) {
// rezip the tmpFolder to zipFile
ZipToFile.zipFile(tmpFolder, destinationZipFile);
} else {
MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Can not create a file", "Can not create a file or have not the permission to create a file!");
}
} catch (Exception e) {
ExceptionHandler.process(e);
} finally {
ExportJobUtil.deleteTempFiles();
JavaJobExportReArchieveCreator.deleteTempDestinationFiles();
// delete the temp zip file
new File(zipFile).delete();
}
}
use of org.talend.repository.documentation.ExportFileResource in project tesb-studio-se by Talend.
the class KarafJavaScriptForESBWithMavenManager method addKarFileToExport.
private void addKarFileToExport(List<ExportFileResource> list) {
if (destinationKar != null) {
File karFile = new File(destinationKar);
if (karFile.exists()) {
//$NON-NLS-1$
ExportFileResource karFileResource = new ExportFileResource(null, "");
try {
//$NON-NLS-1$
karFileResource.addResource("", karFile.toURI().toURL());
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
}
list.add(karFileResource);
}
}
}
use of org.talend.repository.documentation.ExportFileResource 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.documentation.ExportFileResource in project tesb-studio-se by Talend.
the class ExportServiceWithMavenAction method addMavenFilesToExport.
private void addMavenFilesToExport(IProgressMonitor monitor) throws Throwable {
manager.setDestinationPath(serviceManager.getDestinationPath());
String tempDestinationPath = getTempDestinationValue();
List<ExportFileResource> resourcesToExport = manager.getExportResources(//$NON-NLS-1$
new ExportFileResource[] { new ExportFileResource(serviceItem, "") });
ArchiveFileExportOperationFullPath exporterOperation = new ArchiveFileExportOperationFullPath(resourcesToExport, tempDestinationPath);
manager.setTopFolder(resourcesToExport);
executeExportOperation(exporterOperation, monitor);
ZipToFile.unZipFile(tempDestinationPath, tempFolder);
FilesUtils.removeFile(new File(tempDestinationPath));
}
Aggregations