use of org.talend.designer.core.model.components.EmfComponent in project tdi-studio-se by Talend.
the class TalendDndHelper method filterNeededComponents.
public static List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
List<IComponent> neededComponents = new ArrayList<IComponent>();
if (name == null) {
return neededComponents;
}
String productNameWanted = filterProductNameWanted(name, item);
boolean hl7Related = false;
boolean hl7Output = false;
if (item instanceof HL7ConnectionItem) {
hl7Related = true;
EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
if (list != null && list.size() > 0) {
hl7Output = true;
}
}
// for mdm
MdmConceptType mdmType = null;
if (item instanceof MDMConnectionItem) {
MDMConnectionItem mdmItem = (MDMConnectionItem) item;
if (seletetedNode != null && seletetedNode.getObject() instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) seletetedNode.getObject();
if (mdmItem.getConnection() instanceof MDMConnection) {
MDMConnection connection = (MDMConnection) mdmItem.getConnection();
for (Object obj : connection.getSchemas()) {
if (obj instanceof Concept && object.getLabel().equals(((Concept) obj).getLabel())) {
mdmType = ((Concept) obj).getConceptType();
}
}
}
}
}
Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
EmfComponent emfComponent = null;
for (IComponent component : components) {
if (component instanceof EmfComponent) {
emfComponent = (EmfComponent) component;
String componentProductname = emfComponent.getRepositoryType();
boolean value = true;
if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
value = false;
}
}
if (hl7Output && !component.getName().equals("tHL7Output")) {
//$NON-NLS-1$
value = false;
} else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
//$NON-NLS-N$ bug15632
value = false;
}
boolean flag = filterComponent(component, name, type);
if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
Pattern pattern = Pattern.compile("^.*oracle.*$", Pattern.CASE_INSENSITIVE);
if (pattern.matcher(name.getDBType()).matches() && (emfComponent.getName().equals("tAmazonOracleInput") || emfComponent.getName().equals("tAmazonOracleOutput"))) {
continue;
}
if (item instanceof MDMConnectionItem) {
if (MdmConceptType.INPUT.equals(mdmType) && emfComponent.getName().endsWith(INPUT)) {
neededComponents.add(emfComponent);
} else if (MdmConceptType.OUTPUT.equals(mdmType) && emfComponent.getName().endsWith(OUTPUT)) {
neededComponents.add(emfComponent);
} else if (MdmConceptType.RECEIVE.equals(mdmType) && emfComponent.getName().endsWith(RECEIVE)) {
neededComponents.add(emfComponent);
}
} else {
neededComponents.add(emfComponent);
}
}
}
}
return sortFilteredComponnents(item, seletetedNode, type, neededComponents);
}
use of org.talend.designer.core.model.components.EmfComponent in project tdi-studio-se by Talend.
the class ExternalNodeChangeCommand method execute.
@Override
public void execute() {
propagateInput();
// bug 0020749
if (!oldMetaDataList.isEmpty() && !newMetaDataList.isEmpty() && !oldMetaDataList.get(0).sameMetadataAs(newMetaDataList.get(0))) {
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
metadataOutputChanges.clear();
List<IConnection> initTraceList = new ArrayList<IConnection>();
for (IConnection connection : node.getOutgoingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
IODataComponent dataComponent = inAndOut.getDataComponent(connection);
boolean sameMetadataAs = connection.getMetadataTable().sameMetadataAs(dataComponent.getTable());
IMetadataTable tempTable = null;
boolean isSchemaAutoPropagated = true;
if (connection.getTarget().getComponent() instanceof EmfComponent) {
EmfComponent component = (EmfComponent) connection.getTarget().getComponent();
isSchemaAutoPropagated = component.isSchemaAutoPropagated();
}
if (sameMetadataAs || !isSchemaAutoPropagated) {
for (IMetadataTable itable : newMetaDataList) {
if (connection.getMetadataTable().getTableName().equals(itable.getTableName())) {
sameMetadataAs = connection.getMetadataTable().sameMetadataAs(itable);
tempTable = itable;
break;
}
}
} else {
IMetadataTable table = connection.getMetadataTable();
if (table == null || table.getListColumns().isEmpty()) {
initTraceList.add(connection);
}
INode connTar = connection.getTarget();
boolean isAllowedPropagated = connTar.getComponent().isAllowedPropagated();
boolean openDialog = false;
Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
if (isForTemlate()) {
openDialog = true;
} else if (!isAllowedPropagated) {
openDialog = false;
} else {
openDialog = getPropagate(connection, jobletMap);
}
if (openDialog) {
IElementParameter schemaParam = null;
if (connection != null) {
IMetadataTable connTable = connection.getMetadataTable();
IMetadataTable dataTable = dataComponent.getTable();
if (tempTable != null) {
dataTable = tempTable;
}
for (IElementParameter param : ((Node) connection.getTarget()).getElementParameters()) {
if (EParameterFieldType.SCHEMA_TYPE.equals(param.getFieldType()) || EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
INodeConnector connector = connection.getTarget().getConnectorFromName(connection.getConnectorName());
if (connector != null && param.getContext().equals(connector.getBaseSchema())) {
schemaParam = param;
break;
}
}
}
if (schemaParam != null) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(connection.getTarget(), schemaParam, connTable, dataTable);
cmd.execute(true);
metadataOutputChanges.add(cmd);
}
for (IElementParameter param : ((Node) connection.getSource()).getElementParameters()) {
if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) && param.getContext().equals(connection.getSource().getConnectorFromName(connection.getConnectorName()).getBaseSchema())) {
schemaParam = param;
break;
}
}
if (schemaParam != null) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(connection.getSource(), schemaParam, connTable, dataTable);
cmd.execute(true);
metadataOutputChanges.add(cmd);
}
if (((Node) connTar).isJoblet()) {
IElementParameter param = connTar.getElementParameter(connection.getTarget().getUniqueName());
if (param != null) {
IMetadataTable originaleOutputTable = connTar.getMetadataFromConnector(param.getContext());
if (originaleOutputTable != null) {
MetadataToolHelper.copyTable(dataTable, originaleOutputTable);
}
}
} else if (((Node) connTar).getJobletNode() != null) {
IElementParameter param = ((Node) connTar).getJobletNode().getElementParameter(connection.getTarget().getUniqueName());
if (param != null) {
IMetadataTable originaleOutputTable = ((Node) connTar).getJobletNode().getMetadataFromConnector(param.getContext());
if (originaleOutputTable != null) {
MetadataToolHelper.copyTable(dataTable, originaleOutputTable);
}
}
}
}
if (((Node) connTar).isJoblet()) {
changeCollapsedState(true, jobletMap, connTar);
}
} else {
// no matter propagate or not the metadata change will be propagate to xmlmap emf data
final Node target = (Node) connection.getTarget();
if (target != null && target.getExternalNode() != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IXmlMapService.class)) {
final IXmlMapService service = (IXmlMapService) GlobalServiceRegister.getDefault().getService(IXmlMapService.class);
if (service.isXmlMapComponent(target.getExternalNode())) {
IODataComponent output = new IODataComponent(connection, dataComponent.getTable());
target.metadataInputChanged(output, connection.getUniqueName());
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkMapService.class)) {
final ISparkMapService service = (ISparkMapService) GlobalServiceRegister.getDefault().getService(ISparkMapService.class);
if (service.isSparkMapComponent(target.getExternalNode())) {
IODataComponent output = new IODataComponent(connection, dataComponent.getTable());
target.metadataInputChanged(output, connection.getUniqueName());
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDQComponentService.class)) {
final IDQComponentService service = (IDQComponentService) GlobalServiceRegister.getDefault().getService(IDQComponentService.class);
service.externalComponentChange(connection, dataComponent.getTable());
}
}
}
}
if (connection instanceof Connection) {
((Connection) connection).updateName();
}
}
}
node.setExternalData(newExternalData);
/*
* It's better to clone, because will change that, if apply, bug 13325
*/
// node.setExternalData(newExternalData.clone()); //should test later.
List<IMetadataTable> cloneNewMetadata = new ArrayList<IMetadataTable>();
if (newMetaDataList != null) {
for (IMetadataTable t : newMetaDataList) {
cloneNewMetadata.add(t.clone(true));
}
}
node.setMetadataList(cloneNewMetadata);
// init trace
for (IConnection conn : initTraceList) {
if (conn instanceof Connection) {
((Connection) conn).initTraceParamters();
}
}
for (Connection connection : connectionsToDelete.keySet()) {
connection.disconnect();
INode prevNode = connection.getSource();
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = prevNode.getConnectorFromType(connection.getLineStyle());
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
INode nextNode = connection.getTarget();
nodeConnectorTarget = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
inAndOut.getOuputs().remove(connectionsToDelete.get(connection));
((Process) node.getProcess()).checkStartNodes();
}
((Process) node.getProcess()).checkProcess();
if (!isMetaLanguage) {
refreshCodeView();
ComponentSettings.switchToCurComponentSettingsView();
}
}
use of org.talend.designer.core.model.components.EmfComponent in project tdi-studio-se by Talend.
the class ComponentsFactory method loadComponentsFromFolder.
private void loadComponentsFromFolder(String pathSource, AbstractComponentsProvider provider) {
boolean isCustom = false;
if ("org.talend.designer.components.model.UserComponentsProvider".equals(provider.getId()) || "org.talend.designer.components.exchange.ExchangeComponentsProvider".equals(provider.getId())) {
isCustom = true;
}
File source;
try {
source = provider.getInstallationFolder();
} catch (IOException e1) {
ExceptionHandler.process(e1);
return;
}
File[] childDirectories;
FileFilter fileFilter = new FileFilter() {
@Override
public boolean accept(final File file) {
return file.isDirectory() && file.getName().charAt(0) != '.' && !file.getName().equals(IComponentsFactory.EXTERNAL_COMPONENTS_INNER_FOLDER);
}
};
if (source == null) {
//$NON-NLS-1$
ExceptionHandler.process(new Exception(Messages.getString("ComponentsFactory.componentNotFound") + pathSource));
return;
}
childDirectories = source.listFiles(fileFilter);
IBrandingService service = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
// String[] availableComponents = service.getBrandingConfiguration().getAvailableComponents();
FileFilter skeletonFilter = new FileFilter() {
@Override
public boolean accept(final File file) {
String fileName = file.getName();
return file.isFile() && fileName.charAt(0) != '.' && (fileName.endsWith(SKELETON_SUFFIX) || fileName.endsWith(INCLUDEFILEINJET_SUFFIX));
}
};
// Changed by Marvin Wang on Feb.22 for bug TDI-19166, caz the test ConnectionManagerTest maybe get the null
// context.
BundleContext context = null;
if (Platform.getProduct() != null) {
final Bundle definingBundle = Platform.getProduct().getDefiningBundle();
if (definingBundle != null) {
context = definingBundle.getBundleContext();
}
}
if (context == null) {
context = CodeGeneratorActivator.getDefault().getBundle().getBundleContext();
}
ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin admin = (PackageAdmin) context.getService(sref);
String bundleName;
if (!isCustom) {
bundleName = admin.getBundle(provider.getClass()).getSymbolicName();
} else {
bundleName = IComponentsFactory.COMPONENTS_LOCATION;
}
if (childDirectories != null) {
if (monitor != null) {
this.subMonitor = SubMonitor.convert(monitor, Messages.getString("ComponentsFactory.load.components"), //$NON-NLS-1$
childDirectories.length);
}
if (skeletonList != null) {
// to optimize the size of the array
skeletonList.ensureCapacity(childDirectories.length);
for (File currentFolder : childDirectories) {
// get the skeleton files first, then XML config files later.
File[] skeletonFiles = currentFolder.listFiles(skeletonFilter);
if (skeletonFiles != null) {
for (File file : skeletonFiles) {
// path
skeletonList.add(file.getAbsolutePath());
}
}
try {
File xmlMainFile = new File(currentFolder, ComponentFilesNaming.getInstance().getMainXMLFileName(currentFolder.getName(), getCodeLanguageSuffix()));
if (!xmlMainFile.exists()) {
// if not a component folder, ignore it.
continue;
}
String currentXmlSha1 = null;
try {
currentXmlSha1 = SHA1Util.calculateFromTextStream(new FileInputStream(xmlMainFile));
} catch (FileNotFoundException e) {
// nothing since exceptions are directly in the check bellow
}
// Need to check if this component is already in the cache or not.
// if yes, then we compare the sha1... and if different we reload the component
// if component is not in the cache, of course just load it!
ComponentsCache cache = ComponentManager.getComponentCache();
boolean foundComponentIsSame = false;
ComponentInfo existingComponentInfoInCache = null;
if (cache.getComponentEntryMap().containsKey(currentFolder.getName())) {
EList<ComponentInfo> infos = cache.getComponentEntryMap().get(currentFolder.getName());
for (ComponentInfo info : infos) {
if (StringUtils.equals(bundleName, info.getSourceBundleName())) {
existingComponentInfoInCache = info;
if (StringUtils.equals(info.getSha1(), currentXmlSha1)) {
foundComponentIsSame = true;
}
// found component, no matter changed or not
break;
}
}
}
if (foundComponentIsSame) {
// it should go here mainly for commandline or if use like ctrl+shift+f3
if (componentsCache.containsKey(xmlMainFile.getAbsolutePath())) {
IComponent componentFromThisProvider = null;
for (IComponent component : componentsCache.get(xmlMainFile.getAbsolutePath()).values()) {
if (component instanceof EmfComponent) {
if (bundleName.equals(((EmfComponent) component).getSourceBundleName())) {
componentFromThisProvider = component;
break;
}
}
}
if (componentFromThisProvider != null) {
// In headless mode, we assume the components won't change and we will use a cache
componentList.add(componentFromThisProvider);
if (isCustom) {
customComponentList.add(componentFromThisProvider);
}
continue;
}
}
}
if (!foundComponentIsSame) {
ComponentFileChecker.checkComponentFolder(currentFolder, getCodeLanguageSuffix());
}
String pathName = xmlMainFile.getAbsolutePath();
String applicationPath = ComponentBundleToPath.getPathFromBundle(bundleName);
// pathName = C:\myapp\plugins\myplugin\components\mycomponent\mycomponent.xml
pathName = (new Path(pathName)).toPortableString();
// pathName = C:/myapp/plugins/myplugin/components/mycomponent/mycomponent.xml
//$NON-NLS-1$
pathName = pathName.replace(applicationPath, "");
// pathName = /components/mycomponent/mycomponent.xml
// if not already in memory, just load the component from cache.
// if the component is already existing in cache and if it's the same, it won't reload all (cf
// flag: foundComponentIsSame)
EmfComponent currentComp = new EmfComponent(pathName, bundleName, xmlMainFile.getParentFile().getName(), pathSource, cache, foundComponentIsSame, provider);
if (!foundComponentIsSame) {
// force to call some functions to update the cache. (to improve)
currentComp.isVisibleInComponentDefinition();
currentComp.isTechnical();
currentComp.getOriginalFamilyName();
currentComp.getTranslatedFamilyName();
currentComp.getPluginExtension();
currentComp.getVersion();
currentComp.getModulesNeeded(null);
currentComp.getPluginDependencies();
// end of force cache update.
EList<ComponentInfo> componentsInfo = cache.getComponentEntryMap().get(currentFolder.getName());
for (ComponentInfo cInfo : componentsInfo) {
if (cInfo.getSourceBundleName().equals(bundleName)) {
cInfo.setSha1(currentXmlSha1);
break;
}
}
// this will force to save the cache later.
ComponentManager.setModified(true);
}
boolean hiddenComponent = false;
Collection<IComponentFactoryFilter> filters = ComponentsFactoryProviderManager.getInstance().getProviders();
for (IComponentFactoryFilter filter : filters) {
if (!filter.isAvailable(currentComp.getName())) {
hiddenComponent = true;
break;
}
}
// just don't load it
if (hiddenComponent && !(currentComp.getOriginalFamilyName().contains("Technical") || currentComp.isTechnical())) {
continue;
}
componentToProviderMap.put(currentComp, provider);
// hide it
if (hiddenComponent && (currentComp.getOriginalFamilyName().contains("Technical") || currentComp.isTechnical())) {
currentComp.setVisible(false);
currentComp.setTechnical(true);
}
if (provider.getId().contains("Camel")) {
currentComp.setPaletteType(ComponentCategory.CATEGORY_4_CAMEL.getName());
} else {
currentComp.setPaletteType(currentComp.getType());
}
if (componentList.contains(currentComp)) {
//$NON-NLS-1$ //$NON-NLS-2$
log.warn("Component " + currentComp.getName() + " already exists. Cannot load user version.");
} else {
// currentComp.setResourceBundle(getComponentResourceBundle(currentComp, source.toString(),
// null,
// provider));
currentComp.setProvider(provider);
componentList.add(currentComp);
if (isCustom) {
customComponentList.add(currentComp);
}
if (pathSource != null) {
Path userComponent = new Path(pathSource);
Path templatePath = new Path(IComponentsFactory.COMPONENTS_INNER_FOLDER + File.separatorChar + IComponentsFactory.EXTERNAL_COMPONENTS_INNER_FOLDER + File.separatorChar + ComponentUtilities.getExtFolder(OLD_COMPONENTS_USER_INNER_FOLDER));
if (userComponent.equals(templatePath)) {
userComponentList.add(currentComp);
}
}
}
// componentsCache only used bellow in case of headless (commandline) or if use like
// ctrl+shift+f3
String componentName = xmlMainFile.getAbsolutePath();
if (!componentsCache.containsKey(componentName)) {
componentsCache.put(componentName, new HashMap<String, IComponent>());
}
componentsCache.get(xmlMainFile.getAbsolutePath()).put(currentComp.getPaletteType(), currentComp);
} catch (MissingMainXMLComponentFileException e) {
//$NON-NLS-1$ //$NON-NLS-2$
log.trace(currentFolder.getName() + " is not a " + getCodeLanguageSuffix() + " component", e);
} catch (BusinessException e) {
BusinessException ex = new BusinessException(//$NON-NLS-1$ //$NON-NLS-2$
"Cannot load component \"" + currentFolder.getName() + "\": " + e.getMessage(), e);
ExceptionHandler.process(ex, Level.ERROR);
}
if (this.subMonitor != null) {
this.subMonitor.worked(1);
}
if (this.monitor != null && this.monitor.isCanceled()) {
return;
}
}
// to optimize the size of the array
skeletonList.trimToSize();
}
}
}
use of org.talend.designer.core.model.components.EmfComponent 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);
}
}
}
}
use of org.talend.designer.core.model.components.EmfComponent in project tdi-studio-se by Talend.
the class ValidationRulesUtil method filterNeededComponents.
public static List<IComponent> filterNeededComponents(Item item, ERepositoryObjectType type) {
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
String productNameWanted = filterProductNameWanted(name, item);
boolean hl7Related = false;
boolean hl7Output = false;
if (item instanceof HL7ConnectionItem) {
hl7Related = true;
EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
if (list != null && list.size() > 0) {
hl7Output = true;
}
}
Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
List<IComponent> neededComponents = new ArrayList<IComponent>();
EmfComponent emfComponent = null;
for (IComponent component : components) {
if (component instanceof EmfComponent) {
emfComponent = (EmfComponent) component;
String componentProductname = emfComponent.getRepositoryType();
boolean value = true;
if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
value = false;
}
}
if (hl7Output && !component.getName().equals("tHL7Output")) {
//$NON-NLS-1$
value = false;
} else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
// bug15632
value = false;
}
boolean flag = filterComponent(component, name, type);
if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
neededComponents.add(emfComponent);
}
}
}
return sortFilteredComponnents(item, type, neededComponents);
}
Aggregations