001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/common/tool-lib/src/java/org/theospi/portfolio/security/tool/DecoratedMember.java $
003: * $Id:DecoratedMember.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 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.theospi.portfolio.security.tool;
021:
022: import java.util.List;
023:
024: import org.sakaiproject.metaobj.shared.model.Agent;
025:
026: /**
027: * Created by IntelliJ IDEA.
028: * User: John Ellis
029: * Date: Nov 16, 2005
030: * Time: 3:56:31 PM
031: * To change this template use File | Settings | File Templates.
032: */
033: public class DecoratedMember {
034:
035: private Agent base;
036: private AudienceTool parent;
037: private boolean selected = false;
038:
039: public DecoratedMember(AudienceTool parent, Agent base) {
040: this .base = base;
041: this .parent = parent;
042: }
043:
044: public String getDisplayName() {
045: if (base.isRole()) {
046: return parent.getMessageFromBundle("decorated_role_format",
047: new Object[] { base.getDisplayName() });
048: } else {
049: if (base.getEid() != null) {
050: return parent.getMessageFromBundle(
051: "decorated_user_format", new Object[] {
052: base.getDisplayName(),
053: base.getEid().getValue() });
054: } else {
055: return parent.getMessageFromBundle(
056: "decorated_guest_format", new Object[] { base
057: .getDisplayName() });
058: }
059:
060: }
061: }
062:
063: public boolean isSelected() {
064: return selected;
065: }
066:
067: public void setSelected(boolean selected) {
068: this .selected = selected;
069: }
070:
071: public Agent getBase() {
072: return base;
073: }
074:
075: public void setBase(Agent base) {
076: this .base = base;
077: }
078:
079: public AudienceTool getParent() {
080: return parent;
081: }
082:
083: public void setParent(AudienceTool parent) {
084: this .parent = parent;
085: }
086:
087: public Agent getRole() {
088: List roles = getBase().getWorksiteRoles(
089: getParent().getSite().getId());
090: if (roles.size() > 0) {
091: return (Agent) roles.get(0);
092: }
093: return null;
094: }
095:
096: public boolean equals(Object o) {
097: if (this == o) {
098: return true;
099: }
100: if (!(o instanceof DecoratedMember)) {
101: return false;
102: }
103:
104: final DecoratedMember decoratedMember = (DecoratedMember) o;
105:
106: if (!base.equals(decoratedMember.base)) {
107: return false;
108: }
109:
110: return true;
111: }
112:
113: public int hashCode() {
114: return base.hashCode();
115: }
116: }
|