Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rename columnType to dimensionType [DHIS2-16705] #19296

Merged
merged 25 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
import static org.hisp.dhis.common.DimensionalObject.ITEM_SEP;
import static org.hisp.dhis.common.DimensionalObject.OPTION_SEP;
import static org.hisp.dhis.expression.ExpressionService.SYMBOL_WILDCARD;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -53,7 +50,6 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Triple;
Expand All @@ -63,6 +59,9 @@
import org.hisp.dhis.eventvisualization.EventRepetition;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.NoArgsConstructor;

/**
* @author Lars Helge Overland
Expand Down Expand Up @@ -141,7 +140,6 @@ public static DimensionalObject linkAssociations(
EventAnalyticalObject eventAnalyticalObject,
DimensionalObject dimensionalObject,
Attribute parent) {
// Associating event repetitions.
List<EventRepetition> repetitions = eventAnalyticalObject.getEventRepetitions();

if (isNotEmpty(repetitions)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Map;
import org.hisp.dhis.analytics.AnalyticsTableHookService;
import org.hisp.dhis.analytics.partition.PartitionManager;
import org.hisp.dhis.analytics.table.model.AnalyticsColumnType;
import org.hisp.dhis.analytics.table.model.AnalyticsDimensionType;
import org.hisp.dhis.analytics.table.model.AnalyticsTableColumn;
import org.hisp.dhis.analytics.table.model.AnalyticsTablePartition;
import org.hisp.dhis.analytics.table.model.Skip;
Expand Down Expand Up @@ -259,7 +259,7 @@ protected List<AnalyticsTableColumn> getTrackedEntityAttributeColumns(Program pr
columns.add(
AnalyticsTableColumn.builder()
.name(attribute.getUid())
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(dataType)
.selectExpression(sql)
.skipIndex(skipIndex)
Expand All @@ -272,7 +272,7 @@ protected List<AnalyticsTableColumn> getTrackedEntityAttributeColumns(Program pr
columns.add(
AnalyticsTableColumn.builder()
.name((attribute.getUid() + OU_NAME_COL_SUFFIX))
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(TEXT)
.selectExpression(ouNameSql)
.skipIndex(SKIP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.hisp.dhis.analytics.AnalyticsTableType;
import org.hisp.dhis.analytics.AnalyticsTableUpdateParams;
import org.hisp.dhis.analytics.partition.PartitionManager;
import org.hisp.dhis.analytics.table.model.AnalyticsColumnType;
import org.hisp.dhis.analytics.table.model.AnalyticsDimensionType;
import org.hisp.dhis.analytics.table.model.AnalyticsTable;
import org.hisp.dhis.analytics.table.model.AnalyticsTableColumn;
import org.hisp.dhis.analytics.table.model.AnalyticsTablePartition;
Expand Down Expand Up @@ -537,7 +537,7 @@ protected List<AnalyticsTableColumn> getOrganisationUnitGroupSetColumns() {
String name = ougs.getUid();
return AnalyticsTableColumn.builder()
.name(name)
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("ougs." + quote(name))
.skipIndex(skipIndex(ougs))
Expand All @@ -554,7 +554,7 @@ protected List<AnalyticsTableColumn> getDataElementGroupSetColumns() {
String name = degs.getUid();
return AnalyticsTableColumn.builder()
.name(name)
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("degs." + quote(name))
.skipIndex(skipIndex(degs))
Expand All @@ -571,7 +571,7 @@ protected List<AnalyticsTableColumn> getDisaggregationCategoryOptionGroupSetColu
String name = cogs.getUid();
return AnalyticsTableColumn.builder()
.name(name)
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("dcs." + quote(name))
.skipIndex(skipIndex(cogs))
Expand All @@ -588,7 +588,7 @@ protected List<AnalyticsTableColumn> getAttributeCategoryOptionGroupSetColumns()
String name = cogs.getUid();
return AnalyticsTableColumn.builder()
.name(name)
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("acs." + quote(name))
.skipIndex(skipIndex(cogs))
Expand All @@ -605,7 +605,7 @@ protected List<AnalyticsTableColumn> getDisaggregationCategoryColumns() {
String name = category.getUid();
return AnalyticsTableColumn.builder()
.name(name)
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("dcs." + quote(name))
.skipIndex(skipIndex(category))
Expand All @@ -622,7 +622,7 @@ protected List<AnalyticsTableColumn> getAttributeCategoryColumns() {
String name = category.getUid();
return AnalyticsTableColumn.builder()
.name(name)
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("acs." + quote(name))
.skipIndex(skipIndex(category))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.hisp.dhis.analytics.AnalyticsTableType;
import org.hisp.dhis.analytics.AnalyticsTableUpdateParams;
import org.hisp.dhis.analytics.partition.PartitionManager;
import org.hisp.dhis.analytics.table.model.AnalyticsColumnType;
import org.hisp.dhis.analytics.table.model.AnalyticsDimensionType;
import org.hisp.dhis.analytics.table.model.AnalyticsTable;
import org.hisp.dhis.analytics.table.model.AnalyticsTableColumn;
import org.hisp.dhis.analytics.table.model.AnalyticsTablePartition;
Expand Down Expand Up @@ -407,7 +407,7 @@ private List<AnalyticsTableColumn> getColumns(Program program) {
columns.add(
AnalyticsTableColumn.builder()
.name(category.getUid())
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(CHARACTER_11)
.selectExpression("acs." + quote(category.getUid()))
.created(category.getCreated())
Expand Down Expand Up @@ -496,7 +496,7 @@ private List<AnalyticsTableColumn> getColumnForDataElement(
columns.add(
AnalyticsTableColumn.builder()
.name(dataElement.getUid())
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(dataType)
.selectExpression(sql)
.skipIndex(skipIndex)
Expand All @@ -523,7 +523,7 @@ private List<AnalyticsTableColumn> getColumnForOrgUnitDataElement(
columns.add(
AnalyticsTableColumn.builder()
.name((dataElement.getUid() + OU_GEOMETRY_COL_SUFFIX))
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(GEOMETRY)
.selectExpression(geoSql)
.indexType(IndexType.GIST)
Expand All @@ -536,7 +536,7 @@ private List<AnalyticsTableColumn> getColumnForOrgUnitDataElement(
columns.add(
AnalyticsTableColumn.builder()
.name((dataElement.getUid() + OU_NAME_COL_SUFFIX))
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(TEXT)
.selectExpression(ouNameSql)
.skipIndex(SKIP)
Expand All @@ -562,7 +562,7 @@ private List<AnalyticsTableColumn> getColumnForTrackedEntityAttribute(
columns.add(
AnalyticsTableColumn.builder()
.name(attribute.getUid())
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(dataType)
.selectExpression(sql)
.skipIndex(skipIndex)
Expand Down Expand Up @@ -633,7 +633,7 @@ private List<AnalyticsTableColumn> getColumnsForOrgUnitTrackedEntityAttribute(
columns.add(
AnalyticsTableColumn.builder()
.name((attribute.getUid() + OU_GEOMETRY_COL_SUFFIX))
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(GEOMETRY)
.selectExpression(geoSql)
.indexType(IndexType.GIST)
Expand All @@ -646,7 +646,7 @@ private List<AnalyticsTableColumn> getColumnsForOrgUnitTrackedEntityAttribute(
columns.add(
AnalyticsTableColumn.builder()
.name((attribute.getUid() + OU_NAME_COL_SUFFIX))
.columnType(AnalyticsColumnType.DYNAMIC)
.dimensionType(AnalyticsDimensionType.DYNAMIC)
.dataType(TEXT)
.selectExpression(ouNameSql)
.skipIndex(SKIP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Represents a type of dimension, either static, meaning fixed, or dynamic, meaning based on a
* dimensional configuration entity.
*/
public enum AnalyticsColumnType {
public enum AnalyticsDimensionType {
STATIC,
DYNAMIC;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public class AnalyticsTableColumn {
@Builder.Default private final List<String> indexColumns = List.of();

/** The column type indicates the column origin. */
@Builder.Default private final AnalyticsColumnType columnType = AnalyticsColumnType.STATIC;
@Builder.Default
private final AnalyticsDimensionType dimensionType = AnalyticsDimensionType.STATIC;

/** Date of creation of the underlying data dimension. */
private final Date created;
Expand Down Expand Up @@ -104,8 +105,8 @@ public boolean isSkipIndex() {
}

/** Indicates whether the column type is set to a non-default value. */
public boolean isStatic() {
return AnalyticsColumnType.STATIC == columnType;
public boolean isStaticDimension() {
return AnalyticsDimensionType.STATIC == dimensionType;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static void maybeAddTextLowerIndex(
boolean isSingleColumn = indexColumns.size() == 1;

if (column.getDataType() == TEXT
&& !column.isStatic()
&& !column.isStaticDimension()
&& isValidUid(columnName)
&& isSingleColumn) {
String name = indexName + "_lower";
Expand All @@ -178,7 +178,7 @@ private static void maybeAddDateSortOrderIndex(

boolean isSingleColumn = indexColumns.size() == 1;

if (column.getDataType() == TIMESTAMP && column.isStatic() && isSingleColumn) {
if (column.getDataType() == TIMESTAMP && column.isStaticDimension() && isSingleColumn) {
indexes.add(
Index.builder()
.name(indexName + "_desc")
Expand Down
Loading