use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class DefaultLookupRowMatcher method getEmptyRow.
/**
* Returns an empty default row based on the given dataset metadata.
*
* @param columns the list of column metadata of rows within the data set
* @return an empty default row based on the given list of column metadata.
*/
private DataSetRow getEmptyRow(List<ColumnMetadata> columns) {
RowMetadata rowMetadata = new RowMetadata(columns);
DataSetRow defaultRow = new DataSetRow(rowMetadata);
columns.forEach(column -> defaultRow.set(column.getId(), EMPTY));
return defaultRow;
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class ClearMatching method toClear.
@Override
public boolean toClear(DataSetRow dataSetRow, String columnId, ActionContext actionContext) {
final Map<String, String> parameters = actionContext.getParameters();
final RowMetadata rowMetadata = actionContext.getRowMetadata();
final ColumnMetadata columnMetadata = rowMetadata.getById(columnId);
final String value = dataSetRow.get(columnId);
final String equalsValue = parameters.get(VALUE_PARAMETER);
if (Type.get(columnMetadata.getType()) == Type.BOOLEAN) {
// for boolean we can accept True equalsIgnoreCase true
return StringUtils.equalsIgnoreCase(value, equalsValue);
} else {
ReplaceOnValueHelper replaceOnValueHelper = new ReplaceOnValueHelper().build(equalsValue, true);
return replaceOnValueHelper.matches(value);
}
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class DataSetRow method filter.
public DataSetRow filter(List<ColumnMetadata> filteredColumns) {
final Set<String> columnsToKeep = filteredColumns.stream().map(ColumnMetadata::getId).collect(Collectors.toSet());
final Set<String> columnsToDelete = values.entrySet().stream().filter(//
e -> !columnsToKeep.contains(e.getKey())).map(Map.Entry::getKey).collect(Collectors.toSet());
final RowMetadata rowMetadataClone = rowMetadata.clone();
final LinkedHashMap<String, String> filteredValues = new LinkedHashMap<>(this.values);
for (String columnId : columnsToDelete) {
filteredValues.remove(columnId);
rowMetadataClone.deleteColumnById(columnId);
}
final DataSetRow filteredDataSetRow = new DataSetRow(rowMetadataClone, filteredValues);
filteredDataSetRow.invalidColumnIds.addAll(invalidColumnIds);
return filteredDataSetRow;
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class DataSetRowStreamDeserializer method deserialize.
@Override
public Stream<DataSetRow> deserialize(JsonParser jp, DeserializationContext context) {
final List<ColumnMetadata> columns = (List<ColumnMetadata>) context.getAttribute(ColumnContextDeserializer.class.getName());
final RowMetadata rowMetadata;
if (columns == null) {
rowMetadata = new RowMetadata();
} else {
rowMetadata = new RowMetadata(columns);
}
final Iterable<DataSetRow> rowIterable = () -> new DataSetRowIterator(jp, rowMetadata);
return StreamSupport.stream(rowIterable.spliterator(), false);
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class DataSetLookupRowMatcher method getEmptyRow.
/**
* Return an empty default row based on the given dataset metadata.
*
* @param columns the dataset to get build the row from.
* @return an empty default row based on the given dataset metadata.
*/
private DataSetRow getEmptyRow(List<ColumnMetadata> columns) {
RowMetadata rowMetadata = new RowMetadata(columns);
DataSetRow defaultRow = new DataSetRow(rowMetadata);
columns.forEach(column -> defaultRow.set(column.getId(), EMPTY));
return defaultRow;
}
Aggregations