Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.common.UID;

@Getter
@Setter
Expand All @@ -57,7 +58,7 @@ public class SourceRequest implements Serializable {
@JsonProperty private List<String> pe = new ArrayList<>();

/** Org unit identifiers. */
@JsonProperty private List<String> ou = new ArrayList<>();
@JsonProperty private List<UID> ou = new ArrayList<>();

/** Request filters. */
@JsonProperty private List<Filter> filters = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.IdScheme;
import org.hisp.dhis.common.IllegalQueryException;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.dataexchange.client.Dhis2Client;
import org.hisp.dhis.datavalue.DataEntryGroup;
import org.hisp.dhis.datavalue.DataEntryPipeline;
Expand Down Expand Up @@ -361,7 +362,8 @@ DataQueryParams toDataQueryParams(SourceRequest request, SourceDataQueryParams p
return DataQueryParams.newBuilder()
.addDimension(toDimensionalObject(DATA_X_DIM_ID, request.getDx(), inputIdScheme))
.addDimension(toDimensionalObject(PERIOD_DIM_ID, request.getPe(), inputIdScheme))
.addDimension(toDimensionalObject(ORGUNIT_DIM_ID, request.getOu(), inputIdScheme))
.addDimension(
toDimensionalObject(ORGUNIT_DIM_ID, UID.toValueList(request.getOu()), inputIdScheme))
.addFilters(filters)
.withAggregationType(toAnalyticsAggregationType(request.getAggregationType()))
.withOutputDataElementIdScheme(outputDataElementIdScheme)
Expand Down Expand Up @@ -500,7 +502,9 @@ private static String toStageDescription(AggregateDataExchange exchange) {
private static String toItemDescription(SourceRequest request) {
return format(
"dx: %s; pe: %s; ou: %s",
join(",", request.getDx()), join(",", request.getPe()), join(",", request.getOu()));
join(",", request.getDx()),
join(",", request.getPe()),
join(",", UID.toValueList(request.getOu())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.hisp.dhis.common.DisplayProperty;
import org.hisp.dhis.common.IdScheme;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.dataexchange.client.Dhis2Client;
import org.hisp.dhis.datavalue.DataExportService;
import org.hisp.dhis.dxf2.common.ImportOptions;
Expand Down Expand Up @@ -121,7 +122,7 @@ void testToDataQueryParams() {
.setName("SourceRequestA")
.setDx(List.of("Vz0C3i4Wy3M", "ToaOToReol6"))
.setPe(List.of("202101", "202102"))
.setOu(List.of("lGgJFgRkZui", "pvINfKxtqyN", "VOyqQ54TehY"))
.setOu(List.of(UID.of("lGgJFgRkZui"), UID.of("pvINfKxtqyN"), UID.of("VOyqQ54TehY")))
.setAggregationType(AggregationType.COUNT)
.setOutputDataElementIdScheme(IdScheme.UID.name())
.setOutputOrgUnitIdScheme(IdScheme.CODE.name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import org.hisp.dhis.common.IllegalQueryException;
import org.hisp.dhis.common.OrganisationUnitDescendants;
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.common.UserOrgUnitType;
import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.common.cache.CacheStrategy;
Expand Down Expand Up @@ -462,7 +463,7 @@ public static AggregateDataExchange getAggregateDataExchange(char uniqueCharacte
.setVisualization("JHKuBWP20RO")
.setDx(newArrayList("LrDpG50RAU9", "uR5HCiJhQ1w"))
.setPe(newArrayList("202201", "202202"))
.setOu(newArrayList("G9BuXqtNeeb", "jDgiLmYwPDm"))
.setOu(newArrayList(UID.of("G9BuXqtNeeb"), UID.of("jDgiLmYwPDm")))
.setFilters(
newArrayList(
new Filter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,21 @@ void testPatchAggregateDataExchange() {
assertEquals("External basic auth data exchange updated", object.getString("name").string());
}

@Test
@DisplayName("Should return conflict when source request ou contains an invalid UID")
void testSourceRequestOuInvalidUid() {
JsonWebMessage message =
assertWebMessage(
HttpStatus.CONFLICT,
POST(
"/metadata/",
"{'aggregateDataExchanges': [{'id': 'iFOyIpQciyk', 'name': 'Test exchange',"
+ "'source': {'requests': [{'name': 'R1',"
+ "'dx': ['fbfJHSPpUQD'], 'pe': ['202201'], 'ou': ['1nvalidUid']}]},"
+ "'target': {'type': 'INTERNAL'}}]}"));
assertTrue(message.getMessage().contains("1nvalidUid"));
}

@Test
@DisplayName(
"Should return error E6305 if create a new AggregateDataExchange without authentication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.hisp.dhis.dxf2.webmessage.WebMessageUtils.unauthorized;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.RuntimeJsonMappingException;
import io.github.classgraph.ClassGraph;
import jakarta.persistence.PersistenceException;
Expand Down Expand Up @@ -400,6 +401,7 @@ public WebMessage dataApprovalExceptionHandler(Exception ex) {

@ExceptionHandler({
JsonParseException.class,
JsonMappingException.class,
MetadataImportException.class,
MetadataExportException.class
})
Expand Down
Loading