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")));
}
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;
}
}
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;
}
}
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);
}
}
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());
}
Aggregations