use of org.talend.designer.core.model.utils.emf.component.IMPORTType in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExternalLibraries.
/**
* Gets required java jars.
*
* @param process
*
* @param boolean1
* @return
*/
protected List<URL> getExternalLibraries(boolean needLibraries, ExportFileResource[] process, final Set<String> neededLibraries) {
List<URL> list = new ArrayList<URL>();
if (!needLibraries) {
return list;
}
IFolder libFolder = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
libFolder = talendProcessJavaProject.getLibFolder();
}
}
if (libFolder == null) {
return list;
}
File file = libFolder.getLocation().toFile();
File[] files = file.listFiles(FilesUtils.getAcceptModuleFilesFilter());
// Lists all the needed jar files
Set<String> listModulesReallyNeeded = new HashSet<String>();
if (neededLibraries == null) {
// in case export as been done with option "not recompile", then libraires can't be retrieved when build.
IDesignerCoreService designerService = RepositoryPlugin.getDefault().getDesignerCoreService();
for (ExportFileResource resource : process) {
ProcessItem item = (ProcessItem) resource.getItem();
String version = item.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
version = this.getSelectedJobVersion();
}
ProcessItem selectedProcessItem;
if (resource.getNode() != null) {
selectedProcessItem = ItemCacheManager.getProcessItem(resource.getNode().getRoot().getProject(), item.getProperty().getId(), version);
} else {
// if no node given, take in the current project only
selectedProcessItem = ItemCacheManager.getProcessItem(item.getProperty().getId(), version);
}
IProcess iProcess = designerService.getProcessFromProcessItem(selectedProcessItem);
Set<String> processNeededLibraries = iProcess.getNeededLibraries(true);
if (processNeededLibraries != null) {
listModulesReallyNeeded.addAll(processNeededLibraries);
}
}
} else {
listModulesReallyNeeded.addAll(neededLibraries);
}
// jar from routines
List<IRepositoryViewObject> collectRoutines = new ArrayList<IRepositoryViewObject>();
boolean useBeans = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(process[0].getItem())) {
useBeans = true;
}
}
String include = null;
if (useBeans) {
include = USER_BEANS_PATH;
} else {
include = USER_ROUTINES_PATH;
}
collectRoutines.addAll(collectRoutines(process, include));
collectRoutines.addAll(collectRoutines(process, USER_PIGUDF_PATH));
for (IRepositoryViewObject object : collectRoutines) {
Item item = object.getProperty().getItem();
if (item instanceof RoutineItem) {
RoutineItem routine = (RoutineItem) item;
EList imports = routine.getImports();
for (Object o : imports) {
IMPORTType type = (IMPORTType) o;
listModulesReallyNeeded.add(type.getMODULE());
}
}
}
if (Log4jPrefsSettingManager.getInstance().isLog4jEnable()) {
addLog4jToJarList(listModulesReallyNeeded);
}
for (File tempFile : files) {
try {
if (listModulesReallyNeeded.contains(tempFile.getName())) {
list.add(tempFile.toURL());
}
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
}
}
return list;
// List<URL> libraries = new ArrayList<URL>();
// if (needLibraries) {
// try {
// ILibrariesService service = CorePlugin.getDefault().getLibrariesService();
// libraries = service.getTalendRoutines();
// } catch (Exception e) {
// ExceptionHandler.process(e);
// }
// }
// return libraries;
}
Aggregations