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);
}
}
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;
}
}
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));
}
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);
}
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);
}
}
Aggregations