Skip to content

Commit

Permalink
fix: ou item names in visualization [DHIS2-18337] (#19523)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
gnespolino authored Dec 18, 2024
1 parent e5a7530 commit 476cb6e
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@
@JacksonXmlRootElement(localName = "analyticalObject", namespace = DxfNamespaces.DXF_2_0)
public abstract class BaseAnalyticalObject extends BaseNameableObject implements AnalyticalObject {

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";

/** Line and axis labels. */
Expand Down Expand Up @@ -320,6 +329,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 @@ -700,15 +722,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 476cb6e

Please sign in to comment.