use of org.olat.properties.Property in project openolat by klemens.
the class CollaborationTools method getForum.
public Forum getForum() {
final ForumManager fom = ForumManager.getInstance();
final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
Property forumProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
Forum forum;
if (forumProperty != null) {
forum = fom.loadForum(forumProperty.getLongValue());
} else {
forum = coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Forum>() {
@Override
public Forum execute() {
Forum aforum;
Long forumKey;
Property forumKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
if (forumKeyProperty == null) {
// First call of forum, create new forum and save
aforum = fom.addAForum();
forumKey = aforum.getKey();
if (log.isDebug()) {
log.debug("created new forum in collab tools: foid::" + forumKey.longValue() + " for ores::" + ores.getResourceableTypeName() + "/" + ores.getResourceableId());
}
forumKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM, null, forumKey, null, null);
npm.saveProperty(forumKeyProperty);
} else {
// Forum does already exist, load forum with key from properties
forumKey = forumKeyProperty.getLongValue();
aforum = fom.loadForum(forumKey);
if (aforum == null) {
throw new AssertException("Unable to load forum with key " + forumKey.longValue() + " for ores " + ores.getResourceableTypeName() + " with key " + ores.getResourceableId());
}
if (log.isDebug()) {
log.debug("loading forum in collab tools from properties: foid::" + forumKey.longValue() + " for ores::" + ores.getResourceableTypeName() + "/" + ores.getResourceableId());
}
}
return aforum;
}
});
}
return forum;
}
use of org.olat.properties.Property in project openolat by klemens.
the class CollaborationTools method createOrUpdateProperty.
/**
* creates the property if non-existing, or updates the existing property to
* the supplied values. Real changes are made persistent immediately.
*
* @param selectedTool
* @param toolValue
*/
private void createOrUpdateProperty(final String selectedTool, final boolean toolValue) {
Boolean cv = cacheToolStates.get(selectedTool);
if (cv != null && cv.booleanValue() == toolValue) {
// nice, cache saved a needless update
return;
}
// handle Boolean Values via String Field in Property DB Table
final String toolValueStr = toolValue ? TRUE : FALSE;
final PropertyManager pm = PropertyManager.getInstance();
coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
@Override
public void execute() {
// was: synchronized (CollaborationTools.class) {
Property property = getPropertyOf(selectedTool);
if (property == null) {
// not existing -> create it
property = pm.createPropertyInstance(null, null, ores, PROP_CAT_BG_COLLABTOOLS, selectedTool, null, null, toolValueStr, null);
} else {
// if existing -> update to desired value
property.setStringValue(toolValueStr);
}
// create a room if needed
if (toolValue && TOOL_OPENMEETINGS.equals(selectedTool)) {
openOpenMeetingsRoom();
}
// property becomes persistent
pm.saveProperty(property);
}
});
this.dirty = true;
cacheToolStates.put(selectedTool, Boolean.valueOf(toolValue));
}
use of org.olat.properties.Property in project openolat by klemens.
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;
}
use of org.olat.properties.Property in project openolat by klemens.
the class CollaborationTools method saveNews.
/**
* @param news
*/
public void saveNews(String news) {
NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS);
if (property == null) {
// create a new one
Property nP = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS, null, null, null, news);
npm.saveProperty(nP);
} else {
// modify the existing one
property.setTextValue(news);
npm.updateProperty(property);
}
}
use of org.olat.properties.Property in project openolat by klemens.
the class CollaborationTools method archiveForum.
private void archiveForum(String archivFilePath) {
Property forumKeyProperty = NarrowedPropertyManager.getInstance(ores).findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
if (forumKeyProperty != null) {
VFSContainer archiveContainer = new LocalFolderImpl(new File(archivFilePath));
String archiveForumName = "del_forum_" + forumKeyProperty.getLongValue();
VFSContainer archiveForumContainer = archiveContainer.createChildContainer(archiveForumName);
ForumFormatter ff = new ForumRTFFormatter(archiveForumContainer, false, I18nModule.getDefaultLocale());
ForumArchiveManager.getInstance().applyFormatter(ff, forumKeyProperty.getLongValue(), null);
}
}
Aggregations