/// <summary>
        /// Get taxa that belongs to specified organism groups.
        /// </summary>
        /// <param name="userContext">User context.</param>
        /// <param name="organismGroups">Organism groups.</param>
        /// <returns>Taxa that belongs to specified organism groups.</returns>
        public virtual TaxonList GetTaxa(IUserContext userContext,
                                         OrganismGroupList organismGroups)
        {
            IFactor factor;
            ISpeciesFactFieldSearchCriteria fieldSearchCriteria;
            ISpeciesFactSearchCriteria      searchCriteria;
            TaxonList taxa;

            taxa = null;
            if (organismGroups.IsNotEmpty())
            {
                searchCriteria = new SpeciesFactSearchCriteria();
                factor         = CoreData.FactorManager.GetFactor(userContext,
                                                                  FactorId.Redlist_OrganismLabel1);
                searchCriteria.Add(factor);
                searchCriteria.IncludeNotValidHosts = false;
                searchCriteria.IncludeNotValidTaxa  = false;
                searchCriteria.Add(CoreData.FactorManager.GetDefaultIndividualCategory(userContext));
                searchCriteria.FieldLogicalOperator = LogicalOperator.Or;
                foreach (IOrganismGroup organismGroup in organismGroups)
                {
                    fieldSearchCriteria             = new SpeciesFactFieldSearchCriteria();
                    fieldSearchCriteria.FactorField = factor.DataType.Field1;
                    fieldSearchCriteria.Operator    = CompareOperator.Equal;
                    fieldSearchCriteria.AddValue(organismGroup.Id);
                    searchCriteria.Add(fieldSearchCriteria);
                }

                taxa = DataSource.GetTaxa(userContext, searchCriteria);
            }

            return(taxa);
        }
        /// <summary>
        /// Set organism groups for specified locale.
        /// </summary>
        /// <param name="organismGroups">Organism groups.</param>
        /// <param name="locale">Currently used locale.</param>
        /// <param name='organismGroupType'>Type of organism groups.</param>
        protected virtual void SetOrganismGroups(OrganismGroupList organismGroups,
                                                 ILocale locale,
                                                 OrganismGroupType organismGroupType)
        {
            String cacheKey;

            cacheKey = locale.ISOCode + "#" + organismGroupType;
            OrganismGroups[cacheKey] = organismGroups;
        }
示例#3
0
        /// <summary>
        /// Set organism groups for specified locale.
        /// </summary>
        /// <param name="organismGroups">Organism groups.</param>
        /// <param name="locale">Currently used locale.</param>
        /// <param name='organismGroupType'>Type of organism groups.</param>
        protected override void SetOrganismGroups(OrganismGroupList organismGroups,
                                                  ILocale locale,
                                                  OrganismGroupType organismGroupType)
        {
            String cacheKey;

            cacheKey = locale.ISOCode + "#" + organismGroupType;
            lock (OrganismGroups)
            {
                OrganismGroups[cacheKey] = organismGroups;
            }
        }
        /// <summary>
        /// Get organism groups for specified locale.
        /// </summary>
        /// <param name="locale">Currently used locale.</param>
        /// <param name='organismGroupType'>Type of organism groups.</param>
        /// <returns>Organism groups for specified locale.</returns>
        protected virtual OrganismGroupList GetOrganismGroups(ILocale locale,
                                                              OrganismGroupType organismGroupType)
        {
            OrganismGroupList organismGroups = null;
            String            cacheKey;

            cacheKey = locale.ISOCode + "#" + organismGroupType;
            if (OrganismGroups.ContainsKey(cacheKey))
            {
                organismGroups = (OrganismGroupList)(OrganismGroups[cacheKey]);
            }

            return(organismGroups);
        }
        /// <summary>
        /// Get information about organism groups of specified type.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name='organismGroupType'>Type of organism groups.</param>
        /// <returns>Information about organism groups of specified type.</returns>
        public virtual OrganismGroupList GetOrganismGroups(IUserContext userContext,
                                                           OrganismGroupType organismGroupType)
        {
            IOrganismGroup    organismGroup;
            OrganismGroupList organismGroups;

            organismGroups = new OrganismGroupList();
            foreach (FactorFieldEnumValue enumValue in GetFactorFieldEnum(userContext, FactorFieldEnumId.OrganismGroup).Values)
            {
                organismGroup             = new OrganismGroup();
                organismGroup.DataContext = enumValue.DataContext;
                organismGroup.Definition  = enumValue.Information;
                // ReSharper disable once PossibleInvalidOperationException
                organismGroup.Id        = enumValue.KeyInt.Value;
                organismGroup.Name      = enumValue.OriginalLabel;
                organismGroup.SortOrder = enumValue.SortOrder;
                organismGroup.Type      = organismGroupType;
                organismGroups.Add(organismGroup);
            }

            organismGroups.Sort();
            return(organismGroups);
        }