[Mobies-commit] [commit] r3667 - UDM/trunk/src/UdmCliGen
ksmyth at redhat1.isis.vanderbilt.edu
ksmyth at redhat1.isis.vanderbilt.edu
Wed Mar 23 12:34:32 CDT 2011
Author: ksmyth
Date: Wed Mar 23 12:34:31 2011
New Revision: 3667
Log:
Fix associations with association classes. Add associations on association classes.
Modified:
UDM/trunk/src/UdmCliGen/Base.tmpl
UDM/trunk/src/UdmCliGen/Implementation.tmpl
UDM/trunk/src/UdmCliGen/Interface.tmpl
Modified: UDM/trunk/src/UdmCliGen/Base.tmpl
==============================================================================
--- UDM/trunk/src/UdmCliGen/Base.tmpl Tue Mar 22 15:54:26 2011 (r3666)
+++ UDM/trunk/src/UdmCliGen/Base.tmpl Wed Mar 23 12:34:31 2011 (r3667)
@@ -25,6 +25,22 @@
{
get { return backing.uniqueId(); }
}
+ public bool Equals(UdmCliObject that)
+ {
+ return this.id == that.id;
+ }
+ public override bool Equals(object that)
+ {
+ if (that as UdmCliObject != null)
+ {
+ return Equals((UdmCliObject)that);
+ }
+ return false;
+ }
+ public override int GetHashCode()
+ {
+ return id;
+ }
public string type_name
{
get { return backing.type().name().Get(); }
Modified: UDM/trunk/src/UdmCliGen/Implementation.tmpl
==============================================================================
--- UDM/trunk/src/UdmCliGen/Implementation.tmpl Tue Mar 22 15:54:26 2011 (r3666)
+++ UDM/trunk/src/UdmCliGen/Implementation.tmpl Wed Mar 23 12:34:31 2011 (r3667)
@@ -153,14 +153,15 @@
#for $arole in $c.associationRoles
#set orole = ($arole.parent.children()[1] if $arole != $arole.parent.children()[1] else $arole.parent.children()[0])
#set meta_name = $fq_name($c) + "." + role_metaname(orole)
+#def arolegen($propname, $retclass, $getAssocMode, $orole)
#if $orole.max == 1
- public $fq_iname(orole.target) @$orole.name
+ public $fq_iname($retclass) @$propname
{
get
{
- foreach (global::Udm.Native.UdmObject o in backing.getAssociation($meta_name))
+ foreach (global::Udm.Native.UdmObject o in backing.getAssociation($meta_name, $getAssocMode))
{
- return new $fq_name(orole.target)(o);
+ return new $fq_name($retclass)(o);
}
return null;
}
@@ -168,33 +169,56 @@
set
{
Udm.Native.Object_set set = new Udm.Native.Object_set();
- set.Add((($fq_name(orole.target))value).backing);
- backing.setAssociation($meta_name, set);
+ set.Add((($fq_name($retclass))value).backing);
+ backing.setAssociation($meta_name, set, $getAssocMode);
}
}
#else
- public global::System.Collections.Generic.IEnumerable<$fq_iname(orole.target)> @$orole.name
+ public global::System.Collections.Generic.IEnumerable<$fq_iname($retclass)> @$propname
{
get
{
return global::System.Linq.Enumerable.ToList(
- global::System.Linq.Enumerable.Select<global::Udm.Native.UdmObject, $fq_iname(orole.target)>
- (backing.getAssociation($meta_name), o => new $fq_name(orole.target)(o)));
+ global::System.Linq.Enumerable.Select<global::Udm.Native.UdmObject, $fq_iname($retclass)>
+ (backing.getAssociation($meta_name, $getAssocMode), o => new $fq_name($retclass)(o)));
}
## TODO: test this
set
{
Udm.Native.Object_set set = new Udm.Native.Object_set();
- foreach ($fq_iname(orole.target) o in value)
+ foreach ($fq_iname($retclass) o in value)
{
- set.Add((($fq_name(orole.target))o).backing);
+ set.Add((($fq_name($retclass))o).backing);
}
- backing.setAssociation($meta_name, set);
+ backing.setAssociation($meta_name, set, $getAssocMode);
}
}
#end if
+#end def
+#if not $arole.parent.assocClass
+$arolegen($orole.name, $orole.target, "Udm.Native.Udm.TARGETFROMPEER", $orole)
+#else
+$arolegen($orole.name, $orole.parent.assocClass, "Udm.Native.Udm.CLASSFROMTARGET", $orole)
+$arolegen($orole.name + ("_target" if $orole.max == 1 else "_targets"), $orole.target, "Udm.Native.Udm.TARGETFROMPEER", $orole)
+
+#end if
+#end for
+#if $c.association
+#for $role in $c.association.children()
+#set orole = ($role.parent.children()[1] if $role != $role.parent.children()[1] else $role.parent.children()[0])
+#set meta_name = $fq_name($orole.target) + "." + role_metaname($role)
+ public $fq_iname($role.target) @$role.name {
+ get
+ {
+ foreach (global::Udm.Native.UdmObject o in backing.getAssociation($meta_name, Udm.Native.Udm.TARGETFROMCLASS))
+ {
+ return new $fq_name($role.target)(o);
+ }
+ return null;
+ }
+ }
#end for
-##TODO: something for $c.association ?
+#end if
#end def
##
$accessors($c)
Modified: UDM/trunk/src/UdmCliGen/Interface.tmpl
==============================================================================
--- UDM/trunk/src/UdmCliGen/Interface.tmpl Tue Mar 22 15:54:26 2011 (r3666)
+++ UDM/trunk/src/UdmCliGen/Interface.tmpl Wed Mar 23 12:34:31 2011 (r3667)
@@ -33,12 +33,29 @@
// Association ends
#for $arole in $c.associationRoles
#set orole = ($arole.parent.children()[1] if $arole != $arole.parent.children()[1] else $arole.parent.children()[0])
+#if not $orole.parent.assocClass
#if $orole.max == 1
$fq_iname(orole.target) @$orole.name { get; set; }
#else
global::System.Collections.Generic.IEnumerable<$fq_iname(orole.target)> @$orole.name { get; set; }
#end if
+#else
+#if $orole.max == 1
+ $fq_iname(orole.parent.assocClass) @$orole.name { get; set; }
+## FIXME: possible name clash
+ $fq_iname(orole.target) @${orole.name}_target { get; set; }
+#else
+ global::System.Collections.Generic.IEnumerable<$fq_iname(orole.parent.assocClass)> @$orole.name { get; set; }
+ global::System.Collections.Generic.IEnumerable<$fq_iname(orole.target)> @${orole.name}_targets { get; set; }
+#end if
+#end if
+#end for
+// Association role
+#if $c.association
+#for $role in $c.association.children()
+## TODO: set
+ $fq_iname($role.target) @$role.name { get; }
#end for
-##TODO: something for $c.association ?
+#end if
}
}
More information about the Mobies-commit
mailing list