use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class DENManager method addDateInUserCalendar.
/**
* Add this event in the calendar of an enrolled user
* @param newEvent
*/
private void addDateInUserCalendar(KalendarEvent newEvent) {
String[] participants = newEvent.getParticipants();
// no users to update, cancel
if (participants == null)
return;
BaseSecurity manager = BaseSecurityManager.getInstance();
CalendarManager calManager = CoreSpringFactory.getImpl(CalendarManager.class);
for (String participant : participants) {
Identity identity = manager.findIdentityByName(participant);
if (identity != null) {
Kalendar userCal = calManager.getPersonalCalendar(identity).getKalendar();
List<KalendarEvent> userEvents = new ArrayList<>();
userEvents.addAll(userCal.getEvents());
String eventId = CodeHelper.getGlobalForeverUniqueID();
KalendarEvent userNewEvent = new KalendarEvent(eventId, null, newEvent.getSubject(), newEvent.getBegin(), newEvent.getEnd());
userNewEvent.setLocation(newEvent.getLocation());
userNewEvent.setSourceNodeId(newEvent.getSourceNodeId());
userNewEvent.setClassification(KalendarEvent.CLASS_PRIVATE);
List<KalendarEventLink> kalendarEventLinks = userNewEvent.getKalendarEventLinks();
kalendarEventLinks.clear();
kalendarEventLinks.addAll(newEvent.getKalendarEventLinks());
calManager.addEventTo(userCal, userNewEvent);
}
}
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class DENManager method updateMultipleDatesInList.
/**
* Update multiple dates in a list of KalendarEvents with the given informations from a manage dates form
* @param datesForm of type DENEditManageDatesForm
* @param dataList
* @param selectedDates
* @return list with actualized KalendarEvents
*/
protected List<KalendarEvent> updateMultipleDatesInList(String subjectStr, String commentStr, String locationStr, String movementGapStr, int numParticipants, List<KalendarEvent> dataList, BitSet selectedDates) {
for (int i = 0; i < dataList.size(); i++) {
if (selectedDates.get(i)) {
KalendarEvent oldEvent = dataList.get(i);
StringTokenizer strTok = new StringTokenizer(movementGapStr.substring(1), ":", false);
int gap = 1000 * 60 * 60 * Integer.parseInt(strTok.nextToken()) + 1000 * 60 * Integer.parseInt(strTok.nextToken());
Date newBegin, newEnd;
if (movementGapStr.startsWith("+")) {
newBegin = new Date(oldEvent.getBegin().getTime() + gap);
newEnd = new Date(oldEvent.getEnd().getTime() + gap);
} else {
newBegin = new Date(oldEvent.getBegin().getTime() - gap);
newEnd = new Date(oldEvent.getEnd().getTime() - gap);
}
String eventId = oldEvent.getID();
KalendarEvent newEvent = new KalendarEvent(eventId, null, subjectStr.equals(new String()) ? oldEvent.getSubject() : subjectStr, newBegin, newEnd);
if (numParticipants != 0)
newEvent.setNumParticipants(numParticipants);
else
newEvent.setNumParticipants(oldEvent.getNumParticipants());
if (!locationStr.equals(new String()))
newEvent.setLocation(locationStr);
else
newEvent.setLocation(oldEvent.getLocation());
if (!commentStr.equals(new String()))
newEvent.setComment(commentStr);
else
newEvent.setComment(oldEvent.getComment());
newEvent.setParticipants(oldEvent.getParticipants());
newEvent.setSourceNodeId(oldEvent.getSourceNodeId());
dataList.remove(i);
dataList.add(i, newEvent);
}
}
return dataList;
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class DENManager method getEventParticipants.
/**
* Little helper method, that gives you all participants of a specific event
* @param event
* @return list of Identities
*/
protected List<Identity> getEventParticipants(KalendarEvent event) {
List<Identity> identities = new ArrayList<Identity>();
List<KalendarEvent> lstEvent = new ArrayList<KalendarEvent>();
lstEvent.add(event);
BitSet selection = new BitSet(1);
selection.set(0);
identities = getSelectedEventParticipants(lstEvent, selection);
return identities;
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class DENRunTableDataModel method getValueAt.
@Override
public Object getValueAt(int row, int col) {
KalendarEvent event = getObject(row);
switch(col) {
case 0:
// subject
return event.getSubject();
case 1:
return event.getBegin();
case 2:
Date begin = event.getBegin();
Date end = event.getEnd();
long milliSeconds = denManager.getDuration(begin, end);
return denManager.formatDuration(milliSeconds, translator);
case 3:
// location
return event.getLocation();
case 4:
// comment
return event.getComment();
case 5:
// enrolled & total
StringBuilder numStrBuf = new StringBuilder();
String[] participants = event.getParticipants();
numStrBuf.append(participants == null ? "0" : participants.length).append("/").append(event.getNumParticipants());
return numStrBuf.toString();
case 6:
// status
boolean isEnrolled = denManager.isEnrolledInDate(identity, event);
if (isEnrolled)
return translator.translate("dates.table.run.enrolled");
else if (denManager.isDateFull(event))
return translator.translate("dates.table.run.full");
else
return translator.translate("dates.table.run.notenrolled");
case 7:
if (!enrollmentEnabled)
return Boolean.FALSE;
// enroll
if (denManager.isAlreadyEnrolled(identity, objects, courseNode)) {
return Boolean.FALSE;
}
if ((event.getParticipants() != null) && (event.getParticipants().length >= event.getNumParticipants())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
case 8:
if (!enrollmentEnabled) {
return denManager.isEnrolledInDate(identity, event);
}
// cancel enrollment
if (cancelEnrollEnabled)
return denManager.isEnrolledInDate(identity, event);
return Boolean.FALSE;
default:
return "error";
}
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class DENCourseNode method cleanupOnDelete.
@Override
public void cleanupOnDelete(ICourse course) {
super.cleanupOnDelete(course);
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
cpm.deleteNodeProperties(this, CONF_CANCEL_ENROLL_ENABLED);
DENManager denManager = DENManager.getInstance();
// empty List as first argument, so all dates for this course node are going to delete
denManager.persistDENSettings(new ArrayList<KalendarEvent>(), course, this);
}
Aggregations