001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/trunk/component/src/java/org/sakaiproject/tool/assessment/facade/AssessmentTemplateFacade.java $
003: * $Id: AssessmentTemplateFacade.java 9273 2006-05-10 22:34:28Z daisyf@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.facade;
021:
022: import java.util.Date;
023:
024: import org.osid.assessment.Assessment;
025: import org.osid.assessment.AssessmentException;
026: import org.sakaiproject.tool.assessment.data.dao.assessment.AssessmentTemplateData;
027: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentTemplateIfc;
028: import org.sakaiproject.tool.assessment.osid.assessment.impl.AssessmentImpl;
029:
030: public class AssessmentTemplateFacade extends AssessmentBaseFacade
031: implements java.io.Serializable, AssessmentTemplateIfc {
032: private static final long serialVersionUID = 7526471155622776147L;
033: public static final String AUTHORS = "ASSESSMENTTEMPLATE_AUTHORS";
034: public static final String KEYWORDS = "ASSESSMENTTEMPLATE_KEYWORDS";
035: public static final String OBJECTIVES = "ASSESSMENTTEMPLATE_OBJECTIVES";
036: public static final String BGCOLOR = "ASSESSMENTTEMPLATE_BGCOLOR";
037: public static final String BGIMAGE = "ASSESSMENTTEMPLATE_BGIMAGE";
038:
039: public static final Long DEFAULTTEMPLATE = new Long("1");
040: public static final Integer INACTIVE_STATUS = new Integer("0");
041: public static final Integer ACTIVE_STATUS = new Integer("1");
042: private org.osid.assessment.Assessment assessment;
043: private AssessmentTemplateIfc data;
044: private Long assessmentTemplateId;
045:
046: public AssessmentTemplateFacade() {
047: super ();
048: this .data = new AssessmentTemplateData();
049: AssessmentImpl assessmentImpl = new AssessmentImpl(); //<-- place holder
050: assessment = (Assessment) assessmentImpl;
051: try {
052: assessment.updateData(this .data);
053: } catch (AssessmentException ex) {
054: throw new DataFacadeException(ex.getMessage());
055: }
056: }
057:
058: /**
059: * IMPORTANT: this constructor do not have "data", this constructor is
060: * merely used for holding assessmentBaseId (which is the templateId) & Title
061: * for displaying purpose.
062: * This constructor does not persist data (which it has none) to DB
063: * @param id
064: * @param title
065: */
066: public AssessmentTemplateFacade(Long id, String title) {
067: // in the case of template assessmentBaseId is the assessmentTemplateId
068: this .assessmentTemplateId = id;
069: super .setAssessmentBaseId(id);
070: super .setTitle(title);
071: }
072:
073: /**
074: * IMPORTANT: this constructor do not have "data", this constructor is
075: * merely used for holding assessmentBaseId (which is the assessmentId), Title
076: * & lastModifiedDate for displaying purpose.
077: * This constructor does not persist data (which it has none) to DB
078: * @param id
079: * @param title
080: * @param lastModifiedDate
081: */
082: public AssessmentTemplateFacade(Long id, String title,
083: Date lastModifiedDate, Long typeId) {
084: // in the case of template assessmentBaseId is the assessmentTemplateId
085: this .assessmentTemplateId = id;
086: super .setAssessmentBaseId(id);
087: super .setTitle(title);
088: super .setLastModifiedDate(lastModifiedDate);
089: super .setTypeId(typeId);
090: }
091:
092: public AssessmentTemplateFacade(AssessmentTemplateIfc data) {
093: super (data);
094: this .data = data;
095: AssessmentImpl assessmentImpl = new AssessmentImpl(); // place holder
096: assessment = (Assessment) assessmentImpl;
097: try {
098: assessment.updateData(this .data);
099: } catch (AssessmentException ex) {
100: throw new DataFacadeException(ex.getMessage());
101: }
102: this .assessmentTemplateId = data.getAssessmentTemplateId();
103: }
104:
105: public Long getAssessmentTemplateId() {
106: try {
107: this .data = (AssessmentTemplateIfc) assessment.getData();
108: } catch (AssessmentException ex) {
109: throw new DataFacadeException(ex.getMessage());
110: }
111: return this .data.getAssessmentTemplateId();
112: }
113:
114: public void setAssessmentTemplateId(Long newId) {
115: try {
116: this .data = (AssessmentTemplateIfc) assessment.getData();
117: } catch (AssessmentException ex) {
118: throw new DataFacadeException(ex.getMessage());
119: }
120: this.data.setAssessmentTemplateId(newId);
121: }
122:
123: }
|