package kz.cafe;

import kz.cafe.constants.*;
import kz.cafe.db.*;
import kz.cafe.db.model.*;
import kz.cafe.exceptions.*;

public class TestMassLoad{

   /**
    * @param args
    * @throws UserNotFoundException 
    */
   public static void main(String[] args) throws Exception{
      
      for(int f = 0; f < 20; f++){
         MCafeType mCafeType = new MCafeType();
         mCafeType.ID = MongoService.getUniqueID(MCafeType.class);
         mCafeType.name.put(InterfaceConstants.LANGS.RU, "категория"  + f);
         mCafeType.name.put(InterfaceConstants.LANGS.EN, "category "  + f);
         mCafeType.name.put(InterfaceConstants.LANGS.KZ, "фырк-фырк " + f);
         MongoService.save(mCafeType);
         
         for(int i = 0; i < 50; i++){
            MCafe mCafe = new MCafe();
            mCafe.ID = MongoService.getUniqueID(MCafe.class);
            mCafe.name.put(InterfaceConstants.LANGS.RU, "кафе"      + (f * 1000) + i);
            mCafe.name.put(InterfaceConstants.LANGS.EN, "cafe "     + (f * 1000) + i);
            mCafe.name.put(InterfaceConstants.LANGS.KZ, "чай-хана " + (f * 1000) + i);
            
            mCafe.types.add(mCafeType.ID);
            mCafe.city = 4;
            mCafe.image = "17.jpg";
            MongoService.save(mCafe);
         }
      }
      
      
      for(MCafe mCafe : MongoService.getList(MCafe.class)){
         MSale mSale = new MSale();
         mSale.ID = MongoService.getUniqueID(MSale.class);
         mSale.CID = mCafe.ID;
         mSale.name.put(InterfaceConstants.LANGS.RU, "акция"  + System.currentTimeMillis());
         mSale.name.put(InterfaceConstants.LANGS.EN, "акция " + System.currentTimeMillis());
         mSale.name.put(InterfaceConstants.LANGS.KZ, "акция " + System.currentTimeMillis());
         mSale.image = "41.jpg";
         MongoService.save(mSale);
         
         MSale mSale2 = new MSale();
         mSale2.ID = MongoService.getUniqueID(MSale.class);
         mSale2.CID = mCafe.ID;
         mSale2.name.put(InterfaceConstants.LANGS.RU, "акция"  + System.currentTimeMillis());
         mSale2.name.put(InterfaceConstants.LANGS.EN, "акция " + System.currentTimeMillis());
         mSale2.name.put(InterfaceConstants.LANGS.KZ, "акция " + System.currentTimeMillis());
         mSale2.image = "44.jpg";
         MongoService.save(mSale2);

         
         for(int i = 0; i < 50; i++) {
            MFeedback mFeedback = new MFeedback();
            mFeedback.ID = MongoService.getUniqueID(MFeedback.class);
            
            mFeedback.CID = mCafe.ID;
            mFeedback.rate = new Double(Math.random() * 4).intValue();
            
            mFeedback.text.put(InterfaceConstants.LANGS.RU, "Отзыв" + System.currentTimeMillis());
            mFeedback.text.put(InterfaceConstants.LANGS.EN, "Отзыв" + System.currentTimeMillis());
            mFeedback.text.put(InterfaceConstants.LANGS.KZ, "Отзыв" + System.currentTimeMillis());

            MongoService.save(mFeedback);
         }
      }
   }
}
