use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class AbstractDate method getParametersForDatePattern.
/**
* @return the Parameters to display for the date related action.
*/
protected List<Parameter> getParametersForDatePattern(Locale locale) {
HashMap<String, String> datePatterns = loadDatePatterns();
SelectParameter.SelectParameterBuilder selectParamBuilder = SelectParameter.selectParameter(locale).name(NEW_PATTERN);
String defaultItem = null;
for (Map.Entry<String, String> datePatternEntry : datePatterns.entrySet()) {
String key = datePatternEntry.getKey();
String value = datePatternEntry.getValue();
selectParamBuilder.constant(value, choice(this, locale, key));
if ("ISO".equals(key)) {
defaultItem = value;
}
if (defaultItem == null) {
defaultItem = value;
}
}
SelectParameter custom = //
selectParamBuilder.item("custom", "custom", //
buildCustomPatternParam(locale)).defaultValue(//
defaultItem).build(this);
custom.getItems().sort(compareOnLabelWithCustomLast());
List<Parameter> parameters = new ArrayList<>();
parameters.add(custom);
return parameters;
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class DistanceConverter method getParameters.
/**
* @return The list of parameters required for this Action to be executed.
*/
@Override
public List<Parameter> getParameters(Locale locale) {
final List<Parameter> parameters = super.getParameters(locale);
parameters.add(ActionsUtils.getColumnCreationParameter(locale, CREATE_NEW_COLUMN_DEFAULT));
SelectParameterBuilder builder = selectParameter(locale).item(MILLIMETER.name(), MILLIMETER.getShortName()).item(CENTIMETER.name(), CENTIMETER.getShortName()).item(DECIMETER.name(), DECIMETER.getShortName()).item(METER.name(), METER.getShortName()).item(DEKAMETER.name(), DEKAMETER.getShortName()).item(HECTOMETER.name(), HECTOMETER.getShortName()).item(KILOMETER.name(), KILOMETER.getShortName()).item(INCH.name(), INCH.getShortName()).item(FOOT.name(), FOOT.getShortName()).item(YARD.name(), YARD.getShortName()).item(MILE.name(), MILE.getShortName()).item(NAUTICAL_MILE.name(), NAUTICAL_MILE.getShortName()).item(LIGHT_YEAR.name(), LIGHT_YEAR.getShortName()).canBeBlank(false);
parameters.add(builder.name(FROM_UNIT_PARAMETER).defaultValue(MILE.name()).build(this));
builder.setLabel(null).setDescription(null);
parameters.add(builder.name(TO_UNIT_PARAMETER).defaultValue(KILOMETER.name()).build(this));
parameters.add(parameter(locale).setName(TARGET_PRECISION).setType(INTEGER).setDefaultValue("2").setPlaceHolder("precision").build(this));
return parameters;
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class CreateNewColumn method getParameters.
@Override
public List<Parameter> getParameters(Locale locale) {
final List<Parameter> parameters = super.getParameters(locale);
parameters.add(parameter(locale).setName(NEW_COLUMN_NAME).setType(ParameterType.STRING).setDefaultValue(DEFAULT_NAME_FOR_NEW_COLUMN).setCanBeBlank(false).build(this));
Parameter constantParameter = Parameter.parameter(locale).setName(DEFAULT_VALUE_PARAMETER).setType(STRING).setDefaultValue(EMPTY).build(this);
// @formatter:off
parameters.add(selectParameter(locale).name(MODE_PARAMETER).item(EMPTY_MODE, EMPTY_MODE).item(CONSTANT_MODE, CONSTANT_MODE, constantParameter).item(COLUMN_MODE, COLUMN_MODE, parameter(locale).setName(SELECTED_COLUMN_PARAMETER).setType(COLUMN).setDefaultValue(EMPTY).setCanBeBlank(false).build(this)).defaultValue(COLUMN_MODE).build(this));
return parameters;
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class AbstractFillWith method getParameters.
@Override
public List<Parameter> getParameters(Locale locale) {
final List<Parameter> parameters = super.getParameters(locale);
Parameter constantParameter = null;
switch(type) {
case NUMERIC:
case DOUBLE:
case FLOAT:
case STRING:
constantParameter = parameter(locale).setName(DEFAULT_VALUE_PARAMETER).setType(STRING).setDefaultValue(EMPTY).build(this);
break;
case INTEGER:
constantParameter = parameter(locale).setName(DEFAULT_VALUE_PARAMETER).setType(INTEGER).setDefaultValue("0").build(this);
break;
case BOOLEAN:
constantParameter = //
selectParameter(locale).name(//
DEFAULT_VALUE_PARAMETER).item(//
"True").item(//
"False").defaultValue(//
"True").build(this);
break;
case DATE:
constantParameter = parameter(locale).setName(DEFAULT_VALUE_PARAMETER).setType(DATE).setDefaultValue(DEFAULT_DATE_VALUE).setCanBeBlank(false).build(this);
break;
case ANY:
default:
break;
}
// @formatter:off
parameters.add(selectParameter(locale).name(MODE_PARAMETER).item(CONSTANT_MODE, CONSTANT_MODE, constantParameter).item(OTHER_COLUMN_MODE, OTHER_COLUMN_MODE, parameter(locale).setName(SELECTED_COLUMN_PARAMETER).setType(COLUMN).setDefaultValue(EMPTY).setCanBeBlank(false).build(this)).defaultValue(CONSTANT_MODE).build(this));
return parameters;
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class ComputeTimeSinceTest method testParameters.
@Test
public void testParameters() throws Exception {
final List<Parameter> parameters = action.getParameters(Locale.US);
Assert.assertThat(parameters.size(), is(7));
// Test on items label for TDP-2943:
final SelectParameter selectParameter = (SelectParameter) parameters.get(6);
assertEquals("Now", selectParameter.getItems().get(0).getLabel());
assertEquals("Specific date", selectParameter.getItems().get(1).getLabel());
assertEquals("Other column", selectParameter.getItems().get(2).getLabel());
}
Aggregations