[deepamehta-devel] changing label config of existing topic type

Robert Schuster robert.schuster.rs01 at gmail.com
Tue Jan 17 13:53:09 CET 2017


Hi all together,
so I could solve half of the problem.

This code failed with a NoSuchMethodException in the 3rd line:

        TopicType tt = dm4.getTopicType(NS("comment"));
        TopicTypeModel ttm = (TopicTypeModel) tt.getModel();
**     ttm.setLabelConfig(Arrays.asList("dm4.contacts.person_name",
"dm4.contacts.email_address"));
        dm4.updateTopicType(ttm);

The culprit was, that my pom.xml was referring dm-core 4.8.3 and I had
overlooked that. The reason for the NSM-Exception is that in DM 4.8.4
the setLabelConfig() method has a return value while in 4.8.3 it does
not. Such a change while compatible at the source level (at least if you
don't use the return value) is not binary compatible. So after fixing
that I could get my code to work.

I wanted to do the change to the view labels to another type as well.
Coincidentally that type uses the same child types so the code should be
the same. However no matter how hard I tried it will always fail with a
NullPointerException:

Caused by: java.lang.RuntimeException: Updating label configuration of
type "fi.aalto.gamechangers.proposal" failed
    at
de.deepamehta.core.impl.TypeModelImpl._updateLabelConfig(TypeModelImpl.java:553)
    at
de.deepamehta.core.impl.TypeModelImpl.updateType(TypeModelImpl.java:506)
    at
de.deepamehta.core.impl.TypeModelImpl.postUpdate(TypeModelImpl.java:290)
    at
de.deepamehta.core.impl.DeepaMehtaObjectModelImpl.update(DeepaMehtaObjectModelImpl.java:400)
    ... 54 more
Caused by: java.lang.NullPointerException
    at
de.deepamehta.core.impl.TypeStorage.updateLabelConfig(TypeStorage.java:733)
    at
de.deepamehta.core.impl.TypeModelImpl.updateLabelConfig(TypeModelImpl.java:341)
    at
de.deepamehta.core.impl.TypeModelImpl._updateLabelConfig(TypeModelImpl.java:550)
    ... 57 more
(This stack trace is from DM 4.8.5! )

I believe this is actually a bug because after my programmatic migration
failed I tried doing the view label change through the webclient and it
turned out, that the change to the topic type also fails.

All the best,
Robert

For the reference. This is the original definition of the "Proposal" type:

            {
                "value":            "Proposal",
                "uri":              "fi.aalto.gamechangers.proposal",
                "data_type_uri":    "dm4.core.composite",
                "assoc_defs": [
                    {
                        "child_type_uri":        
"dm4.contacts.person_name",
                        "child_cardinality_uri":  "dm4.core.one",
                        "assoc_type_uri":         "dm4.core.composition_def"
                    },
                    {
                        "child_type_uri":        
"dm4.contacts.email_address",
                        "child_cardinality_uri":  "dm4.core.one",
                        "assoc_type_uri":         "dm4.core.composition_def"
                    },
                    {
                        "child_type_uri":         "dm4.notes.text",
                        "child_cardinality_uri":  "dm4.core.one",
                        "assoc_type_uri":         "dm4.core.composition_def"
                    }
               ],
                "view_config_topics": [
                    {
                        "type_uri": "dm4.webclient.view_config",
                        "childs": {
                            "dm4.webclient.show_in_create_menu": true
                        }
                    }
                ]
            },


On 17.01.2017 11:52, Robert Schuster wrote:
> Hi guys,
> happy new year! Long time no see! :)
>
> I'm trying to achieve the following right now and am a bit stuck:
>
> I have an existing topic type and I want to change its label config as
> it was found out, that the implicit label config wasn't practical. So
> what I thought how it should be done was this:
>
> in a class that extends Migration:
>   - get the topic type (dm4.getTopicType("mymodel"); )
>   - get its model, cast this to TopicTypeModel
>   - call setLabelConfig with the new values
>   - do dm4.updateTopicType() with the above model
>
> However with that approach DM fails with a NoSuchMethodError. Apparently
> it does not find a setLabelConfig method.
>
> I am using DM 4.8.4 for compilation and at runtime.
>
> Any ideas?
>
> All the best,
> 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