public void RemoveConnection(string parent, string child)
        {
            AtlasFeature parentFeature = GetFeature(parent);
            AtlasFeature childFeature  = GetFeature(child);

            RemoveConnection(new AtlasConnection(parentFeature, childFeature, 0));
        }
        public void AddConnection(string parent, string child, AtlasConnectionType type)
        {
            AtlasFeature parentFeature = GetFeature(parent);
            AtlasFeature childFeature  = GetFeature(child);

            AddConnection(new AtlasConnection(parentFeature, childFeature, type));
        }
 public void ClearModel()
 {
     features    = new Dictionary <string, AtlasFeature>();
     connections = new Dictionary <AtlasFeatureTuple, AtlasConnection>();
     constraints = new List <AtlasConstraint>();
     rootFeature = null;
 }
        public void CreateFeatureModel(AtlasFeature rootFeature)
        {
            CheckRoot(rootFeature);

            AddFeature(rootFeature);
            this.rootFeature = rootFeature;
        }
        public void SetCardinalityMin(AtlasFeature feat, int min)
        {
            if (!features.ContainsKey(feat.Name))
            {
                throw new ArgumentException("Feature does not exist");
            }

            feat.Minimum = min;
        }
        public void AddFeature(AtlasFeature newFeature)
        {
            if (features.ContainsKey(newFeature.Name))
            {
                throw new ArgumentException("Feature already exists");
            }

            features.Add(newFeature.Name, newFeature);
        }
        public bool RemoveCardinality(AtlasFeature feat)
        {
            if (!features.ContainsKey(feat.Name))
            {
                return(false);
            }

            feat.Minimum = 0;
            feat.Maximum = int.MaxValue;
            return(true);
        }
 internal void CheckRoot(AtlasFeature rootFeature)
 {
     if (this.rootFeature != null)
     {
         throw new InvalidOperationException("This Feature Model already has a root");
     }
     if (rootFeature == null)
     {
         throw new ArgumentNullException("Root cannot be null");
     }
 }
 private void ConnectionNodesCheck(AtlasFeature parent, AtlasFeature child)
 {
     if (!features.ContainsKey(parent.Name))
     {
         throw new ArgumentException("Parent feature does not exist");
     }
     if (!features.ContainsKey(child.Name))
     {
         throw new ArgumentException("Child feature does not exist");
     }
 }
예제 #10
0
        public void ReadXml(XmlReader reader)
        {
            XmlSerializer featureSerializer = new XmlSerializer(typeof(AtlasFeature));

            //Reading Features
            reader.ReadToFollowing("Features");
            XmlReader featureReader = reader.ReadSubtree();

            while (featureReader.ReadToFollowing("AtlasFeature"))
            {
                AddFeature((AtlasFeature)featureSerializer.Deserialize(featureReader));
            }
            featureReader.Close();

            reader.ReadToFollowing("RootFeature");
            string rootName = reader.ReadElementContentAsString();

            rootFeature = GetFeature(rootName);

            //Reading Connections
            if (!reader.Name.Equals("Connections"))
            {
                reader.ReadToFollowing("Connections");
            }
            XmlReader connectionReader = reader.ReadSubtree();

            while (connectionReader.ReadToFollowing("AtlasConnection"))
            {
                AtlasFeature        child  = GetFeature(reader["Child"]);
                AtlasFeature        parent = GetFeature(reader["Parent"]);
                AtlasConnectionType type   = (AtlasConnectionType)int.Parse(reader["Type"]);
                AddConnection(parent, child, type);
            }
            connectionReader.Close();

            //Reading Constraints
            if (!reader.Name.Equals("Constraints"))
            {
                reader.ReadToFollowing("Constraints");
            }
            XmlReader constraintReader = reader.ReadSubtree();

            while (constraintReader.ReadToFollowing("AtlasConstraint"))
            {
                AtlasConstraintValidationQueue queue = new AtlasConstraintValidationQueue(constraintReader["Content"]);
                queue.Normalize();
                AddConstraint(queue);
            }
            constraintReader.Close();

            reader.Close();
        }
예제 #11
0
        public void AddFeature(AtlasFeature newFeature, AtlasFeature parentFeature, AtlasConnectionType type)
        {
            if (features.ContainsKey(newFeature.Name))
            {
                throw new ArgumentException("Feature already exists");
            }
            if (!features.ContainsKey(parentFeature.Name))
            {
                throw new ArgumentException("Parent Feature does not exist");
            }

            AddFeature(newFeature);
            AddConnection(parentFeature, newFeature, type);
        }
예제 #12
0
        public AtlasFeature[] GetChildren(AtlasFeature parent)
        {
            List <AtlasFeature> features = new List <AtlasFeature>();

            foreach (KeyValuePair <AtlasFeatureTuple, AtlasConnection> con in this.connections)
            {
                if (con.Key.ParentFeature == parent)
                {
                    features.Add(con.Key.ChildFeature);
                }
            }

            return(features.ToArray());
            //TODO Return all the children nodes of the specified feature.
            //throw new NotImplementedException("Method not implemented");
        }
예제 #13
0
        public bool RemoveFeature(AtlasFeature toRemove)
        {
            if (!features.ContainsKey(toRemove.Name))
            {
                return(false);
            }

            foreach (AtlasConnection con in Connections)
            {
                if (con.Parent.Equals(toRemove))
                {
                    con.Child.MultipleParentFlag--;
                    connections.Remove(new AtlasFeatureTuple(con.Parent, con.Child));
                }
                else if (con.Child.Equals(toRemove))
                {
                    connections.Remove(new AtlasFeatureTuple(con.Parent, con.Child));
                }
            }

            return(features.Remove(toRemove.Name));
        }
예제 #14
0
        public void WriteXml(XmlWriter writer)
        {
            string content = "";

            foreach (IConstraintMember member in Constraints)
            {
                if (!member.Equals(Constraints.First()))
                {
                    content += " ";
                }

                if (member.GetType().Equals(typeof(AtlasFeature)))
                {
                    AtlasFeature feature = (AtlasFeature)member;
                    content += feature.Name;
                }
                else
                {
                    AtlasConstraintOperator oper = (AtlasConstraintOperator)member;
                    content += ((int)oper.Type).ToString();
                }
            }
            writer.WriteAttributeString("Content", content);
        }
예제 #15
0
 internal AtlasFeatureTuple(AtlasFeature parent, AtlasFeature child)
 {
     this.parent = parent;
     this.child  = child;
 }
예제 #16
0
 public AtlasConnection(AtlasFeature parent, AtlasFeature child, AtlasConnectionType type)
 {
     this.parent = parent;
     this.child  = child;
     this.type   = type;
 }
예제 #17
0
 public bool RemoveSubTree(AtlasFeature toRemove)
 {
     //TODO Remove the subtree that has toRemove as its root.
     throw new NotImplementedException("Method not implemented");
 }
예제 #18
0
 public void AddConnection(AtlasFeature parent, AtlasFeature child, AtlasConnectionType type)
 {
     AddConnection(new AtlasConnection(parent, child, type));
 }
예제 #19
0
 public void RemoveConnection(AtlasFeature parent, AtlasFeature child)
 {
     RemoveConnection(new AtlasConnection(parent, child, 0));
 }
예제 #20
0
        public AtlasFeatureModel(AtlasFeature rootFeature)
        {
            ClearModel();

            CreateFeatureModel(rootFeature);
        }