/*
 *  Copyright (C) 2015 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.events;

import java.util.Date;

import javax.jdo.annotations.PersistenceCapable;

import com.gallatinsystems.framework.domain.BaseDomain;
import com.google.appengine.api.datastore.Text;

/**
 * used to implement a queue for events
 */
@PersistenceCapable
public class EventQueue extends BaseDomain {

    private static final long serialVersionUID = 89484684617286776L;
    private Text payload;
    private Boolean synced = false;

    public EventQueue(Date timestamp, String eventString) {
        this.payload = new Text(eventString);
        this.setLastUpdateDateTime(timestamp);
        this.setCreatedDateTime(timestamp);
    }

    }


    public Text getPayload() {
        return payload;
    }

    public void setPayload(Text payload) {
        this.payload = payload;
    }

    public Boolean getSynced() {
        return synced;
    }

    public void setSynced(Boolean synced) {
        this.synced = synced;
    }

}

@@ -799,24 +799,69 @@
 ceCapable;%0A%0A
+import com.gallatinsystems.common.Constants;%0A
 import com.g
@@ -1136,16 +1136,44 @@
 86776L;%0A
+    private String payload;%0A
     priv
@@ -1180,32 +1180,36 @@
 ate Text payload
+Text
 ;%0A    private Bo
@@ -1295,54 +1295,8 @@
 ) %7B%0A
-        this.payload = new Text(eventString);%0A
     
@@ -1390,18 +1390,45 @@
     
-%7D%0A
+    this.setPayload(payload);
 %0A    %7D%0A%0A
 %0A   
@@ -1423,17 +1423,16 @@
 %0A    %7D%0A%0A
-%0A
     publ
@@ -1434,20 +1434,22 @@
  public 
-Text
+String
  getPayl
@@ -1468,74 +1468,553 @@
     
-return payload;%0A    %7D%0A%0A    public void setPayload(Text payload) %7B%0A
+if (payload != null) %7B%0A            return payload;%0A        %7D%0A        if (payloadText != null) %7B%0A            return payloadText.getValue();%0A        %7D%0A        return null;%0A    %7D%0A%0A    public void setPayload(String payload) %7B%0A        // Explicitly set the non used property to null%0A        // to avoid problems when reading the value%0A        if (payload != null && payload.length() %3E Constants.MAX_LENGTH) %7B%0A            this.payload = null;%0A            this.payloadText = new Text(payload);%0A        %7D else %7B%0A            this.payloadText = null;%0A    
     
@@ -2037,24 +2037,34 @@
  = payload;%0A
+        %7D%0A
     %7D%0A%0A    p

Use String type to store payload < 500 chars