Skip to content

Commit

Permalink
Review Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Agarwal committed Mar 30, 2021
1 parent 4b1b6b5 commit 323d96a
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class TableTypeTest {
@Test
void testGetAndSetField() throws Exception {
Table testTable = Table.builder()
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.name("dim1")
.type(Type.BOOLEAN)
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand Down Expand Up @@ -177,7 +177,7 @@ void testMeasureAnnotations() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.measures(Arrays.asList(Measure.builder()
.measure(Measure.builder()
.type(Type.MONEY)
.category("category1")
.definition("SUM{{ price}}")
Expand All @@ -187,7 +187,7 @@ void testMeasureAnnotations() throws Exception {
.readAccess("Admin")
.description("A measure")
.tags(tags)
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand Down Expand Up @@ -217,7 +217,7 @@ void testDimensionAnnotations() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.type(Type.TEXT)
.category("category1")
.definition("{{region}}")
Expand All @@ -229,7 +229,7 @@ void testDimensionAnnotations() throws Exception {
.tags(tags)
.cardinality("small")
.tableSource("region.id")
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand Down Expand Up @@ -258,11 +258,11 @@ void testDimensionTableValues() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.type(Type.COORDINATE)
.name("location")
.values(values)
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand All @@ -281,7 +281,7 @@ void testTimeDimensionAnnotations() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.type(Type.TIME)
.category("category1")
.definition("{{createdOn }}")
Expand All @@ -291,7 +291,7 @@ void testTimeDimensionAnnotations() throws Exception {
.readAccess("Admin")
.description("A time dimension")
.tags(tags)
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand Down Expand Up @@ -323,19 +323,19 @@ void testMultipleTimeDimensionGrains() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.type(Type.TIME)
.definition("{{createdOn}}")
.name("createdOn")
.grains(Arrays.asList(Grain.builder()
.grain(Grain.builder()
.sql("some sql")
.type(Grain.GrainType.DAY)
.build(),
Grain.builder()
.build())
.grain(Grain.builder()
.sql("some other sql")
.type(Grain.GrainType.YEAR)
.build()))
.build()))
.build())
.build())
.build();

TableType testType = new TableType(testTable);
Expand All @@ -356,21 +356,21 @@ void testMultipleTimeDimensionGrains() throws Exception {
void testJoinField() throws Exception {
Table testTable1 = Table.builder()
.name("table1")
.joins(Arrays.asList(Join.builder()
.join(Join.builder()
.definition("{{id }} = {{ table2.id}}")
.kind(Join.Kind.TOONE)
.type(Join.Type.INNER)
.name("join1")
.to("table2.dim2")
.build()))
.build())
.build();

Table testTable2 = Table.builder()
.name("table2")
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.name("dim2")
.type(Type.BOOLEAN)
.build()))
.build())
.build();

TableType testType1 = new TableType(testTable1);
Expand All @@ -397,11 +397,11 @@ void testHiddenDimension() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.dimensions(Arrays.asList(Dimension.builder()
.dimension(Dimension.builder()
.name("dim1")
.type(Type.BOOLEAN)
.hidden(true)
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand All @@ -420,11 +420,11 @@ void testHiddenMeasure() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.measures(Arrays.asList(Measure.builder()
.measure(Measure.builder()
.name("measure1")
.type(Type.BOOLEAN)
.hidden(true)
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand All @@ -443,11 +443,11 @@ void testInvalidResolver() throws Exception {
Table testTable = Table.builder()
.table("table1")
.name("Table")
.measures(Arrays.asList(Measure.builder()
.measure(Measure.builder()
.name("measure1")
.type(Type.BOOLEAN)
.queryPlanResolver("does.not.exist.class")
.build()))
.build())
.build();

TableType testType = new TableType(testTable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.LinkedHashSet;
import java.util.Set;
Expand All @@ -33,7 +32,6 @@
@Data
@EqualsAndHashCode()
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Argument implements Named {

Expand All @@ -48,15 +46,18 @@ public class Argument implements Named {

@JsonProperty("values")
@JsonDeserialize(as = LinkedHashSet.class)
@Builder.Default
private Set<String> values = new LinkedHashSet<>();
private Set<String> values;

@JsonProperty("tableSource")
private String tableSource;

@JsonProperty("default")
private Object defaultValue;

public Argument() {
this.values = new LinkedHashSet<>();
}

/**
* Returns description of the argument.
* If null, returns the name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Singular;

import java.util.ArrayList;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -44,7 +44,6 @@
@Data
@EqualsAndHashCode()
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Dimension implements Named {

Expand All @@ -61,12 +60,10 @@ public class Dimension implements Named {
private String category;

@JsonProperty("hidden")
@Builder.Default
private Boolean hidden = false;
private Boolean hidden;

@JsonProperty("readAccess")
@Builder.Default
private String readAccess = "Prefab.Role.All";
private String readAccess;

@JsonProperty("definition")
private String definition;
Expand All @@ -78,26 +75,33 @@ public class Dimension implements Named {
private Type type;

@JsonProperty("grains")
@Builder.Default
private List<Grain> grains = new ArrayList<>();
@Singular
private List<Grain> grains;

@JsonProperty("tags")
@JsonDeserialize(as = LinkedHashSet.class)
@Builder.Default
private Set<String> tags = new LinkedHashSet<>();
private Set<String> tags;

@JsonProperty("arguments")
@Builder.Default
private List<Argument> arguments = new ArrayList<>();
@Singular
private List<Argument> arguments;

@JsonProperty("values")
@JsonDeserialize(as = LinkedHashSet.class)
@Builder.Default
private Set<String> values = new LinkedHashSet<>();
private Set<String> values;

@JsonProperty("tableSource")
private String tableSource;

public Dimension() {
this.hidden = false;
this.readAccess = "Prefab.Role.All";
this.grains = new ArrayList<>();
this.tags = new LinkedHashSet<>();
this.values = new LinkedHashSet<>();
this.arguments = new ArrayList<>();
}

/**
* Returns description of the dimension.
* If null, returns the name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
* Joins describe the SQL expression necessary to join two physical tables.
Expand All @@ -29,7 +29,6 @@
@Data
@EqualsAndHashCode()
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Join implements Named {

Expand All @@ -43,12 +42,15 @@ public class Join implements Named {
private Join.Type type;

@JsonProperty("kind")
@Builder.Default
private Join.Kind kind = Join.Kind.TOONE;
private Join.Kind kind;

@JsonProperty("definition")
private String definition;

public Join() {
this.kind = Join.Kind.TOONE;
}

public enum Kind {

TOONE("toOne"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Singular;

import java.util.ArrayList;
import java.util.LinkedHashSet;
Expand All @@ -40,7 +40,6 @@
@Data
@EqualsAndHashCode()
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Measure implements Named {

Expand All @@ -57,12 +56,10 @@ public class Measure implements Named {
private String category;

@JsonProperty("hidden")
@Builder.Default
private Boolean hidden = false;
private Boolean hidden;

@JsonProperty("readAccess")
@Builder.Default
private String readAccess = "Prefab.Role.All";
private String readAccess;

@JsonProperty("definition")
private String definition;
Expand All @@ -75,12 +72,18 @@ public class Measure implements Named {

@JsonProperty("tags")
@JsonDeserialize(as = LinkedHashSet.class)
@Builder.Default
private Set<String> tags = new LinkedHashSet<>();
private Set<String> tags;

@JsonProperty("arguments")
@Builder.Default
private List<Argument> arguments = new ArrayList<>();
@Singular
private List<Argument> arguments;

public Measure() {
this.hidden = false;
this.readAccess = "Prefab.Role.All";
this.tags = new LinkedHashSet<>();
this.arguments = new ArrayList<>();
}

/**
* Returns description of the measure.
Expand Down
Loading

0 comments on commit 323d96a

Please sign in to comment.