use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class SalesforceConnectionProperties method refreshLayout.
@Override
public void refreshLayout(Form form) {
super.refreshLayout(form);
String refComponentIdValue = getReferencedComponentId();
boolean useOtherConnection = refComponentIdValue != null && refComponentIdValue.startsWith(TSalesforceConnectionDefinition.COMPONENT_NAME);
if (form.getName().equals(Form.MAIN) || form.getName().equals(FORM_WIZARD)) {
if (useOtherConnection) {
form.getWidget(loginType.getName()).setHidden(true);
hideOauth2Properties(form, true);
form.getWidget(userPassword).setHidden(true);
} else {
form.getWidget(loginType.getName()).setHidden(false);
switch(loginType.getValue()) {
case Basic:
hideOauth2Properties(form, true);
form.getWidget(userPassword).setHidden(false);
break;
case OAuth:
refreshOauth2Properties(form);
form.getWidget(userPassword).setHidden(true);
break;
default:
throw new ComponentException(new Throwable("Enum value should be handled :" + loginType.getValue()));
}
}
}
if (form.getName().equals(Form.ADVANCED)) {
if (useOtherConnection) {
form.setHidden(true);
} else {
form.setHidden(false);
boolean bulkMode = bulkConnection.getValue();
form.getWidget(httpChunked.getName()).setHidden(bulkMode);
form.getWidget(httpTraceMessage.getName()).setHidden(!bulkMode);
boolean isBasicLogin = LoginType.Basic.equals(loginType.getValue());
form.getWidget(reuseSession.getName()).setVisible(isBasicLogin && !bulkMode);
form.getWidget(sessionDirectory.getName()).setVisible(isBasicLogin && !bulkMode && reuseSession.getValue());
form.getWidget(apiVersion.getName()).setHidden(isBasicLogin);
Form proxyForm = form.getChildForm(proxy.getName());
if (proxyForm != null) {
boolean isUseProxy = proxy.useProxy.getValue();
proxyForm.getWidget(proxy.host.getName()).setHidden(!isUseProxy);
proxyForm.getWidget(proxy.port.getName()).setHidden(!isUseProxy);
proxyForm.getWidget(proxy.userPassword.getName()).setHidden(!isUseProxy);
}
}
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class CouchbaseReader method start.
@Override
public boolean start() throws IOException {
try {
converter = new CouchbaseEventGenericRecordConverter(source.getSchema());
connection = source.getConnection(container);
resultsQueue = new LinkedBlockingQueue<>();
connection.startStreaming(resultsQueue);
} catch (ClassNotFoundException e) {
throw new ComponentException(e);
}
return advance();
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class JdbcRowTestIT method test_die_on_error_as_output.
@SuppressWarnings("rawtypes")
@Test
public void test_die_on_error_as_output() throws Exception {
TJDBCRowDefinition definition = new TJDBCRowDefinition();
TJDBCRowProperties properties = DBTestUtils.createCommonJDBCRowProperties(allSetting, definition);
Schema schema = DBTestUtils.createTestSchema(tablename);
properties.main.schema.setValue(schema);
properties.updateOutputSchemas();
properties.tableSelection.tablename.setValue(tablename);
properties.sql.setValue("insert into " + tablename + " values(?,?)");
properties.dieOnError.setValue(true);
randomCommit(properties);
properties.usePreparedStatement.setValue(true);
properties.preparedStatementTable.indexs.setValue(Arrays.asList(1, 2));
properties.preparedStatementTable.types.setValue(Arrays.asList(PreparedStatementTable.Type.Int.name(), PreparedStatementTable.Type.String.name()));
properties.preparedStatementTable.values.setValue(Arrays.<Object>asList(4, "a too long value"));
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(definition.getRuntimeInfo(ExecutionEngine.DI, properties, ConnectorTopology.INCOMING_AND_OUTGOING), properties.getClass().getClassLoader())) {
JDBCRowSink sink = (JDBCRowSink) sandboxedInstance.getInstance();
sink.initialize(null, properties);
ValidationResult result = sink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
WriteOperation operation = sink.createWriteOperation();
JDBCRowWriter writer = (JDBCRowWriter) operation.createWriter(null);
try {
writer.open("wid");
IndexedRecord r1 = new GenericData.Record(properties.main.schema.getValue());
r1.put(0, 4);
r1.put(1, "xiaoming");
writer.write(r1);
writer.close();
} catch (ComponentException e) {
Assert.assertNotNull(e.getCause());
} finally {
writer.close();
}
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class ReplicateDefinition method getRuntimeInfo.
@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
assertEngineCompatibility(engine);
assertConnectorTopologyCompatibility(connectorTopology);
try {
return new JarRuntimeInfo(new URL("mvn:org.talend.components/processing-runtime"), DependenciesReader.computeDependenciesFilePath(ProcessingFamilyDefinition.MAVEN_GROUP_ID, ProcessingFamilyDefinition.MAVEN_ARTIFACT_ID), "org.talend.components.processing.runtime.replicate.ReplicateRuntime");
} catch (MalformedURLException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class NormalizeDefinition method getRuntimeInfo.
@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
assertEngineCompatibility(engine);
assertConnectorTopologyCompatibility(connectorTopology);
try {
return new JarRuntimeInfo(new URL("mvn:org.talend.components/processing-runtime"), DependenciesReader.computeDependenciesFilePath("org.talend.components", "components-runtime"), "org.talend.components.processing.runtime.normalize.NormalizeRuntime");
} catch (MalformedURLException e) {
throw new ComponentException(e);
}
}
Aggregations