Search in sources :

Example 76 with Property

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

the class CollaborationTools method lookupFolderAccess.

public Long lookupFolderAccess() {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FOLDER_ACCESS);
    if (property == null) {
        // no entry
        return null;
    }
    // read the long value of the existing property
    return property.getLongValue();
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 77 with Property

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

the class CollaborationTools method getPropertyOf.

Property getPropertyOf(String selectedTool) {
    PropertyManager pm = PropertyManager.getInstance();
    Property property = pm.findProperty(null, null, ores, PROP_CAT_BG_COLLABTOOLS, selectedTool);
    Boolean res;
    if (property == null) {
        // meaning false
        res = Boolean.FALSE;
    } else {
        String val = property.getStringValue();
        res = val.equals(TRUE) ? Boolean.TRUE : Boolean.FALSE;
    }
    cacheToolStates.put(selectedTool, res);
    return property;
}
Also used : PropertyManager(org.olat.properties.PropertyManager) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 78 with Property

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

the class CollaborationTools method deleteTools.

/**
 * delete all CollaborationTools stuff from the database, which is related to
 * the calling OLATResourceable.
 */
public void deleteTools(BusinessGroup businessGroupTodelete) {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    /*
		 * delete the forum, if existing
		 */
    ForumManager fom = ForumManager.getInstance();
    Property forumKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
    if (forumKeyProperty != null) {
        // if there was a forum, delete it
        Long forumKey = forumKeyProperty.getLongValue();
        if (forumKey == null)
            throw new AssertException("property had no longValue, prop:" + forumKeyProperty);
        fom.deleteForum(forumKey);
    }
    /*
		 * delete the folder, if existing
		 */
    OlatRootFolderImpl vfsContainer = new OlatRootFolderImpl(getFolderRelPath(), null);
    File fFolderRoot = vfsContainer.getBasefile();
    if (fFolderRoot.exists()) {
        FileUtils.deleteDirsAndFiles(fFolderRoot, true, true);
    }
    /*
		 * delete the wiki if existing
		 */
    VFSContainer rootContainer = WikiManager.getInstance().getWikiRootContainer(ores);
    if (rootContainer != null)
        rootContainer.delete();
    /*
		 * Delete calendar if exists
		 */
    if (businessGroupTodelete != null) {
        CoreSpringFactory.getImpl(ImportToCalendarManager.class).deleteGroupImportedCalendars(businessGroupTodelete);
        CoreSpringFactory.getImpl(CalendarManager.class).deleteGroupCalendar(businessGroupTodelete);
    }
    /*
		 * delete chatRoom
		 */
    // no cleanup needed, automatically done when last user exits the room
    /*
		 * delete all Properties defining enabled/disabled CollabTool XY and the
		 * news content
		 */
    npm.deleteProperties(null, null, PROP_CAT_BG_COLLABTOOLS, null);
    /*
		 * Delete OpenMeetings room
		 */
    OpenMeetingsModule omModule = CoreSpringFactory.getImpl(OpenMeetingsModule.class);
    if (omModule.isEnabled()) {
        OpenMeetingsManager omManager = CoreSpringFactory.getImpl(OpenMeetingsManager.class);
        try {
            omManager.deleteAll(ores, null, null);
        } catch (OpenMeetingsException e) {
            log.error("A room could not be deleted for group: " + ores, e);
        }
    }
    /*
		 * and last but not least the cache is reseted
		 */
    cacheToolStates.clear();
    this.dirty = true;
}
Also used : AssertException(org.olat.core.logging.AssertException) VFSContainer(org.olat.core.util.vfs.VFSContainer) OpenMeetingsModule(org.olat.modules.openmeetings.OpenMeetingsModule) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ForumManager(org.olat.modules.fo.manager.ForumManager) OpenMeetingsException(org.olat.modules.openmeetings.manager.OpenMeetingsException) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property) File(java.io.File) OpenMeetingsManager(org.olat.modules.openmeetings.manager.OpenMeetingsManager)

Example 79 with Property

use of org.olat.properties.Property in project openolat by klemens.

the class DbStorage method updatePreferencesFor.

@Override
public void updatePreferencesFor(Preferences prefs, Identity identity) {
    String props = xstream.toXML(prefs);
    Property property = getPreferencesProperty(identity);
    if (property == null) {
        property = PropertyManager.getInstance().createPropertyInstance(identity, null, null, null, DbStorage.USER_PROPERTY_KEY, null, null, null, props);
        // also save the properties to db, here (strentini)
        // fixes the "non-present gui preferences" for new users, or where guiproperties were manually deleted
        PropertyManager.getInstance().saveProperty(property);
    } else {
        property.setTextValue(props);
        PropertyManager.getInstance().updateProperty(property);
    }
}
Also used : Property(org.olat.properties.Property)

Example 80 with Property

use of org.olat.properties.Property in project openolat by klemens.

the class GetInitialEnrollmentDateFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    /*
		 * argument check
		 */
    if (inStack.length > 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
    } else if (inStack.length < 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
    }
    /*
		 * argument type check
		 */
    if (!(inStack[0] instanceof String))
        return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
    String nodeId = (String) inStack[0];
    /*
		 * check reference integrity
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        if (!cev.existsNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
        }
        if (!cev.isEnrollmentNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notenrollment.coursenodeid", "solution.chooseenrollment"));
        }
        // Allow self-referencing but do not allow dependencies to parents as they create cycles.
        if (!nodeId.equals(cev.getCurrentCourseNodeId())) {
            cev.addSoftReference("courseNodeId", nodeId, false);
        }
        // return a valid value to continue with condition evaluation test
        return defaultValue();
    }
    /*
		 * the real function evaluation which is used during run time
		 */
    CourseNode node = getUserCourseEnv().getCourseEnvironment().getRunStructure().getNode(nodeId);
    // invalid node id's return still a valid double
    // TODO fg: check with editor tree model DONE: the above checks ensure only
    // valid node references
    // if (node == null) return new Double(Double.NEGATIVE_INFINITY);
    CoursePropertyManager pm = getUserCourseEnv().getCourseEnvironment().getCoursePropertyManager();
    Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
    Property firstTime = pm.findCourseNodeProperty(node, identity, null, ENCourseNode.PROPERTY_INITIAL_ENROLLMENT_DATE);
    if (firstTime != null) {
        String firstTimeMillis = firstTime.getStringValue();
        return Double.valueOf(firstTimeMillis);
    } else {
        // what to do in case of no date available??? -> return date in the future
        return new Double(Double.POSITIVE_INFINITY);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) 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