use of org.hisp.dhis.organisationunit.OrganisationUnitLevel in project dhis2-core by dhis2.
the class JdbcValidationResultTableManager method getDimensionColumns.
private List<AnalyticsTableColumn> getDimensionColumns() {
List<AnalyticsTableColumn> columns = new ArrayList<>();
List<OrganisationUnitGroupSet> orgUnitGroupSets = idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class);
List<OrganisationUnitLevel> levels = organisationUnitService.getFilledOrganisationUnitLevels();
List<Category> attributeCategories = categoryService.getAttributeDataDimensionCategoriesNoAcl();
for (OrganisationUnitGroupSet groupSet : orgUnitGroupSets) {
columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "ougs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
}
for (OrganisationUnitLevel level : levels) {
String column = quote(PREFIX_ORGUNITLEVEL + level.getLevel());
columns.add(new AnalyticsTableColumn(column, CHARACTER_11, "ous." + column).withCreated(level.getCreated()));
}
for (Category category : attributeCategories) {
columns.add(new AnalyticsTableColumn(quote(category.getUid()), CHARACTER_11, "acs." + quote(category.getUid())).withCreated(category.getCreated()));
}
for (PeriodType periodType : PeriodType.getAvailablePeriodTypes()) {
String column = quote(periodType.getName().toLowerCase());
columns.add(new AnalyticsTableColumn(column, TEXT, "ps." + column));
}
columns.addAll(getFixedColumns());
return filterDimensionColumns(columns);
}
use of org.hisp.dhis.organisationunit.OrganisationUnitLevel in project dhis2-core by dhis2.
the class JdbcAnalyticsTableManager method getApprovalJoinClause.
/**
* Returns sub-query for approval level. First looks for approval level in
* data element resource table which will indicate level 0 (highest) if
* approval is not required. Then looks for highest level in dataapproval
* table.
*
* @param year the data year.
*/
private String getApprovalJoinClause(Integer year) {
if (isApprovalEnabled(year)) {
String sql = "left join _dataapprovalminlevel da " + "on des.workflowid=da.workflowid and da.periodid=dv.periodid " + "and da.attributeoptioncomboid=dv.attributeoptioncomboid " + "and (";
Set<OrganisationUnitLevel> levels = dataApprovalLevelService.getOrganisationUnitApprovalLevels();
for (OrganisationUnitLevel level : levels) {
sql += "ous.idlevel" + level.getLevel() + " = da.organisationunitid or ";
}
return TextUtils.removeLastOr(sql) + ") ";
}
return StringUtils.EMPTY;
}
use of org.hisp.dhis.organisationunit.OrganisationUnitLevel in project dhis2-core by dhis2.
the class JdbcCompletenessTargetTableManager method getDimensionColumns.
private List<AnalyticsTableColumn> getDimensionColumns() {
List<AnalyticsTableColumn> columns = new ArrayList<>();
List<OrganisationUnitGroupSet> orgUnitGroupSets = idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class);
List<OrganisationUnitLevel> levels = organisationUnitService.getFilledOrganisationUnitLevels();
List<CategoryOptionGroupSet> attributeCategoryOptionGroupSets = categoryService.getAttributeCategoryOptionGroupSetsNoAcl();
List<Category> attributeCategories = categoryService.getAttributeDataDimensionCategoriesNoAcl();
for (OrganisationUnitGroupSet groupSet : orgUnitGroupSets) {
columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "ougs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
}
for (OrganisationUnitLevel level : levels) {
String column = quote(PREFIX_ORGUNITLEVEL + level.getLevel());
columns.add(new AnalyticsTableColumn(column, CHARACTER_11, "ous." + column).withCreated(level.getCreated()));
}
for (CategoryOptionGroupSet groupSet : attributeCategoryOptionGroupSets) {
columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "acs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
}
for (Category category : attributeCategories) {
columns.add(new AnalyticsTableColumn(quote(category.getUid()), CHARACTER_11, "acs." + quote(category.getUid())).withCreated(category.getCreated()));
}
columns.addAll(getFixedColumns());
return filterDimensionColumns(columns);
}
use of org.hisp.dhis.organisationunit.OrganisationUnitLevel in project dhis2-core by dhis2.
the class DefaultDataApprovalLevelService method getAllDataApprovalLevels.
@Override
@Transactional(readOnly = true)
public List<DataApprovalLevel> getAllDataApprovalLevels() {
List<DataApprovalLevel> dataApprovalLevels = dataApprovalLevelStore.getAllDataApprovalLevels();
for (DataApprovalLevel dataApprovalLevel : dataApprovalLevels) {
int ouLevelNumber = dataApprovalLevel.getOrgUnitLevel();
OrganisationUnitLevel ouLevel = organisationUnitService.getOrganisationUnitLevelByLevel(ouLevelNumber);
String ouLevelName = ouLevel != null ? ouLevel.getName() : "Organisation unit level " + ouLevelNumber;
dataApprovalLevel.setOrgUnitLevelName(ouLevelName);
}
return dataApprovalLevels;
}
use of org.hisp.dhis.organisationunit.OrganisationUnitLevel in project dhis2-core by dhis2.
the class PredictionServiceTest method testPredictOrgUnitGroup.
@Test
void testPredictOrgUnitGroup() {
useDataValue(dataElementA, makeMonth(2021, 8), sourceA, 1);
useDataValue(dataElementA, makeMonth(2021, 8), sourceB, 2);
useDataValue(dataElementA, makeMonth(2021, 8), sourceC, 4);
useDataValue(dataElementA, makeMonth(2021, 8), sourceD, 8);
useDataValue(dataElementA, makeMonth(2021, 8), sourceE, 16);
useDataValue(dataElementA, makeMonth(2021, 8), sourceF, 32);
dataValueBatchHandler.flush();
Expression expression = new Expression("if(orgUnit.group( " + ouGroupA.getUid() + " , " + ouGroupB.getUid() + " ), #{" + dataElementA.getUid() + "}, 64)", "description", MissingValueStrategy.SKIP_IF_ALL_VALUES_MISSING);
Set<OrganisationUnitLevel> allLevels = Sets.newHashSet(orgUnitLevel1, orgUnitLevel2, orgUnitLevel3);
Predictor predictor = createPredictor(dataElementX, defaultCombo, "A", expression, null, periodTypeMonthly, allLevels, 1, 0, 0);
predictionService.predict(predictor, monthStart(2021, 8), monthStart(2021, 9), summary);
assertEquals("Pred 1 Ins 6 Upd 0 Del 0 Unch 0", shortSummary(summary));
assertEquals("1.0", getDataValue(dataElementX, defaultCombo, sourceA, makeMonth(2021, 8)));
assertEquals("64.0", getDataValue(dataElementX, defaultCombo, sourceB, makeMonth(2021, 8)));
assertEquals("4.0", getDataValue(dataElementX, defaultCombo, sourceC, makeMonth(2021, 8)));
assertEquals("56.0", getDataValue(dataElementX, defaultCombo, sourceD, makeMonth(2021, 8)));
assertEquals("64.0", getDataValue(dataElementX, defaultCombo, sourceE, makeMonth(2021, 8)));
assertEquals("32.0", getDataValue(dataElementX, defaultCombo, sourceF, makeMonth(2021, 8)));
}
Aggregations