Search in sources :

Example 26 with ComponentDefinition

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);
    }
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 27 with 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;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) IComponent(org.talend.core.model.components.IComponent) Component(org.talend.designer.core.generic.model.Component) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 28 with ComponentDefinition

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);
}
Also used : IComponent(org.talend.core.model.components.IComponent) TestComponentDefinition(org.talend.designer.core.generic.utils.TestComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) TestComponentDefinition(org.talend.designer.core.generic.utils.TestComponentDefinition) Before(org.junit.Before)

Example 29 with 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());
}
Also used : Response(com.jayway.restassured.response.Response) DefinitionDTO(org.talend.components.service.rest.dto.DefinitionDTO) Arrays.asList(java.util.Arrays.asList) List(java.util.List) MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 30 with ComponentDefinition

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());
}
Also used : Response(com.jayway.restassured.response.Response) DefinitionDTO(org.talend.components.service.rest.dto.DefinitionDTO) Arrays.asList(java.util.Arrays.asList) List(java.util.List) MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Aggregations

ComponentDefinition (org.talend.components.api.component.ComponentDefinition)47 Test (org.junit.Test)28 IndexedRecord (org.apache.avro.generic.IndexedRecord)16 TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)14 TSalesforceOutputDefinition (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition)12 ArrayList (java.util.ArrayList)11 Result (org.talend.components.api.component.runtime.Result)11 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)10 List (java.util.List)9 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)8 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 Schema (org.apache.avro.Schema)6 DefinitionDTO (org.talend.components.service.rest.dto.DefinitionDTO)6 MockComponentDefinition (org.talend.components.service.rest.mock.MockComponentDefinition)6 Response (com.jayway.restassured.response.Response)5 Arrays.asList (java.util.Arrays.asList)5 GenericData (org.apache.avro.generic.GenericData)3 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)3 IComponent (org.talend.core.model.components.IComponent)3 File (java.io.File)2