From 10f62090767c78df24c82824c19adad3b5835784 Mon Sep 17 00:00:00 2001 From: reagan-meant Date: Tue, 29 Oct 2019 05:46:28 +0300 Subject: [PATCH] META-224:Exporting metadata packages on-the-fly should not require you to specify ids/uuids of existing items --- .../web/controller/PublishController.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/PublishController.java b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/PublishController.java index bd759e8..1c9b8e9 100644 --- a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/PublishController.java +++ b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/PublishController.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.Date; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -226,7 +227,18 @@ public void getNewPackage(@RequestParam(required = false) } } } - } + if(uuids==null && ids==null && modifiedSince!=null) { + List items=Handler.getItems(type, true, null, null, null); + if (items != null) { + for(Object item: items ) { + if (modifiedSince == null + || OpenmrsUtil.compareWithNullAsEarliest(Handler.getDateChanged(item), + modifiedSince) > 0) { + exporter.addItem(item); + } + } + } + } exporter.getPackage().setName("Package"); exporter.getPackage().setDescription( "Contains " + exporter.getPackage().getItems().size() + " items of type " + type.getSimpleName()); @@ -237,7 +249,8 @@ public void getNewPackage(@RequestParam(required = false) response.setHeader("Content-Disposition", "attachment; filename=\"metadata.zip\""); MetadataZipper zipper = new MetadataZipper(); zipper.zipPackage(response.getOutputStream(), exporter.getExportedPackage().getSerializedPackage()); - } + } + } finally { Context.removeProxyPrivilege(MetadataSharingConsts.MODULE_PRIVILEGE); Context.removeProxyPrivilege(privilegeCompatibility.GET_CONCEPTS());