Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openolat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zentraler Informatikdienst
Digitale Medien und Lerntechnologien
olat
openolat
Commits
02653cd4
Commit
02653cd4
authored
4 years ago
by
uhensler
Browse files
Options
Downloads
Patches
Plain Diff
OO-4630: Link to appointments course node in calendar event
parent
c29d1d93
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/course/nodes/appointments/manager/CalendarSyncher.java
+37
-6
37 additions, 6 deletions
...at/course/nodes/appointments/manager/CalendarSyncher.java
with
37 additions
and
6 deletions
src/main/java/org/olat/course/nodes/appointments/manager/CalendarSyncher.java
+
37
−
6
View file @
02653cd4
...
@@ -21,6 +21,7 @@ package org.olat.course.nodes.appointments.manager;
...
@@ -21,6 +21,7 @@ package org.olat.course.nodes.appointments.manager;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -28,8 +29,10 @@ import org.olat.commons.calendar.CalendarManagedFlag;
...
@@ -28,8 +29,10 @@ import org.olat.commons.calendar.CalendarManagedFlag;
import
org.olat.commons.calendar.CalendarManager
;
import
org.olat.commons.calendar.CalendarManager
;
import
org.olat.commons.calendar.model.Kalendar
;
import
org.olat.commons.calendar.model.Kalendar
;
import
org.olat.commons.calendar.model.KalendarEvent
;
import
org.olat.commons.calendar.model.KalendarEvent
;
import
org.olat.commons.calendar.model.KalendarEventLink
;
import
org.olat.core.gui.translator.Translator
;
import
org.olat.core.gui.translator.Translator
;
import
org.olat.core.id.Identity
;
import
org.olat.core.id.Identity
;
import
org.olat.core.id.context.BusinessControlFactory
;
import
org.olat.core.util.StringHelper
;
import
org.olat.core.util.StringHelper
;
import
org.olat.core.util.Util
;
import
org.olat.core.util.Util
;
import
org.olat.core.util.i18n.I18nManager
;
import
org.olat.core.util.i18n.I18nManager
;
...
@@ -39,6 +42,7 @@ import org.olat.course.nodes.appointments.Participation;
...
@@ -39,6 +42,7 @@ import org.olat.course.nodes.appointments.Participation;
import
org.olat.course.nodes.appointments.ParticipationSearchParams
;
import
org.olat.course.nodes.appointments.ParticipationSearchParams
;
import
org.olat.course.nodes.appointments.Topic
;
import
org.olat.course.nodes.appointments.Topic
;
import
org.olat.course.nodes.appointments.ui.AppointmentsRunController
;
import
org.olat.course.nodes.appointments.ui.AppointmentsRunController
;
import
org.olat.repository.RepositoryManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -58,7 +62,9 @@ public class CalendarSyncher {
...
@@ -58,7 +62,9 @@ public class CalendarSyncher {
@Autowired
@Autowired
private
ParticipationDAO
participationDao
;
private
ParticipationDAO
participationDao
;
@Autowired
@Autowired
private
CalendarManager
calendarMgr
;
private
CalendarManager
calendarManager
;
@Autowired
private
RepositoryManager
repositoryManager
;
/**
/**
* Sync the calendar events of all organizers and all participants.
* Sync the calendar events of all organizers and all participants.
...
@@ -85,7 +91,7 @@ public class CalendarSyncher {
...
@@ -85,7 +91,7 @@ public class CalendarSyncher {
}
}
void
syncCalendar
(
Collection
<
Appointment
>
appointments
,
Identity
identity
)
{
void
syncCalendar
(
Collection
<
Appointment
>
appointments
,
Identity
identity
)
{
Kalendar
cal
=
calendarM
g
r
.
getCalendar
(
CalendarManager
.
TYPE_USER
,
identity
.
getName
());
Kalendar
cal
=
calendarM
anage
r
.
getCalendar
(
CalendarManager
.
TYPE_USER
,
identity
.
getName
());
syncCalendar
(
appointments
,
identity
,
cal
);
syncCalendar
(
appointments
,
identity
,
cal
);
}
}
...
@@ -99,14 +105,14 @@ public class CalendarSyncher {
...
@@ -99,14 +105,14 @@ public class CalendarSyncher {
for
(
KalendarEvent
event
:
cal
.
getEvents
())
{
for
(
KalendarEvent
event
:
cal
.
getEvents
())
{
if
(
eventExternalId
.
equals
(
event
.
getExternalId
()))
{
if
(
eventExternalId
.
equals
(
event
.
getExternalId
()))
{
updateEvent
(
appointment
,
event
,
identity
);
updateEvent
(
appointment
,
event
,
identity
);
calendarM
g
r
.
updateEventFrom
(
cal
,
event
);
calendarM
anage
r
.
updateEventFrom
(
cal
,
event
);
return
;
return
;
}
}
}
}
// create new event if no existing
// create new event if no existing
KalendarEvent
newEvent
=
createEvent
(
appointment
,
identity
);
KalendarEvent
newEvent
=
createEvent
(
appointment
,
identity
);
calendarM
g
r
.
addEventTo
(
cal
,
newEvent
);
calendarM
anage
r
.
addEventTo
(
cal
,
newEvent
);
}
}
/**
/**
...
@@ -133,7 +139,7 @@ public class CalendarSyncher {
...
@@ -133,7 +139,7 @@ public class CalendarSyncher {
}
}
void
unsyncCalendar
(
Collection
<
Appointment
>
appointments
,
Identity
identity
)
{
void
unsyncCalendar
(
Collection
<
Appointment
>
appointments
,
Identity
identity
)
{
Kalendar
cal
=
calendarM
g
r
.
getCalendar
(
CalendarManager
.
TYPE_USER
,
identity
.
getName
());
Kalendar
cal
=
calendarM
anage
r
.
getCalendar
(
CalendarManager
.
TYPE_USER
,
identity
.
getName
());
unsyncCalendar
(
appointments
,
cal
);
unsyncCalendar
(
appointments
,
cal
);
}
}
...
@@ -145,7 +151,7 @@ public class CalendarSyncher {
...
@@ -145,7 +151,7 @@ public class CalendarSyncher {
String
externalId
=
generateExternalId
(
appointment
);
String
externalId
=
generateExternalId
(
appointment
);
cal
.
getEvents
().
stream
()
cal
.
getEvents
().
stream
()
.
filter
(
event
->
externalId
.
equals
(
event
.
getExternalId
()))
.
filter
(
event
->
externalId
.
equals
(
event
.
getExternalId
()))
.
forEach
(
event
->
calendarM
g
r
.
removeEventFrom
(
cal
,
event
));
.
forEach
(
event
->
calendarM
anage
r
.
removeEventFrom
(
cal
,
event
));
}
}
private
KalendarEvent
createEvent
(
Appointment
appointement
,
Identity
identity
)
{
private
KalendarEvent
createEvent
(
Appointment
appointement
,
Identity
identity
)
{
...
@@ -155,6 +161,7 @@ public class CalendarSyncher {
...
@@ -155,6 +161,7 @@ public class CalendarSyncher {
event
.
setExternalId
(
generateExternalId
(
appointement
));
event
.
setExternalId
(
generateExternalId
(
appointement
));
event
.
setLocation
(
appointement
.
getLocation
());
event
.
setLocation
(
appointement
.
getLocation
());
updateEventDescription
(
appointement
,
event
);
updateEventDescription
(
appointement
,
event
);
addKalendarEventLinks
(
appointement
.
getTopic
(),
event
);
event
.
setManagedFlags
(
CAL_MANAGED_FLAGS
);
event
.
setManagedFlags
(
CAL_MANAGED_FLAGS
);
return
event
;
return
event
;
}
}
...
@@ -165,6 +172,7 @@ public class CalendarSyncher {
...
@@ -165,6 +172,7 @@ public class CalendarSyncher {
event
.
setEnd
(
appointement
.
getEnd
());
event
.
setEnd
(
appointement
.
getEnd
());
event
.
setLocation
(
appointement
.
getLocation
());
event
.
setLocation
(
appointement
.
getLocation
());
updateEventDescription
(
appointement
,
event
);
updateEventDescription
(
appointement
,
event
);
addKalendarEventLinks
(
appointement
.
getTopic
(),
event
);
event
.
setManagedFlags
(
CAL_MANAGED_FLAGS
);
event
.
setManagedFlags
(
CAL_MANAGED_FLAGS
);
}
}
...
@@ -194,6 +202,29 @@ public class CalendarSyncher {
...
@@ -194,6 +202,29 @@ public class CalendarSyncher {
event
.
setDescription
(
descr
.
toString
());
event
.
setDescription
(
descr
.
toString
());
}
}
private
void
addKalendarEventLinks
(
Topic
topic
,
KalendarEvent
event
)
{
List
<
KalendarEventLink
>
kalendarEventLinks
=
event
.
getKalendarEventLinks
();
String
id
=
topic
.
getKey
().
toString
();
String
displayName
=
repositoryManager
.
lookupDisplayName
(
topic
.
getEntry
().
getKey
());
String
businessPath
=
getBusinessPath
(
topic
);
KalendarEventLink
link
=
new
KalendarEventLink
(
"appointments"
,
id
,
displayName
,
businessPath
,
"o_CourseModule_icon"
);
kalendarEventLinks
.
clear
();
kalendarEventLinks
.
add
(
link
);
}
private
String
getBusinessPath
(
Topic
topic
)
{
String
businessPath
;
if
(
topic
.
getEntry
()
!=
null
)
{
businessPath
=
"[RepositoryEntry:"
+
topic
.
getEntry
().
getKey
()
+
"]"
;
if
(
StringHelper
.
containsNonWhitespace
(
topic
.
getSubIdent
()))
{
businessPath
+=
"[CourseNode:"
+
topic
.
getSubIdent
()
+
"]"
;
}
}
else
{
businessPath
=
"[RepositoryEntry:0]"
;
}
return
BusinessControlFactory
.
getInstance
().
getURLFromBusinessPathString
(
businessPath
);
}
private
String
generateExternalId
(
Appointment
appointment
)
{
private
String
generateExternalId
(
Appointment
appointment
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"appointment-"
).
append
(
appointment
.
getKey
());
sb
.
append
(
"appointment-"
).
append
(
appointment
.
getKey
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment