public void CreateTaxon()
        {
            WebTaxon taxon, refTaxon, taxon2;

            refTaxon = GetReferenceTaxon();

            taxon = new WebTaxon {
                CreatedBy     = Settings.Default.TestUserId,
                ValidFromDate = new DateTime(1763, 02, 08),
                ValidToDate   = new DateTime(2447, 08, 01)
            };


            using (IWebServiceTransaction transaction = new WebServiceTransaction(GetClientInformation(), WebServiceProxy.TaxonService))
            {
                // We now create the taxon and complete it with Id and GUID from DB
                refTaxon = WebServiceProxy.TaxonService.CreateTaxon(GetClientInformation(), refTaxon, null);
                // We now create the taxon and complete it with Id and GUID from DB
                taxon = WebServiceProxy.TaxonService.CreateTaxon(GetClientInformation(), taxon, null);
                Assert.IsNotNull(taxon);
                Assert.IsTrue(taxon.Id > 0);
                Assert.AreEqual(refTaxon.CreatedBy, taxon.CreatedBy);
                Assert.IsNotNull(taxon.CreatedDate);
                Assert.IsTrue(!string.IsNullOrEmpty(taxon.Guid));
                Assert.AreEqual(refTaxon.ValidFromDate, taxon.ValidFromDate);
                Assert.AreEqual(refTaxon.ValidToDate, taxon.ValidToDate);
            }

            // Create another taxon with different data..TODO Include test for ParentTaxa, ChildTaxa and TaxonNames when they exsit...
            taxon2 = new WebTaxon()
            {
                CreatedBy     = Settings.Default.TestUserId,
                CreatedDate   = DateTime.Now,
                ValidFromDate = new DateTime(1763, 02, 08),
                ValidToDate   = new DateTime(2447, 08, 01)
            };


            using (IWebServiceTransaction transaction = new WebServiceTransaction(GetClientInformation(), WebServiceProxy.TaxonService))
            {
                // We now create the taxon and complete it with Id and GUID from DB
                WebTaxonName        taxonName     = GetReferenceTaxonName(taxon.Id);
                WebTaxonName        taxonName2    = GetReferenceTaxonName(taxon.Id);
                List <WebTaxonName> taxonNameList = new List <WebTaxonName>();
                taxonNameList.Add(taxonName);
                taxonNameList.Add(taxonName2);
                // taxon2.TaxonNames = taxonNameList;


                taxon2 = WebServiceProxy.TaxonService.CreateTaxon(GetClientInformation(), taxon2, null);
                Assert.IsNotNull(taxon2);
                Assert.IsTrue(taxon2.Id > 0);
                Assert.IsFalse(taxon.Id == taxon2.Id);
                Assert.AreEqual(refTaxon.CreatedBy, taxon2.CreatedBy);
                Assert.IsNotNull(taxon2.CreatedDate);
                Assert.IsTrue(!string.IsNullOrEmpty(taxon2.Guid));
                Assert.AreEqual(refTaxon.ValidFromDate, taxon2.ValidFromDate);
                Assert.AreEqual(refTaxon.ValidToDate, taxon2.ValidToDate);
            }
        }
コード例 #2
0
 /// <summary>
 /// Update taxon object.
 /// </summary>
 /// <param name="userContext">User context.</param>
 /// <param name="taxon">Taxon.</param>
 /// <param name="webTaxon">Web taxon.</param>
 private void UpdateTaxon(IUserContext userContext,
                          ITaxon taxon,
                          WebTaxon webTaxon)
 {
     taxon.AlertStatus             = CoreData.TaxonManager.GetTaxonAlertStatus(userContext, webTaxon.AlertStatusId);
     taxon.Author                  = webTaxon.Author;
     taxon.Category                = CoreData.TaxonManager.GetTaxonCategory(userContext, webTaxon.CategoryId);
     taxon.ChangeStatus            = CoreData.TaxonManager.GetTaxonChangeStatus(userContext, webTaxon.ChangeStatusId);
     taxon.CommonName              = webTaxon.CommonName;
     taxon.CreatedBy               = webTaxon.CreatedBy;
     taxon.CreatedDate             = webTaxon.CreatedDate;
     taxon.DataContext             = GetDataContext(userContext);
     taxon.Guid                    = webTaxon.Guid;
     taxon.Id                      = webTaxon.Id;
     taxon.IsInRevision            = webTaxon.IsInRevision;
     taxon.IsPublished             = webTaxon.IsPublished;
     taxon.IsValid                 = webTaxon.IsValid;
     taxon.ModifiedBy              = webTaxon.ModifiedBy;
     taxon.ModifiedByPerson        = GetModifiedByPerson(webTaxon); //taxon.GetModifiedByPersonFullname(userContext);
     taxon.ModifiedDate            = webTaxon.ModifiedDate;
     taxon.PartOfConceptDefinition = webTaxon.PartOfConceptDefinition;
     taxon.ScientificName          = webTaxon.ScientificName;
     taxon.SortOrder               = webTaxon.SortOrder;
     taxon.ValidFromDate           = webTaxon.ValidFromDate;
     taxon.ValidToDate             = webTaxon.ValidToDate;
 }
コード例 #3
0
 private WebTaxon GetData(Boolean refresh)
 {
     if (_data.IsNull() || refresh)
     {
         _data = TaxonManagerTest.GetOneTaxon(GetContext());
     }
     return(_data);
 }
コード例 #4
0
 public WebTaxon GetTaxon()
 {
     if (_taxon.IsNull())
     {
         _taxon = TaxonManagerTest.GetOneTaxon(GetContext());
     }
     return(_taxon);
 }
コード例 #5
0
        /// <summary>
        /// Convert a WebTaxon instance to an ITaxon instance.
        /// </summary>
        /// <param name="userContext">User context.</param>
        /// <param name="webTaxon">An WebTaxon object.</param>
        /// <returns>An ITaxon object.</returns>
        private ITaxon GetTaxon(IUserContext userContext,
                                WebTaxon webTaxon)
        {
            ITaxon taxon;

            taxon = new Taxon();
            UpdateTaxon(userContext, taxon, webTaxon);
            return(taxon);
        }
        public void Taxon()
        {
            var value = new WebTaxon()
            {
                Id = 1
            };

            GetObject(true).Taxon = value;
            Assert.AreEqual(GetObject().Taxon, value);
        }
コード例 #7
0
        public void TaxonBefore()
        {
            WebTaxon value = new WebTaxon()
            {
                Id = 1
            };

            GetObject(true).TaxonIdBefore = value.Id;
            Assert.AreEqual(GetObject().TaxonIdBefore, value.Id);
        }
コード例 #8
0
        public void TaxonAfter()
        {
            WebTaxon value = new WebTaxon()
            {
                Id = 1
            };

            GetObject(true).TaxonIdAfter = value.Id;
            Assert.AreEqual(GetObject().TaxonIdAfter, value.Id);
        }
コード例 #9
0
 /// <summary>
 /// Create an TaxonTreeNode instance.
 /// </summary>
 /// <param name="taxon">Taxon.</param>
 public TaxonTreeNode(WebTaxon taxon)
 {
     ChildRelations   = null;
     Children         = null;
     ChildrenCircular = null;
     IsValid          = taxon.IsValid;
     ParentRelations  = null;
     Parents          = null;
     SortOrder        = taxon.SortOrder;
     TaxonId          = taxon.Id;
 }
        public void LoadData()
        {
            WebTaxon taxon;

            using (DataReader dataReader = GetContext().GetTaxonDatabase().GetTaxonById((Int32)(TaxonId.Bear), null, Settings.Default.TestLocaleId))
            {
                taxon = new WebTaxon();
                Assert.IsTrue(dataReader.Read());
                taxon.LoadData(dataReader);
                Assert.AreEqual((Int32)(TaxonId.Bear), taxon.Id);
            }
        }
コード例 #11
0
        /// <summary>
        /// Load data into the WebTaxon instance.
        /// </summary>
        /// <param name='taxon'>Taxon.</param>
        /// <param name='dataReader'>An open data reader.</param>
        public static void LoadData(this WebTaxon taxon,
                                    DataReader dataReader)
        {
            taxon.AlertStatusId = dataReader.GetInt32(TaxonData.ALERT_STATUS);
            taxon.Author        = dataReader.GetString(TaxonData.AUTHOR);
            if (dataReader.IsNotDbNull(TaxonData.CATEGORY))
            {
                taxon.CategoryId = dataReader.GetInt32(TaxonData.CATEGORY);
            }

            taxon.ChangeStatusId = dataReader.GetInt32(TaxonData.CHANGE_STATUS);
            taxon.CommonName     = dataReader.GetString(TaxonData.COMMON_NAME);
            taxon.CreatedBy      = dataReader.GetInt32(TaxonCommon.CREATED_BY);
            taxon.CreatedDate    = dataReader.GetDateTime(TaxonCommon.CREATED_DATE);
            taxon.Guid           = dataReader.GetString(TaxonCommon.GUID);
            taxon.Id             = dataReader.GetInt32(TaxonCommon.ID);
            taxon.IsInRevision   = dataReader.IsNotDbNull(TaxonData.ONGOING_REVISION_ID);
            if (taxon.IsInRevision)
            {
                SetTaxonRevisionId(taxon, dataReader.GetInt32(TaxonData.ONGOING_REVISION_ID));
            }
            taxon.IsPublished = dataReader.GetBoolean(TaxonCommon.IS_PUBLISHED);
            taxon.IsValid     = dataReader.GetBoolean(TaxonData.IS_VALID);
            taxon.ModifiedBy  = dataReader.GetInt32(TaxonCommon.MODIFIED_BY);
            taxon.SetModifiedByPerson(dataReader.GetString(TaxonData.PERSON_NAME));
            taxon.ModifiedDate            = dataReader.GetDateTime(TaxonCommon.MODIFIED_DATE);
            taxon.PartOfConceptDefinition = dataReader.GetString(TaxonData.CONCEPT_DEFINITION_PART);
            taxon.ScientificName          = dataReader.GetString(TaxonData.SCIENTIFIC_NAME);
            if (dataReader.IsNotDbNull(TaxonCommon.SORT_ORDER))
            {
                taxon.SortOrder = dataReader.GetInt32(TaxonCommon.SORT_ORDER);
            }
            taxon.ValidFromDate = dataReader.GetDateTime(TaxonCommon.VALID_FROM_DATE);
            taxon.ValidToDate   = dataReader.GetDateTime(TaxonCommon.VALID_TO_DATE);

            if (taxon.DataFields == null)
            {
                taxon.DataFields = new List <WebDataField>();
            }

            if (dataReader.HasColumn(TaxonPropertiesData.IS_MICROSPECIES))
            {
                taxon.DataFields.Add(new WebDataField
                {
                    Name  = TaxonPropertiesData.IS_MICROSPECIES,
                    Type  = WebDataType.Boolean,
                    Value = dataReader.GetBoolean(TaxonPropertiesData.IS_MICROSPECIES).ToString()
                });
            }
        }
コード例 #12
0
        /// <summary>
        /// Add data to list.
        /// </summary>
        /// <param name='taxon'>Taxon to add.</param>
        /// <returns>The list index at which the value has been added. -1 means has not been added.</returns>
        public int Add(WebTaxon taxon)
        {
            if (taxon.IsNotNull())
            {
                int id = taxon.Id;
                if (!_idHashTable.Contains(id))
                {
                    _idHashTable.Add(id, taxon);
                }

                return(base.Add(taxon));
            }

            return(-1);
        }
        /// <summary>
        /// Creates a taxon.
        /// </summary>
        /// <returns></returns>
        private WebTaxon GetReferenceTaxon()
        {
            WebTaxon refTaxon = new WebTaxon();

            DateTime createdDate   = new DateTime(2004, 01, 20);
            DateTime validFromDate = new DateTime(1763, 02, 08);
            DateTime validToDate   = new DateTime(2447, 08, 01);

            refTaxon.CreatedDate   = createdDate;
            refTaxon.ValidFromDate = validFromDate;
            refTaxon.ValidToDate   = validToDate;
            // Not used when creating a taxon id will be overwritten from DB
            refTaxon.Id = 1;
            return(refTaxon);
        }
コード例 #14
0
        /// <summary>
        /// Set modified by person in WebTaxon.
        /// </summary>
        /// <param name='taxon'>Taxon.</param>
        /// <param name='modifiedByPerson'>Modified by person.</param>
        public static void SetModifiedByPerson(this WebTaxon taxon,
                                               String modifiedByPerson)
        {
            WebDataField dataField;

            // Add modified by person as dynamic property.
            dataField       = new WebDataField();
            dataField.Name  = Settings.Default.WebDataModifiedByPerson;
            dataField.Type  = WebDataType.String;
            dataField.Value = modifiedByPerson;
            if (taxon.DataFields.IsNull())
            {
                taxon.DataFields = new List <WebDataField>();
            }
            taxon.DataFields.Add(dataField);
        }
コード例 #15
0
        /// <summary>
        /// Set Taxon Revision Id in WebTaxon.
        /// </summary>
        /// <param name="taxon">The taxon.</param>
        /// <param name="taxonRevisionId">The taxon revision identifier.</param>
        public static void SetTaxonRevisionId(this WebTaxon taxon, Int32 taxonRevisionId)
        {
            WebDataField dataField;

            // Add taxon revision id property.
            dataField       = new WebDataField();
            dataField.Name  = Settings.Default.WebDataTaxonRevisionId;
            dataField.Type  = WebDataType.Int32;
            dataField.Value = taxonRevisionId.WebToString();
            if (taxon.DataFields.IsNull())
            {
                taxon.DataFields = new List <WebDataField>();
            }

            taxon.DataFields.Add(dataField);
        }
コード例 #16
0
        /// <summary>
        /// Check the data in current object
        /// </summary>
        /// <param name='taxon'>The taxon.</param>
        public static void CheckData(this WebTaxon taxon)
        {
            if (!taxon.IsDataChecked)
            {
                taxon.CheckStrings();
                taxon.IsDataChecked = true;

                if (taxon.ValidFromDate.Equals(DateTime.MinValue))
                {
                    taxon.ValidFromDate = DateTime.Now;
                }

                if (taxon.ValidToDate.Equals(DateTime.MinValue))
                {
                    taxon.ValidToDate = Settings.Default.DefaultValidToDate;
                }
            }
        }
        /// <summary>
        /// Creates a taxon out of predefined data when a text as identifier is set to
        /// differentiate taxon from each other. To be used in test cases when
        /// a list of taxon is needed.
        /// </summary>
        /// <returns>WebTaxon </returns>
        private WebTaxon GetReferenceTaxon(string text)
        {
            WebTaxon refTaxon = new WebTaxon();

            // First we create a taxon
            string   conceptDefinitionPart = "conceptDefinitionPart" + " " + text;
            Int32    createdBy             = Settings.Default.TestUserId;
            DateTime validFromDate         = new DateTime(DateTime.Now.Ticks);
            DateTime validToDate           = new DateTime(2022, 1, 30);

            refTaxon.PartOfConceptDefinition = conceptDefinitionPart;
            refTaxon.CreatedBy     = createdBy;
            refTaxon.ValidFromDate = validFromDate;
            refTaxon.ValidToDate   = validToDate;
            // Not used when creating a taxon id will be overwritten from DB
            refTaxon.Id = 1;

            return(refTaxon);
        }
コード例 #18
0
        /// <summary>
        /// Get Taxon instance with data from WebTaxon instance.
        /// </summary>
        /// <param name="webTaxon">WebTaxon instance with data.</param>
        /// <returns>Taxon instance.</returns>
        private static Taxon GetTaxon(WebTaxon webTaxon)
        {
            DataFieldList dataFields;
            Taxon         taxon;

            dataFields = new DataFieldList(webTaxon.DataFields);
            switch (webTaxon.TaxonInformationType)
            {
            case TaxonInformationType.Basic:
                taxon = new Taxon(webTaxon.Id,
                                  webTaxon.TaxonTypeId,
                                  webTaxon.SortOrder,
                                  webTaxon.TaxonInformationType,
                                  webTaxon.ScientificName,
                                  webTaxon.Author,
                                  webTaxon.CommonName);
                break;

            case TaxonInformationType.PrintObs:
                taxon = new TaxonPrintObs(webTaxon.Id,
                                          webTaxon.TaxonTypeId,
                                          webTaxon.SortOrder,
                                          webTaxon.TaxonInformationType,
                                          webTaxon.ScientificName,
                                          webTaxon.Author,
                                          webTaxon.CommonName,
                                          dataFields.GetString(TaxonPrintObs.PHYLUM_DATA_FIELD),
                                          dataFields.GetString(TaxonPrintObs.CLASS_DATA_FIELD),
                                          dataFields.GetString(TaxonPrintObs.ORDER_DATA_FIELD),
                                          dataFields.GetString(TaxonPrintObs.FAMILY_DATA_FIELD));
                break;

            default:
                throw new Exception("Unknown taxon information type " + webTaxon.TaxonInformationType.ToString() + "!");
            }
            return(taxon);
        }
コード例 #19
0
 /// <summary>
 /// Get name of the person that made the last
 /// modification of this taxon.
 /// </summary>
 /// <param name='taxon'>Taxon.</param>
 /// <returns>Name of the person that made the last modification of this taxon.</returns>
 public static String GetModifiedByPerson(this WebTaxon taxon)
 {
     return(taxon.DataFields.GetString(Settings.Default.WebDataModifiedByPerson));
 }
コード例 #20
0
 public WebDataTest()
 {
     _data = null;
 }
コード例 #21
0
 public WebTaxonTest()
 {
     _taxon = null;
 }