From ad0c51f600b8f36839ef9de7e92a1fcb5ebcb1a9 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 7 Jul 2015 17:41:59 -0400 Subject: [PATCH] Rename DAO classes per request from Ismael Sarmento Jr --- .../ca/uhn/fhir/model/primitive/IdDt.java | 3 ++ ...{BaseFhirDao.java => BaseHapiFhirDao.java} | 4 +-- ...eDao.java => BaseHapiFhirResourceDao.java} | 28 +++++++++---------- ...temDao.java => BaseHapiFhirSystemDao.java} | 4 +-- .../fhir/jpa/dao/FhirResourceDaoDstu1.java | 2 +- .../fhir/jpa/dao/FhirResourceDaoDstu2.java | 2 +- .../uhn/fhir/jpa/dao/FhirSystemDaoDstu1.java | 10 +++---- .../uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java | 18 ++++++------ .../jpa/dao/SearchParamExtractorDstu1.java | 14 +++++----- .../jpa/dao/SearchParamExtractorDstu2.java | 8 +++--- .../ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java | 2 +- .../jpa/dao/FhirResourceDaoDstu2Test.java | 6 ++-- .../fhir/jpa/dao/FhirSystemDaoDstu2Test.java | 2 +- .../org/hl7/fhir/instance/model/IIdType.java | 9 ++++++ 14 files changed, 62 insertions(+), 50 deletions(-) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/{BaseFhirDao.java => BaseHapiFhirDao.java} (99%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/{BaseFhirResourceDao.java => BaseHapiFhirResourceDao.java} (97%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/{BaseFhirSystemDao.java => BaseHapiFhirSystemDao.java} (96%) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java index 61d1f7186f8..5bca7c1b121 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java @@ -548,6 +548,9 @@ public class IdDt extends UriDt implements IPrimitiveDatatype, IIdType { @Override public IdDt toUnqualifiedVersionless() { + if (isLocal()) { + return toVersionless(); + } return new IdDt(getResourceType(), getIdPart()); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java similarity index 99% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirDao.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index 77685987c34..0d8cc68dfde 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -112,10 +112,10 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; -public abstract class BaseFhirDao implements IDao { +public abstract class BaseHapiFhirDao implements IDao { public static final String NS_JPA_PROFILE = "https://github.com/jamesagnew/hapi-fhir/ns/jpa/profile"; - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseFhirDao.class); + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirDao.class); private static final Map ourRetrievalContexts = new HashMap(); public static final String UCUM_NS = "http://unitsofmeasure.org"; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java similarity index 97% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index d64ec877ff6..d9245debeae 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -129,9 +129,9 @@ import ca.uhn.fhir.util.FhirTerser; import ca.uhn.fhir.util.ObjectUtil; @Transactional(propagation = Propagation.REQUIRED) -public abstract class BaseFhirResourceDao extends BaseFhirDao implements IFhirResourceDao { +public abstract class BaseHapiFhirResourceDao extends BaseHapiFhirDao implements IFhirResourceDao { - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseFhirResourceDao.class); + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirResourceDao.class); @PersistenceContext(type = PersistenceContextType.TRANSACTION) private EntityManager myEntityManager; @@ -654,7 +654,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD } if (!foundChainMatch) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "invalidParameterChain", theParamName + '.' + ref.getChain())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "invalidParameterChain", theParamName + '.' + ref.getChain())); } } @@ -730,7 +730,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD boolean missingFalse = false; if (nextOr.getMissing() != null) { if (nextOr.getMissing().booleanValue() == true) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "multipleParamsWithSameNameOneIsMissingTrue", theParamName)); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "multipleParamsWithSameNameOneIsMissingTrue", theParamName)); } Predicate singleCode = from.get("myId").isNotNull(); Predicate name = theBuilder.equal(from.get("myParamName"), theParamName); @@ -745,7 +745,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD boolean missingFalse = false; if (nextOr.getMissing() != null) { if (nextOr.getMissing().booleanValue() == true) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "multipleParamsWithSameNameOneIsMissingTrue", theParamName)); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "multipleParamsWithSameNameOneIsMissingTrue", theParamName)); } Predicate singleCode = from.get("mySourceResource").isNotNull(); Predicate name = createResourceLinkPathPredicate(theParamName, theBuilder, from); @@ -857,10 +857,10 @@ public abstract class BaseFhirResourceDao extends BaseFhirD if (isNotBlank(theResource.getId().getIdPart())) { if (getContext().getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) { if (theResource.getId().isIdPartValidLong()) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart())); } } else { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getId().getIdPart())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getId().getIdPart())); } } @@ -1117,9 +1117,9 @@ public abstract class BaseFhirResourceDao extends BaseFhirD Set resource = processMatchUrl(theUrl, myResourceType); if (resource.isEmpty()) { - throw new ResourceNotFoundException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "unableToDeleteNotFound", theUrl)); + throw new ResourceNotFoundException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "unableToDeleteNotFound", theUrl)); } else if (resource.size() > 1) { - throw new ResourceNotFoundException(getContext().getLocalizer().getMessage(BaseFhirDao.class, "transactionOperationWithMultipleMatchFailure", "DELETE", theUrl, resource.size())); + throw new ResourceNotFoundException(getContext().getLocalizer().getMessage(BaseHapiFhirDao.class, "transactionOperationWithMultipleMatchFailure", "DELETE", theUrl, resource.size())); } Long pid = resource.iterator().next(); @@ -1144,7 +1144,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD if (isNotBlank(theIfNoneExist)) { Set match = processMatchUrl(theIfNoneExist, myResourceType); if (match.size() > 1) { - String msg = getContext().getLocalizer().getMessage(BaseFhirDao.class, "transactionOperationWithMultipleMatchFailure", "CREATE", theIfNoneExist, match.size()); + String msg = getContext().getLocalizer().getMessage(BaseHapiFhirDao.class, "transactionOperationWithMultipleMatchFailure", "CREATE", theIfNoneExist, match.size()); throw new PreconditionFailedException(msg); } else if (match.size() == 1) { Long pid = match.iterator().next(); @@ -1163,7 +1163,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD if (entity.getForcedId() != null) { try { translateForcedIdToPid(theResource.getId()); - throw new UnprocessableEntityException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "duplicateCreateForcedId", theResource.getId().getIdPart())); + throw new UnprocessableEntityException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "duplicateCreateForcedId", theResource.getId().getIdPart())); } catch (ResourceNotFoundException e) { // good, this ID doesn't exist so we can create it } @@ -2052,7 +2052,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD retVal.add(new TagDefinition(TagTypeEnum.SECURITY_LABEL, next.getSystem(), next.getCode(), next.getDisplay())); } for (UriDt next : theMeta.getProfile()) { - retVal.add(new TagDefinition(TagTypeEnum.PROFILE, BaseFhirDao.NS_JPA_PROFILE, next.getValue(), null)); + retVal.add(new TagDefinition(TagTypeEnum.PROFILE, BaseHapiFhirDao.NS_JPA_PROFILE, next.getValue(), null)); } return retVal; @@ -2080,7 +2080,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD if (isNotBlank(theMatchUrl)) { Set match = processMatchUrl(theMatchUrl, myResourceType); if (match.size() > 1) { - String msg = getContext().getLocalizer().getMessage(BaseFhirDao.class, "transactionOperationWithMultipleMatchFailure", "UPDATE", theMatchUrl, match.size()); + String msg = getContext().getLocalizer().getMessage(BaseHapiFhirDao.class, "transactionOperationWithMultipleMatchFailure", "UPDATE", theMatchUrl, match.size()); throw new PreconditionFailedException(msg); } else if (match.size() == 1) { Long pid = match.iterator().next(); @@ -2098,7 +2098,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD entity = readEntityLatestVersion(resourceId); } catch (ResourceNotFoundException e) { if (Character.isDigit(theResource.getId().getIdPart().charAt(0))) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart())); } return doCreate(theResource, null, thePerformIndexing); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirSystemDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java similarity index 96% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirSystemDao.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java index 9476595f5c9..386bb146395 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirSystemDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java @@ -44,8 +44,8 @@ import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.rest.server.IBundleProvider; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -public abstract class BaseFhirSystemDao extends BaseFhirDao implements IFhirSystemDao { - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseFhirSystemDao.class); +public abstract class BaseHapiFhirSystemDao extends BaseHapiFhirDao implements IFhirSystemDao { + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirSystemDao.class); @Transactional(propagation=Propagation.REQUIRED) @Override diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1.java index 499d2fe0221..b4cdf461e5b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1.java @@ -32,7 +32,7 @@ import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; import ca.uhn.fhir.util.FhirTerser; -public class FhirResourceDaoDstu1 extends BaseFhirResourceDao { +public class FhirResourceDaoDstu1 extends BaseHapiFhirResourceDao { protected List getIncludeValues(FhirTerser t, Include next, IBaseResource nextResource, RuntimeResourceDefinition def) { List values; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2.java index ce7004c1d47..8621c2f9eb5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2.java @@ -33,7 +33,7 @@ import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; import ca.uhn.fhir.util.FhirTerser; -public class FhirResourceDaoDstu2 extends BaseFhirResourceDao { +public class FhirResourceDaoDstu2 extends BaseHapiFhirResourceDao { protected List getIncludeValues(FhirTerser theTerser, Include theInclude, IBaseResource theResource, RuntimeResourceDefinition theResourceDef) { List values; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1.java index d72035de774..355a06930f4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1.java @@ -47,7 +47,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; import ca.uhn.fhir.util.FhirTerser; -public class FhirSystemDaoDstu1 extends BaseFhirSystemDao> { +public class FhirSystemDaoDstu1 extends BaseHapiFhirSystemDao> { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu1.class); @Override @@ -123,14 +123,14 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao> { } else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.PUT || nextResouceOperationIn == BundleEntryTransactionMethodEnum.DELETE) { if (candidateMatches == null || candidateMatches.size() == 0) { if (nextId == null || StringUtils.isBlank(nextId.getIdPart())) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationFailedNoId", nextResouceOperationIn.name())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionOperationFailedNoId", nextResouceOperationIn.name())); } entity = tryToLoadEntity(nextId); if (entity == null) { if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.PUT) { ourLog.debug("Attempting to UPDATE resource with unknown ID '{}', will CREATE instead", nextId); } else if (candidateMatches == null) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationFailedUnknownId", nextResouceOperationIn.name(), nextId)); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionOperationFailedUnknownId", nextResouceOperationIn.name(), nextId)); } else { ourLog.debug("Resource with match URL [{}] already exists, will be NOOP", matchUrl); persistedResources.add(null); @@ -141,7 +141,7 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao> { } else if (candidateMatches.size() == 1) { entity = loadFirstEntityFromCandidateMatches(candidateMatches); } else { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", nextResouceOperationIn.name(), matchUrl, candidateMatches.size())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", nextResouceOperationIn.name(), matchUrl, candidateMatches.size())); } } else if (nextId.isEmpty() || isPlaceholder(nextId)) { entity = null; @@ -169,7 +169,7 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao> { continue; } if (candidateMatches.size() > 1) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", BundleEntryTransactionMethodEnum.POST.name(), matchUrl, candidateMatches.size())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", BundleEntryTransactionMethodEnum.POST.name(), matchUrl, candidateMatches.size())); } } } else { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java index 93690a9560f..1f8ea4b55c7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java @@ -58,13 +58,13 @@ import ca.uhn.fhir.rest.server.IBundleProvider; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.util.FhirTerser; -public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { +public class FhirSystemDaoDstu2 extends BaseHapiFhirSystemDao { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu2.class); private String extractTransactionUrlOrThrowException(Entry nextEntry, HTTPVerbEnum verb) { String url = nextEntry.getTransaction().getUrl(); if (isBlank(url)) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionMissingUrl", verb.name())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionMissingUrl", verb.name())); } return url; } @@ -111,7 +111,7 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { if (nextSubstring.equals(Constants.URL_TOKEN_HISTORY)) { nextIsHistory = true; } else { - String msg = getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); + String msg = getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); throw new InvalidRequestException(msg); } } @@ -129,7 +129,7 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { try { resType = getContext().getResourceDefinition(retVal.getResourceType()); } catch (DataFormatException e) { - String msg = getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); + String msg = getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); throw new InvalidRequestException(msg); } IFhirResourceDao dao = null; @@ -137,13 +137,13 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { dao = getDao(resType.getImplementingClass()); } if (dao == null) { - String msg = getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); + String msg = getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); throw new InvalidRequestException(msg); } retVal.setDao(dao); if (retVal.getResourceId() == null && retVal.getParams() == null) { - String msg = getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); + String msg = getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionInvalidUrl", theAction, theUrl); throw new InvalidRequestException(msg); } @@ -182,12 +182,12 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { */ if (isPlaceholder(nextResourceId)) { if (!allIds.add(nextResourceId)) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextResourceId)); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextResourceId)); } } else if (nextResourceId.hasResourceType() && nextResourceId.hasIdPart()) { IdDt nextId = nextResourceId.toUnqualifiedVersionless(); if (!allIds.add(nextId)) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextId)); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextId)); } } @@ -195,7 +195,7 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { HTTPVerbEnum verb = nextEntry.getTransaction().getMethodElement().getValueAsEnum(); if (verb == null) { - throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionEntryHasInvalidVerb", nextEntry.getTransaction().getMethod())); + throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionEntryHasInvalidVerb", nextEntry.getTransaction().getMethod())); } String resourceType = res != null ? getContext().getResourceDefinition(res).getName() : null; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu1.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu1.java index 33ebb63a792..d5b14b68bd9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu1.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu1.java @@ -160,14 +160,14 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea continue; } - if (new UriDt(BaseFhirDao.UCUM_NS).equals(nextValue.getSystem())) { + if (new UriDt(BaseHapiFhirDao.UCUM_NS).equals(nextValue.getSystem())) { if (isNotBlank(nextValue.getCode().getValue())) { Unit unit = Unit.valueOf(nextValue.getCode().getValue()); javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY); double dayValue = dayConverter.convert(nextValue.getValue().getValue().doubleValue()); DurationDt newValue = new DurationDt(); - newValue.setSystem(BaseFhirDao.UCUM_NS); + newValue.setSystem(BaseHapiFhirDao.UCUM_NS); newValue.setCode(NonSI.DAY.toString()); newValue.setValue(dayValue); nextValue = newValue; @@ -309,7 +309,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea searchTerm = searchTerm.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); } - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseFhirDao.normalizeString(searchTerm), searchTerm); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseHapiFhirDao.normalizeString(searchTerm), searchTerm); nextEntity.setResource(theEntity); retVal.add(nextEntity); } else { @@ -322,7 +322,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea if (nextName.isEmpty()) { continue; } - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseFhirDao.normalizeString(nextName.getValueAsString()), nextName.getValueAsString()); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseHapiFhirDao.normalizeString(nextName.getValueAsString()), nextName.getValueAsString()); nextEntity.setResource(theEntity); retVal.add(nextEntity); } @@ -338,14 +338,14 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea if (nextName.isEmpty()) { continue; } - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseFhirDao.normalizeString(nextName.getValueAsString()), nextName.getValueAsString()); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseHapiFhirDao.normalizeString(nextName.getValueAsString()), nextName.getValueAsString()); nextEntity.setResource(theEntity); retVal.add(nextEntity); } } else if (nextObject instanceof ContactDt) { ContactDt nextContact = (ContactDt) nextObject; if (nextContact.getValue().isEmpty() == false) { - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseFhirDao.normalizeString(nextContact.getValue().getValueAsString()), nextContact.getValue().getValueAsString()); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseHapiFhirDao.normalizeString(nextContact.getValue().getValueAsString()), nextContact.getValue().getValueAsString()); nextEntity.setResource(theEntity); retVal.add(nextEntity); } @@ -404,7 +404,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea } else if (nextObject instanceof CodeableConceptDt) { CodeableConceptDt nextCC = (CodeableConceptDt) nextObject; if (!nextCC.getText().isEmpty()) { - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(nextSpDef.getName(), BaseFhirDao.normalizeString(nextCC.getText().getValue()), nextCC.getText().getValue()); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(nextSpDef.getName(), BaseHapiFhirDao.normalizeString(nextCC.getText().getValue()), nextCC.getText().getValue()); nextEntity.setResource(theEntity); retVal.add(nextEntity); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java index d10b16a7cfb..0110f0b5c56 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java @@ -177,14 +177,14 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea continue; } - if (new UriDt(BaseFhirDao.UCUM_NS).equals(nextValue.getSystemElement())) { + if (new UriDt(BaseHapiFhirDao.UCUM_NS).equals(nextValue.getSystemElement())) { if (isNotBlank(nextValue.getCode())) { Unit unit = Unit.valueOf(nextValue.getCode()); javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY); double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); DurationDt newValue = new DurationDt(); - newValue.setSystem(BaseFhirDao.UCUM_NS); + newValue.setSystem(BaseHapiFhirDao.UCUM_NS); newValue.setCode(NonSI.DAY.toString()); newValue.setValue(dayValue); nextValue = newValue; @@ -390,7 +390,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea searchTerm = searchTerm.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); } - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseFhirDao.normalizeString(searchTerm), searchTerm); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, BaseHapiFhirDao.normalizeString(searchTerm), searchTerm); nextEntity.setResource(theEntity); retVal.add(nextEntity); } @@ -476,7 +476,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea if (value.length() > ResourceIndexedSearchParamString.MAX_LENGTH) { value = value.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); } - ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(nextSpDef.getName(), BaseFhirDao.normalizeString(value), value); + ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(nextSpDef.getName(), BaseHapiFhirDao.normalizeString(value), value); nextEntity.setResource(theEntity); retVal.add(nextEntity); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java index ff538892abd..bc7a59bc011 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java @@ -13,7 +13,7 @@ public class BaseFhirDaoTest extends BaseJpaTest { @Test public void testTranslateMatchUrl() { - SearchParameterMap match = BaseFhirDao.translateMatchUrl("Condition?subject=304&_lastUpdated=>2011-01-01T11:12:21.0000Z", ourCtx.getResourceDefinition(Condition.class)); + SearchParameterMap match = BaseHapiFhirDao.translateMatchUrl("Condition?subject=304&_lastUpdated=>2011-01-01T11:12:21.0000Z", ourCtx.getResourceDefinition(Condition.class)); assertEquals("2011-01-01T11:12:21.0000Z", match.getLastUpdated().getLowerBound().getValueAsString()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java index c001a48c0cd..b64e08d4a33 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java @@ -1157,7 +1157,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest { ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog"); ourPatientDao.removeTag(id1, TagTypeEnum.SECURITY_LABEL, "seclabel:sys:1", "seclabel:code:1"); - ourPatientDao.removeTag(id1, TagTypeEnum.PROFILE, BaseFhirDao.NS_JPA_PROFILE, "http://profile/1"); + ourPatientDao.removeTag(id1, TagTypeEnum.PROFILE, BaseHapiFhirDao.NS_JPA_PROFILE, "http://profile/1"); meta = ourPatientDao.metaGetOperation(); published = meta.getTag(); @@ -1481,12 +1481,12 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest { public void testSearchNumberParam() { Encounter e1 = new Encounter(); e1.addIdentifier().setSystem("foo").setValue("testSearchNumberParam01"); - e1.getLength().setSystem(BaseFhirDao.UCUM_NS).setCode("min").setValue(4.0 * 24 * 60); + e1.getLength().setSystem(BaseHapiFhirDao.UCUM_NS).setCode("min").setValue(4.0 * 24 * 60); IIdType id1 = ourEncounterDao.create(e1).getId(); Encounter e2 = new Encounter(); e2.addIdentifier().setSystem("foo").setValue("testSearchNumberParam02"); - e2.getLength().setSystem(BaseFhirDao.UCUM_NS).setCode("year").setValue(2.0); + e2.getLength().setSystem(BaseHapiFhirDao.UCUM_NS).setCode("year").setValue(2.0); IIdType id2 = ourEncounterDao.create(e2).getId(); { IBundleProvider found = ourEncounterDao.search(Encounter.SP_LENGTH, new NumberParam(">2")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java index eca31dacf11..20e0e6081a5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java @@ -127,7 +127,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaTest { ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog"); ourPatientDao.removeTag(id1, TagTypeEnum.SECURITY_LABEL, "seclabel:sys:1", "seclabel:code:1"); - ourPatientDao.removeTag(id1, TagTypeEnum.PROFILE, BaseFhirDao.NS_JPA_PROFILE, "http://profile/1"); + ourPatientDao.removeTag(id1, TagTypeEnum.PROFILE, BaseHapiFhirDao.NS_JPA_PROFILE, "http://profile/1"); meta = ourSystemDao.metaGetOperation(); published = meta.getTag(); diff --git a/hapi-tinder-plugin/src/main/java/org/hl7/fhir/instance/model/IIdType.java b/hapi-tinder-plugin/src/main/java/org/hl7/fhir/instance/model/IIdType.java index e6fac55fbdd..7d4b627dfc6 100644 --- a/hapi-tinder-plugin/src/main/java/org/hl7/fhir/instance/model/IIdType.java +++ b/hapi-tinder-plugin/src/main/java/org/hl7/fhir/instance/model/IIdType.java @@ -26,6 +26,9 @@ public interface IIdType { boolean isEmpty(); + /** + * Returns true if this ID represents a local reference (i.e. a reference beginning with the character '#') + */ boolean isLocal(); /** @@ -46,8 +49,14 @@ public interface IIdType { String getBaseUrl(); + /** + * Returns a copy of this ID without the base URL or the version + */ IIdType toUnqualifiedVersionless(); + /** + * Returns a copy of this ID without the version + */ IIdType toVersionless(); IIdType setValue(String theString);