review feedback

This commit is contained in:
Ken Stevens 2019-10-24 20:25:16 -04:00
parent 08472c1e3f
commit 4a2ed62357
9 changed files with 18 additions and 130 deletions

View File

@ -96,11 +96,6 @@ public enum RestSearchParameterTypeEnum {
*/
SPECIAL("special", "http://hl7.org/fhir/search-param-type"),
/**
* _source parameter
*/
SOURCE("string", "http://hl7.org/fhir/search-param-type"),
;
@ -124,7 +119,7 @@ public enum RestSearchParameterTypeEnum {
static {
for (RestSearchParameterTypeEnum next : RestSearchParameterTypeEnum.values()) {
if (next == HAS || next == SOURCE) {
if (next == HAS) {
continue;
}

View File

@ -98,10 +98,6 @@ public class ParameterUtil {
binder = new QueryParameterAndBinder(HasAndListParam.class,
Collections.<Class<? extends IQueryParameterType>>emptyList());
break;
case SOURCE:
binder = new QueryParameterAndBinder(SourceAndListParam.class,
Collections.<Class<? extends IQueryParameterType>>emptyList());
break;
}
// FIXME null access

View File

@ -1,41 +0,0 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.util.CoverageIgnore;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2019 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public class SourceAndListParam extends BaseAndListParam<SourceOrListParam> {
@Override
SourceOrListParam newInstance() {
return new SourceOrListParam();
}
@CoverageIgnore
@Override
public SourceAndListParam addAnd(SourceOrListParam theValue) {
addValue(theValue);
return this;
}
}

View File

@ -1,41 +0,0 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.util.CoverageIgnore;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2019 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public class SourceOrListParam extends BaseOrListParam<SourceOrListParam, SourceParam> {
@CoverageIgnore
@Override
SourceParam newInstance() {
return new SourceParam();
}
@CoverageIgnore
@Override
public SourceOrListParam addOr(SourceParam theParameter) {
add(theParameter);
return this;
}
}

View File

@ -39,6 +39,7 @@ import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.ResourceMetaParams;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
import ca.uhn.fhir.jpa.searchparam.util.SourceParam;
import ca.uhn.fhir.jpa.term.VersionIndependentConcept;
import ca.uhn.fhir.jpa.term.api.ITermReadSvc;
import ca.uhn.fhir.jpa.util.*;
@ -1270,7 +1271,6 @@ public class SearchBuilder implements ISearchBuilder {
retVal = createPredicateQuantity(leftValue, theResourceName, theParam.getName(), myBuilder, dateJoin);
break;
}
case SOURCE:
case COMPOSITE:
case HAS:
case NUMBER:
@ -2999,9 +2999,6 @@ public class SearchBuilder implements ISearchBuilder {
case REFERENCE:
qp = new ReferenceParam();
break;
case SOURCE:
qp = new SourceParam();
break;
case SPECIAL:
case URI:
case HAS:

View File

@ -113,7 +113,7 @@ public class MatchUrlService {
type.setValuesAsQueryTokens(myContext, nextParamName, (paramList));
paramMap.add(nextParamName, type);
} else if (Constants.PARAM_SOURCE.equals(nextParamName)) {
IQueryParameterAnd<?> param = ParameterUtil.parseQueryParams(myContext, RestSearchParameterTypeEnum.SOURCE, nextParamName, paramList);
IQueryParameterAnd<?> param = ParameterUtil.parseQueryParams(myContext, RestSearchParameterTypeEnum.TOKEN, nextParamName, paramList);
paramMap.add(nextParamName, param);
} else if (nextParamName.startsWith("_")) {
// ignore these since they aren't search params (e.g. _sort)

View File

@ -27,10 +27,14 @@ import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams;
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
import ca.uhn.fhir.jpa.searchparam.util.SourceParam;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.param.*;
import ca.uhn.fhir.rest.param.BaseParamWithPrefix;
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
import ca.uhn.fhir.rest.param.ReferenceParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.util.MetaUtil;
import ca.uhn.fhir.util.UrlUtil;

View File

@ -1,7 +1,5 @@
package ca.uhn.fhir.rest.param;
package ca.uhn.fhir.jpa.searchparam.util;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.rest.api.Constants;
import static org.apache.commons.lang3.StringUtils.left;
@ -27,22 +25,16 @@ import static org.apache.commons.lang3.StringUtils.left;
*/
/**
* Implementation of the _has method parameter
* Model of the _source parameter
*/
public class SourceParam extends BaseParam implements IQueryParameterType {
public class SourceParam {
private static final long serialVersionUID = 1L;
private String myParameterValue;
private String mySourceUri;
private String myRequestId;
public SourceParam() {}
private final String myParameterValue;
private final String mySourceUri;
private final String myRequestId;
public SourceParam(String theParameterValue) {
setValue(theParameterValue);
}
private void setValue(String theParameterValue) {
myParameterValue = theParameterValue;
String requestId;
int lastHashValueIndex = theParameterValue.lastIndexOf('#');
@ -50,7 +42,9 @@ public class SourceParam extends BaseParam implements IQueryParameterType {
mySourceUri = theParameterValue;
requestId = null;
} else {
if (lastHashValueIndex != 0) {
if (lastHashValueIndex == 0) {
mySourceUri = null;
} else {
mySourceUri = theParameterValue.substring(0, lastHashValueIndex);
}
requestId = theParameterValue.substring(lastHashValueIndex + 1);
@ -58,21 +52,6 @@ public class SourceParam extends BaseParam implements IQueryParameterType {
myRequestId = left(requestId, Constants.REQUEST_ID_LENGTH);
}
@Override
String doGetQueryParameterQualifier() {
return null;
}
@Override
String doGetValueAsQueryToken(FhirContext theContext) {
return myParameterValue;
}
@Override
void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) {
setValue(theValue);
}
public String getSourceUri() {
return mySourceUri;
}

View File

@ -44,8 +44,7 @@ public class InMemoryResourceMatcherR5Test {
private static final String TEST_SOURCE = SOURCE_URI + "#" + REQUEST_ID;
@Autowired
private
InMemoryResourceMatcher myInMemoryResourceMatcher;
private InMemoryResourceMatcher myInMemoryResourceMatcher;
@MockBean
ISearchParamRegistry mySearchParamRegistry;