Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/BurningQuestionLike.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieBurningQuestion.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieConfigItem.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/org/lamsfoundation/lams/tool/scratchie/model/ScratchieUser.hbm.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java (.../BurningQuestionLikeDAOHibernate.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java (.../BurningQuestionLikeDAOHibernate.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -12,17 +12,16 @@ @Override public boolean addLike(Long burningQuestionUid, Long sessionId) { - int status = getSession().createSQLQuery(INSERT_LIKE).setParameter("burningQuestionUid", burningQuestionUid) + int status = getSession().createNativeQuery(INSERT_LIKE).setParameter("burningQuestionUid", burningQuestionUid) .setParameter("sessionId", sessionId).executeUpdate(); return status == 1; } @Override public void removeLike(Long burningQuestionUid, Long sessionId) { + final String FIND_BY_SESSION_AND_BURNING_QUESTION = "FROM " + BurningQuestionLike.class.getName() + + " AS l WHERE l.sessionId=? AND l.burningQuestion.uid = ?"; - final String FIND_BY_SESSION_AND_BURNING_QUESTION = "from " + BurningQuestionLike.class.getName() - + " as l where l.sessionId=? and l.burningQuestion.uid = ?"; - List list = find(FIND_BY_SESSION_AND_BURNING_QUESTION, new Object[] { sessionId, burningQuestionUid }); if (list == null || list.size() == 0) { Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieConfigItemDAOHibernate.java =================================================================== diff -u -rceb74e3b4097cf6461280448f904fa21a176aaa4 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieConfigItemDAOHibernate.java (.../ScratchieConfigItemDAOHibernate.java) (revision ceb74e3b4097cf6461280448f904fa21a176aaa4) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieConfigItemDAOHibernate.java (.../ScratchieConfigItemDAOHibernate.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -30,14 +30,13 @@ @Repository public class ScratchieConfigItemDAOHibernate extends LAMSBaseDAO implements ScratchieConfigItemDAO { - private static final String LOAD_CONFIG_ITEM_BY_KEY = "from ScratchieConfigItem configuration" - + " where configuration.configKey=:key"; + private static final String LOAD_CONFIG_ITEM_BY_KEY = "FROM ScratchieConfigItem configuration" + + " WHERE configuration.configKey=:key"; @Override public ScratchieConfigItem getConfigItemByKey(final String configKey) { - return (ScratchieConfigItem) getSession().createQuery(LOAD_CONFIG_ITEM_BY_KEY).setParameter("key", configKey) - .uniqueResult(); - + return getSession().createQuery(LOAD_CONFIG_ITEM_BY_KEY, ScratchieConfigItem.class) + .setParameter("key", configKey).uniqueResult(); } @Override Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieSessionDAOHibernate.java =================================================================== diff -u -rceb74e3b4097cf6461280448f904fa21a176aaa4 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieSessionDAOHibernate.java (.../ScratchieSessionDAOHibernate.java) (revision ceb74e3b4097cf6461280448f904fa21a176aaa4) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieSessionDAOHibernate.java (.../ScratchieSessionDAOHibernate.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -83,33 +83,30 @@ public void deleteBySessionId(Long toolSessionId) { this.removeObject(ScratchieSession.class, toolSessionId); } - + @SuppressWarnings("unchecked") @Override public List getRawLeaderMarksByToolContentId(Long toolContentId) { - NativeQuery query = getSession().createNativeQuery(LOAD_MARKS); + NativeQuery query = getSession().createNativeQuery(LOAD_MARKS); query.setParameter("toolContentId", toolContentId); - List list = query.list(); - return list; + return (List) query.list(); } @Override public Object[] getStatsMarksForLeaders(Long toolContentId) { - NativeQuery query = getSession().createNativeQuery(FIND_MARK_STATS) + NativeQuery query = getSession().createNativeQuery(FIND_MARK_STATS) .addScalar("min_grade", FloatType.INSTANCE) .addScalar("avg_grade", FloatType.INSTANCE) .addScalar("max_grade", FloatType.INSTANCE) .addScalar("num_complete", IntegerType.INSTANCE); query.setParameter("toolContentId", toolContentId); - @SuppressWarnings("rawtypes") - List list = query.list(); + @SuppressWarnings("unchecked") + List list = (List) query.list(); if ((list == null) || (list.size() == 0)) { return null; } else { return (Object[]) list.get(0); } } - - } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/BurningQuestionLike.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/BurningQuestionLike.java (.../BurningQuestionLike.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/BurningQuestionLike.java (.../BurningQuestionLike.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -1,18 +1,33 @@ package org.lamsfoundation.lams.tool.scratchie.model; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + /** * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_burning_que_like") public class BurningQuestionLike { + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + + @ManyToOne + @JoinColumn(name = "burning_question_uid") private ScratchieBurningQuestion burningQuestion; + + @Column(name = "session_id") private Long sessionId; - /** - * - * @return Returns the log Uid. - */ public Long getUid() { return uid; } @@ -21,10 +36,6 @@ this.uid = uid; } - /** - * - * @return - */ public ScratchieBurningQuestion getBurningQuestion() { return burningQuestion; } @@ -33,10 +44,6 @@ this.burningQuestion = burningQuestion; } - /** - * - * @return - */ public Long getSessionId() { return sessionId; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.java (.../Scratchie.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.java (.../Scratchie.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -28,6 +28,17 @@ import java.util.Iterator; import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.log4j.Logger; @@ -37,61 +48,74 @@ * * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_scratchie") public class Scratchie implements Cloneable { - private static final Logger log = Logger.getLogger(Scratchie.class); - // key + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; - // tool contentID + @Column(name = "content_id") private Long contentId; + @Column private String title; + @Column private String instructions; // advance + @Column(name = "define_later") private boolean defineLater; // general infomation + + @Column(name = "create_date") private Date created; + @Column(name = "update_date") private Date updated; + @Column(name = "submission_deadline") private Date submissionDeadline; - // scratchie Items - private Set scratchieItems; + @OneToMany(cascade = CascadeType.ALL) + @OrderBy("order_id ASC") + @JoinColumn(name = "scratchie_uid") + private Set scratchieItems = new HashSet<>();; + @Column(name = "extra_point") private boolean extraPoint; + @Column(name = "burning_questions_enabled") private boolean burningQuestionsEnabled; + @Column(name = "shuffle_items") private boolean shuffleItems; + @Column(name = "time_limit") private int timeLimit; + @Column(name = "confidence_levels_activity_uiid") private Integer confidenceLevelsActivityUiid; //overwrites default preset marks stored as admin config setting + @Column(name = "preset_marks") private String presetMarks; + @Column(name = "reflect_on_activity") private boolean reflectOnActivity; + @Column(name = "reflect_instructions") private String reflectInstructions; + @Column(name = "show_scratchies_in_results") private boolean showScrachiesInResults; - /** - * Default contruction method. - * - */ - public Scratchie() { - scratchieItems = new HashSet(); - } - // ********************************************************** // Function method for Scratchie // ********************************************************** @@ -105,24 +129,23 @@ @Override public Object clone() { - Scratchie scratchie = null; try { scratchie = (Scratchie) super.clone(); scratchie.setUid(null); if (scratchieItems != null) { - Iterator iter = scratchieItems.iterator(); - Set set = new HashSet(); + Iterator iter = scratchieItems.iterator(); + Set set = new HashSet<>(); while (iter.hasNext()) { - ScratchieItem item = (ScratchieItem) iter.next(); + ScratchieItem item = iter.next(); ScratchieItem newItem = (ScratchieItem) item.clone(); // just clone old file without duplicate it in repository set.add(newItem); } scratchie.scratchieItems = set; } } catch (CloneNotSupportedException e) { - Scratchie.log.error("When clone " + Scratchie.class + " failed"); + log.error("When clone " + Scratchie.class + " failed"); } return scratchie; @@ -207,7 +230,6 @@ * Returns deadline for learner's submission * * @return submissionDeadline - * */ public Date getSubmissionDeadline() { return submissionDeadline; @@ -221,10 +243,7 @@ public void setSubmissionDeadline(Date submissionDeadline) { this.submissionDeadline = submissionDeadline; } - - /** - * - */ + public Long getUid() { return uid; } @@ -235,9 +254,6 @@ /** * @return Returns the title. - * - * - * */ public String getTitle() { return title; @@ -253,8 +269,6 @@ /** * @return Returns the instructions set by the teacher. - * - * */ public String getInstructions() { return instructions; @@ -264,15 +278,6 @@ this.instructions = instructions; } - /** - * - * - * - * - * - * - * @return - */ public Set getScratchieItems() { return scratchieItems; } @@ -281,10 +286,6 @@ this.scratchieItems = scratchieItems; } - /** - * - * @return - */ public boolean isDefineLater() { return defineLater; } @@ -293,10 +294,6 @@ this.defineLater = defineLater; } - /** - * - * @return - */ public Long getContentId() { return contentId; } @@ -305,10 +302,6 @@ this.contentId = contentId; } - /** - * - * @return - */ public String getReflectInstructions() { return reflectInstructions; } @@ -317,10 +310,6 @@ this.reflectInstructions = reflectInstructions; } - /** - * - * @return - */ public boolean isReflectOnActivity() { return reflectOnActivity; } @@ -329,10 +318,6 @@ this.reflectOnActivity = reflectOnActivity; } - /** - * - * @return - */ public boolean isExtraPoint() { return extraPoint; } @@ -341,10 +326,6 @@ this.extraPoint = extraPoint; } - /** - * - * @return - */ public boolean isBurningQuestionsEnabled() { return burningQuestionsEnabled; } @@ -353,10 +334,6 @@ this.burningQuestionsEnabled = burningQuestionsEnabled; } - /** - * - * @return - */ public boolean isShuffleItems() { return shuffleItems; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java (.../ScratchieAnswer.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java (.../ScratchieAnswer.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -23,10 +23,18 @@ package org.lamsfoundation.lams.tool.scratchie.model; -import java.util.HashSet; -import java.util.LinkedList; import java.util.List; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + import org.apache.log4j.Logger; import org.lamsfoundation.lams.confidencelevel.ConfidenceLevelDTO; @@ -35,24 +43,37 @@ * * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_scratchie_answer") public class ScratchieAnswer implements Cloneable { private static final Logger log = Logger.getLogger(ScratchieAnswer.class); + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + @Column private String description; + @Column private boolean correct; + @Column(name = "order_id") private Integer orderId; + @ManyToOne + @JoinColumn(name = "scratchie_item_uid") private ScratchieItem scratchieItem; - // *********************************************** - // DTO fields: + // ******************** DTO fields *************************** + @Transient private boolean scratched; + @Transient private int attemptOrder; + @Transient private int[] attempts; + @Transient private List confidenceLevelDtos; // ********************************************************** Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.java (.../ScratchieAnswerVisitLog.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.java (.../ScratchieAnswerVisitLog.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -26,22 +26,39 @@ import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + /** * Scratchie * * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_answer_log") public class ScratchieAnswerVisitLog { + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + + @ManyToOne + @JoinColumn(name = "scratchie_answer_uid") private ScratchieAnswer scratchieAnswer; + + @Column(name = "access_date") private Date accessDate; + + @Column(name = "session_id") private Long sessionId; - /** - * - * @return - */ public Date getAccessDate() { return accessDate; } @@ -50,10 +67,6 @@ this.accessDate = accessDate; } - /** - * - * @return - */ public ScratchieAnswer getScratchieAnswer() { return scratchieAnswer; } @@ -62,10 +75,6 @@ this.scratchieAnswer = item; } - /** - * - * @return Returns the log Uid. - */ public Long getUid() { return uid; } @@ -74,10 +83,6 @@ this.uid = uid; } - /** - * - * @return - */ public Long getSessionId() { return sessionId; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieBurningQuestion.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieBurningQuestion.java (.../ScratchieBurningQuestion.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieBurningQuestion.java (.../ScratchieBurningQuestion.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -25,24 +25,45 @@ import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + /** * ScratchieBurningQuestion * * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_burning_question") public class ScratchieBurningQuestion { + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + + @ManyToOne + @JoinColumn(name = "scratchie_item_uid") private ScratchieItem scratchieItem; + + @Column(name = "access_date") private Date accessDate; + + @Column(name = "session_id") private Long sessionId; + + @Column private String question; + + @Column(name = "general_question") private boolean generalQuestion; - /** - * - * @return Returns the log Uid. - */ public Long getUid() { return uid; } @@ -51,10 +72,6 @@ this.uid = uid; } - /** - * - * @return - */ public Date getAccessDate() { return accessDate; } @@ -63,10 +80,6 @@ this.accessDate = accessDate; } - /** - * - * @return - */ public ScratchieItem getScratchieItem() { return scratchieItem; } @@ -75,10 +88,6 @@ this.scratchieItem = scratchieItem; } - /** - * - * @return - */ public Long getSessionId() { return sessionId; } @@ -87,10 +96,6 @@ this.sessionId = sessionId; } - /** - * - * @return - */ public String getQuestion() { return question; } @@ -99,10 +104,6 @@ this.question = question; } - /** - * - * @return - */ public boolean isGeneralQuestion() { return generalQuestion; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieConfigItem.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieConfigItem.java (.../ScratchieConfigItem.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieConfigItem.java (.../ScratchieConfigItem.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -23,24 +23,32 @@ package org.lamsfoundation.lams.tool.scratchie.model; -/** - * - */ -public class ScratchieConfigItem implements java.io.Serializable { +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +@Entity +@Table(name = "tl_lascrt11_configuration") +public class ScratchieConfigItem implements java.io.Serializable { private static final long serialVersionUID = 6360672537352753361L; public static final String KEY_IS_ENABLED_EXTRA_POINT_OPTION = "isEnabledExtraPointOption"; public static final String KEY_PRESET_MARKS = "presetMarks"; + @Id + @Column(name = "uid") + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + + @Column(name = "config_key") private String configKey; + + @Column(name = "config_value") private String configValue; - /** - * - * - */ public Long getId() { return id; } @@ -49,9 +57,6 @@ this.id = id; } - /** - * - */ public String getConfigKey() { return configKey; } @@ -60,9 +65,6 @@ this.configKey = configKey; } - /** - * - */ public String getConfigValue() { return configValue; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -28,44 +28,61 @@ import java.util.Iterator; import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; +import javax.persistence.Transient; + import org.apache.log4j.Logger; /** * Tool may contain several questions. Which in turn contain answers. * * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_scratchie_item") public class ScratchieItem implements Cloneable { private static final Logger log = Logger.getLogger(ScratchieItem.class); + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + @Column private String title; + @Column private String description; + @Column(name = "order_id") private Integer orderId; + @Column(name = "create_by_author") private boolean isCreateByAuthor; + @Column(name = "create_date") private Date createDate; - // scratchie Items - private Set answers; + @OneToMany(cascade = CascadeType.ALL) + @OrderBy("order_id ASC") + @JoinColumn(name = "scratchie_item_uid") + private Set answers = new HashSet<>(); - // *********************************************** - // DTO fields: + // ************************ DTO fields *********************** + @Transient private boolean isUnraveled; + @Transient private String burningQuestion; - /** - * Default contruction method. - * - */ - public ScratchieItem() { - answers = new HashSet(); - } - @Override public Object clone() { ScratchieItem item = null; @@ -75,10 +92,10 @@ item.setUid(null); if (answers != null) { - Iterator iter = answers.iterator(); - Set set = new HashSet(); + Iterator iter = answers.iterator(); + Set set = new HashSet<>(); while (iter.hasNext()) { - ScratchieAnswer answer = (ScratchieAnswer) iter.next(); + ScratchieAnswer answer = iter.next(); ScratchieAnswer newAnswer = (ScratchieAnswer) answer.clone(); // just clone old file without duplicate it in repository set.add(newAnswer); @@ -96,18 +113,11 @@ // ********************************************************** // Get/Set methods // ********************************************************** - /** - * - * @return Returns the uid. - */ + public Long getUid() { return uid; } - /** - * @param uid - * The uid to set. - */ public void setUid(Long userID) { this.uid = userID; } @@ -152,11 +162,11 @@ this.orderId = orderId; } - public Set getAnswers() { + public Set getAnswers() { return answers; } - public void setAnswers(Set answers) { + public void setAnswers(Set answers) { this.answers = answers; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.java (.../ScratchieSession.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.java (.../ScratchieSession.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -24,43 +24,80 @@ package org.lamsfoundation.lams.tool.scratchie.model; import java.util.Date; +import java.util.HashSet; import java.util.Set; -import org.apache.log4j.Logger; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; /** * Scratchie * * @author Andrey Balan */ +@Entity +@Table(name = "tl_lascrt11_session") public class ScratchieSession { - private static Logger log = Logger.getLogger(ScratchieSession.class); - + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + + @Column(name = "session_id") private Long sessionId; + + @Column(name = "session_name") private String sessionName; + + @ManyToOne + @JoinColumn(name = "scratchie_uid") private Scratchie scratchie; + + @Column(name = "session_start_date") private Date sessionStartDate; + + @Column(name = "session_end_date") private Date sessionEndDate; + //date when user has started activity (pressed start button) that has time limitation + @Column(name = "time_limit_launched_date") private Date timeLimitLaunchedDate; + // finish or not + @Column private int status; - // scratchie Items - private Set scratchieItems; + + @OneToMany(cascade = CascadeType.ALL) + @OrderBy("create_date DESC") + @JoinColumn(name = "session_uid") + private Set scratchieItems = new HashSet<>(); + + @ManyToOne + @JoinColumn(name = "group_leader_uid") private ScratchieUser groupLeader; + + @Column private int mark; + + @Column(name = "scratching_finished") private boolean scratchingFinished; // ********************************************************** // Get/Set methods // ********************************************************** - /** - * - * @return Returns the learnerID. - */ + public Long getUid() { return uid; } @@ -69,10 +106,6 @@ this.uid = uuid; } - /** - * - * @return - */ public Date getSessionEndDate() { return sessionEndDate; } @@ -81,10 +114,6 @@ this.sessionEndDate = sessionEndDate; } - /** - * - * @return - */ public Date getTimeLimitLaunchedDate() { return timeLimitLaunchedDate; } @@ -93,11 +122,6 @@ this.timeLimitLaunchedDate = timeLimitLaunchedDate; } - /** - * - * - * @return - */ public Date getSessionStartDate() { return sessionStartDate; } @@ -106,10 +130,6 @@ this.sessionStartDate = sessionStartDate; } - /** - * - * @return - */ public int getStatus() { return status; } @@ -118,10 +138,6 @@ this.status = status; } - /** - * - * @return - */ public Scratchie getScratchie() { return scratchie; } @@ -130,10 +146,6 @@ this.scratchie = scratchie; } - /** - * - * @return - */ public Long getSessionId() { return sessionId; } @@ -151,35 +163,21 @@ } /** - * * @param sessionName * The session name to set. */ public void setSessionName(String sessionName) { this.sessionName = sessionName; } - /** - * - * - * - * - * - * - * @return - */ - public Set getScratchieItems() { + public Set getScratchieItems() { return scratchieItems; } - public void setScratchieItems(Set scratchieItems) { + public void setScratchieItems(Set scratchieItems) { this.scratchieItems = scratchieItems; } - /** - * - * - */ public ScratchieUser getGroupLeader() { return this.groupLeader; } @@ -189,15 +187,13 @@ } public boolean isUserGroupLeader(Long userUid) { - boolean isUserLeader = (this.groupLeader != null) && userUid.equals(this.groupLeader.getUid()); return isUserLeader; } /** * Mark scored by a leader and shared by all users in a group. * - * * @return */ public int getMark() { @@ -212,7 +208,6 @@ * Indicates whether leader has pressed Continue button in learning thus finishing scratching. And is shared by all * users in a group. * - * * @return */ public boolean isScratchingFinished() { Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieUser.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieUser.java (.../ScratchieUser.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieUser.java (.../ScratchieUser.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -23,35 +23,65 @@ package org.lamsfoundation.lams.tool.scratchie.model; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.log4j.Logger; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; /** - * Scratchie + * Scratchie user. * * @author Andrey Balan */ -public class ScratchieUser implements Cloneable, Comparable { - private static final long serialVersionUID = -7043502180037866257L; +@Entity +@Table(name = "tl_lascrt11_user") +public class ScratchieUser implements Cloneable, Comparable { private static Logger log = Logger.getLogger(ScratchieUser.class); + @Id + @Column + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long uid; + + @Column(name = "user_id") private Long userId; + + @Column(name = "first_name") private String firstName; + + @Column(name = "last_name") private String lastName; + + @Column(name = "login_name") private String loginName; + + @Column(name = "session_finished") private boolean sessionFinished; - private Long portraitId; + @ManyToOne + @JoinColumn(name = "session_uid") private ScratchieSession session; + + //******************** DTO ********************** + + @Transient + private Long portraitId; public ScratchieUser() { } public ScratchieUser(UserDTO user, ScratchieSession session) { - this.userId = new Long(user.getUserID().intValue()); + this.userId = user.getUserID().longValue(); this.firstName = user.getFirstName(); this.lastName = user.getLastName(); this.loginName = user.getLogin(); @@ -60,12 +90,8 @@ this.sessionFinished = false; } - /** - * Clone method from java.lang.Object - */ @Override public Object clone() { - ScratchieUser user = null; try { user = (ScratchieUser) super.clone(); @@ -80,50 +106,50 @@ } @Override - public int compareTo(Object user) { - ScratchieUser u = (ScratchieUser) user; - return loginName.compareTo(u.getLoginName()); + public int compareTo(ScratchieUser user) { + return loginName.compareTo(user.getLoginName()); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof ScratchieUser)) { + return false; + } + + final ScratchieUser user = (ScratchieUser) obj; + + return new EqualsBuilder().append(this.uid, user.uid).append(this.firstName, user.firstName) + .append(this.lastName, user.lastName).append(this.loginName, user.loginName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(uid).append(firstName).append(lastName).append(loginName).toHashCode(); + } + // ********************************************************** // Get/Set methods // ********************************************************** - /** - * - * @return Returns the uid. - */ + public Long getUid() { return uid; } - /** - * @param uid - * The uid to set. - */ public void setUid(Long userID) { this.uid = userID; } - /** - * - * @return Returns the userId. - */ public Long getUserId() { return userId; } - /** - * @param userId - * The userId to set. - */ public void setUserId(Long userID) { this.userId = userID; } - /** - * - * @return - */ public String getLastName() { return lastName; } @@ -132,10 +158,6 @@ this.lastName = lastName; } - /** - * - * @return - */ public String getFirstName() { return firstName; } @@ -144,10 +166,6 @@ this.firstName = firstName; } - /** - * - * @return - */ public String getLoginName() { return loginName; } @@ -156,10 +174,6 @@ this.loginName = loginName; } - /** - * - * @return - */ public ScratchieSession getSession() { return session; } @@ -168,10 +182,6 @@ this.session = session; } - /** - * - * @return - */ public boolean isSessionFinished() { return sessionFinished; } @@ -180,27 +190,6 @@ this.sessionFinished = sessionFinished; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof ScratchieUser)) { - return false; - } - - final ScratchieUser user = (ScratchieUser) obj; - - return new EqualsBuilder().append(this.uid, user.uid).append(this.firstName, user.firstName) - .append(this.lastName, user.lastName).append(this.loginName, user.loginName).isEquals(); - - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(uid).append(firstName).append(lastName).append(loginName).toHashCode(); - } - public Long getPortraitId() { return portraitId; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml (.../scratchieApplicationContext.xml) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml (.../scratchieApplicationContext.xml) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -131,6 +131,7 @@ + PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r22ca3de0e9fe138e44fc36be1abc6fabbbdc4002 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 22ca3de0e9fe138e44fc36be1abc6fabbbdc4002) @@ -164,7 +164,7 @@ public Scratchie getDefaultContent(Long contentId) throws ScratchieApplicationException { if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); - ScratchieServiceImpl.log.error(error); + log.error(error); throw new ScratchieApplicationException(error); } @@ -319,7 +319,7 @@ // create new user in a DB if (leader == null) { - ScratchieServiceImpl.log.debug("creating new user with userId: " + leaderUserId); + log.debug("creating new user with userId: " + leaderUserId); User leaderDto = (User) getUserManagementService().findById(User.class, leaderUserId.intValue()); leader = new ScratchieUser(leaderDto.getUserDTO(), scratchieSession); this.createUser(leader); @@ -1780,19 +1780,18 @@ Scratchie defaultScratchie = getScratchieByContentId(defaultScratchieId); if (defaultScratchie == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); - ScratchieServiceImpl.log.error(error); + log.error(error); throw new ScratchieApplicationException(error); } return defaultScratchie; } private Long getToolDefaultContentIdBySignature(String toolSignature) throws ScratchieApplicationException { - Long contentId = null; - contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + Long contentId = toolService.getToolDefaultContentIdBySignature(toolSignature); if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); - ScratchieServiceImpl.log.error(error); + log.error(error); throw new ScratchieApplicationException(error); } return contentId; @@ -1921,7 +1920,7 @@ user.setFirstName(sysUser.getFirstName()); user.setLastName(sysUser.getLastName()); user.setLoginName(sysUser.getLogin()); - user.setUserId(new Long(newUserUid.longValue())); + user.setUserId(newUserUid.longValue()); } scratchieDao.saveObject(toolContentObj); @@ -1975,11 +1974,11 @@ scratchieDao.saveObject(toContent); // save scratchie items as well - Set items = toContent.getScratchieItems(); + Set items = toContent.getScratchieItems(); if (items != null) { - Iterator iter = items.iterator(); + Iterator iter = items.iterator(); while (iter.hasNext()) { - ScratchieItem item = (ScratchieItem) iter.next(); + ScratchieItem item = iter.next(); // createRootTopic(toContent.getUid(),null,msg); } } @@ -2020,7 +2019,7 @@ public void removeToolContent(Long toolContentId) throws ToolException { Scratchie scratchie = scratchieDao.getByContentId(toolContentId); if (scratchie == null) { - ScratchieServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); return; } @@ -2037,9 +2036,8 @@ @Override public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { - if (ScratchieServiceImpl.log.isDebugEnabled()) { - ScratchieServiceImpl.log - .debug("Removing Scratchie content for user ID " + userId + " and toolContentId " + toolContentId); + if (log.isDebugEnabled()) { + log.debug("Removing Scratchie content for user ID " + userId + " and toolContentId " + toolContentId); } List sessions = scratchieSessionDao.getByContentId(toolContentId); @@ -2077,20 +2075,20 @@ @Override public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { if (toolSessionId == null) { - ScratchieServiceImpl.log.error("Fail to leave tool Session based on null tool session id."); + log.error("Fail to leave tool Session based on null tool session id."); throw new ToolException("Fail to remove tool Session based on null tool session id."); } if (learnerId == null) { - ScratchieServiceImpl.log.error("Fail to leave tool Session based on null learner."); + log.error("Fail to leave tool Session based on null learner."); throw new ToolException("Fail to remove tool Session based on null learner."); } ScratchieSession session = scratchieSessionDao.getSessionBySessionId(toolSessionId); if (session != null) { session.setStatus(ScratchieConstants.COMPLETED); scratchieSessionDao.saveObject(session); } else { - ScratchieServiceImpl.log.error("Fail to leave tool Session.Could not find shared scratchie " - + "session by given session id: " + toolSessionId); + log.error("Fail to leave tool Session.Could not find shared scratchie " + "session by given session id: " + + toolSessionId); throw new DataMissingException("Fail to leave tool Session." + "Could not find shared scratchie session by given session id: " + toolSessionId); }