001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-hibernate/src/java/org/sakaiproject/tool/assessment/data/dao/questionpool/QuestionPoolData.java $
003: * $Id: QuestionPoolData.java 13062 2006-07-28 21:46: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.questionpool;
021:
022: import java.io.Serializable;
023: import java.util.ArrayList;
024: import java.util.Collection;
025: import java.util.Date;
026: import java.util.Iterator;
027: import java.util.HashSet;
028: import java.util.Set;
029:
030: import org.sakaiproject.tool.assessment.data.ifc.questionpool.QuestionPoolDataIfc;
031: import org.sakaiproject.tool.assessment.data.ifc.questionpool.QuestionPoolItemIfc;
032: import org.sakaiproject.tool.assessment.data.ifc.shared.AgentDataIfc;
033: import org.sakaiproject.tool.assessment.data.ifc.shared.TypeIfc;
034:
035: /**
036: * DOCUMENTATION PENDING
037: *
038: * @author $author$
039: * @version $Id: QuestionPoolData.java 13062 2006-07-28 21:46:55Z lydial@stanford.edu $
040: */
041: public class QuestionPoolData implements Serializable,
042: QuestionPoolDataIfc, Cloneable {
043: /** Use serialVersionUID for interoperability. */
044: private static final long serialVersionUID = 9180085666292824370L;
045: public static final Long ACCESS_DENIED = new Long(30);
046: public static final Long READ_ONLY = new Long(31);
047: public static final Long READ_COPY = new Long(32);
048: public static final Long READ_WRITE = new Long(33);
049: public static final Long ADMIN = new Long(34);
050: public static final Long DEFAULT_TYPEID = new Long(0);
051: public static final Long DEFAULT_INTELLECTUAL_PROPERTYID = new Long(
052: 0);
053: public static final Long ROOT_POOL = new Long(0);
054:
055: private Long questionPoolId;
056: private String title;
057: private String description;
058: private Long parentPoolId = ROOT_POOL;
059:
060: private String ownerId = null;
061: private AgentDataIfc owner;
062: private Date dateCreated;
063: private Date lastModified;
064: private String lastModifiedById;
065: private AgentDataIfc lastModifiedBy;
066: private Long accessTypeId = null;
067: private TypeIfc accessType;
068: private String objectives;
069: private String keywords;
070: private String rubric;
071: private Long typeId;
072: private TypeIfc type;
073: private Long intellectualPropertyId;
074: private String organizationName;
075: private Set questionPoolItems;
076: private Collection items = new ArrayList();
077:
078: private Integer subPoolSize;
079:
080: public QuestionPoolData() {
081: }
082:
083: /**
084: * This is a cheap object created for holding just the Id & title. This is
085: * used by the pulldown list in authoring when we only need the Id & title
086: * and nothing else. This object is not used for persistence.
087: * @param poolId
088: * @param title
089: */
090: public QuestionPoolData(Long poolId, String title) {
091: this .questionPoolId = poolId;
092: this .title = title;
093: }
094:
095: public QuestionPoolData(Long poolId, String title, Long parentPoolId) {
096: this .questionPoolId = poolId;
097: this .parentPoolId = parentPoolId;
098: this .title = title;
099: }
100:
101: public Long getQuestionPoolId() {
102: return questionPoolId;
103: }
104:
105: public void setQuestionPoolId(Long questionPoolId) {
106: this .questionPoolId = questionPoolId;
107: }
108:
109: public String getTitle() {
110: return title;
111: }
112:
113: public void setTitle(String title) {
114: this .title = title;
115: }
116:
117: public String getDescription() {
118: return description;
119: }
120:
121: public void setDescription(String description) {
122: this .description = description;
123: }
124:
125: // added to faciliate Hibernate POJO requirement, parentPool is not part of the orginal
126: // QuestionPoolProperties. Will see if I can make it part of it later - daisyf on 8/25/04
127: public Long getParentPoolId() {
128: return parentPoolId;
129: }
130:
131: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
132: public void setParentPoolId(Long parentPoolId) {
133: this .parentPoolId = parentPoolId;
134: }
135:
136: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
137: public String getOwnerId() {
138: return ownerId;
139: }
140:
141: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
142: public void setOwnerId(String ownerId) {
143: this .ownerId = ownerId;
144: }
145:
146: public AgentDataIfc getOwner() {
147: return owner;
148: }
149:
150: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
151: public void setOwner(AgentDataIfc owner) {
152: this .owner = owner;
153: }
154:
155: /**
156: * DOCUMENTATION PENDING
157: *
158: * @return DOCUMENTATION PENDING
159: */
160: public Date getDateCreated() {
161: return dateCreated;
162: }
163:
164: /**
165: * DOCUMENTATION PENDING
166: *
167: * @param dateCreated DOCUMENTATION PENDING
168: */
169: public void setDateCreated(Date dateCreated) {
170: this .dateCreated = dateCreated;
171: }
172:
173: /**
174: * DOCUMENTATION PENDING
175: *
176: * @return DOCUMENTATION PENDING
177: */
178: public Date getLastModified() {
179: return lastModified;
180: }
181:
182: /**
183: * DOCUMENTATION PENDING
184: *
185: * @param lastModified DOCUMENTATION PENDING
186: */
187: public void setLastModified(Date lastModified) {
188: this .lastModified = lastModified;
189: }
190:
191: public String getLastModifiedById() {
192: return lastModifiedById;
193: }
194:
195: public void setLastModifiedById(String lastModifiedById) {
196: this .lastModifiedById = lastModifiedById;
197: }
198:
199: public AgentDataIfc getLastModifiedBy() {
200: return lastModifiedBy;
201: }
202:
203: public void setLastModifiedBy(AgentDataIfc lastModifiedBy) {
204: this .lastModifiedBy = lastModifiedBy;
205: }
206:
207: /**
208: * DOCUMENTATION PENDING
209: *
210: * @return DOCUMENTATION PENDING
211: */
212:
213: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
214: public Long getAccessTypeId() {
215: return this .accessTypeId;
216: }
217:
218: // added to faciliate Hibernate POJO requirement, also for getting the Type without
219: // making a trip to the DB - daisyf on 8/25/04
220: public void setAccessTypeId(Long accessTypeId) {
221: this .accessTypeId = accessTypeId;
222: }
223:
224: public TypeIfc getAccessType() {
225: return this .accessType;
226: }
227:
228: public void setAccessType(TypeIfc accessType) {
229: this .accessType = accessType;
230: }
231:
232: /**
233: * DOCUMENTATION PENDING
234: *
235: * @return DOCUMENTATION PENDING
236: */
237: public String getObjectives() {
238: return objectives;
239: }
240:
241: /**
242: * DOCUMENTATION PENDING
243: *
244: * @param objectives DOCUMENTATION PENDING
245: */
246: public void setObjectives(String objectives) {
247: this .objectives = objectives;
248: }
249:
250: /**
251: * DOCUMENTATION PENDING
252: *
253: * @return DOCUMENTATION PENDING
254: */
255: public String getKeywords() {
256: return keywords;
257: }
258:
259: /**
260: * DOCUMENTATION PENDING
261: *
262: * @param newKeywords DOCUMENTATION PENDING
263: */
264: public void setKeywords(String keywords) {
265: this .keywords = keywords;
266: }
267:
268: /**
269: * DOCUMENTATION PENDING
270: *
271: * @return DOCUMENTATION PENDING
272: */
273: public String getRubric() {
274: return rubric;
275: }
276:
277: /**
278: * DOCUMENTATION PENDING
279: *
280: * @param rubric DOCUMENTATION PENDING
281: */
282: public void setRubric(String rubric) {
283: this .rubric = rubric;
284: }
285:
286: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
287: public Long getTypeId() {
288: return typeId;
289: }
290:
291: // added to faciliate Hibernate POJO requirement, also for getting the Type
292: // without making a trip to the DB - daisyf on 8/25/04
293: public void setTypeId(Long typeId) {
294: this .typeId = typeId;
295: }
296:
297: public TypeIfc getType() {
298: return this .type;
299: }
300:
301: public void setType(TypeIfc type) {
302: this .type = type;
303: }
304:
305: /**
306: * DOCUMENTATION PENDING
307: *
308: * @return DOCUMENTATION PENDING
309: */
310: public Long getIntellectualPropertyId() {
311: return intellectualPropertyId;
312: }
313:
314: /**
315: * DOCUMENTATION PENDING
316: *
317: * @param intellectualProperty DOCUMENTATION PENDING
318: */
319: public void setIntellectualPropertyId(Long intellectualPropertyId) {
320: this .intellectualPropertyId = intellectualPropertyId;
321: }
322:
323: public void setIntellectualProperty(String intellectualProperty) {
324: setIntellectualPropertyId(new Long(intellectualProperty));
325: }
326:
327: /**
328: * DOCUMENTATION PENDING
329: *
330: * @return DOCUMENTATION PENDING
331: */
332: public String getOrganizationName() {
333: return organizationName;
334: }
335:
336: /**
337: * DOCUMENTATION PENDING
338: *
339: * @param organizationName DOCUMENTATION PENDING
340: */
341: public void setOrganizationName(String organizationName) {
342: this .organizationName = organizationName;
343: }
344:
345: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
346: public Set getQuestionPoolItems() {
347: return questionPoolItems;
348: }
349:
350: // added to faciliate Hibernate POJO requirement - daisyf on 8/25/04
351: public void setQuestionPoolItems(Set questionPoolItems) {
352: this .questionPoolItems = questionPoolItems;
353: }
354:
355: public void addQuestionPoolItem(QuestionPoolItemIfc questionPoolItem) {
356: questionPoolItems.add(questionPoolItem);
357: }
358:
359: /**
360: * DOCUMENTATION PENDING
361: *
362: * @return an ArrayList of org.sakaiproject.tool.assessment.data.dao.ItemData
363: */
364: public Collection getQuestions() {
365: return items;
366: }
367:
368: /**
369: * DOCUMENTATION PENDING
370: *
371: * @param newItems DOCUMENTATION PENDING
372: */
373: public void setQuestions(Collection items) {
374: this .items = items;
375: }
376:
377: // for JSF, sigh - daisyf
378: public Integer getQuestionSize() {
379: return new Integer(items.size());
380: }
381:
382: // for JSF, sigh - daisyf
383: public void setSubPoolSize(Integer subPoolSize) {
384: this .subPoolSize = subPoolSize;
385: }
386:
387: // for JSF, sigh - daisyf
388: public Integer getSubPoolSize() {
389: return subPoolSize;
390: }
391:
392: public Object clone() {
393: QuestionPoolData newQ = new QuestionPoolData();
394: newQ.setQuestionPoolId(questionPoolId);
395: newQ.setTitle(title);
396: newQ.setDescription(description);
397: newQ.setParentPoolId(parentPoolId);
398: newQ.setOwnerId(ownerId);
399: newQ.setOwner(owner);
400: newQ.setDateCreated(dateCreated);
401: newQ.setLastModified(lastModified);
402: newQ.setLastModifiedById(lastModifiedById);
403: newQ.setLastModifiedBy(lastModifiedBy);
404: newQ.setAccessTypeId(accessTypeId);
405: newQ.setAccessType(accessType);
406: newQ.setObjectives(objectives);
407: newQ.setKeywords(keywords);
408: newQ.setRubric(rubric);
409: newQ.setTypeId(typeId);
410: newQ.setType(type);
411: newQ.setIntellectualPropertyId(intellectualPropertyId);
412: newQ.setOrganizationName(organizationName);
413: HashSet s = new HashSet();
414: Iterator iter = questionPoolItems.iterator();
415: while (iter.hasNext()) {
416: QuestionPoolItemData item = (QuestionPoolItemData) iter
417: .next();
418: s.add(item.clone());
419: }
420: newQ.setQuestionPoolItems(s);
421: return newQ;
422: }
423:
424: }
|