Ticket #785 (closed Enhancement: fixed)

Opened 6 years ago

Last modified 6 years ago

Core API: involve the (relating) associations when updating a composite object

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.6
Component: DeepaMehta Standard Distribution Version: 4.5
Keywords: Cc: dgf, Malte
Complexity: 3 Area: Application Framework / API
Module: deepamehta-core

Description

Along with #341 (Association Definitions with Custom Association Types) the associations which connect the child topics (the "Relating Associations") need more attention. The model object used to update a composite topic/association (that includes creating/updating/referencing child topics) should contain the information to update the respective Relating Associations as well.

See also #647

Change History

comment:1 Changed 6 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 6 years ago by Jörg Richter <jri@…>

In 915d837651eeb6b45bd939a770f3edcb9cf1ed01/deepamehta:

Core API: init relating assoc (#785).

4 new methods in ChildTopics with an additional relatingAssocChildTopics parameter:

ChildTopics setRef(String childTypeUri, long   refTopicId,  ChildTopicsModel relatingAssocChildTopics)
ChildTopics setRef(String childTypeUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics)
ChildTopics addRef(String childTypeUri, long   refTopicId,  ChildTopicsModel relatingAssocChildTopics)
ChildTopics addRef(String childTypeUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics)

The relatingAssocChildTopics are used as the model for the Relating Association to be created. The Relating Association is the one that connects the referenced child topic.

This is in particular useful for child topics whose underlying association definition has a Custom Association Type set. The custom association instance is initialized with the passed child topics model then.

Note: not yet functional.
The new API is there just to support the conversion of the Contacts data to the new data model (#779).

Todo:

  • equip the set() and add() methods accordingly.
  • add more methods to support simple custom association types as well. (Currently only composite.)

See #785.

comment:3 Changed 6 years ago by Jörg Richter <jri@…>

In 3ca552f99dd7ecfa75c332b8399307207e34eae0/deepamehta:

Core API: ChildTopicsModel? holds RelTopics? (#785).

CHANGE

A ChildTopicsModel holds RelatedTopicModels (instead of TopicModels).
This means that a ChildTopicsModel? can hold all the information required to update the Relating Associations as well.

Consequently a ChildTopics object holds RelatedTopics (instead of Topics).

The corresponding getters and setters are adapted.

Not yet functional. Tests don't pass.

Available in branch "child-topics-model".

See #785.

comment:4 Changed 6 years ago by Jörg Richter <jri@…>

comment:5 Changed 6 years ago by Jörg Richter <jri@…>

In 5d82c5232d6a8660ebbbc7dc417cf184328e689a/deepamehta:

All tests pass again (#785).

BREAKING CHANGES

Core API:

de.deepamehta.core.ChildTopics:
    List<RelatedTopic> getTopics(String childTypeUri)

de.deepamehta.core.model.ChildTopicsModel:
    List<RelatedTopicModel> getTopics(String childTypeUri)

The getTopics() methods (cardinality "many") return RelatedTopics resp. RelatedTopicModels (instead of plain Topics resp. TopicModels).

Note: also the other ChildTopics and ChildTopicsModel methods now deal with related topics (instead of plain topics). However these changes are not BREAKING.

See #785.

comment:6 Changed 6 years ago by Jörg Richter <jri@…>

comment:7 Changed 6 years ago by Jörg Richter <jri@…>

comment:8 Changed 6 years ago by Jörg Richter <jri@…>

In 25dbd77f2c74f85c8a2e38f92daf59e87e679181/deepamehta:

Core fix: topic refs including assoc info (#341).

JuergeN's "Person-Company" example now works. That adds a simple "Company" child type to the "Person" type via Aggregation Definition and sets "Organizational Role" as the Custom Association Type. "Organizational Role" is a composite association type having "Role Label" as its child type, again via Aggregation Definition. "Role Label" is a simple type (of data type "Text").

CHANGES

REST API:

In an update request when referencing an existing topic (via ref_id: or ref_uri: prefix) you can update the Relating Association as well. That is useful in conjunction with custom associations.

Formerly a reference was just a string (e.g. "ref_id:2345"), so there was no opportunity to specify any values for the association (the Relating Association) that connects the referenced topic:

{
    id: 1234,
    childs: {
        child.type.uri: "ref_id:2345"
    }
}

Now you can wrap a reference in a topic object, and add values for the Relating Association by using the topic's "assoc" property. Put the actual reference in the topic's "value" property.

{
    id: 1234,
    childs: {
        child.type.uri: {       <-- topic
            value: "ref_id:2345",
            assoc: {            <-- relating association
                value: ...
                childs: ...
            }
        }
    }
}

Note: the former format remains supported. It is handy when no custom associations are involved.

Core API:

To support topic references which hold info about the relating association as well, TopicReferenceModel is derived from RelatedTopicModel (instead of TopicModel) since a while. Now the Core respects the relating association part as well when performing an update operation involving topic references.

See #341.
See #785.

comment:9 Changed 6 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.