Fisheye: Tag 374f1e3729c3892074184bbd480ae87bce110cfd refers to a dead (removed) revision in file `lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 374f1e3729c3892074184bbd480ae87bce110cfd refers to a dead (removed) revision in file `lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteQueContent.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 374f1e3729c3892074184bbd480ae87bce110cfd refers to a dead (removed) revision in file `lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteQueUsr.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 374f1e3729c3892074184bbd480ae87bce110cfd refers to a dead (removed) revision in file `lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteSession.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 374f1e3729c3892074184bbd480ae87bce110cfd refers to a dead (removed) revision in file `lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java (.../VoteContentDAO.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java (.../VoteContentDAO.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -42,14 +42,14 @@ public class VoteContentDAO extends LAMSBaseDAO implements IVoteContentDAO { private static final String FIND_VOTE_CONTENT = "from " + VoteContent.class.getName() - + " as vote where content_id=?"; + + " as vote where content_id=:contentId"; private static final String LOAD_VOTE_BY_SESSION = "select vote from VoteContent vote left join fetch " + "vote.voteSessions session where session.voteSessionId=:sessionId"; @Override public VoteContent getVoteContentByUID(Long uid) { - return (VoteContent) this.getSession().get(VoteContent.class, uid); + return this.getSession().get(VoteContent.class, uid); } @Override @@ -60,9 +60,9 @@ @SuppressWarnings("unchecked") @Override public VoteContent getVoteContentByContentId(Long voteContentId) { - String query = "from VoteContent as vote where vote.voteContentId = ?"; + String query = "from VoteContent as vote where vote.voteContentId = :voteContentId"; List list = getSessionFactory().getCurrentSession().createQuery(query) - .setLong(0, voteContentId.longValue()).list(); + .setParameter("voteContentId", voteContentId).list(); if (list != null && list.size() > 0) { VoteContent vote = list.get(0); @@ -74,7 +74,7 @@ @Override public VoteContent getVoteContentBySession(final Long voteSessionId) { return (VoteContent) getSession().createQuery(VoteContentDAO.LOAD_VOTE_BY_SESSION) - .setLong("sessionId", voteSessionId.longValue()).uniqueResult(); + .setParameter("sessionId", voteSessionId).uniqueResult(); } @Override @@ -92,7 +92,7 @@ public void removeVoteById(Long voteContentId) { if (voteContentId != null) { List list = getSessionFactory().getCurrentSession() - .createQuery(VoteContentDAO.FIND_VOTE_CONTENT).setLong(0, voteContentId.longValue()).list(); + .createQuery(VoteContentDAO.FIND_VOTE_CONTENT).setParameter("contentId", voteContentId).list(); if (list != null && list.size() > 0) { VoteContent vote = list.get(0); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java (.../VoteQueContentDAO.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java (.../VoteQueContentDAO.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -37,25 +37,23 @@ @Repository public class VoteQueContentDAO extends LAMSBaseDAO implements IVoteQueContentDAO { - // private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID_SIMPLE = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId"; + private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from voteQueContent in class VoteQueContent where voteQueContent.voteContent.uid=:voteContentId"; - private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId"; + private static final String LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.displayOrder=:displayOrder and voteQueContent.voteContent.uid=:voteContentUid"; - private static final String LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.displayOrder=:displayOrder and voteQueContent.voteContentId=:voteContentUid"; + private static final String SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.voteContent.uid=:voteContentId order by voteQueContent.displayOrder"; - private static final String SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId order by voteQueContent.displayOrder"; - @Override public VoteQueContent getQuestionByUid(Long uid) { - return (VoteQueContent) this.getSession().get(VoteQueContent.class, uid); + return this.getSession().get(VoteQueContent.class, uid); } @SuppressWarnings("unchecked") @Override public VoteQueContent getDefaultVoteContentFirstQuestion() { final long voteContentId = 1; List list = getSessionFactory().getCurrentSession() - .createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setLong("voteContentId", voteContentId).list(); + .createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setParameter("voteContentId", voteContentId).list(); if (list != null && list.size() > 0) { VoteQueContent voteq = list.get(0); @@ -68,8 +66,8 @@ @Override public VoteQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long voteContentUid) { List list = getSessionFactory().getCurrentSession() - .createQuery(LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER).setLong("displayOrder", displayOrder.longValue()) - .setLong("voteContentUid", voteContentUid.longValue()).list(); + .createQuery(LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER).setParameter("displayOrder", displayOrder.intValue()) + .setParameter("voteContentUid", voteContentUid).list(); if (list != null && list.size() > 0) { VoteQueContent voteq = list.get(0); @@ -82,7 +80,8 @@ @Override public List getAllQuestionsSorted(final long voteContentId) { List list = getSessionFactory().getCurrentSession() - .createQuery(SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER).setLong("voteContentId", voteContentId).list(); + .createQuery(SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER).setParameter("voteContentId", voteContentId) + .list(); return list; } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteSessionDAO.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteSessionDAO.java (.../VoteSessionDAO.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteSessionDAO.java (.../VoteSessionDAO.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -41,7 +41,7 @@ public class VoteSessionDAO extends LAMSBaseDAO implements IVoteSessionDAO { private static final String FIND_VOTE_SESSION_CONTENT = "from " + VoteSession.class.getName() - + " as votes where vote_session_id=?"; + + " as votes where vote_session_id=:voteSessionId"; private static final String LOAD_VOTESESSION_BY_USER = "select votes from VoteSession votes left join fetch " + "votes.voteQueUsers user where user.queUsrId=:userId"; @@ -52,16 +52,16 @@ @Override public VoteSession getVoteSessionByUID(Long sessionUid) { - return (VoteSession) this.getSession().get(VoteSession.class, sessionUid); + return this.getSession().get(VoteSession.class, sessionUid); } @SuppressWarnings("unchecked") @Override public VoteSession getSessionBySessionId(Long voteSessionId) { - String query = "from VoteSession votes where votes.voteSessionId=?"; + String query = "from VoteSession votes where votes.voteSessionId=:voteSessionId"; List list = getSessionFactory().getCurrentSession().createQuery(query) - .setLong(0, voteSessionId.longValue()).list(); + .setParameter("voteSessionId", voteSessionId).list(); if (list != null && list.size() > 0) { VoteSession vote = list.get(0); @@ -94,7 +94,7 @@ @Override public void removeVoteSessionByUID(Long uid) { - VoteSession votes = (VoteSession) getSession().get(VoteSession.class, uid); + VoteSession votes = getSession().get(VoteSession.class, uid); this.getSession().delete(votes); } @@ -103,7 +103,7 @@ public void removeVoteSessionById(Long voteSessionId) { if (voteSessionId != null) { List list = getSessionFactory().getCurrentSession().createQuery(FIND_VOTE_SESSION_CONTENT) - .setLong(0, voteSessionId.longValue()).list(); + .setParameter("voteSessionId", voteSessionId).list(); if (list != null && list.size() > 0) { VoteSession vote = list.get(0); @@ -121,8 +121,8 @@ @Override public VoteSession getVoteSessionByUser(final Long userId) { - return (VoteSession) getSession().createQuery(LOAD_VOTESESSION_BY_USER).setLong("userId", userId.longValue()) - .uniqueResult(); + return (VoteSession) getSession().createQuery(LOAD_VOTESESSION_BY_USER) + .setParameter("userId", userId.longValue()).uniqueResult(); } @Override Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUserDAO.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUserDAO.java (.../VoteUserDAO.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUserDAO.java (.../VoteUserDAO.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -41,15 +41,15 @@ @Repository public class VoteUserDAO extends LAMSBaseDAO implements IVoteUserDAO { - private static final String LOAD_USER_FOR_SESSION = "from voteQueUsr in class VoteQueUsr where voteQueUsr.voteSessionId= :voteSessionId"; + private static final String LOAD_USER_FOR_SESSION = "from voteQueUsr in class VoteQueUsr where voteQueUsr.voteSession.uid= :voteSessionId"; @SuppressWarnings("unchecked") @Override public VoteQueUsr getUserByUserId(Long userId) { String query = "from VoteQueUsr user where user.queUsrId=?"; List list = getSessionFactory().getCurrentSession().createQuery(query) - .setLong(0, userId.longValue()).list(); + .setParameter("voteSessionId", userId.longValue()).list(); if (list != null && list.size() > 0) { VoteQueUsr voteu = list.get(0); @@ -62,7 +62,7 @@ @Override public int getCompletedVoteUserBySessionUid(final Long voteSessionUid) { List list = getSessionFactory().getCurrentSession().createQuery(LOAD_USER_FOR_SESSION) - .setLong("voteSessionId", voteSessionUid.longValue()).list(); + .setParameter("voteSessionId", voteSessionUid.longValue()).list(); int completedSessionUserCount = 0; if (list != null && list.size() > 0) { @@ -82,9 +82,10 @@ @Override public VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long voteSessionId) { - String strGetUser = "from voteQueUsr in class VoteQueUsr where voteQueUsr.queUsrId=:queUsrId and voteQueUsr.voteSessionId=:voteSessionId"; + String strGetUser = "from voteQueUsr in class VoteQueUsr where voteQueUsr.queUsrId=:queUsrId and voteQueUsr.voteSession.uid=:voteSessionId"; List list = getSessionFactory().getCurrentSession().createQuery(strGetUser) - .setLong("queUsrId", queUsrId.longValue()).setLong("voteSessionId", voteSessionId.longValue()).list(); + .setParameter("queUsrId", queUsrId.longValue()).setParameter("voteSessionId", voteSessionId.longValue()) + .list(); if (list != null && list.size() > 0) { VoteQueUsr usr = list.get(0); @@ -96,10 +97,10 @@ @SuppressWarnings("unchecked") @Override public VoteQueUsr getVoteQueUsrById(long voteQueUsrId) { - String query = "from VoteQueUsr user where user.queUsrId=?"; + String query = "from VoteQueUsr user where user.queUsrId=:queUsrId"; - List list = getSessionFactory().getCurrentSession().createQuery(query).setLong(0, voteQueUsrId) - .list(); + List list = getSessionFactory().getCurrentSession().createQuery(query) + .setParameter("queUsrId", voteQueUsrId).list(); if (list != null && list.size() > 0) { VoteQueUsr qu = list.get(0); @@ -122,7 +123,7 @@ @Override public List getUserBySessionOnly(final VoteSession voteSession) { List list = getSessionFactory().getCurrentSession().createQuery(LOAD_USER_FOR_SESSION) - .setLong("voteSessionId", voteSession.getUid().longValue()).list(); + .setParameter("voteSessionId", voteSession.getUid().longValue()).list(); return list; } @@ -136,5 +137,4 @@ String query = "from obj in class VoteQueUsr"; return this.doFind(query).size(); } - -} +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -30,7 +30,7 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; -import org.hibernate.SQLQuery; +import org.hibernate.query.NativeQuery; import org.hibernate.transform.Transformers; import org.hibernate.type.BooleanType; import org.hibernate.type.IntegerType; @@ -55,17 +55,17 @@ @Repository public class VoteUsrAttemptDAO extends LAMSBaseDAO implements IVoteUsrAttemptDAO { - private static final String LOAD_ATTEMPT_FOR_USER = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; + private static final String LOAD_ATTEMPT_FOR_USER = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueUsr.uid=:queUsrId"; // The following two queries are the same except one loads the attempts, the other counts them private static final String LOAD_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContent.uid=:voteQueContentId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; private static final String COUNT_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION = "select count(*) from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContent.uid=:voteQueContentId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; - private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContent.uid=:voteQueContentId"; + private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueUsr.uid=:queUsrId and voteUsrAttempt.voteQueContent.uid=:voteQueContentId"; - private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContent.uid=:voteQueContentId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; + private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueUsr.uid=:queUsrId and voteUsrAttempt.voteQueContent.uid=:voteQueContentId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; - private static final String LOAD_ATTEMPT_FOR_USER_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; + private static final String LOAD_ATTEMPT_FOR_USER_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueUsr.uid=:queUsrId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; private static final String LOAD_USER_ENTRIES = "select distinct voteUsrAttempt.userEntry from VoteUsrAttempt voteUsrAttempt where voteUsrAttempt.voteQueUsr.voteSession.voteContent.uid=:voteContentUid"; @@ -80,10 +80,10 @@ @SuppressWarnings("unchecked") @Override public VoteUsrAttempt getAttemptByUID(Long uid) { - String query = "from VoteUsrAttempt attempt where attempt.uid=?"; + String query = "from VoteUsrAttempt attempt where attempt.uid=:attemptUid"; List list = getSessionFactory().getCurrentSession().createQuery(query) - .setLong(0, uid.longValue()).list(); + .setParameter("attemptUid", uid).list(); if ((list != null) && (list.size() > 0)) { VoteUsrAttempt attempt = list.get(0); @@ -101,15 +101,15 @@ @Override public List getAttemptsForUser(final Long queUsrId) { List list = getSessionFactory().getCurrentSession() - .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER).setLong("queUsrId", queUsrId.longValue()).list(); + .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER).setParameter("queUsrId", queUsrId).list(); return list; } @SuppressWarnings("unchecked") @Override public Set getUserEntries(final Long voteContentUid) { List list = getSessionFactory().getCurrentSession().createQuery(VoteUsrAttemptDAO.LOAD_USER_ENTRIES) - .setLong("voteContentUid", voteContentUid).list(); + .setParameter("voteContentUid", voteContentUid).list(); Set userEntries = new HashSet<>(); if ((list != null) && (list.size() > 0)) { @@ -128,24 +128,24 @@ @Override public List getUserAttempts(final Long voteContentUid, final String userEntry) { List list = getSessionFactory().getCurrentSession() - .createQuery(VoteUsrAttemptDAO.LOAD_USER_ENTRY_RECORDS).setLong("voteContentUid", voteContentUid) - .setString("userEntry", userEntry).list(); + .createQuery(VoteUsrAttemptDAO.LOAD_USER_ENTRY_RECORDS).setParameter("voteContentUid", voteContentUid) + .setParameter("userEntry", userEntry).list(); return list; } @SuppressWarnings("unchecked") @Override public List getSessionOpenTextUserEntries(final Long voteSessionUid) { return getSession().createQuery(VoteUsrAttemptDAO.LOAD_OPEN_TEXT_ENTRIES_BY_SESSION_UID) - .setLong("voteSessionUid", voteSessionUid).list(); + .setParameter("voteSessionUid", voteSessionUid).list(); } @SuppressWarnings("unchecked") @Override public void removeAttemptsForUserandSession(final Long queUsrId, final Long sessionUid) { - String strGetUser = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; + String strGetUser = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueUsr.uid=:queUsrId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; List list = getSessionFactory().getCurrentSession().createQuery(strGetUser) - .setLong("queUsrId", queUsrId.longValue()).setLong("sessionUid", sessionUid).list(); + .setParameter("queUsrId", queUsrId.longValue()).setParameter("sessionUid", sessionUid).list(); if ((list != null) && (list.size() > 0)) { Iterator listIterator = list.iterator(); @@ -161,8 +161,7 @@ @Override public int getStandardAttemptsForQuestionContentAndSessionUid(final Long questionUid, final Long sessionUid) { List list = getSession().createQuery(VoteUsrAttemptDAO.COUNT_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION) - .setLong("voteQueContentId", questionUid.longValue()).setLong("sessionUid", sessionUid.longValue()) - .list(); + .setParameter("voteQueContentId", questionUid).setParameter("sessionUid", sessionUid).list(); if (list == null || list.size() == 0) { return 0; @@ -177,8 +176,7 @@ final Long sessionUid) { List list = getSessionFactory().getCurrentSession() .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION) - .setLong("voteQueContentId", questionUid.longValue()).setLong("sessionUid", sessionUid.longValue()) - .list(); + .setParameter("voteQueContentId", questionUid).setParameter("sessionUid", sessionUid).list(); List userEntries = new ArrayList(); if ((list != null) && (list.size() > 0)) { @@ -193,7 +191,7 @@ public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long questionUid) { List list = getSessionFactory().getCurrentSession() .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT) - .setLong("queUsrId", queUsrId.longValue()).setLong("voteQueContentId", questionUid.longValue()).list(); + .setParameter("queUsrId", queUsrId).setParameter("voteQueContentId", questionUid).list(); return list; } @@ -204,8 +202,8 @@ final Long sessionUid) { List list = getSessionFactory().getCurrentSession() .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT_AND_SESSION) - .setLong("queUsrId", queUsrId.longValue()).setLong("voteQueContentId", questionUid.longValue()) - .setLong("sessionUid", sessionUid.longValue()).list(); + .setParameter("queUsrId", queUsrId).setParameter("voteQueContentId", questionUid) + .setParameter("sessionUid", sessionUid).list(); if ((list == null) || (list.size() == 0)) { return null; @@ -218,8 +216,8 @@ public Set getAttemptsForUserAndSession(final Long queUsrId, final Long sessionUid) { List list = getSessionFactory().getCurrentSession() - .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER_AND_SESSION) - .setLong("queUsrId", queUsrId.longValue()).setLong("sessionUid", sessionUid.longValue()).list(); + .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER_AND_SESSION).setParameter("queUsrId", queUsrId) + .setParameter("sessionUid", sessionUid).list(); Set userEntries = new HashSet<>(); if ((list != null) && (list.size() > 0)) { @@ -241,17 +239,17 @@ public List getAttemptsForUserAndSessionUseOpenAnswer(final Long queUsrId, final Long sessionUid) { return getSession().createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER_AND_SESSION) - .setLong("queUsrId", queUsrId.longValue()).setLong("sessionUid", sessionUid.longValue()).list(); + .setParameter("queUsrId", queUsrId).setParameter("sessionUid", sessionUid).list(); } @SuppressWarnings("unchecked") @Override public int getSessionEntriesCount(final Long voteSessionUid) { List result = getSessionFactory().getCurrentSession() - .createQuery(VoteUsrAttemptDAO.COUNT_ENTRIES_BY_SESSION_ID).setLong("voteSessionUid", voteSessionUid) - .list(); - Long resultLong = result.get(0) != null ? (Long) result.get(0) : new Long(0); + .createQuery(VoteUsrAttemptDAO.COUNT_ENTRIES_BY_SESSION_ID) + .setParameter("voteSessionUid", voteSessionUid).list(); + Long resultLong = result.get(0) != null ? (Long) result.get(0) : 0L; return resultLong.intValue(); } @@ -305,10 +303,8 @@ String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id"); // Basic select for the user records - StringBuilder queryText = new StringBuilder(FIND_USER_ANSWERS_BY_QUESTION_UID_SELECT) - .append(portraitStrings[0]) - .append(FIND_USER_ANSWERS_BY_QUESTION_UID_FROM) - .append(portraitStrings[1]); + StringBuilder queryText = new StringBuilder(FIND_USER_ANSWERS_BY_QUESTION_UID_SELECT).append(portraitStrings[0]) + .append(FIND_USER_ANSWERS_BY_QUESTION_UID_FROM).append(portraitStrings[1]); if (sessionUid != null) { queryText.append(FIND_USER_ANSWERS_BY_QUESTION_UID_SESSION_ADDITION); @@ -320,15 +316,13 @@ // Now specify the sort based on the switch statement above. queryText.append(" ORDER BY " + sortingOrder); - SQLQuery query = getSession().createSQLQuery(queryText.toString()); + NativeQuery query = getSession().createSQLQuery(queryText.toString()); query.addScalar("user_id", IntegerType.INSTANCE).addScalar("username", StringType.INSTANCE) - .addScalar("fullname", StringType.INSTANCE) - .addScalar("attemptTime", TimestampType.INSTANCE) - .addScalar("portraitId", IntegerType.INSTANCE) - .setLong("questionUid", questionUid.longValue()) + .addScalar("fullname", StringType.INSTANCE).addScalar("attemptTime", TimestampType.INSTANCE) + .addScalar("portraitId", IntegerType.INSTANCE).setParameter("questionUid", questionUid) .setFirstResult(page * size).setMaxResults(size); if (sessionUid != null) { - query.setLong("sessionUid", sessionUid.longValue()); + query.setParameter("sessionUid", sessionUid); } return query.list(); @@ -356,15 +350,15 @@ @SuppressWarnings("rawtypes") public int getCountUsersBySession(Long sessionUid, Long questionUid, String searchString) { - SQLQuery query; + NativeQuery query; if (questionUid == null) { // get all the users in this session - used for reflections StringBuilder queryText = new StringBuilder(COUNT_USERS_BY_SESSION_UID); buildNameSearch(searchString, queryText, false); // all ready have a WHERE so need an AND query = getSession().createSQLQuery(queryText.toString()); - query.setLong("sessionUid", sessionUid.longValue()); + query.setParameter("sessionUid", sessionUid); } else { @@ -376,9 +370,9 @@ buildNameSearch(searchString, queryText, true); query = getSession().createSQLQuery(queryText.toString()); - query.setLong("questionUid", questionUid.longValue()); + query.setParameter("questionUid", questionUid); if (sessionUid != null) { - query.setLong("sessionUid", sessionUid.longValue()); + query.setParameter("sessionUid", sessionUid); } } @@ -395,7 +389,8 @@ * Will return List<[login (String), fullname(String), String (notebook entry)]> */ public List getUserReflectionsForTablesorter(final Long sessionUid, int page, int size, int sorting, - String searchString, ICoreNotebookService coreNotebookService, IUserManagementService userManagementService) { + String searchString, ICoreNotebookService coreNotebookService, + IUserManagementService userManagementService) { String sortingOrder; switch (sorting) { case VoteAppConstants.SORT_BY_NAME_ASC: @@ -426,27 +421,26 @@ // Add the notebook join queryText.append(notebookEntryStrings[1]); queryText.append(portraitStrings[1]); - + // If filtering by name add a name based where clause buildNameSearch(searchString, queryText, true); // Now specify the sort based on the switch statement above. queryText.append(" ORDER BY " + sortingOrder); - SQLQuery query = getSession().createSQLQuery(queryText.toString()); - query.addScalar("user_id", IntegerType.INSTANCE) - .addScalar("username", StringType.INSTANCE).addScalar("fullname", StringType.INSTANCE) - .addScalar("notebookEntry", StringType.INSTANCE).addScalar("portraitId", IntegerType.INSTANCE) - .setLong("sessionUid", sessionUid.longValue()) + NativeQuery query = getSession().createSQLQuery(queryText.toString()); + query.addScalar("user_id", IntegerType.INSTANCE).addScalar("username", StringType.INSTANCE) + .addScalar("fullname", StringType.INSTANCE).addScalar("notebookEntry", StringType.INSTANCE) + .addScalar("portraitId", IntegerType.INSTANCE).setParameter("sessionUid", sessionUid) .setFirstResult(page * size).setMaxResults(size); return query.list(); } private static final String FIND_USER_OPEN_TEXT_SELECT = "SELECT user.uid userUid, user.username login, user.fullname fullName, " + " attempt.uid userEntryUid, attempt.userEntry userEntry, attempt.attempt_time attemptTime, attempt.visible visible "; - - private static final String FIND_USER_OPEN_TEXT_FROM = " FROM tl_lavote11_usr user " + + private static final String FIND_USER_OPEN_TEXT_FROM = " FROM tl_lavote11_usr user " + " JOIN tl_lavote11_usr_attempt attempt ON user.uid = attempt.que_usr_id AND attempt.vote_nomination_content_id = 1 "; private static final String FIND_USER_OPEN_TEXT_SESSION_UID_ADD = "AND user.vote_session_id=:sessionUid"; @@ -463,7 +457,8 @@ * Will return List */ public List getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long toolContentId, int page, - int size, int sorting, String searchStringVote, String searchStringUsername, IUserManagementService userManagementService) { + int size, int sorting, String searchStringVote, String searchStringUsername, + IUserManagementService userManagementService) { String sortingOrder; switch (sorting) { case VoteAppConstants.SORT_BY_NAME_ASC: @@ -497,8 +492,7 @@ String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id"); // Basic select for the user records - StringBuilder queryText = new StringBuilder(FIND_USER_OPEN_TEXT_SELECT) - .append(portraitStrings[0]) + StringBuilder queryText = new StringBuilder(FIND_USER_OPEN_TEXT_SELECT).append(portraitStrings[0]) .append(FIND_USER_OPEN_TEXT_FROM); if (sessionUid != null) { @@ -514,7 +508,7 @@ // Now specify the sort based on the switch statement above. queryText.append(" ORDER BY " + sortingOrder); - SQLQuery query = getSession().createSQLQuery(queryText.toString()); + NativeQuery query = getSession().createSQLQuery(queryText.toString()); query.addScalar("userUid", LongType.INSTANCE).addScalar("login", StringType.INSTANCE) .addScalar("fullName", StringType.INSTANCE).addScalar("userEntryUid", LongType.INSTANCE) .addScalar("userEntry", StringType.INSTANCE).addScalar("attemptTime", TimestampType.INSTANCE) @@ -523,9 +517,9 @@ .setResultTransformer(Transformers.aliasToBean(OpenTextAnswerDTO.class)); if (sessionUid != null) { - query.setLong("sessionUid", sessionUid); + query.setParameter("sessionUid", sessionUid); } else { - query.setLong("toolContentId", toolContentId); + query.setParameter("toolContentId", toolContentId); } return query.list(); @@ -553,23 +547,23 @@ public int getCountUsersForOpenTextEntries(Long sessionUid, Long toolContentId, String searchStringVote, String searchStringUsername) { - SQLQuery query; + NativeQuery query; StringBuilder queryText = new StringBuilder(COUNT_USERS_OPEN_TEXT_BY_SESSION_UID); if (sessionUid != null) { // get all the users who did an open text reply, restricting by session queryText.append(FIND_USER_OPEN_TEXT_SESSION_UID_ADD); buildCombinedSearch(searchStringVote, searchStringUsername, queryText); query = getSession().createSQLQuery(queryText.toString()); - query.setLong("sessionUid", sessionUid); + query.setParameter("sessionUid", sessionUid); } else { // get all the users for this content (more than one session potentially) queryText.append(FIND_USER_OPEN_TEXT_CONTENT_UID_ADD); buildCombinedSearch(searchStringVote, searchStringUsername, queryText); query = getSession().createSQLQuery(queryText.toString()); - query.setLong("toolContentId", toolContentId); + query.setParameter("toolContentId", toolContentId); } @@ -589,9 +583,9 @@ @SuppressWarnings("unchecked") public List getStatisticsBySession(Long toolContentId) { - SQLQuery query = getSession().createSQLQuery(GET_STATISTICS); + NativeQuery query = getSession().createSQLQuery(GET_STATISTICS); query.addScalar("sessionUid", LongType.INSTANCE).addScalar("sessionName", StringType.INSTANCE) - .addScalar("countUsersComplete", IntegerType.INSTANCE).setLong("contentId", toolContentId) + .addScalar("countUsersComplete", IntegerType.INSTANCE).setParameter("contentId", toolContentId) .setResultTransformer(Transformers.aliasToBean(VoteStatsDTO.class)); return query.list(); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteContent.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteContent.java (.../VoteContent.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteContent.java (.../VoteContent.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -28,6 +28,16 @@ import java.util.Set; import java.util.TreeSet; +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.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + import org.apache.commons.lang.builder.ToStringBuilder; /** @@ -38,74 +48,84 @@ * * @author Ozgur Demirtas */ +@Entity +@Table(name = "tl_lavote11_content") public class VoteContent implements Serializable { - /** - * - */ private static final long serialVersionUID = 1986729606785509746L; - /** identifier field */ + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; - /** persistent field */ + @Column(name = "content_id") private Long voteContentId; - /** nullable persistent field */ + @Column private String title; - /** nullable persistent field */ + @Column private String reflectionSubject; + @Column private String instructions; - /** nullable persistent field */ + @Column(name = "define_later") private boolean defineLater; - /** nullable persistent field */ + @Column(name = "creation_date") private Date creationDate; - /** nullable persistent field */ + @Column(name = "update_date") private Date updateDate; - /** nullable persistent field */ + @Column(name = "created_by") private long createdBy; + @Column(name = "use_select_leader_tool_ouput") private boolean useSelectLeaderToolOuput; + @Column private boolean reflect; + @Column private boolean allowText; + @Column private String maxNominationCount; + @Column private String minNominationCount; - /** nullable persistent field */ + @Column(name = "lock_on_finish") private boolean lockOnFinish; + @Column(name = "show_results") private boolean showResults; - /** persistent field */ + @OneToMany(mappedBy = "voteContent", cascade = CascadeType.ALL, orphanRemoval = true) + @OrderBy("displayOrder") private Set voteQueContents; - /** persistent field */ + @OneToMany(mappedBy = "voteContent", cascade = CascadeType.ALL, orphanRemoval = true) private Set voteSessions; + @Column(name = "submission_deadline") private Date submissionDeadline; /** - * persistent field This field can be calculated, but introducing it reduces number of DB calls. + * This field can be calculated, but introducing it reduces number of DB calls. */ + @Column(name = "assigned_data_flow_object") private Boolean assignedDataFlowObject; - /** persistent field */ + @Column(name = "max_external_inputs") private Short maxExternalInputs; - /** persistent field */ + @Column(name = "external_inputs_added") private Short externalInputsAdded; - /** full constructor */ public VoteContent(Long voteContentId, String title, String instructions, boolean defineLater, Date creationDate, Date updateDate, boolean allowText, boolean useSelectLeaderToolOuput, boolean reflect, String reflectionSubject, String maxNominationCount, String minNominationCount, long createdBy, @@ -132,17 +152,9 @@ this.externalInputsAdded = externalInputsAdded; } - /** default constructor */ public VoteContent() { } - /** minimal constructor */ - public VoteContent(Long voteContentId, Set voteQueContents, Set voteSessions) { - this.voteContentId = voteContentId; - this.voteQueContents = voteQueContents; - this.voteSessions = voteSessions; - } - /** * gets called as part of the copyToolContent * @@ -170,9 +182,6 @@ /** * gets called as part of the copyToolContent - * - * @param newQaContent - * @return Set */ public Set deepCopyMcQueContent(VoteContent newMcContent) { @@ -236,9 +245,6 @@ this.createdBy = createdBy; } - /** - * @return Returns the voteQueContents. - */ public Set getVoteQueContents() { if (voteQueContents == null) { setVoteQueContents(new HashSet()); @@ -247,28 +253,17 @@ } - /** - * @param voteQueContents - * The voteQueContents to set. - */ public void setVoteQueContents(Set voteQueContents) { this.voteQueContents = voteQueContents; } - /** - * @return Returns the voteSessions. - */ public Set getVoteSessions() { if (voteSessions == null) { setVoteSessions(new HashSet()); } return voteSessions; } - /** - * @param voteSessions - * The voteSessions to set. - */ public void setVoteSessions(Set voteSessions) { this.voteSessions = voteSessions; } @@ -278,137 +273,74 @@ return new ToStringBuilder(this).append("uid", getUid()).toString(); } - /** - * @return Returns the creationDate. - */ public Date getCreationDate() { return creationDate; } - /** - * @param creationDate - * The creationDate to set. - */ public void setCreationDate(Date creationDate) { this.creationDate = creationDate; } - /** - * @return Returns the lockOnFinish. - */ public boolean isLockOnFinish() { return lockOnFinish; } - /** - * @param lockOnFinish - * The lockOnFinish to set. - */ public void setLockOnFinish(boolean lockOnFinish) { this.lockOnFinish = lockOnFinish; } - /** - * @return Returns the voteContentId. - */ public Long getVoteContentId() { return voteContentId; } - /** - * @param voteContentId - * The voteContentId to set. - */ public void setVoteContentId(Long voteContentId) { this.voteContentId = voteContentId; } - /** - * @return Returns the allowText. - */ public boolean isAllowText() { return allowText; } - /** - * @param allowText - * The allowText to set. - */ public void setAllowText(boolean allowText) { this.allowText = allowText; } - /** - * @return Returns the maxNominationCount. - */ public String getMaxNominationCount() { return maxNominationCount; } - /** - * @param maxNominationCount - * The maxNominationCount to set. - */ public void setMaxNominationCount(String maxNominationCount) { this.maxNominationCount = maxNominationCount; } - /** - * @return Returns the minNominationCount. - */ public String getMinNominationCount() { return minNominationCount; } - /** - * @param minNominationCount - * The minNominationCount to set. - */ public void setMinNominationCount(String minNominationCount) { this.minNominationCount = minNominationCount; } - /** - * @return Returns the reflect. - */ public boolean isReflect() { return reflect; } - /** - * @param reflect - * The reflect to set. - */ public void setReflect(boolean reflect) { this.reflect = reflect; } - /** - * @param useSelectLeaderToolOuput - * The useSelectLeaderToolOuput to set. - */ public boolean isUseSelectLeaderToolOuput() { return useSelectLeaderToolOuput; } - /** - * @return Returns the useSelectLeaderToolOuput. - */ public void setUseSelectLeaderToolOuput(boolean useSelectLeaderToolOuput) { this.useSelectLeaderToolOuput = useSelectLeaderToolOuput; } - /** - * @return Returns the reflectionSubject. - */ public String getReflectionSubject() { return reflectionSubject; } - /** - * @param reflectionSubject - * The reflectionSubject to set. - */ public void setReflectionSubject(String reflectionSubject) { this.reflectionSubject = reflectionSubject; } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteQueContent.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteQueContent.java (.../VoteQueContent.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteQueContent.java (.../VoteQueContent.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -24,6 +24,15 @@ 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.apache.commons.lang.builder.ToStringBuilder; /** @@ -32,39 +41,33 @@ * * @author Ozgur Demirtas */ +@Entity +@Table(name = "tl_lavote11_nomination_content") public class VoteQueContent implements Serializable, Comparable { - /** - * - */ private static final long serialVersionUID = 1598466582549757720L; - /** identifier field */ + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; - /** nullable persistent field */ + @Column(name = "nomination") private String question; + @Column(name = "display_order") private int displayOrder; - /** non persistent field */ - private Long voteContentId; + @ManyToOne + @JoinColumn(name = "vote_content_id") + private VoteContent voteContent; - /** persistent field */ - private org.lamsfoundation.lams.tool.vote.model.VoteContent voteContent; - - public VoteQueContent(String question, VoteContent voteContent) { - this.question = question; - this.voteContent = voteContent; - } - public VoteQueContent(String question, int displayOrder, VoteContent voteContent) { this.question = question; this.displayOrder = displayOrder; this.voteContent = voteContent; } - /** default constructor */ public VoteQueContent() { } @@ -122,48 +125,19 @@ } } - /** - * @return Returns the voteContentId. - */ - public Long getVoteContentId() { - return voteContentId; - } - - /** - * @param voteContentId - * The voteContentId to set. - */ - public void setVoteContentId(Long voteContentId) { - this.voteContentId = voteContentId; - } - - /** - * @return Returns the voteContent. - */ - public org.lamsfoundation.lams.tool.vote.model.VoteContent getVoteContent() { + public VoteContent getVoteContent() { return voteContent; } - /** - * @param voteContent - * The voteContent to set. - */ - public void setVoteContent(org.lamsfoundation.lams.tool.vote.model.VoteContent voteContent) { + public void setVoteContent(VoteContent voteContent) { this.voteContent = voteContent; } - /** - * @return Returns the displayOrder. - */ public int getDisplayOrder() { return displayOrder; } - /** - * @param displayOrder - * The displayOrder to set. - */ public void setDisplayOrder(int displayOrder) { this.displayOrder = displayOrder; } -} +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteQueUsr.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteQueUsr.java (.../VoteQueUsr.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteQueUsr.java (.../VoteQueUsr.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -26,6 +26,17 @@ 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.Table; + import org.apache.commons.lang.builder.ToStringBuilder; /** @@ -37,50 +48,51 @@ * * @author Ozgur Demirtas */ +@Entity +@Table(name = "tl_lavote11_usr") public class VoteQueUsr implements Serializable, Comparable { private static final long serialVersionUID = 7303944502340276133L; - /** identifier field */ + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; - /** persistent field */ + @Column(name = "user_id") private Long queUsrId; - /** nullable persistent field */ + @Column private String username; - /** nullable persistent field */ + @Column private String fullname; + @Column private boolean responseFinalised; + @Column private boolean finalScreenRequested; - private Long voteSessionId; - - /** nullable persistent field */ + @ManyToOne + @JoinColumn(name = "vote_session_id") private VoteSession voteSession; - /** persistent field */ + @OneToMany(mappedBy = "voteQueUsr", cascade = CascadeType.ALL, orphanRemoval = true) private Set voteUsrAttempts; - /** full constructor */ public VoteQueUsr(Long queUsrId, String username, String fullname, VoteSession voteSession, Set voteUsrAttempts) { this.queUsrId = queUsrId; this.username = username; this.fullname = fullname; this.voteSession = voteSession; - this.voteSessionId = voteSession.getUid(); this.voteUsrAttempts = voteUsrAttempts; } - /** default constructor */ public VoteQueUsr() { } - /** minimal constructor */ public VoteQueUsr(Long queUsrId, Set voteUsrAttempts) { this.queUsrId = queUsrId; this.voteUsrAttempts = voteUsrAttempts; @@ -134,74 +146,30 @@ return new ToStringBuilder(this).append("uid", getUid()).toString(); } - /** - * Beware, it references Votesession.uid field (not the Votesession.voteSessionId). - * - * @return Returns the voteSessionId. - */ - public Long getVoteSessionId() { - return voteSessionId; - } - - /** - * Beware, it references Votesession.uid field (not the Votesession.voteSessionId). - * - * @param voteSessionId - * The voteSessionId to set. - */ - public void setVoteSessionId(Long voteSessionId) { - this.voteSessionId = voteSessionId; - } - - /** - * @return Returns the voteSession. - */ public VoteSession getVoteSession() { return voteSession; } - /** - * @param voteSession - * The voteSession to set. - */ public void setVoteSession(VoteSession voteSession) { this.voteSession = voteSession; } - /** - * @param voteUsrAttempts - * The voteUsrAttempts to set. - */ public void setVoteUsrAttempts(Set voteUsrAttempts) { this.voteUsrAttempts = voteUsrAttempts; } - /** - * @return Returns the responseFinalised. - */ public boolean isResponseFinalised() { return responseFinalised; } - /** - * @param responseFinalised - * The responseFinalised to set. - */ public void setResponseFinalised(boolean responseFinalised) { this.responseFinalised = responseFinalised; } - /** - * @return Returns the finalScreenRequested. - */ public boolean isFinalScreenRequested() { return finalScreenRequested; } - /** - * @param finalScreenRequested - * The finalScreenRequested to set. - */ public void setFinalScreenRequested(boolean finalScreenRequested) { this.finalScreenRequested = finalScreenRequested; } @@ -215,5 +183,4 @@ return (int) (uid.longValue() - other.uid.longValue()); } } - -} +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteSession.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteSession.java (.../VoteSession.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteSession.java (.../VoteSession.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -26,6 +26,17 @@ import java.util.Date; 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.Table; + import org.apache.commons.lang.builder.ToStringBuilder; /** @@ -36,44 +47,45 @@ * * @author Ozgur Demirtas */ +@Entity +@Table(name = "tl_lavote11_session") public class VoteSession implements Serializable, Comparable { - /** - * - */ private static final long serialVersionUID = 5053800653198292982L; public final static String INCOMPLETE = "INCOMPLETE"; public static final String COMPLETED = "COMPLETED"; - /** identifier field */ + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; - /** persistent field */ + @Column(name = "vote_session_id") private Long voteSessionId; - /** nullable persistent field */ + @Column(name = "session_start_date") private Date sessionStartDate; - /** nullable persistent field */ + @Column(name = "session_end_date") private Date sessionEndDate; - /** nullable persistent field */ + @Column(name = "session_status") private String sessionStatus; + @Column private String session_name; - /** nullable persistent field */ - private Long voteContentId; - - /** nullable persistent field */ + @ManyToOne + @JoinColumn(name = "vote_content_id") private VoteContent voteContent; - /** persistent field */ + @OneToMany(mappedBy = "voteSession", cascade = CascadeType.ALL, orphanRemoval = true) private Set voteQueUsers; - /** persistent field */ + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "group_leader_uid") private VoteQueUsr groupLeader; public VoteSession(Long voteSessionId, Date sessionStartDate, String sessionStatus, String session_name, @@ -86,7 +98,6 @@ this.voteQueUsers = voteQueUsers; } - /** default constructor */ public VoteSession() { } @@ -103,137 +114,66 @@ return new ToStringBuilder(this).append("uid", getUid()).toString(); } - /** - * @return Returns the sessionEndDate. - */ public Date getSessionEndDate() { return sessionEndDate; } - /** - * @param sessionEndDate - * The sessionEndDate to set. - */ public void setSessionEndDate(Date sessionEndDate) { this.sessionEndDate = sessionEndDate; } - /** - * @return Returns the sessionStartDate. - */ public Date getSessionStartDate() { return sessionStartDate; } - /** - * @param sessionStartDate - * The sessionStartDate to set. - */ public void setSessionStartDate(Date sessionStartDate) { this.sessionStartDate = sessionStartDate; } - /** - * @return Returns the sessionStatus. - */ public String getSessionStatus() { return sessionStatus; } - /** - * @param sessionStatus - * The sessionStatus to set. - */ public void setSessionStatus(String sessionStatus) { this.sessionStatus = sessionStatus; } - /** - * @return Returns the session_name. - */ public String getSession_name() { return session_name; } - /** - * @param session_name - * The session_name to set. - */ public void setSession_name(String session_name) { this.session_name = session_name; } - /** - * @return Returns the voteSessionId. - */ public Long getVoteSessionId() { return voteSessionId; } - /** - * @param voteSessionId - * The voteSessionId to set. - */ public void setVoteSessionId(Long voteSessionId) { this.voteSessionId = voteSessionId; } - /** - * @return Returns the voteContentId. - */ - public Long getVoteContentId() { - return voteContentId; - } - - /** - * @param voteContentId - * The voteContentId to set. - */ - public void setVoteContentId(Long voteContentId) { - this.voteContentId = voteContentId; - } - - /** - * @return Returns the voteContent. - */ public VoteContent getVoteContent() { return voteContent; } - /** - * @param voteContent - * The voteContent to set. - */ public void setVoteContent(VoteContent voteContent) { this.voteContent = voteContent; } - /** - * @return Returns the voteQueUsers. - */ public Set getVoteQueUsers() { return voteQueUsers; } - /** - * @param voteQueUsers - * The voteQueUsers to set. - */ public void setVoteQueUsers(Set voteQueUsers) { this.voteQueUsers = voteQueUsers; } - /** - * @return Returns the groupLeader. - */ public VoteQueUsr getGroupLeader() { return this.groupLeader; } - /** - * @param groupLeader - * The groupLeader to set. - */ public void setGroupLeader(VoteQueUsr groupLeader) { this.groupLeader = groupLeader; } @@ -247,5 +187,4 @@ return (int) (uid.longValue() - other.uid.longValue()); } } - -} +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteUsrAttempt.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteUsrAttempt.java (.../VoteUsrAttempt.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/model/VoteUsrAttempt.java (.../VoteUsrAttempt.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -25,6 +25,15 @@ import java.io.Serializable; import java.util.Date; +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.apache.commons.lang.builder.ToStringBuilder; /** @@ -35,51 +44,50 @@ * * @author Ozgur Demirtas */ +@Entity +@Table(name = "tl_lavote11_usr_attempt") public class VoteUsrAttempt implements Serializable, Comparable { - /** - * - */ private static final long serialVersionUID = 6756874212158405114L; - /** identifier field */ + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; - /** persistent field */ - private Long attemptId; - - /** nullable persistent field */ + @Column(name = "attempt_time") private Date attemptTime; - /** nullable persistent field */ + @Column(name = "time_zone") private String timeZone; + @Column private String userEntry; - private Long queUsrId; - + @Column private boolean visible; + @Column private boolean singleUserEntry; - /** persistent field */ + @ManyToOne + @JoinColumn(name = "vote_nomination_content_id") private VoteQueContent voteQueContent; - /** persistent field */ + @ManyToOne + @JoinColumn(name = "que_usr_id") private VoteQueUsr voteQueUsr; public VoteUsrAttempt(Date attemptTime, String timeZone, VoteQueContent voteQueContent, VoteQueUsr voteQueUsr, String userEntry, boolean visible) { this.attemptTime = attemptTime; this.timeZone = timeZone; this.voteQueContent = voteQueContent; - //this.voteQueContentId = voteQueContent.getVoteQueContentId(); this.voteQueUsr = voteQueUsr; this.userEntry = userEntry; this.visible = visible; } - /** default constructor */ public VoteUsrAttempt() { } @@ -91,14 +99,6 @@ this.uid = uid; } - public Long getAttemptId() { - return this.attemptId; - } - - public void setAttemptId(Long attemptId) { - this.attemptId = attemptId; - } - public Date getAttemptTime() { return this.attemptTime; } @@ -121,92 +121,42 @@ .append("userEntry:", userEntry).toString(); } - /** - * @return Returns the queUsrId. - */ - public Long getQueUsrId() { - return queUsrId; - } - - /** - * @param queUsrId - * The queUsrId to set. - */ - public void setQueUsrId(Long queUsrId) { - this.queUsrId = queUsrId; - } - - /** - * @return Returns the voteQueContent. - */ public VoteQueContent getVoteQueContent() { return voteQueContent; } - /** - * @param voteQueContent - * The voteQueContent to set. - */ public void setVoteQueContent(VoteQueContent voteQueContent) { this.voteQueContent = voteQueContent; } - /** - * @return Returns the voteQueUsr. - */ public VoteQueUsr getVoteQueUsr() { return voteQueUsr; } - /** - * @param voteQueUsr - * The voteQueUsr to set. - */ public void setVoteQueUsr(VoteQueUsr voteQueUsr) { this.voteQueUsr = voteQueUsr; } - /** - * @return Returns the userEntry. - */ public String getUserEntry() { return userEntry; } - /** - * @param userEntry - * The userEntry to set. - */ public void setUserEntry(String userEntry) { this.userEntry = userEntry; } - /** - * @return Returns the singleUserEntry. - */ public boolean isSingleUserEntry() { return singleUserEntry; } - /** - * @param singleUserEntry - * The singleUserEntry to set. - */ public void setSingleUserEntry(boolean singleUserEntry) { this.singleUserEntry = singleUserEntry; } - /** - * @return Returns the visible. - */ public boolean isVisible() { return visible; } - /** - * @param visible - * The visible to set. - */ public void setVisible(boolean visible) { this.visible = visible; } @@ -220,5 +170,4 @@ return (int) (uid.longValue() - other.uid.longValue()); } } - -} +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteService.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteService.java (.../VoteService.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteService.java (.../VoteService.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -1114,7 +1114,7 @@ if (question != null) { VoteUsrAttempt existingAttempt = voteUsrAttemptDAO.getAttemptForUserAndQuestionContentAndSession( - user.getQueUsrId(), question.getVoteContentId(), session.getUid()); + user.getQueUsrId(), question.getVoteContent().getUid(), session.getUid()); if (existingAttempt != null) { existingAttempt.setUserEntry(userEntry); @@ -1165,8 +1165,7 @@ } logEventService.logHideLearnerContent(voteUsrAttempt.getVoteQueUsr().getQueUsrId(), - voteUsrAttempt.getVoteQueUsr().getUsername(), toolContentId, - voteUsrAttempt.getUserEntry()); + voteUsrAttempt.getVoteQueUsr().getUsername(), toolContentId, voteUsrAttempt.getUserEntry()); } @@ -1181,8 +1180,7 @@ } logEventService.logShowLearnerContent(voteUsrAttempt.getVoteQueUsr().getQueUsrId(), - voteUsrAttempt.getVoteQueUsr().getUsername(), toolContentId, - voteUsrAttempt.getUserEntry()); + voteUsrAttempt.getVoteQueUsr().getUsername(), toolContentId, voteUsrAttempt.getUserEntry()); } @Override Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/controller/LearningController.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/controller/LearningController.java (.../LearningController.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/controller/LearningController.java (.../LearningController.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -792,7 +792,7 @@ if (mode.equals("teacher")) { - Long sessionUid = user.getVoteSessionId(); + Long sessionUid = user.getVoteSession().getUid(); putMapQuestionsContentIntoRequest(request, voteService, user); Set userAttempts = voteService.getAttemptsForUserAndSessionUseOpenAnswer(user.getUid(), sessionUid); request.setAttribute(VoteAppConstants.LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); @@ -815,7 +815,7 @@ * been already called up by this user */ if (user.isFinalScreenRequested()) { - Long sessionUid = user.getVoteSessionId(); + Long sessionUid = user.getVoteSession().getUid(); VoteSession voteUserSession = voteService.getVoteSessionByUID(sessionUid); String userSessionId = voteUserSession.getVoteSessionId().toString(); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/controller/VotePedagogicalPlannerController.java =================================================================== diff -u -r879fb356ece6075603479b01215a6b05465a59c8 -r374f1e3729c3892074184bbd480ae87bce110cfd --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/controller/VotePedagogicalPlannerController.java (.../VotePedagogicalPlannerController.java) (revision 879fb356ece6075603479b01215a6b05465a59c8) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/controller/VotePedagogicalPlannerController.java (.../VotePedagogicalPlannerController.java) (revision 374f1e3729c3892074184bbd480ae87bce110cfd) @@ -85,7 +85,7 @@ VoteQueContent voteQueContent = new VoteQueContent(); voteQueContent.setDisplayOrder(nominationIndex); voteQueContent.setVoteContent(voteContent); - voteQueContent.setVoteContentId(voteContent.getVoteContentId()); + voteQueContent.setVoteContent(voteContent); voteQueContent.setQuestion(nomination); voteService.saveOrUpdateVoteQueContent(voteQueContent); }