Index: lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -r59192abca4167aef55fee0d559349575ee330cd0 -rf8801506e4b6b221595fb585797851a9a6a09404
--- lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 59192abca4167aef55fee0d559349575ee330cd0)
+++ lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision f8801506e4b6b221595fb585797851a9a6a09404)
@@ -195,4 +195,8 @@
label.burning.question =Burning question
label.general.burning.question =General burning question
+label.count =Count
+label.like =Like
+label.unlike =Unlike
+
#======= End labels: Exported 182 labels for en AU =====
Index: lams_tool_scratchie/conf/xdoclet/struts-actions.xml
===================================================================
diff -u -r0e47151ba97eed4c2638f8dcc4fff17d4d0d225c -rf8801506e4b6b221595fb585797851a9a6a09404
--- lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 0e47151ba97eed4c2638f8dcc4fff17d4d0d225c)
+++ lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision f8801506e4b6b221595fb585797851a9a6a09404)
@@ -212,6 +212,14 @@
+
+
+
+
getBurningQuestionsByItemUid(Long itemUid);
+ List getBurningQuestionsByContentId(Long scratchieUid, Long sessionId);
ScratchieBurningQuestion getBurningQuestionBySessionAndItem(Long sessionId, Long itemUid);
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java
===================================================================
diff -u
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java (revision 0)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java (revision f8801506e4b6b221595fb585797851a9a6a09404)
@@ -0,0 +1,37 @@
+package org.lamsfoundation.lams.tool.scratchie.dao.hibernate;
+
+import java.util.List;
+
+import org.lamsfoundation.lams.tool.scratchie.dao.BurningQuestionLikeDAO;
+import org.lamsfoundation.lams.tool.scratchie.model.BurningQuestionLike;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+public class BurningQuestionLikeDAOHibernate extends HibernateDaoSupport implements BurningQuestionLikeDAO {
+
+ private static String INSERT_LIKE = "INSERT IGNORE INTO tl_lascrt11_burning_que_like(burning_question_uid, session_id) VALUES (:burningQuestionUid,:sessionId);";
+
+ public boolean addLike(Long burningQuestionUid, Long sessionId) {
+ int status = getSession().createSQLQuery(INSERT_LIKE)
+ .setParameter("burningQuestionUid", burningQuestionUid)
+ .setParameter("sessionId", sessionId)
+ .executeUpdate();
+ return status == 1;
+ }
+
+ public void removeLike(Long burningQuestionUid, Long sessionId) {
+
+ final String FIND_BY_SESSION_AND_BURNING_QUESTION = "from " + BurningQuestionLike.class.getName()
+ + " as l where l.sessionId=? and l.burningQuestion.uid = ?";
+
+ List list = getHibernateTemplate().find(FIND_BY_SESSION_AND_BURNING_QUESTION, new Object[] {sessionId, burningQuestionUid});
+ if (list == null || list.size() == 0) {
+ return;
+ }
+ BurningQuestionLike like = list.get(0);
+
+ if (like != null) {
+ getHibernateTemplate().delete(like);
+ }
+ }
+
+}
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java
===================================================================
diff -u -r447eb31b1898bb52f8c723f3e91f3a94fdae497d -rf8801506e4b6b221595fb585797851a9a6a09404
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java (.../ScratchieBurningQuestionDAOHibernate.java) (revision 447eb31b1898bb52f8c723f3e91f3a94fdae497d)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java (.../ScratchieBurningQuestionDAOHibernate.java) (revision f8801506e4b6b221595fb585797851a9a6a09404)
@@ -23,9 +23,13 @@
/* $Id$ */
package org.lamsfoundation.lams.tool.scratchie.dao.hibernate;
+import java.util.ArrayList;
import java.util.List;
+import org.hibernate.Hibernate;
+import org.hibernate.SQLQuery;
import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieBurningQuestionDAO;
+import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionDTO;
import org.lamsfoundation.lams.tool.scratchie.model.ScratchieBurningQuestion;
public class ScratchieBurningQuestionDAOHibernate extends BaseDAOHibernate implements ScratchieBurningQuestionDAO {
@@ -39,17 +43,56 @@
private static final String FIND_BY_SESSION = "from " + ScratchieBurningQuestion.class.getName()
+ " as r where r.sessionId=?";
- private static final String FIND_BY_ITEM_UID = "from " + ScratchieBurningQuestion.class.getName()
+ private static final String FIND_BY_CONTENT_ID = "from " + ScratchieBurningQuestion.class.getName()
+ " as r where r.scratchieItem.uid=? order by r.sessionId asc";
// @Override
// public List getBurningQuestionsByContentId(Long contentId) {
// return getHibernateTemplate().find(FIND_BY_CONTENT_ID, new Object[] { contentId});
// }
-
+
@Override
- public List getBurningQuestionsByItemUid(Long itemUid) {
- return getHibernateTemplate().find(FIND_BY_ITEM_UID, new Object[] { itemUid});
+ @SuppressWarnings("unchecked")
+ public List getBurningQuestionsByContentId(Long scratchieUid, Long sessionId) {
+
+ /* Thread based lookups - Returns a complex structure so that the likes information can be passed
+ * back with it. */
+ final String GET_BURNING_QUESTIONS_WITH_LIKES =
+ "SELECT bq.*, session.session_name sessionName, count(like1.uid) total_likes, like2.uid user_like FROM tl_lascrt11_burning_question bq "
+ + " JOIN tl_lascrt11_session session"
+ + " ON session.scratchie_uid = :scratchieUid AND bq.session_id = session.session_id "
+ + " LEFT JOIN tl_lascrt11_burning_que_like like1 ON bq.uid = like1.burning_question_uid "
+ + " LEFT JOIN tl_lascrt11_burning_que_like like2 ON bq.uid = like2.burning_question_uid AND like2.session_id=:sessionId "
+ + " WHERE bq.question IS NOT NULL AND bq.question != ''"
+ + " GROUP BY bq.uid";
+
+ SQLQuery query = getSession().createSQLQuery(GET_BURNING_QUESTIONS_WITH_LIKES);
+ query.addEntity("bq", ScratchieBurningQuestion.class)
+ .addScalar("sessionName", Hibernate.STRING)
+ .addScalar("total_likes", Hibernate.INTEGER)
+ .addScalar("user_like", Hibernate.LONG)
+ .setLong("sessionId", sessionId != null ? sessionId : 0)
+ .setLong("scratchieUid", scratchieUid);
+ List