Index: lams_build/lib/lams/lams.jar
===================================================================
diff -u -r3b02878f07a0d07bf85a0c4126155b7b77d126a8 -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
Binary files differ
Index: lams_common/src/java/org/lamsfoundation/lams/dao/IBaseDAO.java
===================================================================
diff -u -r2dd947ef3812e8d41a9e4be552f54e71ecd1558a -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/dao/IBaseDAO.java (.../IBaseDAO.java) (revision 2dd947ef3812e8d41a9e4be552f54e71ecd1558a)
+++ lams_common/src/java/org/lamsfoundation/lams/dao/IBaseDAO.java (.../IBaseDAO.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -31,294 +31,327 @@
/**
* @version
*
- *
- * View Source
- *
+ *
+ * View Source
+ *
*
* @author Fei Yang
*
- * Created at 22:50:25 on 16/06/2006
+ * Created at 22:50:25 on 16/06/2006
*/
public interface IBaseDAO {
-
- /**
- * Insert an object into the database. Should only be used if the object has not
- * been persisted previously.
- *
- * @param object The object to be inserted
- */
- public void insert(Object object);
- /**
- * Update a previously inserted object into the database.
- * @param object The object to be updated
- */
- public void update(Object object);
- /**
- * Insert or update an object into the database. It is up to the persistence
- * engine to decide whether to insert or update.
- * @param object The object to be inserted/updated
- */
- public void insertOrUpdate(Object object);
-
- /**
- * @param objects
- * @return void
- */
- public void insertOrUpdateAll(Collection objects);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryString
- * @return void
- */
- public void update(String queryString);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryString
- * @param value
- * @return void
- */
- public void update(String queryString, Object value);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryString
- * @param values
- * @return void
- */
- public void update(String queryString, Object[] values);
-
- /**
- * @param clazz
- * @param propertyToChange
- * @param newValue
- * @param conditionProperty
- * @param conditionValue
- * @return void
- */
- public void update(Class clazz, String propertyToChange, Object newValue, String conditionProperty, Object conditionValue);
-
- /**
- * @param clazz
- * @param propertyToChange
- * @param newValue
- * @param conditions in a map
- * @return void
- */
- public void update(Class clazz, String propertyToChange, Object newValue, Map conditions);
-
- /**
- * @param clazz
- * @param newValues in a map
- * @param conditionProperty
- * @param conditionValue
- * @return void
- */
- public void update(Class clazz, Map newValues, String conditionProperty, Object conditionValue);
-
- /**
- * @param clazz
- * @param newValues in a map
- * @param conditions in a map
- * @return void
- */
- public void update(Class clazz, Map newValues, Map conditions);
-
- /**
- * These 2 objects have to be instances of the Class
- * @param clazz
- * @param newValues in a object
- * @param conditions in a object
- * @return void
- */
- public void updateAnythingLike(Class clazz, Object newValues, Object conditions);
-
- /**
- * Remove an object from the database.
- * @param object The object to be deleted
- */
- public void delete(Object object);
-
-
- /**
- * Be careful to use this method. It will clean up the whole table for the Class
- * @param clazz
- * @return void
- */
- public void deleteAll(Class clazz);
-
- /**
- * @param objects to delete
- * @return void
- */
- public void deleteAll(Collection objects);
-
- /**
- * @param clazz java Class
- * @param id identifier
- * @return void
- */
- public void deleteById(Class clazz, Serializable id);
-
- /**
- * @param clazz
- * @param name
- * @param value
- * @return void
- */
- public void deleteByProperty(Class clazz, String name, Object value);
-
- /**
- * @param properties a map of property names and values
- * @return void
- */
- public void deleteByProperties(Class clazz, Map properties);
-
- /**
- * Delete any object which has the same non-null property values as the object
- * @param object
- * @return void
- */
- public void deleteAnythingLike(Object object);
-
- /**
- * Find an object. If the object is not found
- * then it will return null
- * @param clazz
- * @param id
- */
- public Object find(Class clazz, Serializable id);
-
- /**
- * @param clazz
- * @return all of rows in the table for the Class as objects
- */
- public List findAll(Class clazz);
-
- /**
- * @param clazz
- * @param name
- * @param value
- * @return a list of objects which have the same propery value
- */
- public List findByProperty(Class clazz, String name, Object value);
-
- /**
- * @param properties a map of property names and values
- * @return a list of objects which have the same property values
- */
- public List findByProperties(Class clazz, Map properties);
-
- /**
- * Find any object which has the same non-null property values as the object
- * @param object
- * @return a list of objects which has the same non-null property values as the object
- */
- public List findAnythingLike(Object object);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryString
- * @return void
- */
- public List find(String queryString);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryString
- * @param value
- * @return void
- */
- public List find(String queryString, Object value);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryString
- * @param values
- * @return void
- */
- public List find(String queryString, Object[] values);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryName
- * @return void
- */
- public List findByNamedQuery(String queryName);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryName
- * @param value
- * @return void
- */
- public List findByNamedQuery(String queryName, Object value);
-
- /**
- * Just a wrapper of the method in HibernateTemplate
- * shouldn't be used unless a complicated query needed
- * @param queryName
- * @param values
- * @return void
- */
- public List findByNamedQuery(String queryName, Object[] values);
-
-
- /**
- * @param clazz
- * @param name of the property
- * @param pattern to match
- * @return a list of objects
- */
- public List searchByStringProperty(Class clazz, String name, String pattern);
-
- /**
- * @param clazz
- * @param name of the property
- * @param pattern to match
- * @return a list of objects
- */
- public List searchByStringProperties(Class clazz, Map properties);
-
- /**
- * @param clazz
- * @param name of the property
- * @param min
- * @param minIncluded
- * @param max
- * @param maxIncluded
- * @return a list of objects
- */
- public List searchByNumberSpan(Class clazz, String name, Integer min, Boolean minIncluded, Integer max, Boolean maxIncluded);
-
-
- /**
- * Force initialization of a Hibernate proxy or persistent collection
- * @param proxy of persistent object or a collection
- */
- public void initialize(Object proxy);
-
- /**
- * Count all rows in a table for a hibernate-mapped class
- * @param clazz
- * @return
- */
- public long countAll(Class clazz);
-
- /**
- * Create a query based on the properties, and count the result
- *
- * @param properties a map of property names and values
- * @return a list of objects which have the same property values
- */
- public long countByProperties(Class clazz, Map properties);
+
+ public void flush();
+
+ /**
+ * Insert an object into the database. Should only be used if the object has not been persisted previously.
+ *
+ * @param object
+ * The object to be inserted
+ */
+ public void insert(Object object);
+
+ /**
+ * Update a previously inserted object into the database.
+ *
+ * @param object
+ * The object to be updated
+ */
+ public void update(Object object);
+
+ /**
+ * Insert or update an object into the database. It is up to the persistence engine to decide whether to insert or
+ * update.
+ *
+ * @param object
+ * The object to be inserted/updated
+ */
+ public void insertOrUpdate(Object object);
+
+ /**
+ * @param objects
+ * @return void
+ */
+ public void insertOrUpdateAll(Collection objects);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryString
+ * @return void
+ */
+ public void update(String queryString);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryString
+ * @param value
+ * @return void
+ */
+ public void update(String queryString, Object value);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryString
+ * @param values
+ * @return void
+ */
+ public void update(String queryString, Object[] values);
+
+ /**
+ * @param clazz
+ * @param propertyToChange
+ * @param newValue
+ * @param conditionProperty
+ * @param conditionValue
+ * @return void
+ */
+ public void update(Class clazz, String propertyToChange, Object newValue, String conditionProperty,
+ Object conditionValue);
+
+ /**
+ * @param clazz
+ * @param propertyToChange
+ * @param newValue
+ * @param conditions
+ * in a map
+ * @return void
+ */
+ public void update(Class clazz, String propertyToChange, Object newValue, Map conditions);
+
+ /**
+ * @param clazz
+ * @param newValues
+ * in a map
+ * @param conditionProperty
+ * @param conditionValue
+ * @return void
+ */
+ public void update(Class clazz, Map newValues, String conditionProperty, Object conditionValue);
+
+ /**
+ * @param clazz
+ * @param newValues
+ * in a map
+ * @param conditions
+ * in a map
+ * @return void
+ */
+ public void update(Class clazz, Map newValues, Map conditions);
+
+ /**
+ * These 2 objects have to be instances of the Class
+ *
+ * @param clazz
+ * @param newValues
+ * in a object
+ * @param conditions
+ * in a object
+ * @return void
+ */
+ public void updateAnythingLike(Class clazz, Object newValues, Object conditions);
+
+ /**
+ * Remove an object from the database.
+ *
+ * @param object
+ * The object to be deleted
+ */
+ public void delete(Object object);
+
+ /**
+ * Be careful to use this method. It will clean up the whole table for the Class
+ *
+ * @param clazz
+ * @return void
+ */
+ public void deleteAll(Class clazz);
+
+ /**
+ * @param objects
+ * to delete
+ * @return void
+ */
+ public void deleteAll(Collection objects);
+
+ /**
+ * @param clazz
+ * java Class
+ * @param id
+ * identifier
+ * @return void
+ */
+ public void deleteById(Class clazz, Serializable id);
+
+ /**
+ * @param clazz
+ * @param name
+ * @param value
+ * @return void
+ */
+ public void deleteByProperty(Class clazz, String name, Object value);
+
+ /**
+ * @param properties
+ * a map of property names and values
+ * @return void
+ */
+ public void deleteByProperties(Class clazz, Map properties);
+
+ /**
+ * Delete any object which has the same non-null property values as the object
+ *
+ * @param object
+ * @return void
+ */
+ public void deleteAnythingLike(Object object);
+
+ /**
+ * Find an object. If the object is not found then it will return null
+ *
+ * @param clazz
+ * @param id
+ */
+ public Object find(Class clazz, Serializable id);
+
+ /**
+ * @param clazz
+ * @return all of rows in the table for the Class as objects
+ */
+ public List findAll(Class clazz);
+
+ /**
+ * @param clazz
+ * @param name
+ * @param value
+ * @return a list of objects which have the same propery value
+ */
+ public List findByProperty(Class clazz, String name, Object value);
+
+ /**
+ * @param properties
+ * a map of property names and values
+ * @return a list of objects which have the same property values
+ */
+ public List findByProperties(Class clazz, Map properties);
+
+ /**
+ * Find any object which has the same non-null property values as the object
+ *
+ * @param object
+ * @return a list of objects which has the same non-null property values as the object
+ */
+ public List findAnythingLike(Object object);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryString
+ * @return void
+ */
+ public List find(String queryString);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryString
+ * @param value
+ * @return void
+ */
+ public List find(String queryString, Object value);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryString
+ * @param values
+ * @return void
+ */
+ public List find(String queryString, Object[] values);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryName
+ * @return void
+ */
+ public List findByNamedQuery(String queryName);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryName
+ * @param value
+ * @return void
+ */
+ public List findByNamedQuery(String queryName, Object value);
+
+ /**
+ * Just a wrapper of the method in HibernateTemplate shouldn't be used unless a complicated query needed
+ *
+ * @param queryName
+ * @param values
+ * @return void
+ */
+ public List findByNamedQuery(String queryName, Object[] values);
+
+ /**
+ * @param clazz
+ * @param name
+ * of the property
+ * @param pattern
+ * to match
+ * @return a list of objects
+ */
+ public List searchByStringProperty(Class clazz, String name, String pattern);
+
+ /**
+ * @param clazz
+ * @param name
+ * of the property
+ * @param pattern
+ * to match
+ * @return a list of objects
+ */
+ public List searchByStringProperties(Class clazz, Map properties);
+
+ /**
+ * @param clazz
+ * @param name
+ * of the property
+ * @param min
+ * @param minIncluded
+ * @param max
+ * @param maxIncluded
+ * @return a list of objects
+ */
+ public List searchByNumberSpan(Class clazz, String name, Integer min, Boolean minIncluded, Integer max,
+ Boolean maxIncluded);
+
+ /**
+ * Force initialization of a Hibernate proxy or persistent collection
+ *
+ * @param proxy
+ * of persistent object or a collection
+ */
+ public void initialize(Object proxy);
+
+ /**
+ * Count all rows in a table for a hibernate-mapped class
+ *
+ * @param clazz
+ * @return
+ */
+ public long countAll(Class clazz);
+
+ /**
+ * Create a query based on the properties, and count the result
+ *
+ * @param properties
+ * a map of property names and values
+ * @return a list of objects which have the same property values
+ */
+ public long countByProperties(Class clazz, Map properties);
}
Index: lams_common/src/java/org/lamsfoundation/lams/dao/hibernate/BaseDAO.java
===================================================================
diff -u -r2dd947ef3812e8d41a9e4be552f54e71ecd1558a -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/dao/hibernate/BaseDAO.java (.../BaseDAO.java) (revision 2dd947ef3812e8d41a9e4be552f54e71ecd1558a)
+++ lams_common/src/java/org/lamsfoundation/lams/dao/hibernate/BaseDAO.java (.../BaseDAO.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -38,344 +38,387 @@
/**
* @version
*
- * Wrapper of HibernteTemplate() with some more OO methods
+ * Wrapper of HibernteTemplate() with some more OO methods
*
- *
- * View Source
- *
+ *
+ * View Source
+ *
*
* @author Fei Yang
*
- * Created at 23:13:41 on 16/06/2006
+ * Created at 23:13:41 on 16/06/2006
*/
public class BaseDAO extends HibernateDaoSupport implements IBaseDAO {
-
- private static class Qv {
-
- String queryString;
- Object[] values;
-
- Qv(String queryString, Object[] values) {
- super();
-
- this.queryString = queryString;
- this.values = values;
- }
- }
- private static final String SELECT = "from ";
- private static final String UPDATE = "update ";
- private static final String DELETE = "delete ";
- private static final String WHERE = " where ";
- private static final String AND = " and ";
- private static final String SPACE = " ";
- private static final String SPOT = ".";
- private static final String EQUAL_TO_WHAT = "=?";
- private static final String LIKE_WHAT = " like ?";
-
- private static Logger log = Logger.getLogger(BaseDAO.class);
-
+ private static class Qv {
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#insert(java.lang.Object)
- */
- public void insert(Object object) {
- getHibernateTemplate().save(object);
- }
+ String queryString;
+ Object[] values;
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#update(java.lang.Object)
- */
- public void update(Object object) {
- getHibernateTemplate().update(object);
- }
+ Qv(String queryString, Object[] values) {
+ super();
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#insertOrUpdate(java.lang.Object)
- */
- public void insertOrUpdate(Object object) {
- getHibernateTemplate().saveOrUpdate(object);
+ this.queryString = queryString;
+ this.values = values;
}
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#insertOrUpdateAll(java.util.Collection)
- */
- public void insertOrUpdateAll(Collection objects) {
- getHibernateTemplate().saveOrUpdateAll(objects);
- }
+ private static final String SELECT = "from ";
+ private static final String UPDATE = "update ";
+ private static final String DELETE = "delete ";
+ private static final String WHERE = " where ";
+ private static final String AND = " and ";
+ private static final String SPACE = " ";
+ private static final String SPOT = ".";
+ private static final String EQUAL_TO_WHAT = "=?";
+ private static final String LIKE_WHAT = " like ?";
- public void update(String queryString) {
- getHibernateTemplate().bulkUpdate(queryString);
- }
+ private static Logger log = Logger.getLogger(BaseDAO.class);
- public void update(String queryString, Object value) {
- getHibernateTemplate().bulkUpdate(queryString, value);
- }
+ @Override
+ public void flush() {
+ getHibernateTemplate().flush();
+ }
- public void update(String queryString, Object[] values) {
- getHibernateTemplate().bulkUpdate(queryString, values);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#insert(java.lang.Object)
+ */
+ @Override
+ public void insert(Object object) {
+ getHibernateTemplate().save(object);
+ }
- public void update(Class clazz, String propertyToChange, Object newValue, String conditionProperty, Object conditionValue) {
- //TODO implement me
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#update(java.lang.Object)
+ */
+ @Override
+ public void update(Object object) {
+ getHibernateTemplate().update(object);
+ }
- public void update(Class clazz, String propertyToChange, Object newValue, Map conditions) {
- //TODO implement me
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#insertOrUpdate(java.lang.Object)
+ */
+ @Override
+ public void insertOrUpdate(Object object) {
+ getHibernateTemplate().saveOrUpdate(object);
+ }
- public void update(Class clazz, Map newValues, String conditionProperty, Object conditionValue) {
- //TODO implement me
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#insertOrUpdateAll(java.util.Collection)
+ */
+ @Override
+ public void insertOrUpdateAll(Collection objects) {
+ getHibernateTemplate().saveOrUpdateAll(objects);
+ }
- public void update(Class clazz, Map newValues, Map conditions) {
- //TODO implement me
- }
+ @Override
+ public void update(String queryString) {
+ getHibernateTemplate().bulkUpdate(queryString);
+ }
- public void updateAnythingLike(Class clazz, Object newValues, Object conditions) {
- //TODO implement me
- }
+ @Override
+ public void update(String queryString, Object value) {
+ getHibernateTemplate().bulkUpdate(queryString, value);
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#delete(java.lang.Object)
- */
- public void delete(Object object) {
- getHibernateTemplate().delete(object);
- }
+ @Override
+ public void update(String queryString, Object[] values) {
+ getHibernateTemplate().bulkUpdate(queryString, values);
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteAll(java.lang.Class)
- */
- public void deleteAll(Class clazz) {
- String queryString = buildQueryString(clazz,DELETE);
- getHibernateTemplate().bulkUpdate(queryString);
- }
+ @Override
+ public void update(Class clazz, String propertyToChange, Object newValue, String conditionProperty,
+ Object conditionValue) {
+ // TODO implement me
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteAll(java.util.Collection)
- */
- public void deleteAll(Collection objects) {
- getHibernateTemplate().deleteAll(objects);
- }
+ @Override
+ public void update(Class clazz, String propertyToChange, Object newValue, Map conditions) {
+ // TODO implement me
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteById(java.lang.Class, java.io.Serializable)
- */
- public void deleteById(Class clazz, Serializable id) {
- delete(find(clazz,id));
- }
+ @Override
+ public void update(Class clazz, Map newValues, String conditionProperty, Object conditionValue) {
+ // TODO implement me
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteByProperty(java.lang.Class, java.lang.String, java.lang.Object)
- */
- public void deleteByProperty(Class clazz, String name, Object value) {
- String queryString = buildQueryString(clazz,name,DELETE);
- getHibernateTemplate().bulkUpdate(queryString,value);
- }
+ @Override
+ public void update(Class clazz, Map newValues, Map conditions) {
+ // TODO implement me
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteByProperties(java.lang.Class, java.util.Map)
- */
- public void deleteByProperties(Class clazz, Map properties) {
- Qv qv = buildQueryString(clazz,properties,DELETE,EQUAL_TO_WHAT);
- getHibernateTemplate().bulkUpdate(qv.queryString,qv.values);
- }
+ @Override
+ public void updateAnythingLike(Class clazz, Object newValues, Object conditions) {
+ // TODO implement me
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteAnythingLike(java.lang.Object)
- */
- public void deleteAnythingLike(Object object) {
- try{
- Qv qv = buildQueryString(object,DELETE);
- getHibernateTemplate().bulkUpdate(qv.queryString,qv.values);
- }catch(Exception e){
- log.debug(e);
- }
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#delete(java.lang.Object)
+ */
+ @Override
+ public void delete(Object object) {
+ getHibernateTemplate().delete(object);
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#find(java.lang.Class, java.io.Serializable)
- */
- public Object find(Class clazz, Serializable id) {
- return getHibernateTemplate().get(clazz,id);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteAll(java.lang.Class)
+ */
+ @Override
+ public void deleteAll(Class clazz) {
+ String queryString = buildQueryString(clazz, BaseDAO.DELETE);
+ getHibernateTemplate().bulkUpdate(queryString);
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#findAll(java.lang.Class)
- */
- public List findAll(Class clazz) {
- return getHibernateTemplate().loadAll(clazz);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteAll(java.util.Collection)
+ */
+ @Override
+ public void deleteAll(Collection objects) {
+ getHibernateTemplate().deleteAll(objects);
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#findByProperty(java.lang.Class, java.lang.String, java.lang.Object)
- */
- public List findByProperty(Class clazz, String name, Object value) {
- String queryString = buildQueryString(clazz,name,SELECT);
- return getHibernateTemplate().find(queryString,value);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteById(java.lang.Class, java.io.Serializable)
+ */
+ @Override
+ public void deleteById(Class clazz, Serializable id) {
+ delete(find(clazz, id));
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#findByProperties(java.lang.Class, java.util.Map)
- */
- public List findByProperties(Class clazz, Map properties) {
- Qv qv = buildQueryString(clazz,properties,SELECT,EQUAL_TO_WHAT);
- return getHibernateTemplate().find(qv.queryString,qv.values);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteByProperty(java.lang.Class, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void deleteByProperty(Class clazz, String name, Object value) {
+ String queryString = buildQueryString(clazz, name, BaseDAO.DELETE);
+ getHibernateTemplate().bulkUpdate(queryString, value);
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#findAnythingLike(java.lang.Object)
- */
- public List findAnythingLike(Object object) {
- return getHibernateTemplate().findByExample(object);
- }
-
- private String buildQueryString(Class clazz,String operation){
- StringBuffer queryString = new StringBuffer(operation).append(clazz.getSimpleName());
- //log.debug(queryString);
- return queryString.toString();
- }
-
- private String buildQueryString(Class clazz,String name, String operation){
- String clazzName = clazz.getSimpleName();
- String objName = createObjectName(clazzName);
- StringBuffer queryString = new StringBuffer(operation).append(clazzName).append(SPACE)
- .append(objName).append(WHERE).append(objName).append(SPOT)
- .append(name).append(EQUAL_TO_WHAT);
- //log.debug(queryString);
- return queryString.toString();
- }
-
- public List find(String queryString) {
- return getHibernateTemplate().find(queryString);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteByProperties(java.lang.Class, java.util.Map)
+ */
+ @Override
+ public void deleteByProperties(Class clazz, Map properties) {
+ Qv qv = buildQueryString(clazz, properties, BaseDAO.DELETE, BaseDAO.EQUAL_TO_WHAT);
+ getHibernateTemplate().bulkUpdate(qv.queryString, qv.values);
+ }
- public List find(String queryString, Object value) {
- return getHibernateTemplate().find(queryString,value);
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#deleteAnythingLike(java.lang.Object)
+ */
+ @Override
+ public void deleteAnythingLike(Object object) {
+ try {
+ Qv qv = buildQueryString(object, BaseDAO.DELETE);
+ getHibernateTemplate().bulkUpdate(qv.queryString, qv.values);
+ } catch (Exception e) {
+ BaseDAO.log.debug(e);
}
+ }
- public List find(String queryString, Object[] values) {
- return getHibernateTemplate().find(queryString, values);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#find(java.lang.Class, java.io.Serializable)
+ */
+ @Override
+ public Object find(Class clazz, Serializable id) {
+ return getHibernateTemplate().get(clazz, id);
+ }
- public List findByNamedQuery(String queryName) {
- return getHibernateTemplate().findByNamedQuery(queryName);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#findAll(java.lang.Class)
+ */
+ @Override
+ public List findAll(Class clazz) {
+ return getHibernateTemplate().loadAll(clazz);
+ }
- public List findByNamedQuery(String queryName, Object value) {
- return getHibernateTemplate().findByNamedQuery(queryName, value);
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#findByProperty(java.lang.Class, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public List findByProperty(Class clazz, String name, Object value) {
+ String queryString = buildQueryString(clazz, name, BaseDAO.SELECT);
+ return getHibernateTemplate().find(queryString, value);
+ }
- public List findByNamedQuery(String queryName, Object[] values) {
- return getHibernateTemplate().findByNamedQuery(queryName, values);
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#findByProperties(java.lang.Class, java.util.Map)
+ */
+ @Override
+ public List findByProperties(Class clazz, Map properties) {
+ Qv qv = buildQueryString(clazz, properties, BaseDAO.SELECT, BaseDAO.EQUAL_TO_WHAT);
+ return getHibernateTemplate().find(qv.queryString, qv.values);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#findAnythingLike(java.lang.Object)
+ */
+ @Override
+ public List findAnythingLike(Object object) {
+ return getHibernateTemplate().findByExample(object);
+ }
+
+ private String buildQueryString(Class clazz, String operation) {
+ StringBuffer queryString = new StringBuffer(operation).append(clazz.getSimpleName());
+ // log.debug(queryString);
+ return queryString.toString();
+ }
+
+ private String buildQueryString(Class clazz, String name, String operation) {
+ String clazzName = clazz.getSimpleName();
+ String objName = createObjectName(clazzName);
+ StringBuffer queryString = new StringBuffer(operation).append(clazzName).append(BaseDAO.SPACE).append(objName)
+ .append(BaseDAO.WHERE).append(objName).append(BaseDAO.SPOT).append(name).append(BaseDAO.EQUAL_TO_WHAT);
+ // log.debug(queryString);
+ return queryString.toString();
+ }
+
+ @Override
+ public List find(String queryString) {
+ return getHibernateTemplate().find(queryString);
+ }
+
+ @Override
+ public List find(String queryString, Object value) {
+ return getHibernateTemplate().find(queryString, value);
+ }
+
+ @Override
+ public List find(String queryString, Object[] values) {
+ return getHibernateTemplate().find(queryString, values);
+ }
+
+ @Override
+ public List findByNamedQuery(String queryName) {
+ return getHibernateTemplate().findByNamedQuery(queryName);
+ }
+
+ @Override
+ public List findByNamedQuery(String queryName, Object value) {
+ return getHibernateTemplate().findByNamedQuery(queryName, value);
+ }
+
+ @Override
+ public List findByNamedQuery(String queryName, Object[] values) {
+ return getHibernateTemplate().findByNamedQuery(queryName, values);
+ }
+
+ @Override
+ public List searchByStringProperty(Class clazz, String name, String pattern) {
+ // TODO implement me
+ return null;
+ }
+
+ @Override
+ public List searchByStringProperties(Class clazz, Map properties) {
+ Map p = new HashMap();
+ for (Map.Entry entry : properties.entrySet()) {
+ p.put(entry.getKey(), entry.getValue());
}
+ Qv qv = buildQueryString(clazz, p, BaseDAO.SELECT, BaseDAO.LIKE_WHAT);
+ return getHibernateTemplate().find(qv.queryString, qv.values);
+ }
- public List searchByStringProperty(Class clazz, String name, String pattern) {
- //TODO implement me
- return null;
+ @Override
+ public List searchByNumberSpan(Class clazz, String name, Integer min, Boolean minIncluded, Integer max,
+ Boolean maxIncluded) {
+ // TODO implement me
+ return null;
+ }
+
+ private Qv buildQueryString(Class clazz, Map properties, String operation, String condition) {
+ String clazzName = clazz.getSimpleName();
+ String objName = createObjectName(clazzName);
+ StringBuffer queryString = new StringBuffer(operation).append(clazzName).append(BaseDAO.SPACE).append(objName)
+ .append(BaseDAO.WHERE);
+ Object[] values = new Object[properties.size()];
+ int i = 0;
+ for (Map.Entry entry : properties.entrySet()) {
+ queryString.append(objName).append(BaseDAO.SPOT).append(entry.getKey()).append(condition);
+ if (i != (properties.size() - 1)) {
+ queryString.append(BaseDAO.AND);
+ }
+ values[i] = entry.getValue();
+ i++;
}
+ // log.debug(queryString);
+ return new Qv(queryString.toString(), values);
+ }
- public List searchByStringProperties(Class clazz, Map properties) {
- Map p = new HashMap();
- for(Map.Entry entry : properties.entrySet()){
- p.put(entry.getKey(), (Object)entry.getValue());
+ private Qv buildQueryString(Object obj, String operation) throws Exception {
+ String clazzName = obj.getClass().getSimpleName();
+ String objName = createObjectName(clazzName);
+ StringBuffer queryString = new StringBuffer(operation).append(clazzName).append(BaseDAO.SPACE).append(objName)
+ .append(BaseDAO.WHERE);
+ Field[] fields = obj.getClass().getDeclaredFields();
+ List values = new ArrayList();
+ for (int i = 0; i < fields.length; i++) {
+ String name = fields[i].getName();
+ Method readMethod = getReadMethod(fields[i], name, obj.getClass());
+ Object value = readMethod.invoke(obj);
+ if (value != null) {
+ queryString.append(objName).append(BaseDAO.SPOT).append(name).append(BaseDAO.EQUAL_TO_WHAT);
+ if (i != (fields.length - 1)) {
+ queryString.append(BaseDAO.AND);
}
- Qv qv = buildQueryString(clazz,p,SELECT,LIKE_WHAT);
- return getHibernateTemplate().find(qv.queryString,qv.values);
+ values.add(value);
+ }
}
+ // log.debug(queryString);
+ return new Qv(queryString.toString(), values.toArray());
+ }
- public List searchByNumberSpan(Class clazz, String name, Integer min, Boolean minIncluded, Integer max, Boolean maxIncluded) {
- //TODO implement me
- return null;
+ private Method getReadMethod(Field field, String fieldName, Class clazz) throws Exception {
+ String convertedName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
+ if (field.getType().getSimpleName().equals("Boolean")) {
+ return clazz.getDeclaredMethod("is" + convertedName);
+ } else {
+ return clazz.getDeclaredMethod("get" + convertedName);
}
-
- private Qv buildQueryString(Class clazz, Map properties, String operation, String condition){
- String clazzName = clazz.getSimpleName();
- String objName = createObjectName(clazzName);
- StringBuffer queryString = new StringBuffer(operation).append(clazzName).append(SPACE).append(objName).append(WHERE);
- Object[] values = new Object[properties.size()];
- int i=0;
- for(Map.Entry entry : properties.entrySet()){
- queryString.append(objName).append(SPOT).append(entry.getKey()).append(condition);
- if(i!=properties.size()-1){
- queryString.append(AND);
- }
- values[i] = entry.getValue();
- i++;
- }
- //log.debug(queryString);
- return new Qv(queryString.toString(),values);
+
+ }
+
+ private String createObjectName(String clazzName) {
+ return clazzName.substring(0, 1).toLowerCase();
+ }
+
+ @Override
+ public void initialize(Object proxy) {
+ getHibernateTemplate().initialize(proxy);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.dao.IBaseDAO#countAll(java.lang.Class)
+ */
+ @Override
+ public long countAll(Class clazz) {
+ String query = "select count(*) from " + clazz.getSimpleName();
+
+ List list = getHibernateTemplate().find(query);
+
+ if ((list != null) && (list.size() > 0)) {
+ return (Long) list.get(0);
+ } else {
+ return 0;
}
-
- private Qv buildQueryString(Object obj, String operation) throws Exception{
- String clazzName = obj.getClass().getSimpleName();
- String objName = createObjectName(clazzName);
- StringBuffer queryString = new StringBuffer(operation).append(clazzName).append(SPACE).append(objName).append(WHERE);
- Field[] fields = obj.getClass().getDeclaredFields();
- List values = new ArrayList();
- for(int i=0; i properties) {
+ Qv qv = buildQueryString(clazz, properties, BaseDAO.SELECT, BaseDAO.EQUAL_TO_WHAT);
+ String query = "select count(*) " + qv.queryString;
+
+ List list = getHibernateTemplate().find(query, qv.values);
+
+ if ((list != null) && (list.size() > 0)) {
+ return (Long) list.get(0);
+ } else {
+ return 0;
}
-
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#countAll(java.lang.Class)
- */
- public long countAll(Class clazz) {
- String query = "select count(*) from " + clazz.getSimpleName();
-
- List list = getHibernateTemplate().find(query);
-
- if (list != null && list.size() > 0) {
- return (Long)list.get(0);
- } else {
- return 0;
- }
- }
-
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.dao.IBaseDAO#countByProperties(java.lang.Class, java.util.Map)
- */
- public long countByProperties(Class clazz, Map properties) {
- Qv qv = buildQueryString(clazz,properties,SELECT,EQUAL_TO_WHAT);
- String query = "select count(*) " + qv.queryString;
-
- List list = getHibernateTemplate().find(query,qv.values);
-
- if (list != null && list.size() > 0) {
- return (Long)list.get(0);
- } else {
- return 0;
- }
- }
+ }
}
Index: lams_common/src/java/org/lamsfoundation/lams/notebook/dao/INotebookEntryDAO.java
===================================================================
diff -u -r38a6c414e30497d03559a85b5c33155e4a2fc22e -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/notebook/dao/INotebookEntryDAO.java (.../INotebookEntryDAO.java) (revision 38a6c414e30497d03559a85b5c33155e4a2fc22e)
+++ lams_common/src/java/org/lamsfoundation/lams/notebook/dao/INotebookEntryDAO.java (.../INotebookEntryDAO.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -31,21 +31,21 @@
public interface INotebookEntryDAO {
- void saveOrUpdate(NotebookEntry nb);
+ void saveOrUpdate(NotebookEntry nb);
- NotebookEntry get(Long uid);
+ NotebookEntry get(Long uid);
- List get(Integer userID);
+ List get(Integer userID);
- List get(Integer userID, Integer idType);
-
- List get(Integer userID, Long lessonID);
+ List get(Integer userID, Integer idType);
- List get(Long id, Integer idType, Integer userID);
-
- List get(Long id, Integer idType, String signature,
- Integer userID);
-
- List get(Long id, Integer idType, String signature);
+ List get(Integer userID, Long lessonID);
-}
+ List get(Long id, Integer idType, Integer userID);
+
+ List get(Long id, Integer idType, String signature, Integer userID);
+
+ List get(Long id, Integer idType, String signature);
+
+ void delete(NotebookEntry notebookEntry);
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/notebook/dao/hibernate/NotebookEntryDAO.java
===================================================================
diff -u -r38a6c414e30497d03559a85b5c33155e4a2fc22e -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/notebook/dao/hibernate/NotebookEntryDAO.java (.../NotebookEntryDAO.java) (revision 38a6c414e30497d03559a85b5c33155e4a2fc22e)
+++ lams_common/src/java/org/lamsfoundation/lams/notebook/dao/hibernate/NotebookEntryDAO.java (.../NotebookEntryDAO.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -32,59 +32,73 @@
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
public class NotebookEntryDAO extends BaseDAO implements INotebookEntryDAO {
-
- private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG = "from " + NotebookEntry.class.getName()
- + " where external_id=? and external_id_type=? and external_signature=? and user_id=?"
- + " order by create_date desc";
- private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL = "from " + NotebookEntry.class.getName()
- + " where external_id=? and external_id_type=? and external_signature=?"
- + " order by user_id asc, create_date desc";
- private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID = "from " + NotebookEntry.class.getName()
- + " where external_id=? and external_id_type=? and user_id=?"
- + " order by create_date desc";
- private static final String SQL_QUERY_FIND_ENTRY_BY_USER_ID = "from " + NotebookEntry.class.getName()
- + " where user_id=?";
- private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE = "from " + NotebookEntry.class.getName()
- + " where user_id=? and external_id_type=?"
- + " order by external_signature desc, create_date desc";
-
-
- public void saveOrUpdate(NotebookEntry notebookEntry) {
- this.getHibernateTemplate().saveOrUpdate(notebookEntry);
- this.getHibernateTemplate().flush();
- }
- public List get(Long id, Integer idType, String signature, Integer userID) {
- return (List)(getHibernateTemplate().find(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG, new Object[]{id, idType, signature, userID}));
- }
-
- public List get(Long id, Integer idType, String signature) {
- return (List)(getHibernateTemplate().find(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL, new Object[]{id, idType, signature}));
- }
-
- public List get(Long id, Integer idType, Integer userID) {
- return (List)(getHibernateTemplate().find(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID, new Object[]{id, idType, userID}));
- }
+ private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG = "from " + NotebookEntry.class.getName()
+ + " where external_id=? and external_id_type=? and external_signature=? and user_id=?"
+ + " order by create_date desc";
+ private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL = "from " + NotebookEntry.class.getName()
+ + " where external_id=? and external_id_type=? and external_signature=?"
+ + " order by user_id asc, create_date desc";
+ private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID = "from " + NotebookEntry.class.getName()
+ + " where external_id=? and external_id_type=? and user_id=?" + " order by create_date desc";
+ private static final String SQL_QUERY_FIND_ENTRY_BY_USER_ID = "from " + NotebookEntry.class.getName()
+ + " where user_id=?";
+ private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE = "from " + NotebookEntry.class.getName()
+ + " where user_id=? and external_id_type=?" + " order by external_signature desc, create_date desc";
- public NotebookEntry get(Long uid) {
- if (uid != null) {
- Object o = getHibernateTemplate().get(NotebookEntry.class, uid);
- return (NotebookEntry)o;
- } else {
- return null;
- }
- }
+ @Override
+ public void saveOrUpdate(NotebookEntry notebookEntry) {
+ this.getHibernateTemplate().saveOrUpdate(notebookEntry);
+ this.getHibernateTemplate().flush();
+ }
- public List get(Integer userID) {
- return (List)(getHibernateTemplate().find(SQL_QUERY_FIND_ENTRY_BY_USER_ID, userID));
- }
+ @Override
+ public List get(Long id, Integer idType, String signature, Integer userID) {
+ return (getHibernateTemplate().find(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG,
+ new Object[] { id, idType, signature, userID }));
+ }
- public List get(Integer userID, Integer idType) {
- return (List)(getHibernateTemplate().find(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE, new Object[]{userID, idType}));
+ @Override
+ public List get(Long id, Integer idType, String signature) {
+ return (getHibernateTemplate().find(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL,
+ new Object[] { id, idType, signature }));
+ }
+
+ @Override
+ public List get(Long id, Integer idType, Integer userID) {
+ return (getHibernateTemplate().find(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID,
+ new Object[] { id, idType, userID }));
+ }
+
+ @Override
+ public NotebookEntry get(Long uid) {
+ if (uid != null) {
+ Object o = getHibernateTemplate().get(NotebookEntry.class, uid);
+ return (NotebookEntry) o;
+ } else {
+ return null;
}
-
- public List get(Integer userID, Long lessonID) {
- // TODO need to write hql query for lessionID and userID
- return null;
- }
-}
+ }
+
+ @Override
+ public List get(Integer userID) {
+ return (getHibernateTemplate().find(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_USER_ID, userID));
+ }
+
+ @Override
+ public List get(Integer userID, Integer idType) {
+ return (getHibernateTemplate().find(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE,
+ new Object[] { userID, idType }));
+ }
+
+ @Override
+ public List get(Integer userID, Long lessonID) {
+ // TODO need to write hql query for lessionID and userID
+ return null;
+ }
+
+ @Override
+ public void delete(NotebookEntry notebookEntry) {
+ this.getHibernateTemplate().delete(notebookEntry);
+ }
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java
===================================================================
diff -u -r11e6de9b3e4fe89c16cc8545ca8f1b99a990d210 -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java (.../CoreNotebookService.java) (revision 11e6de9b3e4fe89c16cc8545ca8f1b99a990d210)
+++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java (.../CoreNotebookService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -25,199 +25,208 @@
package org.lamsfoundation.lams.notebook.service;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.ArrayList;
import java.util.TreeMap;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.dao.IBaseDAO;
import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.notebook.dao.INotebookEntryDAO;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
+import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
import org.lamsfoundation.lams.util.MessageService;
-import org.lamsfoundation.lams.usermanagement.User;
-import org.lamsfoundation.lams.usermanagement.Role;
+public class CoreNotebookService implements ICoreNotebookService {
+ private static Logger log = Logger.getLogger(CoreNotebookService.class);
-public class CoreNotebookService implements ICoreNotebookService, IExtendedCoreNotebookService{
+ private INotebookEntryDAO notebookEntryDAO;
- private static Logger log = Logger.getLogger(CoreNotebookService.class);
-
- private INotebookEntryDAO notebookEntryDAO;
-
private IBaseDAO baseDAO;
- protected IUserManagementService userManagementService;
-
- protected MessageService messageService;
-
- public Long createNotebookEntry(Long id, Integer idType, String signature,
- Integer userID, String title, String entry) {
- User user = (User)getUserManagementService().findById(User.class, userID);
- NotebookEntry notebookEntry = new NotebookEntry(id, idType, signature,
- user, title, entry, new Date());
- saveOrUpdateNotebookEntry(notebookEntry);
- return notebookEntry.getUid();
- }
-
- public TreeMap> getEntryByLesson(Integer userID, Integer idType) {
- TreeMap> entryMap = new TreeMap>();
- List list = getEntry(userID, idType);
-
- for (NotebookEntry entry : list) {
- if(entryMap.containsKey(entry.getExternalID())) {
- String lessonName = (String) entryMap.get(entry.getExternalID()).get(0).getLessonName();
- entry.setLessonName(lessonName);
- entryMap.get(entry.getExternalID()).add(entry);
- } else {
- Lesson lesson = (Lesson) baseDAO.find(Lesson.class, entry.getExternalID());
- List newEntryList = new ArrayList();
-
- entry.setLessonName(lesson.getLessonName());
- newEntryList.add(entry);
-
- entryMap.put(entry.getExternalID(), newEntryList);
- }
- }
-
- return entryMap;
- }
+ protected IUserManagementService userManagementService;
- public List getEntry(Long id, Integer idType, String signature, Integer userID) {
- return notebookEntryDAO.get(id, idType, signature, userID);
- }
-
- /**
- * Add the SQL needed to look up entries for a given tool. Expects a valid string buffer to be supplied.
- * This allows a tool to get the single matching entry (assuming the tool has only created one notebook entry
- * for each learner in each session) for the teacher to view. This is an efficient way to get the
- * entries at the same time as retrieving the tool data, rather than making a separate lookup.
- * Note - if there is more than on row for each tool/session/learner, then the tool will end up with a
- * cross product against the learner record and you will get one row in the learner + notebook result for each
- * notebook entry.
- *
- * May only be used for entries where the external_id_type = CoreNotebookConstants.NOTEBOOK_TOOL
- *
- * The parameters are strings, and the SQL is built up rather than using parameters as either sessionIdString or
- * userIdString may be the name of a field you are joining on. Typically the sessionId will be a number as the tool
- * would be requesting the entries for only one session but the user field will need to be a reference to a column
- * in the user table so that it can get entries for more than one user. If you wanted multiple users across
- * multiple sessions, then the sessionId would need to refer to the column in the user/session table.
- *
- * If you only want an entry for one user, use getEntry(id, idIdType, signature, userID);
- *
- * The return values are the entry for the select clause (will always have a leading but no trailing comma and
- * an alias of notebookEntry) and the sql join clause, which should go with any other join clauses.
- *
- * To make sure it always returns the same number of objects add the select clause like this:
- * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry");
- *
- * Then if there is isn't a notebookEntry to return, it still returns a notebookEntry column, which translates
- * to null. So you can return a collection like List irrespective of whether
- * or not the notebook entries (the Strings) are needed.
- *
- * Finally, as it will be returning the notebook entry as a separate field in select clause, set up the sql -> java
- * object translation using ".addScalar("notebookEntry", Hibernate.STRING)".
- *
- * @param sessionIdString Session identifier, usually the toolSessionId
- * @param toolSignature Tool's string signature (without any quotes) e.g. lantbk11
- * @param userIdString User identifier field string e.g.
- * @return String[] { partial select string, join clause }
- *
- */
- public String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString) {
- StringBuilder buf = new StringBuilder(" LEFT JOIN lams_notebook_entry entry ON entry.external_id=");
- buf.append(sessionIdString);
- buf.append(" AND entry.external_id_type=");
- buf.append(CoreNotebookConstants.NOTEBOOK_TOOL);
- buf.append(" AND entry.external_signature=\"");
- buf.append(toolSignature);
- buf.append("\" AND entry.user_id=");
- buf.append(userIdString);
- return new String[] { ", entry.entry notebookEntry ", buf.toString() };
- }
+ protected MessageService messageService;
- public List getEntry(Long id, Integer idType, String signature) {
- return notebookEntryDAO.get(id, idType, signature);
- }
-
- public List getEntry(Long id, Integer idType, Integer userID) {
- return notebookEntryDAO.get(id, idType, userID);
- }
+ @Override
+ public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String title,
+ String entry) {
+ User user = (User) getUserManagementService().findById(User.class, userID);
+ NotebookEntry notebookEntry = new NotebookEntry(id, idType, signature, user, title, entry, new Date());
+ saveOrUpdateNotebookEntry(notebookEntry);
+ return notebookEntry.getUid();
+ }
- public List getEntry(Integer userID) {
- return notebookEntryDAO.get(userID);
- }
-
- public List getEntry(Integer userID, Integer idType) {
- return notebookEntryDAO.get(userID, idType);
- }
+ @Override
+ public TreeMap> getEntryByLesson(Integer userID, Integer idType) {
+ TreeMap> entryMap = new TreeMap>();
+ List list = getEntry(userID, idType);
- public List getEntry(Integer userID, Long lessonID) {
- return notebookEntryDAO.get(userID, lessonID);
- }
-
- public NotebookEntry getEntry(Long uid) {
- return notebookEntryDAO.get(uid);
- }
+ for (NotebookEntry entry : list) {
+ if (entryMap.containsKey(entry.getExternalID())) {
+ String lessonName = entryMap.get(entry.getExternalID()).get(0).getLessonName();
+ entry.setLessonName(lessonName);
+ entryMap.get(entry.getExternalID()).add(entry);
+ } else {
+ Lesson lesson = (Lesson) baseDAO.find(Lesson.class, entry.getExternalID());
+ List newEntryList = new ArrayList();
- public void updateEntry(Long uid, String title, String entry) {
- NotebookEntry ne = getEntry(uid);
- if (ne != null) {
- ne.setTitle(title);
- ne.setEntry(entry);
- ne.setLastModified(new Date());
- saveOrUpdateNotebookEntry(ne);
- } else {
- log.debug("updateEntry: uid " + uid + "does not exist");
- }
- }
+ entry.setLessonName(lesson.getLessonName());
+ newEntryList.add(entry);
- public void updateEntry(NotebookEntry notebookEntry) {
- notebookEntry.setLastModified(new Date());
- saveOrUpdateNotebookEntry(notebookEntry);
+ entryMap.put(entry.getExternalID(), newEntryList);
+ }
}
- public void saveOrUpdateNotebookEntry(NotebookEntry notebookEntry) {
- notebookEntryDAO.saveOrUpdate(notebookEntry);
- }
+ return entryMap;
+ }
- /* ********** Used by Spring to "inject" the linked objects ************* */
+ @Override
+ public List getEntry(Long id, Integer idType, String signature, Integer userID) {
+ return notebookEntryDAO.get(id, idType, signature, userID);
+ }
- public void setNotebookEntryDAO(INotebookEntryDAO notebookEntryDAO) {
- this.notebookEntryDAO = notebookEntryDAO;
- }
-
- public void setBaseDAO(IBaseDAO baseDAO) {
- this.baseDAO = baseDAO;
- }
-
- /**
+ /**
+ * Add the SQL needed to look up entries for a given tool. Expects a valid string buffer to be supplied. This allows
+ * a tool to get the single matching entry (assuming the tool has only created one notebook entry for each learner
+ * in each session) for the teacher to view. This is an efficient way to get the entries at the same time as
+ * retrieving the tool data, rather than making a separate lookup. Note - if there is more than on row for each
+ * tool/session/learner, then the tool will end up with a cross product against the learner record and you will get
+ * one row in the learner + notebook result for each notebook entry.
*
- * @param IUserManagementService The userManagementService to set.
+ * May only be used for entries where the external_id_type = CoreNotebookConstants.NOTEBOOK_TOOL
+ *
+ * The parameters are strings, and the SQL is built up rather than using parameters as either sessionIdString or
+ * userIdString may be the name of a field you are joining on. Typically the sessionId will be a number as the tool
+ * would be requesting the entries for only one session but the user field will need to be a reference to a column
+ * in the user table so that it can get entries for more than one user. If you wanted multiple users across multiple
+ * sessions, then the sessionId would need to refer to the column in the user/session table.
+ *
+ * If you only want an entry for one user, use getEntry(id, idIdType, signature, userID);
+ *
+ * The return values are the entry for the select clause (will always have a leading but no trailing comma and an
+ * alias of notebookEntry) and the sql join clause, which should go with any other join clauses.
+ *
+ * To make sure it always returns the same number of objects add the select clause like this:
+ * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry");
+ *
+ * Then if there is isn't a notebookEntry to return, it still returns a notebookEntry column, which translates to
+ * null. So you can return a collection like List irrespective of whether or not the
+ * notebook entries (the Strings) are needed.
+ *
+ * Finally, as it will be returning the notebook entry as a separate field in select clause, set up the sql -> java
+ * object translation using ".addScalar("notebookEntry", Hibernate.STRING)".
+ *
+ * @param sessionIdString
+ * Session identifier, usually the toolSessionId
+ * @param toolSignature
+ * Tool's string signature (without any quotes) e.g. lantbk11
+ * @param userIdString
+ * User identifier field string e.g.
+ * @return String[] { partial select string, join clause }
+ *
*/
- public void setUserManagementService(IUserManagementService userManagementService) {
- this.userManagementService = userManagementService;
+ @Override
+ public String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString) {
+ StringBuilder buf = new StringBuilder(" LEFT JOIN lams_notebook_entry entry ON entry.external_id=");
+ buf.append(sessionIdString);
+ buf.append(" AND entry.external_id_type=");
+ buf.append(CoreNotebookConstants.NOTEBOOK_TOOL);
+ buf.append(" AND entry.external_signature=\"");
+ buf.append(toolSignature);
+ buf.append("\" AND entry.user_id=");
+ buf.append(userIdString);
+ return new String[] { ", entry.entry notebookEntry ", buf.toString() };
+ }
+
+ @Override
+ public List getEntry(Long id, Integer idType, String signature) {
+ return notebookEntryDAO.get(id, idType, signature);
+ }
+
+ @Override
+ public List getEntry(Long id, Integer idType, Integer userID) {
+ return notebookEntryDAO.get(id, idType, userID);
+ }
+
+ @Override
+ public List getEntry(Integer userID, Integer idType) {
+ return notebookEntryDAO.get(userID, idType);
+ }
+
+ @Override
+ public NotebookEntry getEntry(Long uid) {
+ return notebookEntryDAO.get(uid);
+ }
+
+ @Override
+ public void updateEntry(Long uid, String title, String entry) {
+ NotebookEntry ne = getEntry(uid);
+ if (ne != null) {
+ ne.setTitle(title);
+ ne.setEntry(entry);
+ ne.setLastModified(new Date());
+ saveOrUpdateNotebookEntry(ne);
+ } else {
+ CoreNotebookService.log.debug("updateEntry: uid " + uid + "does not exist");
}
-
- public IUserManagementService getUserManagementService() {
- return userManagementService;
- }
-
- /**
- * Set i18n MessageService
- */
- public void setMessageService(MessageService messageService) {
- this.messageService = messageService;
- }
-
- /**
- * Get i18n MessageService
- */
- public MessageService getMessageService() {
- return this.messageService;
- }
+ }
+
+ @Override
+ public void updateEntry(NotebookEntry notebookEntry) {
+ notebookEntry.setLastModified(new Date());
+ saveOrUpdateNotebookEntry(notebookEntry);
+ }
+
+ @Override
+ public void saveOrUpdateNotebookEntry(NotebookEntry notebookEntry) {
+ notebookEntryDAO.saveOrUpdate(notebookEntry);
+ }
+
+ @Override
+ public void deleteEntry(NotebookEntry notebookEntry) {
+ notebookEntryDAO.delete(notebookEntry);
+ }
+
+ /* ********** Used by Spring to "inject" the linked objects ************* */
+
+ public void setNotebookEntryDAO(INotebookEntryDAO notebookEntryDAO) {
+ this.notebookEntryDAO = notebookEntryDAO;
+ }
+
+ public void setBaseDAO(IBaseDAO baseDAO) {
+ this.baseDAO = baseDAO;
+ }
+
+ /**
+ *
+ * @param IUserManagementService
+ * The userManagementService to set.
+ */
+ public void setUserManagementService(IUserManagementService userManagementService) {
+ this.userManagementService = userManagementService;
+ }
+
+ @Override
+ public IUserManagementService getUserManagementService() {
+ return userManagementService;
+ }
+
+ /**
+ * Set i18n MessageService
+ */
+ public void setMessageService(MessageService messageService) {
+ this.messageService = messageService;
+ }
+
+ /**
+ * Get i18n MessageService
+ */
+ @Override
+ public MessageService getMessageService() {
+ return this.messageService;
+ }
}
Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java
===================================================================
diff -u -r11e6de9b3e4fe89c16cc8545ca8f1b99a990d210 -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java (.../ICoreNotebookService.java) (revision 11e6de9b3e4fe89c16cc8545ca8f1b99a990d210)
+++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java (.../ICoreNotebookService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -28,35 +28,37 @@
import java.util.List;
import java.util.TreeMap;
-import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
import org.lamsfoundation.lams.util.MessageService;
public interface ICoreNotebookService {
- Long createNotebookEntry(Long id, Integer idType, String signature,
- Integer userID, String title, String entry);
+ Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String title, String entry);
- TreeMap> getEntryByLesson(Integer userID, Integer idType);
-
- List getEntry(Long id, Integer idType, String signature, Integer userID);
-
- String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString);
-
- List getEntry(Long id, Integer idType, String signature);
-
- List getEntry(Long id, Integer idType, Integer userID);
-
- NotebookEntry getEntry(Long uid);
-
- void updateEntry(Long uid, String title, String entry);
-
- void updateEntry(NotebookEntry notebookEntry);
-
- void saveOrUpdateNotebookEntry(NotebookEntry notebookEntry);
-
- IUserManagementService getUserManagementService();
-
- MessageService getMessageService();
-}
+ TreeMap> getEntryByLesson(Integer userID, Integer idType);
+
+ List getEntry(Long id, Integer idType, String signature, Integer userID);
+
+ String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString);
+
+ List getEntry(Long id, Integer idType, String signature);
+
+ List getEntry(Long id, Integer idType, Integer userID);
+
+ List getEntry(Integer userID, Integer idType);
+
+ NotebookEntry getEntry(Long uid);
+
+ void updateEntry(Long uid, String title, String entry);
+
+ void updateEntry(NotebookEntry notebookEntry);
+
+ void saveOrUpdateNotebookEntry(NotebookEntry notebookEntry);
+
+ IUserManagementService getUserManagementService();
+
+ MessageService getMessageService();
+
+ void deleteEntry(NotebookEntry entry);
+}
\ No newline at end of file
Fisheye: Tag 9aad33f52b06632e7a8ed3705a7708338bcc00f8 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/notebook/service/IExtendedCoreNotebookService.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java
===================================================================
diff -u -r40eb54374e84591563d8b6a679ac719dbc85c8f7 -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java (.../ToolContentManager.java) (revision 40eb54374e84591563d8b6a679ac719dbc85c8f7)
+++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java (.../ToolContentManager.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -26,7 +26,6 @@
import java.util.SortedMap;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
/**
@@ -44,11 +43,11 @@
* the default content id.
*
* @param fromContentId
- * the original tool content id.
+ * the original tool content id.
* @param toContentId
- * the destination tool content id.
+ * the destination tool content id.
* @throws ToolException
- * if an error occurs e.g. defaultContent is missing
+ * if an error occurs e.g. defaultContent is missing
*/
public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException;
@@ -67,30 +66,18 @@
public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException;
/**
- * Remove tool's content according specified the content id. It will be needed by lams to modify the learning
- * design.
+ * Remove tool's content according specified the content id.
*
- * If the tool content includes files in the content repository then the
- * files should be removed from the repository.
+ * If the tool content includes files in the content repository then the files should be removed from the
+ * repository. If no matching data exists, the tool should return without throwing an exception.
*
- * If session data for this toolContentId exists and removeSessionData = true, then the tool should delete the
- * session data as well as the content data.
- *
- * If session data for this toolContentId exists and removeSessionData = false, then the tool should throw
- * SessionDataExists.
- *
- * If no matching data exists, the tool should return without throwing an exception.
- *
* @param toolContentId
- * the requested tool content id.
- * @param removeSessionData
- * should it remove any related session data?
+ * the requested tool content id.
* @throws ToolException
- * if any other error occurs
+ * if any other error occurs
*/
- public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException,
- ToolException;
-
+ public void removeToolContent(Long toolContentId) throws ToolException;
+
/**
* Removes content previously added by the given user.
*/
@@ -100,17 +87,17 @@
* Export the XML fragment for the tool's content, along with any files needed for the content.
*
* @throws DataMissingException
- * if no tool content matches the toolSessionId
+ * if no tool content matches the toolSessionId
* @throws ToolException
- * if any other error occurs
+ * if any other error occurs
*/
public void exportToolContent(Long toolContentId, String toPath) throws DataMissingException, ToolException;
/**
* Import the XML fragment for the tool's content, along with any files needed for the content.
*
* @throws ToolException
- * if any other error occurs
+ * if any other error occurs
*/
public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion,
String toVersion) throws ToolException;
@@ -123,18 +110,18 @@
*
* @return SortedMap of ToolOutputDefinitions with the key being the name of each definition.
*
- * Added in LAMS 2.1
+ * Added in LAMS 2.1
*/
public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType)
throws ToolException;
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType);
-
+
/**
* Finds title entered in the tool content.
*/
public String getToolContentTitle(Long toolContentId);
-
+
/**
* Is an activity being edited by Monitor?
*/
Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java
===================================================================
diff -u -ra207bdecc16a704428826dbf402a97de2e35458b -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision a207bdecc16a704428826dbf402a97de2e35458b)
+++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -92,7 +92,7 @@
/**
* @param toolSessionDAO
- * The toolSessionDAO to set.
+ * The toolSessionDAO to set.
*/
public void setToolSessionDAO(IToolSessionDAO toolSessionDAO) {
this.toolSessionDAO = toolSessionDAO;
@@ -108,16 +108,16 @@
/**
* @param contentIDGenerator
- * The contentIDGenerator to set.
+ * The contentIDGenerator to set.
*/
public void setContentIDGenerator(ToolContentIDGenerator contentIDGenerator) {
this.contentIDGenerator = contentIDGenerator;
}
-
+
public void setToolContentDAO(IToolContentDAO toolContentDAO) {
this.toolContentDAO = toolContentDAO;
}
-
+
/**
* Set i18n MessageService
*/
@@ -177,8 +177,8 @@
try {
ToolSessionManager sessionManager = (ToolSessionManager) findToolService(activity.getTool());
- sessionManager.createToolSession(toolSession.getToolSessionId(), toolSession.getToolSessionName(), activity
- .getToolContentId());
+ sessionManager.createToolSession(toolSession.getToolSessionId(), toolSession.getToolSessionName(),
+ activity.getToolContentId());
} catch (NoSuchBeanDefinitionException e) {
String message = "A tool which is defined in the database appears to missing from the classpath. Unable to create tool session. ToolActivity "
+ activity;
@@ -188,8 +188,8 @@
}
@Override
- public Long notifyToolToCopyContent(ToolActivity toolActivity, String customCSV) throws DataMissingException,
- ToolException {
+ public Long notifyToolToCopyContent(ToolActivity toolActivity, String customCSV)
+ throws DataMissingException, ToolException {
Long toolcontentID = toolActivity.getToolContentId();
try {
ToolContentManager contentManager = (ToolContentManager) findToolService(toolActivity.getTool());
@@ -215,8 +215,8 @@
}
@Override
- public Long notifyToolToCopyContent(Long toolContentId, String customCSV) throws DataMissingException,
- ToolException {
+ public Long notifyToolToCopyContent(Long toolContentId, String customCSV)
+ throws DataMissingException, ToolException {
ToolContent toolContent = (ToolContent) toolContentDAO.find(ToolContent.class, toolContentId);
if (toolContent == null) {
String error = "The toolContentID " + toolContentId
@@ -255,15 +255,15 @@
public void notifyToolToDeleteContent(ToolActivity toolActivity) throws ToolException {
try {
ToolContentManager contentManager = (ToolContentManager) findToolService(toolActivity.getTool());
- contentManager.removeToolContent(toolActivity.getToolContentId(), true);
+ contentManager.removeToolContent(toolActivity.getToolContentId());
} catch (NoSuchBeanDefinitionException e) {
String message = "A tool which is defined in the database appears to missing from the classpath. Unable to delete the tool content. ToolActivity "
+ toolActivity;
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
}
}
-
+
@Override
public void notifyToolToDeleteLearnerContent(ToolActivity toolActivity, Integer userId) throws ToolException {
try {
@@ -305,8 +305,7 @@
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
} catch (java.lang.AbstractMethodError e) {
- String message = "Tool "
- + tool.getToolDisplayName()
+ String message = "Tool " + tool.getToolDisplayName()
+ " doesn't support the getToolOutputDefinitions(toolContentId) method so no output definitions can be accessed.";
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
@@ -369,8 +368,7 @@
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
} catch (java.lang.AbstractMethodError e) {
- String message = "Tool "
- + tool.getToolDisplayName()
+ String message = "Tool " + tool.getToolDisplayName()
+ " doesn't support the getSupportedToolOutputDefinitionClasses(definitionType) method so no output definitions can be accessed.";
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
@@ -414,8 +412,7 @@
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
} catch (java.lang.AbstractMethodError e) {
- String message = "Tool "
- + tool.getToolDisplayName()
+ String message = "Tool " + tool.getToolDisplayName()
+ " doesn't support the getToolOutput(name, toolSessionId, learnerId) method so no output definitions can be accessed.";
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
@@ -447,8 +444,7 @@
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
} catch (java.lang.AbstractMethodError e) {
- String message = "Tool "
- + tool.getToolDisplayName()
+ String message = "Tool " + tool.getToolDisplayName()
+ " doesn't support the forceCompleteUser(ToolSession toolSession, User learner) method so can't force complete learner.";
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
@@ -489,14 +485,13 @@
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
} catch (java.lang.AbstractMethodError e) {
- String message = "Tool "
- + tool.getToolDisplayName()
+ String message = "Tool " + tool.getToolDisplayName()
+ " doesn't support the getToolOutput(name, toolSessionId, learnerId) method so no output definitions can be accessed.";
LamsCoreToolService.log.error(message, e);
throw new ToolException(message, e);
}
}
-
+
@Override
public Long getActivityMaxPossibleMark(ToolActivity activity) {
SortedMap map = getOutputDefinitionsFromTool(activity.getToolContentId(),
@@ -552,8 +547,8 @@
}
// call the tool to remove the session details
- ToolSessionManager sessionManager = (ToolSessionManager) findToolService(toolSession.getToolActivity()
- .getTool());
+ ToolSessionManager sessionManager = (ToolSessionManager) findToolService(
+ toolSession.getToolActivity().getTool());
try {
sessionManager.removeToolSession(toolSession.getToolSessionId());
@@ -612,8 +607,8 @@
} else if (activity.isSystemToolActivity()) {
SystemTool sysTool = systemToolDAO.getSystemToolByActivityTypeId(activity.getActivityTypeId());
if (sysTool != null) {
- return setupURLWithActivityLessonUserID(activity, lessonID, learner.getUserId(), sysTool
- .getLearnerProgressUrl());
+ return setupURLWithActivityLessonUserID(activity, lessonID, learner.getUserId(),
+ sysTool.getLearnerProgressUrl());
}
}
return null;
@@ -651,13 +646,13 @@
@Override
public String getToolAuthorURL(Long lessonID, ToolActivity activity, ToolAccessMode mode) {
String url = activity.getTool().getAuthorUrl();
- url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_TOOL_CONTENT_ID, activity.getToolContentId()
- .toString());
+ url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_TOOL_CONTENT_ID,
+ activity.getToolContentId().toString());
// should have used LessonService, but reusing existing tools is just easier
Lesson lesson = (Lesson) toolContentDAO.find(Lesson.class, lessonID);
- url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_CONTENT_FOLDER_ID, lesson.getLearningDesign()
- .getContentFolderID());
-
+ url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_CONTENT_FOLDER_ID,
+ lesson.getLearningDesign().getContentFolderID());
+
url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_MODE, mode.toString());
return url;
}
@@ -682,11 +677,12 @@
throw new LamsToolServiceException(error);
}
- return WebUtil.appendParameterToURL(toolURL, AttributeNames.PARAM_TOOL_SESSION_ID, toolSession
- .getToolSessionId().toString());
+ return WebUtil.appendParameterToURL(toolURL, AttributeNames.PARAM_TOOL_SESSION_ID,
+ toolSession.getToolSessionId().toString());
}
- private String setupURLWithActivityLessonUserID(Activity activity, Long lessonID, Integer userID, String learnerURL) {
+ private String setupURLWithActivityLessonUserID(Activity activity, Long lessonID, Integer userID,
+ String learnerURL) {
String url = setupURLWithActivityLessonID(activity, lessonID, learnerURL);
if (url != null && userID != null) {
url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_USER_ID, userID.toString());
@@ -697,8 +693,8 @@
private String setupURLWithActivityLessonID(Activity activity, Long lessonID, String learnerURL) {
String url = learnerURL;
if (url != null && activity != null) {
- url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_ACTIVITY_ID, activity.getActivityId()
- .toString());
+ url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_ACTIVITY_ID,
+ activity.getActivityId().toString());
}
if (url != null && lessonID != null) {
url = WebUtil.appendParameterToURL(url, AttributeNames.PARAM_LESSON_ID, lessonID.toString());
@@ -708,8 +704,8 @@
@Override
public String setupToolURLWithToolContent(ToolActivity activity, String toolURL) {
- return WebUtil.appendParameterToURL(toolURL, AttributeNames.PARAM_TOOL_CONTENT_ID, activity.getToolContentId()
- .toString());
+ return WebUtil.appendParameterToURL(toolURL, AttributeNames.PARAM_TOOL_CONTENT_ID,
+ activity.getToolContentId().toString());
}
@Override
Index: lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java
===================================================================
diff -u -rf5fca2d435f9f8765a3ddb1c2ce162a36ba09a9e -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java (.../TransactionRetryInterceptor.java) (revision f5fca2d435f9f8765a3ddb1c2ce162a36ba09a9e)
+++ lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java (.../TransactionRetryInterceptor.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -66,9 +66,13 @@
}
} catch (DataIntegrityViolationException e) {
exception = e;
+ if (exception.getCause() instanceof ConstraintViolationException) {
+ TransactionRetryInterceptor.log.error("Schema error", exception);
+ }
processException(e, invocation, attempt);
} catch (ConstraintViolationException e) {
exception = e;
+ TransactionRetryInterceptor.log.error("Schema error", exception);
processException(e, invocation, attempt);
} catch (CannotAcquireLockException e) {
exception = e;
@@ -107,6 +111,6 @@
}
public void setSessionFactory(SessionFactory sessionFactory) {
- this.sessionFactory = sessionFactory;
+ this.sessionFactory = sessionFactory;
}
}
\ No newline at end of file
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/NotebookAction.java
===================================================================
diff -u -rd578eb0e78e1723052d35e825b00b5c735fe2f7a -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/NotebookAction.java (.../NotebookAction.java) (revision d578eb0e78e1723052d35e825b00b5c735fe2f7a)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/NotebookAction.java (.../NotebookAction.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -21,291 +21,260 @@
* ****************************************************************
*/
-/* $$Id$$ */
+/* $$Id$$ */
package org.lamsfoundation.lams.learning.web.action;
+import java.io.IOException;
import java.util.List;
import java.util.TreeMap;
-import java.lang.Integer;
-import java.io.IOException;
-import java.io.PrintWriter;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.DynaActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-
-import org.lamsfoundation.lams.web.action.LamsDispatchAction;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-
-import org.lamsfoundation.lams.learning.web.util.ActivityMapping;
-import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
-import org.lamsfoundation.lams.notebook.service.ICoreNotebookService;
-import org.lamsfoundation.lams.notebook.service.IExtendedCoreNotebookService;
-import org.lamsfoundation.lams.notebook.model.NotebookEntry;
-
+import org.apache.struts.action.DynaActionForm;
import org.lamsfoundation.lams.learning.service.ICoreLearnerService;
import org.lamsfoundation.lams.learning.service.LearnerServiceProxy;
-
-import org.lamsfoundation.lams.usermanagement.User;
-import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException;
-import org.lamsfoundation.lams.web.util.AttributeNames;
import org.lamsfoundation.lams.learning.web.util.LearningWebUtil;
import org.lamsfoundation.lams.lesson.Lesson;
+import org.lamsfoundation.lams.notebook.model.NotebookEntry;
+import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
+import org.lamsfoundation.lams.notebook.service.ICoreNotebookService;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException;
import org.lamsfoundation.lams.util.WebUtil;
-
import org.lamsfoundation.lams.util.audit.IAuditService;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
-
-/**
+/**
*
* @author M Seaton
*
- * ----------------XDoclet Tags--------------------
+ * ----------------XDoclet Tags--------------------
*
- * @struts:action name="NotebookForm" path="/notebook"
- * parameter="method"
- * validate="false"
- *
+ * @struts:action name="NotebookForm" path="/notebook" parameter="method" validate="false"
+ *
* @struts.action-forward name = "viewAll" path = ".notebookViewAll"
* @struts.action-forward name= "viewSingle" path = ".notebookViewSingle"
* @struts.action-forward name= "viewJournals" path = ".notebookViewJournals"
* @struts.action-forward name = "addNew" path = ".notebookAddNew"
- * @struts.action-forward name = "saveSuccess" path = ".notebookSaveSuccess"
- * ----------------XDoclet Tags--------------------
+ * @struts.action-forward name = "saveSuccess" path = ".notebookSaveSuccess" ----------------XDoclet
+ * Tags--------------------
*
*/
-public class NotebookAction extends LamsDispatchAction
-{
- //---------------------------------------------------------------------
+public class NotebookAction extends LamsDispatchAction {
+ // ---------------------------------------------------------------------
// Instance variables
- //---------------------------------------------------------------------
- private static Logger log = Logger.getLogger(NotebookAction.class);
+ // ---------------------------------------------------------------------
+ private static Logger log = Logger.getLogger(NotebookAction.class);
- private static IAuditService auditService;
-
- private static final String VIEW_ALL = "viewAll";
- private static final String VIEW_SINGLE = "viewSingle";
- private static final String VIEW_JOURNALS = "viewJournals";
- private static final String ADD_NEW = "addNew";
- private static final String SAVE_SUCCESS = "saveSuccess";
+ private static IAuditService auditService;
- public ICoreNotebookService getNotebookService(){
- WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext());
- return (IExtendedCoreNotebookService) webContext.getBean(CoreNotebookConstants.NOTEBOOK_SERVICE_BEAN_NAME);
+ private static final String VIEW_ALL = "viewAll";
+ private static final String VIEW_SINGLE = "viewSingle";
+ private static final String VIEW_JOURNALS = "viewJournals";
+ private static final String ADD_NEW = "addNew";
+ private static final String SAVE_SUCCESS = "saveSuccess";
+
+ public ICoreNotebookService getNotebookService() {
+ WebApplicationContext webContext = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(this.getServlet().getServletContext());
+ return (ICoreNotebookService) webContext.getBean(CoreNotebookConstants.NOTEBOOK_SERVICE_BEAN_NAME);
+ }
+
+ /**
+ * View all notebook entries
+ */
+ public ActionForward viewAll(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+
+ // initialize service object
+ ICoreNotebookService notebookService = getNotebookService();
+
+ DynaActionForm notebookForm = (DynaActionForm) actionForm;
+
+ // getting requested object according to coming parameters
+ Integer learnerID = LearningWebUtil.getUserId();
+
+ // lessonID
+ Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
+
+ // get all notebook entries for the learner
+
+ TreeMap> entries = notebookService.getEntryByLesson(learnerID,
+ CoreNotebookConstants.SCRATCH_PAD);
+
+ request.getSession().setAttribute("entries", entries.values());
+ request.setAttribute("lessonID", lessonID);
+
+ return mapping.findForward(NotebookAction.VIEW_ALL);
+
+ }
+
+ /**
+ * View all journals entries from a lesson call
+ */
+ public ActionForward viewAllJournals(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+
+ // List of Journal entries
+ List journals = null;
+
+ DynaActionForm notebookForm = (DynaActionForm) actionForm;
+
+ // lesson service
+ ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext());
+
+ // getting requested object according to coming parameters
+ Integer userID = LearningWebUtil.getUserId();
+
+ // lessonID
+ Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
+ Lesson lesson = learnerService.getLesson(lessonID);
+
+ // check user has permission
+ User user = (User) LearnerServiceProxy.getUserManagementService(getServlet().getServletContext())
+ .findById(User.class, userID);
+
+ if ((lesson.getUser() != null) && lesson.getUser().getUserId().equals(userID)) {
+ journals = getJournals(lesson.getLessonId());
}
-
- /**
- * View all notebook entries
- */
- public ActionForward viewAll(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
- // initialize service object
- IExtendedCoreNotebookService notebookService = (IExtendedCoreNotebookService) getNotebookService();
-
- DynaActionForm notebookForm = (DynaActionForm)actionForm;
-
- // getting requested object according to coming parameters
- Integer learnerID = LearningWebUtil.getUserId();
-
- // lessonID
- Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
-
- // get all notebook entries for the learner
-
-
- TreeMap> entries = notebookService.getEntryByLesson(learnerID, CoreNotebookConstants.SCRATCH_PAD);
-
- request.getSession().setAttribute("entries", entries.values());
- request.setAttribute("lessonID", lessonID);
-
- return mapping.findForward(VIEW_ALL);
-
+ if ((lesson == null) || (lesson.getLessonClass() == null) || !lesson.getLessonClass().isStaffMember(user)) {
+ throw new UserAccessDeniedException(
+ "User " + userID + " may not retrieve journal entries for lesson " + lesson.getLessonId());
+ } else if (journals == null) {
+ journals = getJournals(lesson.getLessonId());
}
-
-
- /**
- * View all journals entries from a lesson call
- */
- public ActionForward viewAllJournals(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // List of Journal entries
- List journals = null;
-
- DynaActionForm notebookForm = (DynaActionForm)actionForm;
-
- // lesson service
- ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext());
- // getting requested object according to coming parameters
- Integer userID = LearningWebUtil.getUserId();
-
- // lessonID
- Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
- Lesson lesson = learnerService.getLesson(lessonID);
-
- // check user has permission
- User user = (User)LearnerServiceProxy.getUserManagementService(getServlet().getServletContext()).findById(User.class,userID);
-
- if ( lesson.getUser() != null && lesson.getUser().getUserId().equals(userID) ) {
- journals = getJournals(lesson.getLessonId());
- }
-
- if ( lesson == null || lesson.getLessonClass()==null || !lesson.getLessonClass().isStaffMember(user) ) {
- throw new UserAccessDeniedException("User "+userID+" may not retrieve journal entries for lesson "+lesson.getLessonId());
- } else if(journals == null){
- journals = getJournals(lesson.getLessonId());
- }
-
- request.getSession().setAttribute("journals", journals);
- request.setAttribute("lessonID", lessonID);
-
- return mapping.findForward(VIEW_JOURNALS);
+ request.getSession().setAttribute("journals", journals);
+ request.setAttribute("lessonID", lessonID);
+
+ return mapping.findForward(NotebookAction.VIEW_JOURNALS);
+ }
+
+ /**
+ *
+ * @param lessonID
+ * Lesson to get the journals from.
+ * @return List of Journal entries
+ */
+ private List getJournals(Long lessonID) {
+ // initialize service object
+ ICoreNotebookService notebookService = getNotebookService();
+
+ if (lessonID == null) {
+ return null;
}
-
- /**
- *
- * @param lessonID Lesson to get the journals from.
- * @return List of Journal entries
- */
- private List getJournals(Long lessonID) {
- // initialize service object
- ICoreNotebookService notebookService = (ICoreNotebookService) getNotebookService();
-
- if(lessonID == null)
- return null;
-
- return notebookService.getEntry(lessonID, CoreNotebookConstants.SCRATCH_PAD, CoreNotebookConstants.JOURNAL_SIG);
-
+
+ return notebookService.getEntry(lessonID, CoreNotebookConstants.SCRATCH_PAD, CoreNotebookConstants.JOURNAL_SIG);
+
+ }
+
+ /**
+ * View single notebook entry
+ */
+ public ActionForward viewEntry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+
+ // initialize service object
+ ICoreNotebookService notebookService = getNotebookService();
+
+ DynaActionForm notebookForm = (DynaActionForm) actionForm;
+ Long uid = (Long) notebookForm.get("uid");
+ String mode = WebUtil.readStrParam(request, "mode", true);
+
+ NotebookEntry entry = notebookService.getEntry(uid);
+
+ if (mode != null) {
+ request.setAttribute("mode", mode);
}
-
- /**
- * View single notebook entry
- */
- public ActionForward viewEntry(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
- // initialize service object
- IExtendedCoreNotebookService notebookService = (IExtendedCoreNotebookService) getNotebookService();
-
- DynaActionForm notebookForm = (DynaActionForm)actionForm;
- Long uid = (Long) notebookForm.get("uid");
- String mode = WebUtil.readStrParam(request, "mode", true);
-
-
- NotebookEntry entry = notebookService.getEntry(uid);
-
- if(mode != null)
- request.setAttribute("mode", mode);
-
- if(entry != null)
- request.setAttribute("entry", entry);
-
- return mapping.findForward(VIEW_SINGLE);
+ if (entry != null) {
+ request.setAttribute("entry", entry);
}
-
-
-
- /**
- *
- */
- public ActionForward processNewEntry(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // initialize service object
- ICoreNotebookService notebookService = (ICoreNotebookService) getNotebookService();
-
- DynaActionForm notebookForm = (DynaActionForm)actionForm;
- Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
- String title = (String) notebookForm.get("title");
- String entry = (String) notebookForm.get("entry");
- String signature = (String) notebookForm.get("signature");
- Integer userID = LearningWebUtil.getUserId();
-
- notebookService.createNotebookEntry(id, CoreNotebookConstants.SCRATCH_PAD, signature,
- userID, title, entry);
-
- boolean skipViewAll = WebUtil.readBooleanParam(request, "skipViewAll", false);
- return skipViewAll ? null : viewAll(mapping, actionForm, request, response);
+
+ return mapping.findForward(NotebookAction.VIEW_SINGLE);
+ }
+
+ /**
+ *
+ */
+ public ActionForward processNewEntry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+
+ // initialize service object
+ ICoreNotebookService notebookService = getNotebookService();
+
+ DynaActionForm notebookForm = (DynaActionForm) actionForm;
+ Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
+ String title = (String) notebookForm.get("title");
+ String entry = (String) notebookForm.get("entry");
+ String signature = (String) notebookForm.get("signature");
+ Integer userID = LearningWebUtil.getUserId();
+
+ notebookService.createNotebookEntry(id, CoreNotebookConstants.SCRATCH_PAD, signature, userID, title, entry);
+
+ boolean skipViewAll = WebUtil.readBooleanParam(request, "skipViewAll", false);
+ return skipViewAll ? null : viewAll(mapping, actionForm, request, response);
+ }
+
+ /**
+ *
+ */
+ public ActionForward updateEntry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+
+ // initialize service object
+ ICoreNotebookService notebookService = getNotebookService();
+
+ // get form data
+ DynaActionForm notebookForm = (DynaActionForm) actionForm;
+ Long uid = (Long) notebookForm.get("uid");
+ Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
+ String title = (String) notebookForm.get("title");
+ String entry = (String) notebookForm.get("entry");
+ String signature = (String) notebookForm.get("signature");
+
+ // get existing entry to edit
+ NotebookEntry entryObj = notebookService.getEntry(uid);
+
+ // check entry is being edited by it's owner
+ Integer userID = LearningWebUtil.getUserId();
+ if (userID != entryObj.getUser().getUserId()) {
+ // throw exception
}
-
- /**
- *
- */
- public ActionForward updateEntry(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // initialize service object
- ICoreNotebookService notebookService = (ICoreNotebookService) getNotebookService();
-
- // get form data
- DynaActionForm notebookForm = (DynaActionForm)actionForm;
- Long uid = (Long) notebookForm.get("uid");
- Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
- String title = (String) notebookForm.get("title");
- String entry = (String) notebookForm.get("entry");
- String signature = (String) notebookForm.get("signature");
-
-
- // get existing entry to edit
- NotebookEntry entryObj = notebookService.getEntry(uid);
-
- // check entry is being edited by it's owner
- Integer userID = LearningWebUtil.getUserId();
- if(userID != entryObj.getUser().getUserId()) {
- // throw exception
- }
-
- //update entry
- entryObj.setTitle(title);
- entryObj.setEntry(entry);
- entryObj.setExternalSignature(signature);
-
- notebookService.updateEntry(entryObj);
-
- return viewAll(mapping, actionForm, request, response);
-
+
+ // update entry
+ entryObj.setTitle(title);
+ entryObj.setEntry(entry);
+ entryObj.setExternalSignature(signature);
+
+ notebookService.updateEntry(entryObj);
+
+ return viewAll(mapping, actionForm, request, response);
+
+ }
+
+ /**
+ * Get AuditService bean.
+ *
+ * @return
+ */
+ private IAuditService getAuditService() {
+ if (NotebookAction.auditService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ NotebookAction.auditService = (IAuditService) ctx.getBean("auditService");
}
-
- /**
- * Get AuditService bean.
- * @return
- */
- private IAuditService getAuditService(){
- if(auditService==null){
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext());
- auditService = (IAuditService) ctx.getBean("auditService");
- }
- return auditService;
- }
-
+ return NotebookAction.auditService;
+ }
+
}
\ No newline at end of file
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java
===================================================================
diff -u -r1b3256ab2070e6b8b91c1c5df04b5ad0e52635a2 -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 1b3256ab2070e6b8b91c1c5df04b5ad0e52635a2)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -342,9 +342,14 @@
* @param userId
* checks that the user is a staff member for this lesson
*/
- void removeLesson(long lessonId, Integer userId) throws UserAccessDeniedException;
+ void removeLesson(long lessonId, Integer userId) throws SecurityException;
/**
+ * Removes the lesson and all referenced resources (learning design, tool content etc.) from the database.
+ */
+ void removeLessonPermanently(long lessonId, Integer userId) throws SecurityException;
+
+ /**
* Set the gate to open to let all the learners through. This learning service is triggerred by the system
* scheduler. Will return true GateActivity (or subclass) object, rather than a hibernate proxy. This is needed so
* that the class can be returned to the web layer for proper handling.
@@ -669,13 +674,13 @@
* Activity id of the branchingActivity
*/
SortedSet getGroupsNotAssignedToBranch(Long branchingActivityID) throws LessonServiceException;
-
+
/**
* Get all the users records where the user has attempted the given activity, but has not completed it yet. Uses the
* progress records to determine the users.
*/
List getLearnersAttemptedActivity(Activity activity);
-
+
/**
* give the users in all tool sessions for an activity (if it is a tool activity) or it will give all the users who
* have attempted an activity that doesn't have any tool sessions, i.e. system activities such as branching.
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java
===================================================================
diff -u -r2c9f5c4fd2a8e8e664d53cf362b85eaa8dc387ed -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 2c9f5c4fd2a8e8e664d53cf362b85eaa8dc387ed)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -53,6 +53,8 @@
import org.lamsfoundation.lams.learning.service.ICoreLearnerService;
import org.lamsfoundation.lams.learning.web.bean.GateActivityDTO;
import org.lamsfoundation.lams.learningdesign.Activity;
+import org.lamsfoundation.lams.learningdesign.BranchActivityEntry;
+import org.lamsfoundation.lams.learningdesign.BranchCondition;
import org.lamsfoundation.lams.learningdesign.BranchingActivity;
import org.lamsfoundation.lams.learningdesign.ChosenGrouping;
import org.lamsfoundation.lams.learningdesign.ComplexActivity;
@@ -83,7 +85,10 @@
import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.monitoring.MonitoringConstants;
import org.lamsfoundation.lams.monitoring.dto.ContributeActivityDTO;
+import org.lamsfoundation.lams.notebook.model.NotebookEntry;
+import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.security.ISecurityService;
+import org.lamsfoundation.lams.tool.ToolContent;
import org.lamsfoundation.lams.tool.ToolSession;
import org.lamsfoundation.lams.tool.exception.LamsToolServiceException;
import org.lamsfoundation.lams.tool.service.ILamsCoreToolService;
@@ -932,7 +937,68 @@
setLessonState(requestedLesson, Lesson.REMOVED_STATE);
}
+ @SuppressWarnings("unchecked")
@Override
+ public void removeLessonPermanently(long lessonId, Integer userId) {
+ securityService.isLessonMonitor(lessonId, userId, "remove lesson permanently", true);
+
+ Lesson lesson = lessonDAO.getLesson(lessonId);
+ LearningDesign learningDesign = lesson.getLearningDesign();
+
+ // remove lesson resources
+ lessonDAO.deleteByProperty(LogEvent.class, "lessonId", lessonId);
+ lessonDAO.deleteByProperty(ToolSession.class, "lesson.lessonId", lessonId);
+ Map notebookProperties = new TreeMap();
+ notebookProperties.put("externalID", lessonId);
+ notebookProperties.put("externalSignature", CoreNotebookConstants.SCRATCH_PAD_SIG);
+ lessonDAO.deleteByProperties(NotebookEntry.class, notebookProperties);
+ lessonDAO.deleteLesson(lesson);
+
+ // remove each Tool activity content
+ // It has to be done before removing BranchEntries as fetching Tool content
+ // in its own transaction would re-add connected BranchEntries (Hibernate error)
+ Set systemActivities = new HashSet();
+ for (Activity activity : (Set) learningDesign.getActivities()) {
+ // get the real object, not the proxy
+ activity = activityDAO.getActivityByActivityId(activity.getActivityId());
+ if (activity.isToolActivity()) {
+ ToolActivity toolActivity = (ToolActivity) activity;
+ // delete content of each tool
+ lamsCoreToolService.notifyToolToDeleteContent(toolActivity);
+ // possible nonthreadsafe access to session!!!
+ lessonDAO.flush();
+ Long toolContentId = toolActivity.getToolContentId();
+ lessonDAO.deleteById(ToolContent.class, toolContentId);
+ } else {
+ systemActivities.add(activity);
+ }
+ }
+
+ // remove branching and grouping resources
+ for (Activity activity : systemActivities) {
+ if (activity.isBranchingActivity()) {
+ BranchingActivity branchingActivity = (BranchingActivity) activity;
+ Grouping grouping = branchingActivity.getGrouping();
+ groupingDAO.delete(grouping);
+
+ for (BranchActivityEntry entry : branchingActivity.getBranchActivityEntries()) {
+ BranchCondition condition = entry.getCondition();
+ if (condition != null) {
+ lessonDAO.deleteById(BranchCondition.class, condition.getConditionId());
+ }
+ }
+ } else if (activity.isGroupingActivity()) {
+ GroupingActivity groupingActivity = (GroupingActivity) activity;
+ Grouping grouping = groupingActivity.getCreateGrouping();
+ groupingDAO.delete(grouping);
+ }
+ }
+
+ // finally remove the learning design
+ lessonDAO.delete(learningDesign);
+ }
+
+ @Override
public Boolean setLearnerPortfolioAvailable(long lessonId, Integer userId, Boolean isLearnerExportAvailable) {
securityService.isLessonMonitor(lessonId, userId, "set learner portfolio available", true);
@@ -2350,10 +2416,10 @@
}
@Override
- public List getLearnersAttemptedActivity(Activity activity){
+ public List getLearnersAttemptedActivity(Activity activity) {
return learnerProgressDAO.getLearnersAttemptedActivity(activity);
}
-
+
@Override
public List getLearnersAttemptedOrCompletedActivity(Activity activity) throws LessonServiceException {
return lessonService.getLearnersAttemptedOrCompletedActivity(activity);
@@ -2370,7 +2436,8 @@
}
@Override
- public List getLearnersByActivities(Long[] activityIds, Integer limit, Integer offset, boolean orderAscending) {
+ public List getLearnersByActivities(Long[] activityIds, Integer limit, Integer offset,
+ boolean orderAscending) {
return learnerProgressDAO.getLearnersByActivities(activityIds, limit, offset, orderAscending);
}
@@ -2414,12 +2481,11 @@
@Override
public int cloneLessons(String[] lessonIds, Boolean addAllStaff, Boolean addAllLearners, String[] staffIds,
String[] learnerIds, Organisation group) throws MonitoringServiceException {
-
int result = 0;
- HttpSession ss = SessionManager.getSession();
- if (ss != null) {
- UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if (userDto != null) {
+ HttpSession ss = SessionManager.getSession();
+ if (ss != null) {
+ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ if (userDto != null) {
Integer creatorId = userDto.getUserID();
for (String lessonIdStr : lessonIds) {
@@ -2446,44 +2512,44 @@
Lesson lesson = lessonService.getLesson(lessonId);
if (lesson != null) {
- if ((!addAllStaff && (staffIds.length > 0)) || addAllStaff) {
- // create staff LessonClass
- String staffGroupName = group.getName() + " Staff";
- List staffUsers = createStaffGroup(group.getOrganisationId(), addAllStaff, staffIds);
+ if ((!addAllStaff && (staffIds.length > 0)) || addAllStaff) {
+ // create staff LessonClass
+ String staffGroupName = group.getName() + " Staff";
+ List staffUsers = createStaffGroup(group.getOrganisationId(), addAllStaff, staffIds);
- if ((!addAllLearners && (learnerIds.length > 0)) || addAllLearners) {
- // create learner LessonClass for lesson
- String learnerGroupName = group.getName() + " Learners";
+ if ((!addAllLearners && (learnerIds.length > 0)) || addAllLearners) {
+ // create learner LessonClass for lesson
+ String learnerGroupName = group.getName() + " Learners";
List learnerUsers = createLearnerGroup(group.getOrganisationId(), addAllLearners, learnerIds);
- // init Lesson with user as creator
+ // init Lesson with user as creator
newLesson = this.initializeLesson(lesson.getLessonName(), lesson.getLessonDescription(), lesson
.getLearningDesign().getLearningDesignId(), group.getOrganisationId(), creatorId, null,
lesson.isEnableLessonIntro(), lesson.isDisplayDesignImage(), lesson
.getLearnerExportAvailable(), lesson.getLearnerPresenceAvailable(), lesson
.getLearnerImAvailable(), lesson.getLiveEditEnabled(), lesson
.getEnableLessonNotifications(), lesson.getLearnerRestart(), null, null);
- // save LessonClasses
+ // save LessonClasses
newLesson = this.createLessonClassForLesson(newLesson.getLessonId(), group, learnerGroupName,
learnerUsers, staffGroupName, staffUsers, creatorId);
- // start Lessons
- // TODO user-specified creator; must be someone in staff group
- this.startLesson(newLesson.getLessonId(), staffUsers.get(0).getUserId());
+ // start Lessons
+ // TODO user-specified creator; must be someone in staff group
+ this.startLesson(newLesson.getLessonId(), staffUsers.get(0).getUserId());
- } else {
+ } else {
throw new MonitoringServiceException("No learners specified, can't create any Lessons.");
- }
- } else {
- throw new MonitoringServiceException("No staff specified, can't create any Lessons.");
- }
- } else {
+ }
+ } else {
+ throw new MonitoringServiceException("No staff specified, can't create any Lessons.");
+ }
+ } else {
throw new MonitoringServiceException("Couldn't find Lesson based on id=" + lessonId);
- }
+ }
return newLesson.getLessonId();
- }
+ }
/*
* Used in cloneLessons.
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java
===================================================================
diff -u -r3dcdc86bb42ea2451ca470c75a959eff48d0c931 -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 3dcdc86bb42ea2451ca470c75a959eff48d0c931)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -579,15 +579,22 @@
*/
public ActionForward removeLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, JSONException, ServletException {
-
long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
- JSONObject jsonObject = new JSONObject();
+ Integer userId = getUserId();
+ boolean permanently = WebUtil.readBooleanParam(request, "permanently", false);
+ if (permanently) {
+ getMonitoringService().removeLessonPermanently(lessonId, userId);
+ response.setContentType("text/plain;charset=utf-8");
+ response.getWriter().print("OK");
+ return null;
+ }
+
+ JSONObject jsonObject = new JSONObject();
try {
// if this method throws an Exception, there will be no removeLesson=true in the JSON reply
- getMonitoringService().removeLesson(lessonId, getUserId());
+ getMonitoringService().removeLesson(lessonId, userId);
jsonObject.put("removeLesson", true);
-
} catch (Exception e) {
String[] msg = new String[1];
msg[0] = e.getMessage();
Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java
===================================================================
diff -u -rdb4bd53f341896f8d1087dda549c89b3ab785ede -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision db4bd53f341896f8d1087dda549c89b3ab785ede)
+++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -42,7 +42,6 @@
import java.util.regex.Pattern;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.tomcat.util.json.JSONArray;
@@ -100,7 +99,6 @@
import org.lamsfoundation.lams.tool.assessment.util.AssessmentToolContentHandler;
import org.lamsfoundation.lams.tool.assessment.util.SequencableComparator;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
import org.lamsfoundation.lams.usermanagement.Organisation;
@@ -295,18 +293,18 @@
public List getUsersBySession(Long toolSessionID) {
return assessmentUserDao.getBySessionID(toolSessionID);
}
-
+
@Override
- public List getPagedUsersBySession(Long sessionId, int page, int size, String sortBy, String sortOrder,
- String searchString) {
+ public List getPagedUsersBySession(Long sessionId, int page, int size, String sortBy,
+ String sortOrder, String searchString) {
return assessmentUserDao.getPagedUsersBySession(sessionId, page, size, sortBy, sortOrder, searchString);
}
-
+
@Override
public int getCountUsersBySession(Long sessionId, String searchString) {
return assessmentUserDao.getCountUsersBySession(sessionId, searchString);
}
-
+
@Override
public List getPagedUsersBySessionAndQuestion(Long sessionId, Long questionUid, int page,
int size, String sortBy, String sortOrder, String searchString) {
@@ -407,12 +405,12 @@
public void setAttemptStarted(Assessment assessment, AssessmentUser assessmentUser, Long toolSessionId) {
AssessmentResult lastResult = getLastAssessmentResult(assessment.getUid(), assessmentUser.getUserId());
if (lastResult != null) {
-
+
// don't instantiate new attempt if the previous one wasn't finished and thus continue working with it
if (lastResult.getFinishDate() == null) {
return;
-
- // mark previous attempt as not the latest anymore
+
+ // mark previous attempt as not the latest anymore
} else {
lastResult.setLatest(false);
assessmentResultDao.saveObject(lastResult);
@@ -752,7 +750,7 @@
public int getAssessmentResultCount(Long assessmentUid, Long userId) {
return assessmentResultDao.getAssessmentResultCount(assessmentUid, userId);
}
-
+
@Override
public AssessmentQuestionResult getAssessmentQuestionResultByUid(Long questionResultUid) {
return assessmentQuestionResultDao.getAssessmentQuestionResultByUid(questionResultUid);
@@ -833,7 +831,7 @@
}
return nextUrl;
}
-
+
@Override
public List getSessionDtos(Long contentId) {
List sessionDtos = new ArrayList();
@@ -842,18 +840,18 @@
for (AssessmentSession session : sessionList) {
Long sessionId = session.getSessionId();
SessionDTO sessionDto = new SessionDTO(sessionId, session.getSessionName());
-
- //for statistics tab
+
+ // for statistics tab
int countUsers = assessmentUserDao.getCountUsersBySession(sessionId, "");
sessionDto.setNumberLearners(countUsers);
-
+
sessionDtos.add(sessionDto);
}
-
+
return sessionDtos;
}
- //remove method once we remove export portfolio
+ // remove method once we remove export portfolio
@Override
@Deprecated
public List getSessionDataForExport(Long contentId) {
@@ -966,34 +964,34 @@
return userSummary;
}
-
+
@Override
public QuestionSummary getQuestionSummary(Long contentId, Long questionUid) {
QuestionSummary questionSummary = new QuestionSummary();
AssessmentQuestion question = assessmentQuestionDao.getByUid(questionUid);
questionSummary.setQuestion(question);
-
+
return questionSummary;
}
@Override
public Map getQuestionSummaryForExport(Assessment assessment) {
Map questionSummaries = new HashMap();
-
+
if (assessment.getQuestions() == null) {
return questionSummaries;
}
-
+
SortedSet sessions = new TreeSet(new AssessmentSessionComparator());
sessions.addAll(assessmentSessionDao.getByContentId(assessment.getContentId()));
-
- List assessmentResults = assessmentResultDao.getLastFinishedAssessmentResults(assessment
- .getContentId());
+
+ List assessmentResults = assessmentResultDao
+ .getLastFinishedAssessmentResults(assessment.getContentId());
Map userUidToResultMap = new HashMap();
for (AssessmentResult assessmentResult : assessmentResults) {
userUidToResultMap.put(assessmentResult.getUser().getUid(), assessmentResult);
}
-
+
Map> sessionIdToUsersMap = new HashMap>();
for (AssessmentSession session : sessions) {
@@ -1012,7 +1010,7 @@
sessionIdToUsersMap.put(sessionId, users);
}
-
+
for (AssessmentQuestion question : (Set) assessment.getQuestions()) {
Long questionUid = question.getUid();
QuestionSummary questionSummary = new QuestionSummary();
@@ -1070,9 +1068,10 @@
return questionSummaries;
}
-
+
@Override
- public LinkedHashMap exportSummary(Assessment assessment, List sessionDtos, boolean showUserNames) {
+ public LinkedHashMap exportSummary(Assessment assessment, List sessionDtos,
+ boolean showUserNames) {
LinkedHashMap dataToExport = new LinkedHashMap();
final ExcelCell[] EMPTY_ROW = new ExcelCell[0];
@@ -1134,10 +1133,10 @@
dataToExport.put(getMessage("label.export.summary"), summaryTab.toArray(new ExcelCell[][] {}));
}
-
+
// ------------------------------------------------------------------
// -------------- Second tab: Question Summary ----------------------
-
+
ArrayList questionSummaryTab = new ArrayList();
// Create the question summary
@@ -1148,15 +1147,16 @@
Map questionSummaries = getQuestionSummaryForExport(assessment);
if (assessment.getQuestions() != null) {
- Set questions = (Set) assessment.getQuestions();
-
+ Set questions = assessment.getQuestions();
+
// question row title
int count = 0;
ExcelCell[] summaryRowTitle = showUserNames ? new ExcelCell[10] : new ExcelCell[9];
summaryRowTitle[count++] = new ExcelCell(getMessage("label.monitoring.question.summary.question"), true);
summaryRowTitle[count++] = new ExcelCell(getMessage("label.authoring.basic.list.header.type"), true);
summaryRowTitle[count++] = new ExcelCell(getMessage("label.authoring.basic.penalty.factor"), true);
- summaryRowTitle[count++] = new ExcelCell(getMessage("label.monitoring.question.summary.default.mark"), true);
+ summaryRowTitle[count++] = new ExcelCell(getMessage("label.monitoring.question.summary.default.mark"),
+ true);
summaryRowTitle[count++] = new ExcelCell(getMessage("label.export.user.id"), true);
if (showUserNames) {
summaryRowTitle[count++] = new ExcelCell(getMessage("label.monitoring.user.summary.user.name"), true);
@@ -1184,12 +1184,13 @@
if (showUserNames) {
ExcelCell[] userResultRow = new ExcelCell[10];
userResultRow[0] = new ExcelCell(questionResult.getAssessmentQuestion().getTitle(), false);
- userResultRow[1] = new ExcelCell(getQuestionTypeLanguageLabel(questionResult
- .getAssessmentQuestion().getType()), false);
- userResultRow[2] = new ExcelCell(new Float(questionResult.getAssessmentQuestion()
- .getPenaltyFactor()), false);
- Float maxMark = (questionResult.getMaxMark() == null) ? 0 : new Float(
- questionResult.getMaxMark());
+ userResultRow[1] = new ExcelCell(
+ getQuestionTypeLanguageLabel(questionResult.getAssessmentQuestion().getType()),
+ false);
+ userResultRow[2] = new ExcelCell(
+ new Float(questionResult.getAssessmentQuestion().getPenaltyFactor()), false);
+ Float maxMark = (questionResult.getMaxMark() == null) ? 0
+ : new Float(questionResult.getMaxMark());
userResultRow[3] = new ExcelCell(maxMark, false);
userResultRow[4] = new ExcelCell(questionResult.getUser().getUserId(), false);
userResultRow[5] = new ExcelCell(questionResult.getUser().getFullName(), false);
@@ -1199,7 +1200,7 @@
AssessmentResult assessmentResult = questionResult.getAssessmentResult();
Date finishDate = questionResult.getFinishDate();
- if (assessmentResult != null && finishDate != null) {
+ if ((assessmentResult != null) && (finishDate != null)) {
Date startDate = assessmentResult.getStartDate();
if (startDate != null) {
Long seconds = (finishDate.getTime() - startDate.getTime()) / 1000;
@@ -1220,12 +1221,13 @@
} else {
ExcelCell[] userResultRow = new ExcelCell[9];
userResultRow[0] = new ExcelCell(questionResult.getAssessmentQuestion().getTitle(), false);
- userResultRow[1] = new ExcelCell(getQuestionTypeLanguageLabel(questionResult
- .getAssessmentQuestion().getType()), false);
- userResultRow[2] = new ExcelCell(new Float(questionResult.getAssessmentQuestion()
- .getPenaltyFactor()), false);
- Float maxMark = (questionResult.getMaxMark() == null) ? 0 : new Float(
- questionResult.getMaxMark());
+ userResultRow[1] = new ExcelCell(
+ getQuestionTypeLanguageLabel(questionResult.getAssessmentQuestion().getType()),
+ false);
+ userResultRow[2] = new ExcelCell(
+ new Float(questionResult.getAssessmentQuestion().getPenaltyFactor()), false);
+ Float maxMark = (questionResult.getMaxMark() == null) ? 0
+ : new Float(questionResult.getMaxMark());
userResultRow[3] = new ExcelCell(maxMark, false);
userResultRow[4] = new ExcelCell(questionResult.getUser().getUserId(), false);
userResultRow[5] = new ExcelCell(questionResult.getFinishDate(), false);
@@ -1235,7 +1237,7 @@
if (questionResult.getAssessmentResult() != null) {
Date startDate = questionResult.getAssessmentResult().getStartDate();
Date finishDate = questionResult.getFinishDate();
- if (startDate != null && finishDate != null) {
+ if ((startDate != null) && (finishDate != null)) {
Long seconds = (finishDate.getTime() - startDate.getTime()) / 1000;
userResultRow[7] = new ExcelCell(seconds, false);
timeTakenCount++;
@@ -1295,10 +1297,10 @@
}
dataToExport.put(getMessage("lable.export.summary.by.question"),
questionSummaryTab.toArray(new ExcelCell[][] {}));
-
+
// ------------------------------------------------------------------
// -------------- Third tab: User Summary ---------------------------
-
+
ArrayList userSummaryTab = new ArrayList();
// Create the question summary
@@ -1370,13 +1372,13 @@
}
if (sessionDtos != null) {
- List assessmentResults = assessmentResultDao.getLastFinishedAssessmentResults(assessment
- .getContentId());
+ List assessmentResults = assessmentResultDao
+ .getLastFinishedAssessmentResults(assessment.getContentId());
Map userUidToResultMap = new HashMap();
for (AssessmentResult assessmentResult : assessmentResults) {
userUidToResultMap.put(assessmentResult.getUser().getUid(), assessmentResult);
}
-
+
for (SessionDTO sessionDTO : sessionDtos) {
userSummaryTab.add(EMPTY_ROW);
@@ -1396,23 +1398,21 @@
if (showUserNames) {
ExcelCell[] userTitleRow = new ExcelCell[6];
userTitleRow[0] = new ExcelCell(getMessage("label.export.user.id"), true);
- userTitleRow[1] = new ExcelCell(
- getMessage("label.monitoring.user.summary.user.name"), true);
+ userTitleRow[1] = new ExcelCell(getMessage("label.monitoring.user.summary.user.name"),
+ true);
userTitleRow[2] = new ExcelCell(getMessage("label.export.date.attempted"), true);
- userTitleRow[3] = new ExcelCell(
- getMessage("label.monitoring.question.summary.question"), true);
- userTitleRow[4] = new ExcelCell(getMessage("label.authoring.basic.option.answer"),
+ userTitleRow[3] = new ExcelCell(getMessage("label.monitoring.question.summary.question"),
true);
+ userTitleRow[4] = new ExcelCell(getMessage("label.authoring.basic.option.answer"), true);
userTitleRow[5] = new ExcelCell(getMessage("label.export.mark"), true);
userSummaryTab.add(userTitleRow);
} else {
ExcelCell[] userTitleRow = new ExcelCell[5];
userTitleRow[0] = new ExcelCell(getMessage("label.export.user.id"), true);
userTitleRow[1] = new ExcelCell(getMessage("label.export.date.attempted"), true);
- userTitleRow[2] = new ExcelCell(
- getMessage("label.monitoring.question.summary.question"), true);
- userTitleRow[3] = new ExcelCell(getMessage("label.authoring.basic.option.answer"),
+ userTitleRow[2] = new ExcelCell(getMessage("label.monitoring.question.summary.question"),
true);
+ userTitleRow[3] = new ExcelCell(getMessage("label.authoring.basic.option.answer"), true);
userTitleRow[4] = new ExcelCell(getMessage("label.export.mark"), true);
userSummaryTab.add(userTitleRow);
}
@@ -1431,8 +1431,8 @@
userResultRow[0] = new ExcelCell(assessmentUser.getUserId(), false);
userResultRow[1] = new ExcelCell(assessmentUser.getFullName(), false);
userResultRow[2] = new ExcelCell(assessmentResult.getStartDate(), false);
- userResultRow[3] = new ExcelCell(questionResult.getAssessmentQuestion()
- .getTitle(), false);
+ userResultRow[3] = new ExcelCell(
+ questionResult.getAssessmentQuestion().getTitle(), false);
userResultRow[4] = new ExcelCell(
AssessmentEscapeUtils.printResponsesForExcelExport(questionResult),
false);
@@ -1442,8 +1442,8 @@
ExcelCell[] userResultRow = new ExcelCell[5];
userResultRow[0] = new ExcelCell(assessmentUser.getUserId(), false);
userResultRow[1] = new ExcelCell(assessmentResult.getStartDate(), false);
- userResultRow[2] = new ExcelCell(questionResult.getAssessmentQuestion()
- .getTitle(), false);
+ userResultRow[2] = new ExcelCell(
+ questionResult.getAssessmentQuestion().getTitle(), false);
userResultRow[3] = new ExcelCell(
AssessmentEscapeUtils.printResponsesForExcelExport(questionResult),
false);
@@ -1456,13 +1456,11 @@
ExcelCell[] userTotalRow;
if (showUserNames) {
userTotalRow = new ExcelCell[6];
- userTotalRow[4] = new ExcelCell(getMessage("label.monitoring.summary.total"),
- true);
+ userTotalRow[4] = new ExcelCell(getMessage("label.monitoring.summary.total"), true);
userTotalRow[5] = new ExcelCell(assessmentResult.getGrade(), false);
} else {
userTotalRow = new ExcelCell[5];
- userTotalRow[3] = new ExcelCell(getMessage("label.monitoring.summary.total"),
- true);
+ userTotalRow[3] = new ExcelCell(getMessage("label.monitoring.summary.total"), true);
userTotalRow[4] = new ExcelCell(assessmentResult.getGrade(), false);
}
@@ -1474,10 +1472,10 @@
}
}
dataToExport.put(getMessage("label.export.summary.by.user"), userSummaryTab.toArray(new ExcelCell[][] {}));
-
+
return dataToExport;
}
-
+
/**
* Used only for excell export (for getUserSummaryData() method).
*/
@@ -1498,7 +1496,7 @@
case AssessmentConstants.QUESTION_TYPE_TRUE_FALSE:
return "True/False";
case AssessmentConstants.QUESTION_TYPE_MARK_HEDGING:
- return "Mark Hedging";
+ return "Mark Hedging";
default:
return null;
}
@@ -2127,17 +2125,22 @@
}
@Override
- public void removeToolContent(Long toolContentId, boolean removeSessionData)
- throws SessionDataExistsException, ToolException {
+ public void removeToolContent(Long toolContentId) throws ToolException {
Assessment assessment = assessmentDao.getByContentId(toolContentId);
- if (removeSessionData) {
- List list = assessmentSessionDao.getByContentId(toolContentId);
- Iterator iter = list.iterator();
- while (iter.hasNext()) {
- AssessmentSession session = (AssessmentSession) iter.next();
- assessmentSessionDao.delete(session);
+ if (assessment == null) {
+ AssessmentServiceImpl.log
+ .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId);
+ return;
+ }
+
+ for (AssessmentSession session : assessmentSessionDao.getByContentId(toolContentId)) {
+ List entries = coreNotebookService.getEntry(session.getSessionId(),
+ CoreNotebookConstants.NOTEBOOK_TOOL, AssessmentConstants.TOOL_SIGNATURE);
+ for (NotebookEntry entry : entries) {
+ coreNotebookService.deleteEntry(entry);
}
}
+
assessmentDao.delete(assessment);
}
@@ -2167,7 +2170,7 @@
assessmentDao.removeObject(NotebookEntry.class, entry.getUid());
}
- if (session.getGroupLeader() != null && session.getGroupLeader().getUid().equals(user.getUid())) {
+ if ((session.getGroupLeader() != null) && session.getGroupLeader().getUid().equals(user.getUid())) {
session.setGroupLeader(null);
}
@@ -2434,7 +2437,8 @@
assessment.setReflectOnActivity(JsonUtil.opt(toolContentJSON, RestTags.REFLECT_ON_ACTIVITY, Boolean.FALSE));
assessment.setShuffled(JsonUtil.opt(toolContentJSON, "shuffled", Boolean.FALSE));
assessment.setTimeLimit(JsonUtil.opt(toolContentJSON, "timeLimit", 0));
- assessment.setUseSelectLeaderToolOuput(JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE));
+ assessment.setUseSelectLeaderToolOuput(
+ JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE));
// submission deadline set in monitoring
if (toolContentJSON.has("overallFeedback")) {
@@ -2557,9 +2561,11 @@
// TODO Implement REST support for all types and then remove checkType method
void checkType(short type) throws JSONException {
- if (type != AssessmentConstants.QUESTION_TYPE_ESSAY && type != AssessmentConstants.QUESTION_TYPE_MULTIPLE_CHOICE) {
+ if ((type != AssessmentConstants.QUESTION_TYPE_ESSAY)
+ && (type != AssessmentConstants.QUESTION_TYPE_MULTIPLE_CHOICE)) {
throw new JSONException(
- "Assessment Tool does not support REST Authoring for anything but Essay Type and Multiple Choice. Found type " + type);
+ "Assessment Tool does not support REST Authoring for anything but Essay Type and Multiple Choice. Found type "
+ + type);
}
// public static final short QUESTION_TYPE_MATCHING_PAIRS = 2;
// public static final short QUESTION_TYPE_SHORT_ANSWER = 3;
Index: lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbService.java
===================================================================
diff -u -ra207bdecc16a704428826dbf402a97de2e35458b -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbService.java (.../BbbService.java) (revision a207bdecc16a704428826dbf402a97de2e35458b)
+++ lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbService.java (.../BbbService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -44,6 +44,7 @@
import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService;
import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
+import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.notebook.service.ICoreNotebookService;
import org.lamsfoundation.lams.tool.ToolContentManager;
import org.lamsfoundation.lams.tool.ToolOutput;
@@ -62,7 +63,6 @@
import org.lamsfoundation.lams.tool.bbb.util.BbbUtil;
import org.lamsfoundation.lams.tool.bbb.util.Constants;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
import org.lamsfoundation.lams.usermanagement.User;
@@ -102,9 +102,10 @@
}
/* Methods from ToolSessionManager */
+ @Override
public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException {
- if (logger.isDebugEnabled()) {
- logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId
+ if (BbbService.logger.isDebugEnabled()) {
+ BbbService.logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId
+ " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId);
}
@@ -117,17 +118,21 @@
bbbSessionDAO.insertOrUpdate(session);
}
+ @Override
public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException {
return learnerService.completeToolSession(toolSessionId, learnerId);
}
- public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException {
+ @Override
+ public ToolSessionExportOutputData exportToolSession(Long toolSessionId)
+ throws DataMissingException, ToolException {
return null;
}
+ @Override
@SuppressWarnings("unchecked")
- public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException,
- ToolException {
+ public ToolSessionExportOutputData exportToolSession(List toolSessionIds)
+ throws DataMissingException, ToolException {
return null;
}
@@ -146,19 +151,20 @@
public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) {
return null;
}
-
+
@Override
public void forceCompleteUser(Long toolSessionId, User user) {
- //no actions required
+ // no actions required
}
/* Methods from ToolContentManager */
+ @Override
public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException {
- if (logger.isDebugEnabled()) {
- logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId + " toContentId="
- + toContentId);
+ if (BbbService.logger.isDebugEnabled()) {
+ BbbService.logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId
+ + " toContentId=" + toContentId);
}
if (toContentId == null) {
@@ -177,7 +183,7 @@
Bbb toContent = Bbb.newInstance(fromContent, toContentId, bbbToolContentHandler);
saveOrUpdateBbb(toContent);
}
-
+
@Override
public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException {
Bbb bbb = getBbbByContentId(toolContentId);
@@ -189,20 +195,35 @@
}
@Override
- public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException,
- ToolException {
- // TODO Auto-generated method stub
+ public void removeToolContent(Long toolContentId) throws ToolException {
+ Bbb bbb = getBbbByContentId(toolContentId);
+ if (bbb == null) {
+ BbbService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId);
+ return;
+ }
+
+ for (BbbSession session : bbb.getBbbSessions()) {
+ List entries = coreNotebookService.getEntry(session.getSessionId(),
+ CoreNotebookConstants.NOTEBOOK_TOOL, Constants.TOOL_SIGNATURE);
+ for (NotebookEntry entry : entries) {
+ coreNotebookService.deleteEntry(entry);
+ }
+ }
+
+ bbbDAO.delete(bbb);
}
-
+
+ @Override
public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException {
- if (logger.isDebugEnabled()) {
- logger.debug("Resetting Web Conference completion flag for user ID " + userId + " and toolContentId "
- + toolContentId);
+ if (BbbService.logger.isDebugEnabled()) {
+ BbbService.logger.debug("Resetting Web Conference completion flag for user ID " + userId
+ + " and toolContentId " + toolContentId);
}
Bbb bbb = getBbbByContentId(toolContentId);
if (bbb == null) {
- logger.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content");
+ BbbService.logger
+ .warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content");
return;
}
@@ -230,13 +251,15 @@
* if any other error occurs
*/
+ @Override
public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException {
Bbb bbb = getBbbByContentId(toolContentId);
if (bbb == null) {
bbb = getDefaultContent();
}
- if (bbb == null)
+ if (bbb == null) {
throw new DataMissingException("Unable to find default content for the bbb tool");
+ }
// set ResourceToolContentHandler as null to avoid copy file node in
// repository again.
@@ -256,17 +279,19 @@
* @throws ToolException
* if any other error occurs
*/
+ @Override
public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion,
String toVersion) throws ToolException {
try {
// register version filter class
exportContentService.registerImportVersionFilterClass(BbbImportContentVersionFilter.class);
-
+
Object toolPOJO = exportContentService.importToolContent(toolContentPath, bbbToolContentHandler,
fromVersion, toVersion);
- if (!(toolPOJO instanceof Bbb))
- throw new ImportToolContentException("Import Bbb tool content failed. Deserialized object is "
- + toolPOJO);
+ if (!(toolPOJO instanceof Bbb)) {
+ throw new ImportToolContentException(
+ "Import Bbb tool content failed. Deserialized object is " + toolPOJO);
+ }
Bbb bbb = (Bbb) toolPOJO;
// reset it to new toolContentId
@@ -279,10 +304,11 @@
}
}
+ @Override
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return null;
}
-
+
/**
* Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions
* that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created
@@ -291,74 +317,84 @@
*
* @return SortedMap of ToolOutputDefinitions with the key being the name of each definition
*/
+ @Override
public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType)
throws ToolException {
return new TreeMap();
}
+ @Override
public String getToolContentTitle(Long toolContentId) {
return getBbbByContentId(toolContentId).getTitle();
}
-
+
+ @Override
public boolean isContentEdited(Long toolContentId) {
return getBbbByContentId(toolContentId).isDefineLater();
}
-
+
/* IBbbService Methods */
+ @Override
public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) {
return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry);
}
public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID) {
List list = coreNotebookService.getEntry(id, idType, signature, userID);
- if (list == null || list.isEmpty()) {
+ if ((list == null) || list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
+ @Override
public NotebookEntry getNotebookEntry(Long uid) {
return coreNotebookService.getEntry(uid);
}
+ @Override
public void updateNotebookEntry(Long uid, String entry) {
coreNotebookService.updateEntry(uid, "", entry);
}
+ @Override
public void updateNotebookEntry(NotebookEntry notebookEntry) {
coreNotebookService.updateEntry(notebookEntry);
}
+ @Override
public Long getDefaultContentIdBySignature(String toolSignature) {
Long toolContentId = null;
toolContentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature));
if (toolContentId == null) {
String error = "Could not retrieve default content id for this tool";
- logger.error(error);
+ BbbService.logger.error(error);
throw new BbbException(error);
}
return toolContentId;
}
+ @Override
public Bbb getDefaultContent() {
Long defaultContentID = getDefaultContentIdBySignature(Constants.TOOL_SIGNATURE);
Bbb defaultContent = getBbbByContentId(defaultContentID);
if (defaultContent == null) {
String error = "Could not retrieve default content record for this tool";
- logger.error(error);
+ BbbService.logger.error(error);
throw new BbbException(error);
}
return defaultContent;
}
+ @Override
public Bbb copyDefaultContent(Long newContentID) {
if (newContentID == null) {
String error = "Cannot copy the Bbb tools default content: + " + "newContentID is null";
- logger.error(error);
+ BbbService.logger.error(error);
throw new BbbException(error);
}
@@ -370,6 +406,7 @@
return newContent;
}
+ @Override
@SuppressWarnings("unchecked")
public Bbb getBbbByContentId(Long toolContentID) {
List list = bbbDAO.findByProperty(Bbb.class, "toolContentId", toolContentID);
@@ -380,6 +417,7 @@
}
}
+ @Override
@SuppressWarnings("unchecked")
public BbbSession getSessionBySessionId(Long toolSessionId) {
List list = bbbSessionDAO.findByProperty(BbbSession.class, "sessionId", toolSessionId);
@@ -390,6 +428,7 @@
}
}
+ @Override
@SuppressWarnings("unchecked")
public BbbUser getUserByUserIdAndSessionId(Long userId, Long toolSessionId) {
Map map = new HashMap();
@@ -403,6 +442,7 @@
}
}
+ @Override
@SuppressWarnings("unchecked")
public BbbUser getUserByUID(Long uid) {
List list = bbbUserDAO.findByProperty(BbbUser.class, "uid", uid);
@@ -413,159 +453,151 @@
}
}
+ @Override
public String getJoinMeetingURL(UserDTO userDTO, String meetingKey, String password) throws Exception {
// Get Bbb details
String serverURL = getConfigValue(Constants.CFG_SERVER_URL);
- String securitySalt = getConfigValue(Constants.CFG_SECURITYSALT);
+ String securitySalt = getConfigValue(Constants.CFG_SECURITYSALT);
// Get Join parameter
String joinParam = Constants.BBB_JOIN_PARAM;
-
+
if (serverURL == null) {
- logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined");
+ BbbService.logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined");
throw new BbbException("Server url not defined");
}
- String queryString = "fullName="
- + URLEncoder.encode(userDTO.getFirstName() + " " + userDTO.getLastName(), "UTF8")
- + "&meetingID="
- + URLEncoder.encode(meetingKey, "UTF8")
- + "&password="
- + URLEncoder.encode(password, "UTF8");
-
- String checkSum = DigestUtils.shaHex("join" + queryString + securitySalt);
-
+ String queryString = "fullName="
+ + URLEncoder.encode(userDTO.getFirstName() + " " + userDTO.getLastName(), "UTF8") + "&meetingID="
+ + URLEncoder.encode(meetingKey, "UTF8") + "&password=" + URLEncoder.encode(password, "UTF8");
+
+ String checkSum = DigestUtils.shaHex("join" + queryString + securitySalt);
+
String url = serverURL + joinParam + queryString + "&checksum=" + checkSum;
return url;
- }
-
- public Boolean isMeetingRunning(String meetingKey) throws Exception {
- String serverURL = getConfigValue(Constants.CFG_SERVER_URL);
- String securitySalt = getConfigValue(Constants.CFG_SECURITYSALT);
- String meetingRunning = Constants.BBB_MEETING_RUNNING_PARAM;
-
- String queryString = "meetingID="
- + URLEncoder.encode(meetingKey, "UTF8");
-
- String checkSum = DigestUtils.shaHex("isMeetingRunning" + queryString + securitySalt);
-
- URL url;
- url = new URL(serverURL
- + meetingRunning
- + queryString
- + "&checksum="
- + URLEncoder.encode(checkSum, "UTF8"));
+ }
- logger.debug("isMeetingRunningURL=" + url);
-
- String response;
- response = sendRequest(url);
-
- if (response.contains("true")) {
- return true;
- } else {
- return false;
- }
-
+ @Override
+ public Boolean isMeetingRunning(String meetingKey) throws Exception {
+ String serverURL = getConfigValue(Constants.CFG_SERVER_URL);
+ String securitySalt = getConfigValue(Constants.CFG_SECURITYSALT);
+ String meetingRunning = Constants.BBB_MEETING_RUNNING_PARAM;
+
+ String queryString = "meetingID=" + URLEncoder.encode(meetingKey, "UTF8");
+
+ String checkSum = DigestUtils.shaHex("isMeetingRunning" + queryString + securitySalt);
+
+ URL url;
+ url = new URL(serverURL + meetingRunning + queryString + "&checksum=" + URLEncoder.encode(checkSum, "UTF8"));
+
+ BbbService.logger.debug("isMeetingRunningURL=" + url);
+
+ String response;
+ response = sendRequest(url);
+
+ if (response.contains("true")) {
+ return true;
+ } else {
+ return false;
+ }
+
}
-
-
- public String startConference(String meetingKey, String atendeePassword,
- String moderatorPassword, String returnURL,
- String welcomeMessage)
- throws Exception {
+ @Override
+ public String startConference(String meetingKey, String atendeePassword, String moderatorPassword, String returnURL,
+ String welcomeMessage) throws Exception {
+
String serverURL = getConfigValue(Constants.CFG_SERVER_URL);
String securitySalt = getConfigValue(Constants.CFG_SECURITYSALT);
String createParam = Constants.BBB_CREATE_PARAM;
-
+
if (serverURL == null) {
- logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined");
+ BbbService.logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined");
throw new BbbException("Standard server url not defined");
}
-
- String queryString = "name="
- + URLEncoder.encode(meetingKey, "UTF8") + "&meetingID="
- + URLEncoder.encode(meetingKey, "UTF8") + "&attendeePW="
- + URLEncoder.encode(atendeePassword, "UTF8") + "&moderatorPW="
- + URLEncoder.encode(moderatorPassword, "UTF8") + "&logoutURL="
- + URLEncoder.encode(returnURL, "UTF8") + "&welcome="
- + URLEncoder.encode(welcomeMessage, "UTF8");
- logger.debug("queryString = " + queryString);
-
+ String queryString = "name=" + URLEncoder.encode(meetingKey, "UTF8") + "&meetingID="
+ + URLEncoder.encode(meetingKey, "UTF8") + "&attendeePW=" + URLEncoder.encode(atendeePassword, "UTF8")
+ + "&moderatorPW=" + URLEncoder.encode(moderatorPassword, "UTF8") + "&logoutURL="
+ + URLEncoder.encode(returnURL, "UTF8") + "&welcome=" + URLEncoder.encode(welcomeMessage, "UTF8");
+
+ BbbService.logger.debug("queryString = " + queryString);
+
String checkSum = DigestUtils.shaHex("create" + queryString + securitySalt);
- logger.debug("checksum = " + checkSum);
-
+ BbbService.logger.debug("checksum = " + checkSum);
+
URL url;
- url = new URL(serverURL
- + createParam
- + queryString
- + "&checksum="
- + URLEncoder.encode(checkSum, "UTF8"));
+ url = new URL(serverURL + createParam + queryString + "&checksum=" + URLEncoder.encode(checkSum, "UTF8"));
- logger.info("url = " + url);
-
+ BbbService.logger.info("url = " + url);
+
String response;
response = sendRequest(url);
-
+
if (BbbUtil.getResponse(response) == Constants.RESPONSE_SUCCESS) {
- return Constants.RESPONSE_SUCCESS;
+ return Constants.RESPONSE_SUCCESS;
} else {
- logger.error("BBB returns fail when creating a meeting room");
+ BbbService.logger.error("BBB returns fail when creating a meeting room");
throw new BbbException("Standard server url not defined");
}
}
-
+
+ @Override
public void saveOrUpdateBbb(Bbb bbb) {
bbbDAO.insertOrUpdate(bbb);
}
+ @Override
public void saveOrUpdateBbbSession(BbbSession bbbSession) {
bbbSessionDAO.insertOrUpdate(bbbSession);
}
+ @Override
public void saveOrUpdateBbbUser(BbbUser bbbUser) {
bbbUserDAO.insertOrUpdate(bbbUser);
}
+ @Override
public BbbUser createBbbUser(UserDTO user, BbbSession bbbSession) {
BbbUser bbbUser = new BbbUser(user, bbbSession);
saveOrUpdateBbbUser(bbbUser);
return bbbUser;
}
+ @Override
@SuppressWarnings("unchecked")
public BbbConfig getConfig(String key) {
- List list = (List) bbbConfigDAO.findByProperty(BbbConfig.class, "key", key);
+ List list = bbbConfigDAO.findByProperty(BbbConfig.class, "key", key);
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
+ @Override
@SuppressWarnings("unchecked")
public String getConfigValue(String key) {
- List list = (List) bbbConfigDAO.findByProperty(BbbConfig.class, "key", key);
+ List list = bbbConfigDAO.findByProperty(BbbConfig.class, "key", key);
if (list.isEmpty()) {
return null;
} else {
return list.get(0).getValue();
}
}
+ @Override
public void saveOrUpdateConfigEntry(BbbConfig bbbConfig) {
bbbConfigDAO.insertOrUpdate(bbbConfig);
}
private String sendRequest(URL url) throws IOException {
- if (logger.isDebugEnabled()) {
- logger.debug("request = " + url);
+ if (BbbService.logger.isDebugEnabled()) {
+ BbbService.logger.debug("request = " + url);
}
URLConnection connection = url.openConnection();
@@ -574,12 +606,13 @@
String response = "";
String line = "";
- while ((line = in.readLine()) != null)
+ while ((line = in.readLine()) != null) {
response += line;
+ }
in.close();
- if (logger.isDebugEnabled()) {
- logger.debug("response = " + response);
+ if (BbbService.logger.isDebugEnabled()) {
+ BbbService.logger.debug("response = " + response);
}
return response;
@@ -588,11 +621,11 @@
/**
* Set the description, throws away the title value as this is not supported in 2.0
*/
- public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException,
- DataMissingException {
+ public void setReflectiveData(Long toolContentId, String title, String description)
+ throws ToolException, DataMissingException {
- logger
- .warn("Setting the reflective field on a bbb. This doesn't make sense as the bbb is for reflection and we don't reflect on reflection!");
+ BbbService.logger.warn(
+ "Setting the reflective field on a bbb. This doesn't make sense as the bbb is for reflection and we don't reflect on reflection!");
Bbb bbb = getBbbByContentId(toolContentId);
if (bbb == null) {
throw new DataMissingException("Unable to set reflective data titled " + title
Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java
===================================================================
diff -u -ra207bdecc16a704428826dbf402a97de2e35458b -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java (.../ChatService.java) (revision a207bdecc16a704428826dbf402a97de2e35458b)
+++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java (.../ChatService.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -68,7 +68,6 @@
import org.lamsfoundation.lams.tool.chat.util.ChatException;
import org.lamsfoundation.lams.tool.chat.util.ChatMessageFilter;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
import org.lamsfoundation.lams.usermanagement.User;
@@ -85,7 +84,8 @@
* As a requirement, all LAMS tool's service bean must implement ToolContentManager and ToolSessionManager.
*/
-public class ChatService implements ToolSessionManager, ToolContentManager, ToolContentImport102Manager, IChatService, ToolRestManager {
+public class ChatService
+ implements ToolSessionManager, ToolContentManager, ToolContentImport102Manager, IChatService, ToolRestManager {
private static Logger logger = Logger.getLogger(ChatService.class.getName());
@@ -114,6 +114,7 @@
private Random generator = new Random();
/* Methods from ToolSessionManager */
+ @Override
public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException {
if (ChatService.logger.isDebugEnabled()) {
ChatService.logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId
@@ -170,14 +171,15 @@
}
@Override
- public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException {
+ public ToolSessionExportOutputData exportToolSession(Long toolSessionId)
+ throws DataMissingException, ToolException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException,
- ToolException {
+ public ToolSessionExportOutputData exportToolSession(List toolSessionIds)
+ throws DataMissingException, ToolException {
// TODO Auto-generated method stub
return null;
}
@@ -197,10 +199,10 @@
public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) {
return getChatOutputFactory().getToolOutput(name, this, toolSessionId, learnerId);
}
-
+
@Override
public void forceCompleteUser(Long toolSessionId, User user) {
- //no actions required
+ // no actions required
}
/* Methods from ToolContentManager */
@@ -229,7 +231,7 @@
Chat toContent = Chat.newInstance(fromContent, toContentId);
chatDAO.saveOrUpdate(toContent);
}
-
+
@Override
public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException {
Chat chat = chatDAO.getByContentId(toolContentId);
@@ -240,19 +242,37 @@
chatDAO.saveOrUpdate(chat);
}
- public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException,
- ToolException {
- // TODO Auto-generated method stub
+ @SuppressWarnings("unchecked")
+ @Override
+ public void removeToolContent(Long toolContentId) throws ToolException {
+ Chat chat = chatDAO.getByContentId(toolContentId);
+ if (chat == null) {
+ ChatService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId);
+ return;
+ }
+
+ for (ChatSession session : (Set) chat.getChatSessions()) {
+ List entries = coreNotebookService.getEntry(session.getSessionId(),
+ CoreNotebookConstants.NOTEBOOK_TOOL, ChatConstants.TOOL_SIGNATURE);
+ for (NotebookEntry entry : entries) {
+ coreNotebookService.deleteEntry(entry);
+ }
+ }
+
+ chatDAO.delete(chat);
}
+ @Override
@SuppressWarnings("unchecked")
public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException {
- if (logger.isDebugEnabled()) {
- logger.debug("Removing Chat messages for user ID " + userId + " and toolContentId " + toolContentId);
+ if (ChatService.logger.isDebugEnabled()) {
+ ChatService.logger
+ .debug("Removing Chat messages for user ID " + userId + " and toolContentId " + toolContentId);
}
Chat chat = chatDAO.getByContentId(toolContentId);
if (chat == null) {
- logger.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content");
+ ChatService.logger
+ .warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content");
return;
}
@@ -280,7 +300,7 @@
}
}
-
+
/**
* Export the XML fragment for the tool's content, along with any files needed for the content.
*
@@ -290,6 +310,7 @@
* if any other error occurs
*/
+ @Override
public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException {
Chat chat = chatDAO.getByContentId(toolContentId);
if (chat == null) {
@@ -316,17 +337,18 @@
* @throws ToolException
* if any other error occurs
*/
+ @Override
public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion,
String toVersion) throws ToolException {
try {
// register version filter class
exportContentService.registerImportVersionFilterClass(ChatImportContentVersionFilter.class);
-
+
Object toolPOJO = exportContentService.importToolContent(toolContentPath, chatToolContentHandler,
fromVersion, toVersion);
if (!(toolPOJO instanceof Chat)) {
- throw new ImportToolContentException("Import Chat tool content failed. Deserialized object is "
- + toolPOJO);
+ throw new ImportToolContentException(
+ "Import Chat tool content failed. Deserialized object is " + toolPOJO);
}
Chat chat = (Chat) toolPOJO;
@@ -348,6 +370,7 @@
*
* @return SortedMap of ToolOutputDefinitions with the key being the name of each definition
*/
+ @Override
public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType)
throws ToolException {
Chat chat = getChatDAO().getByContentId(toolContentId);
@@ -359,15 +382,18 @@
return getChatOutputFactory().getToolOutputDefinitions(chat, definitionType);
}
+ @Override
public String getToolContentTitle(Long toolContentId) {
return getChatByContentId(toolContentId).getTitle();
}
-
+
+ @Override
public boolean isContentEdited(Long toolContentId) {
return getChatByContentId(toolContentId).isDefineLater();
}
/* IChatService Methods */
+ @Override
public Long getDefaultContentIdBySignature(String toolSignature) {
Long toolContentId = null;
toolContentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature));
@@ -379,6 +405,7 @@
return toolContentId;
}
+ @Override
public Chat getDefaultContent() {
Long defaultContentID = getDefaultContentIdBySignature(ChatConstants.TOOL_SIGNATURE);
Chat defaultContent = getChatByContentId(defaultContentID);
@@ -388,12 +415,13 @@
throw new ChatException(error);
}
if (defaultContent.getConditions().isEmpty()) {
- defaultContent.getConditions().add(
- getChatOutputFactory().createDefaultUserMessagesCondition(defaultContent));
+ defaultContent.getConditions()
+ .add(getChatOutputFactory().createDefaultUserMessagesCondition(defaultContent));
}
return defaultContent;
}
+ @Override
public Chat copyDefaultContent(Long newContentID) {
if (newContentID == null) {
@@ -410,6 +438,7 @@
return newContent;
}
+ @Override
public Chat getChatByContentId(Long toolContentID) {
Chat chat = chatDAO.getByContentId(toolContentID);
if (chat == null) {
@@ -418,6 +447,7 @@
return chat;
}
+ @Override
public ChatSession getSessionBySessionId(Long toolSessionId) {
ChatSession chatSession = chatSessionDAO.getBySessionId(toolSessionId);
if (chatSession == null) {
@@ -426,30 +456,36 @@
return chatSession;
}
+ @Override
public List getUsersActiveBySessionId(Long toolSessionId) {
Date oldestLastPresence = new Date(System.currentTimeMillis() - ChatConstants.PRESENCE_IDLE_TIMEOUT);
return chatUserDAO.getBySessionIdAndLastPresence(toolSessionId, oldestLastPresence);
}
+ @Override
public ChatUser getUserByUserIdAndSessionId(Long userId, Long toolSessionId) {
return chatUserDAO.getByUserIdAndSessionId(userId, toolSessionId);
}
+ @Override
public ChatUser getUserByLoginNameAndSessionId(String loginName, Long toolSessionId) {
return chatUserDAO.getByLoginNameAndSessionId(loginName, toolSessionId);
}
+ @Override
public ChatUser getUserByUID(Long uid) {
return chatUserDAO.getByUID(uid);
}
+ @Override
public ChatUser getUserByNicknameAndSessionID(String nickname, Long sessionID) {
return chatUserDAO.getByNicknameAndSessionID(nickname, sessionID);
}
/**
* Stores information when users with given UIDs were last seen in their Chat session.
*/
+ @Override
public void updateUserPresence(Map presence) {
for (Long userUid : presence.keySet()) {
ChatUser chatUser = chatUserDAO.getByUID(userUid);
@@ -458,34 +494,41 @@
}
}
+ @Override
public List getMessagesForUser(ChatUser chatUser) {
return chatMessageDAO.getForUser(chatUser);
}
/**
* {@inheritDoc}
*/
+ @Override
public List getMessagesSentByUser(Long userUid) {
return chatMessageDAO.getSentByUser(userUid);
}
+ @Override
public void saveOrUpdateChat(Chat chat) {
updateMessageFilters(chat);
chatDAO.saveOrUpdate(chat);
}
+ @Override
public void saveOrUpdateChatSession(ChatSession chatSession) {
chatSessionDAO.saveOrUpdate(chatSession);
}
+ @Override
public void saveOrUpdateChatUser(ChatUser chatUser) {
chatUserDAO.saveOrUpdate(chatUser);
}
+ @Override
public void saveOrUpdateChatMessage(ChatMessage chatMessage) {
chatMessageDAO.saveOrUpdate(chatMessage);
}
+ @Override
public synchronized ChatUser createChatUser(UserDTO user, ChatSession chatSession) {
ChatUser chatUser = new ChatUser(user, chatSession);
@@ -515,6 +558,7 @@
return nickname;
}
+ @Override
public String filterMessage(String message, Chat chat) {
Pattern pattern = getFilterPattern(chat);
@@ -549,16 +593,19 @@
return pattern;
}
+ @Override
public ChatMessageFilter updateMessageFilters(Chat chat) {
ChatMessageFilter filter = new ChatMessageFilter(chat);
messageFilters.put(chat.getToolContentId(), filter);
return filter;
}
+ @Override
public ChatMessage getMessageByUID(Long messageUID) {
return chatMessageDAO.getByUID(messageUID);
}
+ @Override
public List getLastestMessages(ChatSession chatSession, int max) {
return chatMessageDAO.getLatest(chatSession, max);
}
@@ -571,21 +618,24 @@
this.auditService = auditService;
}
+ @Override
public void auditEditMessage(ChatMessage chatMessage, String messageBody) {
- auditService.logChange(ChatConstants.TOOL_SIGNATURE, chatMessage.getFromUser().getUserId(), chatMessage
- .getFromUser().getLoginName(), chatMessage.getBody(), messageBody);
+ auditService.logChange(ChatConstants.TOOL_SIGNATURE, chatMessage.getFromUser().getUserId(),
+ chatMessage.getFromUser().getLoginName(), chatMessage.getBody(), messageBody);
}
+ @Override
public void auditHideShowMessage(ChatMessage chatMessage, boolean messageHidden) {
if (messageHidden) {
- auditService.logHideEntry(ChatConstants.TOOL_SIGNATURE, chatMessage.getFromUser().getUserId(), chatMessage
- .getFromUser().getLoginName(), chatMessage.toString());
+ auditService.logHideEntry(ChatConstants.TOOL_SIGNATURE, chatMessage.getFromUser().getUserId(),
+ chatMessage.getFromUser().getLoginName(), chatMessage.toString());
} else {
- auditService.logShowEntry(ChatConstants.TOOL_SIGNATURE, chatMessage.getFromUser().getUserId(), chatMessage
- .getFromUser().getLoginName(), chatMessage.toString());
+ auditService.logShowEntry(ChatConstants.TOOL_SIGNATURE, chatMessage.getFromUser().getUserId(),
+ chatMessage.getFromUser().getLoginName(), chatMessage.toString());
}
}
+ @Override
public boolean isGroupedActivity(long toolContentID) {
return toolService.isGroupedActivity(toolContentID);
}
@@ -657,10 +707,12 @@
this.exportContentService = exportContentService;
}
+ @Override
public Map getMessageCountBySession(Long chatUID) {
return chatMessageDAO.getCountBySession(chatUID);
}
+ @Override
public Map getMessageCountByFromUser(Long sessionUID) {
return chatMessageDAO.getCountByFromUser(sessionUID);
}
@@ -673,10 +725,12 @@
this.coreNotebookService = coreNotebookService;
}
+ @Override
public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) {
return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry);
}
+ @Override
public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID) {
List list = coreNotebookService.getEntry(id, idType, signature, userID);
@@ -690,6 +744,7 @@
/**
* @param notebookEntry
*/
+ @Override
public void updateEntry(NotebookEntry notebookEntry) {
coreNotebookService.updateEntry(notebookEntry);
}
@@ -701,6 +756,7 @@
/**
* Import the data for a 1.0.2 Chat
*/
+ @Override
public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) {
Date now = new Date();
Chat chat = new Chat();
@@ -710,8 +766,8 @@
chat.setDefineLater(Boolean.FALSE);
chat.setFilterKeywords(null);
chat.setFilteringEnabled(Boolean.FALSE);
- chat.setInstructions(WebUtil.convertNewlines((String) importValues
- .get(ToolContentImport102Manager.CONTENT_BODY)));
+ chat.setInstructions(
+ WebUtil.convertNewlines((String) importValues.get(ToolContentImport102Manager.CONTENT_BODY)));
chat.setLockOnFinished(Boolean.FALSE);
chat.setReflectInstructions(null);
chat.setReflectOnActivity(Boolean.FALSE);
@@ -726,10 +782,8 @@
} catch (WDDXProcessorConversionException e) {
ChatService.logger.error("Unable to content for activity " + chat.getTitle()
+ "properly due to a WDDXProcessorConversionException.", e);
- throw new ToolException(
- "Invalid import data format for activity "
- + chat.getTitle()
- + "- WDDX caused an exception. Some data from the design will have been lost. See log for more details.");
+ throw new ToolException("Invalid import data format for activity " + chat.getTitle()
+ + "- WDDX caused an exception. Some data from the design will have been lost. See log for more details.");
}
chatDAO.saveOrUpdate(chat);
@@ -738,8 +792,9 @@
/**
* Set the description, throws away the title value as this is not supported in 2.0
*/
- public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException,
- DataMissingException {
+ @Override
+ public void setReflectiveData(Long toolContentId, String title, String description)
+ throws ToolException, DataMissingException {
Chat chat = getChatByContentId(toolContentId);
if (chat == null) {
@@ -759,6 +814,7 @@
chatOutputFactory = notebookOutputFactory;
}
+ @Override
public String createConditionName(Collection existingConditions) {
String uniqueNumber = null;
do {
@@ -773,12 +829,14 @@
return getChatOutputFactory().buildUserMessagesConditionName(uniqueNumber);
}
+ @Override
public void deleteCondition(ChatCondition condition) {
if ((condition != null) && (condition.getConditionId() != null)) {
chatDAO.delete(condition);
}
}
+ @Override
public void releaseConditionsFromCache(Chat chat) {
if (chat.getConditions() != null) {
for (ChatCondition condition : chat.getConditions()) {
@@ -787,19 +845,21 @@
}
}
+ @Override
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return getChatOutputFactory().getSupportedDefinitionClasses(definitionType);
}
// =========================================================================================
-
+
// ****************** REST methods *************************
- /** Used by the Rest calls to create content.
- * Mandatory fields in toolContentJSON: title, instructions
- * Optional fields reflectInstructions, lockWhenFinished, filterKeywords
+ /**
+ * Used by the Rest calls to create content. Mandatory fields in toolContentJSON: title, instructions Optional
+ * fields reflectInstructions, lockWhenFinished, filterKeywords
*/
@Override
- public void createRestToolContent(Integer userID, Long toolContentID, JSONObject toolContentJSON) throws JSONException {
+ public void createRestToolContent(Integer userID, Long toolContentID, JSONObject toolContentJSON)
+ throws JSONException {
Chat content = new Chat();
Date updateDate = new Date();
@@ -809,15 +869,15 @@
content.setTitle(toolContentJSON.getString(RestTags.TITLE));
content.setInstructions(toolContentJSON.getString(RestTags.INSTRUCTIONS));
content.setCreateBy(userID.longValue());
-
+
content.setContentInUse(false);
content.setDefineLater(false);
content.setReflectInstructions((String) JsonUtil.opt(toolContentJSON, RestTags.REFLECT_INSTRUCTIONS, null));
content.setReflectOnActivity(JsonUtil.opt(toolContentJSON, RestTags.REFLECT_ON_ACTIVITY, Boolean.FALSE));
content.setLockOnFinished(JsonUtil.opt(toolContentJSON, RestTags.LOCK_WHEN_FINISHED, Boolean.FALSE));
-
+
String filterKeywords = JsonUtil.opt(toolContentJSON, "filterKeywords", null);
- content.setFilteringEnabled(filterKeywords != null && filterKeywords.length()>0);
+ content.setFilteringEnabled((filterKeywords != null) && (filterKeywords.length() > 0));
content.setFilterKeywords(filterKeywords);
// submissionDeadline is set in monitoring
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java
===================================================================
diff -u -ra789c1395e0f8c1f0ded10147c464574c979b69c -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision a789c1395e0f8c1f0ded10147c464574c979b69c)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -77,7 +77,6 @@
import org.lamsfoundation.lams.tool.daco.model.DacoUser;
import org.lamsfoundation.lams.tool.daco.util.DacoToolContentHandler;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
import org.lamsfoundation.lams.usermanagement.User;
@@ -190,8 +189,8 @@
try {
repositoryService.deleteVersion(ticket, fileUuid, fileVersionId);
} catch (Exception e) {
- throw new DacoApplicationException("Exception occured while deleting files from" + " the repository "
- + e.getMessage());
+ throw new DacoApplicationException(
+ "Exception occured while deleting files from" + " the repository " + e.getMessage());
}
}
@@ -220,13 +219,14 @@
}
@Override
- public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException,
- ToolException {
+ public ToolSessionExportOutputData exportToolSession(List toolSessionIds)
+ throws DataMissingException, ToolException {
return null;
}
@Override
- public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException {
+ public ToolSessionExportOutputData exportToolSession(Long toolSessionId)
+ throws DataMissingException, ToolException {
return null;
}
@@ -252,7 +252,7 @@
DacoUser user = getUser(userUid);
Set answers = user.getAnswers();
List> result = new LinkedList>();
- if (answers != null && answers.size() > 0) {
+ if ((answers != null) && (answers.size() > 0)) {
int recordId = 1;
@@ -320,7 +320,7 @@
@Override
public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) {
List list = coreNotebookService.getEntry(sessionId, idType, signature, userID);
- if (list == null || list.isEmpty()) {
+ if ((list == null) || list.isEmpty()) {
return null;
} else {
return list.get(0);
@@ -339,8 +339,8 @@
String fileName = file.getFileName();
String fileType = file.getContentType();
// For file only upload one sigle file
- if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE
- || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) {
+ if ((answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE)
+ || (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE)) {
NodeKey nodeKey = processFile(file);
answer.setFileUuid(nodeKey.getUuid());
answer.setFileVersionId(nodeKey.getVersion());
@@ -408,13 +408,13 @@
return getFile(answer.getFileUuid(), answer.getFileVersionId(), relPathString);
}
-
+
@Override
public Integer getGroupRecordCount(Long sessionId) {
List users = dacoUserDao.getBySessionId(sessionId);
-
+
Integer groupRecordCount = 0;
- for (DacoUser user: users) {
+ for (DacoUser user : users) {
groupRecordCount += dacoAnswerDao.getUserRecordCount(user.getUserId(), sessionId);
}
return groupRecordCount;
@@ -449,15 +449,16 @@
List users = dacoUserDao.getBySessionId(session.getSessionId());
List monitoringUsers = new ArrayList(users.size());
for (DacoUser user : users) {
- MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(), user.getUserId()
- .intValue(), user.getLastName() + " " + user.getFirstName(), user.getLoginName());
+ MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(),
+ user.getUserId().intValue(), user.getLastName() + " " + user.getFirstName(),
+ user.getLoginName());
List> records = getDacoAnswersByUserUid(user.getUid());
/*
* If the user provided as "userUid" matches current user UID, the summary is filled with additional
* data. NULL matches all users. UID < 0 matches no users, so only the brief description of users is
* filled in.
*/
- if (userUid == null || userUid.equals(user.getUid())) {
+ if ((userUid == null) || userUid.equals(user.getUid())) {
monitoringUser.setRecords(records);
NotebookEntry entry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL,
DacoConstants.TOOL_SIGNATURE, user.getUserId().intValue());
@@ -503,8 +504,8 @@
QuestionSummaryDTO summary = new QuestionSummaryDTO();
summary.setQuestionUid(question.getUid());
for (int answerOption = 0; answerOption < answerOptionCount; answerOption++) {
- QuestionSummarySingleAnswerDTO singleAnswer = new QuestionSummarySingleAnswerDTO(String
- .valueOf(answerOption + 1), null, "0%", "0");
+ QuestionSummarySingleAnswerDTO singleAnswer = new QuestionSummarySingleAnswerDTO(
+ String.valueOf(answerOption + 1), null, "0%", "0");
summary.addUserSummarySingleAnswer(answerOption, singleAnswer);
singleAnswer = (QuestionSummarySingleAnswerDTO) singleAnswer.clone();
summary.addGroupSummarySingleAnswer(answerOption, singleAnswer);
@@ -521,14 +522,14 @@
}
return result;
}
-
+
@Override
public void notifyTeachersOnLearnerEntry(Long sessionId, DacoUser dacoUser) {
String userName = dacoUser.getLastName() + " " + dacoUser.getFirstName();
String message = getLocalisedMessage("event.learnerentry.body", new Object[] { userName });
eventNotificationService.notifyLessonMonitors(sessionId, message, false);
}
-
+
@Override
public void notifyTeachersOnRecordSumbit(Long sessionId, DacoUser dacoUser) {
String userName = dacoUser.getLastName() + " " + dacoUser.getFirstName();
@@ -586,10 +587,10 @@
public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) {
return dacoOutputFactory.getToolOutput(name, this, toolSessionId, learnerId);
}
-
+
@Override
public void forceCompleteUser(Long toolSessionId, User user) {
- //no actions required
+ // no actions required
}
@Override
@@ -610,12 +611,12 @@
public String getToolContentTitle(Long toolContentId) {
return getDacoByContentId(toolContentId).getTitle();
}
-
+
@Override
public boolean isContentEdited(Long toolContentId) {
return getDacoByContentId(toolContentId).isDefineLater();
}
-
+
@Override
public DacoUser getUser(Long uid) {
return (DacoUser) dacoUserDao.getObject(DacoUser.class, uid);
@@ -634,18 +635,19 @@
/*
* ===============Methods implemented from ToolContentImport102Manager ===============
*/
+ @Override
public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion,
String toVersion) throws ToolException {
try {
// register version filter class
exportContentService.registerImportVersionFilterClass(DacoImportContentVersionFilter.class);
-
+
Object toolPOJO = exportContentService.importToolContent(toolContentPath, dacoToolContentHandler,
fromVersion, toVersion);
if (!(toolPOJO instanceof Daco)) {
- throw new ImportToolContentException("Import Share daco tool content failed. Deserialized object is "
- + toolPOJO);
+ throw new ImportToolContentException(
+ "Import Share daco tool content failed. Deserialized object is " + toolPOJO);
}
Daco toolContentObj = (Daco) toolPOJO;
@@ -674,6 +676,7 @@
}
}
+ @Override
public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException {
if (toolSessionId == null) {
DacoServiceImpl.log.error("Fail to leave tool Session based on null tool session id.");
@@ -696,7 +699,8 @@
}
return learnerService.completeToolSession(toolSessionId, learnerId);
}
-
+
+ @Override
public boolean isGroupedActivity(long toolContentID) {
return toolService.isGroupedActivity(toolContentID);
}
@@ -716,7 +720,7 @@
*/
private NodeKey processFile(FormFile file) throws UploadDacoFileException {
NodeKey node = null;
- if (file != null && !StringUtils.isEmpty(file.getFileName())) {
+ if ((file != null) && !StringUtils.isEmpty(file.getFileName())) {
String fileName = file.getFileName();
try {
node = dacoToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType());
@@ -745,34 +749,45 @@
return node;
}
+ @Override
public void releaseAnswersFromCache(Collection answers) {
for (DacoAnswer answer : answers) {
dacoAnswerDao.releaseFromCache(answer);
}
}
+ @Override
public void releaseDacoFromCache(Daco daco) {
dacoDao.releaseFromCache(daco);
for (DacoQuestion question : daco.getDacoQuestions()) {
dacoQuestionDao.releaseFromCache(question);
}
}
- public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException,
- ToolException {
+ @Override
+ public void removeToolContent(Long toolContentId) throws ToolException {
Daco daco = dacoDao.getByContentId(toolContentId);
- if (removeSessionData) {
- List list = dacoSessionDao.getByContentId(toolContentId);
- for (DacoSession session : list) {
- dacoSessionDao.deleteBySessionId(session.getSessionId());
+ if (daco == null) {
+ DacoServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId);
+ return;
+ }
+
+ for (DacoSession session : dacoSessionDao.getByContentId(toolContentId)) {
+ List entries = coreNotebookService.getEntry(session.getSessionId(),
+ CoreNotebookConstants.NOTEBOOK_TOOL, DacoConstants.TOOL_SIGNATURE);
+ for (NotebookEntry entry : entries) {
+ coreNotebookService.deleteEntry(entry);
}
}
+
dacoDao.removeObject(Daco.class, daco.getUid());
}
+ @Override
public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException {
- if (log.isDebugEnabled()) {
- log.debug("Removing Daco data for user ID " + userId + " and toolContentId " + toolContentId);
+ if (DacoServiceImpl.log.isDebugEnabled()) {
+ DacoServiceImpl.log
+ .debug("Removing Daco data for user ID " + userId + " and toolContentId " + toolContentId);
}
List sessions = dacoSessionDao.getByContentId(toolContentId);
for (DacoSession session : sessions) {
@@ -799,15 +814,18 @@
}
}
}
-
+
+ @Override
public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException {
dacoSessionDao.deleteBySessionId(toolSessionId);
}
+ @Override
public void saveOrUpdateAnswer(DacoAnswer answer) {
dacoAnswerDao.saveObject(answer);
}
+ @Override
public void saveOrUpdateDaco(Daco daco) {
dacoDao.saveObject(daco);
}
@@ -816,6 +834,7 @@
dacoQuestionDao.saveObject(question);
}
+ @Override
public void saveOrUpdateDacoSession(DacoSession resSession) {
dacoSessionDao.saveObject(resSession);
}
@@ -836,11 +855,11 @@
public ICoreNotebookService getCoreNotebookService() {
return coreNotebookService;
}
-
+
public IUserManagementService getUserManagementService() {
return userManagementService;
}
-
+
public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
this.coreNotebookService = coreNotebookService;
}
@@ -905,6 +924,7 @@
this.eventNotificationService = eventNotificationService;
}
+ @Override
public int getRecordNum(Long userID, Long sessionId) {
return dacoAnswerDao.getUserRecordCount(userID, sessionId);
}
@@ -917,6 +937,7 @@
this.dacoOutputFactory = dacoOutputFactory;
}
+ @Override
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return getDacoOutputFactory().getSupportedDefinitionClasses(definitionType);
}
Index: lams_tool_eadventure/src/java/org/eucm/lams/tool/eadventure/service/EadventureServiceImpl.java
===================================================================
diff -u -ra789c1395e0f8c1f0ded10147c464574c979b69c -r9aad33f52b06632e7a8ed3705a7708338bcc00f8
--- lams_tool_eadventure/src/java/org/eucm/lams/tool/eadventure/service/EadventureServiceImpl.java (.../EadventureServiceImpl.java) (revision a789c1395e0f8c1f0ded10147c464574c979b69c)
+++ lams_tool_eadventure/src/java/org/eucm/lams/tool/eadventure/service/EadventureServiceImpl.java (.../EadventureServiceImpl.java) (revision 9aad33f52b06632e7a8ed3705a7708338bcc00f8)
@@ -41,7 +41,6 @@
import java.util.SortedMap;
import java.util.TreeSet;
-import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.upload.FormFile;
import org.eucm.lams.tool.eadventure.EadventureConstants;
@@ -98,7 +97,6 @@
import org.lamsfoundation.lams.tool.ToolSessionExportOutputData;
import org.lamsfoundation.lams.tool.ToolSessionManager;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
import org.lamsfoundation.lams.usermanagement.User;
@@ -117,24 +115,24 @@
* @author Dapeng.Ni
*
*/
-public class EadventureServiceImpl implements IEadventureService, ToolContentManager, ToolSessionManager,
- ToolContentImport102Manager {
+public class EadventureServiceImpl
+ implements IEadventureService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager {
static Logger log = Logger.getLogger(EadventureServiceImpl.class.getName());
private EadventureDAO eadventureDao;
private EadventureUserDAO eadventureUserDao;
private EadventureSessionDAO eadventureSessionDao;
-
+
private EadventureItemVisitDAO eadventureItemVisitDao;
-
+
private EadventureVarsDAO eadventureVarsDao;
-
+
private EadventureParamDAO eadventureParamDao;
-
+
private EadventureConditionDAO eadventureConditionDao;
-
+
private EadventureExpressionDAO eadventureExpressionDao;
// tool service
@@ -160,14 +158,12 @@
private IEventNotificationService eventNotificationService;
private ILessonService lessonService;
-
+
private IGradebookService gradebookService;
private EadventureOutputFactory eadventureOutputFactory;
-
-
-
+ @Override
public IVersionedNode getFileNode(Long itemUid, String relPathString) throws EadventureApplicationException {
Eadventure ead = (Eadventure) eadventureDao.getObject(Eadventure.class, itemUid);
if (ead == null) {
@@ -191,7 +187,8 @@
* @return file node
* @throws ImscpApplicationException
*/
- private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws EadventureApplicationException {
+ private IVersionedNode getFile(Long uuid, Long versionId, String relativePath)
+ throws EadventureApplicationException {
ITicket tic = getRepositoryLoginTicket();
@@ -219,8 +216,8 @@
}
/**
- * This method verifies the credentials of the Eadventure Tool and gives it the Ticket
to login
- * and access the Content Repository.
+ * This method verifies the credentials of the Eadventure Tool and gives it the Ticket
to login and
+ * access the Content Repository.
*
* A valid ticket is needed in order to access the content from the repository. This method would be called evertime
* the tool needs to upload/download files from the content repository.
@@ -232,8 +229,8 @@
ICredentials credentials = new SimpleCredentials(eadventureToolContentHandler.getRepositoryUser(),
eadventureToolContentHandler.getRepositoryId());
try {
- ITicket ticket = repositoryService.login(credentials, eadventureToolContentHandler
- .getRepositoryWorkspaceName());
+ ITicket ticket = repositoryService.login(credentials,
+ eadventureToolContentHandler.getRepositoryWorkspaceName());
return ticket;
} catch (AccessDeniedException ae) {
throw new EadventureApplicationException("Access Denied to repository." + ae.getMessage());
@@ -244,11 +241,13 @@
}
}
+ @Override
public Eadventure getEadventureByContentId(Long contentId) {
Eadventure rs = eadventureDao.getByContentId(contentId);
return rs;
}
+ @Override
public Eadventure getDefaultContent(Long contentId) throws EadventureApplicationException {
if (contentId == null) {
String error = messageService.getMessage("error.msg.default.content.not.find");
@@ -263,82 +262,93 @@
return content;
}
- //TODO revisar
- /* public List getAuthoredItems(Long eadventureUid) {
- return eadventureItemDao.getAuthoringItems(eadventureUid);
+ // TODO revisar
+ /* public List getAuthoredItems(Long eadventureUid) {
+ return eadventureItemDao.getAuthoringItems(eadventureUid);
}*/
+ @Override
public void createUser(EadventureUser eadventureUser) {
eadventureUserDao.saveObject(eadventureUser);
}
+ @Override
public EadventureUser getUserByIDAndContent(Long userId, Long contentId) {
return eadventureUserDao.getUserByUserIDAndContentID(userId, contentId);
}
+ @Override
public EadventureUser getUserByIDAndSession(Long userId, Long sessionId) {
return eadventureUserDao.getUserByUserIDAndSessionID(userId, sessionId);
}
+ @Override
public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws EadventureApplicationException {
ITicket ticket = getRepositoryLoginTicket();
try {
repositoryService.deleteVersion(ticket, fileUuid, fileVersionId);
} catch (Exception e) {
- throw new EadventureApplicationException("Exception occured while deleting files from" + " the repository "
- + e.getMessage());
+ throw new EadventureApplicationException(
+ "Exception occured while deleting files from" + " the repository " + e.getMessage());
}
}
+ @Override
public void saveOrUpdateEadventure(Eadventure eadventure) {
eadventureDao.saveObject(eadventure);
}
-
-
+
+ @Override
public void saveOrUpdateEadventureExpressions(Set eadExpressions, Long condUID) {
- Iterator it = eadExpressions.iterator();
- while (it.hasNext()){
- EadventureExpression expression = it.next();
- // expression.setCondition_uid(condUID);
- eadventureExpressionDao.saveObject(expression);
- }
+ Iterator it = eadExpressions.iterator();
+ while (it.hasNext()) {
+ EadventureExpression expression = it.next();
+ // expression.setCondition_uid(condUID);
+ eadventureExpressionDao.saveObject(expression);
+ }
}
-
+
+ @Override
public void saveOrUpdateEadventureExpression(EadventureExpression eadExpression) {
eadventureExpressionDao.saveObject(eadExpression);
}
-
+
+ @Override
public void saveOrUpdateEadventureCondition(EadventureCondition eadCondition) {
eadventureConditionDao.saveObject(eadCondition);
}
-
+
+ @Override
public void saveOrUpdateEadventureConditions(Set eadConditions) {
Iterator it = eadConditions.iterator();
- while (it.hasNext()){
+ while (it.hasNext()) {
EadventureCondition cond = it.next();
- // Set expList = cond.getEadListExpression();
- // cond.setEadListExpression(null);
+ // Set expList = cond.getEadListExpression();
+ // cond.setEadListExpression(null);
eadventureConditionDao.saveObject(cond);
- // saveOrUpdateEadventureExpressions(expList, cond.getUid());
- // cond.setEadListExpression(expList);
+ // saveOrUpdateEadventureExpressions(expList, cond.getUid());
+ // cond.setEadListExpression(expList);
}
-}
-
+ }
+
+ @Override
public void deleteEadventureCondition(Long conditionUid) {
eadventureConditionDao.removeObject(EadventureCondition.class, conditionUid);
}
-
+
+ @Override
public void deleteEadventureExpression(Long expressionUid) {
eadventureExpressionDao.removeObject(EadventureExpression.class, expressionUid);
}
-
- //TODO revisar!!!!!! Monitoring
+
+ // TODO revisar!!!!!! Monitoring
+ @Override
public List exportBySessionId(Long sessionId, Long userId) {
EadventureSession session = eadventureSessionDao.getSessionBySessionId(sessionId);
if (session == null) {
@@ -350,87 +360,85 @@
Eadventure ead = session.getEadventure();
Summary sum = new Summary(session.getSessionId(), session.getSessionName(), ead, false);
-
-
- //List userList = getUserListBySessionItem(session.getSessionId(), ead.getUid());
+ // List userList = getUserListBySessionItem(session.getSessionId(), ead.getUid());
boolean[] existList = new boolean[1];
String[] reportList = new String[1];
-
- EadventureUser eadUser = eadventureUserDao.getUserByUserIDAndSessionID(userId,sessionId);
- //TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem)
+
+ EadventureUser eadUser = eadventureUserDao.getUserByUserIDAndSessionID(userId, sessionId);
+ // TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem)
EadventureItemVisitLog log = getEadventureItemLog(ead.getUid(), userId);
eadUser.setAccessDate(log.getAccessDate());
EadventureVars var = getEadventureVars(log.getUid(), EadventureConstants.VAR_NAME_REPORT);
-
- if (var!=null){
- existList[0]=true;
- reportList[0]=var.getValue();
- }else{
- existList[0]=false;
- reportList[0]=null;
+ if (var != null) {
+ existList[0] = true;
+ reportList[0] = var.getValue();
+ } else {
+ existList[0] = false;
+ reportList[0] = null;
}
-
ArrayList userList = new ArrayList();
userList.add(eadUser);
sum.setUsers(userList);
sum.setExistList(existList);
sum.setReportList(reportList);
-
-
- //TODO ver si tiene sentido que sea una lista
+
+ // TODO ver si tiene sentido que sea una lista
ArrayList list = new ArrayList();
list.add(sum);
-
+
return list;
}
- //TODO revisar!!!!!! Monitoring
+
+ // TODO revisar!!!!!! Monitoring
+ @Override
public List exportByContentId(Long contentId) {
Eadventure eadventure = eadventureDao.getByContentId(contentId);
List groupList = new ArrayList();
// session by session
List sessionList = eadventureSessionDao.getByContentId(contentId);
for (EadventureSession session : sessionList) {
-
+
Summary sum = new Summary(session.getSessionId(), session.getSessionName(), session.getEadventure(), false);
-
+
List userList = getUserListBySessionItem(session.getSessionId(), eadventure.getUid());
- boolean[] existList = new boolean[userList.size()];
- String[] reportList = new String[userList.size()];
- int numberOfFinishedLearners = 0;
- int i=0;
- for (EadventureUser eadUser : userList){
- //TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem)
+ boolean[] existList = new boolean[userList.size()];
+ String[] reportList = new String[userList.size()];
+ int numberOfFinishedLearners = 0;
+ int i = 0;
+ for (EadventureUser eadUser : userList) {
+ // TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem)
EadventureItemVisitLog log = getEadventureItemLog(eadventure.getUid(), eadUser.getUserId());
-
+
EadventureVars var = getEadventureVars(log.getUid(), EadventureConstants.VAR_NAME_REPORT);
-
- if (log.isComplete())
+
+ if (log.isComplete()) {
numberOfFinishedLearners++;
+ }
- if (var!=null){
- existList[i]=true;
- reportList[i]=var.getValue();
- }else{
- existList[i]=false;
- reportList[i]=null;
+ if (var != null) {
+ existList[i] = true;
+ reportList[i] = var.getValue();
+ } else {
+ existList[i] = false;
+ reportList[i] = null;
}
i++;
-
- }
- sum.setUsers(userList);
- sum.setExistList(existList);
- sum.setReportList(reportList);
-
-
+
+ }
+ sum.setUsers(userList);
+ sum.setExistList(existList);
+ sum.setReportList(reportList);
+
groupList.add(sum);
}
return groupList;
}
+ @Override
public Eadventure getEadventureBySessionId(Long sessionId) {
EadventureSession session = eadventureSessionDao.getSessionBySessionId(sessionId);
// to skip CGLib problem
@@ -439,26 +447,28 @@
return res;
}
+ @Override
public EadventureSession getEadventureSessionBySessionId(Long sessionId) {
return eadventureSessionDao.getSessionBySessionId(sessionId);
}
+ @Override
public void saveOrUpdateEadventureSession(EadventureSession resSession) {
eadventureSessionDao.saveObject(resSession);
}
- /* public void retrieveComplete(SortedSet eadventureItemList, EadventureUser user) {
- for (EadventureItem item : eadventureItemList) {
- EadventureItemVisitLog log = eadventureItemVisitDao.getEadventureItemLog(item.getUid(), user.getUserId());
- if (log == null) {
- item.setComplete(false);
- } else {
- item.setComplete(log.isComplete());
- }
- }
+ /* public void retrieveComplete(SortedSet eadventureItemList, EadventureUser user) {
+ for (EadventureItem item : eadventureItemList) {
+ EadventureItemVisitLog log = eadventureItemVisitDao.getEadventureItemLog(item.getUid(), user.getUserId());
+ if (log == null) {
+ item.setComplete(false);
+ } else {
+ item.setComplete(log.isComplete());
+ }
+ }
}*/
-
+ @Override
public void setItemComplete(Long eadventureItemUid, Long userId, Long sessionId) {
EadventureItemVisitLog log = eadventureItemVisitDao.getEadventureItemLog(eadventureItemUid, userId);
if (log == null) {
@@ -474,29 +484,33 @@
eadventureItemVisitDao.saveObject(log);
}
+ @Override
public void setItemAccess(Long eadventureItemUid, Long userId, Long sessionId) {
EadventureItemVisitLog log = eadventureItemVisitDao.getEadventureItemLog(eadventureItemUid, userId);
EadventureServiceImpl.log.error("Set item acces!!!!!");
-
+
if (log == null) {
log = new EadventureItemVisitLog();
Eadventure item = eadventureDao.getByUid(eadventureItemUid);
log.setEadventure(item);
EadventureServiceImpl.log.error("El id de usuario es " + userId);
- EadventureServiceImpl.log.error("USER ID "+userId);
- EadventureServiceImpl.log.error("SESSION ID "+sessionId);
+ EadventureServiceImpl.log.error("USER ID " + userId);
+ EadventureServiceImpl.log.error("SESSION ID " + sessionId);
EadventureUser user = eadventureUserDao.getUserByUserIDAndSessionID(userId, sessionId);
- if (user==null)
+ if (user == null) {
EadventureServiceImpl.log.error("NOS DA NULL!!!!!!!");
+ }
log.setUser(user);
log.setComplete(false);
log.setSessionId(sessionId);
log.setAccessDate(new Timestamp(new Date().getTime()));
eadventureItemVisitDao.saveObject(log);
- } else
+ } else {
EadventureServiceImpl.log.error("NO ES NULL!!!");
+ }
}
+ @Override
public String finishToolSession(Long toolSessionId, Long userId) throws EadventureApplicationException {
EadventureUser user = eadventureUserDao.getUserByUserIDAndSessionID(userId, toolSessionId);
user.setSessionFinished(true);
@@ -516,8 +530,9 @@
}
return nextUrl;
}
-
- //TODO revisar!!!! monitoring
+
+ // TODO revisar!!!! monitoring
+ @Override
public List getSummary(Long contentId) {
List groupList = new ArrayList();
@@ -529,45 +544,48 @@
List sessionList = eadventureSessionDao.getByContentId(contentId);
for (EadventureSession session : sessionList) {
// one new group for one session.
- // so far no any ead available, so just put session name info to Summary
+ // so far no any ead available, so just put session name info to Summary
Summary sum = new Summary(session.getSessionId(), session.getSessionName(), session.getEadventure());
// set viewNumber according visit log
- if (visitCountMap.containsKey(eadventure.getUid())) {
- sum.setViewNumber(visitCountMap.get(eadventure.getUid()).intValue());
- }
- List userList = getUserListBySessionItem(session.getSessionId(), eadventure.getUid());
- boolean[] existList = new boolean[userList.size()];
- int numberOfFinishedLearners = 0;
- int i=0;
- for (EadventureUser eadUser : userList){
- //TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem)
+ if (visitCountMap.containsKey(eadventure.getUid())) {
+ sum.setViewNumber(visitCountMap.get(eadventure.getUid()).intValue());
+ }
+ List userList = getUserListBySessionItem(session.getSessionId(), eadventure.getUid());
+ boolean[] existList = new boolean[userList.size()];
+ int numberOfFinishedLearners = 0;
+ int i = 0;
+ for (EadventureUser eadUser : userList) {
+ // TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem)
EadventureItemVisitLog log = getEadventureItemLog(eadventure.getUid(), eadUser.getUserId());
-
+
EadventureVars var = getEadventureVars(log.getUid(), EadventureConstants.VAR_NAME_REPORT);
-
- if (log.isComplete())
+
+ if (log.isComplete()) {
numberOfFinishedLearners++;
+ }
- if (var!=null)
- existList[i]=true;
- else
- existList[i]=false;
-
- i++;
-
+ if (var != null) {
+ existList[i] = true;
+ } else {
+ existList[i] = false;
}
- sum.setUsers(userList);
- sum.setExistList(existList);
- sum.setNumberOfLearners(userList.size());
- sum.setNumberOfFinishedLearners(numberOfFinishedLearners);
-
- groupList.add(sum);
+
+ i++;
+
+ }
+ sum.setUsers(userList);
+ sum.setExistList(existList);
+ sum.setNumberOfLearners(userList.size());
+ sum.setNumberOfFinishedLearners(numberOfFinishedLearners);
+
+ groupList.add(sum);
}
-
+
return groupList;
}
+ @Override
public Map> getReflectList(Long contentId, boolean setEntry) {
Map> map = new HashMap>();
@@ -598,6 +616,7 @@
return map;
}
+ @Override
public List getUserListBySessionItem(Long sessionId, Long itemUid) {
List logList = eadventureItemVisitDao.getEadventureItemLogBySession(sessionId, itemUid);
List userList = new ArrayList(logList.size());
@@ -606,11 +625,12 @@
user.setAccessDate(visit.getAccessDate());
userList.add(user);
}
- //List userList = null;
+ // List userList = null;
return userList;
}
- //TODO revisar Monitoring!!!
+ // TODO revisar Monitoring!!!
+ @Override
public void setItemVisible(Long itemUid, boolean visible) {
/*EadventureItem item = eadventureItemDao.getByUid(itemUid);
if (item != null) {
@@ -631,15 +651,17 @@
}*/
}
+ @Override
public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId,
String entryText) {
return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "",
entryText);
}
+ @Override
public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) {
List list = coreNotebookService.getEntry(sessionId, idType, signature, userID);
- if (list == null || list.isEmpty()) {
+ if ((list == null) || list.isEmpty()) {
return null;
} else {
return list.get(0);
@@ -649,10 +671,12 @@
/**
* @param notebookEntry
*/
+ @Override
public void updateEntry(NotebookEntry notebookEntry) {
coreNotebookService.updateEntry(notebookEntry);
}
+ @Override
public EadventureUser getUser(Long uid) {
return (EadventureUser) eadventureUserDao.getObject(EadventureUser.class, uid);
}
@@ -694,74 +718,78 @@
}
return node;
}
-
- public void saveOrUpdateEadventureParams(Set eadParams){
+
+ @Override
+ public void saveOrUpdateEadventureParams(Set eadParams) {
Iterator it = eadParams.iterator();
- while (it.hasNext()){
+ while (it.hasNext()) {
EadventureParam param = it.next();
eadventureParamDao.saveObject(param);
}
}
-
- public void removeParam(EadventureParam eadParams){
- eadventureParamDao.delete(eadParams);
+
+ @Override
+ public void removeParam(EadventureParam eadParams) {
+ eadventureParamDao.delete(eadParams);
}
-
+ @Override
public void uploadEadventureFile(Eadventure ead, FormFile file) throws UploadEadventureFileException {
try {
InputStream is = file.getInputStream();
String fileName = file.getFileName();
String fileType = file.getContentType();
-
+
// need unzip upload, and parse learning object information from XML file.
-
- String packageDirectory = ZipFileUtil.expandZip(is, fileName);
- log.error("Direcci�n del zip: "+packageDirectory);
- IContentPackageConverter cpConverter = new SimpleContentPackageConverter(packageDirectory);
- String initFile = cpConverter.getDefaultItem();
- ead.setImsSchema(cpConverter.getSchema());
- ead.setOrganizationXml(cpConverter.getOrganzationXML());
- ead.setInitialItem(initFile);
- // upload package
- NodeKey nodeKey = processPackage(packageDirectory, initFile);
- ead.setFileUuid(nodeKey.getUuid());
- ead.setFileVersionId(nodeKey.getVersion());
-
+
+ String packageDirectory = ZipFileUtil.expandZip(is, fileName);
+ EadventureServiceImpl.log.error("Direcci�n del zip: " + packageDirectory);
+ IContentPackageConverter cpConverter = new SimpleContentPackageConverter(packageDirectory);
+ String initFile = cpConverter.getDefaultItem();
+ ead.setImsSchema(cpConverter.getSchema());
+ ead.setOrganizationXml(cpConverter.getOrganzationXML());
+ ead.setInitialItem(initFile);
+ // upload package
+ NodeKey nodeKey = processPackage(packageDirectory, initFile);
+ ead.setFileUuid(nodeKey.getUuid());
+ ead.setFileVersionId(nodeKey.getVersion());
+
// create the package from the directory contents
- ead.setFileType(fileType);
- ead.setFileName(fileName);
-
+ ead.setFileType(fileType);
+ ead.setFileName(fileName);
+
// parse parameters.xml file, and create the eadParams
- //TODO reportar bien el error cuando no se produce xk no es un e-Ad file
- HashMap params = InputOutputReader.getOutputParameterList(packageDirectory+"//"+EadventureConstants.PARAMETERS_FILE_NAME);
- // chek if its a real e-adventure package
-
- if (! new File(packageDirectory+"//"+EadventureConstants.PARAMETERS_FILE_NAME).exists()){
- EadventureServiceImpl.log.error(messageService.getMessage("error.msg.ims.package") + " : "
- + "No eAdventure game!! ");
- throw new UploadEadventureFileException(messageService.getMessage("error.msg.ims.package"));
- }
- Iterator it = params.keySet().iterator();
- Set eadParam = new HashSet();
- while (it.hasNext()){
- EadventureParam param = new EadventureParam();
- String key = it.next();
- param.setInput(false);
- param.setName(key);
- param.setType(params.get(key));
- // eadventureParamDao.saveObject(param);
- eadParam.add(param);
- log.error(key+" ha sido subido con exito!!!!!!");
-
- }
- //add default params (this are not included in the params file at eAd LAMS export due to they always have to appear)
- eadParam.addAll(getDefaultParams());
- ead.setParams(eadParam);
-
+ // TODO reportar bien el error cuando no se produce xk no es un e-Ad file
+ HashMap params = InputOutputReader
+ .getOutputParameterList(packageDirectory + "//" + EadventureConstants.PARAMETERS_FILE_NAME);
+ // chek if its a real e-adventure package
+
+ if (!new File(packageDirectory + "//" + EadventureConstants.PARAMETERS_FILE_NAME).exists()) {
+ EadventureServiceImpl.log
+ .error(messageService.getMessage("error.msg.ims.package") + " : " + "No eAdventure game!! ");
+ throw new UploadEadventureFileException(messageService.getMessage("error.msg.ims.package"));
+ }
+ Iterator it = params.keySet().iterator();
+ Set