package kz.cafe;

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

public class InitAdmin{

   /**
    * @param args
    * @throws UserNotFoundException 
    */
   public static void main(String[] args) throws Exception{
      MUser mUser;
      try{
         mUser = MongoUserService.getUserProfile(0);
      }
      catch (Exception e){
         mUser = new MUser();
      }
      
      mUser.ID = 0;
      mUser.login = "admin";
      mUser.password = "L{Llmhut[2";
      mUser.role = 0;
      mUser.canUseGUI = true;
      mUser.name = "Administrator";
      
      MongoUserService.save(mUser);
      
      
      

      MRole mRoleRead = MongoService.get(MRole.class, 0);
      
      if(mRoleRead == null) {
         mRoleRead = new MRole();
      }
         
      mRoleRead.ID = 0;
      mRoleRead.name.put(InterfaceConstants.LANGS.RU, "Administrator");
      mRoleRead.name.put(InterfaceConstants.LANGS.EN, "Администратор");
      mRoleRead.name.put(InterfaceConstants.LANGS.KZ, "Администратор");
      
      for(int f = 0; f < 200; f++){
         mRoleRead.screenRead.add(f);
         mRoleRead.screenAdd.add(f);
         mRoleRead.screenEdit.add(f);
         mRoleRead.screenDelete.add(f);
      }
      
      MongoService.save(mRoleRead);
   }
}
