001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-hibernate/src/java/org/sakaiproject/tool/assessment/data/dao/assessment/AssessmentData.java $
003: * $Id: AssessmentData.java 20761 2007-01-29 19:10:48Z ktsao@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.data.dao.assessment;
021:
022: import java.util.ArrayList;
023: import java.util.Collections;
024: import java.util.Date;
025: import java.util.Iterator;
026: import java.util.List;
027: import java.util.Set;
028:
029: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentAttachmentIfc;
030: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentIfc;
031: import org.sakaiproject.tool.assessment.data.ifc.assessment.SectionDataIfc;
032:
033: public class AssessmentData
034: extends
035: org.sakaiproject.tool.assessment.data.dao.assessment.AssessmentBaseData
036: implements java.io.Serializable, AssessmentIfc {
037:
038: /**
039: *
040: */
041: private static final long serialVersionUID = -2260656620640273214L;
042: // both Assessment and AssessmentTemplate inherits all the properties & methods from
043: // AssessmentBaseData.
044: // These are the properties that an assessment has and an assessmentTemplate don't
045: private Long assessmentTemplateId;
046: private Set sectionSet;
047: private Set assessmentAttachmentSet;
048:
049: /* Assessment has AssessmentAccessControl and EvaluationModel
050: * as well as a set of Sections
051: * private AssessmentAccessControlIfc assessmentAccessControl;
052: * private EvaluationModelIfc evaluationModel;
053: */
054:
055: public AssessmentData() {
056: setIsTemplate(Boolean.FALSE);
057: }
058:
059: public AssessmentData(Long assessmentTemplateId, String title,
060: Date lastModifiedDate) {
061: // in the case of template assessmentBaseId is the assessmentTemplateId
062: super (assessmentTemplateId, title, lastModifiedDate);
063: }
064:
065: public AssessmentData(Long parentId, String title,
066: String description, String comments,
067: Long assessmentTemplateId, Long typeId,
068: Integer instructorNotification, Integer testeeNotification,
069: Integer multipartAllowed, Integer status, String createdBy,
070: Date createdDate, String lastModifiedBy,
071: Date lastModifiedDate) {
072: super (Boolean.FALSE, parentId, title, description, comments,
073: typeId, instructorNotification, testeeNotification,
074: multipartAllowed, status, createdBy, createdDate,
075: lastModifiedBy, lastModifiedDate);
076: this .assessmentTemplateId = assessmentTemplateId;
077: }
078:
079: public Long getAssessmentId() {
080: return getAssessmentBaseId();
081: }
082:
083: public Long getAssessmentTemplateId() {
084: return this .assessmentTemplateId;
085: }
086:
087: public void setAssessmentTemplateId(Long assessmentTemplateId) {
088: this .assessmentTemplateId = assessmentTemplateId;
089: }
090:
091: public Set getSectionSet() {
092: return sectionSet;
093: }
094:
095: public void setSectionSet(Set sectionSet) {
096: this .sectionSet = sectionSet;
097: }
098:
099: public ArrayList getSectionArray() {
100: ArrayList list = new ArrayList();
101: Iterator iter = sectionSet.iterator();
102: while (iter.hasNext()) {
103: list.add(iter.next());
104: }
105: return list;
106: }
107:
108: public ArrayList getSectionArraySorted() {
109: ArrayList list = getSectionArray();
110: Collections.sort(list);
111: return list;
112: }
113:
114: public SectionDataIfc getSection(Long sequence) {
115: ArrayList list = getSectionArraySorted();
116: if (list == null)
117: return null;
118: else
119: return (SectionDataIfc) list.get(sequence.intValue() - 1);
120: }
121:
122: public SectionDataIfc getDefaultSection() {
123: ArrayList list = getSectionArraySorted();
124: if (list == null)
125: return null;
126: else
127: return (SectionDataIfc) list.get(0);
128: }
129:
130: public Set getAssessmentAttachmentSet() {
131: return assessmentAttachmentSet;
132: }
133:
134: public void setAssessmentAttachmentSet(Set assessmentAttachmentSet) {
135: this .assessmentAttachmentSet = assessmentAttachmentSet;
136: }
137:
138: public List getAssessmentAttachmentList() {
139: ArrayList list = new ArrayList();
140: if (assessmentAttachmentSet != null) {
141: Iterator iter = assessmentAttachmentSet.iterator();
142: while (iter.hasNext()) {
143: AssessmentAttachmentIfc a = (AssessmentAttachmentIfc) iter
144: .next();
145: list.add(a);
146: }
147: }
148: return list;
149: }
150:
151: }
|