@SuppressWarnings("unchecked") @Override public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) { return myContext.getResourceDefinition((Class<? extends IBaseResource>) theType); }
@Override public IDeleteWithQuery resourceConditionalByType(String theResourceType) { Validate.notBlank(theResourceType, "theResourceType can not be blank/null"); if (myContext.getResourceDefinition(theResourceType) == null) { throw new IllegalArgumentException("Unknown resource type: " + theResourceType); } myResourceType = theResourceType; myConditional = true; return this; }
@SuppressWarnings({"unchecked"}) @Override public IOperationUntypedWithInputAndPartialOutput withParameters(IBaseParameters theParameters) { Validate.notNull(theParameters, "theParameters can not be null"); myParameters = theParameters; myParametersDef = myContext.getResourceDefinition(theParameters.getClass()); return this; }
public static RuntimeResourceDefinition parseUrlResourceType(FhirContext theCtx, String theUrl) throws DataFormatException { int paramIndex = theUrl.indexOf('?'); String resourceName = theUrl.substring(0, paramIndex); if (resourceName.contains("/")) { resourceName = resourceName.substring(resourceName.lastIndexOf('/') + 1); } return theCtx.getResourceDefinition(resourceName); }
@Override public IDeleteWithQuery resourceConditionalByType(Class<? extends IBaseResource> theResourceType) { Validate.notNull(theResourceType, "theResourceType can not be null"); myConditional = true; myResourceType = myContext.getResourceDefinition(theResourceType).getName(); return this; }
private void setType(Class<? extends IBaseResource> theResourceType) { myResourceType = theResourceType; RuntimeResourceDefinition definition = myContext.getResourceDefinition(theResourceType); myResourceName = definition.getName(); }
private void initializeMaps(Collection<IFhirResourceDao> theResourceDaos) { myResourceNameToResourceDao = new HashMap<>(); for (IFhirResourceDao nextResourceDao : theResourceDaos) { RuntimeResourceDefinition nextResourceDef = myContext.getResourceDefinition(nextResourceDao.getResourceType()); myResourceNameToResourceDao.put(nextResourceDef.getName(), nextResourceDao); } }
@Override public <T extends IBaseResource> IReadTyped<T> resource(Class<T> theResourceType) { Validate.notNull(theResourceType, "theResourceType must not be null"); myType = myContext.getResourceDefinition(theResourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theResourceType)); } 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; }
public static IBaseReference getSecurityContext(FhirContext theCtx, IBaseBinary theBinary) { RuntimeResourceDefinition def = theCtx.getResourceDefinition("Binary"); BaseRuntimeChildDefinition child = def.getChildByName("securityContext"); IBaseReference retVal = null; if (child != null) { List<IBase> values = child.getAccessor().getValues(theBinary); if (values.size() > 0) { retVal = (IBaseReference) values.get(0); } } return retVal; }
public static HttpPutClientInvocation createUpdateInvocation(FhirContext theContext, IBaseResource theResource, String theResourceBody, Map<String, List<String>> theMatchParams) { String resourceType = theContext.getResourceDefinition(theResource).getName(); StringBuilder b = createUrl(resourceType, theMatchParams); HttpPutClientInvocation retVal; if (StringUtils.isBlank(theResourceBody)) { retVal = new HttpPutClientInvocation(theContext, theResource, b.toString()); } else { retVal = new HttpPutClientInvocation(theContext, theResourceBody, false, b.toString()); } return retVal; }
@Override protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IBaseResource theResource) { StringBuilder urlExtension = new StringBuilder(); urlExtension.append(getContext().getResourceDefinition(theResource).getName()); return new HttpPostClientInvocation(getContext(), theResource, urlExtension.toString()); }
public static String getBundleType(FhirContext theContext, IBaseBundle theBundle) { RuntimeResourceDefinition def = theContext.getResourceDefinition(theBundle); BaseRuntimeChildDefinition entryChild = def.getChildByName("type"); List<IBase> entries = entryChild.getAccessor().getValues(theBundle); if (entries.size() > 0) { IPrimitiveType<?> typeElement = (IPrimitiveType<?>) entries.get(0); return typeElement.getValueAsString(); } return null; }
public Collection<RuntimeSearchParam> getSearchParams(IBaseResource theResource) { RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource); Collection<RuntimeSearchParam> retVal = mySearchParamRegistry.getActiveSearchParams(def.getName()).values(); List<RuntimeSearchParam> defaultList = Collections.emptyList(); retVal = ObjectUtils.defaultIfNull(retVal, defaultList); return retVal; }
private void processUrl() { String resourceType = myId.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, myId)); } myType = myContext.getResourceDefinition(resourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, myId)); } }
@Override public void resourceUpdated(RequestDetails theRequest, IBaseResource theOldResource, IBaseResource theNewResource) { if (myDao.getContext().getResourceDefinition(theNewResource).getName().equals(ResourceTypeEnum.SUBSCRIPTION.getCode())) { verifyStatusOk(RestOperationTypeEnum.UPDATE, theOldResource, theNewResource); } }
@Override public void resourceUpdated(RequestDetails theRequest, IBaseResource theOldResource, IBaseResource theNewResource) { if (myDao.getContext().getResourceDefinition(theNewResource).getName().equals(ResourceTypeEnum.SUBSCRIPTION.getCode())) { verifyStatusOk(RestOperationTypeEnum.UPDATE, theOldResource, theNewResource); } }
@Override public void resourceUpdated(RequestDetails theRequest, IBaseResource theOldResource, IBaseResource theNewResource) { if (myDao.getContext().getResourceDefinition(theNewResource).getName().equals(ResourceTypeEnum.SUBSCRIPTION.getCode())) { verifyStatusOk(RestOperationTypeEnum.UPDATE, theOldResource, theNewResource); } }
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); }
public static void setSecurityContext(FhirContext theCtx, IBaseBinary theBinary, String theSecurityContext) { RuntimeResourceDefinition def = theCtx.getResourceDefinition("Binary"); BaseRuntimeChildDefinition child = def.getChildByName("securityContext"); BaseRuntimeElementDefinition<?> referenceDef = theCtx.getElementDefinition("reference"); IBaseReference reference = (IBaseReference) referenceDef.newInstance(); child.getMutator().addValue(theBinary, reference); reference.setReference(theSecurityContext); }