Search in sources :

Example 1 with ILoggingAction

use of org.olat.core.logging.activity.ILoggingAction in project OpenOLAT by OpenOLAT.

the class CheckboxEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    checkbox.setTitle(titleEl.getValue());
    String releaseKey = releaseEl.getSelectedKey();
    checkbox.setRelease(CheckboxReleaseEnum.valueOf(releaseKey));
    String labelKey = labelEl.getSelectedKey();
    checkbox.setLabel(CheckboxLabelEnum.valueOf(labelKey));
    if (awardPointEl.isAtLeastSelected(1)) {
        Float points = null;
        try {
            points = new Float(Float.parseFloat(pointsEl.getValue()));
        } catch (NumberFormatException e) {
        // check in validation
        }
        checkbox.setPoints(points);
    } else {
        checkbox.setPoints(null);
    }
    checkbox.setDescription(descriptionEl.getValue());
    if (Boolean.TRUE.equals(deleteFile)) {
        checkbox.setFilename(null);
        VFSContainer container = getFileContainer();
        for (VFSItem chd : container.getItems()) {
            chd.delete();
        }
    }
    File uploadedFile = fileEl.getUploadFile();
    if (uploadedFile != null) {
        String filename = fileEl.getUploadFileName();
        checkbox.setFilename(filename);
        VFSContainer container = getFileContainer();
        VFSLeaf leaf = container.createChildLeaf(filename);
        try (InputStream inStream = new FileInputStream(uploadedFile)) {
            VFSManager.copyContent(inStream, leaf);
        } catch (IOException e) {
            logError("", e);
        }
    }
    if (courseNode != null) {
        ILoggingAction action = newCheckbox ? CourseLoggingAction.CHECKLIST_CHECKBOX_CREATED : CourseLoggingAction.CHECKLIST_CHECKBOX_UPDATED;
        ThreadLocalUserActivityLogger.log(action, getClass(), LoggingResourceable.wrap(courseNode), LoggingResourceable.wrapNonOlatResource(StringResourceableType.checkbox, checkbox.getCheckboxId(), checkbox.getTitle()));
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) VFSItem(org.olat.core.util.vfs.VFSItem) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with ILoggingAction

use of org.olat.core.logging.activity.ILoggingAction in project OpenOLAT by OpenOLAT.

the class CertificatesOptionsController method doChangeConfig.

private void doChangeConfig(UserRequest ureq) {
    OLATResourceable courseOres = entry.getOlatResource();
    if (CourseFactory.isCourseEditSessionOpen(courseOres.getResourceableId())) {
        showWarning("error.editoralreadylocked", new String[] { "???" });
        return;
    }
    ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
    courseConfig = course.getCourseEnvironment().getCourseConfig();
    boolean enableEfficiencyStatment = efficencyEl.isSelected(0);
    boolean updateStatement = courseConfig.isEfficencyStatementEnabled() != enableEfficiencyStatment;
    courseConfig.setEfficencyStatementIsEnabled(enableEfficiencyStatment);
    Collection<String> certificationOptions = pdfCertificatesEl.getSelectedKeys();
    courseConfig.setAutomaticCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.auto.name()));
    courseConfig.setManualCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.manual.name()));
    if (selectedTemplate != null) {
        Long templateId = selectedTemplate.getKey();
        courseConfig.setCertificateTemplate(templateId);
    } else {
        courseConfig.setCertificateTemplate(null);
    }
    boolean recertificationEnabled = reCertificationEl.isEnabled() && reCertificationEl.isAtLeastSelected(1);
    courseConfig.setRecertificationEnabled(recertificationEnabled);
    if (recertificationEnabled) {
        int timelapse = reCertificationTimelapseEl.getIntValue();
        courseConfig.setRecertificationTimelapse(timelapse);
        if (reCertificationTimelapseUnitEl.isOneSelected()) {
            String selectedUnit = reCertificationTimelapseUnitEl.getSelectedKey();
            RecertificationTimeUnit timeUnit = RecertificationTimeUnit.valueOf(selectedUnit);
            courseConfig.setRecertificationTimelapseUnit(timeUnit);
        } else {
            courseConfig.setRecertificationTimelapseUnit(RecertificationTimeUnit.month);
        }
    } else {
        courseConfig.setRecertificationTimelapse(0);
        courseConfig.setRecertificationTimelapseUnit(null);
    }
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    if (updateStatement) {
        if (enableEfficiencyStatment) {
            // first create the efficiencies, send event to agency (all courses add link)
            RepositoryEntry courseRe = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            List<Identity> identitiesWithData = course.getCourseEnvironment().getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(null);
            efficiencyStatementManager.updateEfficiencyStatements(courseRe, identitiesWithData);
        } else {
            // delete really the efficiencies of the users.
            RepositoryEntry courseRepoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            efficiencyStatementManager.deleteEfficiencyStatementsFromCourse(courseRepoEntry.getKey());
        }
        // inform everybody else
        EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
        CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigType.efficiencyStatement, course.getResourceableId());
        eventBus.fireEventToListenersOf(courseConfigEvent, course);
        ILoggingAction loggingAction = enableEfficiencyStatment ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : CourseConfigEvent(org.olat.course.config.CourseConfigEvent) OLATResourceable(org.olat.core.id.OLATResourceable) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) EventBus(org.olat.core.util.event.EventBus) RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) Identity(org.olat.core.id.Identity)

Example 3 with ILoggingAction

use of org.olat.core.logging.activity.ILoggingAction in project openolat by klemens.

the class CheckboxEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    checkbox.setTitle(titleEl.getValue());
    String releaseKey = releaseEl.getSelectedKey();
    checkbox.setRelease(CheckboxReleaseEnum.valueOf(releaseKey));
    String labelKey = labelEl.getSelectedKey();
    checkbox.setLabel(CheckboxLabelEnum.valueOf(labelKey));
    if (awardPointEl.isAtLeastSelected(1)) {
        Float points = null;
        try {
            points = new Float(Float.parseFloat(pointsEl.getValue()));
        } catch (NumberFormatException e) {
        // check in validation
        }
        checkbox.setPoints(points);
    } else {
        checkbox.setPoints(null);
    }
    checkbox.setDescription(descriptionEl.getValue());
    if (Boolean.TRUE.equals(deleteFile)) {
        checkbox.setFilename(null);
        VFSContainer container = getFileContainer();
        for (VFSItem chd : container.getItems()) {
            chd.delete();
        }
    }
    File uploadedFile = fileEl.getUploadFile();
    if (uploadedFile != null) {
        String filename = fileEl.getUploadFileName();
        checkbox.setFilename(filename);
        VFSContainer container = getFileContainer();
        VFSLeaf leaf = container.createChildLeaf(filename);
        try (InputStream inStream = new FileInputStream(uploadedFile)) {
            VFSManager.copyContent(inStream, leaf);
        } catch (IOException e) {
            logError("", e);
        }
    }
    if (courseNode != null) {
        ILoggingAction action = newCheckbox ? CourseLoggingAction.CHECKLIST_CHECKBOX_CREATED : CourseLoggingAction.CHECKLIST_CHECKBOX_UPDATED;
        ThreadLocalUserActivityLogger.log(action, getClass(), LoggingResourceable.wrap(courseNode), LoggingResourceable.wrapNonOlatResource(StringResourceableType.checkbox, checkbox.getCheckboxId(), checkbox.getTitle()));
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) VFSItem(org.olat.core.util.vfs.VFSItem) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 4 with ILoggingAction

use of org.olat.core.logging.activity.ILoggingAction in project openolat by klemens.

the class CertificatesOptionsController method doChangeConfig.

private void doChangeConfig(UserRequest ureq) {
    OLATResourceable courseOres = entry.getOlatResource();
    if (CourseFactory.isCourseEditSessionOpen(courseOres.getResourceableId())) {
        showWarning("error.editoralreadylocked", new String[] { "???" });
        return;
    }
    ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
    courseConfig = course.getCourseEnvironment().getCourseConfig();
    boolean enableEfficiencyStatment = efficencyEl.isSelected(0);
    boolean updateStatement = courseConfig.isEfficencyStatementEnabled() != enableEfficiencyStatment;
    courseConfig.setEfficencyStatementIsEnabled(enableEfficiencyStatment);
    Collection<String> certificationOptions = pdfCertificatesEl.getSelectedKeys();
    courseConfig.setAutomaticCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.auto.name()));
    courseConfig.setManualCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.manual.name()));
    if (selectedTemplate != null) {
        Long templateId = selectedTemplate.getKey();
        courseConfig.setCertificateTemplate(templateId);
    } else {
        courseConfig.setCertificateTemplate(null);
    }
    boolean recertificationEnabled = reCertificationEl.isEnabled() && reCertificationEl.isAtLeastSelected(1);
    courseConfig.setRecertificationEnabled(recertificationEnabled);
    if (recertificationEnabled) {
        int timelapse = reCertificationTimelapseEl.getIntValue();
        courseConfig.setRecertificationTimelapse(timelapse);
        if (reCertificationTimelapseUnitEl.isOneSelected()) {
            String selectedUnit = reCertificationTimelapseUnitEl.getSelectedKey();
            RecertificationTimeUnit timeUnit = RecertificationTimeUnit.valueOf(selectedUnit);
            courseConfig.setRecertificationTimelapseUnit(timeUnit);
        } else {
            courseConfig.setRecertificationTimelapseUnit(RecertificationTimeUnit.month);
        }
    } else {
        courseConfig.setRecertificationTimelapse(0);
        courseConfig.setRecertificationTimelapseUnit(null);
    }
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    if (updateStatement) {
        if (enableEfficiencyStatment) {
            // first create the efficiencies, send event to agency (all courses add link)
            RepositoryEntry courseRe = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            List<Identity> identitiesWithData = course.getCourseEnvironment().getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(null);
            efficiencyStatementManager.updateEfficiencyStatements(courseRe, identitiesWithData);
        } else {
            // delete really the efficiencies of the users.
            RepositoryEntry courseRepoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            efficiencyStatementManager.deleteEfficiencyStatementsFromCourse(courseRepoEntry.getKey());
        }
        // inform everybody else
        EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
        CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigType.efficiencyStatement, course.getResourceableId());
        eventBus.fireEventToListenersOf(courseConfigEvent, course);
        ILoggingAction loggingAction = enableEfficiencyStatment ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : CourseConfigEvent(org.olat.course.config.CourseConfigEvent) OLATResourceable(org.olat.core.id.OLATResourceable) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) EventBus(org.olat.core.util.event.EventBus) RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) Identity(org.olat.core.id.Identity)

Example 5 with ILoggingAction

use of org.olat.core.logging.activity.ILoggingAction in project OpenOLAT by OpenOLAT.

the class CourseOptionsController method doChangeConfig.

private void doChangeConfig(UserRequest ureq) {
    OLATResourceable courseOres = entry.getOlatResource();
    ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
    courseConfig = course.getCourseEnvironment().getCourseConfig();
    boolean menuEnabled = menuEl.isSelected(0);
    courseConfig.setMenuEnabled(menuEnabled);
    boolean toolbarEnabled = toolbarEl.isSelected(0);
    courseConfig.setToolbarEnabled(toolbarEnabled);
    boolean enableSearch = searchEl.isSelected(0);
    boolean updateSearch = courseConfig.isCourseSearchEnabled() != enableSearch;
    courseConfig.setCourseSearchEnabled(enableSearch && toolbarEnabled);
    boolean enableChat = chatEl.isSelected(0);
    boolean updateChat = courseConfig.isChatEnabled() != enableChat;
    courseConfig.setChatIsEnabled(enableChat && toolbarEnabled);
    boolean enableCalendar = calendarEl == null ? false : calendarEl.isSelected(0);
    boolean updateCalendar = courseConfig.isCalendarEnabled() != enableCalendar && calendarModule.isEnableCourseToolCalendar();
    courseConfig.setCalendarEnabled(enableCalendar && toolbarEnabled);
    String currentGlossarySoftKey = courseConfig.getGlossarySoftKey();
    RepositoryEntry glossary = (RepositoryEntry) glossaryNameEl.getUserObject();
    String newGlossarySoftKey = (glossary == null || !toolbarEnabled) ? null : glossary.getSoftkey();
    boolean updateGlossary = (currentGlossarySoftKey == null && newGlossarySoftKey != null) || (currentGlossarySoftKey != null && newGlossarySoftKey == null) || (newGlossarySoftKey != null && !newGlossarySoftKey.equals(currentGlossarySoftKey));
    courseConfig.setGlossarySoftKey(newGlossarySoftKey);
    String currentFolderSoftKey = courseConfig.getSharedFolderSoftkey();
    RepositoryEntry folder = (RepositoryEntry) folderNameEl.getUserObject();
    String newFolderSoftKey = folder == null ? null : folder.getSoftkey();
    boolean updateFolder = (currentFolderSoftKey == null && newFolderSoftKey != null) || (currentFolderSoftKey != null && newFolderSoftKey == null) || (currentFolderSoftKey != null && !currentFolderSoftKey.equals(newFolderSoftKey));
    courseConfig.setSharedFolderSoftkey(newFolderSoftKey);
    if (folderReadOnlyEl.isEnabled()) {
        courseConfig.setSharedFolderReadOnlyMount(folderReadOnlyEl.isAtLeastSelected(1));
    } else {
        courseConfig.setSharedFolderReadOnlyMount(true);
    }
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    if (updateSearch) {
        ILoggingAction loggingAction = enableSearch ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.search, course.getResourceableId()), course);
    }
    if (updateChat) {
        ILoggingAction loggingAction = enableChat ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_IM_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_IM_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.chat, course.getResourceableId()), course);
    }
    if (updateCalendar) {
        ILoggingAction loggingAction = enableCalendar ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_CALENDAR_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_CALENDAR_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(), OresHelper.lookupType(CalendarManager.class));
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.calendar, course.getResourceableId()), course);
    }
    if (updateGlossary) {
        ILoggingAction loggingAction = (newGlossarySoftKey == null) ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_GLOSSARY_DISABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_GLOSSARY_ENABLED;
        LoggingResourceable lri = null;
        if (newGlossarySoftKey != null) {
            lri = LoggingResourceable.wrapNonOlatResource(StringResourceableType.glossarySoftKey, newGlossarySoftKey, newGlossarySoftKey);
        } else if (currentGlossarySoftKey != null) {
            lri = LoggingResourceable.wrapNonOlatResource(StringResourceableType.glossarySoftKey, currentGlossarySoftKey, currentGlossarySoftKey);
        }
        if (lri != null) {
            ThreadLocalUserActivityLogger.log(loggingAction, getClass(), lri);
        }
        // remove references
        List<Reference> repoRefs = referenceManager.getReferences(course);
        for (Reference ref : repoRefs) {
            if (ref.getUserdata().equals(GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER)) {
                referenceManager.delete(ref);
            }
        }
        // update references
        if (glossary != null) {
            referenceManager.addReference(course, glossary.getOlatResource(), GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER);
        }
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.glossary, course.getResourceableId()), course);
    }
    if (updateFolder) {
        List<Reference> repoRefs = referenceManager.getReferences(course);
        for (Reference ref : repoRefs) {
            if (ref.getUserdata().equals(SharedFolderManager.SHAREDFOLDERREF)) {
                referenceManager.delete(ref);
            }
        }
        if (folder != null) {
            referenceManager.addReference(course, folder.getOlatResource(), SharedFolderManager.SHAREDFOLDERREF);
            ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_SHARED_FOLDER_REMOVED, getClass(), LoggingResourceable.wrapBCFile(folder.getDisplayname()));
        } else {
            ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_SHARED_FOLDER_ADDED, getClass(), LoggingResourceable.wrapBCFile(""));
        }
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CourseConfigEvent(org.olat.course.config.CourseConfigEvent) OLATResourceable(org.olat.core.id.OLATResourceable) Reference(org.olat.resource.references.Reference) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent) LoggingResourceable(org.olat.util.logging.activity.LoggingResourceable)

Aggregations

ILoggingAction (org.olat.core.logging.activity.ILoggingAction)6 OLATResourceable (org.olat.core.id.OLATResourceable)4 ICourse (org.olat.course.ICourse)4 CourseConfigEvent (org.olat.course.config.CourseConfigEvent)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 CalendarManager (org.olat.commons.calendar.CalendarManager)2 CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)2 Identity (org.olat.core.id.Identity)2 EventBus (org.olat.core.util.event.EventBus)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 RecertificationTimeUnit (org.olat.course.certificate.RecertificationTimeUnit)2 Reference (org.olat.resource.references.Reference)2 LoggingResourceable (org.olat.util.logging.activity.LoggingResourceable)2