use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class ExpressionTest method testEvaluateDistrib_link.
@Test
public void testEvaluateDistrib_link() {
List<IElementParameter> params = new ArrayList<>();
ElementParameter param1 = createMockParameter("PARA1", true, null);
params.add(param1);
ElementParameter paramNode = mock(ElementParameter.class);
INode testElement = mock(INode.class);
when(paramNode.getName()).thenReturn("PARANODE");
TextElementParameter testParam = mock(TextElementParameter.class);
when(paramNode.getElement()).thenReturn(testElement);
when(paramNode.getElement().getElementName()).thenReturn("testComponent");
when(testElement.getElementParametersWithChildrens()).thenReturn((List) Arrays.asList(testParam));
when(testParam.getVariableName()).thenReturn("__CONNECTION__");
when(testParam.getValue()).thenReturn("relatedNode");
INode relatedNode = mock(INode.class);
when(relatedNode.getUniqueName()).thenReturn("relatedNode");
when(relatedNode.getElementParameters()).thenReturn((List) params);
IProcess process = mock(IProcess.class);
when(process.getGeneratingNodes()).thenReturn((List) Arrays.asList(relatedNode));
when(testElement.getProcess()).thenReturn(process);
params.add(paramNode);
ElementParameter distrib = createMockParameter("DISTRIBUTION", "CUSTOM");
params.add(distrib);
ElementParameter version = createMockParameter("HIVE_VERSION", "testVersion");
params.add(version);
ElementParameter invaliddistrib = createMockParameter("INVALDDISTRIB", "INVALID");
params.add(invaliddistrib);
assertTrue(Expression.evaluateDistrib("DISTRIB[#LINK@NODE.CONNECTION.DISTRIBUTION, #LINK@NODE.CONNECTION.HIVE_VERSION].doSupportUseDatanodeHostname[]", params, paramNode));
assertFalse(Expression.evaluateDistrib("!DISTRIB[#LINK@NODE.CONNECTION.DISTRIBUTION, #LINK@NODE.CONNECTION.HIVE_VERSION].doSupportUseDatanodeHostname[]", params, paramNode));
}
use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.
the class CamelFeatureUtil method addFeatureAndBundles.
/**
* Add feature and bundle to Feature Model
*
* @param node
* @param featuresModel
*/
public static void addFeatureAndBundles(ProcessItem routeProcess, FeaturesModel featuresModel) {
IDesignerCoreService designerService = RepositoryPlugin.getDefault().getDesignerCoreService();
IProcess process = designerService.getProcessFromProcessItem(routeProcess, false);
Collection<FeatureModel> features = new HashSet<FeatureModel>();
for (String lib : process.getNeededLibraries(true)) {
Collection<FeatureModel> featureModel = computeFeature(getNameWithoutVersion(lib));
if (featureModel != null) {
features.addAll(featureModel);
}
}
addNodesSpecialFeatures(features, routeProcess.getProcess());
addConnectionsSpecialFeatures(features, routeProcess.getProcess());
for (FeatureModel model : features) {
featuresModel.addFeature(model);
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class JobJavaScriptOSGIForESBManager method getExportResources.
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions) throws ProcessorException {
List<ExportFileResource> list = new ArrayList<ExportFileResource>();
//$NON-NLS-1$;
ExportFileResource osgiResource = new ExportFileResource(null, "");
//$NON-NLS-1$
ExportFileResource jobScriptResource = new ExportFileResource(null, "");
list.add(osgiResource);
list.add(jobScriptResource);
// set export config mode now only to be sure that the libraries will be
// setup for an export mode, and not
// editor mode.
//$NON-NLS-1$
ProcessorUtilities.setExportConfig(JAVA, "", "");
// set export type as osgi
ProcessorUtilities.setExportAsOSGI(true);
try {
ProcessItem processItem = null;
for (ExportFileResource process : processes) {
processItem = (ProcessItem) process.getItem();
if (processItem.eIsProxy() || processItem.getProcess().eIsProxy()) {
try {
Property property = ProxyRepositoryFactory.getInstance().getUptodateProperty(processItem.getProperty());
processItem = (ProcessItem) property.getItem();
} catch (PersistenceException e) {
throw new ProcessorException(e);
}
}
String jobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && getSelectedJobVersion() != null) {
jobVersion = getSelectedJobVersion();
}
ProcessorUtilities.setExportConfig(process.getDirectoryName(), true);
String processId = processItem.getProperty().getId();
if (null == contextName) {
contextName = processItem.getProcess().getDefaultContext();
}
IProcess iProcess = generateJobFiles(processItem, contextName, jobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
analysisModules(processId, jobVersion);
analysisMavenModule(processItem);
// generate jar file for job
getJobScriptsUncompressed(jobScriptResource, processItem);
// dynamic DB XML mapping
addXmlMapping(process, isOptionChoosed(ExportChoice.needSourceCode));
generateConfig(osgiResource, processItem, iProcess);
addResources(osgiResource, processItem);
/*
* export current item's dependencies. this used for TDM components specially and need more discussion
* about then
*/
BuildExportManager.getInstance().exportOSGIDependencies(osgiResource, processItem);
}
ExportFileResource libResource = getCompiledLibExportFileResource(processes);
list.add(libResource);
// generate the META-INFO folder
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
list.add(0, metaInfoFolder);
ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
if (providedLibResources != null) {
list.add(providedLibResources);
}
} catch (ProcessorException e) {
throw e;
} catch (Exception e) {
throw new ProcessorException(e);
}
return list;
}
use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.
the class JobJavaScriptOSGIForESBRuntimeManager method generateJobFiles.
@Override
protected IProcess generateJobFiles(ProcessItem process, String contextName, String version, boolean statistics, boolean trace, boolean applyContextToChildren, IProgressMonitor monitor) throws ProcessorException {
LastGenerationInfo.getInstance().getUseDynamicMap().clear();
// TODO stat port tracer, to replace the port, need to improve efficiency
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess currentProcess = service.getProcessFromProcessItem(process);
IProcessor processor = ProcessorUtilities.getProcessor(currentProcess, null);
StatPortChecker checker = null;
if (processor instanceof MavenJavaProcessor) {
MavenJavaProcessor mvnProcessor = (MavenJavaProcessor) processor;
checker = new StatPortChecker(processor.getCodeProject().getFile(mvnProcessor.getSrcCodePath()).getLocation(), statisticPort, tracePort);
new Thread(checker, "Statistic Port Finder").start();
mvnProcessor = null;
}
IProcessor processor2 = ProcessorUtilities.generateCode(process, contextName, version, statistics, trace, applyContextToChildren, isOptionChoosed(ExportChoice.needContext), monitor);
if (checker != null) {
checker.stop();
}
return processor2.getProcess();
}
Aggregations