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;
}
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);
}
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;
}
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;
}
Aggregations