public String getTableName() { return table.tableName.getValue(); }
/** * {@inheritDoc} */ @Override public void setupProperties() { super.setupProperties(); hostUrl.setValue(INITIAL_HOST); }
private boolean isRequiredPropertiesMissed() { MarkLogicConnectionProperties connection = bulkLoadProperties.getConnection(); return connection.host.getStringValue().isEmpty() || connection.port.getValue() == null || connection.database .getStringValue().isEmpty() || connection.username.getStringValue().isEmpty() || connection.password .getStringValue().isEmpty() || bulkLoadProperties.loadFolder.getStringValue().isEmpty(); } }
private boolean isCachedModuleNameUsed() { for (Object cachedModuleName: this.moduleName.getPossibleValues()) { if (cachedModuleName instanceof String) { if (moduleName.getValue().equals(cachedModuleName)) { return true; } } } return false; } @Override
public static StringProperty newString(String name, String initialValue, String defaultValue) { StringProperty property = newString(name); property.setValue(initialValue); property.setDefaultValue(defaultValue); return property; }
@Override public void encryptStoredValue(boolean encrypt) { if (isFlag(Property.Flags.ENCRYPT)) { String value = (String) getStoredValue(); CryptoHelper ch = new CryptoHelper(CryptoHelper.PASSPHRASE); if (encrypt) { setStoredValue(ch.encrypt(value)); } else { setStoredValue(ch.decrypt(value)); } } }
@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); } };
@Override public void accept(SalesforceRuntimeSourceOrSink runtime) throws IOException { List<NamedThing> moduleNames = runtime.getSchemaNames(null); moduleName.setPossibleNamedThingValues(filter(moduleNames)); } };
@Test public void testUpdatePossibleValues() { StringProperty property = new StringProperty("names"); property.setPossibleValues(Arrays.asList("a", "b", "c")); property.setStoredValue("a"); List<String> newPossibleValues = Arrays.asList("a1", "b1", "c1"); CommonUtils.updatePossibleValues(property, newPossibleValues); Assert.assertEquals("a1", property.getValue()); Assert.assertEquals(newPossibleValues, property.getPossibleValues()); newPossibleValues = Arrays.asList("b1", "a1", "c1", "d1", "e1", "f1"); CommonUtils.updatePossibleValues(property, newPossibleValues); Assert.assertEquals("a1", property.getValue()); Assert.assertEquals(newPossibleValues, property.getPossibleValues()); }
public ValidationResult afterTableName() throws Exception { ValidationResultMutable vr = new ValidationResultMutable(); try { main.schema.setValue(SnowflakeSourceOrSink.getSchema(null, connection, tableName.getValue())); tableName.setPossibleValues(Collections.emptyList()); } catch (Exception ex) { vr.setMessage(ex.getMessage()); vr.setStatus(ValidationResult.Result.ERROR); } return vr; }
/** * the method is called back at many places, even some strange places, so it should work only for basic layout, not * some action which need runtime support. */ @Override public void refreshLayout(Form form) { super.refreshLayout(form); boolean useModule = sourceType.getValue() == SourceType.MODULE_SELECTION; form.getWidget(moduleName).setVisible(useModule); moduleName.setRequired(useModule); boolean moduleNameSelect = StringUtils.isNotEmpty(moduleName.getValue()); form.getWidget(selectColumnIds).setVisible(useModule && moduleNameSelect); selectColumnIds.setRequired(useModule && moduleNameSelect); form.getWidget(condition).setVisible(useModule && moduleNameSelect); // We can not have a hidden field which is required form.getWidget(query).setVisible(!useModule); query.setRequired(!useModule); }
@Override public void setupProperties() { super.setupProperties(); host.setRequired(); host.setValue("127.0.0.1"); port.setRequired(); port.setValue(8000); database.setRequired(); database.setValue("Documents"); username.setRequired(); password.setRequired(); authentication.setPossibleValues("DIGEST", "BASIC"); authentication.setValue("DIGEST"); }
public ValidationResult afterModuleName() 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 { Schema schema = ss.getEndpointSchema(null, moduleName.getStringValue()); main.schema.setValue(schema); moduleName.setPossibleValues(Collections.emptyList()); } catch (Exception ex) { throw new ComponentException(ExceptionUtil.exceptionToValidationResult(ex)); } } else { throw new ComponentException(vr); } return ValidationResult.OK; } }
public ValidationResult afterGuessQueryFromSchema() { String tablenameDisplayed = tableSelection.tablename.getStoredValue() == null ? null : tableSelection.tablename.getStoredValue().toString(); Schema schema = main.schema.getValue(); if (tablenameDisplayed == null || tablenameDisplayed.isEmpty()) { return new ValidationResult(ValidationResult.Result.ERROR, "Please set the table name before it"); } if (schema == null || schema.getFields().isEmpty()) { return new ValidationResult(ValidationResult.Result.ERROR, "Please set the schema before it"); } String query = QueryUtils.generateNewQuery("General JDBC", null, null, tablenameDisplayed, getRuntimeSetting()); sql.setValue(query); // TODO maybe we need to split it two trigger methods : validate and after refreshLayout(getForm(Form.MAIN)); return ValidationResult.OK; }
@Override public void refreshLayout(Form form) { if (sourceType.getValue() == SourceType.MODULE_SELECTION) { form.getWidget(moduleName).setVisible(true); moduleName.setRequired(true); // We can not have a hidden field which is required form.getWidget(query).setVisible(false); query.setRequired(false); } else if (sourceType.getValue() == SourceType.SOQL_QUERY) { form.getWidget(query).setVisible(true); query.setRequired(); // We can not have a hidden field which is required form.getWidget(moduleName).setVisible(false); moduleName.setRequired(false); } super.refreshLayout(form); }
@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); } };
@JsonIgnore // to avoid swagger failure because of the 2 similar following methods. public Property<String> setPossibleValues(List<?> possibleValues) { // check is the type is a NamedThing if (possibleValues != null && !possibleValues.isEmpty() && possibleValues.get(0) instanceof NamedThing) { setPossibleNamedThingValues((List<NamedThing>) possibleValues); } else { super.setPossibleValues(possibleValues); } return this; }
private boolean isCachedTableNameUsed() { for (Object cachedTableName: this.tableName.getPossibleValues()) { if (cachedTableName instanceof String) { if (tableName.getValue().equals(cachedTableName)) { return true; } } } return false; }
public ValidationResult afterTableName() throws Exception { ValidationResultMutable vr = new ValidationResultMutable(); try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) { SnowflakeRuntimeSourceOrSink ss = (SnowflakeRuntimeSourceOrSink) sandboxedInstance.getInstance(); ss.initialize(null, connection); main.schema.setValue(ss.getEndpointSchema(null, tableName.getValue())); tableName.setPossibleValues(Collections.emptyList()); } catch (Exception ex) { vr.setMessage(ex.getMessage()); vr.setStatus(ValidationResult.Result.ERROR); } return vr; }
/** * the method is called back at many places, even some strange places, so it should work only for basic layout, not * some action which need runtime support. */ @Override public void refreshLayout(Form form) { super.refreshLayout(form); boolean useModule = sourceType.getValue() == SourceType.MODULE_SELECTION; form.getWidget(moduleName).setVisible(useModule); moduleName.setRequired(useModule); boolean moduleNameSelect = StringUtils.isNotEmpty(moduleName.getValue()); form.getWidget(selectColumnIds).setVisible(useModule && moduleNameSelect); selectColumnIds.setRequired(useModule && moduleNameSelect); form.getWidget(condition).setVisible(useModule && moduleNameSelect); // We can not have a hidden field which is required form.getWidget(query).setVisible(!useModule); query.setRequired(!useModule); }