Index: lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McUploadedFile.hbm.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/Attic/McUploadedFile.hbm.xml,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McUploadedFile.hbm.xml 31 Oct 2005 18:57:26 -0000 1.1
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_lamc/db/sql/create_lams_tool_lamc.sql
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/db/sql/Attic/create_lams_tool_lamc.sql,v
diff -u -r1.16 -r1.17
Binary files differ
Index: lams_tool_lamc/db/sql/delete_lams_tool_lamc.sql
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/db/sql/Attic/delete_lams_tool_lamc.sql,v
diff -u -r1.1 -r1.2
Binary files differ
Index: lams_tool_lamc/db/sql/drop_lams_tool_lamc.sql
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/db/sql/Attic/drop_lams_tool_lamc.sql,v
diff -u -r1.2 -r1.3
Binary files differ
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUploadedFile.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/Attic/McUploadedFile.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUploadedFile.java 31 Oct 2005 18:57:26 -0000 1.1
@@ -0,0 +1,178 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *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; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.mc;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+/**
+ *
+ * @author Ozgur Demirtas
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * Holds uploaded file information
+ */
+
+public class McUploadedFile implements Serializable
+{
+ /** identifier field */
+ private Long uid;
+
+ /** persistent field */
+ private String uuid;
+
+ /** persistent field */
+ private boolean fileOnline;
+
+ /** persistent field */
+ private String filename;
+
+
+ private Long mcContentId;
+
+ /** persistent field */
+ private McContent mcContent;
+
+ public McUploadedFile(){};
+
+ /** full constructor */
+ public McUploadedFile(Long uid,
+ String uuid,
+ boolean fileOnline,
+ String filename,
+ McContent mcContent)
+ {
+ this.uid=uid;
+ this.uuid = uuid;
+ this.fileOnline = fileOnline;
+ this.filename = filename;
+ this.mcContent=mcContent;
+ }
+
+ public McUploadedFile(String uuid,
+ boolean fileOnline,
+ String filename,
+ McContent mcContent)
+ {
+ this.uuid = uuid;
+ this.fileOnline = fileOnline;
+ this.filename = filename;
+ this.mcContent=mcContent;
+ }
+
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("uuid: ", getUuid())
+ .toString();
+ }
+
+
+ /**
+ * @return Returns the mcContent.
+ */
+ public McContent getMcContent() {
+ return mcContent;
+ }
+ /**
+ * @param mcContent The mcContent to set.
+ */
+ public void setMcContent(McContent mcContent) {
+ this.mcContent = mcContent;
+ }
+ /**
+ * @return Returns the mcContentId.
+ */
+ public Long getMcContentId() {
+ return mcContentId;
+ }
+ /**
+ * @param mcContentId The mcContentId to set.
+ */
+ public void setMcContentId(Long mcContentId) {
+ this.mcContentId = mcContentId;
+ }
+ /**
+ * @return Returns the uid.
+ */
+ public Long getSubmissionId() {
+ return uid;
+ }
+ /**
+ * @param uid The uid to set.
+ */
+ public void setSubmissionId(Long uid) {
+ this.uid = uid;
+ }
+ /**
+ * @return Returns the uuid.
+ */
+ public String getUuid() {
+ return uuid;
+ }
+ /**
+ * @param uuid The uuid to set.
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+ /**
+ * @return Returns the fileOnline.
+ */
+ public boolean isFileOnline() {
+ return fileOnline;
+ }
+ /**
+ * @param fileOnline The fileOnline to set.
+ */
+ public void setFileOnline(boolean fileOnline) {
+ this.fileOnline = fileOnline;
+ }
+ /**
+ * @return Returns the uid.
+ */
+ public Long getUid() {
+ return uid;
+ }
+ /**
+ * @param uid The uid to set.
+ */
+ public void setUid(Long uid) {
+ this.uid = uid;
+ }
+ /**
+ * @return Returns the filename.
+ */
+ public String getFilename() {
+ return filename;
+ }
+ /**
+ * @param filename The filename to set.
+ */
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml,v
diff -u -r1.6 -r1.7
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml 12 Oct 2005 16:39:21 -0000 1.6
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml 31 Oct 2005 18:57:26 -0000 1.7
@@ -23,7 +23,7 @@
/org/lamsfoundation/lams/tool/mc/McSession.hbm.xml
/org/lamsfoundation/lams/tool/mc/McQueUsr.hbm.xml
/org/lamsfoundation/lams/tool/mc/McUsrAttempt.hbm.xml
-
+ /org/lamsfoundation/lams/tool/mc/McUploadedFile.hbm.xml
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/Attic/IMcUploadedFileDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java 31 Oct 2005 18:57:26 -0000 1.1
@@ -0,0 +1,62 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *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; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.mc.dao;
+
+import java.util.List;
+
+import org.lamsfoundation.lams.tool.mc.McContent;
+import org.lamsfoundation.lams.tool.mc.McUploadedFile;
+
+/**
+ *
+ * @author Ozgur Demirtas
+ *
+ */
+public interface IMcUploadedFileDAO
+{
+ public McUploadedFile loadUploadedFileById(long submissionId);
+
+ public void updateUploadFile(McUploadedFile mcUploadedFile);
+
+ public void saveUploadFile(McUploadedFile mcUploadedFile);
+
+ public void createUploadFile(McUploadedFile mcUploadedFile);
+
+ public void UpdateUploadFile(McUploadedFile mcUploadedFile);
+
+ public void removeUploadFile(Long submissionId);
+
+ public void deleteUploadFile(McUploadedFile mcUploadedFile);
+
+ public List retrieveMcUploadedFiles(McContent mc, boolean fileOnline);
+
+ public List retrieveMcUploadedOfflineFilesUuid(McContent mc);
+
+ public List retrieveMcUploadedOnlineFilesUuid(McContent mc);
+
+ public List retrieveMcUploadedOfflineFilesName(McContent mc);
+
+ public List retrieveMcUploadedOnlineFilesName(McContent mc);
+
+ public void cleanUploadedFilesMetaData();
+
+ public void flush();
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUploadedFileDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/Attic/McUploadedFileDAO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUploadedFileDAO.java 31 Oct 2005 18:57:26 -0000 1.1
@@ -0,0 +1,190 @@
+/***************************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ***********************************************************************/
+
+package org.lamsfoundation.lams.tool.mc.dao.hibernate;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.mc.McContent;
+import org.lamsfoundation.lams.tool.mc.McUploadedFile;
+import org.lamsfoundation.lams.tool.mc.dao.IMcUploadedFileDAO;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+
+/**
+ * @author Ozgur Demirtas
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+public class McUploadedFileDAO extends HibernateDaoSupport implements IMcUploadedFileDAO {
+ static Logger logger = Logger.getLogger(McUploadedFileDAO.class.getName());
+
+ private static final String GET_ONLINE_FILENAMES_FOR_CONTENT = "select mcUploadedFile.fileName from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mc and mcUploadedFile.fileOnline=1";
+ private static final String GET_OFFLINE_FILENAMES_FOR_CONTENT = "select mcUploadedFile.fileName from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mc and mcUploadedFile.fileOnline=0";
+
+ private static final String GET_ONLINE_FILES_UUID = "select mcUploadedFile.uuid from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mc and mcUploadedFile.fileOnline=1";
+ private static final String GET_ONLINE_FILES_NAME ="select mcUploadedFile.fileName from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mc and mcUploadedFile.fileOnline=1 order by mcUploadedFile.uuid";
+
+ private static final String GET_OFFLINE_FILES_UUID = "select mcUploadedFile.uuid from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mc and mcUploadedFile.fileOnline=0";
+ private static final String GET_OFFLINE_FILES_NAME ="select mcUploadedFile.fileName from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mc and mcUploadedFile.fileOnline=0 order by mcUploadedFile.uuid";
+
+ public McUploadedFile getUploadedFileById(long submissionId)
+ {
+ return (McUploadedFile) this.getHibernateTemplate()
+ .load(McUploadedFile.class, new Long(submissionId));
+ }
+
+ /**
+ *
+ * return null if not found
+ */
+ public McUploadedFile loadUploadedFileById(long submissionId)
+ {
+ return (McUploadedFile) this.getHibernateTemplate().get(McUploadedFile.class, new Long(submissionId));
+ }
+
+
+
+ public void updateUploadFile(McUploadedFile mcUploadedFile)
+ {
+ this.getHibernateTemplate().update(mcUploadedFile);
+ }
+
+
+ public void saveUploadFile(McUploadedFile mcUploadedFile)
+ {
+ this.getHibernateTemplate().save(mcUploadedFile);
+ }
+
+ public void createUploadFile(McUploadedFile mcUploadedFile)
+ {
+ this.getHibernateTemplate().save(mcUploadedFile);
+ }
+
+ public void UpdateUploadFile(McUploadedFile mcUploadedFile)
+ {
+ this.getHibernateTemplate().update(mcUploadedFile);
+ }
+
+
+ public void cleanUploadedFilesMetaData()
+ {
+ String query = "from uploadedFile in class org.lamsfoundation.lams.tool.mc.McUploadedFile";
+ this.getHibernateTemplate().delete(query);
+ }
+
+ public void removeUploadFile(Long submissionId)
+ {
+ if (submissionId != null ) {
+
+ String query = "from uploadedFile in class org.lamsfoundation.lams.tool.mc.McUploadedFile"
+ + " where uploadedFile.submissionId = ?";
+ Object obj = this.getSession().createQuery(query)
+ .setLong(0,submissionId.longValue())
+ .uniqueResult();
+ if ( obj != null ) {
+ this.getHibernateTemplate().delete(obj);
+ }
+ }
+ }
+
+ public List retrieveMcUploadedFiles(McContent mc, boolean fileOnline)
+ {
+ List listFilenames=null;
+
+ if (fileOnline)
+ {
+ listFilenames=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILENAMES_FOR_CONTENT,
+ "mc",
+ mc));
+ }
+ else
+ {
+ listFilenames=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILENAMES_FOR_CONTENT,
+ "mc",
+ mc));
+ }
+ return listFilenames;
+ }
+
+
+ public List retrieveMcUploadedOfflineFilesUuid(McContent mc)
+ {
+ List listFilesUuid=null;
+
+ listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILES_UUID,
+ "mc",
+ mc));
+
+ return listFilesUuid;
+ }
+
+ public List retrieveMcUploadedOnlineFilesUuid(McContent mc)
+ {
+ List listFilesUuid=null;
+
+ listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILES_UUID,
+ "mc",
+ mc));
+
+ return listFilesUuid;
+ }
+
+
+ public List retrieveMcUploadedOfflineFilesName(McContent mc)
+ {
+ List listFilesUuid=null;
+
+ listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILES_NAME,
+ "mc",
+ mc));
+
+ return listFilesUuid;
+ }
+
+ public List retrieveMcUploadedOnlineFilesName(McContent mc)
+ {
+ List listFilesUuid=null;
+
+ listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILES_NAME,
+ "mc",
+ mc));
+
+ return listFilesUuid;
+ }
+
+
+
+ public void deleteUploadFile(McUploadedFile mcUploadedFile)
+ {
+ this.getHibernateTemplate().delete(mcUploadedFile);
+ }
+
+ public void flush()
+ {
+ this.getHibernateTemplate().flush();
+ }
+
+}
\ No newline at end of file