예제 #1
0
      public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
      {
         bool includeNode = true;
         List<GlymaNodeReference> parentNodes = new List<GlymaNodeReference>();
         string parentNodesJson = string.Empty;

         if (glymaNode == null)
         {
            throw new ArgumentNullException("glymaNode");
         }

         Guid mapId = (Guid)glymaNode[GlymaEntityFields.MapId];
         Guid nodeId = (Guid)glymaNode[GlymaEntityFields.Id];

         if (nodeId.Equals(Guid.Empty))
         {
            throw new ArgumentException("The node ID is invalid because it has an undefined value.");
         }

         parentNodes = mapRepository.GetParentNodes(mapId, nodeId);
         if (parentNodes.Count > 0)
         {
            parentNodes.Sort(new NodeComparer());
            JavaScriptSerializer serialiser = new JavaScriptSerializer();
            parentNodesJson = serialiser.Serialize(parentNodes);
         }
         glymaNode[GlymaEntityFields.ParentNodes] = parentNodesJson;

         return includeNode;
      }
예제 #2
0
        public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
        {
            bool includeNode = true;

            if (glymaNode == null)
            {
                throw new ArgumentNullException("glymaNode");
            }

            string nodeType = (string)glymaNode[GlymaEntityFields.NodeType];

            if (nodeType.Equals(GlymaNodeTypes.Question, StringComparison.OrdinalIgnoreCase))
            {
                string nodeName = (string)glymaNode[GlymaEntityFields.Name];
                if (!string.IsNullOrEmpty(nodeName))
                {
                    foreach (string specifiedQuestion in SpecifiedQuestions)
                    {
                        if (nodeName.Equals(specifiedQuestion, StringComparison.OrdinalIgnoreCase))
                        {
                            includeNode = false;
                            break;
                        }
                    }
                }
                else
                {
                    includeNode = false;
                }
            }

            return(includeNode);
        }
예제 #3
0
        public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
        {
            bool includeNode = true;
            List <GlymaNodeReference> parentNodes = new List <GlymaNodeReference>();
            string parentNodesJson = string.Empty;

            if (glymaNode == null)
            {
                throw new ArgumentNullException("glymaNode");
            }

            Guid mapId  = (Guid)glymaNode[GlymaEntityFields.MapId];
            Guid nodeId = (Guid)glymaNode[GlymaEntityFields.Id];

            if (nodeId.Equals(Guid.Empty))
            {
                throw new ArgumentException("The node ID is invalid because it has an undefined value.");
            }

            parentNodes = mapRepository.GetParentNodes(mapId, nodeId);
            if (parentNodes.Count > 0)
            {
                parentNodes.Sort(new NodeComparer());
                JavaScriptSerializer serialiser = new JavaScriptSerializer();
                parentNodesJson = serialiser.Serialize(parentNodes);
            }
            glymaNode[GlymaEntityFields.ParentNodes] = parentNodesJson;

            return(includeNode);
        }
예제 #4
0
        public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
        {
            bool includeNode = true;

            if (glymaNode == null)
            {
               throw new ArgumentNullException("glymaNode");
            }

            string nodeType = (string)glymaNode[GlymaEntityFields.NodeType];
            if (nodeType.Equals(GlymaNodeTypes.Question, StringComparison.OrdinalIgnoreCase))
            {
                string nodeName = (string)glymaNode[GlymaEntityFields.Name];
                if (!string.IsNullOrEmpty(nodeName))
                {
                  foreach (string specifiedQuestion in SpecifiedQuestions)
                  {

                        if (nodeName.Equals(specifiedQuestion, StringComparison.OrdinalIgnoreCase))
                        {
                           includeNode = false;
                           break;
                        }
                  }
                }
                else
                {
                    includeNode = false;
                }
            }

            return includeNode;
        }
예제 #5
0
      public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
      {
         bool includeNode = true;

         if (glymaNode == null)
         {
            throw new ArgumentNullException("glymaNode");
         }

         string nodeType = (string)glymaNode[GlymaEntityFields.NodeType];
         if (nodeType.Equals(GlymaNodeTypes.Question, StringComparison.OrdinalIgnoreCase))
         {
            string nodeName = (string)glymaNode[GlymaEntityFields.Name];
            if (!string.IsNullOrEmpty(nodeName))
            {
               // Apply default logic that excludes nodes that are less than two "words".  The number of words is determined by the number of spaces.
               int wordCount = nodeName.Count(f => f == ' ') + 1;
               if (wordCount <= 2)
               {
                  includeNode = false;
               }
            }
            else
            {
               includeNode = false;
            }
         }

         return includeNode;
      }
예제 #6
0
        public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
        {
            bool includeNode = true;

            if (glymaNode == null)
            {
                throw new ArgumentNullException("glymaNode");
            }

            string nodeType = (string)glymaNode[GlymaEntityFields.NodeType];

            if (nodeType.Equals(GlymaNodeTypes.Question, StringComparison.OrdinalIgnoreCase))
            {
                string nodeName = (string)glymaNode[GlymaEntityFields.Name];
                if (!string.IsNullOrEmpty(nodeName))
                {
                    // Apply default logic that excludes nodes that are less than two "words".  The number of words is determined by the number of spaces.
                    int wordCount = nodeName.Count(f => f == ' ') + 1;
                    if (wordCount <= 2)
                    {
                        includeNode = false;
                    }
                }
                else
                {
                    includeNode = false;
                }
            }

            return(includeNode);
        }
예제 #7
0
        /// <summary>
        /// Conditionally execute all the crawl rules on a Glyma node.
        /// </summary>
        /// <param name="glymaNode">The Glyma node to apply the crawl rules to.</param>
        /// <param name="dbConnection">The database connection to a Glyma repository that can be used to execute the crawl rules.</param>
        /// <returns>Returns true if all the crawl rules were successfully applied to the Glyma node; otherwise, false.</returns>
        /// <remarks>
        /// Execution of the crawl rules is stopped if any of the crawl rules return false.
        /// </remarks>
        public bool Apply(DynamicType glymaNode, IGlymaMapRepository mapRepository)
        {
            bool includeNode = true;

            foreach (INodeCrawlRule crawlRule in this)
            {
                includeNode = crawlRule.Apply(glymaNode, mapRepository);
                if (!includeNode)
                {
                    break;
                }
            }

            return(includeNode);
        }