001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/profile/tags/sakai_2-4-1/profile-component-shared/src/java/org/sakaiproject/component/app/profile/ProfileImpl.java $
003: * $Id: ProfileImpl.java 20322 2007-01-12 22:49:51Z wagnermr@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 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.component.app.profile;
021:
022: import org.sakaiproject.api.app.profile.Profile;
023: import org.sakaiproject.api.common.edu.person.SakaiPerson;
024:
025: /**
026: * @author rshastri
027: */
028: public class ProfileImpl implements Profile {
029: private SakaiPerson sakaiPerson;
030:
031: public ProfileImpl() {
032: }
033:
034: /**
035: * @param eduPerson
036: */
037: public ProfileImpl(SakaiPerson sakaiPerson) {
038: this .sakaiPerson = sakaiPerson;
039: }
040:
041: /*
042: * (non-Javadoc)
043: *
044: * @see org.sakaiproject.api.app.profile.Profile#getDepartment()
045: */
046: public String getDepartment() {
047: return sakaiPerson.getOrganizationalUnit();
048: }
049:
050: /*
051: * (non-Javadoc)
052: *
053: * @see org.sakaiproject.api.app.profile.Profile#setDepartment(java.lang.String)
054: */
055: public void setDepartment(String department) {
056: sakaiPerson.setOrganizationalUnit(department);
057: }
058:
059: /*
060: * (non-Javadoc)
061: *
062: * @see org.sakaiproject.api.app.profile.Profile#getEmail()
063: */
064: public String getEmail() {
065: return sakaiPerson.getMail();
066: }
067:
068: /*
069: * (non-Javadoc)
070: *
071: * @see org.sakaiproject.api.app.profile.Profile#setEmail(java.lang.String)
072: */
073: public void setEmail(String email) {
074: sakaiPerson.setMail(email);
075: }
076:
077: /*
078: * (non-Javadoc)
079: *
080: * @see org.sakaiproject.api.app.profile.Profile#getFirstName()
081: */
082: public String getFirstName() {
083: return sakaiPerson.getGivenName();
084: }
085:
086: /*
087: * (non-Javadoc)
088: *
089: * @see org.sakaiproject.api.app.profile.Profile#setFirstName(java.lang.String)
090: */
091: public void setFirstName(String firstName) {
092: sakaiPerson.setGivenName(firstName);
093: }
094:
095: /*
096: * (non-Javadoc)
097: *
098: * @see org.sakaiproject.api.app.profile.Profile#getNickName()
099: */
100: public String getNickName() {
101: return sakaiPerson.getNickname();
102: }
103:
104: /*
105: * (non-Javadoc)
106: *
107: * @see org.sakaiproject.api.app.profile.Profile#setNickName(java.lang.String)
108: */
109: public void setNickName(String nickName) {
110: sakaiPerson.setNickname(nickName);
111: }
112:
113: /*
114: * (non-Javadoc)
115: *
116: * @see org.sakaiproject.api.app.profile.Profile#getHomePhone()
117: */
118: public String getHomePhone() {
119: return sakaiPerson.getHomePhone();
120: }
121:
122: /*
123: * (non-Javadoc)
124: *
125: * @see org.sakaiproject.api.app.profile.Profile#setHomePhone(java.lang.String)
126: */
127: public void setHomePhone(String homePhone) {
128: sakaiPerson.setHomePhone(homePhone);
129: }
130:
131: /*
132: * (non-Javadoc)
133: *
134: * @see org.sakaiproject.api.app.profile.Profile#getHomepage()
135: */
136: public String getHomepage() {
137: // to account for the time when we weren't checking for valid urls
138: String homepage = sakaiPerson.getLabeledURI();
139: if (homepage == null || homepage.equals("")) {
140: // ignore the empty url field
141: } else if (homepage.indexOf("://") == -1) {
142: // if it's missing the transport, add http://
143: homepage = "http://" + homepage;
144: }
145:
146: return homepage;
147: }
148:
149: /*
150: * (non-Javadoc)
151: *
152: * @see org.sakaiproject.api.app.profile.Profile#setHomepage(java.lang.String)
153: */
154: public void setHomepage(String homepage) {
155: sakaiPerson.setLabeledURI(homepage);
156: }
157:
158: /*
159: * (non-Javadoc)
160: *
161: * @see org.sakaiproject.api.app.profile.Profile#getLastName()
162: */
163: public String getLastName() {
164: return sakaiPerson.getSurname();
165: }
166:
167: /*
168: * (non-Javadoc)
169: *
170: * @see org.sakaiproject.api.app.profile.Profile#setLastName(java.lang.String)
171: */
172: public void setLastName(String lastName) {
173: sakaiPerson.setSurname(lastName);
174: }
175:
176: /*
177: * (non-Javadoc)
178: *
179: * @see org.sakaiproject.api.app.profile.Profile#getOtherInformation()
180: */
181: public String getOtherInformation() {
182: return sakaiPerson.getNotes();
183: }
184:
185: /*
186: * (non-Javadoc)
187: *
188: * @see org.sakaiproject.api.app.profile.Profile#setOtherInformation(java.lang.String)
189: */
190: public void setOtherInformation(String otherInformation) {
191: sakaiPerson.setNotes(otherInformation);
192: }
193:
194: /*
195: * (non-Javadoc)
196: *
197: * @see org.sakaiproject.api.app.profile.Profile#getPictureURL()
198: */
199: public String getPictureUrl() {
200: return sakaiPerson.getPictureUrl();
201: }
202:
203: /*
204: * (non-Javadoc)
205: *
206: * @see org.sakaiproject.api.app.profile.Profile#setPictureURL(java.lang.String)
207: */
208: public void setPictureUrl(String pictureUrl) {
209: sakaiPerson.setPictureUrl(pictureUrl);
210: }
211:
212: /*
213: * (non-Javadoc)
214: *
215: * @see org.sakaiproject.api.app.profile.Profile#getPosition()
216: */
217: public String getPosition() {
218: return sakaiPerson.getTitle();
219: }
220:
221: /*
222: * (non-Javadoc)
223: *
224: * @see org.sakaiproject.api.app.profile.Profile#setPosition(java.lang.String)
225: */
226: public void setPosition(String position) {
227: sakaiPerson.setTitle(position);
228: }
229:
230: /*
231: * (non-Javadoc)
232: *
233: * @see org.sakaiproject.api.app.profile.Profile#getRoom()
234: */
235: public String getRoom() {
236: return sakaiPerson.getRoomNumber();
237: }
238:
239: /*
240: * (non-Javadoc)
241: *
242: * @see org.sakaiproject.api.app.profile.Profile#setRoom(java.lang.String)
243: */
244: public void setRoom(String room) {
245: sakaiPerson.setRoomNumber(room);
246: }
247:
248: public String getSchool() {
249: return sakaiPerson.getCampus();
250: }
251:
252: /*
253: * (non-Javadoc)
254: *
255: * @see org.sakaiproject.api.app.profile.Profile#setSchool(java.lang.String)
256: */
257: public void setSchool(String school) {
258: sakaiPerson.setCampus(school);
259: }
260:
261: /*
262: * (non-Javadoc)
263: *
264: * @see org.sakaiproject.api.app.profile.Profile#getWorkPhone()
265: */
266: public String getWorkPhone() {
267: return sakaiPerson.getTelephoneNumber();
268: }
269:
270: /*
271: * (non-Javadoc)
272: *
273: * @see org.sakaiproject.api.app.profile.Profile#setWorkPhone(java.lang.String)
274: */
275: public void setWorkPhone(String workPhone) {
276: sakaiPerson.setTelephoneNumber(workPhone);
277: }
278:
279: /*
280: * (non-Javadoc)
281: *
282: * @see org.sakaiproject.api.app.profile.Profile#getNetworkID()
283: */
284: public String getUserId() {
285: return sakaiPerson.getUid();
286: }
287:
288: /*
289: * (non-Javadoc)
290: *
291: * @see org.sakaiproject.api.app.profile.Profile#setNetworkID(java.lang.String)
292: */
293: public void setUserID(String userID) {
294: sakaiPerson.setUid(userID);
295: }
296:
297: /*
298: * (non-Javadoc)
299: *
300: * @see org.sakaiproject.api.app.profile.Profile#isInstitutionalPictureIDSelected()
301: */
302: public Boolean isInstitutionalPictureIdPreferred() {
303: return sakaiPerson.isSystemPicturePreferred();
304: }
305:
306: /*
307: * (non-Javadoc)
308: *
309: * @see org.sakaiproject.api.app.profile.Profile#setInstitutionalPictureIDSelected(boolean)
310: */
311: public void setInstitutionalPictureIdPreferred(
312: Boolean institutionalPictureIdPreferred) {
313: sakaiPerson
314: .setSystemPicturePreferred(institutionalPictureIdPreferred);
315: }
316:
317: /*
318: * (non-Javadoc)
319: *
320: * @see org.sakaiproject.api.app.profile.Profile#getInstitutionalPicture()
321: */
322:
323: public byte[] getInstitutionalPicture() {
324: return sakaiPerson.getJpegPhoto();
325: }
326:
327: /*
328: * (non-Javadoc)
329: *
330: * @see org.sakaiproject.api.app.profile.Profile#isPrivateInfoViewable()
331: */
332: public Boolean getHidePrivateInfo() {
333: return sakaiPerson.getHidePrivateInfo();
334: }
335:
336: /*
337: * (non-Javadoc)
338: *
339: * @see org.sakaiproject.api.app.profile.Profile#setPrivateInfoViewable(java.lang.Boolean)
340: */
341: public void setHidePrivateInfo(Boolean hidePrivateInfo) {
342: sakaiPerson.setHidePrivateInfo(hidePrivateInfo);
343: }
344:
345: /*
346: * (non-Javadoc)
347: *
348: * @see org.sakaiproject.api.app.profile.Profile#isPublicInfoViewable()
349: */
350: public Boolean getHidePublicInfo() {
351: return sakaiPerson.getHidePublicInfo();
352: }
353:
354: /*
355: * (non-Javadoc)
356: *
357: * @see org.sakaiproject.api.app.profile.Profile#setPublicInfoViewable(java.lang.Boolean)
358: */
359: public void setHidePublicInfo(Boolean hidePublicInfo) {
360: sakaiPerson.setHidePublicInfo(hidePublicInfo);
361: }
362:
363: /*
364: * (non-Javadoc)
365: *
366: * @see org.sakaiproject.api.app.profile.Profile#getSakaiPerson()
367: */
368: public SakaiPerson getSakaiPerson() {
369: return sakaiPerson;
370: }
371:
372: /*
373: * (non-Javadoc)
374: *
375: * @see org.sakaiproject.api.app.profile.Profile#setSakaiPerson(org.sakaiproject.api.app.profile.SakaiPerson)
376: */
377: public void setSakaiPerson(SakaiPerson sakaiPerson) {
378: this .sakaiPerson = sakaiPerson;
379: }
380:
381: // public String toString()
382: // {
383: // return sakaiPerson.toString();
384: // }
385:
386: }
|