Hi Steve,
... and a merry Christmas to you also.

Comments within...


On 28 December 2015 at 09:23, Stephen Cameron <steve.cameron...@gmail.com>
wrote:

> Hi,
>
>  Merry Christmas to all and best wishes for 2016.
>
> I have to implement a 'bulk upload' monthly report in XML format to a
> funding organisation.
>
> After reading up on the new JAXB @XmlRootElement form of 'View Model' I am
> still unclear as to why there is also a need for the concept of a Data
> Transfer Object (DTO)? What function does having DTOs serve over and above
> what is possible with the JAXB annotations?
>
> I can understand the need for versioned interfaces so that the domain model
> can evolve independantly, but aren't View Models capable of serving the
> same purpose? It just seems to me that adding DTO into the picture is
> complicating things.
>
>
OK, perhaps - if it wasn't obvious - I need to review that documentation
[1] to clarify matters.  But to answer your questions now as to the intent:

Yes, a view model acts as a versioned interface to a domain model,  Two use
cases for such are:
  - for the REST API
  - to create serializable representations (typically XML), eg that can be
published on an external event bus, eg via ActiveMQ/Camel using the
publishmq module [2].  These are more commonly called DTOs.

So, we're thinking of DTOs as one particular kind of view model, in
particular targetted at this use case.

At the same time, we've had a long-standing limitation with @ViewModel (or
@DomainObject(nature=VIEW_MODEL)) that the only state that makes up the
view model's OID is that of properties; collections are ignored.  With the
JAXB-style the collections are now included in the state; in other words
the view model can be an arbitrarily complex graph of data.

What all this means is that JAXB view models will probably become the
standard way of implementing view models in Isis: they allow more complex
view models, and can also be serialized out as DTOs for events etc.



> I am envisaging that my reports can be such a View Model class, one for
> each month and each with collections to hold summary statistics (e.g total
> contact hours per client) for that month, derived from either SQL views or
> processing other true domain objects.
>
> What is not clear at the moment is how I can allow access those XML format
> view models, created via JAXB annotations, to the user via the UI. The XML
> snapshot service is used in the todoapp demo for this, but it has
> limitations on the size of what can be handled it seems. Is it possible to
> use the JAXB marshalling in the same way?
>
>
There's the JAXBService to do this, referenced here [3] and documented here
[4].  This also allows the XSD schema to be created (or via the maven
plugin [5]) such that one can generate consumers of the XML in other
programming languages.

You mentioned the XML Snapshot Service; I imagine in the future that this
might be deprecated and eventually removed, because using JAXB is much more
"standards compliant".

As to your use case - bulk upload of XML - you should be able to upload
this via a CLOB, and then use JaxbService#fromXml to convert into a JAXB
view model/DTO.

HTH
Dan





[1] http://isis.apache.org/guides/ugbtb.html#_ugbtb_view-models_jaxb
[2] https://github.com/isisaddons/isis-module-publishmq
[3] http://isis.apache.org/guides/ugbtb.html#_generating_xsds_and_dtos
[4] http://isis.apache.org/guides/rgsvc.html#_rgsvc_api_JaxbService
[5] http://isis.apache.org/guides/cg.html#_cg_isis-maven-plugin_xsd


>
> Thanks.
>

Reply via email to