@SuppressWarnings("unchecked") private <R extends IBaseResource> R populateResourceMetadataHapi(Class<R> theResourceType, IBaseResourceEntity theEntity, Collection<? extends BaseTag> theTagList, boolean theForHistoryOperation, IResource res, Long theVersion) { R retVal = (R) res; if (theEntity.getDeleted() != null) { res = (IResource) myContext.getResourceDefinition(theResourceType).newInstance(); retVal = (R) res; ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted())); if (theForHistoryOperation) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.DELETE); Date published = theEntity.getPublished().getValue(); Date updated = theEntity.getUpdated().getValue(); if (published.equals(updated)) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.POST); res.setId(theEntity.getIdDt().withVersion(theVersion.toString())); ResourceMetadataKeyEnum.VERSION.put(res, Long.toString(theEntity.getVersion())); ResourceMetadataKeyEnum.PUBLISHED.put(res, theEntity.getPublished()); ResourceMetadataKeyEnum.UPDATED.put(res, theEntity.getUpdated()); IDao.RESOURCE_PID.put(res, theEntity.getId()); if (theEntity.isHasTags()) { TagList tagList = new TagList(); List<IBaseCoding> securityLabels = new ArrayList<>();
} else if (theEntity instanceof ResourceTable) { ResourceTable resource = (ResourceTable) theEntity; version = theEntity.getVersion(); ResourceHistoryTable history = myResourceHistoryTableDao.findForIdAndVersion(theEntity.getId(), version); while (history == null) { if (version > 1L) { version--; history = myResourceHistoryTableDao.findForIdAndVersion(theEntity.getId(), version); } else { return null; IParser parser = resourceEncoding.newParser(getContext(theEntity.getFhirVersion())); parser.setParserErrorHandler(new LenientErrorHandler(false).setErrorOnInvalidValue(false)); b.append(resourceType); b.append("/"); b.append(theEntity.getIdDt().getIdPart()); b.append(" (pid "); b.append(theEntity.getId()); b.append(", version "); b.append(theEntity.getFhirVersion().name()); b.append("): "); b.append(e.getMessage()); retVal = (R) myContext.getResourceDefinition(theEntity.getResourceType()).newInstance();
@SuppressWarnings("unchecked") private <R extends IBaseResource> R populateResourceMetadataRi(Class<R> theResourceType, IBaseResourceEntity theEntity, Collection<? extends BaseTag> theTagList, boolean theForHistoryOperation, IAnyResource res, Long theVersion) { R retVal = (R) res; if (theEntity.getDeleted() != null) { res = (IAnyResource) myContext.getResourceDefinition(theResourceType).newInstance(); retVal = (R) res; ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted())); if (theForHistoryOperation) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.DELETE.toCode()); Date published = theEntity.getPublished().getValue(); Date updated = theEntity.getUpdated().getValue(); if (published.equals(updated)) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.POST.toCode()); res.setId(res.getIdElement().withVersion(theVersion.toString())); res.getMeta().setLastUpdated(theEntity.getUpdatedDate()); IDao.RESOURCE_PID.put(res, theEntity.getId()); if (theEntity.isHasTags()) { for (BaseTag next : tags) { switch (next.getTag().getTagType()) {
protected void updateResourceMetadata(IBaseResourceEntity theEntity, IBaseResource theResource) { IIdType id = theEntity.getIdDt(); if (getContext().getVersion().getVersion().isRi()) { id = getContext().getVersion().newIdType().setValue(id.getValue()); } if (id.hasResourceType() == false) { id = id.withResourceType(theEntity.getResourceType()); } theResource.setId(id); if (theResource instanceof IResource) { ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, id.getVersionIdPart()); ResourceMetadataKeyEnum.UPDATED.put((IResource) theResource, theEntity.getUpdated()); } else { IBaseMetaType meta = theResource.getMeta(); meta.setVersionId(id.getVersionIdPart()); meta.setLastUpdated(theEntity.getUpdatedDate()); } }
protected void updateResourceMetadata(IBaseResourceEntity theEntity, IBaseResource theResource) { IIdType id = theEntity.getIdDt(); if (getContext().getVersion().getVersion().isRi()) { id = getContext().getVersion().newIdType().setValue(id.getValue()); } if (id.hasResourceType() == false) { id = id.withResourceType(theEntity.getResourceType()); } theResource.setId(id); if (theResource instanceof IResource) { ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, id.getVersionIdPart()); ResourceMetadataKeyEnum.UPDATED.put((IResource) theResource, theEntity.getUpdated()); } else { IBaseMetaType meta = theResource.getMeta(); meta.setVersionId(id.getVersionIdPart()); meta.setLastUpdated(theEntity.getUpdatedDate()); } }
@SuppressWarnings("unchecked") private <R extends IBaseResource> R populateResourceMetadataHapi(Class<R> theResourceType, IBaseResourceEntity theEntity, Collection<? extends BaseTag> theTagList, boolean theForHistoryOperation, IResource res, Long theVersion) { R retVal = (R) res; if (theEntity.getDeleted() != null) { res = (IResource) myContext.getResourceDefinition(theResourceType).newInstance(); retVal = (R) res; ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted())); if (theForHistoryOperation) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.DELETE); Date published = theEntity.getPublished().getValue(); Date updated = theEntity.getUpdated().getValue(); if (published.equals(updated)) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.POST); res.setId(theEntity.getIdDt().withVersion(theVersion.toString())); ResourceMetadataKeyEnum.VERSION.put(res, Long.toString(theEntity.getVersion())); ResourceMetadataKeyEnum.PUBLISHED.put(res, theEntity.getPublished()); ResourceMetadataKeyEnum.UPDATED.put(res, theEntity.getUpdated()); IDao.RESOURCE_PID.put(res, theEntity.getId()); if (theEntity.isHasTags()) { TagList tagList = new TagList(); List<IBaseCoding> securityLabels = new ArrayList<>();
@SuppressWarnings("unchecked") private <R extends IBaseResource> R populateResourceMetadataRi(Class<R> theResourceType, IBaseResourceEntity theEntity, Collection<? extends BaseTag> theTagList, boolean theForHistoryOperation, IAnyResource res, Long theVersion) { R retVal = (R) res; if (theEntity.getDeleted() != null) { res = (IAnyResource) myContext.getResourceDefinition(theResourceType).newInstance(); retVal = (R) res; ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted())); if (theForHistoryOperation) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.DELETE.toCode()); Date published = theEntity.getPublished().getValue(); Date updated = theEntity.getUpdated().getValue(); if (published.equals(updated)) { ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.POST.toCode()); res.setId(res.getIdElement().withVersion(theVersion.toString())); res.getMeta().setLastUpdated(theEntity.getUpdatedDate()); IDao.RESOURCE_PID.put(res, theEntity.getId()); if (theEntity.isHasTags()) { for (BaseTag next : tags) { switch (next.getTag().getTagType()) {
} else if (theEntity instanceof ResourceTable) { ResourceTable resource = (ResourceTable) theEntity; version = theEntity.getVersion(); ResourceHistoryTable history = myResourceHistoryTableDao.findForIdAndVersion(theEntity.getId(), version); while (history == null) { if (version > 1L) { version--; history = myResourceHistoryTableDao.findForIdAndVersion(theEntity.getId(), version); } else { return null; IParser parser = resourceEncoding.newParser(getContext(theEntity.getFhirVersion())); parser.setParserErrorHandler(new LenientErrorHandler(false).setErrorOnInvalidValue(false)); b.append(resourceType); b.append("/"); b.append(theEntity.getIdDt().getIdPart()); b.append(" (pid "); b.append(theEntity.getId()); b.append(", version "); b.append(theEntity.getFhirVersion().name()); b.append("): "); b.append(e.getMessage()); retVal = (R) myContext.getResourceDefinition(theEntity.getResourceType()).newInstance();