예제 #1
0
 /// <summary>
 /// Set factor update modes for specified locale.
 /// </summary>
 /// <param name="factorUpdateModes">Factor update modes.</param>
 /// <param name="locale">Locale.</param>
 protected override void SetFactorUpdateModes(FactorUpdateModeList factorUpdateModes,
                                              ILocale locale)
 {
     lock (FactorUpdateModes)
     {
         FactorUpdateModes[locale.ISOCode] = factorUpdateModes;
     }
 }
        /// <summary>
        /// Get factor update modes for specified locale.
        /// </summary>
        /// <param name="locale">Currently used locale.</param>
        /// <returns>Factor update modes for specified locale.</returns>
        protected virtual FactorUpdateModeList GetFactorUpdateModes(ILocale locale)
        {
            FactorUpdateModeList factorUpdateModes = null;

            if (FactorUpdateModes.ContainsKey(locale.ISOCode))
            {
                factorUpdateModes = (FactorUpdateModeList)(FactorUpdateModes[locale.ISOCode]);
            }

            return(factorUpdateModes);
        }
예제 #3
0
        /// <summary>
        /// Get factor update modes for specified locale.
        /// </summary>
        /// <param name="locale">Locale.</param>
        /// <returns>Factor update modes for specified locale.</returns>
        protected override FactorUpdateModeList GetFactorUpdateModes(ILocale locale)
        {
            FactorUpdateModeList factorUpdateModes = null;

            lock (FactorUpdateModes)
            {
                if (FactorUpdateModes.ContainsKey(locale.ISOCode))
                {
                    factorUpdateModes = (FactorUpdateModeList)(FactorUpdateModes[locale.ISOCode]);
                }
            }
            return(factorUpdateModes);
        }
        /// <summary>
        /// Convert a list of WebFactorUpdateMode instances
        /// to a FactorUpdateModesList.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webFactorUpdateModes">List of WebFactorUpdateMode instances.</param>
        /// <returns>Factor update modes.</returns>
        private FactorUpdateModeList GetFactorUpdateModes(IUserContext userContext,
                                                          List <WebFactorUpdateMode> webFactorUpdateModes)
        {
            FactorUpdateModeList factorUpdateModes;

            factorUpdateModes = null;
            if (webFactorUpdateModes.IsNotEmpty())
            {
                factorUpdateModes = new FactorUpdateModeList();
                foreach (WebFactorUpdateMode webFactorUpdateMode in webFactorUpdateModes)
                {
                    factorUpdateModes.Add(GetFactorUpdateMode(userContext, webFactorUpdateMode));
                }

                factorUpdateModes.Sort();
            }

            return(factorUpdateModes);
        }
        /// <summary>
        /// Convert a list of WebFactor instances
        /// to a FactorList.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webFactors">List of WebFactor instances.</param>
        /// <returns>Factors.</returns>
        private FactorList GetFactors(IUserContext userContext, List <WebFactor> webFactors)
        {
            FactorList           factors;
            FactorDataTypeList   factorDataTypes   = CoreData.FactorManager.GetFactorDataTypes(userContext);
            FactorOriginList     factorOrigins     = CoreData.FactorManager.GetFactorOrigins(userContext);
            FactorUpdateModeList factorUpdateModes = CoreData.FactorManager.GetFactorUpdateModes(userContext);

            factors = null;
            if (webFactors.IsNotEmpty())
            {
                factors = new FactorList();
                foreach (WebFactor webFactor in webFactors)
                {
                    factors.Add(GetFactor(userContext, webFactor, factorDataTypes, factorOrigins, factorUpdateModes));
                }

                factors.Sort();
            }

            return(factors);
        }
 /// <summary>
 /// Set factor update modes for specified locale.
 /// </summary>
 /// <param name="factorUpdateModes">Factor update modes.</param>
 /// <param name="locale">Locale.</param>
 protected virtual void SetFactorUpdateModes(FactorUpdateModeList factorUpdateModes,
                                             ILocale locale)
 {
     FactorUpdateModes[locale.ISOCode] = factorUpdateModes;
 }
        /// <summary>
        /// Convert a WebFactor instance into
        /// an IFactor instance.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webFactorTree">A WebFactorTreeNode instance.</param>
        /// <param name="factorTreeNodes">
        /// All factor tree nodes that have been created so far.
        /// This parameter is used to avoid duplication of
        /// factor tree nodes (factor tree nodes with same factor attached to it)
        /// if the same factor appears more than once in the tree.
        /// </param>
        /// <param name="factorDataTypes">List of factor data types.</param>
        /// <param name="factorOrigins">List of factor origins.</param>
        /// <param name="factorUpdateModes">List of factor update modes.</param>
        /// <returns>An IFactorTreeNode instance.</returns>
        private IFactorTreeNode GetFactorTree(IUserContext userContext, WebFactorTreeNode webFactorTree, Hashtable factorTreeNodes, FactorDataTypeList factorDataTypes, FactorOriginList factorOrigins, FactorUpdateModeList factorUpdateModes)
        {
            IFactorTreeNode child, factorTree;

            if (factorTreeNodes.ContainsKey(webFactorTree.Factor.Id))
            {
                factorTree = (IFactorTreeNode)factorTreeNodes[webFactorTree.Factor.Id];
            }
            else
            {
                factorTree = new FactorTreeNode
                {
                    DataContext = GetDataContext(userContext),
                    Factor      = GetFactor(userContext, webFactorTree.Factor, factorDataTypes, factorOrigins, factorUpdateModes),
                    Id          = webFactorTree.Id
                };
                if (webFactorTree.Children.IsNotEmpty())
                {
                    factorTree.Children = new FactorTreeNodeList();
                    foreach (WebFactorTreeNode webChild in webFactorTree.Children)
                    {
                        child = GetFactorTree(userContext, webChild, factorTreeNodes, factorDataTypes, factorOrigins, factorUpdateModes);
                        if (child.Parents.IsNull())
                        {
                            child.Parents = new FactorTreeNodeList();
                        }

                        child.Parents.Add(factorTree);
                        factorTree.Children.Add(child);
                    }
                }

                factorTreeNodes.Add(webFactorTree.Factor.Id, factorTree);
            }

            return(factorTree);
        }
        /// <summary>
        /// Convert a WebFactor instance into
        /// an IFactor instance.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webFactor">A WebFactor instance.</param>
        /// <param name="factorDataTypes">List of factor data types.</param>
        /// <param name="factorOrigins">List of factor origins.</param>
        /// <param name="factorUpdateModes">List of factor update modes.</param>
        /// <returns>An IFactor instance.</returns>
        private IFactor GetFactor(IUserContext userContext, WebFactor webFactor, FactorDataTypeList factorDataTypes, FactorOriginList factorOrigins, FactorUpdateModeList factorUpdateModes)
        {
            IFactor factor = new Factor
            {
                DataContext = GetDataContext(userContext),
                Id          = webFactor.Id,
                DefaultHostParentTaxonId = webFactor.DefaultHostParentTaxonId,
                DataType    = webFactor.IsDataTypeIdSpecified ? factorDataTypes.Get(webFactor.DataTypeId) : null,
                Origin      = factorOrigins.Get(webFactor.OriginId),
                UpdateMode  = factorUpdateModes.Get(webFactor.UpdateModeId),
                HostLabel   = webFactor.HostLabel,
                Information = webFactor.Information,
                IsLeaf      = webFactor.IsLeaf,
                IsPeriodic  = webFactor.IsPeriodic,
                IsPublic    = webFactor.IsPublic,
                IsTaxonomic = webFactor.IsTaxonomic,
                Label       = webFactor.Label,
                Name        = webFactor.Name,
                SortOrder   = webFactor.SortOrder
            };

            return(factor);
        }