generic parent object handling
[potlatch2.git] / net / systemeD / halcyon / connection / Relation.as
index 58cdc9009d02f833dd3783aafdfbe89df94cc762..475a95ef00303cd7e33aa294dfad9287966055ab 100644 (file)
@@ -2,10 +2,12 @@ package net.systemeD.halcyon.connection {
 
     public class Relation extends Entity {
         private var members:Array;
+               public static var entity_type:String = 'relation';
 
         public function Relation(id:Number, version:uint, tags:Object, members:Array) {
             super(id, version, tags);
             this.members = members;
+                       for each (var member:RelationMember in members) { member.entity.addParent(this); }
         }
 
         public function get length():uint {
@@ -17,21 +19,29 @@ package net.systemeD.halcyon.connection {
         }
 
         public function setMember(index:uint, member:RelationMember):void {
-            members.splice(index, 1, member);
+                       member.entity.addParent(this);
+                       members.splice(index, 1, member);
         }
 
         public function insertMember(index:uint, member:RelationMember):void {
+                       member.entity.addParent(this);
             members.splice(index, 0, member);
         }
 
         public function appendMember(member:RelationMember):uint {
+                       member.entity.addParent(this);
             members.push(member);
             return members.length;
         }
 
         public function removeMember(index:uint):void {
-            members.splice(index, 1);
+            var removed:Array=members.splice(index, 1);
+                       removed[0].entity.removeParent(this);
         }
+
+               public override function getType():String {
+                       return 'relation';
+               }
     }
 
 }