<commit_before>package com.rehivetech.beeeon.network.demo;

import android.content.Context;

import com.rehivetech.beeeon.R;
import com.rehivetech.beeeon.household.device.Device;
import com.rehivetech.beeeon.household.device.DeviceType;
import com.rehivetech.beeeon.household.device.RefreshInterval;
import com.rehivetech.beeeon.household.gate.GateInfo;
import com.rehivetech.beeeon.household.location.Location;
import com.rehivetech.beeeon.household.user.User;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Helper class with data for DemoNetwork.
 *
 * @author vico
 * @author Robyer
 */
public class DemoData {

	private static final String GATE_1_ID = "64206";
	private static final String GATE_2_ID = "65260";

	private static final String GATE_1_LOCATION1 = "1";
	private static final String GATE_1_LOCATION2 = "2";
	private static final String GATE_1_LOCATION3 = "3";
	private static final String GATE_1_LOCATION4 = "4";
	private static final String GATE_2_LOCATION1 = "5";
	private static final String GATE_2_LOCATION2 = "6";

	/**
	 * Holds ID of newly created devices in this class.
	 *
	 * @see #createDevice(DeviceType, String, String)
	 */
	private int deviceIdGenerator = 1000;

	private final User mUser;

	/**
	 * @param user User object used in DemoNetwork, so it will have same correct name in gateusers data.
	 */
	public DemoData(User user) {
		mUser = user;
	}

	public List<GateInfo> getGates(Context context) {
		List<GateInfo> gatesList = new ArrayList<>();

		GateInfo demoGate1 = new GateInfo(GATE_1_ID, context.getString(R.string.gate_1_name));
		demoGate1.setRole(User.Role.Admin);
		demoGate1.setUtcOffset(500);
		demoGate1.setOwner(getGateOwner(demoGate1.getId()));
		gatesList.add(demoGate1);

		GateInfo demoGate2 = new GateInfo(GATE_2_ID, context.getString(R.string.gate_2_name));
		demoGate2.setRole(User.Role.Owner);
		demoGate2.setUtcOffset(60);
		demoGate2.setOwner(getGateOwner(demoGate2.getId()));
		gatesList.add(demoGate2);

		return gatesList;
	}

	/**
	 * Helper for getting gate's owner name.
	 *
	 * @param gateId
	 * @return
	 */
	private String getGateOwner(String gateId) {
		String owner = "";

		List<User> users = getUsers(gateId);
		for (User user : users) {
			if (user.getRole() == User.Role.Owner) {
				owner = user.getFullName();
			}
		}

		return owner;
	}

	public List<Location> getLocation(Context context, String gateId) {
		List<Location> locationsList = new ArrayList<>();

		switch (gateId) {
			case GATE_1_ID: {
				Location location1LivingRoom = new Location(GATE_1_LOCATION1, context.getString(R.string.loc_name_demo_living_room), GATE_1_ID, "5");
				Location location1BedRoom = new Location(GATE_1_LOCATION2, context.getString(R.string.loc_name_demo_bedroom), GATE_1_ID, "2");
				Location location1Kitchen = new Location(GATE_1_LOCATION3, context.getString(R.string.loc_name_demo_kitchen), GATE_1_ID, "4");
				Location location1Wc = new Location(GATE_1_LOCATION4, context.getString(R.string.loc_name_demo_wc), GATE_1_ID, "6");

				locationsList.add(location1LivingRoom);
				locationsList.add(location1BedRoom);
				locationsList.add(location1Kitchen);
				locationsList.add(location1Wc);
				break;
			}

			case GATE_2_ID: {
				Location location2GreenHouse = new Location(GATE_2_LOCATION1, context.getString(R.string.loc_name_demo_green_house), GATE_2_ID, "3");
				Location location2Sauna = new Location(GATE_2_LOCATION2, context.getString(R.string.loc_name_demo_sauna), GATE_2_ID, "1");

				locationsList.add(location2GreenHouse);
				locationsList.add(location2Sauna);
				break;
			}

			default: {
				//do nothing
				break;<commit_msg>Fix determining own role in demo mode<commit_after>package com.rehivetech.beeeon.network.demo;

import android.content.Context;

import com.rehivetech.beeeon.R;
import com.rehivetech.beeeon.household.device.Device;
import com.rehivetech.beeeon.household.device.DeviceType;
import com.rehivetech.beeeon.household.device.RefreshInterval;
import com.rehivetech.beeeon.household.gate.GateInfo;
import com.rehivetech.beeeon.household.location.Location;
import com.rehivetech.beeeon.household.user.User;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Helper class with data for DemoNetwork.
 *
 * @author vico
 * @author Robyer
 */
public class DemoData {

	private static final String GATE_1_ID = "64206";
	private static final String GATE_2_ID = "65260";

	private static final String GATE_1_LOCATION1 = "1";
	private static final String GATE_1_LOCATION2 = "2";
	private static final String GATE_1_LOCATION3 = "3";
	private static final String GATE_1_LOCATION4 = "4";
	private static final String GATE_2_LOCATION1 = "5";
	private static final String GATE_2_LOCATION2 = "6";

	/**
	 * Holds ID of newly created devices in this class.
	 *
	 * @see #createDevice(DeviceType, String, String)
	 */
	private int deviceIdGenerator = 1000;

	private final User mUser;

	/**
	 * @param user User object used in DemoNetwork, so it will have same correct name in gateusers data.
	 */
	public DemoData(User user) {
		mUser = user;
	}

	public List<GateInfo> getGates(Context context) {
		List<GateInfo> gatesList = new ArrayList<>();

		GateInfo demoGate1 = new GateInfo(GATE_1_ID, context.getString(R.string.gate_1_name));
		demoGate1.setRole(getMyRole(demoGate1.getId()));
		demoGate1.setUtcOffset(500);
		demoGate1.setOwner(getGateOwner(demoGate1.getId()));
		gatesList.add(demoGate1);

		GateInfo demoGate2 = new GateInfo(GATE_2_ID, context.getString(R.string.gate_2_name));
		demoGate1.setRole(getMyRole(demoGate2.getId()));
		demoGate2.setUtcOffset(60);
		demoGate2.setOwner(getGateOwner(demoGate2.getId()));
		gatesList.add(demoGate2);

		return gatesList;
	}

	/**
	 * Helper for getting gate's owner name.
	 *
	 * @param gateId
	 * @return
	 */
	private String getGateOwner(String gateId) {
		String owner = "";

		List<User> users = getUsers(gateId);
		for (User user : users) {
			if (user.getRole() == User.Role.Owner) {
				owner = user.getFullName();
			}
		}

		return owner;
	}

	/**
	 * Helper for getting my role for given gate's id.
	 *
	 * @param gateId
	 * @return
	 */
	private User.Role getMyRole(String gateId) {
		User.Role role = User.Role.Guest;

		List<User> users = getUsers(gateId);
		for (User user : users) {
			if (user.getId().equals(mUser.getId())) {
				role = user.getRole();
			}
		}

		return role;
	}

	public List<Location> getLocation(Context context, String gateId) {
		List<Location> locationsList = new ArrayList<>();

		switch (gateId) {
			case GATE_1_ID: {
				Location location1LivingRoom = new Location(GATE_1_LOCATION1, context.getString(R.string.loc_name_demo_living_room), GATE_1_ID, "5");
				Location location1BedRoom = new Location(GATE_1_LOCATION2, context.getString(R.string.loc_name_demo_bedroom), GATE_1_ID, "2");
				Location location1Kitchen = new Location(GATE_1_LOCATION3, context.getString(R.string.loc_name_demo_kitchen), GATE_1_ID, "4");
				Location location1Wc = new Location(GATE_1_LOCATION4, context.getString(R.string.loc_name_demo_wc), GATE_1_ID, "6");

				locationsList.add(location1LivingRoom);
				locationsList.add(location1BedRoom);
				locationsList.add(location1Kitchen);
				locationsList.add(location1Wc);
				break;
			}

			case GATE_2_ID: {
				Location location2GreenHouse = new Location(GATE_2_LOCATION1, context.getString(R.string.loc_name_demo_green_house), GATE_2_ID, "3");
				Location location2Sauna = new Location(GATE_2_LOCATION2, context.getString(R.string.loc_name_demo_sauna), GATE_2_ID, "1");

				locationsList.add(location2GreenHouse);
				locationsList.add(location2Sauna);
				break;
			}

			default: {
				//do nothing
				break;
{'fraction_non_alphanumeric': 0.11300802650019111, 'fraction_numerical': 0.023952095808383235, 'mean_word_length': 4.738304093567251, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '3111423', 'n_tokens_mistral': 3021, 'n_tokens_neox': 2723, 'n_words': 555}