POIs, and relations, and stuff :)
[potlatch2.git] / net / systemeD / halcyon / connection / Relation.as
1 package net.systemeD.halcyon.connection {
2
3     public class Relation extends Entity {
4         private var members:Array;
5                 public static var entity_type:String = 'relation';
6
7         public function Relation(id:Number, version:uint, tags:Object, loaded:Boolean, members:Array) {
8             super(id, version, tags, loaded);
9             this.members = members;
10                         for each (var member:RelationMember in members) { member.entity.addParent(this); }
11         }
12
13         public function update(version:uint, tags:Object, loaded:Boolean, members:Array):void {
14                         var member:RelationMember;
15                         for each (member in this.members) { member.entity.removeParent(this); }
16                         updateEntityProperties(version,tags,loaded); this.members=members;
17                         for each (member in members) { member.entity.addParent(this); }
18                 }
19                 
20         public function get length():uint {
21             return members.length;
22         }
23
24         public function getMember(index:uint):RelationMember {
25             return members[index];
26         }
27
28         public function setMember(index:uint, member:RelationMember):void {
29                         member.entity.addParent(this);
30                         members.splice(index, 1, member);
31         }
32
33         public function insertMember(index:uint, member:RelationMember):void {
34                         member.entity.addParent(this);
35             members.splice(index, 0, member);
36         }
37
38         public function appendMember(member:RelationMember):uint {
39                         member.entity.addParent(this);
40             members.push(member);
41             return members.length;
42         }
43
44         public function removeMember(index:uint):void {
45             var removed:Array=members.splice(index, 1);
46                         removed[0].entity.removeParent(this);
47         }
48
49                 public override function getType():String {
50                         return 'relation';
51                 }
52     }
53
54 }