From 8313babf9bc256199e9f2bd96c4fe6ab802f30f0 Mon Sep 17 00:00:00 2001 From: Petyo Stoyanov Date: Fri, 19 Jan 2024 09:21:24 +0200 Subject: [PATCH] Prepare construct legacy events --- core/logic_events.go | 38 +++-------- core/model/legacyEvents.go | 125 +++++++++++++++++++------------------ 2 files changed, 71 insertions(+), 92 deletions(-) diff --git a/core/logic_events.go b/core/logic_events.go index f8ceed03..c536d116 100644 --- a/core/logic_events.go +++ b/core/logic_events.go @@ -127,31 +127,7 @@ func (e eventsLogic) getAllEvents() ([]model.WebToolsEventItem, error) { if w.WebToolsEvent != nil { for _, g := range w.WebToolsEvent { - var isVirtual bool - if g.VirtualEvent == "false" { - isVirtual = false - } else if g.VirtualEvent == "true" { - isVirtual = true - } - - var IsEventFree bool - if g.CostFree == "false" { - IsEventFree = false - } else if g.CostFree == "true" { - IsEventFree = true - } - - var Recurrence bool - if g.Recurrence == "false" { - Recurrence = false - } else if g.Recurrence == "true" { - Recurrence = true - } - - event := model.LegacyEvent{RecurringFlag: Recurrence, /* RegistrationURL: &g.RegistrationURL, TitleURL: &g.TitleURL*/ - LongDescription: g.Description, IsEventFree: IsEventFree, AllDay: false, SourceID: "0", - CalendarID: g.CalendarID, Title: g.Title, Sponsor: g.Sponsor, DataSourceEventID: g.EventID, - IsVirtial: isVirtual, OriginatingCalendarID: g.OriginatingCalendarID, Category: g.EventType} + event := e.constructLegacyEvents(g) legacyEvent = append(legacyEvent, event) } } @@ -163,8 +139,7 @@ func (e eventsLogic) getAllEvents() ([]model.WebToolsEventItem, error) { return allevents, nil } -func (e eventsLogic) constructLegacyEvents(webToolsEvent model.WebToolsEventItem) model.LegacyEvent { - /*g := webToolsEvent.PublicEventWS +func (e eventsLogic) constructLegacyEvents(g model.WebToolsEvent) model.LegacyEvent { var isVirtual bool if g.VirtualEvent == "false" { @@ -188,10 +163,11 @@ func (e eventsLogic) constructLegacyEvents(webToolsEvent model.WebToolsEventItem } event := model.LegacyEvent{RecurringFlag: Recurrence, /* RegistrationURL: &g.RegistrationURL, TitleURL: &g.TitleURL*/ - // LongDescription: g.Description, IsEventFree: IsEventFree, AllDay: false, SourceID: "0", - // CalendarID: g.CalendarID, Title: g.Title, Sponsor: g.Sponsor, DataSourceEventID: g.EventID, - // IsVirtial: isVirtual, OriginatingCalendarID: g.OriginatingCalendarID, Category: g.EventType} */ - return model.LegacyEvent{} + LongDescription: g.Description, IsEventFree: IsEventFree, AllDay: false, SourceID: "0", + CalendarID: g.CalendarID, Title: g.Title, Sponsor: g.Sponsor, DataSourceEventID: g.EventID, + IsVirtial: isVirtual, OriginatingCalendarID: g.OriginatingCalendarID, Category: g.EventType} + + return event } // newAppEventsLogic creates new appShared diff --git a/core/model/legacyEvents.go b/core/model/legacyEvents.go index 4fc316c1..3b40e2e4 100644 --- a/core/model/legacyEvents.go +++ b/core/model/legacyEvents.go @@ -26,68 +26,71 @@ const ( TypeLegacyEvents logutils.MessageDataType = "legacy_events" ) -// WebToolsEventItem represents web tools item +// WebToolsEventItem represents web tools event wrapper item type WebToolsEventItem struct { - XMLName xml.Name `xml:"responseWS"` - Text string `xml:",chardata"` - Deprecated string `xml:"deprecated"` - MaxPageSize string `xml:"maxPageSize"` - WebToolsEvent []struct { - Text string `xml:",chardata"` - CalendarID string `xml:"calendarId"` - CalendarName string `xml:"calendarName"` - EventID string `xml:"eventId"` - Recurrence string `xml:"recurrence"` - RecurrenceID string `xml:"recurrenceId"` - OriginatingCalendarID string `xml:"originatingCalendarId"` - OriginatingCalendarName string `xml:"originatingCalendarName"` - Title string `xml:"title"` - TitleURL string `xml:"titleURL"` - EventType string `xml:"eventType"` - Sponsor string `xml:"sponsor"` - DateDisplay string `xml:"dateDisplay"` - StartDate string `xml:"startDate"` - EndDate string `xml:"endDate"` - TimeType string `xml:"timeType"` - StartTime string `xml:"startTime"` - EndTime string `xml:"endTime"` - EndTimeLabel string `xml:"endTimeLabel"` - InPersonEvent string `xml:"inPersonEvent"` - Location string `xml:"location"` - Description string `xml:"description"` - Speaker string `xml:"speaker"` - RegistrationLabel string `xml:"registrationLabel"` - RegistrationURL string `xml:"registrationURL"` - ContactName string `xml:"contactName"` - ContactEmail string `xml:"contactEmail"` - ContactPhone string `xml:"contactPhone"` - CostFree string `xml:"costFree"` - Cost string `xml:"cost"` - CreatedBy string `xml:"createdBy"` - CreatedDate string `xml:"createdDate"` - EditedBy string `xml:"editedBy"` - EditedDate string `xml:"editedDate"` - Summary string `xml:"summary"` - AudienceFacultyStaff string `xml:"audienceFacultyStaff"` - AudienceStudents string `xml:"audienceStudents"` - AudiencePublic string `xml:"audiencePublic"` - AudienceAlumni string `xml:"audienceAlumni"` - AudienceParents string `xml:"audienceParents"` - ShareWithUrbanaEventsInChicagoArea string `xml:"shareWithUrbanaEventsInChicagoArea"` - ShareWithResearch string `xml:"shareWithResearch"` - ShareWithSpeakers string `xml:"shareWithSpeakers"` - ShareWithIllinoisMobileApp string `xml:"shareWithIllinoisMobileApp"` - ThumbImageUploaded string `xml:"thumbImageUploaded"` - LargeImageUploaded string `xml:"largeImageUploaded"` - LargeImageSize string `xml:"largeImageSize"` - VirtualEvent string `xml:"virtualEvent"` - VirtualEventURL string `xml:"virtualEventURL"` - Topic []struct { - Text string `xml:",chardata"` - ID string `xml:"id"` - Name string `xml:"name"` - } `xml:"topic"` - } `xml:"publicEventWS"` + XMLName xml.Name `xml:"responseWS"` + Text string `xml:",chardata"` + Deprecated string `xml:"deprecated"` + MaxPageSize string `xml:"maxPageSize"` + WebToolsEvent []WebToolsEvent `xml:"publicEventWS"` +} + +// WebToolsEvent represents web tools event entity +type WebToolsEvent struct { + Text string `xml:",chardata"` + CalendarID string `xml:"calendarId"` + CalendarName string `xml:"calendarName"` + EventID string `xml:"eventId"` + Recurrence string `xml:"recurrence"` + RecurrenceID string `xml:"recurrenceId"` + OriginatingCalendarID string `xml:"originatingCalendarId"` + OriginatingCalendarName string `xml:"originatingCalendarName"` + Title string `xml:"title"` + TitleURL string `xml:"titleURL"` + EventType string `xml:"eventType"` + Sponsor string `xml:"sponsor"` + DateDisplay string `xml:"dateDisplay"` + StartDate string `xml:"startDate"` + EndDate string `xml:"endDate"` + TimeType string `xml:"timeType"` + StartTime string `xml:"startTime"` + EndTime string `xml:"endTime"` + EndTimeLabel string `xml:"endTimeLabel"` + InPersonEvent string `xml:"inPersonEvent"` + Location string `xml:"location"` + Description string `xml:"description"` + Speaker string `xml:"speaker"` + RegistrationLabel string `xml:"registrationLabel"` + RegistrationURL string `xml:"registrationURL"` + ContactName string `xml:"contactName"` + ContactEmail string `xml:"contactEmail"` + ContactPhone string `xml:"contactPhone"` + CostFree string `xml:"costFree"` + Cost string `xml:"cost"` + CreatedBy string `xml:"createdBy"` + CreatedDate string `xml:"createdDate"` + EditedBy string `xml:"editedBy"` + EditedDate string `xml:"editedDate"` + Summary string `xml:"summary"` + AudienceFacultyStaff string `xml:"audienceFacultyStaff"` + AudienceStudents string `xml:"audienceStudents"` + AudiencePublic string `xml:"audiencePublic"` + AudienceAlumni string `xml:"audienceAlumni"` + AudienceParents string `xml:"audienceParents"` + ShareWithUrbanaEventsInChicagoArea string `xml:"shareWithUrbanaEventsInChicagoArea"` + ShareWithResearch string `xml:"shareWithResearch"` + ShareWithSpeakers string `xml:"shareWithSpeakers"` + ShareWithIllinoisMobileApp string `xml:"shareWithIllinoisMobileApp"` + ThumbImageUploaded string `xml:"thumbImageUploaded"` + LargeImageUploaded string `xml:"largeImageUploaded"` + LargeImageSize string `xml:"largeImageSize"` + VirtualEvent string `xml:"virtualEvent"` + VirtualEventURL string `xml:"virtualEventURL"` + Topic []struct { + Text string `xml:",chardata"` + ID string `xml:"id"` + Name string `xml:"name"` + } `xml:"topic"` } // LegacyEvent wrapper