Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/dao/hibernate/LeaderselectionUserDAO.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r6f9041abdcbc64a47af95ec0932c03c9c04e0838
--- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/dao/hibernate/LeaderselectionUserDAO.java (.../LeaderselectionUserDAO.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/dao/hibernate/LeaderselectionUserDAO.java (.../LeaderselectionUserDAO.java) (revision 6f9041abdcbc64a47af95ec0932c03c9c04e0838)
@@ -40,9 +40,6 @@
private static final String SQL_QUERY_FIND_BY_USER_ID_SESSION_ID = "from " + LeaderselectionUser.class.getName()
+ " as f" + " where user_id=? and f.leaderselectionSession.sessionId=?";
- private static final String SQL_QUERY_FIND_BY_LOGIN_NAME_SESSION_ID = "from " + LeaderselectionUser.class.getName()
- + " as f where login_name=? and f.leaderselectionSession.sessionId=?";
-
private static final String SQL_QUERY_FIND_BY_UID = "from " + LeaderselectionUser.class.getName() + " where uid=?";
private static final String FIND_BY_SESSION_ID = "from " + LeaderselectionUser.class.getName()
Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/leaderselectionApplicationContext.xml
===================================================================
diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r6f9041abdcbc64a47af95ec0932c03c9c04e0838
--- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/leaderselectionApplicationContext.xml (.../leaderselectionApplicationContext.xml) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd)
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/leaderselectionApplicationContext.xml (.../leaderselectionApplicationContext.xml) (revision 6f9041abdcbc64a47af95ec0932c03c9c04e0838)
@@ -46,6 +46,7 @@
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/Leaderselection.java
===================================================================
diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r6f9041abdcbc64a47af95ec0932c03c9c04e0838
--- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/Leaderselection.java (.../Leaderselection.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd)
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/Leaderselection.java (.../Leaderselection.java) (revision 6f9041abdcbc64a47af95ec0932c03c9c04e0838)
@@ -28,44 +28,57 @@
import java.util.HashSet;
import java.util.Set;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.tool.leaderselection.service.LeaderselectionService;
-/**
- *
- */
+@Entity
+@Table(name = "tl_lalead11_leaderselection")
public class Leaderselection implements java.io.Serializable, Cloneable {
-
private static final long serialVersionUID = 579733009969321015L;
+ private static Logger log = Logger.getLogger(LeaderselectionService.class.getName());
- static Logger log = Logger.getLogger(LeaderselectionService.class.getName());
-
- // Fields
+ @Id
+ @Column
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long uid;
+ @Column(name = "create_date")
private Date createDate;
+ @Column(name = "update_date")
private Date updateDate;
+ @Column(name = "create_by")
private Long createBy;
+ @Column
private String title;
+ @Column
private String instructions;
+ @Column(name = "content_in_use")
private boolean contentInUse;
+ @Column(name = "define_later")
private boolean defineLater;
+ @Column(name = "tool_content_id")
private Long toolContentId;
+
+ @OneToMany(mappedBy = "leaderselection")
+ @JoinColumn(name = "leaderselection_uid")
+ private Set leaderselectionSessions = new HashSet<>();
- private Set leaderselectionSessions;
-
- // Property accessors
- /**
- *
- *
- */
public Long getUid() {
return uid;
}
@@ -74,10 +87,6 @@
this.uid = uid;
}
- /**
- *
- *
- */
public Date getCreateDate() {
return createDate;
}
@@ -86,10 +95,6 @@
this.createDate = createDate;
}
- /**
- *
- *
- */
public Date getUpdateDate() {
return updateDate;
}
@@ -98,10 +103,6 @@
this.updateDate = updateDate;
}
- /**
- *
- *
- */
public Long getCreateBy() {
return createBy;
}
@@ -110,10 +111,6 @@
this.createBy = createBy;
}
- /**
- *
- *
- */
public String getTitle() {
return title;
}
@@ -122,10 +119,6 @@
this.title = title;
}
- /**
- *
- *
- */
public String getInstructions() {
return instructions;
}
@@ -134,10 +127,6 @@
this.instructions = instructions;
}
- /**
- *
- *
- */
public boolean isContentInUse() {
return contentInUse;
}
@@ -146,10 +135,6 @@
this.contentInUse = contentInUse;
}
- /**
- *
- *
- */
public boolean isDefineLater() {
return defineLater;
}
@@ -158,10 +143,6 @@
this.defineLater = defineLater;
}
- /**
- *
- *
- */
public Long getToolContentId() {
return toolContentId;
}
@@ -170,26 +151,14 @@
this.toolContentId = toolContentId;
}
- /**
- *
- *
- *
- *
- *
- */
- public Set getLeaderselectionSessions() {
+ public Set getLeaderselectionSessions() {
return leaderselectionSessions;
}
- public void setLeaderselectionSessions(Set leaderselectionSessions) {
+ public void setLeaderselectionSessions(Set leaderselectionSessions) {
this.leaderselectionSessions = leaderselectionSessions;
}
- /**
- * toString
- *
- * @return String
- */
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
@@ -244,7 +213,7 @@
leaderselection.setUid(null);
// create an empty set for the leaderselectionSession
- leaderselection.leaderselectionSessions = new HashSet();
+ leaderselection.leaderselectionSessions = new HashSet();
} catch (CloneNotSupportedException cnse) {
Leaderselection.log.error("Error cloning " + Leaderselection.class);
Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/LeaderselectionSession.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r6f9041abdcbc64a47af95ec0932c03c9c04e0838
--- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/LeaderselectionSession.java (.../LeaderselectionSession.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/LeaderselectionSession.java (.../LeaderselectionSession.java) (revision 6f9041abdcbc64a47af95ec0932c03c9c04e0838)
@@ -28,48 +28,68 @@
import java.util.HashSet;
import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+
import org.apache.log4j.Logger;
/**
- *
* Represents the tool session.
- *
- *
*/
-
+@Entity
+@Table(name = "tl_lalead11_session")
public class LeaderselectionSession implements java.io.Serializable {
-
private static Logger log = Logger.getLogger(LeaderselectionSession.class);
private static final long serialVersionUID = 4407078136514639026L;
- // Fields
+ @Id
+ @Column
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long uid;
+ @Column(name = "session_end_date")
private Date sessionEndDate;
+ @Column(name = "session_start_date")
private Date sessionStartDate;
+ @Column
private Integer status;
+ @Column(name = "session_id")
private Long sessionId;
+ @Column(name = "session_name")
private String sessionName;
+ @ManyToOne
+ @JoinColumn(name = "leaderselection_uid")
private Leaderselection leaderselection;
- private Set users;
+ @OneToMany(mappedBy = "leaderselectionSession")
+ @JoinColumn(name = "leaderselection_session_uid")
+ private Set users = new HashSet<>();
+ @ManyToOne
+ @JoinColumn(name = "group_leader_uid")
private LeaderselectionUser groupLeader;
- // Constructors
-
/** default constructor */
public LeaderselectionSession() {
}
/** full constructor */
public LeaderselectionSession(Date sessionEndDate, Date sessionStartDate, Integer status, Long sessionId,
- String sessionName, Leaderselection leaderselection, Set users) {
+ String sessionName, Leaderselection leaderselection, Set users) {
this.sessionEndDate = sessionEndDate;
this.sessionStartDate = sessionStartDate;
this.status = status;
@@ -79,12 +99,6 @@
this.users = users;
}
- // Property accessors
- /**
- *
- *
- */
-
public Long getUid() {
return this.uid;
}
@@ -93,11 +107,6 @@
this.uid = uid;
}
- /**
- *
- *
- */
-
public Date getSessionEndDate() {
return this.sessionEndDate;
}
@@ -106,11 +115,6 @@
this.sessionEndDate = sessionEndDate;
}
- /**
- *
- *
- */
-
public Date getSessionStartDate() {
return this.sessionStartDate;
}
@@ -119,11 +123,6 @@
this.sessionStartDate = sessionStartDate;
}
- /**
- *
- *
- */
-
public Integer getStatus() {
return this.status;
}
@@ -132,11 +131,6 @@
this.status = status;
}
- /**
- *
- *
- */
-
public Long getSessionId() {
return this.sessionId;
}
@@ -145,11 +139,6 @@
this.sessionId = sessionId;
}
- /**
- *
- *
- */
-
public String getSessionName() {
return this.sessionName;
}
@@ -158,12 +147,6 @@
this.sessionName = sessionName;
}
- /**
- *
- *
- *
- */
-
public Leaderselection getLeaderselection() {
return this.leaderselection;
}
@@ -172,25 +155,14 @@
this.leaderselection = leaderselection;
}
- /**
- *
- *
- *
- *
- */
-
- public Set getUsers() {
+ public Set getUsers() {
return this.users;
}
- public void setUsers(Set leaderselectionUsers) {
+ public void setUsers(Set leaderselectionUsers) {
this.users = leaderselectionUsers;
}
- /**
- *
- *
- */
public LeaderselectionUser getGroupLeader() {
return this.groupLeader;
}
@@ -199,11 +171,6 @@
this.groupLeader = groupLeader;
}
- /**
- * toString
- *
- * @return String
- */
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
@@ -249,7 +216,7 @@
LeaderselectionSession session = null;
try {
session = (LeaderselectionSession) super.clone();
- session.users = new HashSet();
+ session.users = new HashSet();
} catch (CloneNotSupportedException e) {
log.error("When clone " + LeaderselectionSession.class + " failed");
}
Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/LeaderselectionUser.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r6f9041abdcbc64a47af95ec0932c03c9c04e0838
--- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/LeaderselectionUser.java (.../LeaderselectionUser.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/model/LeaderselectionUser.java (.../LeaderselectionUser.java) (revision 6f9041abdcbc64a47af95ec0932c03c9c04e0838)
@@ -24,46 +24,58 @@
package org.lamsfoundation.lams.tool.leaderselection.model;
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
/**
- *
* Caches the user details. This allows the tool to be more efficient at displaying user names but means that when
* people's names change, they won't change in the "old" tool data.
- *
- *
*/
-
-public class LeaderselectionUser implements java.io.Serializable {
-
- /**
- *
- */
+@Entity
+@Table(name = "tl_lalead11_user")
+public class LeaderselectionUser implements Serializable {
private static final long serialVersionUID = -3701664859818409197L;
- // Fields
+ @Id
+ @Column
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long uid;
+ @Column(name = "user_id")
private Long userId;
+ @Column(name = "last_name")
private String lastName;
+ @Column(name = "first_name")
private String firstName;
+ @Column(name = "login_name")
private String loginName;
-
+
+ @ManyToOne
+ @JoinColumn(name = "leaderselection_session_uid")
private LeaderselectionSession leaderselectionSession;
+ @Column(name = "finishedActivity")
private boolean finishedActivity;
- // Constructors
-
/** default constructor */
public LeaderselectionUser() {
}
public LeaderselectionUser(UserDTO user, LeaderselectionSession leaderselectionSession) {
- this.userId = new Long(user.getUserID().intValue());
+ this.userId = user.getUserID().longValue();
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
this.loginName = user.getLogin();
@@ -80,10 +92,6 @@
this.leaderselectionSession = leaderselectionSession;
}
- // Property accessors
- /**
- *
- */
public Long getUid() {
return this.uid;
}
@@ -92,10 +100,6 @@
this.uid = uid;
}
- /**
- *
- *
- */
public Long getUserId() {
return this.userId;
}
@@ -104,10 +108,6 @@
this.userId = userId;
}
- /**
- *
- *
- */
public String getLastName() {
return this.lastName;
}
@@ -116,10 +116,6 @@
this.lastName = lastName;
}
- /**
- *
- *
- */
public String getLoginName() {
return loginName;
}
@@ -128,10 +124,6 @@
this.loginName = loginName;
}
- /**
- *
- *
- */
public String getFirstName() {
return this.firstName;
}
@@ -140,9 +132,6 @@
this.firstName = firstName;
}
- /**
- *
- */
public boolean isFinishedActivity() {
return finishedActivity;
}
@@ -151,11 +140,6 @@
this.finishedActivity = finishedActivity;
}
- /**
- *
- *
- *
- */
public LeaderselectionSession getLeaderselectionSession() {
return this.leaderselectionSession;
}
@@ -164,11 +148,6 @@
this.leaderselectionSession = leaderselectionSession;
}
- /**
- * toString
- *
- * @return String
- */
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionService.java
===================================================================
diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r6f9041abdcbc64a47af95ec0932c03c9c04e0838
--- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionService.java (.../LeaderselectionService.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd)
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionService.java (.../LeaderselectionService.java) (revision 6f9041abdcbc64a47af95ec0932c03c9c04e0838)
@@ -98,9 +98,9 @@
/* ************ Methods from ToolSessionManager ************* */
@Override
public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException {
- if (LeaderselectionService.logger.isDebugEnabled()) {
- LeaderselectionService.logger.debug("entering method createToolSession:" + " toolSessionId = "
- + toolSessionId + " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId
+ + " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId);
}
LeaderselectionSession session = new LeaderselectionSession();
@@ -164,9 +164,9 @@
@Override
public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException {
- if (LeaderselectionService.logger.isDebugEnabled()) {
- LeaderselectionService.logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId
- + " toContentId=" + toContentId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId + " toContentId="
+ + toContentId);
}
if (toContentId == null) {
@@ -201,8 +201,7 @@
public void removeToolContent(Long toolContentId) throws ToolException {
Leaderselection content = leaderselectionDAO.getByContentId(toolContentId);
if (content == null) {
- LeaderselectionService.logger
- .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId);
+ logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId);
return;
}
for (LeaderselectionSession session : (Set) content.getLeaderselectionSessions()) {
@@ -219,8 +218,8 @@
@Override
@SuppressWarnings("unchecked")
public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException {
- if (LeaderselectionService.logger.isDebugEnabled()) {
- LeaderselectionService.logger.debug(
+ if (logger.isDebugEnabled()) {
+ logger.debug(
"Removing Leader Selection state for user ID " + userId + " and toolContentId " + toolContentId);
}
@@ -331,8 +330,7 @@
LeaderselectionSession session = getSessionBySessionId(toolSessionId);
LeaderselectionUser newLeader = getUserByUID(userUid);
if ((session == null) || (newLeader == null)) {
- LeaderselectionService.logger
- .error("Wrong parameters supplied. SessionId=" + toolSessionId + " UserId=" + userUid);
+ logger.error("Wrong parameters supplied. SessionId=" + toolSessionId + " UserId=" + userUid);
return false;
}
@@ -376,11 +374,10 @@
@Override
public Long getDefaultContentIdBySignature(String toolSignature) {
- Long toolContentId = null;
- toolContentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature));
- if (toolContentId == null) {
+ long toolContentId = toolService.getToolDefaultContentIdBySignature(toolSignature);
+ if (toolContentId == 0) {
String error = "Could not retrieve default content id for this tool";
- LeaderselectionService.logger.error(error);
+ logger.error(error);
throw new LeaderselectionException(error);
}
return toolContentId;
@@ -392,7 +389,7 @@
Leaderselection defaultContent = getContentByContentId(defaultContentID);
if (defaultContent == null) {
String error = "Could not retrieve default content record for this tool";
- LeaderselectionService.logger.error(error);
+ logger.error(error);
throw new LeaderselectionException(error);
}
return defaultContent;
@@ -403,7 +400,7 @@
if (newContentID == null) {
String error = "Cannot copy the Leaderselection tools default content: + " + "newContentID is null";
- LeaderselectionService.logger.error(error);
+ logger.error(error);
throw new LeaderselectionException(error);
}
@@ -419,7 +416,7 @@
public Leaderselection getContentByContentId(Long toolContentID) {
Leaderselection leaderselection = leaderselectionDAO.getByContentId(toolContentID);
if (leaderselection == null) {
- LeaderselectionService.logger.debug("Could not find the content with toolContentID:" + toolContentID);
+ logger.debug("Could not find the content with toolContentID:" + toolContentID);
}
return leaderselection;
}
@@ -428,8 +425,7 @@
public LeaderselectionSession getSessionBySessionId(Long toolSessionId) {
LeaderselectionSession leaderselectionSession = leaderselectionSessionDAO.getBySessionId(toolSessionId);
if (leaderselectionSession == null) {
- LeaderselectionService.logger
- .debug("Could not find the leaderselection session with toolSessionID:" + toolSessionId);
+ logger.debug("Could not find the leaderselection session with toolSessionID:" + toolSessionId);
}
return leaderselectionSession;
}