Deprecate redundant IVersionSpecificBundleProvider method
This commit is contained in:
parent
1b2892f475
commit
c8ce07c40e
|
@ -25,7 +25,8 @@ public class IncludesExamples {
|
|||
FhirContext ctx = FhirContext.forDstu2();
|
||||
|
||||
Dstu2BundleFactory bf = new Dstu2BundleFactory(ctx);
|
||||
bf.initializeBundleFromResourceList(null, resources, "http://example.com/base", "http://example.com/base/Patient", 1, BundleTypeEnum.SEARCHSET);
|
||||
bf.addRootPropertiesToBundle(null, null, null, null, null, resources.size(), BundleTypeEnum.SEARCHSET, null);
|
||||
bf.addResourcesToBundle(new ArrayList<>(resources), BundleTypeEnum.SEARCHSET, null, null, null);
|
||||
IBaseResource b = bf.getResourceBundle();
|
||||
|
||||
// Encode the bundle
|
||||
|
|
|
@ -19,14 +19,17 @@ package ca.uhn.fhir.rest.api;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.api.BundleInclusionRule;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This interface should be considered experimental and will likely change in future releases of HAPI. Use with caution!
|
||||
|
@ -39,7 +42,15 @@ public interface IVersionSpecificBundleFactory {
|
|||
|
||||
IBaseResource getResourceBundle();
|
||||
|
||||
void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResult, String theServerBase, String theCompleteUrl, int theTotalResults, BundleTypeEnum theBundleType);
|
||||
/**
|
||||
* @deprecated This was deprecated in HAPI FHIR 4.1.0 as it provides duplicate functionality to the {@link #addRootPropertiesToBundle(String, String, String, String, String, Integer, BundleTypeEnum, IPrimitiveType)}
|
||||
* and {@link #addResourcesToBundle(List, BundleTypeEnum, String, BundleInclusionRule, Set)} methods
|
||||
*/
|
||||
@Deprecated
|
||||
default void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResult, String theServerBase, String theCompleteUrl, int theTotalResults, BundleTypeEnum theBundleType) {
|
||||
addRootPropertiesToBundle(null, null, null, null, null, theResult.size(), theBundleType, null);
|
||||
addResourcesToBundle(new ArrayList<>(theResult), theBundleType, null, null, null);
|
||||
}
|
||||
|
||||
void initializeWithBundleResource(IBaseResource theResource);
|
||||
|
||||
|
|
|
@ -715,7 +715,8 @@ public class ExampleDataUploader extends BaseCommand {
|
|||
ourLog.info("About to upload {} examples in a transaction, {} remaining", subResourceList.size(), resources.size());
|
||||
|
||||
IVersionSpecificBundleFactory bundleFactory = ctx.newBundleFactory();
|
||||
bundleFactory.initializeBundleFromResourceList(null, subResourceList, null, null, 0, BundleTypeEnum.TRANSACTION);
|
||||
bundleFactory.addRootPropertiesToBundle(null, null, null, null, null, subResourceList.size(), BundleTypeEnum.TRANSACTION, null);
|
||||
bundleFactory.addResourcesToBundle(new ArrayList<>(subResourceList), BundleTypeEnum.TRANSACTION, null, null, null);
|
||||
IBaseResource subBundle = bundleFactory.getResourceBundle();
|
||||
|
||||
String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(subBundle);
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -52,7 +53,7 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
|
|||
private boolean myOmitResourceId = false;
|
||||
private Map<String, List<String>> myParams;
|
||||
private final IBaseResource myResource;
|
||||
private final List<? extends IBaseResource> myResources;
|
||||
private final List<IBaseResource> myResources;
|
||||
private final String myUrlPath;
|
||||
private IIdType myForceResourceId;
|
||||
|
||||
|
@ -70,7 +71,7 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
|
|||
super(theContext);
|
||||
myResource = null;
|
||||
myUrlPath = null;
|
||||
myResources = theResources;
|
||||
myResources = new ArrayList<>(theResources);
|
||||
myContents = null;
|
||||
myBundleType = theBundleType;
|
||||
}
|
||||
|
@ -172,11 +173,8 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
|
|||
parser.setOmitResourceId(myOmitResourceId);
|
||||
if (myResources != null) {
|
||||
IVersionSpecificBundleFactory bundleFactory = getContext().newBundleFactory();
|
||||
bundleFactory.initializeBundleFromResourceList("", myResources, "", "", myResources.size(), myBundleType);
|
||||
IBaseResource bundle = bundleFactory.getResourceBundle();
|
||||
if (bundle != null) {
|
||||
return parser.encodeResourceToString(bundle);
|
||||
}
|
||||
bundleFactory.addRootPropertiesToBundle(null, null, null, null, null, myResources.size(), myBundleType, null);
|
||||
bundleFactory.addResourcesToBundle(myResources, myBundleType, null, null, null);
|
||||
IBaseResource bundleRes = bundleFactory.getResourceBundle();
|
||||
return parser.encodeResourceToString(bundleRes);
|
||||
} else if (myContents != null) {
|
||||
|
|
|
@ -44,7 +44,8 @@ public class IncludesExamples {
|
|||
FhirContext ctx = FhirContext.forDstu2();
|
||||
|
||||
R4BundleFactory bf = new R4BundleFactory(ctx);
|
||||
bf.initializeBundleFromResourceList(null, resources, "http://example.com/base", "http://example.com/base/Patient", 1, BundleTypeEnum.SEARCHSET);
|
||||
bf.addRootPropertiesToBundle(null, null, null, null, null, resources.size(), BundleTypeEnum.SEARCHSET, null);
|
||||
bf.addResourcesToBundle(new ArrayList<>(resources), BundleTypeEnum.SEARCHSET, null, null, null);
|
||||
IBaseResource b = bf.getResourceBundle();
|
||||
|
||||
// Encode the bundle
|
||||
|
|
|
@ -19,13 +19,6 @@ package org.hl7.fhir.dstu2016may.hapi.rest.server;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.dstu2016may.model.*;
|
||||
import org.hl7.fhir.dstu2016may.model.Bundle.*;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.api.BundleInclusionRule;
|
||||
|
@ -35,6 +28,18 @@ import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory;
|
||||
import ca.uhn.fhir.util.ResourceReferenceInfo;
|
||||
import org.hl7.fhir.dstu2016may.model.Bundle;
|
||||
import org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent;
|
||||
import org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode;
|
||||
import org.hl7.fhir.dstu2016may.model.DomainResource;
|
||||
import org.hl7.fhir.dstu2016may.model.IdType;
|
||||
import org.hl7.fhir.dstu2016may.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
public class Dstu2_1BundleFactory implements IVersionSpecificBundleFactory {
|
||||
|
||||
|
@ -282,44 +287,6 @@ public class Dstu2_1BundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
|
||||
BundleTypeEnum theBundleType) {
|
||||
ensureBundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
myBundle.getMeta().setLastUpdated(new Date());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
Resource next = (Resource) nextBaseRes;
|
||||
BundleEntryComponent nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource(next);
|
||||
if (next.getIdElement().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
|
||||
if (next.getIdElement().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getId());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
myBundle = (Bundle) theBundle;
|
||||
|
|
|
@ -275,44 +275,6 @@ public class Dstu2BundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
|
||||
BundleTypeEnum theBundleType) {
|
||||
ensureBundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
ResourceMetadataKeyEnum.PUBLISHED.put(myBundle, InstantDt.withCurrentTime());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
IResource next = (IResource) nextBaseRes;
|
||||
Entry nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource(next);
|
||||
if (next.getId().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerbEnum.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerbEnum.PUT);
|
||||
if (next.getId().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getId());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdDt(theServerBase, resourceType, next.getId().getIdPart(), next.getId().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
myBundle = (Bundle) theBundle;
|
||||
|
|
|
@ -32,7 +32,6 @@ import ca.uhn.fhir.util.ResourceReferenceInfo;
|
|||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.SearchEntryMode;
|
||||
import org.hl7.fhir.dstu3.model.DomainResource;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
|
@ -314,44 +313,6 @@ public class Dstu3BundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
|
||||
BundleTypeEnum theBundleType) {
|
||||
myBundle = new Bundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
myBundle.getMeta().setLastUpdated(new Date());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
Resource next = (Resource) nextBaseRes;
|
||||
BundleEntryComponent nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource(next);
|
||||
if (next.getIdElement().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
|
||||
if (next.getIdElement().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getId());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
myBundle = (Bundle) theBundle;
|
||||
|
|
|
@ -30,7 +30,6 @@ import ca.uhn.fhir.util.ResourceReferenceInfo;
|
|||
import org.hl7.fhir.dstu2.model.Bundle;
|
||||
import org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu2.model.Bundle.BundleLinkComponent;
|
||||
import org.hl7.fhir.dstu2.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.dstu2.model.Bundle.SearchEntryMode;
|
||||
import org.hl7.fhir.dstu2.model.IdType;
|
||||
import org.hl7.fhir.dstu2.model.InstantType;
|
||||
|
@ -276,45 +275,6 @@ public class Dstu2Hl7OrgBundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources,
|
||||
String theServerBase, String theCompleteUrl, int theTotalResults, BundleTypeEnum theBundleType) {
|
||||
ensureBundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
myBundle.getMeta().setLastUpdatedElement(InstantType.withCurrentTime());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
IBaseResource next = (IBaseResource) nextBaseRes;
|
||||
BundleEntryComponent nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource((Resource) next);
|
||||
if (next.getIdElement().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
|
||||
if (next.getIdElement().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getIdElement().getValue());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(),
|
||||
next.getIdElement().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
myBundle = (Bundle) theBundle;
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.hl7.fhir.instance.model.api.*;
|
|||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleLinkComponent;
|
||||
import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.r4.model.Bundle.SearchEntryMode;
|
||||
import org.hl7.fhir.r4.model.DomainResource;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
|
@ -316,44 +315,6 @@ public class R4BundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
|
||||
BundleTypeEnum theBundleType) {
|
||||
myBundle = new Bundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
myBundle.getMeta().setLastUpdated(new Date());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
Resource next = (Resource) nextBaseRes;
|
||||
BundleEntryComponent nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource(next);
|
||||
if (next.getIdElement().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
|
||||
if (next.getIdElement().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getId());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
myBundle = (Bundle) theBundle;
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.hl7.fhir.instance.model.api.*;
|
|||
import org.hl7.fhir.r5.model.Bundle;
|
||||
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.r5.model.Bundle.BundleLinkComponent;
|
||||
import org.hl7.fhir.r5.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.r5.model.Bundle.SearchEntryMode;
|
||||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.IdType;
|
||||
|
@ -316,43 +315,6 @@ public class R5BundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
|
||||
BundleTypeEnum theBundleType) {
|
||||
myBundle = new Bundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
myBundle.getMeta().setLastUpdated(new Date());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
Resource next = (Resource) nextBaseRes;
|
||||
BundleEntryComponent nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource(next);
|
||||
if (next.getIdElement().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
|
||||
if (next.getIdElement().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getId());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
|
|
|
@ -19,27 +19,32 @@ package ca.uhn.fhir.rest.server.provider.dstu2;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.api.BundleInclusionRule;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.SearchEntryModeEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.valueset.*;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory;
|
||||
import ca.uhn.fhir.util.ResourceReferenceInfo;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
public class Dstu2BundleFactory implements IVersionSpecificBundleFactory {
|
||||
private Bundle myBundle;
|
||||
|
@ -282,44 +287,6 @@ public class Dstu2BundleFactory implements IVersionSpecificBundleFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
|
||||
BundleTypeEnum theBundleType) {
|
||||
myBundle = new Bundle();
|
||||
|
||||
myBundle.setId(UUID.randomUUID().toString());
|
||||
|
||||
ResourceMetadataKeyEnum.PUBLISHED.put(myBundle, InstantDt.withCurrentTime());
|
||||
|
||||
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
|
||||
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
|
||||
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
|
||||
|
||||
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
|
||||
for (IBaseResource nextBaseRes : theResources) {
|
||||
IResource next = (IResource) nextBaseRes;
|
||||
Entry nextEntry = myBundle.addEntry();
|
||||
|
||||
nextEntry.setResource(next);
|
||||
if (next.getId().isEmpty()) {
|
||||
nextEntry.getRequest().setMethod(HTTPVerbEnum.POST);
|
||||
} else {
|
||||
nextEntry.getRequest().setMethod(HTTPVerbEnum.PUT);
|
||||
if (next.getId().isAbsolute()) {
|
||||
nextEntry.getRequest().setUrl(next.getId());
|
||||
} else {
|
||||
String resourceType = myContext.getResourceDefinition(next).getName();
|
||||
nextEntry.getRequest().setUrl(new IdDt(theServerBase, resourceType, next.getId().getIdPart(), next.getId().getVersionIdPart()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addResourcesForSearch(theResources);
|
||||
}
|
||||
|
||||
myBundle.getTotalElement().setValue(theTotalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeWithBundleResource(IBaseResource theBundle) {
|
||||
myBundle = (Bundle) theBundle;
|
||||
|
|
|
@ -39,6 +39,16 @@
|
|||
Support for the FHIR Bulk Data Export specification has been added to the JPA server. See the
|
||||
<a href="http://hl7.org/fhir/uv/bulkdata/">specification</a> for information on how this works. Note that
|
||||
only system level export is currently supported but others will follow.
|
||||
]]>
|
||||
</action>
|
||||
<action type="add">
|
||||
<![CDATA[
|
||||
<b>New Feature</b>:
|
||||
Support for ElasticSearch has been added to the JPA server directly (i.e. without needing a separate
|
||||
module) and a new class called "ElasticsearchHibernatePropertiesBuilder" has been added to facilitate
|
||||
the creation of relevant properties. Instructions have been added to the hapi-fhir-jpaserver-starter
|
||||
project to get started with Elasticsearch. It is likely we will switch our default recommendation
|
||||
to Elastic in the future.
|
||||
]]>
|
||||
</action>
|
||||
<action type="add" issue="1489">
|
||||
|
@ -253,10 +263,14 @@
|
|||
The JPA server failed to find codes defined in not-present codesystems in some cases, and reported
|
||||
that the CodeSystem did not exist. This has been corrected.
|
||||
</action>
|
||||
<action type="add">
|
||||
Support for ElasticSearch has been added to the JPA server directly (i.e. without needing a separate
|
||||
module) and a new class called "ElasticsearchHibernatePropertiesBuilder" has been added to facilitate
|
||||
the creation of relevant properties.
|
||||
<action type="remove">
|
||||
The method
|
||||
<![CDATA[
|
||||
<code>IVersionSpecificBundleFactory#initializeBundleFromResourceList</code>
|
||||
]]>
|
||||
has been deprecated, as it provided duplicate functionality to other methods and had an
|
||||
outdated argument list based on the Bundle needs in DSTU1. We are not aware of any
|
||||
public use of this API, please let us know if this deprecation causes any issues.
|
||||
</action>
|
||||
</release>
|
||||
<release version="4.0.3" date="2019-09-03" description="Igloo (Point Release)">
|
||||
|
|
Loading…
Reference in New Issue