start of turn restriction editor
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / RelationMemberEditorFactory.as
index 86cd9aa7081c1be6a9ec3799a661214c5693a020..180810e035cc4da08fc649462342379aace8b36d 100644 (file)
@@ -6,6 +6,7 @@ package net.systemeD.potlatch2.mapfeatures.editors {
 
        public class RelationMemberEditorFactory extends EditorFactory {
            private var _relationTags:Object;
+               private var _role:String;
         
         public function RelationMemberEditorFactory(inputXML:XML) {
             super(inputXML);
@@ -13,27 +14,35 @@ package net.systemeD.potlatch2.mapfeatures.editors {
             for each(var match:XML in inputXML.match) {
                 _relationTags[match.@k] = match.@v;
             }
+                       for each(var role:XML in inputXML.role) {
+                               _role=role.@role;
+                       }
         }
         
         public function get relationTags():Object {
             return _relationTags;
         }
         
+        public function get role():String {
+            return _role;
+        }
+        
         override public function areTagsMatching(entity:Entity):Boolean {
             var parentRelations:Array = entity.parentRelations;
             if ( parentRelations.length == 0 )
                 return false;
-                
+
             // get relations for the entity
             for each(var relation:Relation in parentRelations) {
+                               var match:Boolean=true;
                 for ( var k:String in _relationTags ) {
                     var relVal:String = relation.getTag(k);
-                    if ( relVal != _relationTags[k] )
-                        return false;
+                    if ( relVal != _relationTags[k] ) { match=false; break; }
+                                       if ( _role && !relation.hasMemberInRole(entity,_role) ) { match=false; break; }
                 }
+                               if (match) { return true; }
             }
-            // all must match
-            return true;
+                       return false;
         }
         
         override public function createEditorInstance(entity:Entity):DisplayObject {