public static IBaseParameters newInstance(FhirContext theContext) { Validate.notNull(theContext, "theContext must not be null"); return (IBaseParameters) theContext.getResourceDefinition("Parameters").newInstance(); }
public static IBaseBinary newBinary(FhirContext theCtx) { return (IBaseBinary) theCtx.getResourceDefinition("Binary").newInstance(); }
@SuppressWarnings("unchecked") @Override public <T extends IBaseParameters> IOperationUntypedWithInputAndPartialOutput<T> withNoParameters(Class<T> theOutputParameterType) { Validate.notNull(theOutputParameterType, "theOutputParameterType may not be null"); RuntimeResourceDefinition def = myContext.getResourceDefinition(theOutputParameterType); if (def == null) { throw new IllegalArgumentException("theOutputParameterType must refer to a HAPI FHIR Resource type: " + theOutputParameterType.getName()); } if (!"Parameters".equals(def.getName())) { throw new IllegalArgumentException("theOutputParameterType must refer to a HAPI FHIR Resource type for a resource named " + "Parameters" + " - " + theOutputParameterType.getName() + " is a resource named: " + def.getName()); } myParameters = (IBaseParameters) def.newInstance(); return this; }
@SuppressWarnings("unchecked") @Override public <T extends IBaseParameters> IOperationUntypedWithInputAndPartialOutput<T> withParameter(Class<T> theParameterType, String theName, IBase theValue) { Validate.notNull(theParameterType, "theParameterType must not be null"); Validate.notEmpty(theName, "theName must not be null"); Validate.notNull(theValue, "theValue must not be null"); myParametersDef = myContext.getResourceDefinition(theParameterType); myParameters = (IBaseParameters) myParametersDef.newInstance(); addParam(theName, theValue); return this; }
/** * Create an OperationOutcome resource which contains all of the messages found as a result of this validation */ public IBaseOperationOutcome toOperationOutcome() { IBaseOperationOutcome oo = (IBaseOperationOutcome) myCtx.getResourceDefinition("OperationOutcome").newInstance(); populateOperationOutcome(oo); return oo; }
@SuppressWarnings("unchecked") @Override public <T extends IBaseParameters> IOperationUntypedWithInputAndPartialOutput<T> withSearchParameter(Class<T> theParameterType, String theName, IQueryParameterType theValue) { Validate.notNull(theParameterType, "theParameterType must not be null"); Validate.notEmpty(theName, "theName must not be null"); Validate.notNull(theValue, "theValue must not be null"); myParametersDef = myContext.getResourceDefinition(theParameterType); myParameters = (IBaseParameters) myParametersDef.newInstance(); addParam(theName, theValue); return this; }
@Override public Object invokeClientForBinary(String theResponseMimeType, InputStream theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException, BaseServerResponseException { byte[] contents = IOUtils.toByteArray(theResponseReader); IBaseBinary resource = (IBaseBinary) getContext().getResourceDefinition("Binary").newInstance(); resource.setContentType(theResponseMimeType); resource.setContent(contents); switch (getMethodReturnType()) { case LIST_OF_RESOURCES: return Collections.singletonList(resource); case RESOURCE: return resource; case BUNDLE_RESOURCE: case METHOD_OUTCOME: break; } throw new IllegalStateException("" + getMethodReturnType()); // should not happen }
protected IBundleProvider toResourceList(Object response) throws InternalErrorException { if (response == null) { return BundleProviders.newEmptyList(); } else if (response instanceof IBundleProvider) { return (IBundleProvider) response; } else if (response instanceof IBaseResource) { return BundleProviders.newList((IBaseResource) response); } else if (response instanceof Collection) { List<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Object next : ((Collection<?>) response)) { retVal.add((IBaseResource) next); } return BundleProviders.newList(retVal); } else if (response instanceof MethodOutcome) { IBaseResource retVal = ((MethodOutcome) response).getOperationOutcome(); if (retVal == null) { retVal = getContext().getResourceDefinition("OperationOutcome").newInstance(); } return BundleProviders.newList(retVal); } else { throw new InternalErrorException("Unexpected return type: " + response.getClass().getCanonicalName()); } }
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (BundleEntryComponent next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdType id = new IdType(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IAnyResource res = (IAnyResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (BundleEntryComponent next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdType id = new IdType(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IBaseResource res = (IBaseResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (BundleEntryComponent next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdType id = new IdType(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IAnyResource res = (IAnyResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Entry next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdDt id = new IdDt(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IResource res = (IResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
public static BaseHttpClientInvocation createValidateInvocation(FhirContext theContext, IBaseResource theResource) { IBaseParameters parameters = (IBaseParameters) theContext.getResourceDefinition("Parameters").newInstance(); ParametersUtil.addParameterToParameters(theContext, parameters, "resource", theResource); String resourceName = theContext.getResourceDefinition(theResource).getName(); String resourceId = theResource.getIdElement().getIdPart(); BaseHttpClientInvocation retVal = createOperationInvocation(theContext, resourceName, resourceId, null,Constants.EXTOP_VALIDATE, parameters, false); return retVal; }
@Override public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException { String id = null; if (myIdParamIndex != null) { IIdType idDt = (IIdType) theArgs[myIdParamIndex]; id = idDt.getValue(); } IBaseParameters parameters = (IBaseParameters) getContext().getResourceDefinition("Parameters").newInstance(); if (theArgs != null) { for (int idx = 0; idx < theArgs.length; idx++) { IParameter nextParam = getParameters().get(idx); nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, parameters); } } return createOperationInvocation(getContext(), getResourceName(), id, null, myName, parameters, false); }
IBaseResource temporaryInstance = theContext.getResourceDefinition(resourceName).newInstance(); try { theContext.newFluentPath().evaluate(temporaryInstance, nextPath, IBase.class);
@SuppressWarnings("unchecked") private T readHtmlResponse(InputStream theResponseInputStream) { RuntimeResourceDefinition resDef = getFhirContext().getResourceDefinition(myReturnType); IBaseResource instance = resDef.newInstance(); BaseRuntimeChildDefinition textChild = resDef.getChildByName("text"); BaseRuntimeElementCompositeDefinition<?> textElement = (BaseRuntimeElementCompositeDefinition<?>) textChild.getChildByName("text"); IBase textInstance = textElement.newInstance(); textChild.getMutator().addValue(instance, textInstance); BaseRuntimeChildDefinition divChild = textElement.getChildByName("div"); BaseRuntimeElementDefinition<?> divElement = divChild.getChildByName("div"); IPrimitiveType<?> divInstance = (IPrimitiveType<?>) divElement.newInstance(); try { divInstance.setValueAsString(IOUtils.toString(theResponseInputStream, Charsets.UTF_8)); } catch (Exception e) { throw new InvalidResponseException(400, "Failed to process HTML response from server: " + e.getMessage(), e); } divChild.getMutator().addValue(textInstance, divInstance); return (T) instance; }
IBaseResource parameters = def.newInstance();
IBaseResource newResource = missingResourceDef.newInstance(); newResource.setId(resName + "/" + theId); IFhirResourceDao<IBaseResource> placeholderResourceDao = (IFhirResourceDao<IBaseResource>) myDaoRegistry.getResourceDao(newResource.getClass());
R retVal = (R) res; if (theEntity.getDeleted() != null) { res = (IResource) myContext.getResourceDefinition(theResourceType).newInstance(); retVal = (R) res; ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted()));
R retVal = (R) res; if (theEntity.getDeleted() != null) { res = (IAnyResource) myContext.getResourceDefinition(theResourceType).newInstance(); retVal = (R) res; ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted()));