package org.commcare.util;

import org.commcare.cases.ledger.Ledger;
import org.commcare.cases.model.Case;
import org.commcare.core.interfaces.UserDataInterface;
import org.commcare.core.properties.CommCareProperties;
import org.javarosa.core.model.instance.FormInstance;
import org.javarosa.core.services.PropertyManager;
import org.javarosa.core.model.User;

import org.javarosa.core.services.storage.IStorageUtilityIndexed;
import org.javarosa.core.services.storage.StorageManager;

public class J2MESandbox implements UserDataInterface{

    public IStorageUtilityIndexed<Case> getCaseStorage() {
        return (IStorageUtilityIndexed<Case>)StorageManager.getStorage(Case.STORAGE_KEY);
    }

    public IStorageUtilityIndexed<Ledger> getLedgerStorage() {
        return (IStorageUtilityIndexed<Ledger>)StorageManager.getStorage(Ledger.STORAGE_KEY);
    }

    public IStorageUtilityIndexed<User> getUserStorage() {
        return (IStorageUtilityIndexed<User>)StorageManager.getStorage(User.STORAGE_KEY);
    }

    public IStorageUtilityIndexed<FormInstance> getUserFixtureStorage() {
        return (IStorageUtilityIndexed<FormInstance>)StorageManager.getStorage(FormInstance.STORAGE_KEY);
    }

    public IStorageUtilityIndexed<FormInstance> getAppFixtureStorage() {
        return (IStorageUtilityIndexed<FormInstance>)StorageManager.getStorage(FormInstance.STORAGE_KEY);
    }

    public User getLoggedInUser() {
        return PropertyManager._().getSingularProperty(CommCareProperties.LOGGED_IN_USER);
    }

    public void setLoggedInUser(User user) {

    }

    public void setSyncToken(String syncToken) {

    }

    public String getSyncToken() {
        return null;
    }

    public void updateLastSync() {

    }
}

@@ -1464,22 +1464,136 @@
         
-return
+IStorageUtilityIndexed%3CUser%3E users = getUserStorage();%0D%0A        User user = (User)users.getRecordForValue(User.META_UID,
  Propert
@@ -1659,16 +1659,39 @@
 IN_USER)
+);%0D%0A        return user
 ;%0D%0A    %7D

move User