Skip to content

Commit

Permalink
META-224:Exporting metadata packages on-the-fly should not require yo…
Browse files Browse the repository at this point in the history
…u to specify ids/uuids of existing items
  • Loading branch information
reagan-meant committed Oct 29, 2019
1 parent d80d76e commit 10f6209
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -226,7 +227,18 @@ public void getNewPackage(@RequestParam(required = false)
}
}
}
}
if(uuids==null && ids==null && modifiedSince!=null) {
List<Object> 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());
Expand All @@ -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());
Expand Down

0 comments on commit 10f6209

Please sign in to comment.