Skip to content

Commit

Permalink
allow SqlViewGroupingBinding to specify the SqlViewRowIdsConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Nov 16, 2017
1 parent f37188d commit 8b160cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/de/metas/ui/web/view/SqlViewFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private SqlViewBinding createViewBinding(@NonNull final SqlViewBindingKey key)
final SqlViewBinding.Builder builder = createBuilderForEntityBindingAndFieldNames(entityBinding, displayFieldNames);

builder.setFilterDescriptors(filterDescriptors)
.setGroupingBinding(groupingBinding);;
.setGroupingBinding(groupingBinding);

if (windowId2SqlDocumentFilterConverterDecorator.containsKey(key.getWindowId()))
{
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/de/metas/ui/web/view/descriptor/SqlViewBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public static final class Builder
private DocumentFilterDescriptorsProvider filterDescriptors = NullDocumentFilterDescriptorsProvider.instance;
private SqlDocumentFilterConvertersList.Builder filterConverters = null;

private SqlViewRowIdsConverter rowIdsConverter = DefaultSqlViewRowIdsConverter.instance;
private SqlViewRowIdsConverter rowIdsConverter = null;

private SqlViewGroupingBinding groupingBinding;
private SqlDocumentFilterConverterDecorator sqlDocumentFilterConverterDecorator = null;
Expand Down Expand Up @@ -454,7 +454,15 @@ public Builder setRowIdsConverter(@NonNull SqlViewRowIdsConverter rowIdsConverte

private SqlViewRowIdsConverter getRowIdsConverter()
{
return rowIdsConverter;
if (rowIdsConverter != null)
{
return rowIdsConverter;
}
if (groupingBinding != null)
{
return groupingBinding.getRowIdsConverter();
}
return DefaultSqlViewRowIdsConverter.instance;
}

public Builder setGroupingBinding(SqlViewGroupingBinding groupingBinding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.google.common.collect.ImmutableSet;

import lombok.Builder;
import lombok.Builder.Default;
import lombok.Getter;
import lombok.NonNull;
import lombok.Singular;
import lombok.ToString;

Expand Down Expand Up @@ -38,11 +41,16 @@ public final class SqlViewGroupingBinding
@Singular("columnSql")
private final ImmutableMap<String, String> columnSqlByFieldName;

@NonNull
@Default
@Getter
private final SqlViewRowIdsConverter rowIdsConverter = DefaultSqlViewRowIdsConverter.instance;

public ImmutableSet<String> getGroupByFieldNames()
{
return groupByFieldNames;
}

public boolean isGroupBy(final String fieldName)
{
return groupByFieldNames.contains(fieldName);
Expand All @@ -52,7 +60,7 @@ public String getColumnSqlByFieldName(final String fieldName)
{
return columnSqlByFieldName.get(fieldName);
}

public boolean isAggregated(final String fieldName)
{
return columnSqlByFieldName.containsKey(fieldName);
Expand Down

0 comments on commit 8b160cc

Please sign in to comment.