当前位置: 首页>>代码示例>>Java>>正文


Java IBundleProvider.size方法代码示例

本文整理汇总了Java中ca.uhn.fhir.rest.api.server.IBundleProvider.size方法的典型用法代码示例。如果您正苦于以下问题:Java IBundleProvider.size方法的具体用法?Java IBundleProvider.size怎么用?Java IBundleProvider.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.uhn.fhir.rest.api.server.IBundleProvider的用法示例。


在下文中一共展示了IBundleProvider.size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: expandByIdentifier

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
@Override
public ValueSet expandByIdentifier(String theUri, String theFilter) {
	if (isBlank(theUri)) {
		throw new InvalidRequestException("URI must not be blank or missing");
	}
	ValueSet source;

	org.hl7.fhir.instance.model.ValueSet defaultValueSet = myDefaultProfileValidationSupport.fetchResource(myRiCtx, org.hl7.fhir.instance.model.ValueSet.class, theUri);
	if (defaultValueSet != null) {
		source = getContext().newJsonParser().parseResource(ValueSet.class, myRiCtx.newJsonParser().encodeResourceToString(defaultValueSet));
	} else {
		SearchParameterMap params = new SearchParameterMap();
		params.setLoadSynchronousUpTo(1);
		params.add(ValueSet.SP_URL, new UriParam(theUri));
		IBundleProvider ids = search(params);
		if (ids.size() == 0) {
			throw new InvalidRequestException("Unknown ValueSet URI: " + theUri);
		}
		source = (ValueSet) ids.getResources(0, 1).get(0);
	}

	return expand(source, theFilter);

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:FhirResourceDaoValueSetDstu2.java

示例2: testSearchWithNoResults

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
@Test
public void testSearchWithNoResults() {
	Device dev = new Device();
	dev.addIdentifier().setSystem("Foo");
	myDeviceDao.create(dev, mySrd);

	IBundleProvider value = myDeviceDao.search(new SearchParameterMap());
	ourLog.info("Initial size: " + value.size());
	for (IBaseResource next : value.getResources(0, value.size())) {
		ourLog.info("Deleting: {}", next.getIdElement());
		myDeviceDao.delete((IIdType) next.getIdElement(), mySrd);
	}

	value = myDeviceDao.search(new SearchParameterMap());
	if (value.size() > 0) {
		ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement()));
		fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0)));
	}
	assertEquals(0, value.size().intValue());

	List<IBaseResource> res = value.getResources(0, 0);
	assertTrue(res.isEmpty());

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:FhirResourceDaoDstu3SearchNoFtTest.java

示例3: testSearchWithNoResults

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
@Test
public void testSearchWithNoResults() {
	Device dev = new Device();
	dev.addIdentifier().setSystem("Foo");
	myDeviceDao.create(dev, mySrd);

	IBundleProvider value = myDeviceDao.search(new SearchParameterMap());
	ourLog.info("Initial size: " + value.size());
	for (IBaseResource next : value.getResources(0, value.size())) {
		ourLog.info("Deleting: {}", next.getIdElement());
		myDeviceDao.delete(next.getIdElement(), mySrd);
	}

	value = myDeviceDao.search(new SearchParameterMap());
	if (value.size() > 0) {
		ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement()));
		fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0)));
	}
	assertEquals(0, value.size().intValue());

	List<IBaseResource> res = value.getResources(0, 0);
	assertTrue(res.isEmpty());

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:FhirResourceDaoR4SearchNoFtTest.java

示例4: toUnqualifiedVersionlessIds

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
protected List<IIdType> toUnqualifiedVersionlessIds(IBundleProvider theFound) {
	List<IIdType> retVal = new ArrayList<>();
	Integer size = theFound.size();
	StopWatch sw = new StopWatch();
	while (size == null) {
		int timeout = 20000;
		if (sw.getMillis() > timeout) {
			fail("Waited over "+timeout+"ms for search");
		}
		try {
			Thread.sleep(100);
		} catch (InterruptedException theE) {
			//ignore
		}
		size = theFound.size();
	}

	ourLog.info("Found {} results", size);
	List<IBaseResource> resources = theFound.getResources(0, size);
	for (IBaseResource next : resources) {
		retVal.add(next.getIdElement().toUnqualifiedVersionless());
	}
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:BaseJpaTest.java

示例5: initSubscriptions

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
/**
 * Read the existing subscriptions from the database
 */
@SuppressWarnings("unused")
@Scheduled(fixedDelay = 10000)
public void initSubscriptions() {
	SearchParameterMap map = new SearchParameterMap();
	map.add(Subscription.SP_TYPE, new TokenParam(null, getChannelType().toCode()));
	map.add(Subscription.SP_STATUS, new TokenOrListParam()
		.addOr(new TokenParam(null, Subscription.SubscriptionStatus.REQUESTED.toCode()))
		.addOr(new TokenParam(null, Subscription.SubscriptionStatus.ACTIVE.toCode())));
	map.setLoadSynchronousUpTo(MAX_SUBSCRIPTION_RESULTS);

	RequestDetails req = new ServletSubRequestDetails();
	req.setSubRequest(true);

	IBundleProvider subscriptionBundleList = getSubscriptionDao().search(map, req);
	if (subscriptionBundleList.size() >= MAX_SUBSCRIPTION_RESULTS) {
		ourLog.error("Currently over " + MAX_SUBSCRIPTION_RESULTS + " subscriptions.  Some subscriptions have not been loaded.");
	}

	List<IBaseResource> resourceList = subscriptionBundleList.getResources(0, subscriptionBundleList.size());

	Set<String> allIds = new HashSet<>();
	for (IBaseResource resource : resourceList) {
		String nextId = resource.getIdElement().getIdPart();
		allIds.add(nextId);
		mySubscriptionActivatingSubscriber.activateAndRegisterSubscriptionIfRequired(resource);
	}

	for (Enumeration<String> keyEnum = myIdToSubscription.keys(); keyEnum.hasMoreElements(); ) {
		String next = keyEnum.nextElement();
		if (!allIds.contains(next)) {
			ourLog.info("Unregistering Subscription/{} as it no longer exists", next);
			myIdToSubscription.remove(next);
		}
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:39,代码来源:BaseSubscriptionInterceptor.java

示例6: toUnqualifiedIdValues

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
protected List<String> toUnqualifiedIdValues(IBundleProvider theFound) {
	List<String> retVal = new ArrayList<String>();
	int size = theFound.size();
	ourLog.info("Found {} results", size);
	List<IBaseResource> resources = theFound.getResources(0, size);
	for (IBaseResource next : resources) {
		retVal.add(next.getIdElement().toUnqualified().getValue());
	}
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:11,代码来源:BaseJpaTest.java

示例7: toUnqualifiedVersionlessIdValues

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
protected List<String> toUnqualifiedVersionlessIdValues(IBundleProvider theFound) {
	List<String> retVal = new ArrayList<String>();
	Integer size = theFound.size();
	ourLog.info("Found {} results", size);

	if (size == null) {
		size = 99999;
	}

	List<IBaseResource> resources = theFound.getResources(0, size);
	for (IBaseResource next : resources) {
		retVal.add(next.getIdElement().toUnqualifiedVersionless().getValue());
	}
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:16,代码来源:BaseJpaTest.java

示例8: log

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
private String log(IBundleProvider theHistory) {
	StringBuilder b = new StringBuilder(theHistory.size() + " results: ");
	for (IBaseResource next : theHistory.getResources(0, theHistory.size())) {
		b.append("\n ").append(next.getIdElement().toUnqualified().getValue());
	}
	return b.toString();
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:8,代码来源:FhirResourceDaoDstu2Test.java

示例9: invokeServer

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
@Override
public IBundleProvider invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
	if (myIdParamIndex != null) {
		theMethodParams[myIdParamIndex] = theRequest.getId();
	}

	Object response = invokeServerMethod(theServer, theRequest, theMethodParams);

	final IBundleProvider resources = toResourceList(response);
	
	/*
	 * We wrap the response so we can verify that it has the ID and version set,
	 * as is the contract for history
	 */
	return new IBundleProvider() {
		
		@Override
		public IPrimitiveType<Date> getPublished() {
			return resources.getPublished();
		}
		
		@Override
		public List<IBaseResource> getResources(int theFromIndex, int theToIndex) {
			List<IBaseResource> retVal = resources.getResources(theFromIndex, theToIndex);
			int index = theFromIndex;
			for (IBaseResource nextResource : retVal) {
				if (nextResource.getIdElement() == null || isBlank(nextResource.getIdElement().getIdPart())) {
					throw new InternalErrorException("Server provided resource at index " + index + " with no ID set (using IResource#setId(IdDt))");
				}
				if (isBlank(nextResource.getIdElement().getVersionIdPart()) && nextResource instanceof IResource) {
					//TODO: Use of a deprecated method should be resolved.
					IdDt versionId = (IdDt) ResourceMetadataKeyEnum.VERSION_ID.get((IResource) nextResource);
					if (versionId == null || versionId.isEmpty()) {
						throw new InternalErrorException("Server provided resource at index " + index + " with no Version ID set (using IResource#setId(IdDt))");
					}
				}
				index++;
			}
			return retVal;
		}
		
		@Override
		public Integer size() {
			return resources.size();
		}

		@Override
		public Integer preferredPageSize() {
			return resources.preferredPageSize();
		}

		@Override
		public String getUuid() {
			return resources.getUuid();
		}
	};
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:58,代码来源:HistoryMethodBinding.java

示例10: handleMessage

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
@Override
public void handleMessage(Message<?> theMessage) throws MessagingException {
	ourLog.trace("Handling resource modified message: {}", theMessage);

	if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
		ourLog.warn("Unexpected message payload type: {}", theMessage);
		return;
	}

	ResourceModifiedMessage msg = ((ResourceModifiedJsonMessage) theMessage).getPayload();
	switch (msg.getOperationType()) {
		case CREATE:
		case UPDATE:
			break;
		default:
			ourLog.trace("Not processing modified message for {}", msg.getOperationType());
			// ignore anything else
			return;
	}

	IIdType id = msg.getId(getContext());
	String resourceType = id.getResourceType();
	String resourceId = id.getIdPart();

	List<CanonicalSubscription> subscriptions = getSubscriptionInterceptor().getSubscriptions();

	ourLog.trace("Testing {} subscriptions for applicability");

	for (CanonicalSubscription nextSubscription : subscriptions) {

		String nextSubscriptionId = nextSubscription.getIdElement(getContext()).toUnqualifiedVersionless().getValue();
		String nextCriteriaString = nextSubscription.getCriteriaString();

		if (StringUtils.isBlank(nextCriteriaString)) {
			continue;
		}

		// see if the criteria matches the created object
		ourLog.trace("Checking subscription {} for {} with criteria {}", nextSubscriptionId, resourceType, nextCriteriaString);
		String criteriaResource = nextCriteriaString;
		int index = criteriaResource.indexOf("?");
		if (index != -1) {
			criteriaResource = criteriaResource.substring(0, criteriaResource.indexOf("?"));
		}

		if (resourceType != null && nextCriteriaString != null && !criteriaResource.equals(resourceType)) {
			ourLog.trace("Skipping subscription search for {} because it does not match the criteria {}", resourceType, nextCriteriaString);
			continue;
		}

		// run the subscriptions query and look for matches, add the id as part of the criteria to avoid getting matches of previous resources rather than the recent resource
		String criteria = nextCriteriaString;
		criteria += "&_id=" + resourceType + "/" + resourceId;
		criteria = massageCriteria(criteria);

		IBundleProvider results = performSearch(criteria);

		ourLog.info("Subscription check found {} results for query: {}", results.size(), criteria);

		if (results.size() == 0) {
			continue;
		}

		// should just be one resource as it was filtered by the id
		for (IBaseResource nextBase : results.getResources(0, results.size())) {
			ourLog.info("Found match: queueing rest-hook notification for resource: {}", nextBase.getIdElement());

			ResourceDeliveryMessage deliveryMsg = new ResourceDeliveryMessage();
			deliveryMsg.setPayload(getContext(), nextBase);
			deliveryMsg.setSubscription(nextSubscription);
			deliveryMsg.setOperationType(msg.getOperationType());
			deliveryMsg.setPayloadId(msg.getId(getContext()));

			ResourceDeliveryJsonMessage wrappedMsg = new ResourceDeliveryJsonMessage(deliveryMsg);
			getSubscriptionInterceptor().getDeliveryChannel().send(wrappedMsg);
		}
	}


}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:81,代码来源:SubscriptionCheckingSubscriber.java

示例11: listResources

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
@Transactional(propagation = Propagation.NEVER)
@Override
public void listResources(Object theAppInfo, String theType, List<Argument> theSearchParams, List<Resource> theMatches) throws FHIRException {

	RuntimeResourceDefinition typeDef = getContext().getResourceDefinition(theType);
	IFhirResourceDao<? extends IBaseResource> dao = getDao(typeDef.getImplementingClass());

	SearchParameterMap params = new SearchParameterMap();

	for (Argument nextArgument : theSearchParams) {

		RuntimeSearchParam searchParam = getSearchParamByName(typeDef, nextArgument.getName());

		for (Value nextValue : nextArgument.getValues()) {
			String value = nextValue.getValue();

			IQueryParameterType param = null;
			switch (searchParam.getParamType()) {
				case NUMBER:
					param = new NumberParam(value);
					break;
				case DATE:
					param = new DateParam(value);
					break;
				case STRING:
					param = new StringParam(value);
					break;
				case TOKEN:
					param = new TokenParam(null, value);
					break;
				case REFERENCE:
					param = new ReferenceParam(value);
					break;
				case COMPOSITE:
					throw new InvalidRequestException("Composite parameters are not yet supported in GraphQL");
				case QUANTITY:
					param = new QuantityParam(value);
					break;
				case URI:
					break;
				case HAS:
					break;
			}

			params.add(nextArgument.getName(), param);
		}
	}

	IBundleProvider response = dao.search(params);
	int size = response.size();
	if (response.preferredPageSize() != null && response.preferredPageSize() < size) {
		size = response.preferredPageSize();
	}

	for (IBaseResource next : response.getResources(0, size)) {
		theMatches.add((Resource) next);
	}

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:60,代码来源:JpaStorageServices.java

示例12: testEverythingWithLargeSet

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
/**
 * Per message from David Hay on Skype
 */
@Test
public void testEverythingWithLargeSet() throws Exception {
	myFhirCtx.setParserErrorHandler(new StrictErrorHandler());

	String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8);
	Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString);
	inputBundle.setType(BundleType.TRANSACTION);

	Set<String> allIds = new TreeSet<>();
	for (BundleEntryComponent nextEntry : inputBundle.getEntry()) {
		nextEntry.getRequest().setMethod(HTTPVerb.PUT);
		nextEntry.getRequest().setUrl(nextEntry.getResource().getId());
		allIds.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue());
	}

	mySystemDao.transaction(mySrd, inputBundle);

	SearchParameterMap map = new SearchParameterMap();
	map.setEverythingMode(EverythingModeEnum.PATIENT_INSTANCE);
	IPrimitiveType<Integer> count = new IntegerType(1000);
	IBundleProvider everything = myPatientDao.patientInstanceEverything(mySrd.getServletRequest(), new IdType("Patient/A161443"), count, null, null, null, null, mySrd);

	TreeSet<String> ids = new TreeSet<>(toUnqualifiedVersionlessIdValues(everything));
	assertThat(ids, hasItem("List/A161444"));
	assertThat(ids, hasItem("List/A161468"));
	assertThat(ids, hasItem("List/A161500"));

	ourLog.info("Expected {} - {}", allIds.size(), allIds);
	ourLog.info("Actual   {} - {}", ids.size(), ids);
	assertEquals(allIds, ids);

	ids = new TreeSet<>();
	for (int i = 0; i < everything.size(); i++) {
		for (IBaseResource next : everything.getResources(i, i + 1)) {
			ids.add(next.getIdElement().toUnqualifiedVersionless().getValue());
		}
	}
	assertThat(ids, hasItem("List/A161444"));
	assertThat(ids, hasItem("List/A161468"));
	assertThat(ids, hasItem("List/A161500"));

	ourLog.info("Expected {} - {}", allIds.size(), allIds);
	ourLog.info("Actual   {} - {}", ids.size(), ids);
	assertEquals(allIds, ids);

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:50,代码来源:FhirResourceDaoDstu3SearchNoFtTest.java

示例13: testEverythingWithLargeSet

import ca.uhn.fhir.rest.api.server.IBundleProvider; //导入方法依赖的package包/类
/**
 * Per message from David Hay on Skype
 */
@Test
public void testEverythingWithLargeSet() throws Exception {
	myFhirCtx.setParserErrorHandler(new StrictErrorHandler());

	String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8);
	Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString);
	inputBundle.setType(BundleType.TRANSACTION);

	Set<String> allIds = new TreeSet<String>();
	for (BundleEntryComponent nextEntry : inputBundle.getEntry()) {
		nextEntry.getRequest().setMethod(HTTPVerb.PUT);
		nextEntry.getRequest().setUrl(nextEntry.getResource().getId());
		allIds.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue());
	}

	mySystemDao.transaction(mySrd, inputBundle);

	SearchParameterMap map = new SearchParameterMap();
	map.setEverythingMode(EverythingModeEnum.PATIENT_INSTANCE);
	IPrimitiveType<Integer> count = new IntegerType(1000);
	IBundleProvider everything = myPatientDao.patientInstanceEverything(mySrd.getServletRequest(), new IdType("Patient/A161443"), count, null, null, null, null, mySrd);

	TreeSet<String> ids = new TreeSet<String>(toUnqualifiedVersionlessIdValues(everything));
	assertThat(ids, hasItem("List/A161444"));
	assertThat(ids, hasItem("List/A161468"));
	assertThat(ids, hasItem("List/A161500"));

	ourLog.info("Expected {} - {}", allIds.size(), allIds);
	ourLog.info("Actual   {} - {}", ids.size(), ids);
	assertEquals(allIds, ids);

	ids = new TreeSet<String>();
	for (int i = 0; i < everything.size(); i++) {
		for (IBaseResource next : everything.getResources(i, i + 1)) {
			ids.add(next.getIdElement().toUnqualifiedVersionless().getValue());
		}
	}
	assertThat(ids, hasItem("List/A161444"));
	assertThat(ids, hasItem("List/A161468"));
	assertThat(ids, hasItem("List/A161500"));

	ourLog.info("Expected {} - {}", allIds.size(), allIds);
	ourLog.info("Actual   {} - {}", ids.size(), ids);
	assertEquals(allIds, ids);

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:50,代码来源:FhirResourceDaoR4SearchNoFtTest.java


注:本文中的ca.uhn.fhir.rest.api.server.IBundleProvider.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。