Search in sources :

Example 46 with PropertyManager

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

the class CourseNodePasswordManagerImpl method deleteAllPasswordsFor.

/**
 * @see de.bps.course.nodes.CourseNodePasswordManager#deleteAllPasswordsFor(java.lang.Long)
 */
public void deleteAllPasswordsFor(OLATResourceable ores) {
    PropertyManager pm = PropertyManager.getInstance();
    List<Property> properties = pm.listProperties(null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, ores.getResourceableId(), null);
    for (Property p : properties) {
        Long nodeId = p.getResourceTypeId();
        Long courseId = p.getLongValue();
        removeAnswers(nodeId, courseId);
        pm.deleteProperty(p);
    }
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 47 with PropertyManager

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

the class DBPersistentLockManager method releasePersistentLock.

/**
 * @see org.olat.core.util.locks.PersistentLockManager#releasePersistentLock(org.olat.core.util.locks.LockEntry)
 */
@Override
public void releasePersistentLock(LockResult le) {
    // synchronisation is solved in the LockManager
    String derivedLockString = ((LockResultImpl) le).getLockEntry().getKey();
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString);
    if (p == null)
        throw new AssertException("could not release lock: no lock in db, " + derivedLockString);
    Identity ident = le.getOwner();
    Long ownerKey = p.getLongValue();
    if (!ownerKey.equals(ident.getKey()))
        throw new AssertException("user " + ident.getName() + " cannot release lock belonging to user with key " + ownerKey + " on resourcestring " + derivedLockString);
    pm.deleteProperty(p);
}
Also used : AssertException(org.olat.core.logging.AssertException) PropertyManager(org.olat.properties.PropertyManager) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property)

Example 48 with PropertyManager

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

the class StatisticUpdateManagerImpl method getAndUpdateLastUpdated.

@Override
public long getAndUpdateLastUpdated(long lastUpdated) {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, STATISTICS_PROPERTIES_CATEGORY, LAST_UPDATED_PROPERTY_NAME);
    if (p == null) {
        Property newp = pm.createPropertyInstance(null, null, null, STATISTICS_PROPERTIES_CATEGORY, LAST_UPDATED_PROPERTY_NAME, null, lastUpdated, null, null);
        pm.saveProperty(newp);
        return -1;
    } else {
        final long result = p.getLongValue();
        p.setLongValue(lastUpdated);
        pm.saveProperty(p);
        return result;
    }
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 49 with PropertyManager

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

the class StatisticUpdateManagerImpl method getLastUpdated.

@Override
public long getLastUpdated() {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, STATISTICS_PROPERTIES_CATEGORY, LAST_UPDATED_PROPERTY_NAME);
    if (p == null) {
        return -1;
    } else {
        return p.getLongValue();
    }
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 50 with PropertyManager

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

the class MessageListController method doExportForumItem.

private void doExportForumItem(UserRequest ureq, MessageView messageToMove) {
    if (foCallback.mayEditMessageAsModerator()) {
        StepRunnerCallback finish = new FinishCallback();
        Translator trans = Util.createPackageTranslator(Step_1_SelectCourse.class, getLocale());
        Step start = new Step_1_SelectCourse(ureq);
        Message message = forumManager.getMessageById(messageToMove.getKey());
        String wizardTitle = trans.translate("title.wizard.movethread", new String[] { message.getTitle() });
        exportCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, wizardTitle, "o_sel_bulk_assessment_wizard");
        StepsRunContext runContext = exportCtrl.getRunContext();
        // can be threadtop message
        runContext.put(SendMailStepForm.MESSAGE_TO_MOVE, message);
        // starting thread
        runContext.put(SendMailStepForm.START_THREADTOP, message.getThreadtop() == null ? message : message.getThreadtop());
        // get start course
        PropertyManager propertyManager = PropertyManager.getInstance();
        Long forumResourceableId = forum.getResourceableId();
        Property forumproperty = propertyManager.getPropertyByLongValue(forumResourceableId, FOCourseNode.FORUM_KEY);
        if (forumproperty != null) {
            Long resourcetypeId = forumproperty.getResourceTypeId();
            String resourcetypeName = forumproperty.getResourceTypeName();
            OLATResourceable olatResourceable = olatManager.findResourceable(resourcetypeId, resourcetypeName);
            RepositoryEntry startCourse = repositoryManager.lookupRepositoryEntry(olatResourceable, false);
            if (startCourse != null) {
                runContext.put(SendMailStepForm.START_COURSE, startCourse);
            }
        }
        listenTo(exportCtrl);
        getWindowControl().pushAsModalDialog(exportCtrl.getInitialComponent());
    } else {
        showWarning("may.not.move.message");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) PropertyManager(org.olat.properties.PropertyManager) Step(org.olat.core.gui.control.generic.wizard.Step) RepositoryEntry(org.olat.repository.RepositoryEntry) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Step_1_SelectCourse(org.olat.modules.fo.export.Step_1_SelectCourse) Translator(org.olat.core.gui.translator.Translator) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Property(org.olat.properties.Property) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) FinishCallback(org.olat.modules.fo.export.FinishCallback)

Aggregations

PropertyManager (org.olat.properties.PropertyManager)50 Property (org.olat.properties.Property)48 Test (org.junit.Test)10 Identity (org.olat.core.id.Identity)8 DBRuntimeException (org.olat.core.logging.DBRuntimeException)8 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)6 ArrayList (java.util.ArrayList)4 GET (javax.ws.rs.GET)4 Produces (javax.ws.rs.Produces)4 UserSession (org.olat.core.util.UserSession)4 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)4 OLATResourceable (org.olat.core.id.OLATResourceable)3 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)3 File (java.io.File)2 IOException (java.io.IOException)2 Calendar (java.util.Calendar)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2