use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class TypedIndexedObjectContainerTest method getContainerExisting.
@Test
void getContainerExisting() {
final Attribute attribute1 = new Attribute();
final Category category1 = new Category();
container.mergeObjectIndex(new Attribute());
container.mergeObjectIndex(new Category());
container.mergeObjectIndex(attribute1);
container.mergeObjectIndex(category1);
IndexedObjectContainer container1 = container.getTypedContainer(Attribute.class);
Assertions.assertSame(1, container1.mergeObjectIndex(attribute1));
IndexedObjectContainer container2 = container.getTypedContainer(Category.class);
Assertions.assertSame(1, container2.mergeObjectIndex(category1));
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class TypedIndexedObjectContainerTest method add.
@Test
void add() {
final Attribute attribute1 = new Attribute();
final Attribute attribute2 = new Attribute();
final Attribute attribute3 = new Attribute();
final Category category1 = new Category();
final Category category2 = new Category();
container.add(attribute1);
container.add(attribute2);
container.add(attribute3);
container.add(category1);
container.add(category2);
Assertions.assertEquals((Integer) 0, container.mergeObjectIndex(attribute1));
Assertions.assertEquals((Integer) 1, container.mergeObjectIndex(attribute2));
Assertions.assertEquals((Integer) 2, container.mergeObjectIndex(attribute3));
Assertions.assertEquals((Integer) 0, container.mergeObjectIndex(category1));
Assertions.assertEquals((Integer) 1, container.mergeObjectIndex(category2));
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class JdbcEventAnalyticsTableManager method getDimensionColumns.
/**
* Returns dimensional analytics table columns.
*
* @param program the program.
* @return a list of {@link AnalyticsTableColumn}.
*/
private List<AnalyticsTableColumn> getDimensionColumns(Program program) {
List<AnalyticsTableColumn> columns = new ArrayList<>();
if (program.hasNonDefaultCategoryCombo()) {
List<Category> categories = program.getCategoryCombo().getCategories();
for (Category category : categories) {
if (category.isDataDimension()) {
columns.add(new AnalyticsTableColumn(quote(category.getUid()), CHARACTER_11, "acs." + quote(category.getUid())).withCreated(category.getCreated()));
}
}
}
columns.addAll(addOrganisationUnitLevels());
columns.addAll(addOrganisationUnitGroupSets());
columns.addAll(categoryService.getAttributeCategoryOptionGroupSetsNoAcl().stream().map(l -> toCharColumn(quote(l.getUid()), "acs", l.getCreated())).collect(Collectors.toList()));
columns.addAll(addPeriodTypeColumns("dps"));
columns.addAll(program.getAnalyticsDataElements().stream().map(de -> getColumnFromDataElement(de, false)).flatMap(Collection::stream).collect(Collectors.toList()));
columns.addAll(program.getAnalyticsDataElementsWithLegendSet().stream().map(de -> getColumnFromDataElement(de, true)).flatMap(Collection::stream).collect(Collectors.toList()));
columns.addAll(program.getNonConfidentialTrackedEntityAttributes().stream().map(tea -> getColumnFromTrackedEntityAttribute(tea, getNumericClause(), getDateClause(), false)).flatMap(Collection::stream).collect(Collectors.toList()));
columns.addAll(program.getNonConfidentialTrackedEntityAttributesWithLegendSet().stream().map(tea -> getColumnFromTrackedEntityAttribute(tea, getNumericClause(), getDateClause(), true)).flatMap(Collection::stream).collect(Collectors.toList()));
columns.addAll(getFixedColumns());
if (program.isRegistration()) {
columns.add(new AnalyticsTableColumn(quote("tei"), CHARACTER_11, "tei.uid"));
}
return filterDimensionColumns(columns);
}
use of org.hisp.dhis.category.Category 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.category.Category 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);
}
Aggregations