Search in sources :

Example 1 with Message

use of org.apereo.portal.i18n.Message in project uPortal by Jasig.

the class MessageEntityTranslationController method postTranslation.

@ResourceMapping
@RequestMapping(params = "action=postTranslation")
public ModelAndView postTranslation(@RequestParam("id") String code, @RequestParam("locale") String localeStr, @RequestParam("value") String value) {
    final Locale locale = LocaleManager.parseLocale(localeStr);
    if (locale != null && StringUtils.hasText(code) && StringUtils.hasText(value)) {
        final Message message = messageDao.getMessage(code, locale);
        if (message != null) {
            message.setValue(value);
            messageDao.updateMessage(message);
        } else {
            // if message is not found in the backend storage, a new one must be created
            messageDao.createMessage(code, locale, value);
        }
    }
    return new ModelAndView("json");
}
Also used : Locale(java.util.Locale) Message(org.apereo.portal.i18n.Message) ModelAndView(org.springframework.web.portlet.ModelAndView) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Message

use of org.apereo.portal.i18n.Message in project uPortal by Jasig.

the class JpaMessageDao method deleteMessage.

@Override
@PortalTransactional
public void deleteMessage(Message message) {
    Validate.notNull(message, "message can not be null");
    final Message msg;
    final EntityManager entityManager = this.getEntityManager();
    if (entityManager.contains(message)) {
        msg = message;
    } else {
        msg = entityManager.merge(message);
    }
    entityManager.remove(msg);
}
Also used : EntityManager(javax.persistence.EntityManager) Message(org.apereo.portal.i18n.Message)

Example 3 with Message

use of org.apereo.portal.i18n.Message in project uPortal by Jasig.

the class JpaMessageDao method createMessage.

@Override
@PortalTransactional
public Message createMessage(String code, Locale locale, String value) {
    Validate.notNull(code, "code can not be null");
    final Message msg = new MessageImpl(code, locale, value);
    this.getEntityManager().persist(msg);
    return msg;
}
Also used : Message(org.apereo.portal.i18n.Message)

Example 4 with Message

use of org.apereo.portal.i18n.Message in project uPortal by Jasig.

the class MessageEntityTranslationController method getEntity.

@ResourceMapping
@RequestMapping(params = "action=getEntity")
public ModelAndView getEntity(@RequestParam("id") String code, @RequestParam("locale") String localeStr) {
    final Locale locale = LocaleManager.parseLocale(localeStr);
    final Message message = messageDao.getMessage(code, locale);
    return new ModelAndView("json", "message", message);
}
Also used : Locale(java.util.Locale) Message(org.apereo.portal.i18n.Message) ModelAndView(org.springframework.web.portlet.ModelAndView) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Message (org.apereo.portal.i18n.Message)4 Locale (java.util.Locale)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.portlet.ModelAndView)2 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)2 EntityManager (javax.persistence.EntityManager)1