use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class JavaProcessUtil method getModuleNeededForContextParam.
private static ModuleNeeded getModuleNeededForContextParam(IContextParameter contextParam) {
if (contextParam != null) {
String values = contextParam.getValue();
if (StringUtils.isNotBlank(values)) {
// if it's path
IPath path = new Path(values);
// get the file name only.
String fileName = path.lastSegment();
ModuleNeeded module = new ModuleNeeded(null, fileName, null, true);
return module;
}
}
return null;
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class JavaProcessUtil method getModulesInTable.
private static void getModulesInTable(final IProcess process, IElementParameter curParam, List<ModuleNeeded> modulesNeeded) {
if (!(curParam.getValue() instanceof List)) {
return;
}
List<Map<String, Object>> values = (List<Map<String, Object>>) curParam.getValue();
if (values != null && !values.isEmpty()) {
Object[] listItemsValue = curParam.getListItemsValue();
if (listItemsValue != null && listItemsValue.length > 0 && listItemsValue[0] instanceof IElementParameter) {
for (Object o : listItemsValue) {
IElementParameter param = (IElementParameter) o;
if (param.getFieldType() == EParameterFieldType.MODULE_LIST) {
for (Map<String, Object> line : values) {
String moduleName = (String) line.get(param.getName());
if (moduleName != null && !"".equals(moduleName)) {
//$NON-NLS-1$
boolean isContextMode = ContextParameterUtils.containContextVariables(moduleName);
if (isContextMode) {
List<IContext> listContext = process.getContextManager().getListContext();
for (IContext context : listContext) {
List<IContextParameter> contextParameterList = context.getContextParameterList();
for (IContextParameter contextPara : contextParameterList) {
String var = ContextParameterUtils.getVariableFromCode(moduleName);
if (var.equals(contextPara.getName())) {
String value = context.getContextParameter(contextPara.getName()).getValue();
if (curParam.getName().equals(EParameterName.DRIVER_JAR.getName()) && value.contains(";")) {
//$NON-NLS-1$
//$NON-NLS-1$
String[] jars = value.split(";");
for (String jar2 : jars) {
String jar = jar2;
//$NON-NLS-1$
jar = jar.substring(jar.lastIndexOf("\\") + 1);
ModuleNeeded module = new ModuleNeeded(null, jar, null, true);
modulesNeeded.add(module);
}
} else {
//$NON-NLS-1$
value = value.substring(value.lastIndexOf("\\") + 1);
ModuleNeeded module = new ModuleNeeded(null, value, null, true);
modulesNeeded.add(module);
}
}
}
}
} else {
ModuleNeeded mn = getModuleValue(process, moduleName);
if (line.get("JAR_NEXUS_VERSION") != null) {
String a = moduleName.replaceFirst("[.][^.]+$", "");
mn.setMavenUri("mvn:org.talend.libraries/" + a + "/" + line.get("JAR_NEXUS_VERSION") + "/jar");
}
modulesNeeded.add(mn);
}
}
}
}
}
}
}
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class JavaProcessUtil method getChildrenModules.
static List<ModuleNeeded> getChildrenModules(final INode node, Set<ProcessItem> searchItems, boolean forMR) {
List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
if (node.getComponent().getName().equals("tRunJob")) {
//$NON-NLS-1$
//$NON-NLS-1$
IElementParameter processIdparam = node.getElementParameter("PROCESS_TYPE_PROCESS");
IElementParameter processVersionParam = node.getElementParameter(EParameterName.PROCESS_TYPE_VERSION.getName());
ProcessItem processItem = null;
if (processVersionParam != null) {
processItem = ItemCacheManager.getProcessItem((String) processIdparam.getValue(), (String) processVersionParam.getValue());
} else {
processItem = ItemCacheManager.getProcessItem((String) processIdparam.getValue());
}
//$NON-NLS-1$
String context = (String) node.getElementParameter("PROCESS_TYPE_CONTEXT").getValue();
if (processItem != null && !searchItems.contains(processItem)) {
boolean seperated = //$NON-NLS-1$
getBooleanParamValue(node, "USE_INDEPENDENT_PROCESS") || //$NON-NLS-1$
getBooleanParamValue(node, "USE_DYNAMIC_JOB");
if (!seperated) {
// avoid dead loop of method call
searchItems.add(processItem);
JobInfo subJobInfo = new JobInfo(processItem, context);
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess child = service.getProcessFromItem(subJobInfo.getProcessItem());
getNeededModules(child, true, searchItems, modulesNeeded, forMR);
}
}
}
return modulesNeeded;
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class WSDL2JAVAController method addWsdlNeedLib.
// gcui:see bug 9733.
private void addWsdlNeedLib(RoutineItem routineItem) {
List<IMPORTType> wsdlNeedImport = new ArrayList<IMPORTType>();
IMPORTType type1 = ComponentFactory.eINSTANCE.createIMPORTType();
type1.setMODULE("axis.jar");
type1.setREQUIRED(true);
type1.setNAME(routineItem.getProperty().getLabel());
wsdlNeedImport.add(type1);
IMPORTType type2 = ComponentFactory.eINSTANCE.createIMPORTType();
type2.setMODULE("jaxrpc.jar");
type2.setREQUIRED(true);
type2.setNAME(routineItem.getProperty().getLabel());
wsdlNeedImport.add(type2);
routineItem.getImports().addAll(wsdlNeedImport);
try {
CorePlugin.getDefault().getProxyRepositoryFactory().save(routineItem);
} catch (Exception e) {
ExceptionHandler.process(e);
}
CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
CorePlugin.getDefault().getRunProcessService().updateLibraries(new HashSet<ModuleNeeded>(), null);
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method sortClasspath.
// // see bug 3914, make the order of the jar files consistent with the
// command
// // line in run mode
private static void sortClasspath(Set<ModuleNeeded> jobModuleList, IProcess process, Set<ModuleNeeded> alreadyRetrievedModules) throws CoreException, ProcessorException {
ITalendProcessJavaProject jProject = getTalendJavaProject();
if (jProject == null) {
return;
}
Set<ModuleNeeded> listModulesReallyNeeded = new HashSet<ModuleNeeded>();
listModulesReallyNeeded.addAll(jobModuleList);
Set<ModuleNeeded> optionalJarsOnlyForRoutines = new HashSet<ModuleNeeded>();
// only for wizards or additional jars only to make the java project compile without any error.
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getSystemRunningModules()) {
optionalJarsOnlyForRoutines.add(moduleNeeded);
}
// list contains all routines linked to job as well as routines not used in the job
// rebuild the list to have only the libs linked to routines "not used".
optionalJarsOnlyForRoutines.removeAll(listModulesReallyNeeded);
// only to be able to compile java project without error.
for (ModuleNeeded jar : optionalJarsOnlyForRoutines) {
listModulesReallyNeeded.add(jar);
}
addLog4jToModuleList(listModulesReallyNeeded);
listModulesReallyNeeded.removeAll(alreadyRetrievedModules);
alreadyRetrievedModules.addAll(listModulesReallyNeeded);
String missingJars = null;
Set<String> missingJarsForRoutinesOnly = new HashSet<String>();
Set<String> missingJarsForProcessOnly = new HashSet<String>();
File libDir = getJavaProjectLibFolder();
ILibraryManagerService repositoryBundleService = CorePlugin.getDefault().getRepositoryBundleService();
if ((libDir != null) && (libDir.isDirectory())) {
Set<ModuleNeeded> jarsNeedRetrieve = new HashSet<ModuleNeeded>();
for (ModuleNeeded moduleNeeded : listModulesReallyNeeded) {
jarsNeedRetrieve.add(moduleNeeded);
}
if (!jarsNeedRetrieve.isEmpty()) {
repositoryBundleService.retrieve(jarsNeedRetrieve, libDir.getAbsolutePath(), true);
if (process instanceof IProcess2) {
((IProcess2) process).checkProcess();
}
}
Set<ModuleNeeded> exist = new HashSet<ModuleNeeded>();
for (File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) {
for (ModuleNeeded module : jarsNeedRetrieve) {
if (externalLib.getName().equals(module.getModuleName())) {
exist.add(module);
}
}
}
jarsNeedRetrieve.removeAll(exist);
Set<String> jarStringListNeededByProcess = new HashSet<String>();
for (ModuleNeeded moduleNeeded : jobModuleList) {
jarStringListNeededByProcess.add(moduleNeeded.getModuleName());
}
for (ModuleNeeded jar : jarsNeedRetrieve) {
if (jobModuleList.contains(jar)) {
missingJarsForProcessOnly.add(jar.getModuleName());
} else {
missingJarsForRoutinesOnly.add(jar.getModuleName());
}
if (missingJars == null) {
//$NON-NLS-1$
missingJars = Messages.getString("JavaProcessorUtilities.msg.missingjar.forProcess") + jar;
} else {
//$NON-NLS-1$
missingJars = missingJars + ", " + jar;
}
}
}
repositoryBundleService.deployModules(listModulesReallyNeeded, null);
if (missingJars != null) {
handleMissingJarsForProcess(missingJarsForRoutinesOnly, missingJarsForProcessOnly, missingJars);
}
}
Aggregations