Fixed this bug: the security labels wouldn't be encoded if versionId or lastUpdated weren't present.

This commit is contained in:
mochaholic 2015-02-23 21:10:38 -07:00
parent f7a8c8d5f5
commit 8a2f9ff983
2 changed files with 13 additions and 8 deletions

View File

@ -670,14 +670,15 @@ public class JsonParser extends BaseParser implements IParser {
if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1) && theResource instanceof IResource) {
IResource resource = (IResource) theResource;
if (!ElementUtil.isEmpty(resource.getId().getVersionIdPart(), ResourceMetadataKeyEnum.UPDATED.get(resource))) {
//Object securityLabelRawObj =
List<BaseCodingDt> securityLabels = (List<BaseCodingDt>) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.SECURITY_LABELS);
if (!ElementUtil.isEmpty(resource.getId().getVersionIdPart(), ResourceMetadataKeyEnum.UPDATED.get(resource))
|| (securityLabels != null && !securityLabels.isEmpty())) {
theEventWriter.writeStartObject("meta");
writeOptionalTagWithTextNode(theEventWriter, "versionId", resource.getId().getVersionIdPart());
writeOptionalTagWithTextNode(theEventWriter, "lastUpdated", ResourceMetadataKeyEnum.UPDATED.get(resource));
Object securityLabelRawObj = resource.getResourceMetadata().get(ResourceMetadataKeyEnum.SECURITY_LABELS);
if (securityLabelRawObj != null) {
List<BaseCodingDt> securityLabels = (List<BaseCodingDt>) securityLabelRawObj;
if (securityLabels != null) {
if (!securityLabels.isEmpty()) {
theEventWriter.writeStartArray("security");

View File

@ -747,8 +747,12 @@ public class XmlParser extends BaseParser implements IParser {
InstantDt updated = (InstantDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
//Object securityLabelRawObj = resource.getResourceMetadata().get(ResourceMetadataKeyEnum.SECURITY_LABELS);
List<BaseCodingDt> securityLabels = (List<BaseCodingDt>) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.SECURITY_LABELS);
IdDt resourceId = resource.getId();
if (resourceId != null && isNotBlank(resourceId.getVersionIdPart()) || (updated != null && !updated.isEmpty())) {
if (resourceId != null && isNotBlank(resourceId.getVersionIdPart())
|| (updated != null && !updated.isEmpty())
|| (securityLabels != null && !securityLabels.isEmpty())) {
theEventWriter.writeStartElement("meta");
String versionIdPart = resourceId.getVersionIdPart();
if (isBlank(versionIdPart)) {
@ -758,9 +762,9 @@ public class XmlParser extends BaseParser implements IParser {
if (updated != null) {
writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
}
Object securityLabelRawObj = resource.getResourceMetadata().get(ResourceMetadataKeyEnum.SECURITY_LABELS);
if (securityLabelRawObj != null) {
List<BaseCodingDt> securityLabels = (List<BaseCodingDt>) securityLabelRawObj;
if (securityLabels != null) {
if (!securityLabels.isEmpty()) {
for (BaseCodingDt securityLabel : securityLabels) {