Skip to content

Commit

Permalink
fix: Always include default cat combo for data se metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge committed Dec 6, 2023
1 parent 20fa77f commit 8def023
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
import static org.hisp.dhis.commons.collection.CollectionUtils.addIfNotNull;
import static org.hisp.dhis.commons.collection.CollectionUtils.flatMapToSet;
import static org.hisp.dhis.commons.collection.CollectionUtils.mapToSet;
import static org.hisp.dhis.commons.collection.ListUtils.union;
import static org.hisp.dhis.commons.collection.ListUtils.distinctUnion;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -44,7 +42,7 @@
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;

import org.apache.commons.collections4.SetValuedMap;
import org.apache.commons.lang3.ObjectUtils;
import org.hisp.dhis.category.Category;
Expand Down Expand Up @@ -74,6 +72,11 @@
import org.hisp.dhis.util.DateUtils;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import lombok.RequiredArgsConstructor;

/**
* @author Lars Helge Overland
*/
Expand Down Expand Up @@ -138,7 +141,6 @@ public class DefaultDataSetMetadataExportService implements DataSetMetadataExpor
@Override
public ObjectNode getDataSetMetadata() {
User user = currentUserService.getCurrentUser();
CategoryCombo defaultCategoryCombo = categoryService.getDefaultCategoryCombo();
SetValuedMap<String, String> dataSetOrgUnits =
dataSetService.getDataSetOrganisationUnitsAssociations();

Expand All @@ -153,12 +155,13 @@ public ObjectNode getDataSetMetadata() {
sortById(flatMapToSet(dataElementCategoryCombos, CategoryCombo::getCategories));
List<Category> dataSetCategories =
sortById(flatMapToSet(dataSetCategoryCombos, CategoryCombo::getCategories));
List<Category> categories = union(dataElementCategories, dataSetCategories);
List<Category> categories = distinctUnion(dataElementCategories, dataSetCategories);
List<CategoryOption> categoryOptions =
sortById(getCategoryOptions(dataElementCategories, dataSetCategories, user));
List<OptionSet> optionSets = sortById(getOptionSets(dataElements));

dataSetCategoryCombos.removeAll( dataElementCategoryCombos );

dataSetCategoryCombos.remove(defaultCategoryCombo);
expressionService.substituteIndicatorExpressions(indicators);

ObjectNode rootNode = fieldFilterService.createObjectNode();
Expand Down

0 comments on commit 8def023

Please sign in to comment.