Skip to content
Merged
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 @@ -56,6 +56,8 @@
import io.javalin.plugin.openapi.annotations.OpenApiContent;
import io.javalin.plugin.openapi.annotations.OpenApiParam;
import io.javalin.plugin.openapi.annotations.OpenApiResponse;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;
Expand All @@ -64,7 +66,7 @@ public final class PublishedController implements CrudHandler {
private static final String TAG = "Published";
private final MetricRegistry metrics;
private final Histogram requestResultSize;
private static final int DEFAULT_PAGE_SIZE = 20;
private static final int DEFAULT_PAGE_SIZE = 500;

public PublishedController(MetricRegistry metrics) {
this.metrics = metrics;
Expand Down Expand Up @@ -95,7 +97,8 @@ public void delete(@NotNull Context context, @NotNull String s) {
@OpenApi(
queryParams = {
@OpenApiParam(name = OFFICE_MASK, description = "Office Id used to filter the results."),
@OpenApiParam(name = LOCATION_MASK, description = "Location Id used to filter the results."),
@OpenApiParam(name = LOCATION_MASK, description = "A pipe-separated list of Location IDs used to filter the results. "
+ "For example, 'AARK|ADDI'."),
@OpenApiParam(name = PAGE,
description = "This end point can return a lot of data, this "
+ "identifies where in the request you are. This is an opaque "
Expand Down Expand Up @@ -131,7 +134,8 @@ public void getAll(@NotNull Context ctx) {
try (Timer.Context ignored = markAndTime(GET_ALL)) {
DSLContext dsl = getDslContext(ctx);
PublishedTimeSeriesDao dao = new PublishedTimeSeriesDao(dsl);
PublishedRetrievalParameters retrievalParams = new PublishedRetrievalParameters(locationIdMask, officeIdMask);
List<String> locationIds = locationIdMask != null ? Arrays.asList(locationIdMask.split("\\|")) : null;
PublishedRetrievalParameters retrievalParams = new PublishedRetrievalParameters(locationIds, officeIdMask);
LocationToPublishedDataList result = dao.retrievePublishedTimeSeriesIds(retrievalParams, cursor, pageSize);

String formatHeader = ctx.header(Header.ACCEPT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
* SOFTWARE.
*/
package cwms.cda.data.dao;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public class PublishedRetrievalParameters {
private final String locationIdsMask;
private final List<String> locationIds;
private final String officeIdsMask;

public PublishedRetrievalParameters(String locationIdsMask, String officeIdsMask) {
this.locationIdsMask = locationIdsMask;
public PublishedRetrievalParameters(List<String> locationIds, String officeIdsMask) {
this.locationIds = locationIds != null ? Collections.unmodifiableList(locationIds) : Collections.emptyList();
this.officeIdsMask = officeIdsMask;
}

public Optional<String> getLocationId() {
return Optional.ofNullable(locationIdsMask);
public List<String> getLocationIds() {
return locationIds;
}

public Optional<String> getOfficeId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfile;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -64,7 +63,11 @@ public LocationToPublishedDataList retrievePublishedTimeSeriesIds(PublishedRetri
String cursorLocId = null;

Condition officeCondition = caseInsensitiveLikeRegexNullTrue(AV_A2W_TS_CODES_BY_LOC2.DB_OFFICE_ID, retrievalParameters.getOfficeId().orElse("*"));
Condition locationCondition = caseInsensitiveLikeRegexNullTrue(AV_A2W_TS_CODES_BY_LOC2.LOCATION_ID, retrievalParameters.getLocationId().orElse("*"));
Condition locationCondition = noCondition();
List<String> locationIds = retrievalParameters.getLocationIds();
if (locationIds != null && !locationIds.isEmpty()) {
locationCondition = upper(AV_A2W_TS_CODES_BY_LOC2.LOCATION_ID).in(locationIds.stream().map(String::toUpperCase).collect(toList()));
}

Condition whereClause = locationCondition.and(officeCondition);

Expand Down
Loading