-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a default base class for all dimension types
- Loading branch information
1 parent
dc6df32
commit 790ff11
Showing
9 changed files
with
427 additions
and
119 deletions.
There are no files selected for viewing
134 changes: 134 additions & 0 deletions
134
...src/main/java/com/yahoo/bard/webservice/data/config/dimension/DefaultDimensionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Copyright 2016 Yahoo Inc. | ||
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. | ||
package com.yahoo.bard.webservice.data.config.dimension; | ||
|
||
import com.yahoo.bard.webservice.data.config.names.DimensionName; | ||
import com.yahoo.bard.webservice.data.dimension.DimensionField; | ||
import com.yahoo.bard.webservice.data.dimension.KeyValueStore; | ||
import com.yahoo.bard.webservice.data.dimension.SearchProvider; | ||
|
||
import java.util.LinkedHashSet; | ||
import javax.validation.constraints.NotNull; | ||
|
||
|
||
/** | ||
* A Dimension instance holds all of the information needed to construct a Dimension. | ||
*/ | ||
public class DefaultDimensionConfig implements DimensionConfig { | ||
|
||
private final DimensionName apiName; | ||
private final String physicalName; | ||
private final String description; | ||
private final String longName; | ||
private final String category; | ||
private final LinkedHashSet<DimensionField> fields; | ||
private final LinkedHashSet<DimensionField> defaultDimensionFields; | ||
private final KeyValueStore keyValueStore; | ||
private final SearchProvider searchProvider; | ||
|
||
/** | ||
* Construct a DefaultDimensionConfig Instance from Dimension Name , dimension fields and default dimension fields. | ||
* | ||
* @param apiName The API Name is the external, end-user-facing name for the dimension. | ||
* @param physicalName The internal, physical name for the dimension. | ||
* @param description A description of the dimension and its meaning. | ||
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
* @param fields The set of fields for this dimension. | ||
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
*/ | ||
public DefaultDimensionConfig( | ||
@NotNull DimensionName apiName, | ||
@NotNull String physicalName, | ||
@NotNull String description, | ||
@NotNull String longName, | ||
@NotNull String category, | ||
@NotNull LinkedHashSet<DimensionField> fields, | ||
@NotNull LinkedHashSet<DimensionField> defaultDimensionFields, | ||
@NotNull KeyValueStore keyValueStore, | ||
@NotNull SearchProvider searchProvider | ||
) { | ||
this.apiName = apiName; | ||
this.physicalName = physicalName; | ||
this.description = description; | ||
this.longName = longName; | ||
this.category = category; | ||
this.fields = fields; | ||
this.defaultDimensionFields = defaultDimensionFields; | ||
this.keyValueStore = keyValueStore; | ||
this.searchProvider = searchProvider; | ||
} | ||
|
||
/** | ||
* Construct a DefaultDimensionConfig Instance from Dimension Name and only using default dimension fields. | ||
* | ||
* @param apiName The API Name is the external, end-user-facing name for the dimension. | ||
* @param physicalName The internal, physical name for the dimension. | ||
* @param description A description of the dimension and its meaning. | ||
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
*/ | ||
public DefaultDimensionConfig( | ||
DimensionName apiName, | ||
String physicalName, | ||
String description, | ||
String longName, | ||
String category, | ||
LinkedHashSet<DimensionField> defaultDimensionFields, | ||
KeyValueStore keyValueStore, | ||
SearchProvider searchProvider | ||
) { | ||
this ( | ||
apiName, | ||
physicalName, | ||
description, | ||
longName, | ||
category, | ||
defaultDimensionFields, | ||
defaultDimensionFields, | ||
keyValueStore, | ||
searchProvider | ||
); | ||
} | ||
|
||
public String getApiName() { | ||
return apiName.asName(); | ||
} | ||
|
||
public String getLongName() { | ||
return longName; | ||
} | ||
|
||
public String getCategory() { | ||
return category; | ||
} | ||
|
||
public String getPhysicalName() { | ||
return physicalName; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public LinkedHashSet<DimensionField> getFields() { | ||
return fields; | ||
} | ||
|
||
public LinkedHashSet<DimensionField> getDefaultDimensionFields() { | ||
return defaultDimensionFields; | ||
} | ||
|
||
public KeyValueStore getKeyValueStore() { | ||
return keyValueStore; | ||
} | ||
|
||
public SearchProvider getSearchProvider() { | ||
return searchProvider; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
...in/java/com/yahoo/bard/webservice/data/config/dimension/LookupDefaultDimensionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2017 Yahoo Inc. | ||
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. | ||
package com.yahoo.bard.webservice.data.config.dimension; | ||
|
||
import com.yahoo.bard.webservice.data.config.names.DimensionName; | ||
import com.yahoo.bard.webservice.data.dimension.DimensionField; | ||
import com.yahoo.bard.webservice.data.dimension.KeyValueStore; | ||
import com.yahoo.bard.webservice.data.dimension.SearchProvider; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* A Lookup Dimension instance holds all of the information needed to construct a Lookup Dimension. | ||
*/ | ||
public class LookupDefaultDimensionConfig extends DefaultDimensionConfig implements LookupDimensionConfig { | ||
private final List<String> namespaces; | ||
|
||
/** | ||
* Construct a LookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and | ||
* default dimension fields. | ||
* | ||
* @param apiName The API Name is the external, end-user-facing name for the dimension. | ||
* @param physicalName The internal, physical name for the dimension. | ||
* @param description A description of the dimension and its meaning. | ||
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
* @param fields The set of fields for this dimension. | ||
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
* @param namespaces A list of namespaces used to configure the Lookup dimension. | ||
*/ | ||
public LookupDefaultDimensionConfig( | ||
@NotNull DimensionName apiName, | ||
@NotNull String physicalName, | ||
@NotNull String description, | ||
@NotNull String longName, | ||
@NotNull String category, | ||
@NotNull LinkedHashSet<DimensionField> fields, | ||
@NotNull LinkedHashSet<DimensionField> defaultDimensionFields, | ||
@NotNull KeyValueStore keyValueStore, | ||
@NotNull SearchProvider searchProvider, | ||
@NotNull List<String> namespaces | ||
) { | ||
super ( | ||
apiName, | ||
physicalName, | ||
description, | ||
longName, | ||
category, | ||
fields, | ||
defaultDimensionFields, | ||
keyValueStore, | ||
searchProvider | ||
); | ||
this.namespaces = namespaces; | ||
} | ||
|
||
/** | ||
* Construct a LookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and default dimension fields. | ||
* | ||
* @param apiName The API Name is the external, end-user-facing name for the dimension. | ||
* @param physicalName The internal, physical name for the dimension. | ||
* @param description A description of the dimension and its meaning. | ||
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
* @param namespaces A list of namespaces used to configure the Lookup dimension. | ||
*/ | ||
public LookupDefaultDimensionConfig( | ||
DimensionName apiName, | ||
String physicalName, | ||
String description, | ||
String longName, | ||
String category, | ||
LinkedHashSet<DimensionField> defaultDimensionFields, | ||
KeyValueStore keyValueStore, | ||
SearchProvider searchProvider, | ||
List<String> namespaces | ||
) { | ||
this ( | ||
apiName, | ||
physicalName, | ||
description, | ||
longName, | ||
category, | ||
defaultDimensionFields, | ||
defaultDimensionFields, | ||
keyValueStore, | ||
searchProvider, | ||
namespaces | ||
); | ||
} | ||
|
||
public List<String> getNamespaces() { | ||
return namespaces; | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
...m/yahoo/bard/webservice/data/config/dimension/RegisteredLookupDefaultDimensionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Copyright 2017 Yahoo Inc. | ||
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. | ||
package com.yahoo.bard.webservice.data.config.dimension; | ||
|
||
import com.yahoo.bard.webservice.data.config.names.DimensionName; | ||
import com.yahoo.bard.webservice.data.dimension.DimensionField; | ||
import com.yahoo.bard.webservice.data.dimension.KeyValueStore; | ||
import com.yahoo.bard.webservice.data.dimension.SearchProvider; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* A Registered Dimension Instance holds all of the information needed to construct a Registered Lookup Dimension. | ||
*/ | ||
public class RegisteredLookupDefaultDimensionConfig extends DefaultDimensionConfig | ||
implements RegisteredLookupDimensionConfig { | ||
private final List<String> lookups; | ||
|
||
/** | ||
* Construct a RegisteredLookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and | ||
* default dimension fields. | ||
* | ||
* @param apiName The API Name is the external, end-user-facing name for the dimension. | ||
* @param physicalName The internal, physical name for the dimension. | ||
* @param description A description of the dimension and its meaning. | ||
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
* @param fields The set of fields for this dimension. | ||
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
* @param lookups A list of lookups used to configure the Lookup dimension. | ||
*/ | ||
public RegisteredLookupDefaultDimensionConfig( | ||
@NotNull DimensionName apiName, | ||
@NotNull String physicalName, | ||
@NotNull String description, | ||
@NotNull String longName, | ||
@NotNull String category, | ||
@NotNull LinkedHashSet<DimensionField> fields, | ||
@NotNull LinkedHashSet<DimensionField> defaultDimensionFields, | ||
@NotNull KeyValueStore keyValueStore, | ||
@NotNull SearchProvider searchProvider, | ||
@NotNull List<String> lookups | ||
) { | ||
super ( | ||
apiName, | ||
physicalName, | ||
description, | ||
longName, | ||
category, | ||
fields, | ||
defaultDimensionFields, | ||
keyValueStore, | ||
searchProvider | ||
); | ||
this.lookups = lookups; | ||
} | ||
|
||
/** | ||
* Construct a RegisteredLookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and | ||
* default dimension fields. | ||
* | ||
* @param apiName The API Name is the external, end-user-facing name for the dimension. | ||
* @param physicalName The internal, physical name for the dimension. | ||
* @param description A description of the dimension and its meaning. | ||
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
* @param lookups A list of lookups used to configure the Lookup dimension. | ||
*/ | ||
public RegisteredLookupDefaultDimensionConfig( | ||
DimensionName apiName, | ||
String physicalName, | ||
String description, | ||
String longName, | ||
String category, | ||
LinkedHashSet<DimensionField> defaultDimensionFields, | ||
KeyValueStore keyValueStore, | ||
SearchProvider searchProvider, | ||
List<String> lookups | ||
) { | ||
this ( | ||
apiName, | ||
physicalName, | ||
description, | ||
longName, | ||
category, | ||
defaultDimensionFields, | ||
defaultDimensionFields, | ||
keyValueStore, | ||
searchProvider, | ||
lookups | ||
); | ||
} | ||
|
||
public List<String> getLookups() { | ||
return lookups; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
fili-core/src/main/java/com/yahoo/bard/webservice/data/config/names/DimensionName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2017 Yahoo Inc. | ||
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. | ||
package com.yahoo.bard.webservice.data.config.names; | ||
|
||
/** | ||
* Defines the name of a Dimension. | ||
*/ | ||
public interface DimensionName { | ||
|
||
/** | ||
* The name of this dimension. | ||
* | ||
* @return Dimension Name | ||
*/ | ||
String asName(); | ||
} |
20 changes: 20 additions & 0 deletions
20
fili-core/src/test/java/com/yahoo/bard/webservice/data/config/names/TestDimensionName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2017 Yahoo Inc. | ||
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. | ||
package com.yahoo.bard.webservice.data.config.names; | ||
|
||
import com.yahoo.bard.webservice.util.EnumUtils; | ||
|
||
/** | ||
* Bard test dimensions. | ||
*/ | ||
public enum TestDimensionName implements DimensionName { | ||
NAME, | ||
AGE, | ||
ETHNICITY, | ||
GENDER; | ||
|
||
@Override | ||
public String asName() { | ||
return EnumUtils.camelCase(name()); | ||
} | ||
} |
Oops, something went wrong.