use of org.talend.components.api.properties.ComponentProperties in project components by Talend.
the class SalesforceComponentTestIT method testAfterLoginType.
@Test
public void testAfterLoginType() throws Throwable {
ComponentProperties props;
props = new TSalesforceConnectionDefinition().createProperties();
ComponentTestUtils.checkSerialize(props, errorCollector);
Property<LoginType> loginType = (Property<LoginType>) props.getProperty("loginType");
LOGGER.debug(loginType.getPossibleValues().toString());
assertEquals(SalesforceConnectionProperties.LoginType.Basic, loginType.getPossibleValues().get(0));
assertEquals(SalesforceConnectionProperties.LoginType.OAuth, loginType.getPossibleValues().get(1));
assertEquals(SalesforceConnectionProperties.LoginType.Basic, loginType.getValue());
Form mainForm = props.getForm(Form.MAIN);
assertEquals("Salesforce Connection Settings", mainForm.getTitle());
assertFalse(mainForm.getWidget(SalesforceUserPasswordProperties.class).isHidden());
loginType.setValue(SalesforceConnectionProperties.LoginType.OAuth);
props = checkAndAfter(mainForm, "loginType", props);
mainForm = props.getForm(Form.MAIN);
assertTrue(mainForm.isRefreshUI());
assertTrue(mainForm.getWidget(SalesforceUserPasswordProperties.class).isHidden());
}
use of org.talend.components.api.properties.ComponentProperties in project components by Talend.
the class SalesforceDataprepSource method initialize.
@Override
public ValidationResult initialize(RuntimeContainer container, ComponentProperties properties) {
this.properties = (SalesforceInputProperties) properties;
dataset = this.properties.getDatasetProperties();
datastore = dataset.getDatastoreProperties();
String config_file = System.getProperty(CONFIG_FILE_lOCATION_KEY);
try (InputStream is = config_file != null ? (new FileInputStream(config_file)) : null) {
if (is == null) {
LOG.warn("not found the property file, will use the default value for endpoint and timeout");
return ValidationResult.OK;
}
Properties props = new Properties();
props.load(is);
String endpoint = props.getProperty("endpoint");
if (endpoint != null && !endpoint.isEmpty()) {
this.endpoint = endpoint;
}
String timeout = props.getProperty("timeout");
if (timeout != null && !timeout.isEmpty()) {
this.timeout = Integer.parseInt(timeout);
}
} catch (IOException e) {
LOG.warn("not found the property file, will use the default value for endpoint and timeout", e);
}
return ValidationResult.OK;
}
use of org.talend.components.api.properties.ComponentProperties in project components by Talend.
the class RuntimeControllerImpl method writeData.
@Override
public void writeData(InputStream rawPayload) throws IOException {
// 1) Read payload (with data as a stream of course)
DatasetWritePayload payload = DatasetWritePayload.readData(rawPayload, mapper);
String definitionName = payload.getConfiguration().getDefinitionName();
// 2) Create properties
Properties properties = propertiesHelpers.propertiesFromDto(payload.getConfiguration());
if (properties instanceof ComponentProperties) {
ComponentProperties componentProperties = (ComponentProperties) properties;
// 3) Retrieve component definition to be able to create the runtime
final ComponentDefinition definition = propertiesHelpers.getDefinition(ComponentDefinition.class, definitionName);
// 4) Get the execution engine
ExecutionEngine executionEngine;
if (definition.isSupportingExecutionEngines(DI)) {
executionEngine = DI;
// 5) Create the sandbox
try (SandboxedInstance instance = RuntimeUtil.createRuntimeClass(definition.getRuntimeInfo(executionEngine, componentProperties, INCOMING), definition.getClass().getClassLoader())) {
Sink datasetRuntimeInstance = (Sink) instance.getInstance();
datasetRuntimeInstance.initialize(null, componentProperties);
Iterator<IndexedRecord> data = payload.getData();
WriteOperation writeOperation = datasetRuntimeInstance.createWriteOperation();
// Supplier return null to signify end of data stream => see WriterDataSupplier.writeData
WriterDataSupplier<?, IndexedRecord> stringWriterDataSupplier = new WriterDataSupplier<Object, IndexedRecord>(writeOperation, () -> data.hasNext() ? data.next() : null, null);
stringWriterDataSupplier.writeData();
}
} else if (definition.isSupportingExecutionEngines(BEAM)) {
throw new UnsupportedOperationException("Beam runtime is not available for dataset write through HTTP API.");
} else {
throw new TalendRuntimeException(CommonErrorCodes.UNREGISTERED_DEFINITION);
}
} else if (properties instanceof DatasetProperties) {
throw new UnsupportedOperationException("HTTP API is only able to write using component implementations. Not " + properties.getClass());
}
}
use of org.talend.components.api.properties.ComponentProperties in project components by Talend.
the class JDBCOutputWriter method open.
@Override
public void open(String uId) throws IOException {
componentSchema = CommonUtils.getMainSchemaFromInputConnector((ComponentProperties) properties);
rejectSchema = CommonUtils.getRejectSchema((ComponentProperties) properties);
columnList = JDBCSQLBuilder.getInstance().createColumnList(setting, componentSchema);
if (!setting.getClearDataInTable()) {
return;
}
String sql = JDBCSQLBuilder.getInstance().generateSQL4DeleteTable(setting.getTablename());
try {
conn = sink.getConnection(runtime);
try (Statement statement = conn.createStatement()) {
deleteCount += statement.executeUpdate(sql);
}
} catch (ClassNotFoundException | SQLException e) {
throw CommonUtils.newComponentException(e);
}
}
use of org.talend.components.api.properties.ComponentProperties in project components by Talend.
the class SnowflakeTestIT method generateJavaNestedCompPropClassNames.
@Test
public void generateJavaNestedCompPropClassNames() {
Set<ComponentDefinition> allComponents = getComponentService().getAllComponents();
for (ComponentDefinition cd : allComponents) {
ComponentProperties props = cd.createProperties();
String javaCode = PropertiesTestUtils.generatedNestedComponentCompatibilitiesJavaCode(props);
LOGGER.debug("Nested Props for (" + cd.getClass().getSimpleName() + ".java:1)" + javaCode);
}
}
Aggregations