use of org.olat.commons.info.model.InfoMessageImpl in project OpenOLAT by OpenOLAT.
the class InfoMessageManagerImpl method createInfoMessage.
@Override
public InfoMessage createInfoMessage(OLATResourceable ores, String subPath, String businessPath, Identity author) {
if (ores == null)
throw new NullPointerException("OLAT Resourceable cannot be null");
InfoMessageImpl info = new InfoMessageImpl();
info.setResId(ores.getResourceableId());
info.setResName(ores.getResourceableTypeName());
info.setResSubPath(subPath);
info.setBusinessPath(normalizeBusinessPath(businessPath));
info.setAuthor(author);
return info;
}
use of org.olat.commons.info.model.InfoMessageImpl in project openolat by klemens.
the class InfoMessageManagerImpl method createInfoMessage.
@Override
public InfoMessage createInfoMessage(OLATResourceable ores, String subPath, String businessPath, Identity author) {
if (ores == null)
throw new NullPointerException("OLAT Resourceable cannot be null");
InfoMessageImpl info = new InfoMessageImpl();
info.setResId(ores.getResourceableId());
info.setResName(ores.getResourceableTypeName());
info.setResSubPath(subPath);
info.setBusinessPath(normalizeBusinessPath(businessPath));
info.setAuthor(author);
return info;
}
use of org.olat.commons.info.model.InfoMessageImpl in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_4_0 method processInfoMessage.
/**
* @param business group
* @return true if upgrade went well
*/
private boolean processInfoMessage(BusinessGroup businessGroup) {
// iterate all groups and translate their singular info message to the new standard
try {
String businessPath = "[BusinessGroup:" + businessGroup.getKey() + "][toolmsg:0]";
int messageCount = infoMessageManager.countInfoMessageByResource(businessGroup.getResource(), InfoMessageFrontendManager.businessGroupResSubPath, businessPath, null, null);
// only upgrade if business group has not any info messages of the new kind yet
if (1 > messageCount) {
CollaborationTools collabTools = toolsF.getOrCreateCollaborationTools(businessGroup);
Property property = collabTools.lookupNewsDBEntry();
if (property != null) {
// collabTools.lookupNews();
String oldNews = property.getTextValue();
Identity author;
List<Identity> members = groupService.getMembers(businessGroup, GroupRoles.owner.name(), GroupRoles.coach.name());
if (members == null || (members != null && members.isEmpty())) {
author = deletionManager.getAdminUserIdentity();
} else {
author = members.get(0);
}
InfoMessageImpl infoMessage = (InfoMessageImpl) infoMessageManager.createInfoMessage(businessGroup.getResource(), InfoMessageFrontendManager.businessGroupResSubPath, businessPath, author);
Translator trans = Util.createPackageTranslator(CollaborationTools.class, I18nModule.getDefaultLocale());
String title = trans.translate("news.content");
infoMessage.setTitle(title);
infoMessage.setMessage(oldNews);
infoMessage.setCreationDate(property.getCreationDate());
infoMessageManager.saveInfoMessage(infoMessage);
} else {
log.warn("The group " + businessGroup.getName() + " does not have an info message");
}
}
return true;
} catch (Exception e) {
log.warn("Update InfoMessage for " + businessGroup.getName() + " failed", e);
return false;
}
}
use of org.olat.commons.info.model.InfoMessageImpl in project OpenOLAT by OpenOLAT.
the class InfoMessageFrontendManagerImpl method updateInfoMessagesOfIdentity.
@Override
public void updateInfoMessagesOfIdentity(BusinessGroupRef businessGroup, IdentityRef identity) {
List<InfoMessage> infoMessages = infoMessageManager.loadInfoMessagesOfIdentity(businessGroup, identity);
for (InfoMessage infoMessage : infoMessages) {
Identity author = infoMessage.getAuthor();
if (author != null && author.getKey().equals(identity.getKey())) {
((InfoMessageImpl) infoMessage).setAuthor(null);
}
Identity modifier = infoMessage.getModifier();
if (modifier != null && modifier.getKey().equals(identity.getKey())) {
infoMessage.setModifier(null);
}
infoMessageManager.saveInfoMessage(infoMessage);
}
}
use of org.olat.commons.info.model.InfoMessageImpl in project openolat by klemens.
the class OLATUpgrade_11_4_0 method processInfoMessage.
/**
* @param business group
* @return true if upgrade went well
*/
private boolean processInfoMessage(BusinessGroup businessGroup) {
// iterate all groups and translate their singular info message to the new standard
try {
String businessPath = "[BusinessGroup:" + businessGroup.getKey() + "][toolmsg:0]";
int messageCount = infoMessageManager.countInfoMessageByResource(businessGroup.getResource(), InfoMessageFrontendManager.businessGroupResSubPath, businessPath, null, null);
// only upgrade if business group has not any info messages of the new kind yet
if (1 > messageCount) {
CollaborationTools collabTools = toolsF.getOrCreateCollaborationTools(businessGroup);
Property property = collabTools.lookupNewsDBEntry();
if (property != null) {
// collabTools.lookupNews();
String oldNews = property.getTextValue();
Identity author;
List<Identity> members = groupService.getMembers(businessGroup, GroupRoles.owner.name(), GroupRoles.coach.name());
if (members == null || (members != null && members.isEmpty())) {
author = deletionManager.getAdminUserIdentity();
} else {
author = members.get(0);
}
InfoMessageImpl infoMessage = (InfoMessageImpl) infoMessageManager.createInfoMessage(businessGroup.getResource(), InfoMessageFrontendManager.businessGroupResSubPath, businessPath, author);
Translator trans = Util.createPackageTranslator(CollaborationTools.class, I18nModule.getDefaultLocale());
String title = trans.translate("news.content");
infoMessage.setTitle(title);
infoMessage.setMessage(oldNews);
infoMessage.setCreationDate(property.getCreationDate());
infoMessageManager.saveInfoMessage(infoMessage);
} else {
log.warn("The group " + businessGroup.getName() + " does not have an info message");
}
}
return true;
} catch (Exception e) {
log.warn("Update InfoMessage for " + businessGroup.getName() + " failed", e);
return false;
}
}
Aggregations