[deepamehta-devel] Setting a simple association programmatically

Robert Schuster robert.schuster.rs01 at gmail.com
Mon Oct 24 20:31:45 CEST 2016

Hey Malte,
thanks a lot this was, of course, the right solution!

Yeah, I was kind of expecting the write operation to be somewhere else
than ChildTopics but couldn't figure out where and then after a while of
trying I was blinded by too many
ModelModelFactoryAdapterChannelBuilderConnectorImpl ;-) ;-) ;-) ...

Thanks again!

All the best,

On 23.10.2016 23:44, Malte Reissig wrote:
> Hi Robert,
> that is an very interesting observation. The solution lies in the
> "CoreService", it "provides the methods to deal with topics,
> associations, types and plugins", among others there is a
> `createAssociation` method.
> Tocreate a simple "dm4.core.association" you can write, for example:
> dm4.createAssociation(mf.newAssociationModel("dm4.core.association",
>     mf.newTopicRoleModel(username.getId(), "dm4.core.default"),
>     mf.newTopicRoleModel(website.getId(), "dm4.core.default")));
> In your plugin the CoreService is available through the `dm4` object:
> http://api.deepamehta.de/deepamehta/4.8.3/de/deepamehta/core/service/CoreService.html
> I must leave a better explanation to others here but here is my quick
> answer: ChildTopics is a core service utility which takes the
> respective type definition into account governing the relation
> between, e.g. a "Comment" and a "Blogpost". If your "Comment" type is
> not (child) part of a "Blogpost"s type definition you can not use
> ChildTopics.addRef(). For an "assocDefUri" (=associationDefinitionUri)
> the only two valid values are "dm4.core.composition" or
> "dm4.core.aggregation".
> You might want to consider to either (1) introduce a custom
> association type to express this relation (esp. if the association
> carries dedicated application logic and not rely on ChildTopics but on
> dm4.createAssociation() or (2) alter the type definition of the parent
> in a way that, e.g. for each "Blogpost" a "Comment" becomes a (by
> type) defined (meaning either aggregated, composed) child of it.
> I hope this helps.
> Nice greetings,
> Malte
> On 23.10.2016 22:10, Robert Schuster wrote:
>> Hi all,
>> I want to create a simple association between between two topics
>> programmatically.
>> So the result should be as if I would draw a line between two topics in
>> the webclient. I was under the impression that this would be a simple:
>>          ChildTopics childs = comment.getChildTopics();
>>          childs.addRef("dm4.core.association", topicCommentOn.getId());
>> However that did not work as intended. Any idea what I am missing here?
>> What wonders me also is that this code seemingly works without error but
>> I cannot 'see' any associations in the webclient later on.
>> Best regards,
>> Robert

Robert Schuster
freiberuflicher Softwareingenieur

RS01 - IT-Systemanalyse und -entwicklung Robert Schuster
Brückenstraße 4 • 12439 Berlin
+49 157 798 00 310
robert.schuster.rs01 at gmail.com

More information about the devel mailing list