/** * Copyright 2010 The University of Nottingham * * This file is part of lobbyservice. * * lobbyservice is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * lobbyservice 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with lobbyservice. If not, see <http://www.gnu.org/licenses/>. * */ package uk.ac.horizon.ug.lobby.model; import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import com.google.appengine.api.datastore.Key; /** * @author cmg * */ @Entity public class GameInstanceFactory { /** key - autogenerated */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key key; /** game template id - for search and instance */ private String gameTemplateId; /** server - for lifecycle and instance */ private Key gameServerId; /** factory type, e.g. SCHEDULED */ private GameInstanceFactoryType type; /** title - for search and instance*/ private String title; /** title - for instance*/ private String instanceTitle; /** min (start) time (0 for as far back as possible) */ private long minTime; /** max (start/end) time (0 is NOT unspecified - it is 1970) */ private long maxTime; /** CRON-style start time pattern - for search, lifecycle and instance start time*/ private String startTimeCron; /** JSON encoding of time options from startTimeCron - for search, lifecycle and instance start time*/ @Lob private String startTimeOptionsJson; /** duration (milliseconds) - for search, lifecycle and instance end time*/ private long durationMs; /** location name - human consumption - for search and instance*/ private String locationName; /** template location type - future extension e.g. to first player's location */ private GameInstanceFactoryLocationType locationType; /** latitude - for search and instance */ private int latitudeE6; /** longitude - for search and instance */ private int longitudeE6; /** radius metres (or 0) - for search and instance */ private double radiusMetres; /** visibility - i.e. seen by browsers or not - for search */ private GameTemplateVisibility visibility; /** visibility - i.e. seen by browsers or not - for instance */ private GameTemplateVisibility instanceVisibility; /** max num slots - for instance */ private int maxNumSlots; /** allow anonymous (non-account) clients - for instance */ private boolean allowAnonymousClients; /** instance factory status - for lifecycle/new instance creation */ private GameInstanceFactoryStatus status; /** server configuration info (JSON) - for lifecycle */ private String serverConfigJson; /** time (delta) to create game on server before scheduled start - for lifecycle */ private long serverCreateTimeOffsetMs; /** time (delta) to 'start' game on server before scheduled start - for lifecycle */ private long serverStartTimeOffsetMs; /** time (delta) to mark game on server as 'ending' related to nominal endTime - for lifecycle */ private long serverEndingTimeOffsetMs; /** time (delta) to end game on server related to nominal endTime - for lifecycle */ private long serverEndTimeOffsetMs; /** create an instance for anonymous (non-account) client - ON_DEMAND instance creation constraint(s) */ private boolean createForAnonymousClient; /** create an instance with more limited visibility if requested by client - for ON_DEMAND */ private boolean allowPrivateInstances; /** new instance current quota (1 token = 1 instance) */ private int newInstanceTokens; /** new instance max momentary quota (token bucket size) */ private int newInstanceTokensMax; /** new instance quota increase rate */ private int newInstanceTokensPerHour; /** last (java) time that this Factory was checked for new instances to create */ private long lastInstanceCheckTime; /** (java) start time of last created instance */ private long lastInstanceStartTime; /** time ahead that instances should be created */ private long instanceCreateTimeWindowMs; /** management/audit counter of instances created from this template */ @Embedded @AttributeOverrides({ @AttributeOverride(name="value", column= @Column(name="newInstanceCounterValue")), @AttributeOverride(name="startTime", column= @Column(name="newInstanceCounterStartTime")), @AttributeOverride(name="updateTime", column= @Column(name="newInstanceCounterUpdateTime")) }) private AuditCounter newInstanceCounter; /** cons */ public GameInstanceFactory() { } /** * @return the key */ public Key getKey() { return key; } /** * @param key the key to set */ public void setKey(Key key) { this.key = key; } /** * @return the gameTemplateId */ public String getGameTemplateId() { return gameTemplateId; } /** * @param gameTemplateId the gameTemplateId to set */ public void setGameTemplateId(String gameTemplateId) { this.gameTemplateId = gameTemplateId; } /** * @return the gameServerId */ public Key getGameServerId() { return gameServerId; } /** * @param gameServerId the gameServerId to set */ public void setGameServerId(Key gameServerId) { this.gameServerId = gameServerId; } /** * @return the title */ public String getTitle() { return title; } /** * @param title the title to set */ public void setTitle(String title) { this.title = title; } /** * @return the startTimeCron */ public String getStartTimeCron() { return startTimeCron; } /** * @param startTimeCron the startTimeCron to set */ public void setStartTimeCron(String startTimeCron) { this.startTimeCron = startTimeCron; } /** * @return the durationMs */ public long getDurationMs() { return durationMs; } /** * @param durationMs the durationMs to set */ public void setDurationMs(long durationMs) { this.durationMs = durationMs; } /** * @return the locationName */ public String getLocationName() { return locationName; } /** * @param locationName the locationName to set */ public void setLocationName(String locationName) { this.locationName = locationName; } /** * @return the locationType */ public GameInstanceFactoryLocationType getLocationType() { return locationType; } /** * @param locationType the locationType to set */ public void setLocationType(GameInstanceFactoryLocationType locationType) { this.locationType = locationType; } /** * @return the latitudeE6 */ public int getLatitudeE6() { return latitudeE6; } /** * @param latitudeE6 the latitudeE6 to set */ public void setLatitudeE6(int latitudeE6) { this.latitudeE6 = latitudeE6; } /** * @return the longitudeE6 */ public int getLongitudeE6() { return longitudeE6; } /** * @param longitudeE6 the longitudeE6 to set */ public void setLongitudeE6(int longitudeE6) { this.longitudeE6 = longitudeE6; } /** * @return the radiusMetres */ public double getRadiusMetres() { return radiusMetres; } /** * @param radiusMetres the radiusMetres to set */ public void setRadiusMetres(double radiusMetres) { this.radiusMetres = radiusMetres; } /** * @return the visibility */ public GameTemplateVisibility getVisibility() { return visibility; } /** * @param visibility the visibility to set */ public void setVisibility(GameTemplateVisibility visibility) { this.visibility = visibility; } /** * @return the maxNumSlots */ public int getMaxNumSlots() { return maxNumSlots; } /** * @param maxNumSlots the maxNumSlots to set */ public void setMaxNumSlots(int maxNumSlots) { this.maxNumSlots = maxNumSlots; } /** * @return the allowAnonymousClients */ public boolean isAllowAnonymousClients() { return allowAnonymousClients; } /** * @param allowAnonymousClients the allowAnonymousClients to set */ public void setAllowAnonymousClients(boolean allowAnonymousClients) { this.allowAnonymousClients = allowAnonymousClients; } /** * @return the serverConfigJson */ public String getServerConfigJson() { return serverConfigJson; } /** * @param serverConfigJson the serverConfigJson to set */ public void setServerConfigJson(String serverConfigJson) { this.serverConfigJson = serverConfigJson; } /** * @return the serverCreateTimeOffsetMs */ public long getServerCreateTimeOffsetMs() { return serverCreateTimeOffsetMs; } /** * @param serverCreateTimeOffsetMs the serverCreateTimeOffsetMs to set */ public void setServerCreateTimeOffsetMs(long serverCreateTimeOffsetMs) { this.serverCreateTimeOffsetMs = serverCreateTimeOffsetMs; } /** * @return the serverStartTimeOffsetMs */ public long getServerStartTimeOffsetMs() { return serverStartTimeOffsetMs; } /** * @param serverStartTimeOffsetMs the serverStartTimeOffsetMs to set */ public void setServerStartTimeOffsetMs(long serverStartTimeOffsetMs) { this.serverStartTimeOffsetMs = serverStartTimeOffsetMs; } /** * @return the serverEndingTimeOffsetMs */ public long getServerEndingTimeOffsetMs() { return serverEndingTimeOffsetMs; } /** * @param serverEndingTimeOffsetMs the serverEndingTimeOffsetMs to set */ public void setServerEndingTimeOffsetMs(long serverEndingTimeOffsetMs) { this.serverEndingTimeOffsetMs = serverEndingTimeOffsetMs; } /** * @return the serverEndTimeOffsetMs */ public long getServerEndTimeOffsetMs() { return serverEndTimeOffsetMs; } /** * @param serverEndTimeOffsetMs the serverEndTimeOffsetMs to set */ public void setServerEndTimeOffsetMs(long serverEndTimeOffsetMs) { this.serverEndTimeOffsetMs = serverEndTimeOffsetMs; } /** * @return the createForAnonymousClient */ public boolean isCreateForAnonymousClient() { return createForAnonymousClient; } /** * @param createForAnonymousClient the createForAnonymousClient to set */ public void setCreateForAnonymousClient(boolean createForAnonymousClient) { this.createForAnonymousClient = createForAnonymousClient; } /** * @return the status */ public GameInstanceFactoryStatus getStatus() { return status; } /** * @param status the status to set */ public void setStatus(GameInstanceFactoryStatus status) { this.status = status; } /** * @return the instanceTitle */ public String getInstanceTitle() { return instanceTitle; } /** * @param instanceTitle the instanceTitle to set */ public void setInstanceTitle(String instanceTitle) { this.instanceTitle = instanceTitle; } /** * @return the minTime */ public long getMinTime() { return minTime; } /** * @param minTime the minTime to set */ public void setMinTime(long minTime) { this.minTime = minTime; } /** * @return the maxTime */ public long getMaxTime() { return maxTime; } /** * @param maxTime the maxTime to set */ public void setMaxTime(long maxTime) { this.maxTime = maxTime; } /** * @return the instanceVisibility */ public GameTemplateVisibility getInstanceVisibility() { return instanceVisibility; } /** * @param instanceVisibility the instanceVisibility to set */ public void setInstanceVisibility(GameTemplateVisibility instanceVisibility) { this.instanceVisibility = instanceVisibility; } /** * @return the lastInstanceCheckTime */ public long getLastInstanceCheckTime() { return lastInstanceCheckTime; } /** * @param lastInstanceCheckTime the lastInstanceCheckTime to set */ public void setLastInstanceCheckTime(long lastInstanceCheckTime) { this.lastInstanceCheckTime = lastInstanceCheckTime; } /** * @return the instanceCreateTimeWindowMs */ public long getInstanceCreateTimeWindowMs() { return instanceCreateTimeWindowMs; } /** * @param instanceCreateTimeWindowMs the instanceCreateTimeWindowMs to set */ public void setInstanceCreateTimeWindowMs(long instanceCreateTimeWindowMs) { this.instanceCreateTimeWindowMs = instanceCreateTimeWindowMs; } /** * @return the newInstanceTokens */ public int getNewInstanceTokens() { return newInstanceTokens; } /** * @param newInstanceTokens the newInstanceTokens to set */ public void setNewInstanceTokens(int newInstanceTokens) { this.newInstanceTokens = newInstanceTokens; } /** * @return the newInstanceTokensMax */ public int getNewInstanceTokensMax() { return newInstanceTokensMax; } /** * @param newInstanceTokensMax the newInstanceTokensMax to set */ public void setNewInstanceTokensMax(int newInstanceTokensMax) { this.newInstanceTokensMax = newInstanceTokensMax; } /** * @return the newInstanceTokensPerHour */ public int getNewInstanceTokensPerHour() { return newInstanceTokensPerHour; } /** * @param newInstanceTokensPerHour the newInstanceTokensPerHour to set */ public void setNewInstanceTokensPerHour(int newInstanceTokensPerHour) { this.newInstanceTokensPerHour = newInstanceTokensPerHour; } /** * @return the lastInstanceStartTime */ public long getLastInstanceStartTime() { return lastInstanceStartTime; } /** * @param lastInstanceStartTime the lastInstanceStartTime to set */ public void setLastInstanceStartTime(long lastInstanceStartTime) { this.lastInstanceStartTime = lastInstanceStartTime; } /** * @return the startTimeOptionsJson */ public String getStartTimeOptionsJson() { return startTimeOptionsJson; } /** * @param startTimeOptionsJson the startTimeOptionsJson to set */ public void setStartTimeOptionsJson(String startTimeOptionsJson) { this.startTimeOptionsJson = startTimeOptionsJson; } /** * @return the type */ public GameInstanceFactoryType getType() { return type; } /** * @param type the type to set */ public void setType(GameInstanceFactoryType type) { this.type = type; } /** * @return the newInstanceCounter */ public AuditCounter getNewInstanceCounter() { return newInstanceCounter; } /** * @param newInstanceCounter the newInstanceCounter to set */ public void setNewInstanceCounter(AuditCounter newInstanceCounter) { this.newInstanceCounter = newInstanceCounter; } /** * @return the allowPrivateInstances */ public boolean isAllowPrivateInstances() { return allowPrivateInstances; } /** * @param allowPrivateInstances the allowPrivateInstances to set */ public void setAllowPrivateInstances(boolean allowPrivateInstances) { this.allowPrivateInstances = allowPrivateInstances; } }