Skip to content
Snippets Groups Projects
Commit 5057d667 authored by srosse's avatar srosse
Browse files

OO-4150: log changes to absence notice and related

parent c2e4fad7
No related branches found
No related tags found
No related merge requests found
Showing
with 397 additions and 34 deletions
...@@ -44,6 +44,8 @@ public interface LectureBlockAuditLog { ...@@ -44,6 +44,8 @@ public interface LectureBlockAuditLog {
public Long getRollCallKey(); public Long getRollCallKey();
public Long getEntryKey(); public Long getEntryKey();
public Long getAbsenceNoticeKey();
public Long getIdentityKey(); public Long getIdentityKey();
...@@ -68,7 +70,13 @@ public interface LectureBlockAuditLog { ...@@ -68,7 +70,13 @@ public interface LectureBlockAuditLog {
updateSummary, updateSummary,
removeCustomRate, removeCustomRate,
sendAppeal sendAppeal,
createAbsenceNotice,
updateAbsenceNotice,
createAbsenceNoticeRelations,
updateAbsenceNoticeRelations,
} }
} }
...@@ -140,6 +140,10 @@ public interface LectureService { ...@@ -140,6 +140,10 @@ public interface LectureService {
public String toAuditXml(LectureParticipantSummary summary); public String toAuditXml(LectureParticipantSummary summary);
public String toAuditXml(AbsenceNotice absenceNotice);
public AbsenceNotice toAuditAbsenceNotice(String xml);
public LectureParticipantSummary toAuditLectureParticipantSummary(String xml); public LectureParticipantSummary toAuditLectureParticipantSummary(String xml);
...@@ -153,6 +157,19 @@ public interface LectureService { ...@@ -153,6 +157,19 @@ public interface LectureService {
LectureBlockRef lectureBlock, LectureBlockRollCall rollCall, LectureBlockRef lectureBlock, LectureBlockRollCall rollCall,
RepositoryEntryRef entry, IdentityRef assessedIdentity, IdentityRef author); RepositoryEntryRef entry, IdentityRef assessedIdentity, IdentityRef author);
/**
*
* @param action
* @param before
* @param after
* @param message
* @param absenceNotice
* @param assessedIdentity
* @param author
*/
public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message,
AbsenceNoticeRef absenceNotice, IdentityRef assessedIdentity, IdentityRef author);
public List<LectureBlockAuditLog> getAuditLog(LectureBlockRef lectureBlock); public List<LectureBlockAuditLog> getAuditLog(LectureBlockRef lectureBlock);
/** /**
...@@ -299,7 +316,7 @@ public interface LectureService { ...@@ -299,7 +316,7 @@ public interface LectureService {
* @return A refreshed absence notice * @return A refreshed absence notice
*/ */
public AbsenceNotice updateAbsenceNotice(AbsenceNotice absenceNotice, Identity authorizer, public AbsenceNotice updateAbsenceNotice(AbsenceNotice absenceNotice, Identity authorizer,
List<RepositoryEntry> entries, List<LectureBlock> lectureBlocks); List<RepositoryEntry> entries, List<LectureBlock> lectureBlocks, Identity actingIdentity);
public AbsenceNotice updateAbsenceNoticeAttachments(AbsenceNotice absenceNotice, List<VFSItem> newFiles, List<VFSItem> filesToDelete); public AbsenceNotice updateAbsenceNoticeAttachments(AbsenceNotice absenceNotice, List<VFSItem> newFiles, List<VFSItem> filesToDelete);
......
...@@ -90,6 +90,7 @@ public class AbsenceNoticeDAO { ...@@ -90,6 +90,7 @@ public class AbsenceNoticeDAO {
QueryBuilder sb = new QueryBuilder(); QueryBuilder sb = new QueryBuilder();
sb.append("select rollCall from lectureblockrollcall rollCall") sb.append("select rollCall from lectureblockrollcall rollCall")
.append(" inner join fetch rollCall.absenceNotice as notice") .append(" inner join fetch rollCall.absenceNotice as notice")
.append(" left join fetch rollCall.lectureBlock as lectureBlock")
.append(" where notice.key=:noticeKey"); .append(" where notice.key=:noticeKey");
return dbInstance.getCurrentEntityManager() return dbInstance.getCurrentEntityManager()
...@@ -120,16 +121,12 @@ public class AbsenceNoticeDAO { ...@@ -120,16 +121,12 @@ public class AbsenceNoticeDAO {
.append(" inner join bGroup.members participants on (participants.role='").append(GroupRoles.participant.name()).append("')") .append(" inner join bGroup.members participants on (participants.role='").append(GroupRoles.participant.name()).append("')")
.append(" inner join absencenotice notice on (participants.identity.key=notice.identity.key)") .append(" inner join absencenotice notice on (participants.identity.key=notice.identity.key)")
.append(" where notice.key in (:noticeKeys)"); .append(" where notice.key in (:noticeKeys)");
}
if(target == AbsenceNoticeTarget.entries || target == AbsenceNoticeTarget.allentries) {
// date constraints // date constraints
sb.append(" and (") sb.append(" and ");
.append("(notice.startDate<=block.startDate and notice.endDate>=block.endDate)") noticeBlockDates(sb);
.append(" or ")
.append("(notice.startDate>=block.startDate and notice.endDate<=block.startDate)")
.append(" or ")
.append("(notice.startDate>=block.endDate and notice.endDate<=block.endDate)")
.append(" or ")
.append("(notice.startDate is null and notice.endDate is null)")
.append(")");
} }
List<Long> noticeKeys = notices.stream() List<Long> noticeKeys = notices.stream()
...@@ -150,6 +147,19 @@ public class AbsenceNoticeDAO { ...@@ -150,6 +147,19 @@ public class AbsenceNoticeDAO {
return blockWithNotices; return blockWithNotices;
} }
protected static QueryBuilder noticeBlockDates(QueryBuilder sb) {
sb.append("(")
.append("(notice.startDate<=block.startDate and notice.endDate>=block.endDate)")
.append(" or ")
.append("(notice.startDate>=block.startDate and notice.endDate<=block.startDate)")
.append(" or ")
.append("(notice.startDate>=block.endDate and notice.endDate<=block.endDate)")
.append(" or ")
.append("(notice.startDate is null and notice.endDate is null)")
.append(")");
return sb;
}
public AbsenceNotice loadAbsenceNotice(Long noticeKey) { public AbsenceNotice loadAbsenceNotice(Long noticeKey) {
QueryBuilder sb = new QueryBuilder(512); QueryBuilder sb = new QueryBuilder(512);
sb.append("select notice from absencenotice as notice") sb.append("select notice from absencenotice as notice")
...@@ -335,7 +345,7 @@ public class AbsenceNoticeDAO { ...@@ -335,7 +345,7 @@ public class AbsenceNoticeDAO {
.append(" and noticeToEntry.absenceNotice.key=notice.key and noticeToEntry.entry.key=:entryKey") .append(" and noticeToEntry.absenceNotice.key=notice.key and noticeToEntry.entry.key=:entryKey")
.append(" ) or (notice.target ").in(AbsenceNoticeTarget.allentries) .append(" ) or (notice.target ").in(AbsenceNoticeTarget.allentries)
.append(" and notice.startDate<=:startDate and notice.endDate>=:endDate") .append(" and notice.startDate<=:startDate and notice.endDate>=:endDate")
.append(" )") .append(" )")//TODO absences date for entries and all entries
.append(")"); .append(")");
} }
......
...@@ -77,14 +77,21 @@ public class AbsenceNoticeToRepositoryEntryDAO { ...@@ -77,14 +77,21 @@ public class AbsenceNoticeToRepositoryEntryDAO {
dbInstance.getCurrentEntityManager().remove(relation); dbInstance.getCurrentEntityManager().remove(relation);
} }
/**
* List of roll call with the suitable dates and repository entries
* @param notice
* @return
*/
public List<LectureBlockRollCall> getRollCallsByRepositoryEntry(AbsenceNotice notice) { public List<LectureBlockRollCall> getRollCallsByRepositoryEntry(AbsenceNotice notice) {
QueryBuilder sb = new QueryBuilder(); QueryBuilder sb = new QueryBuilder();
sb.append("select rollCall from absencenoticetoentry noticeToEntry") sb.append("select rollCall from absencenoticetoentry noticeToEntry")
.append(" inner join noticeToEntry.entry as entry") .append(" inner join noticeToEntry.entry as entry")
.append(" inner join noticeToEntry.absenceNotice as notice")
.append(" inner join lectureblock as block on (block.entry.key=entry.key)") .append(" inner join lectureblock as block on (block.entry.key=entry.key)")
.append(" inner join lectureblockrollcall as rollCall on (rollCall.lectureBlock.key=block.key)") .append(" inner join lectureblockrollcall as rollCall on (rollCall.lectureBlock.key=block.key)")
.append(" inner join fetch rollCall.absenceNotice as currentNotice") .append(" inner join fetch rollCall.absenceNotice as currentNotice")
.append(" where noticeToEntry.absenceNotice.key=:noticeKey"); .append(" where notice.key=:noticeKey and ");
AbsenceNoticeDAO.noticeBlockDates(sb);
return dbInstance.getCurrentEntityManager() return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), LectureBlockRollCall.class) .createQuery(sb.toString(), LectureBlockRollCall.class)
...@@ -92,13 +99,24 @@ public class AbsenceNoticeToRepositoryEntryDAO { ...@@ -92,13 +99,24 @@ public class AbsenceNoticeToRepositoryEntryDAO {
.getResultList(); .getResultList();
} }
/**
*
* @param notice
* @return
*/
public List<LectureBlockRollCall> getRollCallsOfAllEntries(AbsenceNotice notice) { public List<LectureBlockRollCall> getRollCallsOfAllEntries(AbsenceNotice notice) {
QueryBuilder sb = new QueryBuilder(); QueryBuilder sb = new QueryBuilder();
sb.append("select rollCall from lectureblock block") sb.append("select rollCall from lectureblock block")
.append(" inner join lectureblockrollcall as rollCall on (rollCall.lectureBlock.key=block.key)") .append(" inner join lectureblockrollcall as rollCall on (rollCall.lectureBlock.key=block.key)")
.append(" inner join fetch rollCall.absenceNotice as currentNotice") .append(" inner join fetch rollCall.absenceNotice as currentNotice")
.append(" where rollCall.identity.key=:identityKey") .append(" where rollCall.identity.key=:identityKey")
.append(" and block.startDate>=:startDate and block.endDate<=:endDate"); .append(" and (")
.append(" (block.startDate>=:startDate and block.endDate<=:endDate)")
.append(" or ")
.append(" (block.startDate<=:startDate and block.startDate>=:endDate)")
.append(" or ")
.append(" (block.endDate<=:startDate and block.endDate>=:endDate)")
.append(" )");
return dbInstance.getCurrentEntityManager() return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), LectureBlockRollCall.class) .createQuery(sb.toString(), LectureBlockRollCall.class)
......
...@@ -22,22 +22,31 @@ package org.olat.modules.lecture.manager; ...@@ -22,22 +22,31 @@ package org.olat.modules.lecture.manager;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.logging.log4j.Logger;
import org.olat.basesecurity.IdentityImpl;
import org.olat.basesecurity.IdentityRef; import org.olat.basesecurity.IdentityRef;
import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DB;
import org.apache.logging.log4j.Logger;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper; import org.olat.core.util.StringHelper;
import org.olat.core.util.xml.XStreamHelper; import org.olat.core.util.xml.XStreamHelper;
import org.olat.modules.lecture.AbsenceNotice;
import org.olat.modules.lecture.AbsenceNoticeRef;
import org.olat.modules.lecture.AbsenceNoticeToRepositoryEntry;
import org.olat.modules.lecture.LectureBlock; import org.olat.modules.lecture.LectureBlock;
import org.olat.modules.lecture.LectureBlockAuditLog; import org.olat.modules.lecture.LectureBlockAuditLog;
import org.olat.modules.lecture.LectureBlockRef; import org.olat.modules.lecture.LectureBlockRef;
import org.olat.modules.lecture.LectureBlockRollCall; import org.olat.modules.lecture.LectureBlockRollCall;
import org.olat.modules.lecture.LectureParticipantSummary; import org.olat.modules.lecture.LectureParticipantSummary;
import org.olat.modules.lecture.model.AbsenceCategoryImpl;
import org.olat.modules.lecture.model.AbsenceNoticeImpl;
import org.olat.modules.lecture.model.AbsenceNoticeRelationsAuditImpl;
import org.olat.modules.lecture.model.AbsenceNoticeToLectureBlockImpl;
import org.olat.modules.lecture.model.LectureBlockAuditLogImpl; import org.olat.modules.lecture.model.LectureBlockAuditLogImpl;
import org.olat.modules.lecture.model.LectureBlockImpl; import org.olat.modules.lecture.model.LectureBlockImpl;
import org.olat.modules.lecture.model.LectureBlockRollCallImpl; import org.olat.modules.lecture.model.LectureBlockRollCallImpl;
import org.olat.modules.lecture.model.LectureParticipantSummaryImpl; import org.olat.modules.lecture.model.LectureParticipantSummaryImpl;
import org.olat.modules.lecture.model.ReasonImpl; import org.olat.modules.lecture.model.ReasonImpl;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryRef; import org.olat.repository.RepositoryEntryRef;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -90,6 +99,62 @@ public class LectureBlockAuditLogDAO { ...@@ -90,6 +99,62 @@ public class LectureBlockAuditLogDAO {
summaryXStream.omitField(LectureParticipantSummaryImpl.class, "identity"); summaryXStream.omitField(LectureParticipantSummaryImpl.class, "identity");
summaryXStream.omitField(LectureParticipantSummaryImpl.class, "entry"); summaryXStream.omitField(LectureParticipantSummaryImpl.class, "entry");
} }
private static final XStream absenceNoticeXStream = XStreamHelper.createXStreamInstanceForDBObjects();
static {
absenceNoticeXStream.alias("absenceNotice", AbsenceNoticeImpl.class);
absenceNoticeXStream.ignoreUnknownElements();
absenceNoticeXStream.omitField(LectureParticipantSummaryImpl.class, "identity");
absenceNoticeXStream.omitField(LectureParticipantSummaryImpl.class, "entry");
absenceNoticeXStream.alias("identity", IdentityImpl.class);
absenceNoticeXStream.omitField(IdentityImpl.class, "user");
absenceNoticeXStream.alias("absenceCategory", AbsenceCategoryImpl.class);
}
private static final XStream absenceNoticeRelationsXStream = XStreamHelper.createXStreamInstanceForDBObjects();
static {
absenceNoticeRelationsXStream.alias("absenceNoticeRelations", AbsenceNoticeRelationsAuditImpl.class);
absenceNoticeRelationsXStream.ignoreUnknownElements();
absenceNoticeRelationsXStream.omitField(AbsenceNoticeToLectureBlockImpl.class, "lectureToBlock");
absenceNoticeRelationsXStream.omitField(AbsenceNoticeToRepositoryEntry.class, "lectureToEntry");
absenceNoticeRelationsXStream.omitField(AbsenceNoticeToLectureBlockImpl.class, "absenceNotice");
absenceNoticeRelationsXStream.omitField(AbsenceNoticeToRepositoryEntry.class, "absenceNotice");
absenceNoticeRelationsXStream.alias("absenceNotice", AbsenceNoticeImpl.class);
absenceNoticeRelationsXStream.omitField(AbsenceNoticeImpl.class, "identity");
absenceNoticeRelationsXStream.omitField(AbsenceNoticeImpl.class, "notifier");
absenceNoticeRelationsXStream.omitField(AbsenceNoticeImpl.class, "authorizer");
absenceNoticeRelationsXStream.alias("lectureBlock", LectureBlockImpl.class);
absenceNoticeRelationsXStream.omitField(LectureBlockImpl.class, "entry");
absenceNoticeRelationsXStream.omitField(LectureBlockImpl.class, "teacherGroup");
absenceNoticeRelationsXStream.omitField(LectureBlockImpl.class, "groups");
absenceNoticeRelationsXStream.omitField(LectureBlockImpl.class, "lastModified");
absenceNoticeRelationsXStream.omitField(LectureBlockImpl.class, "taxonomyLevels");
absenceNoticeRelationsXStream.alias("repositoryEntry", RepositoryEntry.class);
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "olatResource");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "groups");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "organisations");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "taxonomyLevels");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "description");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "objectives");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "requirements");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "location");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "credits");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "expenditureOfWork");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "lifecycle");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "deletedBy");
absenceNoticeRelationsXStream.omitField(RepositoryEntry.class, "statistics");
absenceNoticeRelationsXStream.alias("rollcall", LectureBlockRollCallImpl.class);
absenceNoticeRelationsXStream.ignoreUnknownElements();
absenceNoticeRelationsXStream.omitField(LectureBlockRollCallImpl.class, "identity");
absenceNoticeRelationsXStream.omitField(LectureBlockRollCallImpl.class, "lastModified");
absenceNoticeRelationsXStream.alias("absenceCategory", AbsenceCategoryImpl.class);
}
public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message, public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message,
LectureBlockRef lectureBlock, LectureBlockRollCall rollCall, LectureBlockRef lectureBlock, LectureBlockRollCall rollCall,
...@@ -118,6 +183,26 @@ public class LectureBlockAuditLogDAO { ...@@ -118,6 +183,26 @@ public class LectureBlockAuditLogDAO {
dbInstance.getCurrentEntityManager().persist(auditLog); dbInstance.getCurrentEntityManager().persist(auditLog);
} }
public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message,
AbsenceNoticeRef absenceNotice, IdentityRef assessedIdentity, IdentityRef author) {
LectureBlockAuditLogImpl auditLog = new LectureBlockAuditLogImpl();
auditLog.setCreationDate(new Date());
auditLog.setAction(action.name());
auditLog.setBefore(before);
auditLog.setAfter(after);
auditLog.setMessage(message);
if(absenceNotice != null) {
auditLog.setAbsenceNoticeKey(absenceNotice.getKey());
}
if(assessedIdentity != null) {
auditLog.setIdentityKey(assessedIdentity.getKey());
}
if(author != null) {
auditLog.setAuthorKey(author.getKey());
}
dbInstance.getCurrentEntityManager().persist(auditLog);
}
public List<LectureBlockAuditLog> getAuditLog(LectureBlockRef lectureBlock) { public List<LectureBlockAuditLog> getAuditLog(LectureBlockRef lectureBlock) {
StringBuilder sb = new StringBuilder(128); StringBuilder sb = new StringBuilder(128);
sb.append("select log from lectureblockauditlog log where log.lectureBlockKey=:lectureBlockKey"); sb.append("select log from lectureblockauditlog log where log.lectureBlockKey=:lectureBlockKey");
...@@ -211,7 +296,7 @@ public class LectureBlockAuditLogDAO { ...@@ -211,7 +296,7 @@ public class LectureBlockAuditLogDAO {
if(summary == null) return null; if(summary == null) return null;
return summaryXStream.toXML(summary); return summaryXStream.toXML(summary);
} }
public LectureParticipantSummary summaryFromXml(String xml) { public LectureParticipantSummary summaryFromXml(String xml) {
if(StringHelper.containsNonWhitespace(xml)) { if(StringHelper.containsNonWhitespace(xml)) {
try { try {
...@@ -226,4 +311,30 @@ public class LectureBlockAuditLogDAO { ...@@ -226,4 +311,30 @@ public class LectureBlockAuditLogDAO {
} }
return null; return null;
} }
public String toXml(AbsenceNotice absenceNotice) {
if(absenceNotice == null) return null;
return absenceNoticeXStream.toXML(absenceNotice);
}
public AbsenceNotice absenceNoticeFromXml(String xml) {
if(StringHelper.containsNonWhitespace(xml)) {
try {
Object obj = absenceNoticeXStream.fromXML(xml);
if(obj instanceof AbsenceNotice) {
return (AbsenceNotice)obj;
}
} catch (Exception e) {
log.error("", e);
return null;
}
}
return null;
}
public String toXml(AbsenceNoticeRelationsAuditImpl absenceNoticeAudit) {
if(absenceNoticeAudit == null) return null;
return absenceNoticeRelationsXStream.toXML(absenceNoticeAudit);
}
} }
...@@ -95,6 +95,7 @@ import org.olat.modules.lecture.Reason; ...@@ -95,6 +95,7 @@ import org.olat.modules.lecture.Reason;
import org.olat.modules.lecture.RepositoryEntryLectureConfiguration; import org.olat.modules.lecture.RepositoryEntryLectureConfiguration;
import org.olat.modules.lecture.model.AbsenceNoticeImpl; import org.olat.modules.lecture.model.AbsenceNoticeImpl;
import org.olat.modules.lecture.model.AbsenceNoticeInfos; import org.olat.modules.lecture.model.AbsenceNoticeInfos;
import org.olat.modules.lecture.model.AbsenceNoticeRelationsAuditImpl;
import org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics; import org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics;
import org.olat.modules.lecture.model.IdentityRateWarning; import org.olat.modules.lecture.model.IdentityRateWarning;
import org.olat.modules.lecture.model.LectureBlockAndRollCall; import org.olat.modules.lecture.model.LectureBlockAndRollCall;
...@@ -321,12 +322,28 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De ...@@ -321,12 +322,28 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De
return auditLogDao.summaryFromXml(xml); return auditLogDao.summaryFromXml(xml);
} }
@Override
public String toAuditXml(AbsenceNotice absenceNotice) {
return auditLogDao.toXml(absenceNotice);
}
@Override
public AbsenceNotice toAuditAbsenceNotice(String xml) {
return auditLogDao.absenceNoticeFromXml(xml);
}
@Override @Override
public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message, public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message,
LectureBlockRef lectureBlock, LectureBlockRollCall rollCall, LectureBlockRef lectureBlock, LectureBlockRollCall rollCall,
RepositoryEntryRef entry, IdentityRef assessedIdentity, IdentityRef author) { RepositoryEntryRef entry, IdentityRef assessedIdentity, IdentityRef author) {
auditLogDao.auditLog(action, before, after, message, lectureBlock, rollCall, entry, assessedIdentity, author); auditLogDao.auditLog(action, before, after, message, lectureBlock, rollCall, entry, assessedIdentity, author);
} }
@Override
public void auditLog(LectureBlockAuditLog.Action action, String before, String after, String message,
AbsenceNoticeRef absenceNotice, IdentityRef assessedIdentity, IdentityRef author) {
auditLogDao.auditLog(action, before, after, message, absenceNotice, assessedIdentity, author);
}
@Override @Override
public List<LectureBlockAuditLog> getAuditLog(LectureBlockRef lectureBlock) { public List<LectureBlockAuditLog> getAuditLog(LectureBlockRef lectureBlock) {
...@@ -529,28 +546,40 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De ...@@ -529,28 +546,40 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De
if(authorized != null && authorized.booleanValue()) { if(authorized != null && authorized.booleanValue()) {
authorizer = actingIdentity; authorizer = actingIdentity;
} }
AbsenceNoticeRelationsAuditImpl after = new AbsenceNoticeRelationsAuditImpl();
AbsenceNotice notice = absenceNoticeDao.createAbsenceNotice(absentIdentity, type, target, start, end, AbsenceNotice notice = absenceNoticeDao.createAbsenceNotice(absentIdentity, type, target, start, end,
category, absenceRason, authorized, authorizer, actingIdentity); category, absenceRason, authorized, authorizer, actingIdentity);
if(entries != null && !entries.isEmpty()) { if(entries != null && !entries.isEmpty()) {
List<AbsenceNoticeToRepositoryEntry> relations = new ArrayList<>();
for(RepositoryEntry entry:entries) { for(RepositoryEntry entry:entries) {
absenceNoticeToRepositoryEntryDao.createRelation(notice, entry); AbsenceNoticeToRepositoryEntry noticeToEntry = absenceNoticeToRepositoryEntryDao.createRelation(notice, entry);
relations.add(noticeToEntry);
} }
after.setNoticeToEntries(relations);
} }
if(lectureBlocks != null && !lectureBlocks.isEmpty()) { if(lectureBlocks != null && !lectureBlocks.isEmpty()) {
List<AbsenceNoticeToLectureBlock> relations = new ArrayList<>();
for(LectureBlock lectureBlock:lectureBlocks) { for(LectureBlock lectureBlock:lectureBlocks) {
absenceNoticeToLectureBlockDao.createRelation(notice, lectureBlock); AbsenceNoticeToLectureBlock noticeToBlock = absenceNoticeToLectureBlockDao.createRelation(notice, lectureBlock);
relations.add(noticeToBlock);
} }
after.setNoticeToBlocks(relations);
} }
dbInstance.commit(); dbInstance.commit();
// calculate roll calls // calculate roll calls
calculateAbsencesOfRollcall(notice); calculateAbsencesOfRollcall(notice, null, after);
dbInstance.commit();
String afterXml = auditLogDao.toXml(after);
auditLog(Action.createAbsenceNoticeRelations, null, afterXml, null, notice, absentIdentity, actingIdentity);
return notice; return notice;
} }
@Override @Override
public AbsenceNotice updateAbsenceNotice(AbsenceNotice absenceNotice, Identity authorizer, public AbsenceNotice updateAbsenceNotice(AbsenceNotice absenceNotice, Identity authorizer,
List<RepositoryEntry> entries, List<LectureBlock> lectureBlocks) { List<RepositoryEntry> entries, List<LectureBlock> lectureBlocks, Identity actingIdentity) {
if(authorizer != null && absenceNotice.getAuthorizer() == null) { if(authorizer != null && absenceNotice.getAuthorizer() == null) {
((AbsenceNoticeImpl)absenceNotice).setAuthorizer(authorizer); ((AbsenceNoticeImpl)absenceNotice).setAuthorizer(authorizer);
...@@ -559,6 +588,12 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De ...@@ -559,6 +588,12 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De
List<AbsenceNoticeToLectureBlock> currentNoticeToBlocks = absenceNoticeToLectureBlockDao.getRelations(absenceNotice); List<AbsenceNoticeToLectureBlock> currentNoticeToBlocks = absenceNoticeToLectureBlockDao.getRelations(absenceNotice);
List<AbsenceNoticeToRepositoryEntry> currentNoticeToEntries = absenceNoticeToRepositoryEntryDao.getRelations(absenceNotice); List<AbsenceNoticeToRepositoryEntry> currentNoticeToEntries = absenceNoticeToRepositoryEntryDao.getRelations(absenceNotice);
AbsenceNoticeRelationsAuditImpl before = new AbsenceNoticeRelationsAuditImpl();
before.setNoticeToBlocks(currentNoticeToBlocks);
before.setNoticeToEntries(currentNoticeToEntries);
AbsenceNoticeRelationsAuditImpl after = new AbsenceNoticeRelationsAuditImpl();
if(notice.getNoticeTarget() == AbsenceNoticeTarget.allentries) { if(notice.getNoticeTarget() == AbsenceNoticeTarget.allentries) {
absenceNoticeToLectureBlockDao.deleteRelations(currentNoticeToBlocks); absenceNoticeToLectureBlockDao.deleteRelations(currentNoticeToBlocks);
absenceNoticeToRepositoryEntryDao.deleteRelations(currentNoticeToEntries); absenceNoticeToRepositoryEntryDao.deleteRelations(currentNoticeToEntries);
...@@ -566,47 +601,65 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De ...@@ -566,47 +601,65 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De
absenceNoticeToLectureBlockDao.deleteRelations(currentNoticeToBlocks); absenceNoticeToLectureBlockDao.deleteRelations(currentNoticeToBlocks);
if(entries != null) { if(entries != null) {
List<RepositoryEntry> currentEntries = new ArrayList<>(currentNoticeToEntries.size()); List<RepositoryEntry> currentEntries = new ArrayList<>(currentNoticeToEntries.size());
List<AbsenceNoticeToRepositoryEntry> relations = new ArrayList<>(currentNoticeToEntries);
for(AbsenceNoticeToRepositoryEntry currentNoticeToEntry:currentNoticeToEntries) { for(AbsenceNoticeToRepositoryEntry currentNoticeToEntry:currentNoticeToEntries) {
currentEntries.add(currentNoticeToEntry.getEntry()); currentEntries.add(currentNoticeToEntry.getEntry());
if(!entries.contains(currentNoticeToEntry.getEntry())) { if(entries.contains(currentNoticeToEntry.getEntry())) {
relations.add(currentNoticeToEntry);
} else {
absenceNoticeToRepositoryEntryDao.deleteRelation(currentNoticeToEntry); absenceNoticeToRepositoryEntryDao.deleteRelation(currentNoticeToEntry);
} }
} }
for(RepositoryEntry entry:entries) { for(RepositoryEntry entry:entries) {
if(!currentEntries.contains(entry)) { if(!currentEntries.contains(entry)) {
absenceNoticeToRepositoryEntryDao.createRelation(notice, entry); AbsenceNoticeToRepositoryEntry noticeToEntry = absenceNoticeToRepositoryEntryDao.createRelation(notice, entry);
relations.add(noticeToEntry);
} }
} }
after.setNoticeToEntries(relations);
} }
} else if(notice.getNoticeTarget() == AbsenceNoticeTarget.lectureblocks) { } else if(notice.getNoticeTarget() == AbsenceNoticeTarget.lectureblocks) {
absenceNoticeToRepositoryEntryDao.deleteRelations(currentNoticeToEntries); absenceNoticeToRepositoryEntryDao.deleteRelations(currentNoticeToEntries);
if(lectureBlocks != null) { if(lectureBlocks != null) {
List<LectureBlock> currentBlocks = new ArrayList<>(); List<LectureBlock> currentBlocks = new ArrayList<>();
List<AbsenceNoticeToLectureBlock> relations = new ArrayList<>();
for(AbsenceNoticeToLectureBlock currentNoticeToBlock:currentNoticeToBlocks) { for(AbsenceNoticeToLectureBlock currentNoticeToBlock:currentNoticeToBlocks) {
currentBlocks.add(currentNoticeToBlock.getLectureBlock()); currentBlocks.add(currentNoticeToBlock.getLectureBlock());
if(!lectureBlocks.contains(currentNoticeToBlock.getLectureBlock())) { if(lectureBlocks.contains(currentNoticeToBlock.getLectureBlock())) {
relations.add(currentNoticeToBlock);
} else {
absenceNoticeToLectureBlockDao.deleteRelation(currentNoticeToBlock); absenceNoticeToLectureBlockDao.deleteRelation(currentNoticeToBlock);
} }
} }
for(LectureBlock lectureBlock:lectureBlocks) { for(LectureBlock lectureBlock:lectureBlocks) {
if(!currentBlocks.contains(lectureBlock)) { if(!currentBlocks.contains(lectureBlock)) {
absenceNoticeToLectureBlockDao.createRelation(notice, lectureBlock); AbsenceNoticeToLectureBlock noticeToBlock = absenceNoticeToLectureBlockDao.createRelation(notice, lectureBlock);
relations.add(noticeToBlock);
} }
} }
after.setNoticeToBlocks(relations);
} }
} }
dbInstance.commit(); dbInstance.commit();
// calculate roll calls // calculate roll calls
calculateAbsencesOfRollcall(notice); calculateAbsencesOfRollcall(notice, before, after);
dbInstance.commit();
String beforeXml = auditLogDao.toXml(before);
String afterXml = auditLogDao.toXml(after);
auditLog(Action.updateAbsenceNoticeRelations, beforeXml, afterXml, null, absenceNotice, absenceNotice.getIdentity(), actingIdentity);
return notice; return notice;
} }
private void calculateAbsencesOfRollcall(AbsenceNotice notice) { private void calculateAbsencesOfRollcall(AbsenceNotice notice, AbsenceNoticeRelationsAuditImpl before, AbsenceNoticeRelationsAuditImpl after) {
List<LectureBlockRollCall> currentRollCalls = absenceNoticeDao.getRollCalls(notice); List<LectureBlockRollCall> currentRollCalls = absenceNoticeDao.getRollCalls(notice);
if(before != null) {
before.setRollCalls(currentRollCalls);
}
Set<LectureBlockRollCall> currentRollCallSet = new HashSet<>(currentRollCalls); Set<LectureBlockRollCall> currentRollCallSet = new HashSet<>(currentRollCalls);
List<LectureBlockRollCall> rollCalls; List<LectureBlockRollCall> rollCalls;
...@@ -621,15 +674,19 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De ...@@ -621,15 +674,19 @@ public class LectureServiceImpl implements LectureService, UserDataDeletable, De
if(currentRollCallSet.contains(rollCall)) { if(currentRollCallSet.contains(rollCall)) {
currentRollCallSet.remove(rollCall); currentRollCallSet.remove(rollCall);
} else { } else {
rollCall.setAbsenceNotice(notice);//TODO absences log rollCall.setAbsenceNotice(notice);
lectureBlockRollCallDao.update(rollCall); lectureBlockRollCallDao.update(rollCall);
} }
} }
for(LectureBlockRollCall toUnlink: currentRollCallSet) { for(LectureBlockRollCall toUnlink: currentRollCallSet) {
toUnlink.setAbsenceNotice(null);//TODO absences log toUnlink.setAbsenceNotice(null);
lectureBlockRollCallDao.update(toUnlink); lectureBlockRollCallDao.update(toUnlink);
} }
if(after != null) {
after.setRollCalls(rollCalls);
}
} }
@Override @Override
......
package org.olat.modules.lecture.model;
import java.util.ArrayList;
import java.util.List;
import org.olat.modules.lecture.AbsenceNoticeToLectureBlock;
import org.olat.modules.lecture.AbsenceNoticeToRepositoryEntry;
import org.olat.modules.lecture.LectureBlockRollCall;
/**
*
* Initial date: 20 août 2019<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class AbsenceNoticeRelationsAuditImpl {
private List<LectureBlockRollCall> rollCalls;
private List<AbsenceNoticeToLectureBlock> noticeToBlocks;
private List<AbsenceNoticeToRepositoryEntry> noticeToEntries;
public List<AbsenceNoticeToLectureBlock> getNoticeToBlocks() {
return noticeToBlocks;
}
public void setNoticeToBlocks(List<AbsenceNoticeToLectureBlock> noticeToBlocks) {
this.noticeToBlocks = noticeToBlocks == null ? new ArrayList<>(1) : new ArrayList<>(noticeToBlocks);
}
public List<AbsenceNoticeToRepositoryEntry> getNoticeToEntries() {
return noticeToEntries;
}
public void setNoticeToEntries(List<AbsenceNoticeToRepositoryEntry> noticeToEntries) {
this.noticeToEntries = noticeToEntries == null ? new ArrayList<>(1) : new ArrayList<>(noticeToEntries);
}
public List<LectureBlockRollCall> getRollCalls() {
return rollCalls;
}
public void setRollCalls(List<LectureBlockRollCall> rollCalls) {
this.rollCalls = rollCalls == null ? new ArrayList<>(1) : new ArrayList<>(rollCalls);
}
}
...@@ -67,6 +67,8 @@ public class LectureBlockAuditLogImpl implements LectureBlockAuditLog, Persistab ...@@ -67,6 +67,8 @@ public class LectureBlockAuditLogImpl implements LectureBlockAuditLog, Persistab
private Long lectureBlockKey; private Long lectureBlockKey;
@Column(name="fk_roll_call", nullable=true, insertable=true, updatable=false) @Column(name="fk_roll_call", nullable=true, insertable=true, updatable=false)
private Long rollCallKey; private Long rollCallKey;
@Column(name="fk_absence_notice", nullable=true, insertable=true, updatable=false)
private Long absenceNoticeKey;
@Column(name="fk_entry", nullable=true, insertable=true, updatable=false) @Column(name="fk_entry", nullable=true, insertable=true, updatable=false)
private Long entryKey; private Long entryKey;
...@@ -152,6 +154,15 @@ public class LectureBlockAuditLogImpl implements LectureBlockAuditLog, Persistab ...@@ -152,6 +154,15 @@ public class LectureBlockAuditLogImpl implements LectureBlockAuditLog, Persistab
this.entryKey = entryKey; this.entryKey = entryKey;
} }
@Override
public Long getAbsenceNoticeKey() {
return absenceNoticeKey;
}
public void setAbsenceNoticeKey(Long absenceNoticeKey) {
this.absenceNoticeKey = absenceNoticeKey;
}
@Override @Override
public Long getIdentityKey() { public Long getIdentityKey() {
return identityKey; return identityKey;
......
...@@ -37,6 +37,7 @@ import org.olat.modules.lecture.AbsenceNoticeTarget; ...@@ -37,6 +37,7 @@ import org.olat.modules.lecture.AbsenceNoticeTarget;
import org.olat.modules.lecture.AbsenceNoticeToLectureBlock; import org.olat.modules.lecture.AbsenceNoticeToLectureBlock;
import org.olat.modules.lecture.AbsenceNoticeToRepositoryEntry; import org.olat.modules.lecture.AbsenceNoticeToRepositoryEntry;
import org.olat.modules.lecture.LectureBlock; import org.olat.modules.lecture.LectureBlock;
import org.olat.modules.lecture.LectureBlockAuditLog.Action;
import org.olat.modules.lecture.LectureService; import org.olat.modules.lecture.LectureService;
import org.olat.modules.lecture.model.EditAbsenceNoticeWrapper; import org.olat.modules.lecture.model.EditAbsenceNoticeWrapper;
import org.olat.modules.lecture.ui.LecturesSecurityCallback; import org.olat.modules.lecture.ui.LecturesSecurityCallback;
...@@ -107,6 +108,8 @@ public class EditNoticeController extends FormBasicController { ...@@ -107,6 +108,8 @@ public class EditNoticeController extends FormBasicController {
datesAndLecturesCtrl.formOK(ureq); datesAndLecturesCtrl.formOK(ureq);
absenceNotice = lectureService.getAbsenceNotice(absenceNotice); absenceNotice = lectureService.getAbsenceNotice(absenceNotice);
String before = lectureService.toAuditXml(absenceNotice);
Boolean authorized = absenceNotice.getAbsenceAuthorized(); Boolean authorized = absenceNotice.getAbsenceAuthorized();
absenceNotice.setStartDate(noticeWrapper.getStartDate()); absenceNotice.setStartDate(noticeWrapper.getStartDate());
...@@ -130,13 +133,16 @@ public class EditNoticeController extends FormBasicController { ...@@ -130,13 +133,16 @@ public class EditNoticeController extends FormBasicController {
authorizer = getIdentity(); authorizer = getIdentity();
} }
absenceNotice = lectureService.updateAbsenceNotice(absenceNotice, authorizer, entries, lectureBlocks); absenceNotice = lectureService.updateAbsenceNotice(absenceNotice, authorizer, entries, lectureBlocks, getIdentity());
List<VFSItem> newFiles = new ArrayList<>(); List<VFSItem> newFiles = new ArrayList<>();
if(noticeWrapper.getTempUploadFolder() != null) { if(noticeWrapper.getTempUploadFolder() != null) {
newFiles.addAll(noticeWrapper.getTempUploadFolder().getItems(new VFSSystemItemFilter())); newFiles.addAll(noticeWrapper.getTempUploadFolder().getItems(new VFSSystemItemFilter()));
} }
lectureService.updateAbsenceNoticeAttachments(absenceNotice, newFiles, noticeWrapper.getAttachmentsToDelete()); absenceNotice = lectureService.updateAbsenceNoticeAttachments(absenceNotice, newFiles, noticeWrapper.getAttachmentsToDelete());
fireEvent(ureq, Event.CHANGED_EVENT); fireEvent(ureq, Event.CHANGED_EVENT);
String after = lectureService.toAuditXml(absenceNotice);
lectureService.auditLog(Action.updateAbsenceNotice, before, after, null, absenceNotice, noticeWrapper.getIdentity(), getIdentity());
} }
@Override @Override
......
...@@ -37,6 +37,7 @@ import org.olat.core.util.openxml.OpenXMLWorkbook; ...@@ -37,6 +37,7 @@ import org.olat.core.util.openxml.OpenXMLWorkbook;
import org.olat.core.util.openxml.OpenXMLWorkbookResource; import org.olat.core.util.openxml.OpenXMLWorkbookResource;
import org.olat.core.util.openxml.OpenXMLWorksheet; import org.olat.core.util.openxml.OpenXMLWorksheet;
import org.olat.core.util.openxml.OpenXMLWorksheet.Row; import org.olat.core.util.openxml.OpenXMLWorksheet.Row;
import org.olat.modules.lecture.AbsenceNotice;
import org.olat.modules.lecture.LectureBlock; import org.olat.modules.lecture.LectureBlock;
import org.olat.modules.lecture.LectureBlockAuditLog; import org.olat.modules.lecture.LectureBlockAuditLog;
import org.olat.modules.lecture.LectureBlockRef; import org.olat.modules.lecture.LectureBlockRef;
...@@ -157,6 +158,7 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook ...@@ -157,6 +158,7 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook
LectureBlock auditBlock = null; LectureBlock auditBlock = null;
LectureBlockRollCall auditRollCall = null; LectureBlockRollCall auditRollCall = null;
LectureParticipantSummary auditSummary = null; LectureParticipantSummary auditSummary = null;
AbsenceNotice absenceNotice = null;
if(logEntry.getRollCallKey() != null) { if(logEntry.getRollCallKey() != null) {
auditRollCall = getAuditRollCall(logEntry.getAfter()); auditRollCall = getAuditRollCall(logEntry.getAfter());
} }
...@@ -167,6 +169,9 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook ...@@ -167,6 +169,9 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook
auditSummary = getAuditLectureParticipantSummary(logEntry.getAfter()); auditSummary = getAuditLectureParticipantSummary(logEntry.getAfter());
} }
} }
if(logEntry.getAbsenceNoticeKey() != null) {
absenceNotice = getAuditAbsenceNotice(logEntry.getAfter());
}
if(auditBlock != null) { if(auditBlock != null) {
if(auditBlock.getStatus() == null) { if(auditBlock.getStatus() == null) {
...@@ -181,7 +186,25 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook ...@@ -181,7 +186,25 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook
pos += 4; pos += 4;
} }
if(auditRollCall != null) { if(absenceNotice != null) {
Long assessedIdentityKey = logEntry.getIdentityKey();
String fullname = userManager.getUserDisplayName(assessedIdentityKey);
row.addCell(pos++, fullname);
pos += 2;// attendedNumber, absentNumber
if(authorizedAbsenceEnabled) {
if(absenceNotice.getAbsenceAuthorized() != null && absenceNotice.getAbsenceAuthorized().booleanValue()) {
row.addCell(pos++, "x");
} else {
pos++;
}
row.addCell(pos++, absenceNotice.getAbsenceReason(), null);
}
if(absenceNotice.getAbsenceCategory() != null) {
row.addCell(pos++, absenceNotice.getAbsenceCategory().getTitle(), null);
} else {
pos++;
}
} else if(auditRollCall != null) {
Long assessedIdentityKey = logEntry.getIdentityKey(); Long assessedIdentityKey = logEntry.getIdentityKey();
String fullname = userManager.getUserDisplayName(assessedIdentityKey); String fullname = userManager.getUserDisplayName(assessedIdentityKey);
row.addCell(pos++, fullname); row.addCell(pos++, fullname);
...@@ -267,6 +290,10 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook ...@@ -267,6 +290,10 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook
return lectureService.toAuditLectureParticipantSummary(xml); return lectureService.toAuditLectureParticipantSummary(xml);
} }
private AbsenceNotice getAuditAbsenceNotice(String xml) {
return lectureService.toAuditAbsenceNotice(xml);
}
protected void cacheRepositoryEntry(RepositoryEntry entry) { protected void cacheRepositoryEntry(RepositoryEntry entry) {
if(entry != null) { if(entry != null) {
displayNames.put(entry.getKey(), entry.getDisplayname()); displayNames.put(entry.getKey(), entry.getDisplayname());
...@@ -274,6 +301,7 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook ...@@ -274,6 +301,7 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook
} }
private String getRepositoryEntryDisplayName(Long entryKey) { private String getRepositoryEntryDisplayName(Long entryKey) {
if(entryKey == null) return null;
String displayName = displayNames.get(entryKey); String displayName = displayNames.get(entryKey);
if(displayName == null) { if(displayName == null) {
......
/** /**
* <a href="http://www.openolat.org"> * <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br> * OpenOLAT - Online Learning and Training</a><br>
* <p> * <p>
...@@ -46,6 +47,7 @@ import org.olat.core.util.mail.MailerResult; ...@@ -46,6 +47,7 @@ import org.olat.core.util.mail.MailerResult;
import org.olat.core.util.vfs.VFSItem; import org.olat.core.util.vfs.VFSItem;
import org.olat.core.util.vfs.filters.VFSSystemItemFilter; import org.olat.core.util.vfs.filters.VFSSystemItemFilter;
import org.olat.modules.lecture.AbsenceNotice; import org.olat.modules.lecture.AbsenceNotice;
import org.olat.modules.lecture.LectureBlockAuditLog.Action;
import org.olat.modules.lecture.LectureService; import org.olat.modules.lecture.LectureService;
import org.olat.modules.lecture.model.EditAbsenceNoticeWrapper; import org.olat.modules.lecture.model.EditAbsenceNoticeWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -87,8 +89,10 @@ public class AbsenceNoticeFinishStepCallback implements StepRunnerCallback { ...@@ -87,8 +89,10 @@ public class AbsenceNoticeFinishStepCallback implements StepRunnerCallback {
if(noticeWrapper.getTempUploadFolder() != null) { if(noticeWrapper.getTempUploadFolder() != null) {
newFiles.addAll(noticeWrapper.getTempUploadFolder().getItems(new VFSSystemItemFilter())); newFiles.addAll(noticeWrapper.getTempUploadFolder().getItems(new VFSSystemItemFilter()));
} }
lectureService.updateAbsenceNoticeAttachments(notice, newFiles, noticeWrapper.getAttachmentsToDelete()); notice = lectureService.updateAbsenceNoticeAttachments(notice, newFiles, noticeWrapper.getAttachmentsToDelete());
String after = lectureService.toAuditXml(notice);
lectureService.auditLog(Action.createAbsenceNotice, null, after, null, notice, absentIdentity, ureq.getIdentity());
} }
if(noticeWrapper.getTempUploadFolder() != null) { if(noticeWrapper.getTempUploadFolder() != null) {
......
...@@ -69,4 +69,8 @@ alter table o_lecture_block_roll_call add column l_absence_notice_lectures varch ...@@ -69,4 +69,8 @@ alter table o_lecture_block_roll_call add column l_absence_notice_lectures varch
alter table o_lecture_block_roll_call add column fk_absence_notice bigint default null; alter table o_lecture_block_roll_call add column fk_absence_notice bigint default null;
alter table o_lecture_block_roll_call add constraint rollcall_to_notice_idx foreign key (fk_absence_notice) references o_lecture_absence_notice (id); alter table o_lecture_block_roll_call add constraint rollcall_to_notice_idx foreign key (fk_absence_notice) references o_lecture_absence_notice (id);
alter table o_lecture_block_audit_log add column fk_absence_notice bigint default null;
...@@ -2579,6 +2579,7 @@ create table o_lecture_block_audit_log ( ...@@ -2579,6 +2579,7 @@ create table o_lecture_block_audit_log (
l_message mediumtext, l_message mediumtext,
fk_lecture_block bigint, fk_lecture_block bigint,
fk_roll_call bigint, fk_roll_call bigint,
fk_absence_notice bigint,
fk_entry bigint, fk_entry bigint,
fk_identity bigint, fk_identity bigint,
fk_author bigint, fk_author bigint,
......
...@@ -72,3 +72,7 @@ alter table o_lecture_block_roll_call add l_absence_notice_lectures varchar(128) ...@@ -72,3 +72,7 @@ alter table o_lecture_block_roll_call add l_absence_notice_lectures varchar(128)
alter table o_lecture_block_roll_call add fk_absence_notice number(20) default null; alter table o_lecture_block_roll_call add fk_absence_notice number(20) default null;
alter table o_lecture_block_roll_call add constraint rollcall_to_notice_idx foreign key (fk_absence_notice) references o_lecture_absence_notice (id); alter table o_lecture_block_roll_call add constraint rollcall_to_notice_idx foreign key (fk_absence_notice) references o_lecture_absence_notice (id);
create index idx_rollcall_to_notice_idx on o_lecture_block_roll_call (fk_absence_notice); create index idx_rollcall_to_notice_idx on o_lecture_block_roll_call (fk_absence_notice);
alter table o_lecture_block_audit_log add fk_absence_notice number(20) default null;
...@@ -2658,6 +2658,7 @@ create table o_lecture_block_audit_log ( ...@@ -2658,6 +2658,7 @@ create table o_lecture_block_audit_log (
l_message CLOB, l_message CLOB,
fk_lecture_block number(20), fk_lecture_block number(20),
fk_roll_call number(20), fk_roll_call number(20),
fk_absence_notice number(20),
fk_entry number(20), fk_entry number(20),
fk_identity number(20), fk_identity number(20),
fk_author number(20), fk_author number(20),
......
...@@ -72,6 +72,8 @@ alter table o_lecture_block_roll_call add column fk_absence_notice bigint defaul ...@@ -72,6 +72,8 @@ alter table o_lecture_block_roll_call add column fk_absence_notice bigint defaul
alter table o_lecture_block_roll_call add constraint rollcall_to_notice_idx foreign key (fk_absence_notice) references o_lecture_absence_notice (id); alter table o_lecture_block_roll_call add constraint rollcall_to_notice_idx foreign key (fk_absence_notice) references o_lecture_absence_notice (id);
create index idx_rollcall_to_notice_idx on o_lecture_block_roll_call (fk_absence_notice); create index idx_rollcall_to_notice_idx on o_lecture_block_roll_call (fk_absence_notice);
alter table o_lecture_block_audit_log add column fk_absence_notice int8 default null;
......
...@@ -2605,6 +2605,7 @@ create table o_lecture_block_audit_log ( ...@@ -2605,6 +2605,7 @@ create table o_lecture_block_audit_log (
l_message text, l_message text,
fk_lecture_block int8, fk_lecture_block int8,
fk_roll_call int8, fk_roll_call int8,
fk_absence_notice int8,
fk_entry int8, fk_entry int8,
fk_identity int8, fk_identity int8,
fk_author int8, fk_author int8,
......
...@@ -21,11 +21,17 @@ package org.olat.modules.lecture.manager; ...@@ -21,11 +21,17 @@ package org.olat.modules.lecture.manager;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.olat.commons.calendar.CalendarUtils;
import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DB;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.modules.lecture.AbsenceCategory;
import org.olat.modules.lecture.AbsenceNotice;
import org.olat.modules.lecture.AbsenceNoticeTarget;
import org.olat.modules.lecture.AbsenceNoticeType;
import org.olat.modules.lecture.LectureBlock; import org.olat.modules.lecture.LectureBlock;
import org.olat.modules.lecture.LectureBlockAuditLog; import org.olat.modules.lecture.LectureBlockAuditLog;
import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntry;
...@@ -46,6 +52,10 @@ public class LectureBlockAuditLogDAOTest extends OlatTestCase { ...@@ -46,6 +52,10 @@ public class LectureBlockAuditLogDAOTest extends OlatTestCase {
@Autowired @Autowired
private LectureBlockDAO lectureBlockDao; private LectureBlockDAO lectureBlockDao;
@Autowired @Autowired
private AbsenceNoticeDAO absenceNoticeDao;
@Autowired
private AbsenceCategoryDAO absenceCategoryDao;
@Autowired
private LectureBlockAuditLogDAO lectureBlockAuditLogDao; private LectureBlockAuditLogDAO lectureBlockAuditLogDao;
@Test @Test
...@@ -139,4 +149,27 @@ public class LectureBlockAuditLogDAOTest extends OlatTestCase { ...@@ -139,4 +149,27 @@ public class LectureBlockAuditLogDAOTest extends OlatTestCase {
String xml = lectureBlockAuditLogDao.toXml(lectureBlock); String xml = lectureBlockAuditLogDao.toXml(lectureBlock);
Assert.assertNotNull(xml); Assert.assertNotNull(xml);
} }
@Test
public void xmlAuditLog_absenceNotice() {
String title = UUID.randomUUID().toString();
String description = "Long absence";
AbsenceCategory absenceCategory = absenceCategoryDao.createAbsenceCategory(title, description);
dbInstance.commitAndCloseSession();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("absent-1");
Identity notifier = JunitTestHelper.createAndPersistIdentityAsRndUser("notifier-1");
Identity authorizer = JunitTestHelper.createAndPersistIdentityAsRndUser("authorizer-1");
Date start = CalendarUtils.startOfDay(new Date());
Date end = CalendarUtils.endOfDay(new Date());
AbsenceNotice notice = absenceNoticeDao.createAbsenceNotice(identity, AbsenceNoticeType.absence, AbsenceNoticeTarget.lectureblocks,
start, end, absenceCategory, "A very good reason", Boolean.TRUE, authorizer, notifier);
dbInstance.commitAndCloseSession();
String xml = lectureBlockAuditLogDao.toXml(notice);
System.out.println(xml);
Assert.assertNotNull(xml);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment