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/PublishedSectionData.java $
003: * $Id: PublishedSectionData.java 15083 2006-09-20 20:03:55Z lydial@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.io.IOException;
023: import java.util.ArrayList;
024: import java.util.Collections;
025: import java.util.Date;
026: import java.util.HashMap;
027: import java.util.HashSet;
028: import java.util.Iterator;
029: import java.util.List; //import java.util.Random;
030: import java.util.Set;
031:
032: import org.apache.log4j.Category; //import org.sakaiproject.tool.assessment.data.dao.shared.TypeD;
033: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentIfc;
034: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemDataIfc;
035: import org.sakaiproject.tool.assessment.data.ifc.assessment.SectionAttachmentIfc;
036: import org.sakaiproject.tool.assessment.data.ifc.assessment.SectionDataIfc;
037: import org.sakaiproject.tool.assessment.data.ifc.shared.TypeIfc;
038:
039: //import org.sakaiproject.tool.assessment.facade.AgentFacade;
040: //import org.sakaiproject.tool.assessment.facade.TypeFacadeQueriesAPI;
041: //import org.sakaiproject.tool.assessment.services.PersistenceService;
042:
043: public class PublishedSectionData implements java.io.Serializable,
044: SectionDataIfc, Comparable {
045: static Category errorLogger = Category.getInstance("errorLogger");
046:
047: private static final long serialVersionUID = 7526471155622776147L;
048: public static final Integer ACTIVE_STATUS = new Integer(1);
049: public static final Integer INACTIVE_STATUS = new Integer(0);
050: public static final Integer ANY_STATUS = new Integer(2);
051:
052: private Long id;
053: private Long assessmentId;
054: private AssessmentIfc assessment;
055: private Integer duration;
056: private Integer sequence;
057: private String title;
058: private String description;
059: private Long typeId;
060: private Integer status;
061: private String createdBy;
062: private Date createdDate;
063: private String lastModifiedBy;
064: private Date lastModifiedDate;
065: private Set itemSet;
066: private Set sectionMetaDataSet;
067: private HashMap sectionMetaDataMap;
068: private Set sectionAttachmentSet;
069:
070: public PublishedSectionData() {
071: }
072:
073: public PublishedSectionData(Integer duration, Integer sequence,
074: String title, String description, Long typeId,
075: Integer status, String createdBy, Date createdDate,
076: String lastModifiedBy, Date lastModifiedDate) {
077: this .duration = duration;
078: this .sequence = sequence;
079: this .title = title;
080: this .description = description;
081: this .typeId = typeId;
082: this .status = status;
083: this .createdBy = createdBy;
084: this .createdDate = createdDate;
085: this .lastModifiedBy = lastModifiedBy;
086: this .lastModifiedDate = lastModifiedDate;
087:
088: }
089:
090: public Long getSectionId() {
091: return this .id;
092: }
093:
094: public void setSectionId(Long id) {
095: this .id = id;
096: }
097:
098: public Long getAssessmentId() {
099: return this .assessmentId;
100: }
101:
102: public void setAssessmentId(Long assessmentId) {
103: this .assessmentId = assessmentId;
104: }
105:
106: public void setAssessment(AssessmentIfc assessment) {
107: this .assessment = assessment;
108: }
109:
110: public AssessmentIfc getAssessment() {
111: return assessment;
112: }
113:
114: /**
115: public AssessmentDataIfc getAssessment()
116: {
117: return (AssessmentDataIfc)assessment;
118: }
119: */
120: public Integer getDuration() {
121: return this .duration;
122: }
123:
124: public void setDuration(Integer duration) {
125: this .duration = duration;
126: }
127:
128: public Integer getSequence() {
129: return this .sequence;
130: }
131:
132: public void setSequence(Integer sequence) {
133: this .sequence = sequence;
134: }
135:
136: public String getTitle() {
137: return this .title;
138: }
139:
140: public void setTitle(String title) {
141: this .title = title;
142: }
143:
144: public String getDescription() {
145: return this .description;
146: }
147:
148: public void setDescription(String description) {
149: this .description = description;
150: }
151:
152: public Long getTypeId() {
153: return this .typeId;
154: }
155:
156: public void setTypeId(Long typeId) {
157: this .typeId = typeId;
158: }
159:
160: public Integer getStatus() {
161: return this .status;
162: }
163:
164: public void setStatus(Integer status) {
165: this .status = status;
166: }
167:
168: public String getCreatedBy() {
169: return this .createdBy;
170: }
171:
172: public void setCreatedBy(String createdBy) {
173: this .createdBy = createdBy;
174: }
175:
176: public Date getCreatedDate() {
177: return this .createdDate;
178: }
179:
180: public void setCreatedDate(Date createdDate) {
181: this .createdDate = createdDate;
182: }
183:
184: public String getLastModifiedBy() {
185: return this .lastModifiedBy;
186: }
187:
188: public void setLastModifiedBy(String lastModifiedBy) {
189: this .lastModifiedBy = lastModifiedBy;
190: }
191:
192: public Date getLastModifiedDate() {
193: return this .lastModifiedDate;
194: }
195:
196: public void setLastModifiedDate(Date lastModifiedDate) {
197: this .lastModifiedDate = lastModifiedDate;
198: }
199:
200: public Set getItemSet() {
201: return itemSet;
202: }
203:
204: public void setItemSet(Set itemSet) {
205: this .itemSet = itemSet;
206: }
207:
208: public Set getSectionMetaDataSet() {
209: return sectionMetaDataSet;
210: }
211:
212: public void setSectionMetaDataSet(Set param) {
213: this .sectionMetaDataSet = param;
214: this .sectionMetaDataMap = getSectionMetaDataMap(sectionMetaDataSet);
215:
216: }
217:
218: public HashMap getSectionMetaDataMap(Set metaDataSet) {
219: HashMap metaDataMap = new HashMap();
220: if (metaDataSet != null) {
221: for (Iterator i = metaDataSet.iterator(); i.hasNext();) {
222: PublishedSectionMetaData metaData = (PublishedSectionMetaData) i
223: .next();
224: metaDataMap.put(metaData.getLabel(), metaData
225: .getEntry());
226: }
227: }
228: return metaDataMap;
229: }
230:
231: public void addSectionMetaData(String label, String entry) {
232: if (this .sectionMetaDataSet == null) {
233: setSectionMetaDataSet(new HashSet());
234: this .sectionMetaDataMap = new HashMap();
235: }
236: this .sectionMetaDataMap.put(label, entry);
237: this .sectionMetaDataSet.add(new SectionMetaData(this , label,
238: entry));
239: }
240:
241: public ArrayList getItemArray() {
242: ArrayList list = new ArrayList();
243: Iterator iter = itemSet.iterator();
244: while (iter.hasNext()) {
245: list.add(iter.next());
246: }
247: return list;
248: }
249:
250: public String getSectionMetaDataByLabel(String label) {
251: return (String) this .sectionMetaDataMap.get(label);
252: }
253:
254: public ArrayList getItemArraySortedForGrading() {
255: // this returns all items, used for grading
256: ArrayList list = getItemArray();
257: Collections.sort(list);
258: return list;
259: }
260:
261: public void addItem(ItemDataIfc item) {
262: if (itemSet == null)
263: itemSet = new HashSet();
264: itemSet.add((ItemData) item);
265: }
266:
267: private void writeObject(java.io.ObjectOutputStream out)
268: throws IOException {
269: out.defaultWriteObject();
270: }
271:
272: private void readObject(java.io.ObjectInputStream in)
273: throws IOException, ClassNotFoundException {
274: in.defaultReadObject();
275: }
276:
277: public TypeIfc getType() {
278: /*
279: TypeFacadeQueriesAPI typeFacadeQueries = PersistenceService.getInstance().getTypeFacadeQueries();
280: TypeIfc type = typeFacadeQueries.getTypeFacadeById(this.typeId);
281: TypeD typeD = new TypeD(type.getAuthority(), type.getDomain(),
282: type.getKeyword(), type.getDescription());
283: typeD.setTypeId(this.typeId);
284: return typeD;
285: */
286: return null;
287: }
288:
289: public int compareTo(Object o) {
290: PublishedSectionData a = (PublishedSectionData) o;
291: return sequence.compareTo(a.sequence);
292: }
293:
294: public Set getSectionAttachmentSet() {
295: return sectionAttachmentSet;
296: }
297:
298: public void setSectionAttachmentSet(Set sectionAttachmentSet) {
299: this .sectionAttachmentSet = sectionAttachmentSet;
300: }
301:
302: public List getSectionAttachmentList() {
303: ArrayList list = new ArrayList();
304: if (sectionAttachmentSet != null) {
305: Iterator iter = sectionAttachmentSet.iterator();
306: while (iter.hasNext()) {
307: SectionAttachmentIfc a = (SectionAttachmentIfc) iter
308: .next();
309: list.add(a);
310: }
311: }
312: return list;
313: }
314:
315: }
|