Search in sources :

Example 1 with IndicatorGroupSet

use of org.hisp.dhis.indicator.IndicatorGroupSet in project dhis2-core by dhis2.

the class DhisConvenienceTest method createIndicatorGroupSet.

/**
     * @param uniqueCharacter A unique character to identify the object.
     */
public static IndicatorGroupSet createIndicatorGroupSet(char uniqueCharacter) {
    IndicatorGroupSet groupSet = new IndicatorGroupSet();
    groupSet.setAutoFields();
    groupSet.setUid(BASE_UID + uniqueCharacter);
    groupSet.setName("IndicatorGroupSet" + uniqueCharacter);
    return groupSet;
}
Also used : IndicatorGroupSet(org.hisp.dhis.indicator.IndicatorGroupSet)

Example 2 with IndicatorGroupSet

use of org.hisp.dhis.indicator.IndicatorGroupSet in project dhis2-core by dhis2.

the class IndicatorGroupSetResourceTable method getPopulateTempTableStatement.

@Override
public Optional<String> getPopulateTempTableStatement() {
    String sql = "insert into " + getTempTableName() + " " + "select i.indicatorid as indicatorid, i.name as indicatorname, ";
    for (IndicatorGroupSet groupSet : objects) {
        sql += "(" + "select ig.name from indicatorgroup ig " + "inner join indicatorgroupmembers igm on igm.indicatorgroupid = ig.indicatorgroupid " + "inner join indicatorgroupsetmembers igsm on igsm.indicatorgroupid = igm.indicatorgroupid and igsm.indicatorgroupsetid = " + groupSet.getId() + " " + "where igm.indicatorid = i.indicatorid " + "limit 1) as " + columnQuote + groupSet.getName() + columnQuote + ", ";
        sql += "(" + "select ig.uid from indicatorgroup ig " + "inner join indicatorgroupmembers igm on igm.indicatorgroupid = ig.indicatorgroupid " + "inner join indicatorgroupsetmembers igsm on igsm.indicatorgroupid = igm.indicatorgroupid and igsm.indicatorgroupsetid = " + groupSet.getId() + " " + "where igm.indicatorid = i.indicatorid " + "limit 1) as " + columnQuote + groupSet.getUid() + columnQuote + ", ";
    }
    sql = TextUtils.removeLastComma(sql) + " ";
    sql += "from indicator i";
    return Optional.of(sql);
}
Also used : IndicatorGroupSet(org.hisp.dhis.indicator.IndicatorGroupSet)

Example 3 with IndicatorGroupSet

use of org.hisp.dhis.indicator.IndicatorGroupSet in project dhis2-core by dhis2.

the class IndicatorGroupSetResourceTable method getCreateTempTableStatement.

@Override
public String getCreateTempTableStatement() {
    String statement = "create table " + getTempTableName() + " (" + "indicatorid integer not null, " + "indicatorname varchar(230), ";
    for (IndicatorGroupSet groupSet : objects) {
        statement += columnQuote + groupSet.getName() + columnQuote + " varchar(230), ";
        statement += columnQuote + groupSet.getUid() + columnQuote + " character(11), ";
    }
    statement += "primary key (indicatorid))";
    return statement;
}
Also used : IndicatorGroupSet(org.hisp.dhis.indicator.IndicatorGroupSet)

Example 4 with IndicatorGroupSet

use of org.hisp.dhis.indicator.IndicatorGroupSet in project dhis2-core by dhis2.

the class DefaultDataIntegrityService method getIndicatorsViolatingExclusiveGroupSets.

@Override
public SortedMap<Indicator, Collection<IndicatorGroup>> getIndicatorsViolatingExclusiveGroupSets() {
    Collection<IndicatorGroupSet> groupSets = indicatorService.getAllIndicatorGroupSets();
    SortedMap<Indicator, Collection<IndicatorGroup>> targets = new TreeMap<>();
    for (IndicatorGroupSet groupSet : groupSets) {
        Collection<Indicator> duplicates = getDuplicates(new ArrayList<>(groupSet.getIndicators()));
        for (Indicator duplicate : duplicates) {
            targets.put(duplicate, duplicate.getGroups());
        }
    }
    return targets;
}
Also used : IndicatorGroupSet(org.hisp.dhis.indicator.IndicatorGroupSet) Collection(java.util.Collection) TreeMap(java.util.TreeMap) Indicator(org.hisp.dhis.indicator.Indicator)

Aggregations

IndicatorGroupSet (org.hisp.dhis.indicator.IndicatorGroupSet)4 Collection (java.util.Collection)1 TreeMap (java.util.TreeMap)1 Indicator (org.hisp.dhis.indicator.Indicator)1