content: /*
   *  Copyright (C) 2010-2012, 2019 Stichting Akvo (Akvo Foundation)
   *
   *  This file is part of Akvo FLOW.
   *
   *  Akvo FLOW is free software: you can redistribute it and modify it under the terms of
   *  the GNU Affero General Public License (AGPL) as published by the Free Software Foundation,
   *  either version 3 of the License or any later version.
   *
   *  Akvo FLOW is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
   *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   *  See the GNU Affero General Public License included below for more details.
   *
   *  The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>.
   */
  
  package org.akvo.flow.domain;
  
  import javax.jdo.annotations.PersistenceCapable;
  
  import com.gallatinsystems.framework.domain.BaseDomain;
  import com.google.appengine.api.datastore.Text;
  
  /**
   * persistent object for storing system messages that are to be displayed to the user.
   * 
   * @author Christopher Fagiani
   */
  @PersistenceCapable
  public class Message extends BaseDomain {
  
      private static final long serialVersionUID = -7829182245275723095L;
  
      private String actionAbout;
      private Long objectId;
      private Text message;
      private String objectTitle;
      private String shortMessage;
      private String transactionUUID;
      private String userName;
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getObjectTitle() {
          return objectTitle;
      }
  
      public void setObjectTitle(String objectTitle) {
          this.objectTitle = objectTitle;
      }
  
      public String getActionAbout() {
          return actionAbout;
      }
  
      public void setActionAbout(String actionAbout) {
          this.actionAbout = actionAbout;
      }
  
      public Long getObjectId() {
          return objectId;
      }
  
      public void setObjectId(Long objectId) {
          this.objectId = objectId;
      }
  
      public String getMessage() {
          if (message != null) {
              return message.getValue();
          } else {
              return null;
          }
      }
  
      public void setMessage(String message) {
          this.message = new Text(message);
      }
  
      public void setTransactionUUID(String transactionUUID) {
          this.transactionUUID = transactionUUID;
      }
  
      public String getTransactionUUID() {
          return transactionUUID;
      }
  
      public String getShortMessage() {
          return shortMessage;
      }
  
      //Max 1500 chars
      //TODO If the UI displayed the long msg instead if it exists, we should clear shortMessage.
      public void setShortMessage(String shortMessage) {
          if (shortMessage.length() > 1500) {
              setMessage(shortMessage);
              this.shortMessage = shortMessage.substring(0, 1495) + " ...";
          } else {
              this.shortMessage = shortMessage;
          }
      }
  
  }
  