KalturaComment
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.model.KalturaComment
+ */
+public interface IKalturaCommentDAO extends IBaseDAO {
+
+ /**
+ * Return KalturaComment by the given commentUid.
+ *
+ * @param commentUid
+ * @return
+ */
+ KalturaComment getCommentByUid(Long commentUid);
+
+}
Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaDAO.java 15 Nov 2012 14:39:28 -0000 1.1
@@ -0,0 +1,44 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id: IKalturaDAO.java,v 1.1 2012/11/15 14:39:28 andreyb Exp $$ */
+
+package org.lamsfoundation.lams.tool.kaltura.dao;
+
+import org.lamsfoundation.lams.dao.IBaseDAO;
+import org.lamsfoundation.lams.tool.kaltura.model.Kaltura;
+
+/**
+ * DAO for accessing the Kaltura objects - interface defining methods to be implemented by the Hibernate or other
+ * implementation.
+ */
+public interface IKalturaDAO extends IBaseDAO {
+
+ Kaltura getByContentId(Long toolContentId);
+
+ void saveOrUpdate(Kaltura toContent);
+
+ void deleteInstructionFile(Long toolContentId, Long uuid, Long versionId, String type);
+
+ void releaseFromCache(Object o);
+
+}
Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaItemDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaItemDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaItemDAO.java 15 Nov 2012 14:39:29 -0000 1.1
@@ -0,0 +1,49 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id: IKalturaItemDAO.java,v 1.1 2012/11/15 14:39:29 andreyb Exp $ */
+package org.lamsfoundation.lams.tool.kaltura.dao;
+
+import java.util.List;
+
+import org.lamsfoundation.lams.dao.IBaseDAO;
+import org.lamsfoundation.lams.tool.kaltura.model.KalturaItem;
+
+/**
+ * DAO interface for KalturaItem
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.model.KalturaItem
+ */
+public interface IKalturaItemDAO extends IBaseDAO {
+
+ /**
+ * Return all kaltura items which is uploaded by author in given kalturaUid.
+ *
+ * @param kalturaUid
+ * @return
+ */
+ List getAuthoringItems(Long kalturaUid);
+
+ KalturaItem getByUid(Long kalturaItemUid);
+
+}
Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaItemVisitDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaItemVisitDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/IKalturaItemVisitDAO.java 15 Nov 2012 14:39:28 -0000 1.1
@@ -0,0 +1,45 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id: IKalturaItemVisitDAO.java,v 1.1 2012/11/15 14:39:28 andreyb Exp $ */
+package org.lamsfoundation.lams.tool.kaltura.dao;
+
+import java.util.List;
+
+import org.lamsfoundation.lams.dao.IBaseDAO;
+import org.lamsfoundation.lams.tool.kaltura.model.KalturaItemVisitLog;
+
+/**
+ * DAO interface for KalturaItemVisitLog
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.model.KalturaItemVisitLog
+ */
+public interface IKalturaItemVisitDAO extends IBaseDAO {
+
+ KalturaItemVisitLog getKalturaItemLog(Long itemUid, Long userId);
+
+ int getUserViewLogCount(Long sessionId, Long userUid);
+
+ ListKalturaRating
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.model.KalturaRating
+ */
+public interface IKalturaRatingDAO extends IBaseDAO {
+
+ /**
+ * Return KalturaRating by the given itemUid and userId.
+ *
+ * @param itemUid
+ * @param userId
+ * @return
+ */
+ KalturaRating getKalturaRatingByItemAndUser(Long itemUid, Long userId);
+
+ /**
+ * Return list of KalturaRating by the the given itemUid.
+ *
+ * @param itemUid
+ * @param userId
+ * @return
+ */
+ ListIKalturaCommentDAO
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.dao.IKalturaCommentDAO
+ */
+public class KalturaCommentDAO extends BaseDAO implements IKalturaCommentDAO {
+
+ private static final String FIND_BY_UID = "from " + KalturaComment.class.getName() + " as r where r.uid = ?";
+
+ public KalturaComment getCommentByUid(Long commentUid) {
+ List list = getHibernateTemplate().find(FIND_BY_UID, commentUid);
+ if (list == null || list.size() == 0)
+ return null;
+ return (KalturaComment) list.get(0);
+ }
+
+}
Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaDAO.java 15 Nov 2012 14:39:30 -0000 1.1
@@ -0,0 +1,80 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id: KalturaDAO.java,v 1.1 2012/11/15 14:39:30 andreyb Exp $$ */
+
+package org.lamsfoundation.lams.tool.kaltura.dao.hibernate;
+
+import java.util.List;
+
+import org.hibernate.FlushMode;
+import org.lamsfoundation.lams.dao.hibernate.BaseDAO;
+import org.lamsfoundation.lams.tool.kaltura.dao.IKalturaDAO;
+import org.lamsfoundation.lams.tool.kaltura.model.Kaltura;
+import org.lamsfoundation.lams.tool.kaltura.model.KalturaAttachment;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+
+/**
+ * DAO for accessing the Kaltura objects - Hibernate specific code.
+ */
+public class KalturaDAO extends BaseDAO implements IKalturaDAO {
+
+ private static final String FIND_FORUM_BY_CONTENTID = "from Kaltura kaltura where kaltura.toolContentId=?";
+
+ private static final String FIND_INSTRUCTION_FILE = "from " + KalturaAttachment.class.getName()
+ + " as i where tool_content_id=? and i.file_uuid=? and i.file_version_id=? and i.file_type=?";
+
+ public Kaltura getByContentId(Long toolContentId) {
+ List list = getHibernateTemplate().find(KalturaDAO.FIND_FORUM_BY_CONTENTID, toolContentId);
+ if (list != null && list.size() > 0) {
+ return (Kaltura) list.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ public void saveOrUpdate(Kaltura kaltura) {
+ this.getHibernateTemplate().saveOrUpdate(kaltura);
+ this.getHibernateTemplate().flush();
+ }
+
+ public void deleteInstructionFile(Long toolContentId, Long uuid, Long versionId, String type) {
+ HibernateTemplate templ = this.getHibernateTemplate();
+ if (toolContentId != null && uuid != null && versionId != null) {
+ List list = getSession().createQuery(KalturaDAO.FIND_INSTRUCTION_FILE)
+ .setLong(0, toolContentId.longValue()).setLong(1, uuid.longValue())
+ .setLong(2, versionId.longValue()).setString(3, type).list();
+ if (list != null && list.size() > 0) {
+ KalturaAttachment file = (KalturaAttachment) list.get(0);
+ this.getSession().setFlushMode(FlushMode.AUTO);
+ templ.delete(file);
+ templ.flush();
+ }
+ }
+
+ }
+
+ public void releaseFromCache(Object o) {
+ getSession().evict(o);
+
+ }
+}
Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaItemDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaItemDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaItemDAO.java 15 Nov 2012 14:39:30 -0000 1.1
@@ -0,0 +1,46 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id: KalturaItemDAO.java,v 1.1 2012/11/15 14:39:30 andreyb Exp $ */
+package org.lamsfoundation.lams.tool.kaltura.dao.hibernate;
+
+import java.util.List;
+
+import org.lamsfoundation.lams.dao.hibernate.BaseDAO;
+import org.lamsfoundation.lams.tool.kaltura.dao.IKalturaItemDAO;
+import org.lamsfoundation.lams.tool.kaltura.model.KalturaItem;
+
+public class KalturaItemDAO extends BaseDAO implements IKalturaItemDAO {
+
+ private static final String FIND_AUTHORING_ITEMS = "from " + KalturaItem.class.getName()
+ + " where kaltura_uid = ? and create_by_author = 1 order by create_date asc";
+
+ @Override
+ public List getAuthoringItems(Long kalturaUid) {
+ return this.getHibernateTemplate().find(FIND_AUTHORING_ITEMS, kalturaUid);
+ }
+
+ @Override
+ public KalturaItem getByUid(Long kalturaItemUid) {
+ return (KalturaItem) this.getHibernateTemplate().get(KalturaItem.class, kalturaItemUid);
+ }
+}
Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaItemVisitDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaItemVisitDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/dao/hibernate/KalturaItemVisitDAO.java 15 Nov 2012 14:39:30 -0000 1.1
@@ -0,0 +1,68 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id: KalturaItemVisitDAO.java,v 1.1 2012/11/15 14:39:30 andreyb Exp $ */
+package org.lamsfoundation.lams.tool.kaltura.dao.hibernate;
+
+import java.util.List;
+
+import org.lamsfoundation.lams.dao.hibernate.BaseDAO;
+import org.lamsfoundation.lams.tool.kaltura.dao.IKalturaItemVisitDAO;
+import org.lamsfoundation.lams.tool.kaltura.model.KalturaItemVisitLog;
+
+/**
+ * Hibernate implementation of IKalturaItemVisitDAO
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.dao.IKalturaItemVisitDAO
+ */
+public class KalturaItemVisitDAO extends BaseDAO implements IKalturaItemVisitDAO {
+
+ private static final String FIND_BY_ITEM_AND_USER = "from " + KalturaItemVisitLog.class.getName()
+ + " as r where r.user.userId = ? and r.kalturaItem.uid=?";
+
+ private static final String FIND_BY_ITEM_BYSESSION = "from " + KalturaItemVisitLog.class.getName()
+ + " as r where r.sessionId = ? and r.kalturaItem.uid=?";
+
+ private static final String FIND_VIEW_COUNT_BY_USER = "select count(*) from "
+ + KalturaItemVisitLog.class.getName() + " as r where r.sessionId=? and r.user.userId =?";
+
+ public KalturaItemVisitLog getKalturaItemLog(Long itemUid, Long userId) {
+ List list = getHibernateTemplate().find(FIND_BY_ITEM_AND_USER, new Object[] { userId, itemUid });
+ if (list == null || list.size() == 0)
+ return null;
+ return (KalturaItemVisitLog) list.get(0);
+ }
+
+ public int getUserViewLogCount(Long toolSessionId, Long userUid) {
+ List list = getHibernateTemplate().find(FIND_VIEW_COUNT_BY_USER, new Object[] { toolSessionId, userUid });
+ if (list == null || list.size() == 0)
+ return 0;
+ return ((Number) list.get(0)).intValue();
+ }
+
+ public ListIKalturaRatingDAO
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.kaltura.dao.IKalturaRatingDAO
+ */
+public class KalturaRatingDAO extends BaseDAO implements IKalturaRatingDAO {
+
+ private static final String FIND_BY_ITEM_AND_USER = "from " + KalturaRating.class.getName()
+ + " as r where r.createBy.userId = ? and r.kalturaItem.uid=?";
+
+ private static final String FIND_BY_ITEM_UID = "from " + KalturaRating.class.getName()
+ + " as r where r.kalturaItem.uid=?";
+
+ private static final String FIND_AVERAGE_RATING_BY_MESSAGE = "SELECT AVG(r.rating), COUNT(*) from "
+ + KalturaRating.class.getName() + " as r where r.kalturaItem.uid=? and r.createBy.session.sessionId=?";
+
+ @Override
+ public KalturaRating getKalturaRatingByItemAndUser(Long itemUid, Long userId) {
+ List list = getHibernateTemplate().find(FIND_BY_ITEM_AND_USER, new Object[] { userId, itemUid });
+ if (list == null || list.size() == 0)
+ return null;
+ return (KalturaRating) list.get(0);
+ }
+
+ @Override
+ public List