/*
 * Copyright (c) 2005-2010 KOM - Multimedia Communications Lab
 *
 * This file is part of PeerfactSim.KOM.
 * 
 * PeerfactSim.KOM is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * PeerfactSim.KOM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with PeerfactSim.KOM.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import org.json.JSONArray;
import org.json.JSONObject;

public class AvailableServices {
	private static HashMap<Long, String> iotServiceNames = new HashMap<>();
	private static HashMap<String,ArrayList<String>> iotServiceNamesDomains = new HashMap<>();
	private static HashMap<Long, String> dummyServiceNames = new HashMap<>();
	private static HashMap<Long, String> goodRequestsNames = new HashMap<>();
	private static HashMap<Long, String> baddRequestsNames = new HashMap<>();
	private static HashMap<Long, String> impossibleRequestsNames = new HashMap<>();
		
	public AvailableServices(JSONArray iotServiceNames, JSONObject iotServiceNamesDomains,JSONArray dummyServiceNames , JSONArray allGoodRequests, JSONArray allBadRequests, JSONArray allImpossibleRequests ) {
		for(int i=0;i<iotServiceNames.length();i++){
			getIoTServiceNames().put(Long.parseLong("" +i), "/"+iotServiceNames.getString(i));
		}
		for(int i=0;i<dummyServiceNames.length();i++){
			getDummyServiceNames().put(Long.parseLong("" +i), "/"+dummyServiceNames.getString(i));
		}
		for(int i=0;i<allGoodRequests.length();i++){
			getGoodRequestsNames().put(Long.parseLong("" +i), "/"+allGoodRequests.getString(i));
		}
		for(int i=0;i<allBadRequests.length();i++){
			getBaddRequestsNames().put(Long.parseLong("" +i), "/"+allBadRequests.getString(i));
		}
		for(int i=0;i<allImpossibleRequests.length();i++){
			getImpossibleRequestsNames().put(Long.parseLong("" +i), "/"+allImpossibleRequests.getString(i));
		}
		
		Set keys = iotServiceNamesDomains.keySet();
		Iterator it = keys.iterator();
		while(it.hasNext()){
			String key = (String)it.next();
			JSONArray names = iotServiceNamesDomains.getJSONArray(key);
			ArrayList<String> n = new ArrayList<>();
			for(int i = 0; i<names.length();i++){
				n.add("/"+names.getString(i));
			}
			getIotServiceNamesDomains().put(key, n);
		}
	}

	public static HashMap<Long, String> getIoTServiceNames() {
		return iotServiceNames;
	}

	public static void setIoTServiceNames(HashMap<Long, String> iotServiceNames) {
		AvailableServices.iotServiceNames = iotServiceNames;
	}

	public static HashMap<Long, String> getGoodRequestsNames() {
		return goodRequestsNames;
	}

	public static void setGoodRequestsNames(HashMap<Long, String> goodRequestsNames) {
		AvailableServices.goodRequestsNames = goodRequestsNames;
	}

	public static HashMap<Long, String> getBaddRequestsNames() {
		return baddRequestsNames;
	}

	public static void setBaddRequestsNames(HashMap<Long, String> baddRequestsNames) {
		AvailableServices.baddRequestsNames = baddRequestsNames;
	}

	public static HashMap<Long, String> getImpossibleRequestsNames() {
		return impossibleRequestsNames;
	}

	public static void setImpossibleRequestsNames(
			HashMap<Long, String> impossibleRequestsNames) {
		AvailableServices.impossibleRequestsNames = impossibleRequestsNames;
	}

	public static HashMap<Long, String> getDummyServiceNames() {
		return dummyServiceNames;
	}

	public static void setDummyServiceNames(HashMap<Long, String> dummyServiceNames) {
		AvailableServices.dummyServiceNames = dummyServiceNames;
	}

	public static HashMap<String, ArrayList<String>> getIotServiceNamesDomains() {
		return iotServiceNamesDomains;
	}

	public static void setIotServiceNamesDomains(
			HashMap<String, ArrayList<String>> iotServiceNamesDomains) {
		AvailableServices.iotServiceNamesDomains = iotServiceNamesDomains;
	}
}
