using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Vulnerator.Model.Entity
{
    [Table("Vulnerabilities")]
    public class Vulnerability : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public Vulnerability()
        {
            UniqueFindings = new ObservableCollection<UniqueFinding>();
            VulnerabilitySources = new ObservableCollection<VulnerabilitySource>();
            CCIs = new ObservableCollection<CCI>();
            GroupsMitigationsOrConditionsVulnerabilities = new ObservableCollection<GroupMitigationOrConditionVulnerability>();
            IA_Controls = new ObservableCollection<IA_Control>();
            ResponsibilityRoles = new ObservableCollection<ResponsibilityRole>();
            VulnerabilityReferences = new ObservableCollection<VulnerabilityReference>();
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public long Vulnerability_ID { get; set; }

        [Required]
        [StringLength(100)]
        public string UniqueVulnerabilityIdentifier { get; set; }

        [StringLength(100)]
        public string VulnerabilityGroupIdentifier { get; set; }

        [StringLength(100)]
        public string VulnerabilityGroupTitle { get; set; }

        [StringLength(25)]
        public string SecondaryVulnerabilityIdentifier { get; set; }

        [StringLength(100)]
        public string VulnerabilityFamilyOrClass { get; set; }

        [StringLength(25)]
        public string VulnerabilityVersion { get; set; }

        [StringLength(25)]
        public string VulnerabilityRelease { get; set; }

        [Required]
        [StringLength(100)]
        public string VulnerabilityTitle { get; set; }

        [StringLength(2147483647)]
        public string VulnerabilityDescription { get; set; }

        [StringLength(2147483647)]
        public string RiskStatement { get; set; }

        [StringLength(2147483647)]
        public string FixText { get; set; }

        public DateTime? PublishedDate { get; set; }

        public DateTime? ModifiedDate { get; set; }

        public DateTime? FixPublishedDate { get; set; }

        [Required]
        [StringLength(25)]
        public string PrimaryRawRiskIndicator { get; set; }

        [StringLength(25)]
        public string SecondaryRawRiskIndicator { get; set; }

        [StringLength(5)]
        public string CVSS_BaseScore { get; set; }

        [StringLength(25)]
        public string CVSS_BaseVector { get; set; }

        [StringLength(5)]
        public string CVSS_TemporalScore { get; set; }

        [StringLength(25)]
        public string CVSS_TemporalVector { get; set; }

        [StringLength(2000)]
        public string CheckContent { get; set; }

        [StringLength(2000)]
        public string FalsePositives { get; set; }

        [StringLength(2000)]
        public string FalseNegatives { get; set; }

        [StringLength(5)]
        public string IsDocumentable { get; set; }

        [StringLength(2000)]
        public string Mitigations { get; set; }

        [StringLength(2000)]
        public string MitigationControl { get; set; }

        [StringLength(2000)]
        public string PotentialImpacts { get; set; }

        [StringLength(500)]
        public string ThirdPartyTools { get; set; }

        [StringLength(2000)]
        public string SecurityOverrideGuidance { get; set; }

        [StringLength(2000)]
        public string SeverityOverrideGuidance { get; set; }

        [StringLength(2000)]
        public string Overflow { get; set; }

        [StringLength(5)]
        public string IsActive { get; set; }

        [NotMapped]
        public bool IsChecked { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<UniqueFinding> UniqueFindings { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<VulnerabilitySource> VulnerabilitySources { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<CCI> CCIs { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<IA_Control> IA_Controls { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<ResponsibilityRole> ResponsibilityRoles { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<VulnerabilityReference> VulnerabilityReferences { get; set; }
        
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<GroupMitigationOrConditionVulnerability> GroupsMitigationsOrConditionsVulnerabilities { get; set; }
    }
}
