@Override TokenOrListParam newInstance() { return new TokenOrListParam(); }
private int doSyncSubscriptions() { synchronized (mySyncSubscriptionsLock) { ourLog.debug("Starting sync subscriptions"); SearchParameterMap map = new SearchParameterMap(); map.add(Subscription.SP_STATUS, new TokenOrListParam() // TODO KHS perhaps we should only be requesting ACTIVE subscriptions here?... .addOr(new TokenParam(null, Subscription.SubscriptionStatus.REQUESTED.toCode())) .addOr(new TokenParam(null, Subscription.SubscriptionStatus.ACTIVE.toCode()))); map.setLoadSynchronousUpTo(SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS); IBundleProvider subscriptionBundleList = mySubscriptionProvidor.search(map); if (subscriptionBundleList.size() >= SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS) { ourLog.error("Currently over " + SubscriptionConstants.MAX_SUBSCRIPTION_RESULTS + " subscriptions. Some subscriptions have not been loaded."); } List<IBaseResource> resourceList = subscriptionBundleList.getResources(0, subscriptionBundleList.size()); Set<String> allIds = new HashSet<>(); int changesCount = 0; for (IBaseResource resource : resourceList) { String nextId = resource.getIdElement().getIdPart(); allIds.add(nextId); boolean changed = mySubscriptionProvidor.loadSubscription(resource); if (changed) { changesCount++; } } mySubscriptionRegistry.unregisterAllSubscriptionsNotInCollection(allIds); ourLog.debug("Finished sync subscriptions - found {}", resourceList.size()); return changesCount; } }
@Override TokenOrListParam newInstance() { return new TokenOrListParam(); }