Java function Any-object to list of datatypes.

1
I'd like to create a Java function, which has 'Any'-object as input and a list of attributes (and their datatypes) as output. I used the MXModelReflection module as an example for my function (I do not want to use the whole MXModelReflection module, because that would be overkill). I'm not a Java programmer and after a day of trying and figuring things out, I'm still not able to get a working function. Is there anyone who can help me out? Thanks in advance! --- UPDATE 13-02-2012 14:55 --- I'm a little bit closer to the solution. I wrote the following code: // BEGIN USER CODE List<IMendixObject> definities = new ArrayList<IMendixObject>(); for (IMetaPrimitive metaPrimitive : Core.getMetaObject(AnyObjectName).getMetaPrimitives()) { Definitie definitie = Definitie.create(this.getContext()); definitie.setColumn(metaPrimitive.getName()); definitie.setDataType(metaPrimitive.getType().toString()); definities.add(definitie.getMendixObject()); } return definities; // END USER CODE There are still two problems: Now I get the following error: 'AnyObjectName' is not a valid entity I'm using the name of the object as an input variable, but I would prefer to use an 'Any'-object.
asked
2 answers
2

If you recieve an Any Object you could say:

iMendixObject.getMetaObject()

in the loop.

iMendixObject is your parameter to your java action of type Any Object.

also you probably need

Core.commit(definitie .getMendixObject());
answered
0

Pass anyobject (in this case called MyEntity) and use

for (IMetaPrimitive metaPrimitive : MyEntity.getMetaObject().getMetaPrimitives())
answered