<commit_before>package org.ihtsdo.otf.mapping.jpa;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.ihtsdo.otf.mapping.model.MapUser;
import org.ihtsdo.otf.mapping.model.MapUserPreferences;

/**
 * Set of preferences for a user Preferences are accessed via services.
 */
@Entity
// @UniqueConstraint here is being used to create an index, not to enforce
// uniqueness
@Table(name = "map_user_preferences", uniqueConstraints = {
  @UniqueConstraint(columnNames = {
      "mapUser_id", "id"
  })
})
@XmlRootElement(name = "mapUserPreferences")
public class MapUserPreferencesJpa implements MapUserPreferences {

  /** The id. */
  @Id
  @GeneratedValue
  private Long id;

  /** The map user id. */
  @OneToOne(targetEntity = MapUserJpa.class)
  private MapUser mapUser;

  /** The time of last login (in ms since 1970). */
  @Column(nullable = false)
  private Long lastLogin = (new Date()).getTime();

  /** The map project id for the project last worked on. */
  @Column(nullable = false)
  private Long mapProjectId;
  
  /** The last tab on the Assigned Work widget on which the user was working. */
  @Column(nullable = false)
  private String lastAssignedTab;
  
  /** The last radio button that was selected on the Assigned Work widget. */
  @Column(nullable = true)
  private String lastAssignedRadio;


  /** The map of name to model dashboards. */
  @ElementCollection(fetch = FetchType.EAGER)
  @MapKeyColumn(name = "dashboardModels_KEY")
  @Column(name = "dashboardModels", length = 4000)
  @CollectionTable(name = "map_user_preferences_dashboard_models", joinColumns = @JoinColumn(name = "id"))
  private Map<String, String> dashboardModels = new HashMap<>();
<commit_msg>MAP-1496: Allow lastAssignedTab to be null.  Enables Reset Demo Db to create/update db.<commit_after>package org.ihtsdo.otf.mapping.jpa;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.ihtsdo.otf.mapping.model.MapUser;
import org.ihtsdo.otf.mapping.model.MapUserPreferences;

/**
 * Set of preferences for a user Preferences are accessed via services.
 */
@Entity
// @UniqueConstraint here is being used to create an index, not to enforce
// uniqueness
@Table(name = "map_user_preferences", uniqueConstraints = {
  @UniqueConstraint(columnNames = {
      "mapUser_id", "id"
  })
})
@XmlRootElement(name = "mapUserPreferences")
public class MapUserPreferencesJpa implements MapUserPreferences {

  /** The id. */
  @Id
  @GeneratedValue
  private Long id;

  /** The map user id. */
  @OneToOne(targetEntity = MapUserJpa.class)
  private MapUser mapUser;

  /** The time of last login (in ms since 1970). */
  @Column(nullable = false)
  private Long lastLogin = (new Date()).getTime();

  /** The map project id for the project last worked on. */
  @Column(nullable = false)
  private Long mapProjectId;
  
  /** The last tab on the Assigned Work widget on which the user was working. */
  @Column(nullable = true)
  private String lastAssignedTab;
  
  /** The last radio button that was selected on the Assigned Work widget. */
  @Column(nullable = true)
  private String lastAssignedRadio;


  /** The map of name to model dashboards. */
  @ElementCollection(fetch = FetchType.EAGER)
  @MapKeyColumn(name = "dashboardModels_KEY")
  @Column(name = "dashboardModels", length = 4000)
  @CollectionTable(name = "map_user_preferences_dashboard_models", joinColumns = @JoinColumn(name = "id"))
  private Map<String, String> dashboardModels = new HashMap<>();

{'fraction_non_alphanumeric': 0.10568751361952496, 'fraction_numerical': 0.004358247984310307, 'mean_word_length': 4.7518796992481205, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2500089', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1359, 'n_words': 386}