use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class GenerateSequence method getParameters.
@Override
public List<Parameter> getParameters(Locale locale) {
final List<Parameter> parameters = super.getParameters(locale);
parameters.add(ActionsUtils.getColumnCreationParameter(locale, true));
Parameter startParameter = parameter(locale).setName(START_VALUE).setType(INTEGER).setDefaultValue("1").build(this);
parameters.add(startParameter);
Parameter stepParameter = parameter(locale).setName(STEP_VALUE).setType(INTEGER).setDefaultValue("1").build(this);
parameters.add(stepParameter);
return parameters;
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class TestI18nKeysForActionsTest method allActionShouldHaveTranslations.
@Test
public void allActionShouldHaveTranslations() {
for (ActionDefinition actionMetadata : allActions) {
final String name = actionMetadata.getName();
assertNotNull(name);
assertNotEquals("", name);
actionMetadata.getLabel(Locale.US);
actionMetadata.getDescription(Locale.US);
String toString = actionMetadata.getName() + "," + actionMetadata.getCategory(Locale.US) + "," + actionMetadata.getLabel(Locale.US) + "," + actionMetadata.getDescription(Locale.US);
LOGGER.info(toString);
for (Parameter param : actionMetadata.getParameters(Locale.US)) {
assertParameter(param);
}
}
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class TestI18nKeysForActionsTest method assertItem.
private void assertItem(Item value) {
LOGGER.trace(" - " + value);
List<Parameter> parameters = value.getParameters();
if (parameters != null) {
for (Parameter inlineParam : parameters) {
String name = inlineParam.getName();
String label = inlineParam.getLabel();
String desc = inlineParam.getDescription();
LOGGER.trace(" - " + name + " | " + label + " | " + desc);
}
}
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class ExportAPITest method get_all_export_types.
@Test
public void get_all_export_types() throws Exception {
// given
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// when
String actualJsonString = RestAssured.when().get("/api/export/formats").asString();
List<ExportFormatMessage> exportFormatMessageList = mapper.readValue(actualJsonString, new TypeReference<List<ExportFormatMessage>>() {
});
ExportFormatMessage exportFormatMessageCSV = exportFormatMessageList.get(0);
ExportFormatMessage exportFormatMessageXLSX = exportFormatMessageList.get(1);
// then
assertEquals("text/csv", exportFormatMessageCSV.getMimeType());
assertEquals("CSV", exportFormatMessageCSV.getId());
assertEquals("Local CSV file", exportFormatMessageCSV.getName());
assertEquals(true, exportFormatMessageCSV.isNeedParameters());
assertEquals(false, exportFormatMessageCSV.isDefaultExport());
assertEquals(true, exportFormatMessageCSV.isEnabled());
assertEquals(true, exportFormatMessageCSV.isSupportSampling());
assertEquals("", exportFormatMessageCSV.getDisableReason());
assertEquals("Export to CSV", exportFormatMessageCSV.getTitle());
List<Parameter> parametersCSV = exportFormatMessageCSV.getParameters();
assertNotNull(parametersCSV);
assertEquals(6, parametersCSV.size());
// Andthen
assertEquals("application/vnd.ms-excel", exportFormatMessageXLSX.getMimeType());
assertEquals("XLSX", exportFormatMessageXLSX.getId());
assertEquals("Local XLSX file", exportFormatMessageXLSX.getName());
assertEquals(true, exportFormatMessageXLSX.isNeedParameters());
assertEquals(true, exportFormatMessageXLSX.isDefaultExport());
assertEquals(true, exportFormatMessageXLSX.isEnabled());
assertEquals(true, exportFormatMessageXLSX.isSupportSampling());
assertEquals("", exportFormatMessageXLSX.getDisableReason());
assertEquals("Export to XLSX", exportFormatMessageXLSX.getTitle());
List<Parameter> parametersXLS = exportFormatMessageXLSX.getParameters();
assertNotNull(parametersXLS);
assertEquals(1, parametersXLS.size());
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class ActionsStaticProfiler method profile.
public ActionsProfile profile(final List<ColumnMetadata> columns, final List<RunnableAction> actions) {
final Map<Action, ActionDefinition> metadataByAction = getActionMetadataByAction(actions);
// Compile actions
final Set<String> originalColumns = columns.stream().map(ColumnMetadata::getId).collect(toSet());
final Set<String> valueModifiedColumns = new HashSet<>();
final Set<String> metadataModifiedColumns = new HashSet<>();
int createColumnActions = 0;
// Analyze what columns to look at during analysis
for (Map.Entry<Action, ActionDefinition> entry : metadataByAction.entrySet()) {
final ActionDefinition actionMetadata = entry.getValue();
final Action action = entry.getKey();
Set<ActionDefinition.Behavior> behavior = actionMetadata.getBehavior();
boolean createColumn = false;
for (ActionDefinition.Behavior currentBehavior : behavior) {
switch(currentBehavior) {
case VALUES_ALL:
// All values are going to be changed, and all original columns are going to be modified.
valueModifiedColumns.addAll(originalColumns);
break;
case METADATA_CHANGE_TYPE:
valueModifiedColumns.add(action.getParameters().get(COLUMN_ID.getKey()));
metadataModifiedColumns.add(action.getParameters().get(COLUMN_ID.getKey()));
break;
case VALUES_COLUMN:
valueModifiedColumns.add(action.getParameters().get(COLUMN_ID.getKey()));
break;
case VALUES_MULTIPLE_COLUMNS:
// Add the action's source column
valueModifiedColumns.add(action.getParameters().get(COLUMN_ID.getKey()));
// ... then add all column parameter (COLUMN_ID is string, not column)
final List<Parameter> parameters = actionMetadata.getParameters(Locale.US);
valueModifiedColumns.addAll(//
parameters.stream().filter(//
parameter -> ParameterType.valueOf(parameter.getType().toUpperCase()) == ParameterType.COLUMN).map(//
parameter -> action.getParameters().get(parameter.getName())).collect(Collectors.toList()));
break;
case METADATA_COPY_COLUMNS:
case METADATA_CREATE_COLUMNS:
createColumn = true;
break;
case METADATA_DELETE_COLUMNS:
case METADATA_CHANGE_NAME:
// Do nothing: no need to re-analyze where only name was changed.
break;
default:
break;
}
}
if (createColumn || isCreateColumnParameterOn(action)) {
createColumnActions++;
}
}
// when values are modified, we need to do a full analysis (schema + invalid + stats)
boolean needFullAnalysis = !valueModifiedColumns.isEmpty() || createColumnActions > 0;
// when only metadata is modified, we need to re-evaluate the invalids entries
boolean needOnlyInvalidAnalysis = !needFullAnalysis && !metadataModifiedColumns.isEmpty();
// only the columns with modified values or new columns need the schema + stats analysis
SerializablePredicate<ColumnMetadata> filterForFullAnalysis = new FilterForFullAnalysis(originalColumns, valueModifiedColumns);
// only the columns with metadata change or value changes need to re-evaluate invalids
Predicate<ColumnMetadata> filterForInvalidAnalysis = new FilterForInvalidAnalysis(filterForFullAnalysis, metadataModifiedColumns);
return new ActionsProfile(needFullAnalysis, needOnlyInvalidAnalysis, filterForFullAnalysis, filterForInvalidAnalysis, filterForInvalidAnalysis, metadataByAction);
}
Aggregations