Skip to content

Commit

Permalink
AMP-30891-Filter indicators by program
Browse files Browse the repository at this point in the history
  • Loading branch information
brianbrix committed Jun 12, 2024
1 parent 5e0213a commit 11687b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static void processThemeWithChildren(AmpTheme theme, Set<AmpTheme> allThe
}


private List<BigInteger> getProgramIds(Long indicatorId) {
public static List<BigInteger> getProgramIds(Long indicatorId) {
Session session = PersistenceManager.getRequestDBSession();
String sql = "SELECT theme_id FROM AMP_INDICATOR_CONNECTION " +
"WHERE indicator_id = :indicatorId AND sub_clazz='p'";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigInteger;
import java.util.List;
import java.util.Set;

Expand All @@ -16,14 +17,14 @@ public class IndicatorExtraInfo {
private final List<Long> sectorIds;


public List<Long> getProgramIds() {
public List<BigInteger> getProgramIds() {
return programIds;
}

@JsonProperty("program-ids")
private final List<Long> programIds;
private final List<BigInteger> programIds;

public IndicatorExtraInfo(String code, List<Long> sectorIds, List<Long> programIds) {
public IndicatorExtraInfo(String code, List<Long> sectorIds, List<BigInteger> programIds) {
this.code = code;
this.sectorIds = sectorIds;
this.programIds = programIds;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.digijava.kernel.ampapi.endpoints.activity.values;

import com.google.common.collect.ImmutableMap;
import org.digijava.kernel.ampapi.endpoints.activity.AmpPossibleValuesDAO;
import org.digijava.kernel.ampapi.endpoints.activity.IndicatorExtraInfo;
import org.digijava.kernel.ampapi.endpoints.activity.PossibleValue;
import org.digijava.kernel.ampapi.endpoints.common.TranslatorService;
Expand All @@ -15,6 +16,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand All @@ -33,7 +35,7 @@ public List<PossibleValue> getPossibleValues(TranslatorService translatorService
for (AmpIndicator indicator : indicators) {
logger.info("Indicator: "+indicator);
List<Long> sectorIds = getSectorIds(indicator.getSectors());
List<Long> programIds = getProgramIds(indicator.getIndicatorId());
List<BigInteger> programIds = AmpPossibleValuesDAO.getProgramIds(indicator.getIndicatorId());
IndicatorExtraInfo extraInfo = new IndicatorExtraInfo(indicator.getCode(), sectorIds, programIds);
pvs.add(new PossibleValue(indicator.getIndicatorId(), indicator.getName(), ImmutableMap.of(), extraInfo));
}
Expand Down

0 comments on commit 11687b6

Please sign in to comment.