Optimize hierarchy export, support hierarchy as json

This commit is contained in:
Terry Brady
2016-01-14 14:20:14 -08:00
parent d76f5696de
commit 7f3d38836a
2 changed files with 13 additions and 26 deletions

View File

@@ -62,7 +62,7 @@ public class HierarchyResource extends Resource {
* UNATHORIZED status codes, too. * UNATHORIZED status codes, too.
*/ */
@GET @GET
@Produces({MediaType.APPLICATION_XML}) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public HierarchySite getHierarchy( public HierarchySite getHierarchy(
@QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor,
@Context HttpHeaders headers, @Context HttpServletRequest request) throws UnsupportedEncodingException, WebApplicationException { @Context HttpHeaders headers, @Context HttpServletRequest request) throws UnsupportedEncodingException, WebApplicationException {

View File

@@ -492,29 +492,16 @@ var CommunitySelector = function(report, parent, paramCollSel) {
report.myHtmlUtil.addOpt(collSel, "Whole Repository", ""); report.myHtmlUtil.addOpt(collSel, "Whole Repository", "");
$.ajax({ $.ajax({
url: "/rest/communities", url: "/rest/hierarchy",
data: {
limit : report.COLL_LIMIT,
expand : "subCommunities,collections"
},
dataType: "json", dataType: "json",
headers: report.myAuth.getHeaders(), headers: report.myAuth.getHeaders(),
success: function(data){ success: function(data){
var collSel = $("#collSel"); var collSel = $("#collSel");
var COMMS = {}; if (data.community != null) {
var TOPCOMMS = {}; $.each(data.community, function(index, comm){
$.each(data, function(index, comm){ self.addCommLabel(collSel, comm, 0, paramCollSel);
COMMS["comm"+report.getId(comm)] = comm; });
TOPCOMMS["comm"+report.getId(comm)] = comm; }
});
$.each(data, function(index, comm){
$.each(comm.subcommunities, function(index, scomm){
delete TOPCOMMS["comm"+report.getId(scomm)];
});
});
for(var commindex in TOPCOMMS) {
self.addCommLabel(collSel, COMMS, COMMS[commindex], 0, paramCollSel);
};
}, },
error: function(xhr, status, errorThrown) { error: function(xhr, status, errorThrown) {
alert("Error in /rest/communities "+ status+ " " + errorThrown); alert("Error in /rest/communities "+ status+ " " + errorThrown);
@@ -523,14 +510,14 @@ var CommunitySelector = function(report, parent, paramCollSel) {
} }
}); });
this.addCommLabel = function(collSel, COMMS, comm, indent, paramCollSel) { this.addCommLabel = function(collSel, comm, indent, paramCollSel) {
var prefix = ""; var prefix = "";
for(var i=0; i<indent; i++) { for(var i=0; i<indent; i++) {
prefix += "--"; prefix += "--";
} }
report.myHtmlUtil.addDisabledOpt(collSel, prefix + comm.name, "comm" + report.getId(comm)); report.myHtmlUtil.addDisabledOpt(collSel, prefix + comm.name, "comm" + report.getId(comm));
if (comm.collections != null) { if (comm.collection != null) {
$.each(comm.collections, function(index, coll) { $.each(comm.collection, function(index, coll) {
var opt = report.myHtmlUtil.addOpt(collSel, prefix + "--" + coll.name, report.getId(coll)); var opt = report.myHtmlUtil.addOpt(collSel, prefix + "--" + coll.name, report.getId(coll));
$.each(paramCollSel, function(index, collid){ $.each(paramCollSel, function(index, collid){
if (collid == report.getId(coll)) { if (collid == report.getId(coll)) {
@@ -539,9 +526,9 @@ var CommunitySelector = function(report, parent, paramCollSel) {
}); });
}); });
} }
if (comm.subcommunities != null) { if (comm.community != null) {
$.each(comm.subcommunities, function(index, scomm) { $.each(comm.community, function(index, scomm) {
self.addCommLabel(collSel, COMMS, COMMS["comm"+report.getId(scomm)], indent + 1, paramCollSel); self.addCommLabel(collSel, scomm, indent + 1, paramCollSel);
}); });
} }
} }