[deepamehta-devel] new data model

Jörg Richter jri at deepamehta.de
Thu Nov 19 01:10:37 CET 2015


Hi Jürgen,

in your case the relevant changes in the DM REST API and the Access Control system are:

DM 4.4: the JSON property "composite" is renamed to "childs". So, in your JSON always write "childs" instead of "composite".
https://trac.deepamehta.de/ticket/702

DM 4.5: the Access Control concept is completely revised. Each topic/association "derives" its ACL settings from the workspace it is assigned to. So, each topic/association should have a workspace assignment (otherwise it will not be editable).
https://trac.deepamehta.de/ticket/592

DM 4.6: custom association types were introduced. In general the JSON format (as used by the REST API) is still upward compatible, that is JSON written before 4.6 still works in 4.6. Only when custom associations are involved you'll make use of the new "assoc" JSON property.
https://trac.deepamehta.de/ticket/341

Also in DM 4.6 the Contacts models was redefined in order to make use of custom association types, namely "Phone Entry" and "Address Entry" (which are composite). A Person is now *directly* connected to Phone/Address topics via such an Entry association. The Phone Label/Address Label are childs of these associations.

This example illustrates the creation of a Person topic according to the new Contacts model, in particular the use of custom associations:

curl -X POST localhost:8080/core/topic -H Content-Type:application/json -d '{
    type_uri: "dm4.contacts.person",
    childs: {
        dm4.contacts.person_name: {
            dm4.contacts.first_name: "Karl",
            dm4.contacts.last_name: "Kungel"
        },
        dm4.contacts.phone_number: [
            {
                value: "12345678",
                assoc: {
                    childs: {
                        dm4.contacts.phone_label: "ref_uri:dm4.contacts.home_phone"
                    }
                }
            }
        ],
        dm4.contacts.address: [
            {
                childs: {
                    dm4.contacts.street: "Spreeweg 3",
                    dm4.contacts.postal_code: "12345",
                    dm4.contacts.city: "Berlin"
                },
                assoc: {
                    childs: {
                        dm4.contacts.address_label: "ref_uri:dm4.contacts.home_address"
                    }
                }
            }
        ]
    }
}'

When you don't want assign a phone label you can just write:

        dm4.contacts.phone_number: ["12345678"]

When you don't want assign an address label you can just write:

        dm4.contacts.address: [
            {
                dm4.contacts.street: "Spreeweg 3",
                dm4.contacts.postal_code: "12345",
                dm4.contacts.city: "Berlin"
            }
        ]

That is, just drop the "assoc" property. DM will still create a custom association of type "Phone Entry" resp. "Address Entry", as this is defined in the Contacts model. The Entry association will just have no child topic (= phone label / address label) assigned to it.

You also asked for creating Note topics. This is straight-forward. No custom associations are involved:

curl -X POST localhost:8080/core/topic -H Content-Type:application/json -d '{
    type_uri: "dm4.notes.note",
    childs: {
        dm4.notes.title: "My Note",
        dm4.notes.text: "<p>My HTML content here<p>",
    }
}'

General hints (not related to DM changes) follow:

Note that Phone and Address are defined as "many". That's why a JSON array (brackets) appear: [ ... ]. To store many phone numbers or addresses just put them in the array: [..., ..., ...]

In order to assign the created topic to a workspace in the first place, add a workspace cookie (Cookie header) to your POST request. (Alternatively you can do the assignment afterwards by the means of the DM Workspaces service). For help see the comments in this ticket:
https://trac.deepamehta.de/ticket/767

Your request must be authenticated. Do so either by attaching an Authorization header or a session ID (Cookie header) to it. For help see also this ticket:
https://trac.deepamehta.de/ticket/767

That's great you're adapting the address book importer to DM 4.7!

Cheers,
Jörg


On Nov 18, 2015, at 20:33, Juergen Neumann wrote:

> Dear Jörg,
> 
> since the data model for composites has changed a lot since the
> introduction of custom assoc types and with the new workspace acls in
> place, I wanted to ask you, if you could please provide me with an
> updated json structure to create a person topic with curl against the
> REST API. Maybe you could also provide a simple note topic example.
> 
> Thank you very much in advance!
> 
> JuergeN
> 
> -- 
> devel mailing list
> devel at lists.deepamehta.de
> http://lists.deepamehta.de/mailman/listinfo/devel-lists.deepamehta.de



More information about the devel mailing list