Search in sources :

Example 66 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class PubSubDatasetProperties method beforeTopic.

public ValidationResult beforeTopic() {
    PubSubDatasetDefinition definition = new PubSubDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IPubSubDatasetRuntime runtime = (IPubSubDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        List<NamedThing> topics = new ArrayList<>();
        for (String topicName : runtime.listTopics()) {
            topics.add(new SimpleNamedThing(topicName, topicName));
        }
        topic.setPossibleValues(topics);
        return ValidationResult.OK;
    } catch (Exception e) {
        return new ValidationResult(new ComponentException(e));
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) IPubSubDatasetRuntime(org.talend.components.pubsub.runtime.IPubSubDatasetRuntime) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ValidationResult(org.talend.daikon.properties.ValidationResult) ComponentException(org.talend.components.api.exception.ComponentException)

Example 67 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class SalesforceDatasetPropertiesTest method testSetDataStorePropertiesWithModuleNameSpecified.

@Test
public void testSetDataStorePropertiesWithModuleNameSpecified() throws Exception {
    datastoreProperties.init();
    properties.init();
    try (MockRuntimeSourceOrSinkTestFixture testFixture = new MockRuntimeSourceOrSinkTestFixture(isA(SalesforceInputProperties.class), createDefaultTestDataset())) {
        testFixture.setUp();
        properties.moduleName.setValue("Account");
        properties.setDatastoreProperties(datastoreProperties);
        assertThat((Iterable<String>) properties.moduleName.getPossibleValues(), containsInAnyOrder("Account", "Customer"));
        assertThat((Iterable<NamedThing>) properties.selectColumnIds.getPossibleValues(), contains((NamedThing) new SimpleNamedThing("Id", "Id"), new SimpleNamedThing("Name", "Name")));
    }
}
Also used : SimpleNamedThing(org.talend.daikon.SimpleNamedThing) SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) Test(org.junit.Test)

Example 68 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class OsgiSalesforceEsbTestIT method testStaticGetSchemaNames.

@Test
public void testStaticGetSchemaNames() throws IOException {
    SalesforceConnectionProperties scp = setupProps(null, !ADD_QUOTES);
    List<NamedThing> schemaNames = SalesforceSourceOrSink.getSchemaNames(null, scp);
    assertTrue(schemaNames.size() > 50);
}
Also used : SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) NamedThing(org.talend.daikon.NamedThing) Test(org.junit.Test)

Example 69 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class SalesforceModuleListPropertiesTest method testBeforeFormPresentMain.

@Test
public void testBeforeFormPresentMain() throws Throwable {
    properties.init();
    try (MockRuntimeSourceOrSinkTestFixture testFixture = new MockRuntimeSourceOrSinkTestFixture(equalTo(properties), createDefaultTestDataset())) {
        testFixture.setUp();
        propertiesService.beforeFormPresent("Main", properties);
        assertThat((Iterable<NamedThing>) properties.selectedModuleNames.getPossibleValues(), containsInAnyOrder((NamedThing) new SimpleNamedThing("Account"), new SimpleNamedThing("Customer")));
        Form mainForm = properties.getForm(Form.MAIN);
        assertTrue(mainForm.isAllowBack());
        assertTrue(mainForm.isAllowFinish());
    }
}
Also used : Form(org.talend.daikon.properties.presentation.Form) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) Test(org.junit.Test)

Example 70 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class SalesforceSourceOrSink method getSchemaNames.

protected List<NamedThing> getSchemaNames(PartnerConnection connection) throws IOException {
    List<NamedThing> returnList = new ArrayList<>();
    DescribeGlobalResult result = null;
    try {
        result = connection.describeGlobal();
    } catch (ConnectionException e) {
        throw new ComponentException(e);
    }
    DescribeGlobalSObjectResult[] objects = result.getSobjects();
    for (DescribeGlobalSObjectResult obj : objects) {
        LOG.debug("module label: " + obj.getLabel() + " name: " + obj.getName());
        returnList.add(new SimpleNamedThing(obj.getName(), obj.getLabel()));
    }
    return returnList;
}
Also used : DescribeGlobalResult(com.sforce.soap.partner.DescribeGlobalResult) DescribeGlobalSObjectResult(com.sforce.soap.partner.DescribeGlobalSObjectResult) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ConnectionException(com.sforce.ws.ConnectionException)

Aggregations

NamedThing (org.talend.daikon.NamedThing)71 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)34 ArrayList (java.util.ArrayList)33 Test (org.junit.Test)21 Property (org.talend.daikon.properties.property.Property)17 ComponentProperties (org.talend.components.api.properties.ComponentProperties)15 ComponentException (org.talend.components.api.exception.ComponentException)14 Schema (org.apache.avro.Schema)11 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)9 ValidationResult (org.talend.daikon.properties.ValidationResult)8 Form (org.talend.daikon.properties.presentation.Form)8 List (java.util.List)7 IOException (java.io.IOException)6 PresentationItem (org.talend.daikon.properties.PresentationItem)6 Properties (org.talend.daikon.properties.Properties)6 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)5 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)5 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)4 ComponentWizardDefinition (org.talend.components.api.wizard.ComponentWizardDefinition)4 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)4