Search in sources :

Example 21 with NamedThing

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

the class SnowflakeTableListProperties method afterFormFinishMain.

public ValidationResult afterFormFinishMain(Repository<Properties> repo) throws Exception {
    ValidationResult vr = SnowflakeSourceOrSink.validateConnection(this);
    if (vr.getStatus() != ValidationResult.Result.OK) {
        return vr;
    }
    String connRepLocation = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
    for (NamedThing nl : selectedTableNames.getValue()) {
        String tableId = nl.getName();
        SnowflakeTableProperties tableProps = new SnowflakeTableProperties(tableId);
        tableProps.connection = connection;
        tableProps.init();
        Schema schema = SnowflakeSourceOrSink.getSchema(null, this, tableId);
        tableProps.tableName.setValue(tableId);
        tableProps.main.schema.setValue(schema);
        repo.storeProperties(tableProps, nl.getName(), connRepLocation, "main.schema");
    }
    return ValidationResult.OK;
}
Also used : Schema(org.apache.avro.Schema) ValidationResult(org.talend.daikon.properties.ValidationResult) NamedThing(org.talend.daikon.NamedThing)

Example 22 with NamedThing

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

the class NetSuiteClientServiceIT method testGetSearchableTypes.

@Test
public void testGetSearchableTypes() throws Exception {
    NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
    connection.login();
    Collection<NamedThing> searches = connection.getMetaDataSource().getSearchableTypes();
    for (NamedThing search : searches) {
        assertNotNull(search);
        assertNotNull(search.getName());
        assertNotNull(search.getDisplayName());
        SearchRecordTypeDesc searchRecordInfo = connection.getMetaDataSource().getSearchRecordType(search.getName());
        assertNotNull("Search record def found: " + search.getName(), searchRecordInfo);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) NamedThing(org.talend.daikon.NamedThing) Test(org.junit.Test)

Example 23 with NamedThing

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

the class PubSubDatasetProperties method beforeSubscription.

public ValidationResult beforeSubscription() {
    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.listSubscriptions()) {
            topics.add(new SimpleNamedThing(topicName, topicName));
        }
        subscription.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 24 with NamedThing

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

the class MarketoSourceOrSink method getSchemaNames.

@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
    List<NamedThing> customObjects = new ArrayList<>();
    MarketoClientServiceExtended client = (MarketoClientServiceExtended) getClientService(null);
    TMarketoInputProperties ip = new TMarketoInputProperties("COSchemas");
    ip.init();
    ip.connection = properties.getConnectionProperties();
    ip.inputOperation.setValue(InputOperation.CustomObject);
    ip.customObjectAction.setValue(CustomObjectAction.list);
    ip.customObjectNames.setValue("");
    ip.schemaInput.schema.setValue(MarketoConstants.getCustomObjectDescribeSchema());
    MarketoRecordResult r = client.listCustomObjects(ip);
    for (IndexedRecord co : r.getRecords()) {
        // name cannot be null
        String name = co.get(0).toString();
        Object displayName = co.get(1);
        if (displayName == null) {
            displayName = name;
        }
        customObjects.add(new SimpleNamedThing(name, displayName.toString()));
    }
    // 
    return customObjects;
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) MarketoClientServiceExtended(org.talend.components.marketo.runtime.client.MarketoClientServiceExtended) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult)

Example 25 with NamedThing

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

the class MarketoCustomObjectsSchemasPropertiesTest method testAfterFormFinishCustomObjects.

@Test
public void testAfterFormFinishCustomObjects() throws Exception {
    try (SandboxedInstanceTestFixture sandboxedInstanceTestFixture = new SandboxedInstanceTestFixture()) {
        sandboxedInstanceTestFixture.setUp();
        properties.beforeFormPresentCustomObjects();
        List<NamedThing> o = new ArrayList<>();
        o.add(new SimpleNamedThing("car_c", "car_c"));
        properties.selectedCustomObjectsNames.setValue(o);
        assertEquals(Result.OK, properties.afterFormFinishCustomObjects(repo).getStatus());
        // 
        o.add(new SimpleNamedThing("car_except", "car_except"));
        properties.selectedCustomObjectsNames.setValue(o);
        assertEquals(Result.ERROR, properties.afterFormFinishCustomObjects(repo).getStatus());
    }
}
Also used : SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) Test(org.junit.Test)

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