View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.usertracking.impl;
23  
24  import org.opencastproject.usertracking.api.UserSession;
25  
26  import javax.persistence.Access;
27  import javax.persistence.AccessType;
28  import javax.persistence.Column;
29  import javax.persistence.Entity;
30  import javax.persistence.Id;
31  import javax.persistence.Index;
32  import javax.persistence.NamedQueries;
33  import javax.persistence.NamedQuery;
34  import javax.persistence.Table;
35  import javax.xml.bind.annotation.XmlAccessType;
36  import javax.xml.bind.annotation.XmlAccessorType;
37  import javax.xml.bind.annotation.XmlElement;
38  import javax.xml.bind.annotation.XmlRootElement;
39  import javax.xml.bind.annotation.XmlType;
40  
41  @Entity(name = "UserSession")
42  @Access(AccessType.FIELD)
43  @Table(name = "oc_user_session", indexes = {
44      @Index(name = "IX_oc_user_session_user_id", columnList = "user_id")
45  })
46  @NamedQueries({
47      @NamedQuery(name = "findUserSessionBySessionId", query = "SELECT s FROM UserSession s WHERE s.sessionId = :sessionId") })
48  @XmlType(name = "session", namespace = "http://usertracking.opencastproject.org")
49  @XmlRootElement(name = "session", namespace = "http://usertracking.opencastproject.org")
50  @XmlAccessorType(XmlAccessType.FIELD)
51  public class UserSessionImpl implements UserSession {
52  
53    @Id
54    @Column(name = "session_id", length = 50)
55    @XmlElement(name = "sessionId")
56    private String sessionId;
57  
58    @Column(name = "user_id")
59    @XmlElement(name = "userId")
60    private String userId;
61  
62    @Column(name = "user_ip")
63    @XmlElement(name = "userIp")
64    private String userIp;
65  
66    @Column(name = "user_agent")
67    @XmlElement(name = "userAgent")
68    private String userAgent;
69  
70    /**
71     * No Arg Constructor for JAXB
72     */
73    public UserSessionImpl() {
74  
75    }
76  
77    @Override
78    public String getUserId() {
79      return userId;
80    }
81  
82    @Override
83    public void setUserId(String userId) {
84      this.userId = userId;
85    }
86  
87    @Override
88    public String getUserIp() {
89      return userIp;
90    }
91  
92    @Override
93    public void setUserIp(String userIp) {
94      this.userIp = userIp;
95    }
96  
97    @Override
98    public String getSessionId() {
99      return sessionId;
100   }
101 
102   @Override
103   public void setSessionId(String sessionId) {
104     this.sessionId = sessionId;
105   }
106 
107   @Override
108   public String getUserAgent() {
109     return userAgent;
110   }
111 
112   @Override
113   public void setUserAgent(String userAgent) {
114     this.userAgent = userAgent;
115   }
116 }