001: /**********************************************************************************
002: * $URL$
003: * $Id$
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.ui.bean.shared;
021:
022: import org.sakaiproject.util.ResourceLoader;
023:
024: import java.io.Serializable;
025: import java.util.HashMap;
026: import java.util.List;
027: import java.util.Locale;
028:
029: //import org.sakaiproject.tool.assessment.services.PersistenceService;
030: import org.sakaiproject.tool.assessment.services.assessment.AssessmentService;
031: import org.sakaiproject.authz.cover.SecurityService;
032: import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;
033: import org.sakaiproject.tool.assessment.ui.bean.delivery.DeliveryBean;
034: import org.sakaiproject.tool.assessment.facade.AgentFacade;
035: import org.apache.commons.logging.LogFactory;
036: import org.apache.commons.logging.Log;
037:
038: /**
039: * <p> </p>
040: * <p>Description: Person Bean with some properties</p>
041: * <p>Copyright: Copyright (c) 2004</p>
042: * <p>Organization: Sakai Project</p>
043: * @author Ed Smiley
044: * @version $id: $
045: */
046:
047: public class PersonBean implements Serializable {
048: /**
049: *
050: */
051: private static final long serialVersionUID = 1884634498046475698L;
052: private static Log log = LogFactory.getLog(PersonBean.class);
053: private String anonymousId;
054:
055: public PersonBean() {
056: }
057:
058: {
059: }
060:
061: public String getAgentString() {
062: return AgentFacade.getAgentString();
063: }
064:
065: public String getAnonymousId() {
066: return anonymousId;
067: }
068:
069: public String getId() {
070: DeliveryBean delivery = (DeliveryBean) ContextUtil
071: .lookupBean("delivery");
072: if (delivery.getAnonymousLogin())
073: return getAnonymousId();
074: else
075: return getAgentString();
076: }
077:
078: public String getEid() {
079: return AgentFacade.getEid();
080: }
081:
082: public void setAnonymousId(String anonymousId) {
083: this .anonymousId = anonymousId;
084: }
085:
086: public boolean getIsAdmin() {
087: String context = "!admin";
088: return SecurityService.unlock("site.upd", "/site/" + context);
089: }
090:
091: private boolean isMacNetscapeBrowser = false;
092:
093: public void setIsMacNetscapeBrowser(boolean isMacNetscapeBrowser) {
094: this .isMacNetscapeBrowser = isMacNetscapeBrowser;
095: }
096:
097: public boolean getIsMacNetscapeBrowser() {
098: return isMacNetscapeBrowser;
099: }
100:
101: private HashMap totalSubmissionPerAssessmentHash = new HashMap();
102:
103: public HashMap getTotalSubmissionPerAssessmentHash() {
104: return totalSubmissionPerAssessmentHash;
105: }
106:
107: public void setTotalSubmissionPerAssessmentHash(
108: HashMap totalSubmissionPerAssessmentHash) {
109: this .totalSubmissionPerAssessmentHash = totalSubmissionPerAssessmentHash;
110: }
111:
112: private List resourceIdList;
113:
114: public void setResourceIdListInPreview(List resourceIdList) {
115: if (this .resourceIdList != null
116: && this .resourceIdList.size() > 0) {
117: // they maybe left over from last preview, delete them
118: AssessmentService service = new AssessmentService();
119: service.deleteResources(this .resourceIdList);
120: }
121: this .resourceIdList = resourceIdList;
122: }
123:
124: public List getResourceIdListInPreview() {
125: return resourceIdList;
126: }
127:
128: public String cleanResourceIdListInPreview() {
129: AssessmentService service = new AssessmentService();
130: service.deleteResources(resourceIdList);
131: return "editAssessment";
132: }
133:
134: public String getLocaleLanguage() {
135: ResourceLoader r = new ResourceLoader();
136: Locale locale = r.getLocale();
137: return locale.getLanguage();
138: }
139:
140: public String getLocaleCountry() {
141: ResourceLoader r = new ResourceLoader();
142: Locale locale = r.getLocale();
143: return locale.getCountry();
144: }
145: }
|