Rename DAO classes per request from Ismael Sarmento Jr
This commit is contained in:
parent
d20b7e2c94
commit
ad0c51f600
|
@ -548,6 +548,9 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdDt toUnqualifiedVersionless() {
|
public IdDt toUnqualifiedVersionless() {
|
||||||
|
if (isLocal()) {
|
||||||
|
return toVersionless();
|
||||||
|
}
|
||||||
return new IdDt(getResourceType(), getIdPart());
|
return new IdDt(getResourceType(), getIdPart());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,10 +112,10 @@ import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.Lists;
|
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";
|
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<FhirVersionEnum, FhirContext> ourRetrievalContexts = new HashMap<FhirVersionEnum, FhirContext>();
|
private static final Map<FhirVersionEnum, FhirContext> ourRetrievalContexts = new HashMap<FhirVersionEnum, FhirContext>();
|
||||||
public static final String UCUM_NS = "http://unitsofmeasure.org";
|
public static final String UCUM_NS = "http://unitsofmeasure.org";
|
|
@ -129,9 +129,9 @@ import ca.uhn.fhir.util.FhirTerser;
|
||||||
import ca.uhn.fhir.util.ObjectUtil;
|
import ca.uhn.fhir.util.ObjectUtil;
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
@Transactional(propagation = Propagation.REQUIRED)
|
||||||
public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirDao implements IFhirResourceDao<T> {
|
public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseHapiFhirDao implements IFhirResourceDao<T> {
|
||||||
|
|
||||||
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)
|
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
|
||||||
private EntityManager myEntityManager;
|
private EntityManager myEntityManager;
|
||||||
|
@ -654,7 +654,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundChainMatch) {
|
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<T extends IResource> extends BaseFhirD
|
||||||
boolean missingFalse = false;
|
boolean missingFalse = false;
|
||||||
if (nextOr.getMissing() != null) {
|
if (nextOr.getMissing() != null) {
|
||||||
if (nextOr.getMissing().booleanValue() == true) {
|
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 singleCode = from.get("myId").isNotNull();
|
||||||
Predicate name = theBuilder.equal(from.get("myParamName"), theParamName);
|
Predicate name = theBuilder.equal(from.get("myParamName"), theParamName);
|
||||||
|
@ -745,7 +745,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
boolean missingFalse = false;
|
boolean missingFalse = false;
|
||||||
if (nextOr.getMissing() != null) {
|
if (nextOr.getMissing() != null) {
|
||||||
if (nextOr.getMissing().booleanValue() == true) {
|
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 singleCode = from.get("mySourceResource").isNotNull();
|
||||||
Predicate name = createResourceLinkPathPredicate(theParamName, theBuilder, from);
|
Predicate name = createResourceLinkPathPredicate(theParamName, theBuilder, from);
|
||||||
|
@ -857,10 +857,10 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
if (isNotBlank(theResource.getId().getIdPart())) {
|
if (isNotBlank(theResource.getId().getIdPart())) {
|
||||||
if (getContext().getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) {
|
if (getContext().getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) {
|
||||||
if (theResource.getId().isIdPartValidLong()) {
|
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 {
|
} 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<T extends IResource> extends BaseFhirD
|
||||||
|
|
||||||
Set<Long> resource = processMatchUrl(theUrl, myResourceType);
|
Set<Long> resource = processMatchUrl(theUrl, myResourceType);
|
||||||
if (resource.isEmpty()) {
|
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) {
|
} 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();
|
Long pid = resource.iterator().next();
|
||||||
|
@ -1144,7 +1144,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
if (isNotBlank(theIfNoneExist)) {
|
if (isNotBlank(theIfNoneExist)) {
|
||||||
Set<Long> match = processMatchUrl(theIfNoneExist, myResourceType);
|
Set<Long> match = processMatchUrl(theIfNoneExist, myResourceType);
|
||||||
if (match.size() > 1) {
|
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);
|
throw new PreconditionFailedException(msg);
|
||||||
} else if (match.size() == 1) {
|
} else if (match.size() == 1) {
|
||||||
Long pid = match.iterator().next();
|
Long pid = match.iterator().next();
|
||||||
|
@ -1163,7 +1163,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
if (entity.getForcedId() != null) {
|
if (entity.getForcedId() != null) {
|
||||||
try {
|
try {
|
||||||
translateForcedIdToPid(theResource.getId());
|
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) {
|
} catch (ResourceNotFoundException e) {
|
||||||
// good, this ID doesn't exist so we can create it
|
// good, this ID doesn't exist so we can create it
|
||||||
}
|
}
|
||||||
|
@ -2052,7 +2052,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
retVal.add(new TagDefinition(TagTypeEnum.SECURITY_LABEL, next.getSystem(), next.getCode(), next.getDisplay()));
|
retVal.add(new TagDefinition(TagTypeEnum.SECURITY_LABEL, next.getSystem(), next.getCode(), next.getDisplay()));
|
||||||
}
|
}
|
||||||
for (UriDt next : theMeta.getProfile()) {
|
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;
|
return retVal;
|
||||||
|
@ -2080,7 +2080,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
if (isNotBlank(theMatchUrl)) {
|
if (isNotBlank(theMatchUrl)) {
|
||||||
Set<Long> match = processMatchUrl(theMatchUrl, myResourceType);
|
Set<Long> match = processMatchUrl(theMatchUrl, myResourceType);
|
||||||
if (match.size() > 1) {
|
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);
|
throw new PreconditionFailedException(msg);
|
||||||
} else if (match.size() == 1) {
|
} else if (match.size() == 1) {
|
||||||
Long pid = match.iterator().next();
|
Long pid = match.iterator().next();
|
||||||
|
@ -2098,7 +2098,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
|
||||||
entity = readEntityLatestVersion(resourceId);
|
entity = readEntityLatestVersion(resourceId);
|
||||||
} catch (ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
if (Character.isDigit(theResource.getId().getIdPart().charAt(0))) {
|
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);
|
return doCreate(theResource, null, thePerformIndexing);
|
||||||
}
|
}
|
|
@ -44,8 +44,8 @@ import ca.uhn.fhir.model.primitive.InstantDt;
|
||||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
|
|
||||||
public abstract class BaseFhirSystemDao<T> extends BaseFhirDao implements IFhirSystemDao<T> {
|
public abstract class BaseHapiFhirSystemDao<T> extends BaseHapiFhirDao implements IFhirSystemDao<T> {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseFhirSystemDao.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirSystemDao.class);
|
||||||
|
|
||||||
@Transactional(propagation=Propagation.REQUIRED)
|
@Transactional(propagation=Propagation.REQUIRED)
|
||||||
@Override
|
@Override
|
|
@ -32,7 +32,7 @@ import ca.uhn.fhir.model.api.Include;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
import ca.uhn.fhir.util.FhirTerser;
|
||||||
|
|
||||||
public class FhirResourceDaoDstu1<T extends IResource> extends BaseFhirResourceDao<T> {
|
public class FhirResourceDaoDstu1<T extends IResource> extends BaseHapiFhirResourceDao<T> {
|
||||||
|
|
||||||
protected List<Object> getIncludeValues(FhirTerser t, Include next, IBaseResource nextResource, RuntimeResourceDefinition def) {
|
protected List<Object> getIncludeValues(FhirTerser t, Include next, IBaseResource nextResource, RuntimeResourceDefinition def) {
|
||||||
List<Object> values;
|
List<Object> values;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import ca.uhn.fhir.model.api.Include;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
import ca.uhn.fhir.util.FhirTerser;
|
||||||
|
|
||||||
public class FhirResourceDaoDstu2<T extends IResource> extends BaseFhirResourceDao<T> {
|
public class FhirResourceDaoDstu2<T extends IResource> extends BaseHapiFhirResourceDao<T> {
|
||||||
|
|
||||||
protected List<Object> getIncludeValues(FhirTerser theTerser, Include theInclude, IBaseResource theResource, RuntimeResourceDefinition theResourceDef) {
|
protected List<Object> getIncludeValues(FhirTerser theTerser, Include theInclude, IBaseResource theResource, RuntimeResourceDefinition theResourceDef) {
|
||||||
List<Object> values;
|
List<Object> values;
|
||||||
|
|
|
@ -47,7 +47,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
|
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
import ca.uhn.fhir.util.FhirTerser;
|
||||||
|
|
||||||
public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
public class FhirSystemDaoDstu1 extends BaseHapiFhirSystemDao<List<IResource>> {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu1.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu1.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,14 +123,14 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
} else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.PUT || nextResouceOperationIn == BundleEntryTransactionMethodEnum.DELETE) {
|
} else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.PUT || nextResouceOperationIn == BundleEntryTransactionMethodEnum.DELETE) {
|
||||||
if (candidateMatches == null || candidateMatches.size() == 0) {
|
if (candidateMatches == null || candidateMatches.size() == 0) {
|
||||||
if (nextId == null || StringUtils.isBlank(nextId.getIdPart())) {
|
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);
|
entity = tryToLoadEntity(nextId);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.PUT) {
|
if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.PUT) {
|
||||||
ourLog.debug("Attempting to UPDATE resource with unknown ID '{}', will CREATE instead", nextId);
|
ourLog.debug("Attempting to UPDATE resource with unknown ID '{}', will CREATE instead", nextId);
|
||||||
} else if (candidateMatches == null) {
|
} 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 {
|
} else {
|
||||||
ourLog.debug("Resource with match URL [{}] already exists, will be NOOP", matchUrl);
|
ourLog.debug("Resource with match URL [{}] already exists, will be NOOP", matchUrl);
|
||||||
persistedResources.add(null);
|
persistedResources.add(null);
|
||||||
|
@ -141,7 +141,7 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
} else if (candidateMatches.size() == 1) {
|
} else if (candidateMatches.size() == 1) {
|
||||||
entity = loadFirstEntityFromCandidateMatches(candidateMatches);
|
entity = loadFirstEntityFromCandidateMatches(candidateMatches);
|
||||||
} else {
|
} 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)) {
|
} else if (nextId.isEmpty() || isPlaceholder(nextId)) {
|
||||||
entity = null;
|
entity = null;
|
||||||
|
@ -169,7 +169,7 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (candidateMatches.size() > 1) {
|
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 {
|
} else {
|
||||||
|
|
|
@ -58,13 +58,13 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
import ca.uhn.fhir.util.FhirTerser;
|
||||||
|
|
||||||
public class FhirSystemDaoDstu2 extends BaseFhirSystemDao<Bundle> {
|
public class FhirSystemDaoDstu2 extends BaseHapiFhirSystemDao<Bundle> {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu2.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu2.class);
|
||||||
|
|
||||||
private String extractTransactionUrlOrThrowException(Entry nextEntry, HTTPVerbEnum verb) {
|
private String extractTransactionUrlOrThrowException(Entry nextEntry, HTTPVerbEnum verb) {
|
||||||
String url = nextEntry.getTransaction().getUrl();
|
String url = nextEntry.getTransaction().getUrl();
|
||||||
if (isBlank(url)) {
|
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;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao<Bundle> {
|
||||||
if (nextSubstring.equals(Constants.URL_TOKEN_HISTORY)) {
|
if (nextSubstring.equals(Constants.URL_TOKEN_HISTORY)) {
|
||||||
nextIsHistory = true;
|
nextIsHistory = true;
|
||||||
} else {
|
} 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);
|
throw new InvalidRequestException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao<Bundle> {
|
||||||
try {
|
try {
|
||||||
resType = getContext().getResourceDefinition(retVal.getResourceType());
|
resType = getContext().getResourceDefinition(retVal.getResourceType());
|
||||||
} catch (DataFormatException e) {
|
} 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);
|
throw new InvalidRequestException(msg);
|
||||||
}
|
}
|
||||||
IFhirResourceDao<? extends IResource> dao = null;
|
IFhirResourceDao<? extends IResource> dao = null;
|
||||||
|
@ -137,13 +137,13 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao<Bundle> {
|
||||||
dao = getDao(resType.getImplementingClass());
|
dao = getDao(resType.getImplementingClass());
|
||||||
}
|
}
|
||||||
if (dao == null) {
|
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);
|
throw new InvalidRequestException(msg);
|
||||||
}
|
}
|
||||||
retVal.setDao(dao);
|
retVal.setDao(dao);
|
||||||
|
|
||||||
if (retVal.getResourceId() == null && retVal.getParams() == null) {
|
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);
|
throw new InvalidRequestException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,12 +182,12 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao<Bundle> {
|
||||||
*/
|
*/
|
||||||
if (isPlaceholder(nextResourceId)) {
|
if (isPlaceholder(nextResourceId)) {
|
||||||
if (!allIds.add(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()) {
|
} else if (nextResourceId.hasResourceType() && nextResourceId.hasIdPart()) {
|
||||||
IdDt nextId = nextResourceId.toUnqualifiedVersionless();
|
IdDt nextId = nextResourceId.toUnqualifiedVersionless();
|
||||||
if (!allIds.add(nextId)) {
|
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<Bundle> {
|
||||||
|
|
||||||
HTTPVerbEnum verb = nextEntry.getTransaction().getMethodElement().getValueAsEnum();
|
HTTPVerbEnum verb = nextEntry.getTransaction().getMethodElement().getValueAsEnum();
|
||||||
if (verb == null) {
|
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;
|
String resourceType = res != null ? getContext().getResourceDefinition(res).getName() : null;
|
||||||
|
|
|
@ -160,14 +160,14 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new UriDt(BaseFhirDao.UCUM_NS).equals(nextValue.getSystem())) {
|
if (new UriDt(BaseHapiFhirDao.UCUM_NS).equals(nextValue.getSystem())) {
|
||||||
if (isNotBlank(nextValue.getCode().getValue())) {
|
if (isNotBlank(nextValue.getCode().getValue())) {
|
||||||
|
|
||||||
Unit<? extends Quantity> unit = Unit.valueOf(nextValue.getCode().getValue());
|
Unit<? extends Quantity> unit = Unit.valueOf(nextValue.getCode().getValue());
|
||||||
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY);
|
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY);
|
||||||
double dayValue = dayConverter.convert(nextValue.getValue().getValue().doubleValue());
|
double dayValue = dayConverter.convert(nextValue.getValue().getValue().doubleValue());
|
||||||
DurationDt newValue = new DurationDt();
|
DurationDt newValue = new DurationDt();
|
||||||
newValue.setSystem(BaseFhirDao.UCUM_NS);
|
newValue.setSystem(BaseHapiFhirDao.UCUM_NS);
|
||||||
newValue.setCode(NonSI.DAY.toString());
|
newValue.setCode(NonSI.DAY.toString());
|
||||||
newValue.setValue(dayValue);
|
newValue.setValue(dayValue);
|
||||||
nextValue = newValue;
|
nextValue = newValue;
|
||||||
|
@ -309,7 +309,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
|
||||||
searchTerm = searchTerm.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH);
|
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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
} else {
|
} else {
|
||||||
|
@ -322,7 +322,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
|
||||||
if (nextName.isEmpty()) {
|
if (nextName.isEmpty()) {
|
||||||
continue;
|
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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
|
@ -338,14 +338,14 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
|
||||||
if (nextName.isEmpty()) {
|
if (nextName.isEmpty()) {
|
||||||
continue;
|
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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
} else if (nextObject instanceof ContactDt) {
|
} else if (nextObject instanceof ContactDt) {
|
||||||
ContactDt nextContact = (ContactDt) nextObject;
|
ContactDt nextContact = (ContactDt) nextObject;
|
||||||
if (nextContact.getValue().isEmpty() == false) {
|
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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
|
||||||
} else if (nextObject instanceof CodeableConceptDt) {
|
} else if (nextObject instanceof CodeableConceptDt) {
|
||||||
CodeableConceptDt nextCC = (CodeableConceptDt) nextObject;
|
CodeableConceptDt nextCC = (CodeableConceptDt) nextObject;
|
||||||
if (!nextCC.getText().isEmpty()) {
|
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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,14 +177,14 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new UriDt(BaseFhirDao.UCUM_NS).equals(nextValue.getSystemElement())) {
|
if (new UriDt(BaseHapiFhirDao.UCUM_NS).equals(nextValue.getSystemElement())) {
|
||||||
if (isNotBlank(nextValue.getCode())) {
|
if (isNotBlank(nextValue.getCode())) {
|
||||||
|
|
||||||
Unit<? extends Quantity> unit = Unit.valueOf(nextValue.getCode());
|
Unit<? extends Quantity> unit = Unit.valueOf(nextValue.getCode());
|
||||||
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY);
|
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY);
|
||||||
double dayValue = dayConverter.convert(nextValue.getValue().doubleValue());
|
double dayValue = dayConverter.convert(nextValue.getValue().doubleValue());
|
||||||
DurationDt newValue = new DurationDt();
|
DurationDt newValue = new DurationDt();
|
||||||
newValue.setSystem(BaseFhirDao.UCUM_NS);
|
newValue.setSystem(BaseHapiFhirDao.UCUM_NS);
|
||||||
newValue.setCode(NonSI.DAY.toString());
|
newValue.setCode(NonSI.DAY.toString());
|
||||||
newValue.setValue(dayValue);
|
newValue.setValue(dayValue);
|
||||||
nextValue = newValue;
|
nextValue = newValue;
|
||||||
|
@ -390,7 +390,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
|
||||||
searchTerm = searchTerm.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH);
|
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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
|
||||||
if (value.length() > ResourceIndexedSearchParamString.MAX_LENGTH) {
|
if (value.length() > ResourceIndexedSearchParamString.MAX_LENGTH) {
|
||||||
value = value.substring(0, 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);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class BaseFhirDaoTest extends BaseJpaTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslateMatchUrl() {
|
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());
|
assertEquals("2011-01-01T11:12:21.0000Z", match.getLastUpdated().getLowerBound().getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1157,7 +1157,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest {
|
||||||
|
|
||||||
ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog");
|
ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog");
|
||||||
ourPatientDao.removeTag(id1, TagTypeEnum.SECURITY_LABEL, "seclabel:sys:1", "seclabel:code:1");
|
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();
|
meta = ourPatientDao.metaGetOperation();
|
||||||
published = meta.getTag();
|
published = meta.getTag();
|
||||||
|
@ -1481,12 +1481,12 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest {
|
||||||
public void testSearchNumberParam() {
|
public void testSearchNumberParam() {
|
||||||
Encounter e1 = new Encounter();
|
Encounter e1 = new Encounter();
|
||||||
e1.addIdentifier().setSystem("foo").setValue("testSearchNumberParam01");
|
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();
|
IIdType id1 = ourEncounterDao.create(e1).getId();
|
||||||
|
|
||||||
Encounter e2 = new Encounter();
|
Encounter e2 = new Encounter();
|
||||||
e2.addIdentifier().setSystem("foo").setValue("testSearchNumberParam02");
|
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();
|
IIdType id2 = ourEncounterDao.create(e2).getId();
|
||||||
{
|
{
|
||||||
IBundleProvider found = ourEncounterDao.search(Encounter.SP_LENGTH, new NumberParam(">2"));
|
IBundleProvider found = ourEncounterDao.search(Encounter.SP_LENGTH, new NumberParam(">2"));
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaTest {
|
||||||
|
|
||||||
ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog");
|
ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog");
|
||||||
ourPatientDao.removeTag(id1, TagTypeEnum.SECURITY_LABEL, "seclabel:sys:1", "seclabel:code:1");
|
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();
|
meta = ourSystemDao.metaGetOperation();
|
||||||
published = meta.getTag();
|
published = meta.getTag();
|
||||||
|
|
|
@ -26,6 +26,9 @@ public interface IIdType {
|
||||||
|
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this ID represents a local reference (i.e. a reference beginning with the character '#')
|
||||||
|
*/
|
||||||
boolean isLocal();
|
boolean isLocal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,8 +49,14 @@ public interface IIdType {
|
||||||
|
|
||||||
String getBaseUrl();
|
String getBaseUrl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of this ID without the base URL or the version
|
||||||
|
*/
|
||||||
IIdType toUnqualifiedVersionless();
|
IIdType toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of this ID without the version
|
||||||
|
*/
|
||||||
IIdType toVersionless();
|
IIdType toVersionless();
|
||||||
|
|
||||||
IIdType setValue(String theString);
|
IIdType setValue(String theString);
|
||||||
|
|
Loading…
Reference in New Issue