Search in sources :

Example 1 with InfoMessageImpl

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;
}
Also used : InfoMessageImpl(org.olat.commons.info.model.InfoMessageImpl)

Example 2 with InfoMessageImpl

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;
}
Also used : InfoMessageImpl(org.olat.commons.info.model.InfoMessageImpl)

Example 3 with InfoMessageImpl

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;
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) CollaborationTools(org.olat.collaboration.CollaborationTools) InfoMessageImpl(org.olat.commons.info.model.InfoMessageImpl) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property)

Example 4 with InfoMessageImpl

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);
    }
}
Also used : InfoMessage(org.olat.commons.info.InfoMessage) InfoMessageImpl(org.olat.commons.info.model.InfoMessageImpl) Identity(org.olat.core.id.Identity)

Example 5 with InfoMessageImpl

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;
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) CollaborationTools(org.olat.collaboration.CollaborationTools) InfoMessageImpl(org.olat.commons.info.model.InfoMessageImpl) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property)

Aggregations

InfoMessageImpl (org.olat.commons.info.model.InfoMessageImpl)6 Identity (org.olat.core.id.Identity)4 CollaborationTools (org.olat.collaboration.CollaborationTools)2 InfoMessage (org.olat.commons.info.InfoMessage)2 Translator (org.olat.core.gui.translator.Translator)2 Property (org.olat.properties.Property)2