private void rateRecommendation(int rating){
		//Save last recommendation ID with current context and rating to case base in MongoDB
		GUI.disableButtons();
		if(!recommendationsToShow.isEmpty() && !contextInformation.isEmpty()&&useMongoDBConnection){
			HashMap<String, String> data = contextInformation;
			data.put("RecID", recommendationsToShow.firstElement().getID());
			data.put("UserRating", Integer.toString(rating));
			//Find very similar past cases and remove them from the database because we have better data now.
			Vector<Integer> recommendationID = new Vector<Integer>();
			recommendationID.add(Integer.parseInt(recommendationsToShow.firstElement().getID()));
			//Get all known past cases for the possible recommendation IDs
			Vector<HashMap<String, String>> pastCases = mongoDBConnection.getCasesForRecommendationIDs(recommendationID, caseDB, caseCollection);
			for(HashMap<String, String> pastCase : pastCases){
				if(recommenderFilter.calculateCaseSimilarity(data, pastCase)>recommenderFilter.casesEqualThreshold){
					Utils.printWithDate("Removing old case from database.", Utils.DEBUGLEVEL.DEBUG);
					mongoDBConnection.deleteDBObjectByObjectId(caseDB, caseCollection, pastCase.get("_id"));
				}
			}
			//Save new data to MongoDB
			Utils.printWithDate("Saving rated recommendation to MongoDB", Utils.DEBUGLEVEL.DEBUG);
			mongoDBConnection.insertDataDirectly(data, caseDB, caseCollection);
			recommendationsToShow.clear();
		}
		//generate next recommendation
		newRecommendation();
	}