Search in sources :

Example 1 with ColumnDataType

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;
}
Also used : TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) ColumnDataType(org.hisp.dhis.analytics.ColumnDataType) ArrayList(java.util.ArrayList) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn)

Example 2 with ColumnDataType

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;
}
Also used : ColumnDataType(org.hisp.dhis.analytics.ColumnDataType) ArrayList(java.util.ArrayList) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) DateUtils.getLongDateString(org.hisp.dhis.util.DateUtils.getLongDateString)

Example 3 with ColumnDataType

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;
}
Also used : ColumnDataType(org.hisp.dhis.analytics.ColumnDataType) ArrayList(java.util.ArrayList) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) DateUtils.getLongDateString(org.hisp.dhis.util.DateUtils.getLongDateString)

Aggregations

ArrayList (java.util.ArrayList)3 AnalyticsTableColumn (org.hisp.dhis.analytics.AnalyticsTableColumn)3 ColumnDataType (org.hisp.dhis.analytics.ColumnDataType)3 DateUtils.getLongDateString (org.hisp.dhis.util.DateUtils.getLongDateString)2 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)1