package org.commcare.android.database.user.models;

import org.commcare.android.storage.framework.Persisted;
import org.commcare.models.framework.Persisting;
import org.commcare.modern.database.Table;
import org.commcare.modern.models.EncryptedModel;
import org.commcare.modern.models.MetaField;
import org.javarosa.core.util.MD5;

/**
 * Represents the version of SessionStateDescriptor that exists in user databases up until CommCare
 * version 2.40; used to perform the necessary user db migration from V21 --> V22 in CommCare 2.41
 *
 */
@Table(SessionStateDescriptor.STORAGE_KEY)
public class SessionStateDescriptorV1 extends Persisted implements EncryptedModel {

    public static final String STORAGE_KEY = "android_cc_session";

    public static final String META_DESCRIPTOR_HASH = "descriptorhash";

    public static final String META_FORM_RECORD_ID = "form_record_id";

    @Persisting(1)
    @MetaField(value = META_FORM_RECORD_ID, unique = true)
    private int formRecordId = -1;

    @Persisting(2)
    private String sessionDescriptor = null;

    @MetaField(value = META_DESCRIPTOR_HASH)
    public String getHash() {
        return MD5.toHex(MD5.hash(sessionDescriptor.getBytes()));
    }

    @Override
    public boolean isEncrypted(String data) {
        return false;
    }

    @Override
    public boolean isBlobEncrypted() {
        return false;
    }

    public int getFormRecordId() {
        return formRecordId;
    }

    public String getSessionDescriptor() {
        return this.sessionDescriptor;
    }

}

@@ -292,43 +292,8 @@
 eld;
-%0Aimport org.javarosa.core.util.MD5;
 %0A%0A/*
@@ -1024,156 +1024,8 @@
 l;%0A%0A
-    @MetaField(value = META_DESCRIPTOR_HASH)%0A    public String getHash() %7B%0A        return MD5.toHex(MD5.hash(sessionDescriptor.getBytes()));%0A    %7D%0A%0A
     

remove unused method from V1 class