/// <summary>
        /// Get WebFactorTreeSearchCriteria form IFactorTreeSearchCriteria.
        /// </summary>
        /// <param name="searchCriteria">A WebFactorTreeSearchCriteria instance.</param>
        /// <returns></returns>
        private WebFactorTreeSearchCriteria GetFactorTreeSearchCriteria(IFactorTreeSearchCriteria searchCriteria)
        {
            WebFactorTreeSearchCriteria webFactorTreeSearchCriteria = new WebFactorTreeSearchCriteria {
                FactorIds = searchCriteria.FactorIds
            };

            return(webFactorTreeSearchCriteria);
        }
        public void GetFactorTreesBySearchCriteriaExpectsNonPublicFactorTree()
        {
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria {
                FactorIds = new List <int> {
                    1872
                }
            };

            factorTrees = WebServiceProxy.TaxonAttributeService.GetFactorTreesBySearchCriteria(GetClientInformation(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsNotEmpty());
        }
        public static WebFactorTreeNode GetRedlistFactorTreeNode(WebServiceContext context)
        {
            List <Int32>                factorIds;
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria;

            searchCriteria = new WebFactorTreeSearchCriteria();
            factorIds      = new List <Int32>();
            factorIds.Add(REDLIST_FACTOR_ID);
            searchCriteria.RestrictSearchToFactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(context, searchCriteria);
            return(factorTrees[0]);
        }
        public void GetFactorTreesBySearchCriteriaExpectsNoFactorTree()
        {
            SetUserAndApplicationIdentifier("testUserPublic", "8RevNymI&A3rW", ApplicationIdentifier.AnalysisPortal.ToString());

            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria {
                FactorIds = new List <int> {
                    1872
                }
            };

            factorTrees = WebServiceProxy.TaxonAttributeService.GetFactorTreesBySearchCriteria(GetClientInformation(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsEmpty());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get information about factor trees that matches the search criteria.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="searchCriteria">Factor tree information.</param>
        /// <returns>Filtered factor trees.</returns>
        /// <exception cref="ArgumentException">Thrown if factorSearchCriteria is null.</exception>
        public static List <WebFactorTreeNode> GetFactorTreesBySearchCriteria(WebServiceContext context,
                                                                              WebFactorTreeSearchCriteria searchCriteria)
        {
            FactorInformation        factorInformation;
            List <WebFactorTreeNode> factorTrees;
            WebFactorTreeNodeList    factorTreeNodes;
            Boolean getOnlyPublicFactors = !IsUserAuthorizedToReadNonPublicFactors(context);

            // Check arguments.
            searchCriteria.CheckNotNull("searchCriteria");
            searchCriteria.CheckData();

            if (searchCriteria.FactorIds.IsEmpty())
            {
                // Get all factor trees.
                factorTrees = GetFactorTrees(context);
            }
            else
            {
                // Get all factor tree nodes.
                if (context.IsInTransaction())
                {
                    // Get information from database.
                    using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetFactorTrees(getOnlyPublicFactors))
                    {
                        factorInformation = new FactorInformation(context, dataReader);
                    }

                    factorTreeNodes = factorInformation.FactorTreeNodes;
                }
                else
                {
                    factorTreeNodes = GetFactorInformation(context, getOnlyPublicFactors).FactorTreeNodes;
                }

                // Get all factor trees that are requested.
                factorTrees = new List <WebFactorTreeNode>();
                foreach (Int32 factorId in searchCriteria.FactorIds)
                {
                    if (factorTreeNodes.Contains(factorId))
                    {
                        factorTrees.Add(factorTreeNodes.Get(factorId));
                    }
                }
            }

            return(factorTrees);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Get information about factor trees that matches the search criteria.
 /// </summary>
 /// <param name="clientInformation">Information about the client that makes this web service call.</param>
 /// <param name="searchCriteria">Factor tree information.</param>
 /// <returns>Factor trees.</returns>
 public List <WebFactorTreeNode> GetFactorTreesBySearchCriteria(WebClientInformation clientInformation,
                                                                WebFactorTreeSearchCriteria searchCriteria)
 {
     using (WebServiceContext context = GetWebServiceContext(clientInformation))
     {
         try
         {
             return(FactorManager.GetFactorTreesBySearchCriteria(context, searchCriteria));
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }
Ejemplo n.º 7
0
        public void GetFactorTreesByIdsAndSearchCriteria_UserCanReadAllFactors_GetNonPublicFactor_ExpectsFactorTree()
        {
            List <Int32>                factorIds = new List <Int32>();
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria();

            factorIds.Add(1872);

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsNotEmpty());
            Console.WriteLine("factorTrees.Count: " + factorTrees.Count);
            Assert.AreEqual(factorTrees.Count, 1);
            Console.WriteLine("factorTrees[0].Children.Count: " + factorTrees[0].Children.Count);
            Assert.AreEqual(factorTrees[0].Children.Count, 4);
        }
Ejemplo n.º 8
0
        public void GetFactorTreesByIdsAndSearchCriteria_UserCanReadOnlyPublicFactors_GetNonPublicFactor_ExpectsNoFactorTree()
        {
            SetUserAndApplicationIdentifier("testUserPublic", ApplicationIdentifier.EVA.ToString());

            List <Int32>                factorIds = new List <Int32>();
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria();

            factorIds.Add(1872);

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsEmpty());
            Console.WriteLine("factorTrees.Count: " + factorTrees.Count);
            Assert.AreEqual(factorTrees.Count, 0);
        }
Ejemplo n.º 9
0
        public void GetFactorTreesByIdsAndSearchCriteria()
        {
            List <Int32>                factorIds = new List <Int32>();
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria();

            factorIds.Add(661);

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsNotEmpty());

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.AreEqual(factorTrees.Count, 1);
            Assert.AreEqual(factorTrees[0].Children.Count, 9);
        }
        public void GetFactorTreesBySearchCriteria()
        {
            List <Int32>                factorIds;
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria;

            factorIds = new List <Int32>();
            factorIds.Add(LANDSCAPES_FACTOR_ID);
            searchCriteria = new WebFactorTreeSearchCriteria();

            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsNotEmpty());

            searchCriteria.RestrictSearchToFactorIds = factorIds;

            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.AreEqual(factorTrees.Count, 1);
            Assert.AreEqual(factorTrees[0].Children.Count, 9);
        }
 /// <summary>
 /// Get all factor trees that matches search criteria.
 /// </summary>
 /// <param name="clientInformation">Information about the client that makes this web service call.</param>
 /// <param name="searchCriteria">The factor search criteria.</param>
 /// <returns>Factor trees.</returns>
 public List <WebFactorTreeNode> GetFactorTreesBySearchCriteria(WebClientInformation clientInformation, WebFactorTreeSearchCriteria searchCriteria)
 {
     using (ClientProxy client = new ClientProxy(this, 5))
     {
         return(client.Client.GetFactorTreesBySearchCriteria(clientInformation, searchCriteria));
     }
 }