Skip to content

Commit

Permalink
fix: formatting [DHIS2-18337]
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Nespolino <[email protected]>

fix: ou item names in visualization [DHIS2-18337] (#19523)

* fix: ou item names in visualization [DHIS2-18337]

Signed-off-by: Giuseppe Nespolino <[email protected]>

* fix: formatting [DHIS2-18337]

Signed-off-by: Giuseppe Nespolino <[email protected]>

---------

Signed-off-by: Giuseppe Nespolino <[email protected]>

(cherry picked from commit 476cb6e)
Signed-off-by: Giuseppe Nespolino <[email protected]>
  • Loading branch information
gnespolino committed Dec 19, 2024
1 parent 1dff744 commit 044eb41
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ public abstract class BaseAnalyticalObject extends BaseNameableObject implements

public static final int NONE = 0;

private static final BaseDimensionalItemObject USER_OU_ITEM_OBJ =
buildDimItemObj(KEY_USER_ORGUNIT, "User organisation unit");

private static final BaseDimensionalItemObject USER_OU_CHILDREN_ITEM_OBJ =
buildDimItemObj(KEY_USER_ORGUNIT_CHILDREN, "User organisation unit children");

private static final BaseDimensionalItemObject USER_OU_GRANDCHILDREN_ITEM_OBJ =
buildDimItemObj(KEY_USER_ORGUNIT_GRANDCHILDREN, "User organisation unit grand children");

public static final String NOT_A_VALID_DIMENSION = "Not a valid dimension: %s";

// -------------------------------------------------------------------------
Expand Down Expand Up @@ -242,6 +251,19 @@ public abstract void init(
List<OrganisationUnit> organisationUnitsInGroups,
I18nFormat format);

/**
* Returns the dimensional item object for the given dimension and name.
*
* @param uid the dimension uid.
* @param name the dimension name.
* @return the DimensionalObject.
*/
private static BaseDimensionalItemObject buildDimItemObj(String uid, String name) {
BaseDimensionalItemObject itemObj = new BaseDimensionalItemObject(uid);
itemObj.setName(name);
return itemObj;
}

@Override
public abstract void populateAnalyticalProperties();

Expand Down Expand Up @@ -639,15 +661,15 @@ protected Optional<DimensionalObject> getDimensionalObject(String dimension) {
ouList.addAll(transientOrganisationUnits);

if (userOrganisationUnit) {
ouList.add(new BaseDimensionalItemObject(KEY_USER_ORGUNIT));
ouList.add(USER_OU_ITEM_OBJ);
}

if (userOrganisationUnitChildren) {
ouList.add(new BaseDimensionalItemObject(KEY_USER_ORGUNIT_CHILDREN));
ouList.add(USER_OU_CHILDREN_ITEM_OBJ);
}

if (userOrganisationUnitGrandChildren) {
ouList.add(new BaseDimensionalItemObject(KEY_USER_ORGUNIT_GRANDCHILDREN));
ouList.add(USER_OU_GRANDCHILDREN_ITEM_OBJ);
}

if (organisationUnitLevels != null && !organisationUnitLevels.isEmpty()) {
Expand Down

0 comments on commit 044eb41

Please sign in to comment.