// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
//     PARTNER, USER, SYNC, OTHER;
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
//     private long mId;
//     private long mSessionId;
//     private String mMessage;
//     private long mTimestamp;
//     private ChatMessageType mChatMessageType;
// 
//     public long getId() {
//         return mId;
//     }
// 
//     public void setId(long id) {
//         this.mId = id;
//     }
// 
//     public long getSessionId() {
//         return mSessionId;
//     }
// 
//     public void setSessionId(long sessionId) {
//         this.mSessionId = sessionId;
//     }
// 
//     public String getMessage() {
//         return mMessage;
//     }
// 
//     public void setMessage(String message) {
//         this.mMessage = message;
//     }
// 
//     public long getTimestamp() {
//         return mTimestamp;
//     }
// 
//     public void setTimestamp(long timestamp) {
//         this.mTimestamp = timestamp;
//     }
// 
//     public ChatMessageType getChatMessageType() {
//         return mChatMessageType;
//     }
// 
//     public void setChatMessageType(ChatMessageType chatMessageType) {
//         this.mChatMessageType = chatMessageType;
//     }
// 
//     @Override
//     public String toString() {
//         return "DBChatMessageEntity{" +
//                 "mId=" + mId +
//                 ", mSessionId=" + mSessionId +
//                 ", mMessage='" + mMessage + '\'' +
//                 ", mTimestamp=" + mTimestamp +
//                 ", mChatMessageType=" + mChatMessageType +
//                 '}';
//     }
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
//     public List<IDbEntity> getAllIDbEntity();
// 
//     public IDbEntity getIDbEntityById(long sessionId);
// 
//     public boolean addDbEntity(IDbEntity dbEntity);
// 
//     public int updateDbEntity(IDbEntity dbEntity);
// 
//     public boolean deleteDbEntity(IDbEntity dbEntity);
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
// 
//     public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
//     public static final int DATABASE_VERSION = 1;
// 
//     public static final String TABLE_CONTACTS = "contacts";
//     public static final String TABLE_MY_PROFILE = "my_profile";
//     public static final String TABLE_CHATS = "chats";
//     public static final String TABLE_CHATS_MESSAGES = "chats_messages";
// 
//     //    contacts table
//     public static final String COLUMN_ID = "id";
//     public static final String COLUMN_NAME = "name";
//     public static final String COLUMN_NICKNAME = "nickname";
//     public static final String COLUMN_SESSION_ID = "session_id";
//     public static final String COLUMN_ADDRESS = "address";
//     public static final String COLUMN_EMAIL = "email";
// 
//     //    chats table
//     public static final String COLUMN_CHAT_NAME = "chat_name";
//     public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
//     public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
// 
//     //    chats_messages
//     public static final String COLUMN_MESSAGE = "message";
//     public static final String COLUMN_MESSAGE_TYPE = "message_type";
//     public static final String COLUMN_TIMESTAMP = "timestamp";
// 
//     //  my profile table
//     public static final String COLUMN_MY_ADDRESS = "my_address";
//     public static final String COLUMN_MY_NAME = "my_name";
//     public static final String COLUMN_MY_NICKNAME = "my_nickname";
//     public static final String COLUMN_MY_EMAIL = "my_email";
//     public static final String COLUMN_TBE_PID = "bundle_pid";
//     public static final String COLUMN_TBE_PROCESS = "bundle_process";
// 
// }


import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.persistence.operations;




/**
 * Created by tudor on 5/4/2017.
 */

public class DbChatMessagesOperations implements IEntityDbOperations {
    private static final String LOG = DbChatMessagesOperations.class.getSimpleName();

    private SQLiteDatabase mSQLiteDatabase;

    public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
        mSQLiteDatabase = sqLiteDatabase;
    }

    @Override
    public List<IDbEntity> getAllIDbEntity() {
        Log.i(LOG, "getAllIDbEntity -> ENTER");

        List<IDbEntity> retVal = new ArrayList<>();

        String selectQuery = "SELECT " + PersistenceConstants.COLUMN_ID + ", " +
                PersistenceConstants.COLUMN_CONTACT_SESSION_ID + ", " +
                PersistenceConstants.COLUMN_MESSAGE + ", " +
                PersistenceConstants.COLUMN_MESSAGE_TYPE + ", " +
                PersistenceConstants.COLUMN_TIMESTAMP +
                " FROM " + PersistenceConstants.TABLE_CHATS_MESSAGES;

        Cursor cursor = mSQLiteDatabase.rawQuery(selectQuery, null);

        if (cursor.moveToFirst()) {
            do {
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
//     PARTNER, USER, SYNC, OTHER;
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
//     private long mId;
//     private long mSessionId;
//     private String mMessage;
//     private long mTimestamp;
//     private ChatMessageType mChatMessageType;
// 
//     public long getId() {
//         return mId;
//     }
// 
//     public void setId(long id) {
//         this.mId = id;
//     }
// 
//     public long getSessionId() {
//         return mSessionId;
//     }
// 
//     public void setSessionId(long sessionId) {
//         this.mSessionId = sessionId;
//     }
// 
//     public String getMessage() {
//         return mMessage;
//     }
// 
//     public void setMessage(String message) {
//         this.mMessage = message;
//     }
// 
//     public long getTimestamp() {
//         return mTimestamp;
//     }
// 
//     public void setTimestamp(long timestamp) {
//         this.mTimestamp = timestamp;
//     }
// 
//     public ChatMessageType getChatMessageType() {
//         return mChatMessageType;
//     }
// 
//     public void setChatMessageType(ChatMessageType chatMessageType) {
//         this.mChatMessageType = chatMessageType;
//     }
// 
//     @Override
//     public String toString() {
//         return "DBChatMessageEntity{" +
//                 "mId=" + mId +
//                 ", mSessionId=" + mSessionId +
//                 ", mMessage='" + mMessage + '\'' +
//                 ", mTimestamp=" + mTimestamp +
//                 ", mChatMessageType=" + mChatMessageType +
//                 '}';
//     }
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
//     public List<IDbEntity> getAllIDbEntity();
// 
//     public IDbEntity getIDbEntityById(long sessionId);
// 
//     public boolean addDbEntity(IDbEntity dbEntity);
// 
//     public int updateDbEntity(IDbEntity dbEntity);
// 
//     public boolean deleteDbEntity(IDbEntity dbEntity);
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
// 
//     public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
//     public static final int DATABASE_VERSION = 1;
// 
//     public static final String TABLE_CONTACTS = "contacts";
//     public static final String TABLE_MY_PROFILE = "my_profile";
//     public static final String TABLE_CHATS = "chats";
//     public static final String TABLE_CHATS_MESSAGES = "chats_messages";
// 
//     //    contacts table
//     public static final String COLUMN_ID = "id";
//     public static final String COLUMN_NAME = "name";
//     public static final String COLUMN_NICKNAME = "nickname";
//     public static final String COLUMN_SESSION_ID = "session_id";
//     public static final String COLUMN_ADDRESS = "address";
//     public static final String COLUMN_EMAIL = "email";
// 
//     //    chats table
//     public static final String COLUMN_CHAT_NAME = "chat_name";
//     public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
//     public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
// 
//     //    chats_messages
//     public static final String COLUMN_MESSAGE = "message";
//     public static final String COLUMN_MESSAGE_TYPE = "message_type";
//     public static final String COLUMN_TIMESTAMP = "timestamp";
// 
//     //  my profile table
//     public static final String COLUMN_MY_ADDRESS = "my_address";
//     public static final String COLUMN_MY_NAME = "my_name";
//     public static final String COLUMN_MY_NICKNAME = "my_nickname";
//     public static final String COLUMN_MY_EMAIL = "my_email";
//     public static final String COLUMN_TBE_PID = "bundle_pid";
//     public static final String COLUMN_TBE_PROCESS = "bundle_process";
// 
// }


// Path: app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List;

package com.batsw.anonimitychat.persistence.operations;




/**
 * Created by tudor on 5/4/2017.
 */

public class DbChatMessagesOperations implements IEntityDbOperations {
    private static final String LOG = DbChatMessagesOperations.class.getSimpleName();

    private SQLiteDatabase mSQLiteDatabase;

    public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
        mSQLiteDatabase = sqLiteDatabase;
    }

    @Override
    public List<IDbEntity> getAllIDbEntity() {
        Log.i(LOG, "getAllIDbEntity -> ENTER");

        List<IDbEntity> retVal = new ArrayList<>();

        String selectQuery = "SELECT " + PersistenceConstants.COLUMN_ID + ", " +
                PersistenceConstants.COLUMN_CONTACT_SESSION_ID + ", " +
                PersistenceConstants.COLUMN_MESSAGE + ", " +
                PersistenceConstants.COLUMN_MESSAGE_TYPE + ", " +
                PersistenceConstants.COLUMN_TIMESTAMP +
                " FROM " + PersistenceConstants.TABLE_CHATS_MESSAGES;

        Cursor cursor = mSQLiteDatabase.rawQuery(selectQuery, null);

        if (cursor.moveToFirst()) {
            do {
                DBChatMessageEntity messageEntity = new DBChatMessageEntity();