[great-dev] Re: [udm-users] RE: [great-users] "Com exception:
Object cannot be changed"
Aditya Agrawal
aagrawa at us.ibm.com
Sun Apr 10 15:46:03 CDT 2005
Dear Tivadar,
to create an association from the AM code you can use one of the
following.
1. Use UDM's generic API
sample code below (this is code that I wrote in AM of GReAT where OrState
is the parent of the relation and NewState and DataVar are pattern
instances available in the rule)
Uml::Class kind =
Uml::classByName(OrState.__impl()->__getdn()->GetRootMeta(),
"StateDataRelation");
if (!kind) return;
Udm::Object pso = OrState.CreateObject(kind);
if(pso==Udm::null)
{ printf("\n Error: Creation of Object failed \n");
}
else
{ pso.SetStrValue("Value", val);
pso.SetStrValue("Color", "black");
Udm::Object::AssociationInfo inf(kind);
inf.strSrcRoleName = "states";
inf.strDstRoleName = "data";
NewState.CreateLink(pso, inf);
inf.strSrcRoleName = "data";
inf.strDstRoleName = "states";
DataVar.CreateLink(pso, inf);
}
2. As far as I know you should also be able to use the custom API to do
the same
some thing like this
StateDataRelation rel = StateDataRelation::Create(OrState);
rel.states() += NewState;
rel.data() = DataVar;
Thanks,
Adi
-----------------------------------
Aditya Agrawal
Researcher
IBM T. J. Watson
mailto:aagrawa at us.ibm.com
+1 (914) 784-6068 (TL 863)
great-users-bounces at list.isis.vanderbilt.edu wrote on 04/09/2005 11:04:05
AM:
> Hello,
>
> Thanks for the answers.
> Looks like the problem can be solved by
>
> 1) identifying the archetype from a guard/AttrMap code using Endre's
code
> 2) from the same guard/AttrMap create an association (defined in
> CrossLinks) between the object and it's archetype
> 3) match this association from a subsequent GReAT rule
>
> Let's say I have an association between two MyObjects (srcMyObject,
> dstMyObject) defined in CrossLinks.
>
> How do I create the association of step 2) ?
>
> I tried to look at the generated code of a GReAT rule for creating such
> association, and replicate it, but it did not work.
>
>
> Thanks,
>
> Tivadar
>
> Endre Magyari wrote:
>
> >
> > Then the code is:
> >
> > Udm::Object o;
> >
> > if (o.isInstance())
> > {
> > //o is an instance, only it's type can be modified
> > Udm::Object type = o.archetype();
> > //modify type
> > }
> > else
> > {
> > //o is not an instance, it's either an normal object(model, fco,
> > atom) or a derived object, which can be modified.
> > //if it's a derived object, isSubtype() returns true
> > };
> >
> >
> >
> > Note that this is generic code, but since all generated types are
> > inherited from Udm::Object, isInstance(), isSubtype() works.
> > For the generated classes in UDM API there is also available an
> > Archetype()call, which is typed, it returns with an object of the
> > same type.
> >
> >
> > Endre
> >
> >
> >
> > On Fri, 8 Apr 2005 10:20:39 -0500, Attila Vizhanyo
> > <viza at isis.vanderbilt.edu> wrote:
> >
> >> Tivadar wants to (1) query if an object is instance or not (2) if it
is,
> >> get access to its type object, and modify the type object.
> >>
> >>
> >>> -----Original Message-----
> >>> From: Endre Magyari
> >>> Sent: Friday, April 08, 2005 2:06
> >>> To: udm-users
> >>> Cc: This is a list for GReAT developers to exchange
> >>> development related thoughts and ideas
> >>> Subject: [great-dev] Re: [udm-users] RE: [great-users] "Com
> >>> exception: Object cannot bechanged"
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> Attila,
> >>>
> >>> there is no UDM API which permits to modify an instance
> >>> object - besides,
> >>> Tivadar is talking about a COM exception thrown by MGA layer.
> >>> So, what kind of solution did you mean ?
> >>>
> >>> Thanks,
> >>> Endre
> >>>
> >>>
> >>> On Thu, 7 Apr 2005 16:42:22 -0500, Attila Vizhanyo
> >>> <viza at isis.vanderbilt.edu> wrote:
> >>>
> >>> > I believe these problems can be solved using the UDM API
> >>> from Guard/
> >>> > AttributeMapping code. I'm forwarding your post to the
> >>> udm-users list.
> >>> >
> >>> > Thanks,
> >>> > Attila
> >>> >
> >>> >
> >>> >> -----Original Message-----
> >>> >> From: Tivadar Szemethy
> >>> >> Sent: Thursday, April 07, 2005 16:28
> >>> >> To: great-users
> >>> >> Subject: [great-users] "Com exception: Object cannot be changed"
> >>> >>
> >>> >>
> >>> >> Hello,
> >>> >>
> >>> >> In a GReAT transformation, I have to make temporary
> >>> modifications to
> >>> >> my src model in order to make further processing easier. However,
> >>> >> some of the objects in the src are Instances (as in General
> >>> >> Properties/Type in the Attribute Panel in GME) of other objects
> >>> >> defined in a "Model Library" folder in the src model.
> >>> >>
> >>> >> As I understand, instances cannot be modified.
> >>> >> Therefore, I need to come up with a GReAT rule, which:
> >>> >>
> >>> >> a) checks whether the object in question is an Instance or not
> >>> >> b) if it is, returns the corresponding "Template" object
> >>> which can be
> >>> >> modified
> >>> >>
> >>> >> How do I do this ?
> >>> >>
> >>> >> Thanks,
> >>> >>
> >>> >> Tivadar
> >>> >> _______________________________________________
> >>> >> great-users mailing list great-users at list.isis.vanderbilt.edu
> >>> >> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users
> >>> >>
> >>> > _______________________________________________
> >>> > udm-users mailing list
> >>> > udm-users at list.isis.vanderbilt.edu
> >>> > http://list.isis.vanderbilt.edu/mailman/listinfo/udm-users
> >>>
> >>>
> >>> _______________________________________________
> >>> great-dev mailing list
> >>> great-dev at list.isis.vanderbilt.edu
> >>> http://list.isis.vanderbilt.edu/mailman/listinfo/great-dev
> >>>
> >> _______________________________________________
> >> great-dev mailing list
> >> great-dev at list.isis.vanderbilt.edu
> >> http://list.isis.vanderbilt.edu/mailman/listinfo/great-dev
> >
> >
> >
>
>
> _______________________________________________
> great-users mailing list
> great-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20050410/6f8b6527/attachment.htm
More information about the great-users
mailing list