Exemple #1
0
        private IDirectAccessIterator <IdentificationUnit> _identificationUnitIterator;//Dieser iteriert im Gegensatz zu den anderen KLassen in Datamanagement nur auf dem TopLevel


        #endregion

        #region Constructor

        internal IdentificationUnits(CollectionSpecimen cs)
        {
            if (cs != null)
            {
                this._collectionSpecimen    = cs;
                _identificationUnitIterator = cs.IdentificationUnits;
                _identificationUnitIterator.Reset();
                this._currentIdentificationUnit = _identificationUnitIterator.First();
                if (this._currentIdentificationUnit != null)
                {
                    while (this._currentIdentificationUnit.RelatedUnitID != null)
                    {
                        try
                        {
                            this._currentIdentificationUnit = this.Next;
                        }
                        catch (DataFunctionsException)
                        {
                            this._currentIdentificationUnit = null;
                        }
                    }
                }
                //this._identificationUnitBrotherIterator = this._identificationUnitIterator;
            }
        }
Exemple #2
0
        public void Remove(IdentificationUnit identificationUnit)
        {
            if (identificationUnit != null)
            {
                //IU-Children und Analysen werden durch Cascade gelöscht.

                //// Remove all IdentificationUnitAnalysis assigned to IdentificationUnit
                //IList<IdentificationUnitAnalysis> iuaList;
                //IRestriction restrict = RestrictionFactory.Eq(typeof(IdentificationUnitAnalysis), "_IdentificationUnitID", identificationUnit.IdentificationUnitID);
                //iuaList = con.LoadList<IdentificationUnitAnalysis>(restrict);
                //foreach (IdentificationUnitAnalysis iuaTemp in iuaList)
                //{
                //    DataFunctions.Instance.Remove(iuaTemp);
                //}
                //// Remove all IdentificationUnitGeoAnalysis assigned to IdentificationUnit
                //IList<IdentificationUnitGeoAnalysis> iuGeoAnalysisList;
                //restrict = RestrictionFactory.Eq(typeof(IdentificationUnitGeoAnalysis), "_IdentificationUnitID", identificationUnit.IdentificationUnitID);
                //iuGeoAnalysisList = con.LoadList<IdentificationUnitGeoAnalysis>(restrict);
                //foreach (IdentificationUnitGeoAnalysis iuGeoAnalysisTemp in iuGeoAnalysisList)
                //{
                //    DataFunctions.Instance.Remove(iuGeoAnalysisTemp);
                //}
                try
                {
                    con.Delete(identificationUnit);
                }
                catch (Exception)
                {
                    throw new DataFunctionsException("Identification Unit (" + identificationUnit.IdentificationUnitID + ") couldn't be removed.");
                }
            }
        }
Exemple #3
0
 public IdentificationUnit CreateTopLevelIdentificationUnit(String lastIdentificationCache)
 {
     try
     {
         IdentificationUnit iu = SERIALIZER.CreateISerializableObject <IdentificationUnit>();
         iu.CollectionSpecimenID    = this._collectionSpecimen.CollectionSpecimenID;
         iu.LastIdentificationCache = lastIdentificationCache;
         SERIALIZER.ConnectOneToMany(this._collectionSpecimen, iu);
         SERIALIZER.Connector.Save(iu);
         this._currentIdentificationUnit = this._identificationUnitIterator.Last();
         return(iu);
     }
     catch (Exception)
     {
         throw new DataFunctionsException("New TopLevel Identification Unit couldn't be created");
     }
 }
Exemple #4
0
        public IdentificationUnitForm(IdentificationUnit currentIU)
            : this(true)
        {
            if (currentIU != null)
            {
                this._iu = currentIU;

                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    this.fillIUData();
                    this._oldIdentificationCache = currentIU.LastIdentificationCache;
                    Cursor.Current = Cursors.Default;
                }
                catch (ConnectionCorruptedException ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    this.Close();
                }
            }
        }
Exemple #5
0
        public bool FindTopLevelIU(int id)
        {
            try
            {
                IRestriction r1       = RestrictionFactory.Eq(typeof(IdentificationUnit), "_IdentificationUnitID", id);
                IRestriction r2       = RestrictionFactory.Eq(typeof(IdentificationUnit), "_RelatedUnitID", null);
                IRestriction restrict = RestrictionFactory.And().Add(r1).Add(r2);
                this._currentIdentificationUnit = con.Load <IdentificationUnit>(restrict);

                if (this._currentIdentificationUnit == null)
                {
                    return(false);
                }
                else
                {
                    this._identificationUnitIterator.SetIteratorTo(this._currentIdentificationUnit);
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #6
0
 public IdentificationUnitVM(IdentificationUnit iu)
     : base(iu)
 {
 }
Exemple #7
0
            private void bottomUp(ISerializableObject iso, List <ISerializableObject> parents)
            {
                if (iso.GetType().Equals(typeof(IdentificationUnitAnalysis)))
                {
                    IdentificationUnitAnalysis iua = (IdentificationUnitAnalysis)iso;
                    IdentificationUnit         iu  = iua.IdentificationUnit;
                    if (iu != null)
                    {
                        parents.Add(iu);
                        bottomUp(iu, parents);
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else if (iso.GetType().Equals(typeof(IdentificationUnit)))
                {
                    IdentificationUnit iu = (IdentificationUnit)iso;

                    /*
                     * IDirectAccessIterator<Identification> identifications = iu.Identifications;
                     * short i = 0;
                     * Identification ident = null;
                     * foreach (Identification id in identifications)
                     * {
                     *  if (id.IdentificationSequence != null && id.IdentificationSequence > i)
                     *  {
                     *      i = (short)id.IdentificationSequence;
                     *      ident = id;
                     *  }
                     * }
                     * if (ident != null)
                     *  parents.Add(ident);*/
                    IdentificationUnit relatedUnit = iu.RelatedUnit;
                    if (relatedUnit != null)
                    {
                        parents.Add(relatedUnit);
                        bottomUp(relatedUnit, parents);
                    }
                    else
                    {
                        CollectionSpecimen spec = iu.CollectionSpecimen;
                        if (spec != null)
                        {
                            parents.Add(spec);
                            bottomUp(spec, parents);
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                }
                else if (iso.GetType().Equals(typeof(CollectionSpecimen)))
                {
                    CollectionSpecimen spec = (CollectionSpecimen)iso;
                    CollectionAgent    ca   = spec.CollectionAgent.First();
                    if (ca != null)
                    {
                        parents.Add(ca);
                    }
                    CollectionEvent ce = spec.CollectionEvent;
                    if (ce != null)
                    {
                        parents.Add(ce);
                        bottomUp(ce, parents);
                    }
                    else
                    {
                        this.root = spec;
                    };                      //Warnung dass das Specimen nicht angezeigt werden kann
                }
                else if (iso.GetType().Equals(typeof(CollectionEvent)))
                {
                    CollectionEvent ce = (CollectionEvent)iso;
                    IDirectAccessIterator <CollectionEventLocalisation> locations = ce.CollectionEventLocalisation;
                    foreach (CollectionEventLocalisation loc in locations)
                    {
                        parents.Add(loc);
                    }
                    IDirectAccessIterator <CollectionEventProperty> properties = ce.CollectionEventProperties;
                    foreach (CollectionEventProperty prop in properties)
                    {
                        parents.Add(prop);
                    }
                    CollectionEventSeries cs = ce.CollectionEventSeries;
                    if (cs != null)
                    {
                        parents.Add(cs);
                        this.root = cs;
                    }
                    else
                    {
                        this.root = ce;
                    }
                }
                else if (iso.GetType().Equals(typeof(CollectionEventSeries)))
                {
                    CollectionEventSeries cs = (CollectionEventSeries)iso;
                    this.root = cs;
                }
            }
Exemple #8
0
 private void topDown(ISerializableObject iso, List <ISerializableObject> children)
 {
     if (iso.GetType().Equals(typeof(CollectionEventSeries)))
     {
         CollectionEventSeries cs = (CollectionEventSeries)iso;
         IDirectAccessIterator <CollectionEvent> events = cs.CollectionEvents;
         foreach (CollectionEvent ce in events)
         {
             children.Add(ce);
             topDown(ce, children);
         }
     }
     if (iso.GetType().Equals(typeof(CollectionEvent)))
     {
         CollectionEvent ce = (CollectionEvent)iso;
         IDirectAccessIterator <CollectionEventLocalisation> locations = ce.CollectionEventLocalisation;
         foreach (CollectionEventLocalisation loc in locations)
         {
             children.Add(loc);
         }
         IDirectAccessIterator <CollectionEventProperty> properties = ce.CollectionEventProperties;
         foreach (CollectionEventProperty prop in properties)
         {
             children.Add(prop);
         }
         IDirectAccessIterator <CollectionSpecimen> specimen = ce.CollectionSpecimen;
         foreach (CollectionSpecimen spec in specimen)
         {
             children.Add(spec);
             topDown(spec, children);
         }
     }
     if (iso.GetType().Equals(typeof(CollectionSpecimen)))
     {
         CollectionSpecimen spec = (CollectionSpecimen)iso;
         CollectionAgent    ca   = spec.CollectionAgent.First();
         if (ca != null)
         {
             children.Add(ca);
         }
         IDirectAccessIterator <CollectionProject> projects = spec.CollectionProject;
         foreach (CollectionProject pr in projects)
         {
             children.Add(pr);
         }
         IDirectAccessIterator <IdentificationUnit> units = spec.IdentificationUnits;
         foreach (IdentificationUnit iu in units)
         {
             if (iu.RelatedUnit == null)//Hier kann der Aufwand optimiert werden indem gleich alle IdentificationUnits angehängt werden, alerdings muss dann der Fall von einer IU als Startpunkt gesondert behandelt werden
             {
                 children.Add(iu);
                 topDown(iu, children);
             }
         }
     }
     if (iso.GetType().Equals(typeof(IdentificationUnit)))
     {
         IdentificationUnit iu = (IdentificationUnit)iso;
         IDirectAccessIterator <IdentificationUnitAnalysis>    analyses    = iu.IdentificationUnitAnalysis;
         IDirectAccessIterator <IdentificationUnitGeoAnalysis> geoAnalyses = iu.IdentificationUnitGeoAnalysis;
         IDirectAccessIterator <Identification> ids = iu.Identifications;
         foreach (IdentificationUnitAnalysis iua in analyses)
         {
             children.Add(iua);
         }
         foreach (IdentificationUnitGeoAnalysis iuga in geoAnalyses)
         {
             children.Add(iuga);
         }
         foreach (Identification id in ids)
         {
             children.Add(id);
         }
         IDirectAccessIterator <IdentificationUnit> units = iu.ChildUnits;
         foreach (IdentificationUnit childUnit in units)
         {
             children.Add(childUnit);
             topDown(childUnit, children);
         }
     }
 }
Exemple #9
0
        private void fillIUData()
        {
            if (this._iu != null)
            {
                if (this._iu.LastIdentificationCache != null)
                {
                    this.comboBoxIdentification.Items.Clear();
                    this.comboBoxIdentification.Items.Add(this._iu.LastIdentificationCache);
                    this.comboBoxIdentification.SelectedIndex = 0;
                }

                if (this._iu.TaxonomicGroup != null)
                {
                    this.labelTaxonomicGroup.Text = this._iu.TaxonomicGroup;
                }

                if (this._iu.RelatedUnitID != null)
                {
                    try
                    {
                        IdentificationUnit iu = DataFunctions.Instance.RetrieveIdentificationUnit((int)this._iu.RelatedUnitID);
                        if (iu != null)
                        {
                            this.labelRelatedUnit.Text = iu.UnitIdentifier + " - " + iu.LastIdentificationCache;

                            this.comboBoxRelationType.Enabled      = true;
                            this.comboBoxRelationType.SelectedItem = this._iu.RelationType;
                        }
                    }
                    catch (ConnectionCorruptedException ex)
                    {
                        throw ex;
                    }
                }

                if (_iu.UnitIdentifier != null && !_iu.UnitIdentifier.Equals(String.Empty))
                {
                    this.textBoxUnitIdentifier.Text = _iu.UnitIdentifier;
                }

                if (this._iu.TaxonomicGroup != null)
                {
                    this.comboBoxIUUnitDescription.Items.Clear();
                    if (this._iu.TaxonomicGroup.Equals("plant"))
                    {
                        this.comboBoxIUUnitDescription.Items.Add("tree");
                        this.comboBoxIUUnitDescription.Items.Add("branch");
                        this.comboBoxIUUnitDescription.Items.Add("leaf");
                        this.comboBoxIUUnitDescription.Items.Add("gall");
                    }
                    else
                    {
                        if (this._iu.UnitDescription != null)
                        {
                            this.comboBoxIUUnitDescription.Items.Add(this._iu.UnitDescription);
                        }
                    }

                    if (this._iu.UnitDescription != null && !this._iu.UnitDescription.Equals(String.Empty))
                    {
                        this.comboBoxIUUnitDescription.SelectedItem = this._iu.UnitDescription;
                    }
                }

                if (this._iu.OnlyObserved != null)
                {
                    this.checkBoxIUOnlyObservedDetails.Checked = (bool)this._iu.OnlyObserved;
                }

                if (this._iu.ColonisedSubstratePart != null)
                {
                    this.textBoxColonisedSubstratePart.Text = this._iu.ColonisedSubstratePart;
                }

                if (this._iu.LifeStage != null)
                {
                    this.textBoxLifeStage.Text = this._iu.LifeStage;
                }

                if (this._iu.Gender != null)
                {
                    this.textBoxGender.Text = this._iu.Gender;
                }

                if (this._iu.NumberOfUnits != null)
                {
                    this.textBoxNumberOfUnits.Text = this._iu.NumberOfUnits.ToString();
                }

                if (this._iu.Circumstances != null)
                {
                    this.comboBoxCircumstances.Text = this._iu.Circumstances;
                }

                if (this._iu.DisplayOrder != null)
                {
                    this.textBoxDisplayOrder.Text = this._iu.DisplayOrder.ToString();
                }
            }
        }
        public void IdentificationUnitWorking()
        {
            //Prepare
            var iu = new IdentificationUnit()
            {
                CollectionSpecimenID = 1,
                Altitude = 0.0,
                Latitude = 30.0,
                Longitude = 31.0,
                IdentificationUri = "TestIdentificationURI",
                LastIdentificationCache = "TestCache",
                TaxonomicGroup = "virus",
                AnalysisDate = DateTime.Now,
                CollectionRelatedUnitID = null

            };

            //Execute
            var id = _target.InsertIdentificationUnit(iu, null, TestResources.Credentials);

            //Assert
            //Nothing to assert
        }