Search in sources :

Example 1 with IComponentsService

use of org.talend.core.model.components.IComponentsService in project tdi-studio-se by Talend.

the class ComponentChooseDialog method getAppropriateComponent.

private void getAppropriateComponent(Item item, boolean quickCreateInput, boolean quickCreateOutput, TempStore store, ERepositoryObjectType type) {
    IComponentName rcSetting = RepositoryComponentManager.getSetting(item, type);
    // For handler, need check for esb
    if (rcSetting == null) {
        for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
            rcSetting = handler.getCorrespondingComponentName(item, type);
            if (rcSetting != null) {
                break;
            }
        }
        if (rcSetting == null) {
            return;
        }
    }
    boolean isCurrentProject = true;
    String projectName = null;
    if (store.seletetedNode.getObject() != null) {
        projectName = store.seletetedNode.getObject().getProjectLabel();
        isCurrentProject = projectName.equals(ProjectManager.getInstance().getCurrentProject().getLabel());
    }
    List<IComponent> neededComponents = RepositoryComponentManager.filterNeededComponents(item, store.seletetedNode, type, isCurrentProject, projectName);
    for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
        List<IComponent> comList = handler.filterNeededComponents(item, store.seletetedNode, type);
        if (comList != null) {
            for (IComponent handlerComp : comList) {
                if (!neededComponents.contains(handlerComp) && !handlerComp.isTechnical()) {
                    neededComponents.add(handlerComp);
                }
            }
        }
    }
    // special handle hbase to support tpigLoad
    String hbaseName = EDatabaseTypeName.HBASE.getDisplayName().toUpperCase();
    if (rcSetting != null && (hbaseName).equals(rcSetting.toString())) {
        IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
        String componentProductname = null;
        Set<IComponent> components = service.getComponentsFactory().getComponents();
        for (IComponent component : components) {
            componentProductname = component.getRepositoryType();
            if (componentProductname != null && componentProductname.contains(hbaseName) && !neededComponents.contains(component) && !component.isTechnical()) {
                neededComponents.add(component);
            }
        }
    }
    neededComponents = (List<IComponent>) ComponentUtilities.filterVisibleComponents(neededComponents);
    // Check if the components in the list neededComponents have the same category that is required by Process.
    IComponent component = chooseOneComponent(extractComponents(neededComponents), rcSetting, quickCreateInput, quickCreateOutput);
    store.component = component;
    store.componentName = rcSetting;
}
Also used : IComponentsService(org.talend.core.model.components.IComponentsService) IDragAndDropServiceHandler(org.talend.core.model.utils.IDragAndDropServiceHandler) IComponent(org.talend.core.model.components.IComponent) IComponentName(org.talend.core.model.utils.IComponentName)

Example 2 with IComponentsService

use of org.talend.core.model.components.IComponentsService in project tdi-studio-se by Talend.

the class GenericDragAndDropHandler method filterNeededComponents.

@Override
public List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    // TUP-4151
    List<IComponent> neededComponents = new ArrayList<>();
    if (!(item instanceof GenericConnectionItem)) {
        return neededComponents;
    }
    IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
    Set<IComponent> components = service.getComponentsFactory().getComponents();
    for (IComponent component : components) {
        if (EComponentType.GENERIC.equals(component.getComponentType())) {
            if (!neededComponents.contains(component) && isValid(seletetedNode, component)) {
                neededComponents.add(component);
            }
        }
    }
    return neededComponents;
}
Also used : IComponentsService(org.talend.core.model.components.IComponentsService) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem)

Example 3 with IComponentsService

use of org.talend.core.model.components.IComponentsService in project tdi-studio-se by Talend.

the class JSONDragAndDropHandler method filterNeededComponents.

@Override
public List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    if (!(item instanceof JSONFileConnectionItem)) {
        return neededComponents;
    }
    IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
    Set<IComponent> components = service.getComponentsFactory().getComponents();
    JSONFileConnection connection = (JSONFileConnection) ((JSONFileConnectionItem) item).getConnection();
    for (IComponent component : components) {
        if (!connection.isInputModel()) {
            if (isValid(item, type, seletetedNode, component, "JSONOUTPUT") && !neededComponents.contains(component)) {
                neededComponents.add(component);
            }
        } else {
            if (isValid(item, type, seletetedNode, component, JSON) && !neededComponents.contains(component)) {
                neededComponents.add(component);
            }
        }
    }
    // type);
    return neededComponents;
}
Also used : IComponentsService(org.talend.core.model.components.IComponentsService) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem)

Aggregations

IComponent (org.talend.core.model.components.IComponent)3 IComponentsService (org.talend.core.model.components.IComponentsService)3 ArrayList (java.util.ArrayList)2 IComponentName (org.talend.core.model.utils.IComponentName)1 IDragAndDropServiceHandler (org.talend.core.model.utils.IDragAndDropServiceHandler)1 GenericConnectionItem (org.talend.repository.generic.model.genericMetadata.GenericConnectionItem)1 JSONFileConnection (org.talend.repository.model.json.JSONFileConnection)1 JSONFileConnectionItem (org.talend.repository.model.json.JSONFileConnectionItem)1