Exemplo n.º 1
0
        public String GetElementTypeLongName(Taxon taxon)
        {
            string longrank = LongName;

            if (taxon.AvailableName.GetValueOrDefault(false))
            {
                longrank += " Available Name";
            }
            else if (taxon.LiteratureName.GetValueOrDefault(false))
            {
                longrank += " Literature Name";
            }
            return(longrank);
        }
Exemplo n.º 2
0
        public void TestAddTaxa()
        {
            // First find a root to start from...
            var parent = Service.GetTaxon(7009); // Insecta
            Assert.NotNull(parent);
            // Create a new family...
            var taxon = new Taxon { TaxaParentID = parent.TaxaID, Author = "Smith",  YearOfPub = "1990", AvailableName = false, ChgComb = false, Epithet = "Test Taxa", ElemType = "F", KingdomCode = "A", Unplaced = false, Unverified = false, LiteratureName = false, Order = 0 };
            // insert it...
            Service.InsertTaxon(taxon);
            Assert.IsTrue(taxon.TaxaID.HasValue);
            Trace("Inserted TaxaID: {0}", taxon.TaxaID);

            var other = Service.GetTaxon(taxon.TaxaID.Value);
            AssertObjectsEqual(other, taxon, "Rank", "NameStatus", "Parentage", "Shadowed", "RankLong", "KingdomLong", "RankCategory", "DateCreated", "WhoCreated", "DateModified", "WhoModified", "GUID", "ObjectID");
        }
Exemplo n.º 3
0
 protected Func<MapPointSet> TaxonPointFunctionFactory(Taxon t)
 {
     return () => {
         return ExtractSpecimenPointSet(t);
     };
 }
Exemplo n.º 4
0
 protected MapPointSet ExtractSpecimenPointSet(Taxon t)
 {
     var data = Service.GetMaterialForTaxon(t.TaxaID.Value);
     var set = new MatrixMapPointSet(t.TaxaFullName, data, null);
     return set;
 }
Exemplo n.º 5
0
 internal MapPointSet GenerateSpecimenPoints(bool showOptions, Taxon taxon)
 {
     if (showOptions) {
         var frm = new PointSetOptionsWindow(taxon.TaxaFullName, TaxonPointFunctionFactory(taxon));
         frm.Owner = this.FindParentWindow();
         if (frm.ShowDialog() == true) {
             return frm.Points;
         }
     } else {
         return ExtractSpecimenPointSet(taxon);
     }
     return null;
 }
Exemplo n.º 6
0
        internal void AddNewTaxonAllRanks(TaxonViewModel parent)
        {
            var frm = new SelectRankWindow();
            frm.Owner = this.FindParentWindow();
            frm.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            if (frm.ShowDialog() == true) {
                var rank = frm.SelectedRank;
                if (rank != null) {

                    var t = new Taxon() { TaxaID = GetNewTaxonID(), TaxaParentID = 0, Rank = rank.Code, ElemType = rank.Code, KingdomCode = rank.KingdomCode };

                    TaxonViewModel viewModel = new TaxonViewModel(parent, t, GenerateTaxonDisplayLabel);

                    viewModel.Author = "";
                    viewModel.YearOfPub = "";
                    viewModel.Epithet = "";
                    parent.IsExpanded = true;

                    try {
                        parent.Children.Add(viewModel);
                        // Move to the top of the list, until it is saved...
                        parent.Children.Move(parent.Children.IndexOf(viewModel), 0);
                        viewModel.IsSelected = true;
                        RenameTaxon(viewModel);
                        RegisterPendingChange(new InsertTaxonDatabaseCommand(viewModel), this);
                    } catch (Exception ex) {
                        ErrorMessage.Show(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 7
0
        internal TaxonViewModel AddNewTaxon(TaxonViewModel parent, string elemType, TaxonViewModelAction action, bool startRename = true, bool select = true)
        {
            // TODO: check permissions...

            Taxon t = new Taxon();
            t.TaxaParentID = parent.TaxaID.Value;
            t.TaxaID = GetNewTaxonID();
            TaxonViewModel viewModel = new TaxonViewModel(parent, t, GenerateTaxonDisplayLabel);

            viewModel.ElemType = elemType;
            viewModel.KingdomCode = parent.KingdomCode;
            viewModel.Author = "";
            viewModel.YearOfPub = "";
            viewModel.Epithet = "";
            parent.IsExpanded = true;

            try {
                if (action != null) {
                    action(viewModel);
                }

                parent.Children.Add(viewModel);
                // Move to the top of the list, until it is saved...
                parent.Children.Move(parent.Children.IndexOf(viewModel), 0);
                if (select) {
                    viewModel.IsSelected = true;
                }

                if (startRename) {
                    RenameTaxon(viewModel);
                }

                RegisterPendingChange(new InsertTaxonDatabaseCommand(viewModel), this);

            } catch (Exception ex) {
                ErrorMessage.Show(ex.Message);
            }
            return viewModel;
        }
Exemplo n.º 8
0
 private void AddMaterialRowsForTaxon(DataMatrix results, Taxon taxon)
 {
     var ids = XMLIOService.GetMaterialForTaxon(taxon.TaxaID.Value);
     foreach (XMLIOMaterialID id in ids) {
         var links = SupportService.GetMultimediaItems(TraitCategoryType.Material.ToString(), id.MaterialID);
         foreach (MultimediaLink link in links) {
             AddTaxonRow(results, taxon, link, "Material", id.MaterialID);
         }
     }
 }
Exemplo n.º 9
0
        private void AddTaxonRow(DataMatrix results, Taxon taxa, MultimediaLink link, string multimediaSource = "Taxon", int? materialId= null)
        {
            // Filter the rows...
            bool addRow = true;
            if (!string.IsNullOrWhiteSpace(_extensionFilter)) {
                addRow = _extensionFilter.Equals(link.Extension, StringComparison.CurrentCultureIgnoreCase);
            }

            if (addRow && !string.IsNullOrWhiteSpace(_typeFilter)) {
                addRow = _typeFilter.Equals(link.MultimediaType, StringComparison.CurrentCultureIgnoreCase);
            }

            if (addRow) {
                var row = results.AddRow();
                row[0] = link.MultimediaID;
                row[1] = taxa.TaxaID.Value;
                row[2] = link;
                row[3] = taxa.TaxaFullName;
                row[4] = taxa.Rank;
                row[5] = link.Name;
                row[6] = link.Extension;
                row[7] = link.MultimediaType;
                row[8] = link.SizeInBytes;
                row[9] = multimediaSource;
                row[10] = materialId;
            }
        }
Exemplo n.º 10
0
 public void UpdateTaxon(Taxon taxon)
 {
     StoredProcUpdate("spBiotaUpdate",
         _P("intBiotaID", taxon.TaxaID),
         _P("vchrEpithet", taxon.Epithet, ""),
         _P("vchrAuthor", taxon.Author, ""),
         _P("vchrYearOfPub", taxon.YearOfPub, ""),
         _P("bitChgComb", taxon.ChgComb, 0),
         _P("chrElemType", taxon.ElemType, ""),
         _P("bitUnplaced", taxon.Unplaced, 0),
         _P("bitUnverified", taxon.Unverified, 0),
         _P("vchrRank", taxon.Rank, ""),
         _P("intOrder", taxon.Order, 0),
         _P("chrKingdomCode", taxon.KingdomCode, "A"),
         _P("bitAvailableName", taxon.AvailableName, ""),
         _P("bitLiteratureName", taxon.LiteratureName, ""),
         _P("vchrAvailableNameStatus", taxon.NameStatus, ""));
 }
Exemplo n.º 11
0
        public DataValidationResult ValidateTaxonMove(Taxon source, Taxon dest)
        {
            var map = GetTaxonRankMap();

            // Can only really validate if the ranks of the source and target are 'known'
            if (map.ContainsKey(RankKey(dest)) && map.ContainsKey(RankKey(source))) {
                TaxonRank destrank = map[RankKey(dest)];
                TaxonRank srcrank = map[RankKey(source)];
                if (!IsValidChild(srcrank, destrank)) {
                    return new DataValidationResult(false, String.Format("{0} is not a valid child of {1}", srcrank.LongName, destrank.LongName));
                }
            }

            return new DataValidationResult(true);
        }
Exemplo n.º 12
0
        public void InsertTaxon(Taxon taxon)
        {
            var retval = ReturnParam("newTaxonId");
            StoredProcUpdate("spBiotaInsert",
                _P("intParentID", taxon.TaxaParentID),
                _P("vchrEpithet", taxon.Epithet),
                _P("vchrAuthor", taxon.Author, ""),
                _P("vchrYearOfPub", taxon.YearOfPub, ""),
                _P("bitChgComb", taxon.ChgComb, 0),
                _P("chrElemType", taxon.ElemType, ""),
                _P("bitUnplaced", taxon.Unplaced, 0),
                _P("vchrRank", taxon.Rank, ""),
                _P("intOrder", taxon.Order, 0),
                _P("bitUnverified", taxon.Unverified, 0),
                _P("chrKingdomCode", taxon.KingdomCode, "A"),
                _P("bitAvailableName", taxon.AvailableName, 0),
                _P("bitLiteratureName", taxon.LiteratureName, ""),
                _P("vchrAvailableNameStatus", taxon.NameStatus, ""),
                retval);

            if (retval.Value != null) {
                taxon.TaxaID = (Int32) retval.Value;
            }
        }
Exemplo n.º 13
0
 public TaxonRank GetTaxonRank(Taxon taxon)
 {
     // If there is no kingdom code, assume Animalia
     var kingdomCode = taxon.KingdomCode;
     if (String.IsNullOrEmpty(kingdomCode)) {
         kingdomCode = "A";
     }
     return GetTaxonRank(taxon.ElemType, kingdomCode);
 }
Exemplo n.º 14
0
 private string RankKey(Taxon taxon)
 {
     return RankKey(taxon.KingdomCode == null ? "A" : taxon.KingdomCode, taxon.ElemType);
 }
Exemplo n.º 15
0
 public TaxonViewModel(HierarchicalViewModelBase parent, Taxon taxon, TaxonLabelGenerator labelGenerator, bool isRoot = false)
     : base()
 {
     this.Parent = parent;
     this.Taxon = taxon;
     this.IsChanged = false;
     this.DataChanged += new DataChangedHandler(TaxonViewModel_DataChanged);
     _labelGenerator = labelGenerator;
     this.IsRootNode = isRoot;
     TaxonLabel = GenerateLabel();
 }
Exemplo n.º 16
0
 public String GetElementTypeLongName(Taxon taxon)
 {
     string longrank = LongName;
     if (taxon.AvailableName.GetValueOrDefault(false)) {
         longrank += " Available Name";
     } else if (taxon.LiteratureName.GetValueOrDefault(false)) {
         longrank += " Literature Name";
     }
     return longrank;
 }
Exemplo n.º 17
0
 public UpdateTaxonCommand(Taxon taxon)
 {
     this.Taxon = taxon;
     _isNew = taxon.TaxaID.Value < 0;
 }
Exemplo n.º 18
0
        public ObservableCollection<HierarchicalViewModelBase> LoadTaxonViewModel()
        {
            using (new OverrideCursor(Cursors.Wait)) {
                List<Taxon> taxa = Service.GetTopLevelTaxa();

                Taxon root = new Taxon();
                root.TaxaID = 0;
                root.TaxaParentID = -1;
                root.Epithet = _R("TaxonExplorer.explorer.root");

                TaxonViewModel rootNode = new TaxonViewModel(null, root, GenerateTaxonDisplayLabel, true);

                taxa.ForEach((taxon) => {
                    TaxonViewModel item = new TaxonViewModel(rootNode, taxon, GenerateTaxonDisplayLabel);
                    if (item.NumChildren > 0) {
                        item.LazyLoadChildren += new HierarchicalViewModelAction(item_LazyLoadChildren);
                        item.Children.Add(new ViewModelPlaceholder(_R("TaxonExplorer.explorer.loading", item.Epithet)));
                    }
                    rootNode.Children.Add(item);
                });

                ObservableCollection<HierarchicalViewModelBase> model = new ObservableCollection<HierarchicalViewModelBase>();
                model.Add(rootNode);
                rootNode.IsExpanded = true;
                return model;
            }
        }
Exemplo n.º 19
0
 public UpdateBiotaPermissions(int groupId, int userId, PERMISSION_MASK mask, Taxon taxon)
 {
     this.GroupID = groupId;
     this.UserID = userId;
     this.Mask = mask;
     this.Taxon = taxon;
 }
Exemplo n.º 20
0
 public TaxonReferencesReport(User user, Taxon taxon)
     : base(user)
 {
     Taxon = taxon;
 }