Search in sources :

Example 1 with EDatabaseComponentName

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;
    }
}
Also used : HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) WSDLSchemaConnectionItem(org.talend.core.model.properties.WSDLSchemaConnectionItem) Item(org.talend.core.model.properties.Item) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) EDatabaseComponentName(org.talend.designer.core.ui.editor.process.EDatabaseComponentName) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IComponent(org.talend.core.model.components.IComponent) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 2 with EDatabaseComponentName

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);
}
Also used : EDatabaseComponentName(org.talend.designer.core.ui.editor.process.EDatabaseComponentName) EList(org.eclipse.emf.common.util.EList) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) EmfComponent(org.talend.designer.core.model.components.EmfComponent) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection)

Aggregations

IComponent (org.talend.core.model.components.IComponent)2 HL7ConnectionItem (org.talend.core.model.properties.HL7ConnectionItem)2 EDatabaseComponentName (org.talend.designer.core.ui.editor.process.EDatabaseComponentName)2 ArrayList (java.util.ArrayList)1 EList (org.eclipse.emf.common.util.EList)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 HL7Connection (org.talend.core.model.metadata.builder.connection.HL7Connection)1 Item (org.talend.core.model.properties.Item)1 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)1 ValidationRulesConnectionItem (org.talend.core.model.properties.ValidationRulesConnectionItem)1 WSDLSchemaConnectionItem (org.talend.core.model.properties.WSDLSchemaConnectionItem)1 XmlFileConnectionItem (org.talend.core.model.properties.XmlFileConnectionItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 EmfComponent (org.talend.designer.core.model.components.EmfComponent)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1