use of org.olat.properties.NarrowedPropertyManager in project OpenOLAT by OpenOLAT.
the class GroupPortfolioIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
if (!(businessObj instanceof BusinessGroup))
throw new AssertException("businessObj must be BusinessGroup");
BusinessGroup businessGroup = (BusinessGroup) businessObj;
NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
// Check if portfolio map property exist
if (mapKeyProperty != null) {
Long mapKey = mapKeyProperty.getLongValue();
String version = mapKeyProperty.getStringValue();
if (version == null || !version.equals("2")) {
PortfolioStructure map = frontendManager.loadPortfolioStructureByKey(mapKey);
if (map != null) {
SearchResourceContext resourceContext = new SearchResourceContext(parentResourceContext);
resourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLPORTFOLIO);
resourceContext.setDocumentType(TYPE);
resourceContext.setParentContextType(GroupDocument.TYPE);
resourceContext.setParentContextName(businessGroup.getName());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
}
use of org.olat.properties.NarrowedPropertyManager in project openolat by klemens.
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();
}
use of org.olat.properties.NarrowedPropertyManager 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.NarrowedPropertyManager 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.NarrowedPropertyManager in project OpenOLAT by OpenOLAT.
the class CollaborationTools method saveCalendarAccess.
public void saveCalendarAccess(Long calendarAccess) {
NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_CALENDAR_ACCESS);
if (property == null) {
// create a new one
Property nP = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_CALENDAR_ACCESS, null, calendarAccess, null, null);
npm.saveProperty(nP);
} else {
// modify the existing one
property.setLongValue(calendarAccess);
npm.updateProperty(property);
}
}
Aggregations