<commit_before>package it.cnr.droidpark;

import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.app.Application;
import android.util.Log;

public class ApplicationDroidPark extends Application {
	
	// TODO: persistence of the data missing
	
    private static final String TAG = "ApplicationDroidPark";
	public final Integer NUMBER_OF_GAMES = 4;
	public final Integer NUMBER_OF_COPIES = 50;
	

	private Set<ApplicationMsg> jobs;

	private Map<Integer, QueueMsg> queueList; // < IDgioco, QueueMsg > 
	private Map<Integer, Map<Integer, RatingMsg>> ratingList; // < IDgioco, <IDutente,RatingMsg> >
	private Map<Integer, Map<Integer, Opinion>> opinionList; // < IDgioco, <IDutente,Opinion> >
	
	@Override
	public void onCreate() {
		super.onCreate();
		
		jobs = new HashSet<ApplicationMsg>();
		queueList = new Hashtable<Integer, QueueMsg>(NUMBER_OF_GAMES);
		ratingList = new Hashtable<Integer, Map<Integer, RatingMsg>>(NUMBER_OF_GAMES);
		opinionList = new Hashtable<Integer, Map<Integer, Opinion>>(NUMBER_OF_GAMES);
	}
	
	public float getRatingAverage(Integer gameID) {
		float average = 0f;
		int numGameRatings = 0;
		
		Set<Entry<Integer, RatingMsg>> currentGameRatings = ratingList.get(gameID).entrySet();
		for(Entry<Integer, RatingMsg> entry : currentGameRatings) {
			average += entry.getValue().getEval();
			numGameRatings++;
		}
		
		return average / numGameRatings;
	}
	
	public Map<Integer, RatingMsg> getRatingMsg(Integer gameID) {
		return ratingList.get(gameID);
	}
	
	public QueueMsg getQueueMsg(Integer gameID) {
		return queueList.get(gameID);
	}
	
	public Opinion getGameOpinion(Integer gameID, Integer userID) {
		Map<Integer, Opinion> gameOpinions = opinionList.get(gameID);
		if(gameOpinions != null)
			return gameOpinions.get(userID);
		else<commit_msg>Demo opinions inserted<commit_after>package it.cnr.droidpark;

import java.util.Calendar;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.app.Application;
import android.util.Log;

public class ApplicationDroidPark extends Application {
	
	// TODO: persistence of the data missing
	
    private static final String TAG = "ApplicationDroidPark";
	public final Integer NUMBER_OF_GAMES = 4;
	public final Integer NUMBER_OF_COPIES = 50;
	

	private Set<ApplicationMsg> jobs;

	private Map<Integer, QueueMsg> queueList; // < IDgioco, QueueMsg > 
	private Map<Integer, Map<Integer, RatingMsg>> ratingList; // < IDgioco, <IDutente,RatingMsg> >
	private Map<Integer, Map<Integer, Opinion>> opinionList; // < IDgioco, <IDutente,Opinion> >
	
	@Override
	public void onCreate() {
		super.onCreate();
		
		jobs = new HashSet<ApplicationMsg>();
		queueList = new Hashtable<Integer, QueueMsg>(NUMBER_OF_GAMES);
		ratingList = new Hashtable<Integer, Map<Integer, RatingMsg>>(NUMBER_OF_GAMES);
		opinionList = new Hashtable<Integer, Map<Integer, Opinion>>(NUMBER_OF_GAMES);
		
		Map<Integer, Opinion> demoMap = new Hashtable<Integer, Opinion>();
		demoMap.put(466546, new Opinion(1, 466546, Calendar.getInstance().getTime(), "Questa è un'opinione"));
		demoMap.put(87678, new Opinion(1, 87678, Calendar.getInstance().getTime(), "Questa è un'altra opinione"));
		opinionList.put(1, demoMap);
	}
	
	public float getRatingAverage(Integer gameID) {
		float average = 0f;
		int numGameRatings = 0;
		
		Set<Entry<Integer, RatingMsg>> currentGameRatings = ratingList.get(gameID).entrySet();
		for(Entry<Integer, RatingMsg> entry : currentGameRatings) {
			average += entry.getValue().getEval();
			numGameRatings++;
		}
		
		return average / numGameRatings;
	}
	
	public Map<Integer, RatingMsg> getRatingMsg(Integer gameID) {
		return ratingList.get(gameID);
	}
	
	public QueueMsg getQueueMsg(Integer gameID) {
		return queueList.get(gameID);
	}
	
	public Opinion getGameOpinion(Integer gameID, Integer userID) {
		Map<Integer, Opinion> gameOpinions = opinionList.get(gameID);
		if(gameOpinions != null)
			return gameOpinions.get(userID);
		else
{'fraction_non_alphanumeric': 0.11462160176340926, 'fraction_numerical': 0.008572128337007103, 'mean_word_length': 5.197268588770865, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1682915', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1296, 'n_words': 308}