use of org.talend.core.model.temp.ECodePart in project tesb-studio-se by Talend.
the class TemplatePartGenerator method generateDefaultTypedComponentCode.
private CharSequence generateDefaultTypedComponentCode(ECamelTemplate template, Object... params) throws CodeGeneratorException {
Object argument = null;
if (params.length > 0) {
argument = params[0];
}
ECodePart part = null;
String incomingName = null;
NodesSubTree subProcess = null;
if (params.length > 1) {
for (int i = 1; i < params.length; i++) {
if (params[i] instanceof ECodePart) {
part = (ECodePart) params[i];
} else if (params[i] instanceof String) {
incomingName = (String) params[i];
} else if (params[i] instanceof NodesSubTree) {
subProcess = (NodesSubTree) params[i];
}
}
}
return generateTypedComponentCode(template, argument, part, incomingName, subProcess);
}
use of org.talend.core.model.temp.ECodePart in project tdi-studio-se by Talend.
the class CodeGeneratorEmittersPoolFactory method initComponent.
/**
* initialization of the available components.
*
* @param codeLanguage
* @param jetBeans
* @param codePart
* @param component
*/
private static void initComponent(ECodeLanguage codeLanguage, List<JetBean> jetBeans, ECodePart codePart, IComponent component) {
if (component.getAvailableCodeParts().contains(codePart)) {
IComponentFileNaming fileNamingInstance = ComponentsFactoryProvider.getFileNamingInstance();
String templateURI = component.getPathSource() + TemplateUtil.DIR_SEP + component.getName() + TemplateUtil.DIR_SEP + fileNamingInstance.getJetFileName(component, codeLanguage.getExtension(), codePart);
String componentsPath = IComponentsFactory.COMPONENTS_LOCATION;
IBrandingService breaningService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (breaningService.isPoweredOnlyCamel()) {
componentsPath = IComponentsFactory.CAMEL_COMPONENTS_LOCATION;
}
if (component instanceof EmfComponent) {
componentsPath = ((EmfComponent) component).getSourceBundleName();
}
JetBean jetBean = new JetBean(componentsPath, templateURI, component.getName(), component.getVersion(), codeLanguage.getName(), codePart.getName());
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("EMF_ECORE", "org.eclipse.emf.ecore");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("EMF_COMMON", "org.eclipse.emf.common");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("CORERUNTIME_LIBRARIES", "org.talend.core.runtime");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("MANAGEMENT_LIBRARIES", "org.talend.metadata.managment");
//$NON-NLS-1$
jetBean.addClassPath("CORE_LIBRARIES", CorePlugin.PLUGIN_ID);
//$NON-NLS-1$
jetBean.addClassPath("CODEGEN_LIBRARIES", CodeGeneratorActivator.PLUGIN_ID);
//$NON-NLS-1$
jetBean.addClassPath("COMMON_LIBRARIES", CommonsPlugin.PLUGIN_ID);
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("COMPONENT_FRAMEWORK", "org.talend.components.api");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("DAIKON", "org.talend.daikon");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("COMPONENT_CORE", "org.talend.designer.core.generic");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("DESIGNER_CORE", "org.talend.designer.core");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("HADOOP_DISTRIBUTIONS", "org.talend.hadoop.distribution");
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("HADOOP_CUSTOM_DISTRIBUTIONS", "org.talend.hadoop.distribution.custom");
if (PluginChecker.isGEFAbstractMapLoaded()) {
//$NON-NLS-1$ //$NON-NLS-2$
jetBean.addClassPath("GEF_MAP", "org.talend.designer.gefabstractmap");
}
for (String pluginDependency : component.getPluginDependencies()) {
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
jetBean.addClassPath(pluginDependency.toUpperCase().replaceAll("\\.", "_") + "_LIBRARIES", pluginDependency);
}
String familyName = component.getOriginalFamilyName();
if (familyName.contains("|")) {
//$NON-NLS-1$
//$NON-NLS-1$
familyName = component.getOriginalFamilyName().substring(0, component.getOriginalFamilyName().indexOf("|"));
}
jetBean.setFamily(StringUtils.removeSpecialCharsForPackage(familyName.toLowerCase()));
// Spark, M/R and Storm requires the plugin org.talend.designer.spark to be in the classpath in order to
// generate the code.
//$NON-NLS-1$
String sparkUtilsPluginName = "org.talend.designer.spark";
//$NON-NLS-1$
String bigDataUtilsPluginName = "org.talend.designer.bigdata";
if (PluginChecker.isPluginLoaded(sparkUtilsPluginName) && (//$NON-NLS-1$
"SPARK".equals(component.getPaletteType()) || "MR".equals(component.getPaletteType()) || //$NON-NLS-1$ //$NON-NLS-2$
"STORM".equals(component.getPaletteType()) || "SPARKSTREAMING".equals(component.getPaletteType()))) {
//$NON-NLS-1$
//$NON-NLS-1$
jetBean.addClassPath("BIGDATA_LIBRARIES", bigDataUtilsPluginName);
//$NON-NLS-1$
jetBean.addClassPath("SPARK_LIBRARIES", sparkUtilsPluginName);
jetBean.setClassLoader(createDelegateClassLoader(createDelegateClassLoader(new CodeGeneratorEmittersPoolFactory().getClass().getClassLoader(), bigDataUtilsPluginName, //$NON-NLS-1$
"org.talend.designer.bigdata.common.BigDataDataProcess"), sparkUtilsPluginName, //$NON-NLS-1$
"org.talend.designer.spark.SparkPlugin"));
// spark as a secondary, delegate classloader.
if (component.getPluginExtension() != null) {
jetBean.addClassPath(//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"EXTERNAL_COMPONENT_" + component.getPluginExtension().toUpperCase().replaceAll("\\.", "_"), component.getPluginExtension());
jetBean.setClassLoader(new DelegateClassLoader(ExternalNodesFactory.getInstance(component.getPluginExtension()).getClass().getClassLoader(), jetBean.getClassLoader()));
}
} else if (component.getPluginExtension() != null) {
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
jetBean.addClassPath(//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"EXTERNAL_COMPONENT_" + component.getPluginExtension().toUpperCase().replaceAll("\\.", "_"), component.getPluginExtension());
jetBean.setClassLoader(ExternalNodesFactory.getInstance(component.getPluginExtension()).getClass().getClassLoader());
} else {
jetBean.setClassLoader(new CodeGeneratorEmittersPoolFactory().getClass().getClassLoader());
}
jetBeans.add(jetBean);
}
// When building the main part of the component, also attempt to build the other parts.
if (codePart.compareTo(ECodePart.MAIN) == 0) {
for (ECodePart otherPart : ECodePart.values()) {
if (otherPart != ECodePart.MAIN && component.getAvailableCodeParts().contains(otherPart)) {
initComponent(codeLanguage, jetBeans, otherPart, component);
}
}
}
}
Aggregations