Fix up operation param types, fix bug in link builder

This commit is contained in:
Tadgh 2021-06-30 23:17:04 -04:00
parent 1eb82d633d
commit 0893ba0039
3 changed files with 12 additions and 13 deletions

View File

@ -49,6 +49,7 @@ public final class MdmPageLinkBuilder {
builder.append("?"); builder.append("?");
} }
builder.append(PARAM_OFFSET).append("=").append(theOffset); builder.append(PARAM_OFFSET).append("=").append(theOffset);
builder.append("&");
builder.append(PARAM_COUNT).append("=").append(theCount); builder.append(PARAM_COUNT).append("=").append(theCount);
return builder.toString(); return builder.toString();
} }

View File

@ -4,6 +4,7 @@ import ca.uhn.fhir.rest.server.IPagingProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu3.model.UnsignedIntType; import org.hl7.fhir.dstu3.model.UnsignedIntType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
@ -24,7 +25,7 @@ public class MdmPageRequest {
private final int myOffset; private final int myOffset;
private final int myCount; private final int myCount;
public MdmPageRequest(@Nullable UnsignedIntType theOffset, @Nullable UnsignedIntType theCount, int theDefaultPageSize, int theMaximumPageSize) { public MdmPageRequest(@Nullable IPrimitiveType<Integer> theOffset, @Nullable IPrimitiveType<Integer> theCount, int theDefaultPageSize, int theMaximumPageSize) {
myOffset = theOffset == null ? 0 : theOffset.getValue(); myOffset = theOffset == null ? 0 : theOffset.getValue();
myCount = theCount == null ? theDefaultPageSize : Math.min(theCount.getValue(), theMaximumPageSize); myCount = theCount == null ? theDefaultPageSize : Math.min(theCount.getValue(), theMaximumPageSize);
validatePagingParameters(myOffset, myCount); validatePagingParameters(myOffset, myCount);

View File

@ -31,20 +31,18 @@ import ca.uhn.fhir.mdm.api.MdmLinkJson;
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest; import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.model.MdmTransactionContext;
import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.primitive.IntegerDt;
import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam; import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.IPagingProvider;
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.provider.ProviderConstants; import ca.uhn.fhir.rest.server.provider.ProviderConstants;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.BundleBuilder; import ca.uhn.fhir.util.BundleBuilder;
import ca.uhn.fhir.util.ParametersUtil; import ca.uhn.fhir.util.ParametersUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu3.model.UnsignedIntType;
import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement; import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
@ -207,11 +205,11 @@ public class MdmProviderDstu3Plus extends BaseMdmProvider {
IPrimitiveType<String> theLinkSource, IPrimitiveType<String> theLinkSource,
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.") @Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.")
@OperationParam(name = PARAM_OFFSET, min = 0, max = 1) @OperationParam(name = PARAM_OFFSET, min = 0, max = 1, typeName = "integer")
UnsignedIntType theOffset, IPrimitiveType<Integer> theOffset,
@Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.") @Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
@OperationParam(name = Constants.PARAM_COUNT, min = 0, max = 1) @OperationParam(name = Constants.PARAM_COUNT, min = 0, max = 1, typeName = "integer")
UnsignedIntType theCount, IPrimitiveType<Integer> theCount,
ServletRequestDetails theRequestDetails) { ServletRequestDetails theRequestDetails) {
MdmPageRequest mdmPageRequest = new MdmPageRequest(theOffset, theCount, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE); MdmPageRequest mdmPageRequest = new MdmPageRequest(theOffset, theCount, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
@ -223,15 +221,14 @@ public class MdmProviderDstu3Plus extends BaseMdmProvider {
return parametersFromMdmLinks(mdmLinkJson, true, theRequestDetails, mdmPageRequest); return parametersFromMdmLinks(mdmLinkJson, true, theRequestDetails, mdmPageRequest);
} }
@Operation(name = ProviderConstants.MDM_DUPLICATE_GOLDEN_RESOURCES, idempotent = true) @Operation(name = ProviderConstants.MDM_DUPLICATE_GOLDEN_RESOURCES, idempotent = true)
public IBaseParameters getDuplicateGoldenResources( public IBaseParameters getDuplicateGoldenResources(
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.") @Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.")
@OperationParam(name = PARAM_OFFSET, min = 0, max = 1) @OperationParam(name = PARAM_OFFSET, min = 0, max = 1, typeName = "integer")
UnsignedIntType theOffset, IPrimitiveType<Integer> theOffset,
@Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.") @Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
@OperationParam(name = Constants.PARAM_COUNT, min = 0, max = 1) @OperationParam(name = Constants.PARAM_COUNT, min = 0, max = 1, typeName = "integer")
UnsignedIntType theCount, IPrimitiveType<Integer> theCount,
ServletRequestDetails theRequestDetails) { ServletRequestDetails theRequestDetails) {
MdmPageRequest mdmPageRequest = new MdmPageRequest(theOffset, theCount, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE); MdmPageRequest mdmPageRequest = new MdmPageRequest(theOffset, theCount, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);