Index: lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java =================================================================== diff -u -r2962a623ecfbd3460df3e34aa323e0cdc65438bd -rffedc450c9e442cbefc9a7ddd8aa26933041b6fa --- lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java (.../Lesson.java) (revision 2962a623ecfbd3460df3e34aa323e0cdc65438bd) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java (.../Lesson.java) (revision ffedc450c9e442cbefc9a7ddd8aa26933041b6fa) @@ -1,6 +1,28 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ package org.lamsfoundation.lams.lesson; import org.lamsfoundation.lams.learningdesign.LearningDesign; +import org.lamsfoundation.lams.lesson.dto.LessonDTO; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; import java.io.Serializable; @@ -12,14 +34,20 @@ import org.apache.commons.lang.builder.ToStringBuilder; /** * A Lesson is a learning sequence that is assocated with - * a number of users for use in learning. + * a number of users for use in learning. A lesson needs a run time copy of + * learning design to interact with. * + * * Hibernate definition: * * @hibernate.class table="tool_lasr10_survey_session" * */ public class Lesson implements Serializable { + + //--------------------------------------------------------------------- + // Class level constants + //--------------------------------------------------------------------- //The state for newly created lesson public static final Integer CREATED = new Integer(1); //The state for lessons that have been scheduled @@ -34,6 +62,9 @@ //The state for lesssons that are no longer visible to the learners. public static final Integer ARCHIVED_STATE = new Integer(6); + //--------------------------------------------------------------------- + // attributes + //--------------------------------------------------------------------- /** identifier field */ private Long lessonId; @@ -63,15 +94,17 @@ /** persistent field */ private Set learnerProgresses; - + + //--------------------------------------------------------------------- + // constructors + //--------------------------------------------------------------------- /** default constructor */ public Lesson() { } - /** * Minimum constructor that includes all not null attributes to create * a new Lesson object. - * Chain construtor implementation. + * Chain construtor pattern implementation. */ public Lesson(Date createDateTime, User user, Integer lessonStateId, LearningDesign learningDesign, LessonClass lessonClass, Organisation organisation, Set learnerProgresses) { @@ -92,13 +125,20 @@ this.learnerProgresses = learnerProgresses; } /** - * @param user - * @param organisation - * @param ld - * @param newLessonClass - * @return + * Factory method that create a new lesson. It initialized all necessary + * data for a new lesson. It is design for monitor side to create a lesson + * by teacher. + * + * @param user the teacher who created this lesson + * @param organisation the organisation associated with this lesson. + * @param ld the learning design associated with this lesson. + * @param newLessonClass the lesson class that will run this lesson. + * @return the new lesson object. */ - public static Lesson createNewLesson(User user, Organisation organisation, LearningDesign ld, LessonClass newLessonClass) + public static Lesson createNewLesson(User user, + Organisation organisation, + LearningDesign ld, + LessonClass newLessonClass) { //setup new lesson return new Lesson(new Date(System.currentTimeMillis()), @@ -110,7 +150,9 @@ new HashSet());//learner progress } - + //--------------------------------------------------------------------- + // Getters and Setters + //--------------------------------------------------------------------- /** * @hibernate.id generator-class="identity" type="java.lang.Long" * column="lesson_id" @@ -234,7 +276,7 @@ this.learnerProgresses = learnerProgresses; } - public String toString() { + public String toString() { return new ToStringBuilder(this) .append("lessonId", getLessonId()) .toString(); @@ -259,5 +301,18 @@ { return lessonClass.getLearners(); } - + //--------------------------------------------------------------------- + // Domain service methods + //--------------------------------------------------------------------- + /** + * Create lesson data transfer object for flash and java interaction. + * @return the lesson data transfer object. + */ + public LessonDTO getLessonData() + { + return new LessonDTO(this.lessonId, + this.getLearningDesign().getTitle(), + this.getLearningDesign().getDescription(), + this.lessonStateId); + } } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dto/LessonDTO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/lesson/dto/LessonDTO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dto/LessonDTO.java (revision ffedc450c9e442cbefc9a7ddd8aa26933041b6fa) @@ -0,0 +1,102 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.lesson.dto; + + +/** + *
This is a cut down version of Lesson domain object. This data transfer object + * is design for the data interaction between flash and java. As the flash and + * java communication is expensive, DTO pattern works fine here to save all + * unecessary data transfer.
+ * + *As DTO is only used for data transfer purpose, we should make it immutable + * to avoid any unecessary error state.
+ * + * @author Jacky Fang 2005-3-3 + * @version 1.1 + * + */ +public class LessonDTO +{ + //--------------------------------------------------------------------- + // attributes + //--------------------------------------------------------------------- + private Long lessonId; + private String learningDesignTitle; + private String learningDesignDescription; + private Integer lessonStateId; + + //--------------------------------------------------------------------- + // Construtors + //--------------------------------------------------------------------- + /** + * Full constructor + */ + public LessonDTO(Long lessonId, + String learningDesignTitle, + String learningDesignDescription, + Integer lessonStateId) + { + this.lessonId = lessonId; + this.learningDesignTitle = learningDesignTitle; + this.learningDesignDescription = learningDesignDescription; + this.lessonStateId = lessonStateId; + + } + //--------------------------------------------------------------------- + // Getters + //--------------------------------------------------------------------- + /** + * Returns the learning design description that current lesson is based on. + * @return Returns the description. + */ + public String getLearningDesignDescription() + { + return learningDesignDescription; + } + /** + * Returns the lesson id. + * @return Returns the lessonId. + */ + public Long getLessonId() + { + return lessonId; + } + /** + * Returns the lesson state. Plese refer to the lesson object for lesson + * state. + * @return Returns the lessonStateId. + */ + public Integer getLessonStateId() + { + return lessonStateId; + } + /** + * Returns the learning design title that current lesson is based on. + * @return Returns the title. + */ + public String getLearningDesignTitle() + { + return learningDesignTitle; + } +}