Skip to content

Commit

Permalink
Create a default base class for all dimension types
Browse files Browse the repository at this point in the history
  • Loading branch information
asifmansoora committed Feb 24, 2017
1 parent dc6df32 commit 790ff11
Show file tree
Hide file tree
Showing 9 changed files with 427 additions and 119 deletions.
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;
}
}
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;
}
}
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;
}
}
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();
}
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());
}
}
Loading

0 comments on commit 790ff11

Please sign in to comment.