Skip to content

Commit

Permalink
fix: Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge committed Nov 26, 2024
1 parent 490ea09 commit 781d2e4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
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

0 comments on commit 781d2e4

Please sign in to comment.