Search in sources :

Example 11 with IComponentsFactory

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

the class ComponentsUtils method loadComponents.

public static void loadComponents(ComponentService service) {
    if (service == null) {
        return;
    }
    IComponentsFactory componentsFactory = null;
    if (componentsFactory == null) {
        componentsFactory = ComponentsFactoryProvider.getInstance();
    }
    Set<IComponent> componentsList = componentsFactory.getComponents();
    if (components == null) {
        components = new ArrayList<IComponent>();
    } else {
        componentsList.removeAll(components);
    }
    // Load components from service
    Set<ComponentDefinition> componentDefinitions = service.getAllComponents();
    for (ComponentDefinition componentDefinition : componentDefinitions) {
        loadComponents(componentsList, componentDefinition);
    }
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 12 with IComponentsFactory

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

the class ReplaceMultiFlowBytReplicateMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@Override
public ExecutionResult execute(Item processItem) {
    ProcessType processType = getProcessType(processItem);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    IComponentsFactory componentFactory = ComponentsFactoryProvider.getInstance();
    boolean modified = false;
    try {
        List<NodeType> initialNodes = new ArrayList<NodeType>(processType.getNode());
        for (NodeType nodeType : initialNodes) {
            IComponent component = componentFactory.get(nodeType.getComponentName(), ComponentCategory.CATEGORY_4_DI.getName());
            if (component != null) {
                if (checkMaxOutputAndUpdate(processItem, processType, component, nodeType)) {
                    modified = true;
                }
            } else {
                ExceptionHandler.log(//$NON-NLS-1$
                Messages.getString(//$NON-NLS-1$
                "ReplaceMultiFlowBytReplicateMigrationTask.componentNotExist", nodeType.getComponentName(), processItem.getProperty().getLabel()));
            }
        }
        if (modified) {
            return ExecutionResult.SUCCESS_WITH_ALERT;
        } else {
            return ExecutionResult.NOTHING_TO_DO;
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 13 with IComponentsFactory

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

the class TalendEditorPaletteFactoryTest method testAddComponentsByNameFilter.

@Test
public void testAddComponentsByNameFilter() {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    String keyword = "mysql";
    Set<IComponent> componentHits = new LinkedHashSet<IComponent>();
    TalendEditorPaletteFactory.addComponentsByNameFilter(componentsFactory, componentHits, keyword);
    /**
         * NOTE: the expect result may change if we add/change some new components in someday
         */
    assert (componentHits.iterator().next().getName().equals(TMYSQLSP));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Test(org.junit.Test)

Example 14 with IComponentsFactory

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

the class TalendEditorPaletteFactoryTest method testGetRelatedComponents_ComponentName.

@Test
public void testGetRelatedComponents_ComponentName() {
    storeRecentlyUsed();
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    String keyword = "tJava";
    List<IComponent> componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
    Assert.assertFalse("Can't find any components", componentHits.isEmpty());
    assertExistedComponent(TJAVA, keyword, componentHits);
    assertExistedComponent(TJAVAROW, keyword, componentHits);
    keyword = "tjava";
    componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
    Assert.assertFalse("Can't find any components", componentHits.isEmpty());
    assertExistedComponent(TJAVA, keyword, componentHits);
    assertExistedComponent(TJAVAROW, keyword, componentHits);
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Test(org.junit.Test)

Example 15 with IComponentsFactory

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

the class AddFamilyFieldProjectMigrationTask method resetFamily.

/**
     * yzhang Comment method "resetFamily".
     * 
     * @param list
     */
private void resetFamily(EList list) {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    Set<IComponent> components = componentsFactory.getComponents();
    list.clear();
    for (IComponent component : components) {
        String[] families = component.getOriginalFamilyName().split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
        for (String family : families) {
            ComponentSetting setting = PropertiesFactory.eINSTANCE.createComponentSetting();
            setting.setFamily(family);
            setting.setName(component.getName());
            setting.setHidden(!component.isVisibleInComponentDefinition());
            list.add(setting);
        }
    }
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
    try {
        prf.saveProject(repositoryContext.getProject());
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) ComponentSetting(org.talend.core.model.properties.ComponentSetting) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

IComponentsFactory (org.talend.core.model.components.IComponentsFactory)16 IComponent (org.talend.core.model.components.IComponent)12 Test (org.junit.Test)5 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 RepositoryContext (org.talend.core.context.RepositoryContext)2 FileFilter (java.io.FileFilter)1 LinkedHashSet (java.util.LinkedHashSet)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)1 ECodeLanguage (org.talend.core.language.ECodeLanguage)1