SEBSERV-556 fixed notify exam template deletion to moodle
This commit is contained in:
parent
b0617803f1
commit
ee89d2a24e
2 changed files with 24 additions and 20 deletions
|
@ -14,10 +14,19 @@ import org.springframework.context.ApplicationEvent;
|
|||
|
||||
public class ExamTemplateChangeEvent extends ApplicationEvent {
|
||||
|
||||
public static enum ChangeState {
|
||||
CREATED,
|
||||
MODIFIED,
|
||||
DELETED,
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -7239994198026689531L;
|
||||
|
||||
public ExamTemplateChangeEvent(final ExamTemplate source) {
|
||||
public final ChangeState changeState;
|
||||
|
||||
public ExamTemplateChangeEvent(final ExamTemplate source, final ChangeState changeState) {
|
||||
super(source);
|
||||
this.changeState = changeState;
|
||||
}
|
||||
|
||||
public ExamTemplate getExamTemplate() {
|
||||
|
|
|
@ -119,36 +119,20 @@ public class ExamTemplateController extends EntityController<ExamTemplate, ExamT
|
|||
|
||||
@Override
|
||||
protected Result<ExamTemplate> notifyCreated(final ExamTemplate entity) {
|
||||
return notifyExamTemplateChange(entity);
|
||||
return notifyExamTemplateChange(entity, ExamTemplateChangeEvent.ChangeState.CREATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<ExamTemplate> notifySaved(final ExamTemplate entity) {
|
||||
return notifyExamTemplateChange(entity);
|
||||
}
|
||||
|
||||
private Result<ExamTemplate> notifyExamTemplateChange(final ExamTemplate entity) {
|
||||
try {
|
||||
applicationEventPublisher.publishEvent(new ExamTemplateChangeEvent(entity));
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to notify ExamTemplate change: ", e);
|
||||
}
|
||||
return Result.of(entity);
|
||||
return notifyExamTemplateChange(entity, ExamTemplateChangeEvent.ChangeState.MODIFIED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<Pair<ExamTemplate, EntityProcessingReport>> notifyDeleted(final Pair<ExamTemplate, EntityProcessingReport> pair) {
|
||||
notifyExamTemplateChange(pair.a, ExamTemplateChangeEvent.ChangeState.DELETED);
|
||||
return super.notifyDeleted(pair);
|
||||
}
|
||||
|
||||
private void notifyChanged(final ExamTemplate examTemplate) {
|
||||
try {
|
||||
applicationEventPublisher.publishEvent(new ExamTemplateChangeEvent(examTemplate));
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to notify Exam Template change: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
private ExamTemplate applyQuitPasswordIfNeeded(final ExamTemplate entity) {
|
||||
if (entity.configTemplateId != null) {
|
||||
try {
|
||||
|
@ -637,4 +621,15 @@ public class ExamTemplateController extends EntityController<ExamTemplate, ExamT
|
|||
return indicatorTemplate;
|
||||
}
|
||||
|
||||
private Result<ExamTemplate> notifyExamTemplateChange(
|
||||
final ExamTemplate entity,
|
||||
final ExamTemplateChangeEvent.ChangeState changeState) {
|
||||
try {
|
||||
applicationEventPublisher.publishEvent(new ExamTemplateChangeEvent(entity, changeState));
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to notify ExamTemplate change: ", e);
|
||||
}
|
||||
return Result.of(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue