use of org.talend.components.api.component.ComponentDefinition 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.components.api.component.ComponentDefinition in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method isValid.
private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
// TUP-4151
IRepositoryViewObject object = seletetedNode.getObject();
if (component == null || object == null) {
return false;
}
ComponentProperties currentComponentProperties = null;
if (object instanceof RepositoryViewObject) {
RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
if (canHandle(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
}
} else if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
} else if (object instanceof MetadataColumnRepositoryObject) {
MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
ModelElement element = metaColumnRepObj.getTdColumn();
if (element != null && element.eContainer() instanceof MetadataTable) {
MetadataTable metadataTable = (MetadataTable) element.eContainer();
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
}
}
if (currentComponentProperties != null) {
try {
List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
if (component instanceof Component) {
ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
return possibleComponents.contains(componentDefinition);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
return false;
}
use of org.talend.components.api.component.ComponentDefinition in project tdi-studio-se by Talend.
the class ComponentTest method setUp.
@Before
public void setUp() throws Exception {
ComponentDefinition componentDefinition = new TestComponentDefinition();
component = new Component(componentDefinition);
}
use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class DefinitionsControllerTest method shouldFilterComponentsByTag.
public void shouldFilterComponentsByTag(String tag, int expectedResults) throws JsonParseException, JsonMappingException, IOException {
Map<String, ComponentDefinition> definitions = getComponentsDefinitions();
//
BDDMockito.given(delegate.getDefinitionsMapByType(ComponentDefinition.class)).willReturn(definitions);
// when
final Response response = when().get(getVersionPrefix() + "/definitions/" + COMPONENT + "?tag=" + tag).andReturn();
// then
assertEquals(OK.value(), response.getStatusCode());
List<DefinitionDTO> actual = objectMapper.readValue(response.asInputStream(), new TypeReference<List<DefinitionDTO>>() {
});
assertEquals(expectedResults, actual.size());
}
use of org.talend.components.api.component.ComponentDefinition in project components by Talend.
the class DefinitionsControllerTest method shouldFilterComponentsByExecutionEngine.
public void shouldFilterComponentsByExecutionEngine(ExecutionEngine executionEngine, int expectedResults) throws IOException {
// given
Map<String, ComponentDefinition> definitions = getComponentsDefinitions();
//
BDDMockito.given(delegate.getDefinitionsMapByType(ComponentDefinition.class)).willReturn(definitions);
// when
final Response response = when().get(getVersionPrefix() + "/definitions/components?executionEngine=" + executionEngine.name()).andReturn();
// then
assertEquals(OK.value(), response.getStatusCode());
List<DefinitionDTO> actual = objectMapper.readValue(response.asInputStream(), new TypeReference<List<DefinitionDTO>>() {
});
assertEquals(expectedResults, actual.size());
assertEquals(expectedResults, actual.stream().filter(dto -> dto.getExecutionEngines().contains(executionEngine.name())).count());
}
Aggregations