Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Nov 6, 2024
1 parent 5484a88 commit 3cc1fb7
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2708,8 +2708,8 @@ private Condition createPredicateSearchParameter(
}

} else {
RuntimeSearchParam notEnabledForSearchParam =
mySearchParamRegistry.getActiveSearchParam(theResourceName, theParamName, ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
RuntimeSearchParam notEnabledForSearchParam = mySearchParamRegistry.getActiveSearchParam(
theResourceName, theParamName, ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
if (notEnabledForSearchParam == null) {
String msg = myFhirContext
.getLocalizer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ Parameters buildIndexResponse(
private void fillInParamNames(
ResourceTable theEntity, Collection<SearchParamPresentEntity> theTarget, String theResourceName) {
Map<Long, String> hashes = new HashMap<>();
ResourceSearchParams searchParams = mySearchParamRegistry.getActiveSearchParams(theResourceName, ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
ResourceSearchParams searchParams = mySearchParamRegistry.getActiveSearchParams(
theResourceName, ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
for (RuntimeSearchParam next : searchParams.values()) {
hashes.put(
SearchParamPresentEntity.calculateHashPresence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public SearchParamRegistryImpl() {

@Override
public RuntimeSearchParam getActiveSearchParam(
@Nonnull String theResourceName, @Nonnull String theParamName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull String theParamName,
@Nonnull SearchParamLookupContextEnum theContext) {
requiresActiveSearchParams();

// Can still be null in unit test scenarios
Expand All @@ -134,7 +136,8 @@ public RuntimeSearchParam getActiveSearchParam(

@Nonnull
@Override
public ResourceSearchParams getActiveSearchParams(@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
public ResourceSearchParams getActiveSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
requiresActiveSearchParams();
return getActiveSearchParams().getSearchParamMap(theResourceName).toFilteredForContext(theContext);
}
Expand All @@ -148,20 +151,24 @@ private void requiresActiveSearchParams() {

@Override
public List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
return filteredForContext(myJpaSearchParamCache.getActiveComboSearchParams(theResourceName), theContext);
}

@Override
public List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull ComboSearchParamType theParamType, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull ComboSearchParamType theParamType,
@Nonnull SearchParamLookupContextEnum theContext) {
return filteredForContext(
myJpaSearchParamCache.getActiveComboSearchParams(theResourceName, theParamType), theContext);
}

@Override
public List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull Set<String> theParamNames, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull Set<String> theParamNames,
@Nonnull SearchParamLookupContextEnum theContext) {
return filteredForContext(
myJpaSearchParamCache.getActiveComboSearchParams(theResourceName, theParamNames), theContext);
}
Expand All @@ -173,7 +180,8 @@ public Optional<IndexedSearchParam> getIndexedSearchParamByHashIdentity(Long the

@Nullable
@Override
public RuntimeSearchParam getActiveSearchParamByUrl(@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext) {
public RuntimeSearchParam getActiveSearchParamByUrl(
@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext) {
if (myActiveSearchParams != null) {
RuntimeSearchParam param = myActiveSearchParams.getByUrl(theUrl);
if (isAllowedForContext(param, theContext)) {
Expand All @@ -184,7 +192,8 @@ public RuntimeSearchParam getActiveSearchParamByUrl(@Nonnull String theUrl, @Non
}

@Override
public Optional<RuntimeSearchParam> getActiveComboSearchParamById(@Nonnull String theResourceName, @Nonnull IIdType theId) {
public Optional<RuntimeSearchParam> getActiveComboSearchParamById(
@Nonnull String theResourceName, @Nonnull IIdType theId) {
return myJpaSearchParamCache.getActiveComboSearchParamById(theResourceName, theId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public static List<RuntimeSearchParam> resolveCompositeComponentsDeclaredOrder(
List<RuntimeSearchParam.Component> components = theParamDef.getComponents();
for (RuntimeSearchParam.Component next : components) {
String url = next.getReference();
RuntimeSearchParam componentParam = theSearchParamRegistry.getActiveSearchParamByUrl(url, ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
RuntimeSearchParam componentParam = theSearchParamRegistry.getActiveSearchParamByUrl(
url, ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
if (componentParam == null) {
throw new InternalErrorException(Msg.code(499) + "Can not find SearchParameter: " + url);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public int doSyncSubscriptionsForUnitTest() {
protected SearchParameterMap getSearchParameterMap() {
SearchParameterMap map = new SearchParameterMap();

if (mySearchParamRegistry.getActiveSearchParam("Subscription", "status", ISearchParamRegistry.SearchParamLookupContextEnum.ALL) != null) {
if (mySearchParamRegistry.getActiveSearchParam(
"Subscription", "status", ISearchParamRegistry.SearchParamLookupContextEnum.ALL)
!= null) {
map.add(
Subscription.SP_STATUS,
new TokenOrListParam()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public void registerListener() {
protected SearchParameterMap getSearchParameterMap() {
SearchParameterMap map = new SearchParameterMap();

if (mySearchParamRegistry.getActiveSearchParam("SubscriptionTopic", "status", ISearchParamRegistry.SearchParamLookupContextEnum.ALL) != null) {
if (mySearchParamRegistry.getActiveSearchParam(
"SubscriptionTopic", "status", ISearchParamRegistry.SearchParamLookupContextEnum.ALL)
!= null) {
map.add(SubscriptionTopic.SP_STATUS, new TokenParam(null, Enumerations.PublicationStatus.ACTIVE.toCode()));
}
map.setLoadSynchronousUpTo(SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ private String createNamedQueryName(SearchMethodBinding searchMethodBinding) {

@Override
public RuntimeSearchParam getActiveSearchParam(
@Nonnull String theResourceName, @Nonnull String theParamName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull String theParamName,
@Nonnull SearchParamLookupContextEnum theContext) {
return getActiveSearchParams(theResourceName, theContext).get(theParamName);
}

@Override
public ResourceSearchParams getActiveSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
Validate.notBlank(theResourceName, "theResourceName must not be null or blank");

ResourceSearchParams retval = new ResourceSearchParams(theResourceName);
Expand All @@ -444,7 +446,8 @@ public ResourceSearchParams getActiveSearchParams(

@Nullable
@Override
public RuntimeSearchParam getActiveSearchParamByUrl(@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext) {
public RuntimeSearchParam getActiveSearchParamByUrl(
@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext) {
throw new UnsupportedOperationException(Msg.code(286));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ public void forceRefresh() {

@Override
public RuntimeSearchParam getActiveSearchParam(
@Nonnull String theResourceName, @Nonnull String theParamName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull String theParamName,
@Nonnull SearchParamLookupContextEnum theContext) {
return getActiveSearchParams(theResourceName, theContext).get(theParamName);
}

@Override
public ResourceSearchParams getActiveSearchParams(@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
public ResourceSearchParams getActiveSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
ResourceSearchParams retval = new ResourceSearchParams(theResourceName);
RuntimeResourceDefinition nextResDef = myCtx.getResourceDefinition(theResourceName);
for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) {
Expand All @@ -86,13 +89,16 @@ public void addSearchParam(RuntimeSearchParam theSearchParam) {

@Override
public List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull Set<String> theParamNames, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull Set<String> theParamNames,
@Nonnull SearchParamLookupContextEnum theContext) {
throw new UnsupportedOperationException(Msg.code(2066));
}

@Nullable
@Override
public RuntimeSearchParam getActiveSearchParamByUrl(@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext) {
public RuntimeSearchParam getActiveSearchParamByUrl(
@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext) {
// simple implementation for test support
return myCtx.getResourceTypes().stream()
.flatMap(type -> getActiveSearchParams(type, theContext).values().stream())
Expand All @@ -103,18 +109,21 @@ public RuntimeSearchParam getActiveSearchParamByUrl(@Nonnull String theUrl, @Non

@Override
public List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
throw new UnsupportedOperationException(Msg.code(2068));
}

@Override
public List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull ComboSearchParamType theParamType, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull ComboSearchParamType theParamType,
@Nonnull SearchParamLookupContextEnum theContext) {
throw new UnsupportedOperationException(Msg.code(2209));
}

@Override
public Optional<RuntimeSearchParam> getActiveComboSearchParamById(@Nonnull String theResourceName, @Nonnull IIdType theId) {
public Optional<RuntimeSearchParam> getActiveComboSearchParamById(
@Nonnull String theResourceName, @Nonnull IIdType theId) {
throw new UnsupportedOperationException(Msg.code(2211));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ default boolean isInitialized() {
* @deprecated Use {@link #getActiveSearchParam(String, String, SearchParamLookupContextEnum)}
*/
@Deprecated(since = "8.0.0", forRemoval = true)
default RuntimeSearchParam getActiveSearchParam(
String theResourceName, String theParamName) {
default RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName) {
return getActiveSearchParam(theResourceName, theParamName, SearchParamLookupContextEnum.ALL);
}

Expand All @@ -64,14 +63,15 @@ default RuntimeSearchParam getActiveSearchParam(
* @return Returns {@literal null} if no match
*/
RuntimeSearchParam getActiveSearchParam(
@Nonnull String theResourceName, @Nonnull String theParamName, @Nonnull SearchParamLookupContextEnum theContext);
@Nonnull String theResourceName,
@Nonnull String theParamName,
@Nonnull SearchParamLookupContextEnum theContext);

/**
* @deprecated Use {@link #getActiveSearchParam(String, String, SearchParamLookupContextEnum)}
*/
@Deprecated(since = "8.0.0", forRemoval = true)
default ResourceSearchParams getActiveSearchParams(
String theResourceName) {
default ResourceSearchParams getActiveSearchParams(String theResourceName) {
return getActiveSearchParams(theResourceName, SearchParamLookupContextEnum.ALL);
}

Expand All @@ -80,7 +80,7 @@ default ResourceSearchParams getActiveSearchParams(
* @return Returns all active search params for the given resource
*/
ResourceSearchParams getActiveSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext);
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext);

/**
* Request that the cache be refreshed now, in the current thread
Expand All @@ -104,26 +104,31 @@ default void setPhoneticEncoder(IPhoneticEncoder thePhoneticEncoder) {}
* @param theContext The context to return active search params for, or {@literal null} to return any active search params
*/
default List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
return Collections.emptyList();
}

// TODO ND remove default implementation
default List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull ComboSearchParamType theParamType, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull ComboSearchParamType theParamType,
@Nonnull SearchParamLookupContextEnum theContext) {
return Collections.emptyList();
}

// TODO ND remove default implementation
default Optional<RuntimeSearchParam> getActiveComboSearchParamById(@Nonnull String theResourceName, @Nonnull IIdType theId) {
default Optional<RuntimeSearchParam> getActiveComboSearchParamById(
@Nonnull String theResourceName, @Nonnull IIdType theId) {
return Optional.empty();
}

/**
* @param theContext The context to return active search params for, or {@literal null} to return any active search params
*/
default List<RuntimeSearchParam> getActiveComboSearchParams(
@Nonnull String theResourceName, @Nonnull Set<String> theParamNames, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName,
@Nonnull Set<String> theParamNames,
@Nonnull SearchParamLookupContextEnum theContext) {
return Collections.emptyList();
}

Expand All @@ -135,7 +140,7 @@ default List<RuntimeSearchParam> getActiveComboSearchParams(
* @param theContext The context to return active search params for, or {@literal null} to return any active search params
*/
default Collection<String> getValidSearchParameterNamesIncludingMeta(
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceName, @Nonnull SearchParamLookupContextEnum theContext) {
TreeSet<String> retval;
ResourceSearchParams activeSearchParams = getActiveSearchParams(theResourceName, theContext);
if (activeSearchParams == null) {
Expand All @@ -155,7 +160,8 @@ default Collection<String> getValidSearchParameterNamesIncludingMeta(
* @return Returns <code>null</code> if it can't be found
*/
@Nullable
RuntimeSearchParam getActiveSearchParamByUrl(@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext);
RuntimeSearchParam getActiveSearchParamByUrl(
@Nonnull String theUrl, @Nonnull SearchParamLookupContextEnum theContext);

/**
* Find a search param for a resource. First, check the resource itself, then check the top-level `Resource` resource.
Expand All @@ -166,7 +172,9 @@ default Collection<String> getValidSearchParameterNamesIncludingMeta(
* @return the {@link RuntimeSearchParam} that is found.
*/
default RuntimeSearchParam getRuntimeSearchParam(
@Nonnull String theResourceType, @Nonnull String theParamName, @Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceType,
@Nonnull String theParamName,
@Nonnull SearchParamLookupContextEnum theContext) {
RuntimeSearchParam availableSearchParamDef = getActiveSearchParam(theResourceType, theParamName, theContext);
if (availableSearchParamDef == null) {
availableSearchParamDef = getActiveSearchParam("Resource", theParamName, theContext);
Expand All @@ -186,7 +194,7 @@ default RuntimeSearchParam getRuntimeSearchParam(
* @return the {@link ResourceSearchParams} that has all the search params.
*/
default ResourceSearchParams getRuntimeSearchParams(
@Nonnull String theResourceType,@Nonnull SearchParamLookupContextEnum theContext) {
@Nonnull String theResourceType, @Nonnull SearchParamLookupContextEnum theContext) {
ResourceSearchParams availableSearchParams =
getActiveSearchParams(theResourceType, theContext).makeCopy();
ResourceSearchParams resourceSearchParams = getActiveSearchParams("Resource", theContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,9 @@ public void translateRawParameters(Map<String, List<String>> theSource, SearchPa
Collection<String> validNames = mySearchParamRegistry.getValidSearchParameterNamesIncludingMeta(
getResourceName(), ISearchParamRegistry.SearchParamLookupContextEnum.SEARCH);
RuntimeSearchParam notEnabledForSearchParam = mySearchParamRegistry.getActiveSearchParam(
getResourceName(), qualifiedParamName.getParamName(), ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
getResourceName(),
qualifiedParamName.getParamName(),
ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
if (notEnabledForSearchParam != null) {
String msg = getContext()
.getLocalizer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public void validate(SearchParameter searchParameter) {
if (myStorageSettings.isDefaultSearchParamsCanBeOverridden() == false) {
for (IPrimitiveType<?> nextBaseType : searchParameter.getBase()) {
String nextBase = nextBaseType.getValueAsString();
RuntimeSearchParam existingSearchParam =
mySearchParamRegistry.getActiveSearchParam(nextBase, searchParameter.getCode(), ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
RuntimeSearchParam existingSearchParam = mySearchParamRegistry.getActiveSearchParam(
nextBase, searchParameter.getCode(), ISearchParamRegistry.SearchParamLookupContextEnum.ALL);
if (existingSearchParam != null) {
boolean isBuiltIn = existingSearchParam.getId() == null;
isBuiltIn |= existingSearchParam.getUri().startsWith("http://hl7.org/fhir/SearchParameter/");
Expand Down Expand Up @@ -221,7 +221,8 @@ private void validateCompositeSearchParameterComponents(SearchParameter theSearc
.filter(SearchParameter.SearchParameterComponentComponent::hasDefinition)
.map(SearchParameter.SearchParameterComponentComponent::getDefinition)
.filter(Objects::nonNull)
.map((String url) -> mySearchParamRegistry.getActiveSearchParamByUrl(url, ISearchParamRegistry.SearchParamLookupContextEnum.ALL))
.map((String url) -> mySearchParamRegistry.getActiveSearchParamByUrl(
url, ISearchParamRegistry.SearchParamLookupContextEnum.ALL))
.filter(Objects::nonNull)
.forEach(theRuntimeSp -> validateComponentSpTypeAgainstWhiteList(
theRuntimeSp, getAllowedSearchParameterTypes(theSearchParameter)));
Expand Down

0 comments on commit 3cc1fb7

Please sign in to comment.