<commit_before>package net.yasme.android.entities;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import net.yasme.android.storage.DatabaseConstants;

import org.codehaus.jackson.annotate.JsonIgnore;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by bene on 06.05.14.
 */

@DatabaseTable(tableName = DatabaseConstants.MESSAGE_TABLE)
public class Message implements Serializable {

    @DatabaseField(columnName = DatabaseConstants.MESSAGE_ID, id = true)// generatedId = true, allowGeneratedIdInsert = true)
    private long id;

    @DatabaseField(columnName = DatabaseConstants.CHAT, canBeNull = false, foreign = true,
            foreignAutoCreate=true, foreignAutoRefresh=true)
    private Chat chat;

    @DatabaseField(columnName = DatabaseConstants.SENDER, foreign = true,
            foreignAutoCreate=true, foreignAutoRefresh=true)
    private User sender;

    @DatabaseField(columnName = DatabaseConstants.DATE)
    private Date dateSent;

    @DatabaseField(columnName = DatabaseConstants.MESSAGE)
    private String message;

    @DatabaseField(columnName = DatabaseConstants.MESSAGE_MESSAGEKEY_ID)
    private long messageKeyId;

    private MessageKey messageKey;

    /**
     * Constructors *
     */
    public Message() {
        // ORMLite needs a no-arg constructor
    }

    public Message(long id, Chat chat, User sender, Date dateSent, String message, long messageKeyId) {
        this.id = id;
        this.chat = chat;
        this.sender = sender;
        this.dateSent = dateSent;
        this.message = message;
        this.messageKeyId = messageKeyId;
    }

    public Message(User sender, String message, long chatId, long messageKeyId) {
        Chat chat = new Chat();
        chat.setId(chatId);

        this.chat = chat;
        this.dateSent = new Date();
        this.sender = sender;
        this.message = message;
        this.messageKeyId = messageKeyId;

        //new Message(sender, message, new Date(), chat, messageKeyId);
    }

    public Message(User sender, String message, Chat chat, long messageKeyId) {
        this.chat = chat;
        this.dateSent = new Date();
        this.sender = sender;
        this.message = message;
        this.messageKeyId = messageKeyId;

        //new Message(sender, message, new Date(), chat, messageKeyId);
    }

    public Message(User sender, String message, Date dateSent, Chat chat, long messageKeyId) {
        this.sender = sender;
        this.message = message;
        this.dateSent = dateSent;
        this.chat = chat;
        //this.id = id++;<commit_msg>Don't set creation date for new messages. Otherwise this date may differ from device to device<commit_after>package net.yasme.android.entities;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import net.yasme.android.storage.DatabaseConstants;

import org.codehaus.jackson.annotate.JsonIgnore;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by bene on 06.05.14.
 */

@DatabaseTable(tableName = DatabaseConstants.MESSAGE_TABLE)
public class Message implements Serializable {

    @DatabaseField(columnName = DatabaseConstants.MESSAGE_ID, id = true)// generatedId = true, allowGeneratedIdInsert = true)
    private long id;

    @DatabaseField(columnName = DatabaseConstants.CHAT, canBeNull = false, foreign = true,
            foreignAutoCreate=true, foreignAutoRefresh=true)
    private Chat chat;

    @DatabaseField(columnName = DatabaseConstants.SENDER, foreign = true,
            foreignAutoCreate=true, foreignAutoRefresh=true)
    private User sender;

    @DatabaseField(columnName = DatabaseConstants.DATE)
    private Date dateSent;

    @DatabaseField(columnName = DatabaseConstants.MESSAGE)
    private String message;

    @DatabaseField(columnName = DatabaseConstants.MESSAGE_MESSAGEKEY_ID)
    private long messageKeyId;

    private MessageKey messageKey;

    /**
     * Constructors *
     */
    public Message() {
        // ORMLite needs a no-arg constructor
    }

    public Message(long id, Chat chat, User sender, Date dateSent, String message, long messageKeyId) {
        this.id = id;
        this.chat = chat;
        this.sender = sender;
        this.dateSent = dateSent;
        this.message = message;
        this.messageKeyId = messageKeyId;
    }

    public Message(User sender, String message, long chatId, long messageKeyId) {
        Chat chat = new Chat();
        chat.setId(chatId);

        this.chat = chat;
        //this.dateSent = new Date(); // Set date at server. Otherwise dates may differ from device to device
        this.sender = sender;
        this.message = message;
        this.messageKeyId = messageKeyId;

        //new Message(sender, message, new Date(), chat, messageKeyId);
    }

    public Message(User sender, String message, Chat chat, long messageKeyId) {
        this.chat = chat;
        //this.dateSent = new Date();   // Set date at server. Otherwise dates may differ from device to device
        this.sender = sender;
        this.message = message;
        this.messageKeyId = messageKeyId;

        //new Message(sender, message, new Date(), chat, messageKeyId);
    }

    public Message(User sender, String message, Date dateSent, Chat chat, long messageKeyId) {
        this.sender = sender;
        this.message = message;
        this.dateSent = dateSent;
        this.chat = chat;
        //this.id = id++;
{'fraction_non_alphanumeric': 0.09410906438081343, 'fraction_numerical': 0.0043771657851541124, 'mean_word_length': 2.9481641468682507, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2367534', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1492, 'n_words': 414}