Search in sources :

Example 41 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method saveAssessmentID.

/**
 * @param courseNode
 * @param assessedIdentity
 * @param assessmentID
 * @param coursePropManager
 */
void saveAssessmentID(CourseNode courseNode, Identity assessedIdentity, Long assessmentID, CoursePropertyManager coursePropManager) {
    if (assessmentID != null) {
        Property assessmentIDProperty = coursePropManager.findCourseNodeProperty(courseNode, assessedIdentity, null, ASSESSMENT_ID);
        if (assessmentIDProperty == null) {
            assessmentIDProperty = coursePropManager.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ASSESSMENT_ID, null, assessmentID, null, null);
            coursePropManager.saveProperty(assessmentIDProperty);
        } else {
            assessmentIDProperty.setLongValue(assessmentID);
            coursePropManager.updateProperty(assessmentIDProperty);
        }
        // add to cache
        putPropertyIntoCache(assessedIdentity, assessmentIDProperty);
    }
}
Also used : Property(org.olat.properties.Property)

Example 42 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method saveNodeComment.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeComment(org.olat.course.nodes.CourseNode,
 *      org.olat.core.id.Identity, org.olat.core.id.Identity,
 *      java.lang.String)
 */
public void saveNodeComment(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final String comment) {
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {

        public void execute() {
            Property commentProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, COMMENT);
            if (commentProperty == null) {
                commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COMMENT, null, null, null, comment);
                cpm.saveProperty(commentProperty);
            } else {
                commentProperty.setTextValue(comment);
                cpm.updateProperty(commentProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, commentProperty);
        }
    });
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, COMMENT + " set to: " + comment);
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_USER_COMMENT_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_USERCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiUserComment, "", StringHelper.stripLineBreaks(comment)));
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 43 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_8_1_0 method getEfficiencyStatement.

private List<Property> getEfficiencyStatement(int firstResult) {
    StringBuilder query = new StringBuilder();
    query.append("select p from ").append(Property.class.getName()).append(" as p ");
    query.append(" where p.category='efficiencyStatement' order by p.key");
    DBQuery dbQuery = dbInstance.createQuery(query.toString());
    dbQuery.setFirstResult(firstResult);
    dbQuery.setMaxResults(REPO_ENTRIES_BATCH_SIZE);
    @SuppressWarnings("unchecked") List<Property> props = dbQuery.list();
    return props;
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery) Property(org.olat.properties.Property)

Example 44 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_9_4_0 method upgradeDisplayMembers.

private boolean upgradeDisplayMembers(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_DISPLAY_MEMBERS)) {
        int counter = 0;
        List<BusinessGroupImpl> groups;
        do {
            groups = findGroups(counter, BATCH_SIZE);
            for (BusinessGroupImpl group : groups) {
                Property prop = findProperty(group);
                if (prop != null) {
                    boolean changed = false;
                    Long internValue = prop.getLongValue();
                    if (internValue != null && internValue.longValue() > 0) {
                        long value = internValue.longValue();
                        boolean owners = (value & showOwnersVal) == showOwnersVal;
                        boolean participants = (value & showPartipsVal) == showPartipsVal;
                        boolean waiting = (value & showWaitingListVal) == showWaitingListVal;
                        group.setOwnersVisibleIntern(owners);
                        group.setParticipantsVisibleIntern(participants);
                        group.setWaitingListVisibleIntern(waiting);
                        changed = true;
                    }
                    String publicValue = prop.getStringValue();
                    if (publicValue != null && publicValue.length() > 0 && Character.isDigit(publicValue.toCharArray()[0])) {
                        try {
                            int value = Integer.parseInt(publicValue);
                            boolean owners = (value & showOwnersVal) == showOwnersVal;
                            boolean participants = (value & showPartipsVal) == showPartipsVal;
                            boolean waiting = (value & showWaitingListVal) == showWaitingListVal;
                            group.setOwnersVisiblePublic(owners);
                            group.setParticipantsVisiblePublic(participants);
                            group.setWaitingListVisiblePublic(waiting);
                        } catch (NumberFormatException e) {
                            log.error("", e);
                        }
                        changed = true;
                    }
                    Float downloadValue = prop.getFloatValue();
                    if (downloadValue != null && downloadValue != 0.0f) {
                        float value = downloadValue.floatValue();
                        // paranoid check
                        if (value > 0.9 && value < 1.1) {
                            group.setDownloadMembersLists(true);
                            changed = true;
                        } else if (value < -0.9 && value > -1.1) {
                            group.setDownloadMembersLists(true);
                            changed = true;
                        }
                    }
                    if (changed) {
                        prop.setCategory("configMoved");
                        dbInstance.getCurrentEntityManager().merge(group);
                    }
                }
            }
            counter += groups.size();
            log.audit("Business groups processed: " + groups.size());
            dbInstance.commitAndCloseSession();
        } while (groups.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_DISPLAY_MEMBERS, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : BusinessGroupImpl(org.olat.group.BusinessGroupImpl) Property(org.olat.properties.Property)

Example 45 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class CustomDBController method addCustomDb.

private void addCustomDb(final String category) {
    final ICourse course = CourseFactory.loadCourse(courseKey);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(course, new SyncerExecutor() {

        @Override
        public void execute() {
            CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
            CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
            Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
            if (p == null) {
                p = cpm.createCourseNodePropertyInstance(rootNode, null, null, CustomDBMainController.CUSTOM_DB, null, null, null, category);
                cpm.saveProperty(p);
            } else {
                String currentDbs = p.getTextValue();
                p.setTextValue(currentDbs + ":" + category);
                cpm.updateProperty(p);
            }
        }
    });
}
Also used : ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) CourseNode(org.olat.course.nodes.CourseNode) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

Property (org.olat.properties.Property)270 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)62 PropertyManager (org.olat.properties.PropertyManager)48 Identity (org.olat.core.id.Identity)36 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)36 ArrayList (java.util.ArrayList)24 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)22 BusinessGroup (org.olat.group.BusinessGroup)18 File (java.io.File)16 ICourse (org.olat.course.ICourse)16 Translator (org.olat.core.gui.translator.Translator)14 AssertException (org.olat.core.logging.AssertException)14 CourseNode (org.olat.course.nodes.CourseNode)14 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)14 Test (org.junit.Test)12 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)12 XStream (com.thoughtworks.xstream.XStream)10 HashMap (java.util.HashMap)10 List (java.util.List)10