How to know the class of an entity?

Thomas Sødring Thomas.Sodring at hioa.no
Tue May 23 20:39:35 CEST 2017


I have considered this and wondered if saksmappe and moetemappe should not be part of the mappe list. It comes down to how inheritance is handled in the core.


If inheritance is joined, mappe exists as a table and moetmappe and saksmappe link back to the mappe table. In essence the record is distributed across two tables and most CRUD operations will require a SQL join.  This is what nikita does.


The other strategy is a table per entity, where there is just a moetemappe and saksmappe table. There is no mappe table. In this case a call to find all mappe would require processing of saksmappe and moetemappe on their own.


My understanding of the spec is that joined is the underlying method they hint at is to use joined.


I thought it was possible to filter out saksmappe when you get all mappe. If the entity is a mappe, then it will use arkivstruktur/mappe, but if the entity is a saksmappe it will use sakarkiv/saksmappe. This should be visible now and was one of the things that was fixed when I did the big anti-pattern update.



 - Tom


________________________________
From: nikita-noark-bounces at nuug.no <nikita-noark-bounces at nuug.no> on behalf of Petter Reinholdtsen <pere at hungry.com>
Sent: Tuesday, May 23, 2017 8:20:29 PM
To: nikita-noark at nuug.no
Subject: How to know the class of an entity?


Using the API, is there a well known way to figure the class of an
entity?  I have not seen it described in the spec.  It might remove the
need for a .../arkivdel/<id>/saksmappe endpoint, as I could instead use
the .../arkivdel/<id>/mappe endpoint and filter out entities without the
saksmappe class.

When looking at <URL: http://n5test.kxml.no/api/arkivstruktur/mappe >, I
notice this trick which could be used to identify the class of 'self':

  "_links":[
    {
      "rel":"self",
      "href":"http://n5test.kxml.no/api/arkivstruktur/Mappe/37a8f68c-a9d3-4af2-b547-4fa95e36e70e",
      "templated":false
    }, {
      "rel":"http://rel.kxml.no/noark5/v4/api/arkivstruktur/mappe",
      "href":"http://n5test.kxml.no/api/arkivstruktur/Mappe/37a8f68c-a9d3-4af2-b547-4fa95e36e70e",
      "templated":false
    }, ...

Here you can see that the 'self' link have a href that is identical to
another href, and the rel of that href represent the class of the
entity.

Did I miss the description in the spec stating that this is the way to
detect the entity class, or should we write a defect report suggesting
how to figure out the class of a entity?

--
Happy hacking
Petter Reinholdtsen

_______________________________________________
nikita-noark mailing list
nikita-noark at nuug.no
https://lists.nuug.no/mailman/listinfo/nikita-noark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.nuug.no/pipermail/nikita-noark/attachments/20170523/c9a2cf3a/attachment.htm 


More information about the nikita-noark mailing list