package kz.cafe;

import java.io.*;
import kz.cafe.constants.*;
import kz.cafe.db.*;
import kz.cafe.db.model.*;

public class FuckFeedbacks{

   /**
    * @param args
    * @throws UserNotFoundException 
    */
   
   private static BufferedReader in;
   
   public static void main(String[] args) throws Exception{
      
       in = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), "UTF8"));

      
       for(MCafe mCafe : MongoService.getList(MCafe.class)) {
         
          for(int f = 0; f < 15; f++) {
            MFeedback mFeedback = new MFeedback();
            mFeedback.ID = MongoService.getUniqueID(MFeedback.class);
            
            String sLine = readLine();
            
            System.out.println(sLine);

            for(InterfaceConstants.LANGS lang : InterfaceConstants.LANGS.values()) { 
               mFeedback.text.put(lang, sLine);
            }
            mFeedback.CID = mCafe.ID;
            MongoService.save(mFeedback);
         }
       }
   }
   
 

   

   private static String readLine() throws FileNotFoundException{

      while (true){
         try{

            StringBuilder sbBuilder = new StringBuilder();

            int iCounter = 0;
            while (iCounter < 10){
               
               String sLine = in.readLine();
               
               if(sLine == null){
                  in = new BufferedReader(new InputStreamReader(new FileInputStream("c:/1.txt"), "UTF8"));
                  continue;
               }
               
               sbBuilder.append(sLine);

               iCounter++;
            }

            return sbBuilder.toString();
         }
         catch (IOException e){
            break;
         }
      }
      return null;
   }
}
