package com.infinite.focus.server.home;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;

import com.cloudinary.Cloudinary;
import com.cloudinary.utils.ObjectUtils;
import com.infinite.focus.server.auth.AccountRepository;
import com.infinite.focus.server.auth.AvatarRepository;
import com.infinite.focus.server.auth.Instructor;
import com.infinite.focus.server.auth.InstructorRepository;
import com.infinite.focus.server.auth.Message;
import com.infinite.focus.server.auth.School;
import com.infinite.focus.server.auth.SchoolRepository;
import com.infinite.focus.server.auth.Student;
import com.infinite.focus.server.auth.StudentRepository;
import com.infinite.focus.server.data.MoodOccurance;
import com.infinite.focus.server.lessons.Lesson;
import com.infinite.focus.server.lessons.LessonRecord;
import com.infinite.focus.server.lessons.LessonRecordRepository;
import com.infinite.focus.server.lessons.LessonRepository;
import com.infinite.focus.server.notifications.service.NotificationService;
import com.infinite.focus.server.students.ClassRepository;
import com.infinite.focus.server.tests.SocioEmotionalTestResult;
import com.infinite.focus.server.tests.SocioEmotionalTestResultRepository;
import com.infinite.focus.server.wall.TopPicks;
import com.infinite.focus.server.wall.WallPost;
import com.infinite.focus.server.wall.WallPostAttachment;
import com.infinite.focus.server.wall.WallPostAttachmentRepository;
import com.infinite.focus.server.wall.WallPostRepository;
import com.infinite.focus.server.wall.WallPostRequestRepository;
import com.infinite.focus.server.wall.WallPostWrapper;

/**
 * 
 * @author Saboor
 * 
 *
 */


@CrossOrigin(origins = "http://localhost:8383")
@RestController
@RequestMapping("api/home")

public class HomeController {
	
	@Autowired
	NotificationService notificationService;
	
	 	private AccountRepository accountRepository;
		private StudentRepository studentRepository;
		private InstructorRepository instructorRepository;
		private AvatarRepository avatarRepository;
	    private BCryptPasswordEncoder bCryptPasswordEncoder;
	    private WallPostRepository wallPostRepository;
	    private WallPostAttachmentRepository wallPostAttachmentRepository;
	    private WallPostRequestRepository wallPostRequestRepository;
	    private QuoteRepository qouteRepository;
	    private MoodUpdateRepository moodUpdateRepository;
	    private DailyAppreciationRepository dailyAppreciationRepository;
	    private NotificationRepository notificationRepository;
	    private SchoolRepository schoolRepository;
	    private ClassRepository classRepository;
	    
	    private LessonRepository lessonRepository;
	    private LessonRecordRepository lessonRecordRepository;
	    private SocioEmotionalTestResultRepository socioEmotionalTestResultRepository;

	 	@Autowired
	    private RealTimeMessageService realTimeMessageService;
	    
	    public HomeController(SocioEmotionalTestResultRepository socioEmotionalTestResultRepository, LessonRepository lessonRepository, LessonRecordRepository lessonRecordRepository, ClassRepository classRepository, SchoolRepository schoolRepository, RealTimeMessageService realTimeMessageService, NotificationRepository notificationRepository, DailyAppreciationRepository dailyAppreciationRepository, MoodUpdateRepository moodUpdateRepository, QuoteRepository qouteRepository, WallPostRepository wallPostRepository, WallPostAttachmentRepository wallPostAttachmentRepository, WallPostRequestRepository wallPostRequestRepository, AvatarRepository avatarRepository,
	    		InstructorRepository instructorRepository, StudentRepository studentRepository,AccountRepository accountRepository, BCryptPasswordEncoder bCryptPasswordEncoder) {
	    	this.socioEmotionalTestResultRepository = socioEmotionalTestResultRepository;
	    	this.lessonRecordRepository = lessonRecordRepository;
	    	this.lessonRepository = lessonRepository;
	    	this.classRepository = classRepository;
	    	this.schoolRepository = schoolRepository;
	    	this.realTimeMessageService = realTimeMessageService;
	    	this.notificationRepository = notificationRepository;
	    	this.qouteRepository = qouteRepository;
	    	this.wallPostRepository = wallPostRepository;
	    	this.wallPostAttachmentRepository = wallPostAttachmentRepository;
	    	this.wallPostRequestRepository = wallPostRequestRepository;
	    	this.avatarRepository = avatarRepository;
	    	this.bCryptPasswordEncoder= bCryptPasswordEncoder;
	    	this.instructorRepository = instructorRepository;
	    	this.studentRepository = studentRepository;
	    	this.accountRepository = accountRepository;
	    	this.moodUpdateRepository = moodUpdateRepository;
			this.dailyAppreciationRepository = dailyAppreciationRepository;
			
		}
	    
	    //Return all schools for a particular district
	    @GetMapping("/get/schools/by/district")   
	    public ResponseEntity<List<School>> getSchoolsByDistrict(@RequestParam(value="district_id", defaultValue="aEn24") Long district_id){
    	   	
	    	//Find school by district id
	    	return new ResponseEntity<List<School>>(schoolRepository.findByDistrictId(district_id), HttpStatus.OK);
	    	
	    }
	    
	    

	    @GetMapping("/get/classes/by/school")   
	    public ResponseEntity<List<com.infinite.focus.server.students.Class>> getClassesBySchool(@RequestParam(value="school_id", defaultValue="aEn24") Long school_id){
    	   	
	    	List<Instructor> list = instructorRepository.findBySchoolId(school_id);
	    	List<com.infinite.focus.server.students.Class> cs = new ArrayList<>();
	    	
	    	for(Instructor i: list) {
	    		
	    		List<com.infinite.focus.server.students.Class> classes = classRepository.findByInstructorId(i.getInstructor_id());
	    		
	    		for(com.infinite.focus.server.students.Class c:classes) {
	    			
	    			c.setClass_name(i.getFirst_name() + " " + i.getLast_name() + "'s " + c.getClass_name());
	    		}
	    		
	    		cs.addAll(classes);
	    		
	    		
	    	}
	    	
	    	return new ResponseEntity<List<com.infinite.focus.server.students.Class>>(cs, HttpStatus.OK);
	    }
	    
	    
	    @GetMapping("/test/notification")   
	    public ResponseEntity<Notification> sendTestNotification(@RequestParam(value="student_id", defaultValue="aEn24") Long student_id){
	    	
	    	Student s = studentRepository.getOne(student_id);
	    	
	    	if(s == null) {
	    		new ResponseEntity<Notification>(HttpStatus.NOT_FOUND);
	    	}
	    	
	    	Notification n = new Notification();
	    	n.setInstructor_id(s.getInstructor_id());
	    	n.setStudent_id(s.getStudent_id());
	    	n.setText(s.getFirst_name() + " " + s.getLast_name() + " has selected mad or sad for more than 3 days in a row");
	    	
	        notificationRepository.save(n);
	        
	      //Construct json message to send to instructors 
    		String json_message = "{\"type\":\"NOTIFICATION\",\"message\":\"" + n.getText() + "\"}";
	        
	        realTimeMessageService.sendMessage(s.getInstructor_id(), json_message);
	        
	    	
    	   	return new ResponseEntity<Notification>(n, HttpStatus.OK);
	    		    	
	    }
	    
	    @GetMapping("/get/notifications")   
	    public ResponseEntity<List<Notification>> getNotifications(@RequestParam(value="instructor_id", defaultValue="aEn24") Long instructor_id){
	    	
    	   	return new ResponseEntity<List<Notification>>(notificationRepository.findByInstructorId(instructor_id), HttpStatus.OK);
	    		    	
	    }
	    
	    
	    @PostMapping("/get/notifications")
	    @ResponseBody
	    public ResponseEntity<List<Notification>> getNotifications(@RequestBody GetNotificationsRequest request){
			
    	   	return new ResponseEntity<List<Notification>>(notificationService.getNotifications(request), HttpStatus.OK);
	    		    	
	    }	    
	    
	    @GetMapping("/get/daily/quote")   
	    public ResponseEntity<Quote> getCurrentDailyQuote(){
	    	
	    	Quote qoute = qouteRepository.findDailyQuote();
	    	
    	   	return new ResponseEntity<Quote>(qoute, HttpStatus.OK);
	    		    	
	    }
	    
	    
	    @GetMapping("/delete/daily/quote")   
	    public ResponseEntity<Message> deleteQuote(@RequestParam(value="quote_id", defaultValue="aEn24") Long quote_id){
	    		    	
	    	
	    	Quote quote = qouteRepository.getOne(quote_id);
			
			if(quote == null) {
				throw new ResponseStatusException(HttpStatus.NOT_FOUND, "The Quote not found!");
			}
			
			if(quote.getIsDailyQuote()) {
				throw new ResponseStatusException(HttpStatus.CONFLICT, "The Quote is a Daily Quote, the Daily Quote can not be deleted.");
			}
						
	    	qouteRepository.deleteById(quote_id);
	    	
	    	Message message = new Message();
			message.setMessage("The Quote is deleted successfully.");
			
			return new ResponseEntity<Message>(message, HttpStatus.OK);
	    		    	
	    }
	    
	    
	    @GetMapping("/get/all/daily/quotes")   
	    public ResponseEntity<List<Quote>> getAllQuotes(){
	    		    	
    	   	return new ResponseEntity<List<Quote>>(qouteRepository.findAllOrderById(), HttpStatus.OK);
	    		    	
	    }
	    
	    @PostMapping("/create/daily/quote")
	    @ResponseBody
	    public ResponseEntity<Quote> createDailyQuote(@RequestBody Quote request){
	    		    	
    	   	return new ResponseEntity<Quote>(qouteRepository.save(request), HttpStatus.OK);
	    		    	
	    }
	    
	    @PostMapping("/update/daily/quote")
	    @ResponseBody
	    public ResponseEntity<Quote> updateDailyQuote(@RequestBody Quote request){
	    	
	    	Quote quote = qouteRepository.getOne(request.getQuote_id());
	    	quote.setText(request.getText());
	    	quote.setAuthor(request.getAuthor());
	    	
    	   	return new ResponseEntity<Quote>(qouteRepository.save(quote), HttpStatus.OK);
	    		    	
	    }
	  
	    @PostMapping("/create/mood_update")   //API End point for POST request to register a new company
	    @ResponseBody
	    public ResponseEntity<MoodUpdate> createMoodUpdate(@RequestBody MoodUpdate request) { //Capture data sent in Request Body
	    	
	  	if(containsMood("sad", request.getText()) || containsMood("depressed", request.getText())){
		    		
		    		Student s = studentRepository.getOne(request.getStudent_id());
			    	
			    	if(s == null) {
			    		new ResponseEntity<Notification>(HttpStatus.NOT_FOUND);
			    	}
			    	
		    		
		    		Notification n = new Notification();
			    	
			    	n.setInstructor_id(s.getInstructor_id());
			    	n.setStudent_id(s.getStudent_id());
			    	
			    	n.setText(s.getFirst_name() + " " + s.getLast_name() + "  is sad/depressed today (" + new SimpleDateFormat("yyyy.MM.dd").format(new Date()) + ").");
			    	
			        notificationRepository.save(n);
			        
			        //Construct json message to send to instructors 
			        
		    		String json_message = "{\"type\":\"NOTIFICATION\",\"message\":\"" + n.getText() + "\"}";
			        
			        realTimeMessageService.sendMessage(s.getInstructor_id(), json_message);
		    		
	  		}
	  	
	  	
	  	if(containsMood("anxious", request.getText())){
			
			List<MoodUpdate> list = moodUpdateRepository.findByStudentIdInLast3Days(request.getStudent_id());
		
			
			int count = 0;

			
			for(MoodUpdate m:list) {
				
				if(containsMood("anxious", m.getText())){
					count++;
				}
				
			}
			
			if(count >= 2) {

		    	Student s = studentRepository.getOne(request.getStudent_id());
		    	
		    	if(s == null) {
		    		new ResponseEntity<Notification>(HttpStatus.NOT_FOUND);
		    	}
		    	
		    	Notification n = new Notification();
		    	
		    	n.setInstructor_id(s.getInstructor_id());
		    	n.setStudent_id(s.getStudent_id());
		    	
		    	n.setText(s.getFirst_name() + " " + s.getLast_name() + " has selected anxious for three days in a row (" + new SimpleDateFormat("yyyy.MM.dd").format(new Date()) + ").");
		    	
		        notificationRepository.save(n);
		        
		        //Construct json message to send to instructors 
		        
	    		String json_message = "{\"type\":\"NOTIFICATION\",\"message\":\"" + n.getText() + "\"}";
		        
		        realTimeMessageService.sendMessage(s.getInstructor_id(), json_message);
				
			}
	  	}
	  	
	  	if(containsMood("mad", request.getText()) || containsMood("angry", request.getText())){
			
			List<MoodUpdate> list = moodUpdateRepository.findByStudentIdInLast3Days(request.getStudent_id());
		
			
			int count = 0;

			
			for(MoodUpdate m:list) {
				
				if(containsMood("mad", m.getText()) || containsMood("angry", m.getText())){
					count++;
				}
				
			}
			
			if(count >= 2) {

		    	Student s = studentRepository.getOne(request.getStudent_id());
		    	
		    	if(s == null) {
		    		new ResponseEntity<Notification>(HttpStatus.NOT_FOUND);
		    	}
		    	
		    	Notification n = new Notification();
		    	
		    	n.setInstructor_id(s.getInstructor_id());
		    	n.setStudent_id(s.getStudent_id());
		    	
		    	n.setText(s.getFirst_name() + " " + s.getLast_name() + " has selected angry/mad for three days in a row (" + new SimpleDateFormat("yyyy.MM.dd").format(new Date()) + ").");
		    	
		        notificationRepository.save(n);
		        
		        //Construct json message to send to instructors 
		        
	    		String json_message = "{\"type\":\"NOTIFICATION\",\"message\":\"" + n.getText() + "\"}";
		        
		        realTimeMessageService.sendMessage(s.getInstructor_id(), json_message);
				
			}
	  	}
			
			
	    	
	    	if(containsMood("sad", request.getText()) || containsMood("depressed", request.getText())){
    			
    			List<MoodUpdate> list = moodUpdateRepository.findByStudentIdInLast3Days(request.getStudent_id());
    		
    			
    			int count = 0;

    			
    			for(MoodUpdate m:list) {
    				
    				if(containsMood("sad", m.getText()) || containsMood("depressed", m.getText())){
    					count++;
    				}
    				
    			}
    			
    			if(count >= 2) {

    		    	Student s = studentRepository.getOne(request.getStudent_id());
    		    	
    		    	if(s == null) {
    		    		new ResponseEntity<Notification>(HttpStatus.NOT_FOUND);
    		    	}
    		    	
    		    	Notification n = new Notification();
    		    	
    		    	n.setInstructor_id(s.getInstructor_id());
    		    	n.setStudent_id(s.getStudent_id());
    		    	
    		    	n.setText(s.getFirst_name() + " " + s.getLast_name() + " has selected sad/depressed for three days in a row (" + new SimpleDateFormat("yyyy.MM.dd").format(new Date()) + ").");
    		    	
    		        notificationRepository.save(n);
    		        
    		        //Construct json message to send to instructors 
    		        
    	    		String json_message = "{\"type\":\"NOTIFICATION\",\"message\":\"" + n.getText() + "\"}";
    		        
    		        realTimeMessageService.sendMessage(s.getInstructor_id(), json_message);
    				
    			}
    		
    			
    		}
	    	
	        return new ResponseEntity<MoodUpdate>(moodUpdateRepository.save(request),HttpStatus.OK);

	    }
	    
	    @PostMapping("/create/daily_appreciation")   //API End point for POST request to register a new company
	    @ResponseBody
	    public ResponseEntity<DailyAppreciation> createDailyAppreciation(@RequestBody DailyAppreciation request) { //Capture data sent in Request Body
	    	
	        return new ResponseEntity<DailyAppreciation>(dailyAppreciationRepository.save(request),HttpStatus.OK);

	    }
	    
	    @GetMapping("/get/daily_appreciation/for/instructor/all")   
	    public ResponseEntity<List<DailyAppreciationStudentWrapper>> getAllDailyAppreciationForInstructor(@RequestParam(value="instructor_id", defaultValue="aEn24") Long instructor_id){
	    	
	    	
	    	List<DailyAppreciationStudentWrapper> list = new ArrayList<>();
	    	
	    	Instructor i = instructorRepository.getOne(instructor_id);
	    	
	    	if(i == null) {
	     		return new ResponseEntity<List<DailyAppreciationStudentWrapper>>(HttpStatus.CONFLICT); //if account exists return error
	    	 }
	    	
	    	List<Student> students = studentRepository.findByInstructorId(instructor_id);
	    	
	    	for(Student s: students) {
	    		
	    		for(DailyAppreciation d: dailyAppreciationRepository.findByStudent(s.getStudent_id())) {
	    			
		    		DailyAppreciationStudentWrapper w = new DailyAppreciationStudentWrapper();
		    		w.setDailyAppreciation(d);
		    		w.setStudent(s);
		    		list.add(w);
	    			
	    		}
	    		
	    		
	    		
	    		
	    	}
	    	
    	   	return new ResponseEntity<List<DailyAppreciationStudentWrapper>>(list, HttpStatus.OK);
	    		    	
	    }   
	    
	    //http://localhost:8081/api/home/get/daily_appreciation/for/instructor/all?instructor_id=6
	    
	    @GetMapping("/get/daily_appreciation/for/instructor/today")   
	    
	    public ResponseEntity<List<DailyAppreciation>> getDailyAppreciationForInstructor(@RequestParam(value="instructor_id", defaultValue="aEn24") Long instructor_id){
	    	
	    	
	    	List<DailyAppreciation> list = new ArrayList<>();
	    	
	    	Instructor i = instructorRepository.getOne(instructor_id);
	    	
	    	if(i == null) {
	     		return new ResponseEntity<List<DailyAppreciation>>(HttpStatus.CONFLICT); //if account exists return error
	    	 }
	    	
	    	List<Student> students = studentRepository.findByInstructorId(instructor_id);
	    	
	    	for(Student s: students) {
	    		
	    		list.addAll(dailyAppreciationRepository.findByStudentForToday(s.getStudent_id()));
	    		
	    	}
	    	
    	   	return new ResponseEntity<List<DailyAppreciation>>(list, HttpStatus.OK);
	    		    	
	    }
	    
	    
	    @GetMapping("/get/daily_appreciation/for/student")   
	    public ResponseEntity<List<DailyAppreciation>> getAllDailyAppreciationForStudent(@RequestParam(value="student_id", defaultValue="aEn24") Long student_id){
	    	
	    		    		    	
    	   	return new ResponseEntity<List<DailyAppreciation>>(dailyAppreciationRepository.findByStudent(student_id), HttpStatus.OK);
	    		    	
	    } 
	    
	    @GetMapping("/get/mood_log/for/student")   
	    public ResponseEntity<List<MoodUpdate>> getMoodLogForStudent(@RequestParam(value="student_id", defaultValue="aEn24") Long student_id){
	    		    		    	
    	   	return new ResponseEntity<List<MoodUpdate>>(moodUpdateRepository.findByStudentId(student_id), HttpStatus.OK);
	    		    	
	    } 
	    
	    
	    @GetMapping("/get/socio/emotional/score")   
	    public ResponseEntity<SocioEmotionalTestResult> getSocioEmotionalScore(@RequestParam(value="student_id", defaultValue="aEn24") Long student_id){
    	   	
	    	List<SocioEmotionalTestResult> list = socioEmotionalTestResultRepository.findByStudentId(student_id);
	    	
	    	if(list.size() > 0) {
	    		
	    		return new ResponseEntity<SocioEmotionalTestResult>(list.get(list.size()-1), HttpStatus.OK);
	    		
	    	}else {    		
	    		
	    		return new ResponseEntity<SocioEmotionalTestResult>(new SocioEmotionalTestResult(), HttpStatus.OK);
	    		
	    	}
	    	
	    	
	    }
	    
	    @GetMapping("/get/lesson/progress/for/student")   
	    public ResponseEntity<List<Lesson>> getLessonProgress(@RequestParam(value="student_id", defaultValue="aEn24") Long student_id){
	    	
	    	Student s = studentRepository.getOne(student_id);
	    	
	    	if(s == null) {
	    		new ResponseEntity<Notification>(HttpStatus.NOT_FOUND);
	    	}
	    	
	    	
	    	List<Lesson> allLessons = lessonRepository.findByGradeId(s.getGrade_id());
	    	
	    	//Get lesson associated with each record
	    	for(LessonRecord l:lessonRecordRepository.findByStudentId(s.getStudent_id())) {
	    			    		
	    		for(Lesson ln: allLessons) {
	    			
	    			if(ln.getLesson_id() == l.getLesson_id()) {
	    				
	    				ln.setCompleted(true);
	    				
	    			}
	    			
	    		}
	    			    		
	    	}	    	
	    		    		    	
    	   	return new ResponseEntity<List<Lesson>>(allLessons, HttpStatus.OK);
	    		    	
	    }  
	    
	    
 private boolean containsMood(String mood, String text) {
	    	
	    	if(text.toLowerCase().trim().contains(mood.toLowerCase().trim())) {
	    		
	    		return true;
	    		
	    	} else {
	    		
	    		String[] words = text.split("\\s+");
	    		
	    		for(String s:words) {
	    			
	    			if(calculate(s.toLowerCase().trim(), mood.toLowerCase().trim()) < 2) {
	    				
	    				return true;
	    				
	    			}
	    			
	    		}

	    		
	    	}
	    	
			return false;
	    	
	    	
	    }
	    
	    public int calculate(String x, String y) {
	    	
	        if (x.isEmpty()) {
	        	
	            return y.length();
	            
	        }
	 
	        if (y.isEmpty()) {
	        	
	            return x.length();
	            
	        } 
	 
	        int substitution = calculate(x.substring(1), y.substring(1)) 
	         + costOfSubstitution(x.charAt(0), y.charAt(0));
	        int insertion = calculate(x, y.substring(1)) + 1;
	        int deletion = calculate(x.substring(1), y) + 1;
	 
	        return min(substitution, insertion, deletion);
	    }
	 
	    public int costOfSubstitution(char a, char b) {
	        return a == b ? 0 : 1;
	    }
	 
	    public int min(int... numbers) {
	    	
	        return Arrays.stream(numbers)
	          .min().orElse(Integer.MAX_VALUE);
	    }    
	    
	    public final int ELEMENTARY = 1, MIDDLE = 2, HIGHSCHOOL = 3;

	    @GetMapping("/get-appreciation-items")   
	    public ResponseEntity<List<AppreciationItem>> getAppreciationItems(@RequestParam(value="grade_id", defaultValue="aEn24") int grade_id) {

	        List<AppreciationItem> appreciationItems = new ArrayList<>();

	        switch (grade_id) {

	            case ELEMENTARY:
	                appreciationItems.add(new AppreciationItem("Family", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-01_d5d2vw.png"));
	                appreciationItems.add(new AppreciationItem("Friends", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-05_wlkkvu.png"));
	                appreciationItems.add(new AppreciationItem("School", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-04_fau1yu.png"));
	                appreciationItems.add(new AppreciationItem("Me", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("My Pets", "https://res.cloudinary.com/veedbeta/image/upload/v1547834966/AppreciationIcon2-04_ongiie.png"));
	                appreciationItems.add(new AppreciationItem("My Teacher", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-06_qfjc0f.png"));


	                break;
	            case MIDDLE:

	                appreciationItems.add(new AppreciationItem("Family", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-01_d5d2vw.png"));
	                appreciationItems.add(new AppreciationItem("Friends", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-05_wlkkvu.png"));
	                appreciationItems.add(new AppreciationItem("School", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-04_fau1yu.png"));
	                appreciationItems.add(new AppreciationItem("Me", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("A Teacher", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-06_qfjc0f.png"));
	                appreciationItems.add(new AppreciationItem("Technology", "https://res.cloudinary.com/veedbeta/image/upload/v1547835026/AppreciationIcon2-01_1_fyczr2.png"));
	                appreciationItems.add(new AppreciationItem("Math", "https://res.cloudinary.com/veedbeta/image/upload/v1547835026/AppreciationIcon2-01_1_fyczr2.png"));
	                appreciationItems.add(new AppreciationItem("Music", "https://res.cloudinary.com/veedbeta/image/upload/v1547834969/AppreciationIcon2-02_xjyz5w.png"));
	                appreciationItems.add(new AppreciationItem("Art", "https://res.cloudinary.com/veedbeta/image/upload/v1547834971/AppreciationIcon2-03_weelnk.png"));

	                break;
	            case HIGHSCHOOL:

	                appreciationItems.add(new AppreciationItem("Family", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-01_d5d2vw.png"));
	                appreciationItems.add(new AppreciationItem("Friends", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-05_wlkkvu.png"));
	                appreciationItems.add(new AppreciationItem("School", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-04_fau1yu.png"));
	                appreciationItems.add(new AppreciationItem("Me", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("A Teacher", "https://res.cloudinary.com/veedbeta/image/upload/v1546901606/AppreciationIcon-06_qfjc0f.png"));
	                appreciationItems.add(new AppreciationItem("Technology", "https://res.cloudinary.com/veedbeta/image/upload/v1547835026/AppreciationIcon2-01_1_fyczr2.png"));
	                appreciationItems.add(new AppreciationItem("Math", "https://res.cloudinary.com/veedbeta/image/upload/v1547835026/AppreciationIcon2-01_1_fyczr2.png"));
	                appreciationItems.add(new AppreciationItem("Music", "https://res.cloudinary.com/veedbeta/image/upload/v1547834969/AppreciationIcon2-02_xjyz5w.png"));
	                appreciationItems.add(new AppreciationItem("Art", "https://res.cloudinary.com/veedbeta/image/upload/v1547834971/AppreciationIcon2-03_weelnk.png"));

	                break;
	            default:

	                appreciationItems.add(new AppreciationItem("Family", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("Friends", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("School", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("Me", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("A teacher", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("Technology", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("Math", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("Music", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));
	                appreciationItems.add(new AppreciationItem("Art", "https://res.cloudinary.com/veedbeta/image/upload/v1546843386/AppreciationIcon-03_gjled8.png"));

	        }

	        return new ResponseEntity<List<AppreciationItem>>(appreciationItems, HttpStatus.OK);
	    }

	    @GetMapping("/get-moods")   
	    public ResponseEntity<List<MoodWrapper>> getMoods(@RequestParam(value="grade_id", defaultValue="aEn24") int grade_id) {

	        List<MoodWrapper> moods = new ArrayList<>();

	        switch (grade_id) {

	            case ELEMENTARY:

	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272936/Mad_2FAngry_veznqf.jpg", "mad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272940/happy_bmcjwa.jpg", "happy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/Excited_pa3fkw.jpg", "excited"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/annoyed_ebv6bq.jpg", "annoyed"));

	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305076/sad_apgqzd.jpg", "sad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305061/Scared_svwem3.jpg", "scared"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305065/Shy_2FAnxious_pxwzrj.jpg", "shy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305090/silly_2Fwrite_my_own_mood_ahpyof.jpg", "silly"));


	                break;
	            case MIDDLE:
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272936/Mad_2FAngry_veznqf.jpg", "mad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272940/happy_bmcjwa.jpg", "happy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/Excited_pa3fkw.jpg", "excited"));

	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305076/sad_apgqzd.jpg", "sad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305061/Scared_svwem3.jpg", "scared"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305065/Shy_2FAnxious_pxwzrj.jpg", "shy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305090/silly_2Fwrite_my_own_mood_ahpyof.jpg", "silly"));


	                break;
	            case HIGHSCHOOL:
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272936/Mad_2FAngry_veznqf.jpg", "mad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272940/happy_bmcjwa.jpg", "happy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/Excited_pa3fkw.jpg", "excited"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/annoyed_ebv6bq.jpg", "annoyed"));

	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305076/sad_apgqzd.jpg", "sad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305061/Scared_svwem3.jpg", "scared"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305065/Shy_2FAnxious_pxwzrj.jpg", "shy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305090/silly_2Fwrite_my_own_mood_ahpyof.jpg", "silly"));


	                break;
	            default:
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272936/Mad_2FAngry_veznqf.jpg", "mad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540272940/happy_bmcjwa.jpg", "happy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/Excited_pa3fkw.jpg", "excited"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540273006/annoyed_ebv6bq.jpg", "annoyed"));

	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305076/sad_apgqzd.jpg", "sad"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305061/Scared_svwem3.jpg", "scared"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305065/Shy_2FAnxious_pxwzrj.jpg", "shy"));
	                moods.add(new MoodWrapper("https://res.cloudinary.com/veedbeta/image/upload/v1540305090/silly_2Fwrite_my_own_mood_ahpyof.jpg", "silly"));


	        }

	        return new ResponseEntity<List<MoodWrapper>>(moods, HttpStatus.OK);

	    }    
	   
}
