Пример #1
0
        /// <summary>
        /// Convert a WebTaxonName array to a TaxonNameList.
        /// </summary>
        /// <param name="webTaxonNames">Web taxon names.</param>
        /// <returns>Taxon names.</returns>
        private static TaxonNameList GetTaxonNames(List <WebTaxonName> webTaxonNames)
        {
            DataFieldList dataFields;
            TaxonName     taxonName;
            TaxonNameList taxonNames = null;

            if (webTaxonNames.IsNotEmpty())
            {
                taxonNames = new TaxonNameList();
                foreach (WebTaxonName webTaxonName in webTaxonNames)
                {
                    dataFields = new DataFieldList(webTaxonName.Taxon.DataFields);
                    taxonName  = new TaxonName(webTaxonName.Id,
                                               webTaxonName.Taxon.Id,
                                               webTaxonName.TaxonNameTypeId,
                                               webTaxonName.TaxonNameUseTypeId,
                                               webTaxonName.Name,
                                               webTaxonName.Author,
                                               webTaxonName.IsRecommended);
                    taxonName.Taxon = new TaxonPrintObs(webTaxonName.Taxon.Id,
                                                        webTaxonName.Taxon.TaxonTypeId,
                                                        webTaxonName.Taxon.SortOrder,
                                                        webTaxonName.Taxon.TaxonInformationType,
                                                        webTaxonName.Taxon.ScientificName,
                                                        webTaxonName.Taxon.Author,
                                                        webTaxonName.Taxon.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));
                    taxonNames.Add(taxonName);
                }
            }
            return(taxonNames);
        }
Пример #2
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);
        }
        /// <summary>
        /// Convert a WebSpeciesObservation to a SpeciesObservation.
        /// </summary>
        /// <param name="webSpeciesObservation">The WebSpeciesObservation.</param>
        /// <returns>The SpeciesObservation.</returns>
        public static SpeciesObservation GetSpeciesObservation(WebSpeciesObservation webSpeciesObservation)
        {
            DataFieldList      dataFields;
            Int32?             accuracy, speciesActivityId;
            SpeciesObservation speciesObservation;

            dataFields = new DataFieldList(webSpeciesObservation.DataFields);
            accuracy   = null;
            if (dataFields.IsValueSpecified(SpeciesObservation.ACCURACY_DATA_FIELD))
            {
                accuracy = dataFields.GetInt32(SpeciesObservation.ACCURACY_DATA_FIELD);
            }

            speciesActivityId = null;
            if (dataFields.IsValueSpecified(SpeciesObservation.SPECIES_ACTIVITY_ID_DATA_FIELD))
            {
                speciesActivityId = dataFields.GetInt32(SpeciesObservation.SPECIES_ACTIVITY_ID_DATA_FIELD);
            }

            speciesObservation = new SpeciesObservation(webSpeciesObservation.Id,
                                                        dataFields.GetString(SpeciesObservation.ORGANISM_GROUP_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.SCIENTIFIC_NAME_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.TAXON_UNCERTAINTY_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.COMMON_NAME_DATA_FIELD),
                                                        dataFields.GetDateTime(SpeciesObservation.START_DATE_DATA_FIELD),
                                                        dataFields.GetDateTime(SpeciesObservation.END_DATE_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.LOCALITY_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.PARISH_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.MUNICIPALITY_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.COUNTY_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.PROVINCE_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.NORTH_COORDINATE_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.EAST_COORDINATE_DATA_FIELD),
                                                        accuracy,
                                                        dataFields.GetString(SpeciesObservation.OBSERVERS_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.ORIGIN_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.QUANTITY_OR_AREA_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.UNIT_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.LIFE_STAGE_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.ACTIVITY_OR_SUBSTRATE_COUNT_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.BIOTOPE_OR_SUBSTRATE_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.COMMENT_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.DETERMINATOR_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.COLLECTION_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.ACCESSION_ID_DATA_FIELD),
                                                        dataFields.GetBoolean(SpeciesObservation.NOT_REDISCOVERED_DATA_FIELD),
                                                        dataFields.GetBoolean(SpeciesObservation.NEVER_FOUND_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.DATABASE_OBSERVATION_ID_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.DATABASE_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.TAXON_SORT_ORDER_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.TAXON_ID_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.ORGANISM_GROUP_SORT_ORDER_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.PROTECTION_LEVEL_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.SCI_CODE_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.SCI_NAME_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.REDLIST_CATEGORY_DATA_FIELD),
                                                        dataFields.GetString(SpeciesObservation.GUID_DATA_FIELD),
                                                        dataFields.GetInt32(SpeciesObservation.DATABASE_ID_DATA_FIELD),
                                                        dataFields.GetDateTime(SpeciesObservation.REPORTED_DATE_DATA_FIELD),
                                                        speciesActivityId,
                                                        dataFields.GetDateTime(SpeciesObservation.MODIFIED_DATA_FIELD));
            return(speciesObservation);
        }