Search in sources :

Example 11 with NamedThing

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

the class SalesforceRuntimeCommonTest method testGetSchemaNames.

@Test
public void testGetSchemaNames() throws Exception {
    DescribeGlobalResult result = new DescribeGlobalResult();
    DescribeGlobalSObjectResult sObjectResult1 = new DescribeGlobalSObjectResult();
    sObjectResult1.setName("Account");
    sObjectResult1.setLabel("Account");
    DescribeGlobalSObjectResult sObjectResult2 = new DescribeGlobalSObjectResult();
    sObjectResult2.setName("Contact");
    sObjectResult2.setLabel("Contact");
    DescribeGlobalSObjectResult sObjectResult3 = new DescribeGlobalSObjectResult();
    sObjectResult3.setName("Campaign");
    sObjectResult3.setLabel("Campaign");
    result.setSobjects(new IDescribeGlobalSObjectResult[] { sObjectResult1, sObjectResult2, sObjectResult3 });
    PartnerConnection conn = mock(PartnerConnection.class);
    doReturn(result).when(conn).describeGlobal();
    List<NamedThing> schemaNames = SalesforceRuntimeCommon.getSchemaNames(conn);
    assertThat(schemaNames, containsInAnyOrder((NamedThing) new SimpleNamedThing("Account", "Account"), new SimpleNamedThing("Contact", "Contact"), new SimpleNamedThing("Campaign", "Campaign")));
}
Also used : DescribeGlobalResult(com.sforce.soap.partner.DescribeGlobalResult) IDescribeGlobalSObjectResult(com.sforce.soap.partner.IDescribeGlobalSObjectResult) DescribeGlobalSObjectResult(com.sforce.soap.partner.DescribeGlobalSObjectResult) PartnerConnection(com.sforce.soap.partner.PartnerConnection) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) Test(org.junit.Test)

Example 12 with NamedThing

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

the class SalesforceModuleProperties method beforeModuleName.

// consider beforeActivate and beforeRender (change after to afterActivate)
public ValidationResult beforeModuleName() throws Exception {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
        ss.initialize(null, getEffectiveConnection());
        ValidationResult vr = ss.validate(null);
        if (vr.getStatus() == ValidationResult.Result.OK) {
            try {
                List<NamedThing> moduleNames = ss.getSchemaNames(null);
                moduleName.setPossibleNamedThingValues(moduleNames);
            } catch (Exception ex) {
                return ExceptionUtil.exceptionToValidationResult(ex);
            }
        } else {
            return vr;
        }
        return ValidationResult.OK;
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) SalesforceDefinition.getSandboxedInstance(org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink) ValidationResult(org.talend.daikon.properties.ValidationResult) NamedThing(org.talend.daikon.NamedThing) ComponentException(org.talend.components.api.exception.ComponentException)

Example 13 with NamedThing

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

the class SalesforceModuleListProperties method afterFormFinishMain.

public ValidationResult afterFormFinishMain(Repository<Properties> repo) throws Exception {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
        ss.initialize(null, this);
        ValidationResult vr = ss.validate(null);
        if (vr.getStatus() != ValidationResult.Result.OK) {
            return vr;
        }
        String connRepLocation = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
        for (NamedThing nl : selectedModuleNames.getValue()) {
            String moduleId = nl.getName();
            SalesforceModuleProperties modProps = new SalesforceModuleProperties(moduleId);
            modProps.connection = connection;
            modProps.init();
            Schema schema = ss.getEndpointSchema(null, moduleId);
            modProps.moduleName.setValue(moduleId);
            modProps.main.schema.setValue(schema);
            repo.storeProperties(modProps, nl.getName(), connRepLocation, "main.schema");
        }
        return ValidationResult.OK;
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) SalesforceDefinition.getSandboxedInstance(org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance) Schema(org.apache.avro.Schema) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink) ValidationResult(org.talend.daikon.properties.ValidationResult) NamedThing(org.talend.daikon.NamedThing)

Example 14 with NamedThing

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

the class SalesforceDatasetProperties method retrieveModuleFields.

private void retrieveModuleFields() throws IOException {
    // refresh the module list
    if (sourceType.getValue() == SourceType.MODULE_SELECTION && StringUtils.isNotEmpty(moduleName.getValue())) {
        Consumer consumer = new Consumer() {

            @Override
            public void accept(SalesforceRuntimeSourceOrSink runtime) throws IOException {
                List<NamedThing> moduleNames = runtime.getSchemaNames(null);
                moduleName.setPossibleNamedThingValues(filter(moduleNames));
                Schema schema = runtime.getEndpointSchema(null, moduleName.getValue());
                List<NamedThing> columns = new ArrayList<>();
                for (Schema.Field field : schema.getFields()) {
                    columns.add(new SimpleNamedThing(field.name(), field.name()));
                }
                selectColumnIds.setPossibleValues(columns);
            }
        };
        runtimeTask(consumer);
    }
}
Also used : Schema(org.apache.avro.Schema) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing)

Example 15 with NamedThing

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

the class AzureStorageComponentListPropertiesTest method afterFormFinishTable.

/**
 * @see org.talend.components.azurestorage.wizard.AzureStorageComponentListProperties#afterFormFinishTable(Repository<Properties>)
 */
@Test
public void afterFormFinishTable() throws Exception {
    List<NamedThing> nameWithNumeric = new ArrayList<NamedThing>();
    nameWithNumeric.add(new SimpleNamedThing("2Name_with_numeric2", "2Name_with_numeric2"));
    properties.selectedContainerNames.setStoredValue(nameWithNumeric);
    properties.selectedQueueNames.setStoredValue(nameWithNumeric);
    ValidationResult result = properties.afterFormFinishTable(repo);
    assertEquals(Result.OK, result.getStatus());
}
Also used : SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ValidationResult(org.talend.daikon.properties.ValidationResult) 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