/** * Express {@link #getImplementingClass()} as theClass (to prevent casting warnings) */ @SuppressWarnings("unchecked") public <T> Class<T> getImplementingClass(Class<T> theClass) { if (!theClass.isAssignableFrom(getImplementingClass())) { throw new ConfigurationException("Unable to convert " + getImplementingClass() + " to " + theClass); } return (Class<T>) getImplementingClass(); }
private void setType(String theResourceName) { myResourceType = myContext.getResourceDefinition(theResourceName).getImplementingClass(); myResourceName = theResourceName; }
@SuppressWarnings("unchecked") private <T extends IBaseResource> void doReindex(ResourceTable theResourceTable, T theResource) { RuntimeResourceDefinition resourceDefinition = myContext.getResourceDefinition(theResource.getClass()); Class<T> resourceClass = (Class<T>) resourceDefinition.getImplementingClass(); final IFhirResourceDao<T> dao = myDaoRegistry.getResourceDao(resourceClass); dao.reindex(theResource, theResourceTable); myCounter.incrementAndGet(); }
@Override public Class<? extends IBaseResource> getResourceType() { return myFhirContext.getResourceDefinition(ResourceTypeEnum.SUBSCRIPTION.getCode()).getImplementingClass(); }
public Class<? extends IBaseBundle> getBundleTypeForFhirVersion() { return getFhirContext().getResourceDefinition("Bundle").getImplementingClass(IBaseBundle.class); }
public Class<? extends IBaseResource> getResourceType(FhirContext theCtx) { if (isBlank(getResourceType())) { return null; } return theCtx.getResourceDefinition(getResourceType()).getImplementingClass(); }
public static IBaseOperationOutcome newInstance(FhirContext theCtx) { RuntimeResourceDefinition ooDef = theCtx.getResourceDefinition("OperationOutcome"); try { return (IBaseOperationOutcome) ooDef.getImplementingClass().newInstance(); } catch (InstantiationException e) { throw new InternalErrorException("Unable to instantiate OperationOutcome", e); } catch (IllegalAccessException e) { throw new InternalErrorException("Unable to instantiate OperationOutcome", e); } }
@Override public Object execute() {// AAA if (myId.hasVersionIdPart()) { return doReadOrVRead(myType.getImplementingClass(), myId, true, myNotModifiedHandler, myIfVersionMatches, myPrettyPrint, mySummaryMode, myParamEncoding, getSubsetElements(), getCustomAcceptHeaderValue()); } return doReadOrVRead(myType.getImplementingClass(), myId, false, myNotModifiedHandler, myIfVersionMatches, myPrettyPrint, mySummaryMode, myParamEncoding, getSubsetElements(), getCustomAcceptHeaderValue()); }
private ISearchBuilder newSearchBuilder() { Class<? extends IBaseResource> resourceTypeClass = myContext.getResourceDefinition(myResourceType).getImplementingClass(); ISearchBuilder sb = myCallingDao.newSearchBuilder(); sb.setType(resourceTypeClass, myResourceType); return sb; }
@Override public IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation) { RuntimeResourceDefinition type = myContext.getResourceDefinition(theEntity.getResourceType()); Class<? extends IBaseResource> resourceType = type.getImplementingClass(); return toResource(resourceType, theEntity, null, theForHistoryOperation); }
private IFhirResourceDao<? extends IBaseResource> getDao(String theResourceType) { RuntimeResourceDefinition typeDef = getContext().getResourceDefinition(theResourceType); return getDao(typeDef.getImplementingClass()); }
private ISchematronResource getSchematron(IValidationContext<IBaseResource> theCtx) { Class<? extends IBaseResource> resource = theCtx.getResource().getClass(); Class<? extends IBaseResource> baseResourceClass = theCtx.getFhirContext().getResourceDefinition(resource).getBaseDefinition().getImplementingClass(); return getSchematronAndCache(theCtx, baseResourceClass); }
@Override public Object execute() { ResourceResponseHandler binding = new ResourceResponseHandler(myType.getImplementingClass()); FhirContext fhirContext = getFhirContext(); HttpGetClientInvocation invocation = MethodUtil.createConformanceInvocation(fhirContext); return super.invoke(null, binding, invocation); }
protected List<IBaseResource> doSearchOrEverything(final int theFromIndex, final int theToIndex) { final ISearchBuilder sb = myDao.newSearchBuilder(); String resourceName = mySearchEntity.getResourceType(); Class<? extends IBaseResource> resourceType = myContext.getResourceDefinition(resourceName).getImplementingClass(); sb.setType(resourceType, resourceName); final List<Long> pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex); TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager); template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); return template.execute(theStatus -> toResourceList(sb, pidsSubList)); }
@Override public IBaseResource read(UriDt theUrl) { IdDt id = new IdDt(theUrl); String resourceType = id.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, theUrl.getValueAsString())); } RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType); if (def == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theUrl.getValueAsString())); } return read(def.getImplementingClass(), id); }
@Override public IBaseResource getResource(IIdType payloadId) throws ResourceGoneException { RuntimeResourceDefinition resourceDef = myFhirContext.getResourceDefinition(payloadId.getResourceType()); IFhirResourceDao dao = myDaoRegistry.getResourceDao(resourceDef.getImplementingClass()); return dao.read(payloadId.toVersionless()); } }
/** * Search based on a query criteria */ private IBundleProvider performSearch(String theCriteria) { IFhirResourceDao<?> subscriptionDao = myDaoRegistry.getSubscriptionDao(); RuntimeResourceDefinition responseResourceDef = subscriptionDao.validateCriteriaAndReturnResourceDefinition(theCriteria); SearchParameterMap responseCriteriaUrl = myMatchUrlService.translateMatchUrl(theCriteria, responseResourceDef); IFhirResourceDao<? extends IBaseResource> responseDao = myDaoRegistry.getResourceDao(responseResourceDef.getImplementingClass()); responseCriteriaUrl.setLoadSynchronousUpTo(1); return responseDao.search(responseCriteriaUrl); } }
@SuppressWarnings("unchecked") @Override public List<IBaseResource> invokeClient(String theResponseMimeType, InputStream theResponseInputStream, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws BaseServerResponseException { Class<? extends IBaseResource> bundleType = myContext.getResourceDefinition("Bundle").getImplementingClass(); ResourceResponseHandler<IBaseResource> handler = new ResourceResponseHandler<>((Class<IBaseResource>) bundleType); IBaseResource response = handler.invokeClient(theResponseMimeType, theResponseInputStream, theResponseStatusCode, theHeaders); IVersionSpecificBundleFactory bundleFactory = myContext.newBundleFactory(); bundleFactory.initializeWithBundleResource(response); return bundleFactory.toListOfResources(); } }
@Override protected void populateActionRequestDetailsForInterceptor(RequestDetails theRequestDetails, ActionRequestDetails theDetails, Object[] theMethodParams) { super.populateActionRequestDetailsForInterceptor(theRequestDetails, theDetails, theMethodParams); /* * If the method has no parsed resource parameter, we parse here in order to have something for the interceptor. */ if (myTransactionParamIndex != -1) { theDetails.setResource((IBaseResource) theMethodParams[myTransactionParamIndex]); } else { Class<? extends IBaseResource> resourceType = getContext().getResourceDefinition("Bundle").getImplementingClass(); theDetails.setResource(ResourceParameter.parseResourceFromRequest(theRequestDetails, this, resourceType)); } }
@Override protected void validateResourceForStorage(Subscription theResource, ResourceTable theEntityToSave) { super.validateResourceForStorage(theResource, theEntityToSave); RuntimeResourceDefinition resDef = validateCriteriaAndReturnResourceDefinition(theResource); IFhirResourceDao<? extends IBaseResource> dao = getDao(resDef.getImplementingClass()); if (dao == null) { throw new UnprocessableEntityException("Subscription.criteria contains invalid/unsupported resource type: " + resDef); } if (theResource.getChannel().getType() == null) { throw new UnprocessableEntityException("Subscription.channel.type must be populated on this server"); } SubscriptionStatusEnum status = theResource.getStatusElement().getValueAsEnum(); if (status == null) { throw new UnprocessableEntityException("Subscription.status must be populated on this server"); } }