Imports System.Net
Imports System.Text.RegularExpressions
Imports DpmaXmlParser

Public Class Patent
    ' Aus Search
    Private _LeadingRegisteredNumber As String ' leading-registered-number / Aktenzeichen
    Private _RN As String ' registered-number
    Private _edition As String ' ICM / IPC-Hauptklasse
    Private _classification As String ' ICM / IPC-Hauptklasse
    Private _type As String ' type / Schutzrechtsart
    Private _status As String
    Private _title As String
    Private _applicants As New List(Of String)
    Private _inventors As New List(Of String)
    Private _applicationDate As Date
    Private _publiccationDate As Date

    ' Aus GetRegisterInfo
    Private _abstract As String
    Private _events As New List(Of PatentEvent)
    Private _applicationDocuments As New List(Of PatentDocument)
    Private _publicationDocuments As New List(Of PatentDocument)

    Public Property LeadingRegisteredNumber As String
        Get
            Return _LeadingRegisteredNumber
        End Get
        Set(value As String)
            _LeadingRegisteredNumber = value
        End Set
    End Property

    Public Property RegisteredNumber As String
        Get
            Return _RN
        End Get
        Set(value As String)
            _RN = value
        End Set
    End Property

    Public Property Type As String
        Get
            Return _type
        End Get
        Set(value As String)
            _type = value
        End Set
    End Property

    Public Property Status As String
        Get
            Return _status
        End Get
        Set(value As String)
            _status = value
        End Set
    End Property

    Public Property Title As String
        Get
            Return _title
        End Get
        Set(value As String)
            _title = value
        End Set
    End Property

    Public ReadOnly Property ICM As String
        Get
            Return String.Format("{0} ({1})", _classification, _edition)
        End Get
    End Property

    Public Property Edition As String
        Get
            Return _edition
        End Get
        Set(value As String)
            _edition = value
        End Set
    End Property

    Public Property Classification As String
        Get
            Return _classification
        End Get
        Set(value As String)
            _classification = value
        End Set
    End Property

    Public Property ApplicationDate As String
        Get
            Return _applicationDate
        End Get
        Set(value As String)
            _applicationDate = Utils.ParseShortDate(value)
        End Set
    End Property

    Public Property PublicationDate As String
        Get
            Return _publiccationDate
        End Get
        Set(value As String)
            _publiccationDate = Utils.ParseShortDate(value)
        End Set
    End Property

    Public Property ApplicantsList As List(Of String)
        Get
            Return _applicants
        End Get
        Set(value As List(Of String))
            _applicants = value
        End Set
    End Property

    Public ReadOnly Property Applicants As String
        Get
            Return String.Join(";", _applicants.ToArray())
        End Get
    End Property

    Public Property InventorsList As List(Of String)
        Get
            Return _inventors
        End Get
        Set(value As List(Of String))
            _inventors = value
        End Set
    End Property

    Public ReadOnly Property Inventors As String
        Get
            Return String.Join(";", _inventors.ToArray())
        End Get
    End Property

    Public Property Abstract As String
        Get
            Return _abstract
        End Get
        Set(value As String)
            ' Änderung 01.08.17 - Problem bei Maskierung von Hochkomma    
            '_abstract = value.Replace("'", "`")
            _abstract = value.Replace("'", "''")
        End Set
    End Property

    Public Property Events As List(Of PatentEvent)
        Get
            Return _events
        End Get
        Set(value As List(Of PatentEvent))
            _events = value
        End Set
    End Property

    Public Property ApplicationDocuments As List(Of PatentDocument)
        Get
            Return _applicationDocuments
        End Get
        Set(value As List(Of PatentDocument))
            _applicationDocuments = value
        End Set
    End Property

    Public Property PublicationDocuments As List(Of PatentDocument)
        Get
            Return _publicationDocuments
        End Get
        Set(value As List(Of PatentDocument))
            _publicationDocuments = value
        End Set
    End Property
End Class

Public Class PatentDocument
    Private _docdate As Date

    Public Country As String
    Public DocNumber As String
    Public Kind As String

    Public Property DocDate As String
        Get
            Return _docdate
        End Get
        Set(value As String)
            _docdate = Utils.ParseShortDate(value)
        End Set
    End Property
End Class

Public Class PatentEvent
    Public Type As String
    Public Status As String
    Public StatusDate As Date
    Public CaptureDate As Date

    Public PublicationInfo As PatentPublication
End Class

Public Class PatentPublication
    Public IssueNumber As Integer
    Public Year As Integer
    Public PublicationDate As Date
    Public PublicationType As String
    Public Part As String
End Class
