Author Topic: Type parameter of Collection::AddNew method  (Read 1656 times)

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Type parameter of Collection::AddNew method
« on: January 30, 2013, 02:10:01 am »
Hi,

I have developed an MDG technology. I've been trying to automate certain capabilities using the Java API. I'm puzzled by the Type parameter of the Collection::AddNew method. I recall reading somewhere that, when adding an element from an MDG technology, the correct usage is:

   collection.AddNew(name, "profile-id::element-type")

where profile-id is the ID of the UML profile in my MDG technology (specifically, the value of the id attribute in the Documentation element) and element-type is the name of an element from my MDG technology that is a stereotype.

The odd thing is, sometimes this works and sometimes it doesn't. When it doesn't work, the API throws an exception whose message is "Invalid type".

Can someone provide more information on this topic? What values are acceptable, and why? I suppose some understanding of EA's internals is required; at least, I haven't found anything in the available documentation.  If you know of something, please point me that way. Thanks!

(By the way, I've tried other approaches: not including the profile ID, and using the profile name rather than its ID. These either fail or are unsatisfactory for reasons for which I won't burden this forum.)

qwerty

  • EA Guru
  • *****
  • Posts: 9766
  • Karma: +179/-152
  • I'm no guru at all
    • View Profile
Re: Type parameter of Collection::AddNew method
« Reply #1 on: January 30, 2013, 03:25:58 am »
For which collections does it fail? Just foe EaElement or also others? Do have some example (for non-/failing) parameters and maybe some insight in the profile?

q.

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Re: Type parameter of Collection::AddNew method
« Reply #2 on: January 30, 2013, 04:01:22 am »
Qwerty,

So far I've only tried EaElement. I do have some examples, but my technology is hard to condense into something I can fit on the forum. Is the following enough?

The profile implements the (as yet unofficial) version 2 of ODM. (It was originally developed by a former Sparx Systems employee.) The code:
org.sparx.Package model = ...;
org.sparx.Collection<org.sparx.Package> pkgs = model.GetPackages();
org.sparx.Package p = pkgs.AddNew("ontology", "B62663A0-03::owlOntology");
works, except that the stereotypes are from EA's built-in ODM profile. The code:
org.sparx.Collection<org.sparx.Element> e = p.GetElements();
e.AddNew("objProp", "B62663A0-03::objectProperty");
works as I expect. The code:
e.AddNew("uc", "B62663A0-03::UnionClass");
throws an exception.

In my profile, owlOntology extends metaclass Package, and objectProperty and UnionClass both extend metaclass Class.

qwerty

  • EA Guru
  • *****
  • Posts: 9766
  • Karma: +179/-152
  • I'm no guru at all
    • View Profile
Re: Type parameter of Collection::AddNew method
« Reply #3 on: January 30, 2013, 04:29:11 am »
Is there any significant difference between UnionClass and objectProperty? Have you looked down the UML Settings for similar (conflicting) stereotypes?

q.

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Re: Type parameter of Collection::AddNew method
« Reply #4 on: January 30, 2013, 04:38:48 am »
I don't know of any real differences between objectProperty and UnionClass. They have different attributes; that's all I can think of. Any ideas on other kinds of differences?

I don't have any similar existing stereotypes. None have a name that's even close.

qwerty

  • EA Guru
  • *****
  • Posts: 9766
  • Karma: +179/-152
  • I'm no guru at all
    • View Profile
Re: Type parameter of Collection::AddNew method
« Reply #5 on: January 30, 2013, 05:14:15 am »
Hard to tell then. You should probably contact Sparx support and send your profile with an error description. They are usually very quick in finding the cause and helping you out.

q.

[edit] Just another thought. Have you turned on any other MDG. Then try running with your MDG solely.
« Last Edit: January 30, 2013, 05:17:43 am by qwerty »

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Re: Type parameter of Collection::AddNew method
« Reply #6 on: January 30, 2013, 07:52:41 am »
Good thought, but didn't work. Thanks for the time you spent on this. Tech support, here I come.