use of org.hisp.dhis.analytics.ColumnDataType in project dhis2-core by dhis2.
the class AbstractEventJdbcTableManager method addTrackedEntityAttributes.
protected List<AnalyticsTableColumn> addTrackedEntityAttributes(Program program) {
List<AnalyticsTableColumn> columns = new ArrayList<>();
for (TrackedEntityAttribute attribute : program.getNonConfidentialTrackedEntityAttributes()) {
ColumnDataType dataType = getColumnType(attribute.getValueType(), databaseInfo.isSpatialSupport());
String dataClause = attribute.isNumericType() ? getNumericClause() : attribute.isDateType() ? getDateClause() : "";
String select = getSelectClause(attribute.getValueType(), "value");
boolean skipIndex = skipIndex(attribute.getValueType(), attribute.hasOptionSet());
String sql = "(select " + select + " " + "from trackedentityattributevalue where trackedentityinstanceid=pi.trackedentityinstanceid " + "and trackedentityattributeid=" + attribute.getId() + dataClause + ")" + getClosingParentheses(select) + " as " + quote(attribute.getUid());
columns.add(new AnalyticsTableColumn(quote(attribute.getUid()), dataType, sql).withSkipIndex(skipIndex));
}
return columns;
}
use of org.hisp.dhis.analytics.ColumnDataType in project dhis2-core by dhis2.
the class JdbcEventAnalyticsTableManager method getColumnFromTrackedEntityAttribute.
private List<AnalyticsTableColumn> getColumnFromTrackedEntityAttribute(TrackedEntityAttribute attribute, String numericClause, String dateClause, boolean withLegendSet) {
List<AnalyticsTableColumn> columns = new ArrayList<>();
ColumnDataType dataType = getColumnType(attribute.getValueType(), databaseInfo.isSpatialSupport());
String dataClause = attribute.isNumericType() ? numericClause : attribute.isDateType() ? dateClause : "";
String select = getSelectClause(attribute.getValueType(), "value");
String sql = selectForInsert(attribute, select, dataClause);
boolean skipIndex = skipIndex(attribute.getValueType(), attribute.hasOptionSet());
if (attribute.getValueType().isOrganisationUnit()) {
columns.addAll(getColumnsFromOrgUnitTrackedEntityAttribute(attribute, dataClause));
}
columns.add(new AnalyticsTableColumn(quote(attribute.getUid()), dataType, sql).withSkipIndex(skipIndex));
return withLegendSet ? getColumnFromTrackedEntityAttributeWithLegendSet(attribute, numericClause) : columns;
}
use of org.hisp.dhis.analytics.ColumnDataType in project dhis2-core by dhis2.
the class JdbcEventAnalyticsTableManager method getColumnFromDataElement.
private List<AnalyticsTableColumn> getColumnFromDataElement(DataElement dataElement, boolean withLegendSet) {
List<AnalyticsTableColumn> columns = new ArrayList<>();
ColumnDataType dataType = getColumnType(dataElement.getValueType(), databaseInfo.isSpatialSupport());
String dataClause = getDataClause(dataElement.getUid(), dataElement.getValueType());
String columnName = "eventdatavalues #>> '{" + dataElement.getUid() + ", value}'";
String select = getSelectClause(dataElement.getValueType(), columnName);
String sql = selectForInsert(dataElement, select, dataClause);
boolean skipIndex = skipIndex(dataElement.getValueType(), dataElement.hasOptionSet());
if (dataElement.getValueType().isOrganisationUnit()) {
columns.addAll(getColumnFromOrgUnitDataElement(dataElement, dataClause));
}
columns.add(new AnalyticsTableColumn(quote(dataElement.getUid()), dataType, sql).withSkipIndex(skipIndex));
return withLegendSet ? getColumnFromDataElementWithLegendSet(dataElement, select, dataClause) : columns;
}
Aggregations