License update
This commit is contained in:
parent
faf7c410e1
commit
46ec5799ae
|
@ -107,22 +107,21 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceTable entity;
|
ResourceTable entity;
|
||||||
if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.CREATE) {
|
if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.POST) {
|
||||||
entity = null;
|
entity = null;
|
||||||
} else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.UPDATE || 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(BaseFhirSystemDao.class, "transactionOperationFailedNoId", nextResouceOperationIn.name()));
|
||||||
}
|
}
|
||||||
entity = tryToLoadEntity(nextId);
|
entity = tryToLoadEntity(nextId);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.UPDATE) {
|
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(BaseFhirSystemDao.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);
|
||||||
ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(nextResource, BundleEntryTransactionMethodEnum.NOOP);
|
|
||||||
persistedResources.add(null);
|
persistedResources.add(null);
|
||||||
retVal.add(nextResource);
|
retVal.add(nextResource);
|
||||||
continue;
|
continue;
|
||||||
|
@ -133,8 +132,6 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", nextResouceOperationIn.name(), matchUrl, candidateMatches.size()));
|
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", nextResouceOperationIn.name(), matchUrl, candidateMatches.size()));
|
||||||
}
|
}
|
||||||
} else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.NOOP) {
|
|
||||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "incomingNoopInTransaction"));
|
|
||||||
} else if (nextId.isEmpty()) {
|
} else if (nextId.isEmpty()) {
|
||||||
entity = null;
|
entity = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -143,11 +140,11 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
|
|
||||||
BundleEntryTransactionMethodEnum nextResouceOperationOut;
|
BundleEntryTransactionMethodEnum nextResouceOperationOut;
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
nextResouceOperationOut = BundleEntryTransactionMethodEnum.CREATE;
|
nextResouceOperationOut = BundleEntryTransactionMethodEnum.POST;
|
||||||
entity = toEntity(nextResource);
|
entity = toEntity(nextResource);
|
||||||
if (nextId.isEmpty() == false && nextId.getIdPart().startsWith("cid:")) {
|
if (nextId.isEmpty() == false && nextId.getIdPart().startsWith("cid:")) {
|
||||||
ourLog.debug("Resource in transaction has ID[{}], will replace with server assigned ID", nextId.getIdPart());
|
ourLog.debug("Resource in transaction has ID[{}], will replace with server assigned ID", nextId.getIdPart());
|
||||||
} else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.CREATE) {
|
} else if (nextResouceOperationIn == BundleEntryTransactionMethodEnum.POST) {
|
||||||
if (nextId.isEmpty() == false) {
|
if (nextId.isEmpty() == false) {
|
||||||
ourLog.debug("Resource in transaction has ID[{}] but is marked for CREATE, will ignore ID", nextId.getIdPart());
|
ourLog.debug("Resource in transaction has ID[{}] but is marked for CREATE, will ignore ID", nextId.getIdPart());
|
||||||
}
|
}
|
||||||
|
@ -156,13 +153,12 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
ourLog.debug("Resource with match URL [{}] already exists, will be NOOP", matchUrl);
|
ourLog.debug("Resource with match URL [{}] already exists, will be NOOP", matchUrl);
|
||||||
BaseHasResource existingEntity = loadFirstEntityFromCandidateMatches(candidateMatches);
|
BaseHasResource existingEntity = loadFirstEntityFromCandidateMatches(candidateMatches);
|
||||||
IResource existing = (IResource) toResource(existingEntity);
|
IResource existing = (IResource) toResource(existingEntity);
|
||||||
ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(existing, BundleEntryTransactionMethodEnum.NOOP);
|
|
||||||
persistedResources.add(null);
|
persistedResources.add(null);
|
||||||
retVal.add(existing);
|
retVal.add(existing);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (candidateMatches.size() > 1) {
|
if (candidateMatches.size() > 1) {
|
||||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", BundleEntryTransactionMethodEnum.CREATE.name(), matchUrl, candidateMatches.size()));
|
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirSystemDao.class, "transactionOperationWithMultipleMatchFailure", BundleEntryTransactionMethodEnum.POST.name(), matchUrl, candidateMatches.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,7 +173,7 @@ public class FhirSystemDaoDstu1 extends BaseFhirSystemDao<List<IResource>> {
|
||||||
} else {
|
} else {
|
||||||
nextResouceOperationOut = nextResouceOperationIn;
|
nextResouceOperationOut = nextResouceOperationIn;
|
||||||
if (nextResouceOperationOut == null) {
|
if (nextResouceOperationOut == null) {
|
||||||
nextResouceOperationOut = BundleEntryTransactionMethodEnum.UPDATE;
|
nextResouceOperationOut = BundleEntryTransactionMethodEnum.PUT;
|
||||||
}
|
}
|
||||||
updates++;
|
updates++;
|
||||||
ourLog.info("Resource Type[{}] with ID[{}] exists, updating it", resourceName, nextId);
|
ourLog.info("Resource Type[{}] with ID[{}] exists, updating it", resourceName, nextId);
|
||||||
|
|
Loading…
Reference in New Issue