use of org.talend.designer.core.ui.editor.process.EDatabaseComponentName in project tdi-studio-se by Talend.
the class ValidationRulesUtil method getComponentsFromItemId.
/**
* DOC ycbai Comment method "getComponentsFromItemId". modify from method getAppropriateComponent() of
* TalendEditorDropTargetListener.
*
* @param itemId
* @param type
* @param quickCreateInput
* @param quickCreateOutput
* @return
*/
public static IComponent getComponentsFromItemId(String itemId, ERepositoryObjectType type, boolean quickCreateInput, boolean quickCreateOutput) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IRepositoryViewObject obj = null;
try {
obj = factory.getLastVersion(itemId);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (obj == null) {
return null;
}
Item item = obj.getProperty().getItem();
if (item == null) {
return null;
}
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
String componentName = null;
if (item instanceof JobletProcessItem) {
// joblet
componentName = item.getProperty().getLabel();
} else if (name == null) {
return null;
} else {
// tRunjob
componentName = name.getDefaultComponentName();
}
// tRunJob is special from our rules
if (name == EDatabaseComponentName.RunJob || item instanceof JobletProcessItem) {
return ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName());
} else {
// for database, file, webservices, saleforce ...
List<IComponent> neededComponents = filterNeededComponents(item, type);
IComponent component = chooseOneComponent(neededComponents, name, quickCreateInput, quickCreateOutput);
return component;
}
}
use of org.talend.designer.core.ui.editor.process.EDatabaseComponentName 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