private static void extractCompositeStringUniquesValueChains(String theResourceType, List<List<String>> thePartsChoices, List<String> theValues, Set<String> theQueryStringsToPopulate) { if (thePartsChoices.size() > 0) { List<String> nextList = thePartsChoices.get(0); Collections.sort(nextList); for (String nextChoice : nextList) { theValues.add(nextChoice); extractCompositeStringUniquesValueChains(theResourceType, thePartsChoices.subList(1, thePartsChoices.size()), theValues, theQueryStringsToPopulate); theValues.remove(theValues.size() - 1); } } else { if (theValues.size() > 0) { StringBuilder uniqueString = new StringBuilder(); uniqueString.append(theResourceType); for (int i = 0; i < theValues.size(); i++) { uniqueString.append(i == 0 ? "?" : "&"); uniqueString.append(theValues.get(i)); } theQueryStringsToPopulate.add(uniqueString.toString()); } } }
public void findMissingSearchParams(ModelConfig theModelConfig, ResourceTable theEntity, Set<Entry<String, RuntimeSearchParam>> theActiveSearchParams) { findMissingSearchParams(theModelConfig, theEntity, theActiveSearchParams, RestSearchParameterTypeEnum.STRING, stringParams); findMissingSearchParams(theModelConfig, theEntity, theActiveSearchParams, RestSearchParameterTypeEnum.NUMBER, numberParams); findMissingSearchParams(theModelConfig, theEntity, theActiveSearchParams, RestSearchParameterTypeEnum.QUANTITY, quantityParams); findMissingSearchParams(theModelConfig, theEntity, theActiveSearchParams, RestSearchParameterTypeEnum.DATE, dateParams); findMissingSearchParams(theModelConfig, theEntity, theActiveSearchParams, RestSearchParameterTypeEnum.URI, uriParams); findMissingSearchParams(theModelConfig, theEntity, theActiveSearchParams, RestSearchParameterTypeEnum.TOKEN, tokenParams); }
public void setUpdatedTime(Date theUpdateTime) { setUpdatedTime(stringParams, theUpdateTime); setUpdatedTime(numberParams, theUpdateTime); setUpdatedTime(quantityParams, theUpdateTime); setUpdatedTime(dateParams, theUpdateTime); setUpdatedTime(uriParams, theUpdateTime); setUpdatedTime(coordsParams, theUpdateTime); setUpdatedTime(tokenParams, theUpdateTime); }
private boolean matchResourceLinks(String theResourceName, String theParamName, IQueryParameterType theParam) { ReferenceParam reference = (ReferenceParam)theParam; Predicate<ResourceLink> namedParamPredicate = resourceLink -> resourceLinkMatches(theResourceName, resourceLink, theParamName) && resourceIdMatches(resourceLink, reference); return links.stream().anyMatch(namedParamPredicate); }
public void populateFromResource(ResourceIndexedSearchParams theParams, IDao theCallingDao, Date theUpdateTime, ResourceTable theEntity, IBaseResource theResource, ResourceIndexedSearchParams existingParams) { mySearchParamExtractorService.extractFromResource(theParams, theEntity, theResource); Set<Map.Entry<String, RuntimeSearchParam>> activeSearchParams = mySearchParamRegistry.getActiveSearchParams(theEntity.getResourceType()).entrySet(); if (myDaoConfig.getIndexMissingFields() == DaoConfig.IndexEnabledEnum.ENABLED) { theParams.findMissingSearchParams(myDaoConfig.getModelConfig(), theEntity, activeSearchParams); } theParams.setUpdatedTime(theUpdateTime); extractInlineReferences(theResource); myResourceLinkExtractor.extractResourceLinks(theParams, theEntity, theResource, theUpdateTime, myDaoResourceLinkResolver, true); /* * If the existing resource already has links and those match links we still want, use them instead of removing them and re adding them */ for (Iterator<ResourceLink> existingLinkIter = existingParams.getResourceLinks().iterator(); existingLinkIter.hasNext(); ) { ResourceLink nextExisting = existingLinkIter.next(); if (theParams.links.remove(nextExisting)) { existingLinkIter.remove(); theParams.links.add(nextExisting); } } /* * Handle composites */ extractCompositeStringUniques(theEntity, theParams); }
ResourceIndexedSearchParams existingParams = new ResourceIndexedSearchParams(theEntity); if (theDeletedTimestampOrNull != null) { newParams = new ResourceIndexedSearchParams(); newParams = new ResourceIndexedSearchParams(); mySearchParamWithInlineReferencesExtractor.populateFromResource(newParams, this, theUpdateTime, theEntity, theResource, existingParams); newParams.setParamsOn(theEntity); theEntity.setIndexStatus(INDEX_STATUS_INDEXED); populateFullTextFields(myContext, theResource, theEntity); for (String nextKey : newParams.getPopulatedResourceLinkParameters()) { presentSearchParams.put(nextKey, Boolean.TRUE);
SubscriptionMatchResult match(String criteria, IBaseResource resource) { ResourceTable entity = new ResourceTable(); String resourceType = myContext.getResourceDefinition(resource).getName(); entity.setResourceType(resourceType); ResourceIndexedSearchParams searchParams = new ResourceIndexedSearchParams(); mySearchParamExtractorService.extractFromResource(searchParams, entity, resource); myResourceLinkExtractor.extractResourceLinks(searchParams, entity, resource, resource.getMeta().getLastUpdated(), myInlineResourceLinkResolver, false); return myCriteriaResourceMatcher.match(criteria, resource, searchParams); } }
private <T extends BaseResourceIndex> void synchronize(ResourceIndexedSearchParams theParams, ResourceTable theEntity, Collection<T> theNewParms, Collection<T> theExistingParms) { theParams.calculateHashes(theNewParms); List<T> quantitiesToRemove = subtract(theExistingParms, theNewParms); List<T> quantitiesToAdd = subtract(theNewParms, theExistingParms); tryToReuseIndexEntities(quantitiesToRemove, quantitiesToAdd); for (T next : quantitiesToRemove) { myEntityManager.remove(next); theEntity.getParamsQuantity().remove(next); } for (T next : quantitiesToAdd) { myEntityManager.merge(next); } }
private boolean matchParams(String theResourceName, String theParamName, RuntimeSearchParam paramDef, List<? extends IQueryParameterType> theNextAnd, ResourceIndexedSearchParams theSearchParams) { return theNextAnd.stream().anyMatch(token -> theSearchParams.matchParam(theResourceName, theParamName, paramDef, token)); }
break; case REFERENCE: return matchResourceLinks(theResourceName, theParamName, theParam); case COMPOSITE: case HAS:
public void populateFromResource(ResourceIndexedSearchParams theParams, IDao theCallingDao, Date theUpdateTime, ResourceTable theEntity, IBaseResource theResource, ResourceIndexedSearchParams existingParams) { mySearchParamExtractorService.extractFromResource(theParams, theEntity, theResource); Set<Map.Entry<String, RuntimeSearchParam>> activeSearchParams = mySearchParamRegistry.getActiveSearchParams(theEntity.getResourceType()).entrySet(); if (myDaoConfig.getIndexMissingFields() == DaoConfig.IndexEnabledEnum.ENABLED) { theParams.findMissingSearchParams(myDaoConfig.getModelConfig(), theEntity, activeSearchParams); } theParams.setUpdatedTime(theUpdateTime); extractInlineReferences(theResource); myResourceLinkExtractor.extractResourceLinks(theParams, theEntity, theResource, theUpdateTime, myDaoResourceLinkResolver, true); /* * If the existing resource already has links and those match links we still want, use them instead of removing them and re adding them */ for (Iterator<ResourceLink> existingLinkIter = existingParams.getResourceLinks().iterator(); existingLinkIter.hasNext(); ) { ResourceLink nextExisting = existingLinkIter.next(); if (theParams.links.remove(nextExisting)) { existingLinkIter.remove(); theParams.links.add(nextExisting); } } /* * Handle composites */ extractCompositeStringUniques(theEntity, theParams); }
ResourceIndexedSearchParams existingParams = new ResourceIndexedSearchParams(theEntity); if (theDeletedTimestampOrNull != null) { newParams = new ResourceIndexedSearchParams(); newParams = new ResourceIndexedSearchParams(); mySearchParamWithInlineReferencesExtractor.populateFromResource(newParams, this, theUpdateTime, theEntity, theResource, existingParams); newParams.setParamsOn(theEntity); theEntity.setIndexStatus(INDEX_STATUS_INDEXED); populateFullTextFields(myContext, theResource, theEntity); for (String nextKey : newParams.getPopulatedResourceLinkParameters()) { presentSearchParams.put(nextKey, Boolean.TRUE);
private <T extends BaseResourceIndex> void synchronize(ResourceIndexedSearchParams theParams, ResourceTable theEntity, Collection<T> theNewParms, Collection<T> theExistingParms) { theParams.calculateHashes(theNewParms); List<T> quantitiesToRemove = subtract(theExistingParms, theNewParms); List<T> quantitiesToAdd = subtract(theNewParms, theExistingParms); tryToReuseIndexEntities(quantitiesToRemove, quantitiesToAdd); for (T next : quantitiesToRemove) { myEntityManager.remove(next); theEntity.getParamsQuantity().remove(next); } for (T next : quantitiesToAdd) { myEntityManager.merge(next); } }
extractCompositeStringUniquesValueChains(theResourceType, thePartsChoices, values, queryStringsToPopulate); return queryStringsToPopulate;
Set<String> uniqueQueryStrings = ResourceIndexedSearchParams.extractCompositeStringUniquesValueChains(myResourceName, params); if (ourTrackHandlersForUnitTest) { ourLastHandlerParamsForUnitTest = theParams;
Set<String> queryStringsToPopulate = theParams.extractCompositeStringUniquesValueChains(resourceType, partsChoices);
Set<String> uniqueQueryStrings = ResourceIndexedSearchParams.extractCompositeStringUniquesValueChains(myResourceName, params); if (ourTrackHandlersForUnitTest) { ourLastHandlerParamsForUnitTest = theParams;
Set<String> queryStringsToPopulate = theParams.extractCompositeStringUniquesValueChains(resourceType, partsChoices);