cancel
Showing results for 
Search instead for 
Did you mean: 

property names with german umlauts - access using Java API fails

Occasional Contributor

property names with german umlauts - access using Java API fails

I have a Java (more precisely, a Groovy) program which retrievs attributes of MegaObjects, i.e.

 

// access an attribute whose name includes a german umlaut
obj.getAttribute("Verfügbarkeit").getValue()

// access a collection whose name includes a german umlaut
domain.getCollection("Owner-IT-Städteplan")

This works fine, if I run the program from within my IDE (eclipse, in my case). When I run in from the command line, though, I get the following exception

 

MEGA Error 0x80020009(MegaObject.GetProp) : MegaObject.GetProp:Name 'Verf?gbarkeit' is not a valid argument
at com.mega.modeling.api.jni.MegaObjectJNI.getGetProp(Native Method)
at com.mega.modeling.api.jni.MegaObjectProxy.getProp(Unknown Source)

Any ideas why I get this exception?

 

3 REPLIES
MEGA

Re: property names with german umlauts - access using Java API fails

Hello,

 

you should use fields instead of string in your code :-)

To do so, for example, search for your "Verfügbarkeit" metaAttribute in MEGA and "right click > Copy" on it.

Open your script editor, and paste it.

Now copy what has been pasted in your script editor, and paste it in your code.

You should get something like :

obj.getAttribute("~A2(lhb13Avm0[Verfügbarkeit]").getValue()

I think it will work better.

 

Regards,

 

Lionel

Occasional Contributor

Re: property names with german umlauts - access using Java API fails

Thanks, Lionel! Unfortunately, in my environment this doesn't work, copy/paste results in "Verfügbarkeit" only, without the unique MEGA identifier

 

But I was able to retrieve the field for the MetaAttribute "Verfügbarkeit" with the following groovy script: 

 

// this is a groovy fragment 
def attrs = root.getSelection(""" Select [MetaAttribute] Where [Name] = "Verfügbarkeit" """) println("Field: ${attrs.get(1).megaField()}")

 

 

Highlighted
MEGA

Re: property names with german umlauts - access using Java API fails

Strange that it did not work.

Are you sure you pasted it in the MEGA Script Editor before copying it again from the MEGA Script Editor to finally paste it in your code ? You could also copy directly the Absolute Identifier from MEGA and paste it in your code instead of the name of your attribute (do not forgot the "~" character, the brackets are not mandatory).

In any case, your "groovy" solution works too :-)

 

Lionel