Opened 12 years ago

Closed 12 years ago

#1297 closed enhancement (fixed)

Add support for custom 'data loaders' and collections to SimpleExporter (aka. table exporter)

Reported by: Nicklas Nordborg Owned by: Martin Svensson
Priority: major Milestone: BASE 2.12
Component: web Version:
Keywords: Cc:


The use of a Formatter implementation as described in #1272 turned out to be a bit problematic when used with child items (#1128). One reason is that the loading can't be separated from the formatting. Since the SimpleExporter? also supports export to an xml file the initial scheme of simply comma-separating child items was too restrictive. In XML mode we wan't each child item in it's own tag.

The proposed solution to this problem is to define a DataLoader interface which has a single method: getData() with the same signature as the current getData() method in the QueryWrapper interface. DataLoader implementations can be passed to the plug-in in the same way as we currently pass Formatter implementations to it. Eg:

cc.setObject("export.dataloader.children", new ChildDataLoader());

Then, inside the SimpleExporter we can use the specified data loader or use the generic QueryWrapper:

Object data = ep.dataLoader == null ?
  queryWrapper.getData(ep, item) : ep.dataLoader.getData(ep, item);

A second step is to support collections of values. Since we want the XML export to be more fancy we probaby need to add ExportTemplate.writeCollection() method. The SimpleExporter should then check the type of the loaded data and call the correct template method:

if (data instanceof Collection)
   template.writeCollection(ep, data);
   template.writeProperty(ep, data);

When this is in place, all that remains is to implement specific DataLoader:s for loading the proper child items.

Change History (3)

comment:1 Changed 12 years ago by Martin Svensson

Owner: changed from everyone to Martin Svensson
Status: newassigned

comment:2 Changed 12 years ago by Martin Svensson

(In [4898]) References #1297 Added support for custom data loaders and collections

comment:3 Changed 12 years ago by Martin Svensson

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.