001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.workgroup.web;
018:
019: import java.util.List;
020:
021: import org.apache.commons.lang.StringUtils;
022: import org.kuali.workflow.attribute.Extension;
023: import org.kuali.workflow.workgroup.WorkgroupType;
024:
025: import edu.iu.uis.eden.EdenConstants;
026: import edu.iu.uis.eden.KEWServiceLocator;
027: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
028: import edu.iu.uis.eden.lookupable.MyColumns;
029: import edu.iu.uis.eden.lookupable.WebLookupableDecorator;
030: import edu.iu.uis.eden.user.Recipient;
031: import edu.iu.uis.eden.user.WorkflowUser;
032: import edu.iu.uis.eden.util.CodeTranslator;
033: import edu.iu.uis.eden.workgroup.GroupNameId;
034: import edu.iu.uis.eden.workgroup.WorkflowGroupId;
035: import edu.iu.uis.eden.workgroup.Workgroup;
036:
037: /**
038: * A decorator for {@link Workgroup} which allows for the bean to be more
039: * easily used by the web-tier.
040: *
041: * @author bmcgough
042: */
043: public class WebWorkgroup extends WebLookupableDecorator implements
044: Workgroup {
045:
046: private static final long serialVersionUID = -6073955034528195631L;
047:
048: private Workgroup workgroup;
049: private WorkgroupType workgroupType;
050: private MyColumns myColumns;
051:
052: public WebWorkgroup(Workgroup workgroup) {
053: this .workgroup = workgroup;
054: if (StringUtils.isBlank(workgroup.getWorkgroupType())
055: || workgroup.getWorkgroupType().equals(
056: EdenConstants.LEGACY_DEFAULT_WORKGROUP_TYPE)) {
057: workgroupType = WorkgroupForm.createDefaultWorkgroupType();
058: } else {
059: workgroupType = KEWServiceLocator.getWorkgroupTypeService()
060: .findByName(workgroup.getWorkgroupType());
061: if (workgroupType == null) {
062: throw new WorkflowRuntimeException(
063: "Workgroup with name '"
064: + workgroup.getGroupNameId()
065: .getNameId()
066: + "' has an invalid workgroup type of '"
067: + workgroup.getWorkgroupType() + "'");
068: }
069: }
070: }
071:
072: /**
073: * @return
074: */
075: public Integer getLockVerNbr() {
076: return workgroup.getLockVerNbr();
077: }
078:
079: /**
080: * @return
081: */
082: public String getWorkgroupType() {
083: return workgroup.getWorkgroupType();
084: }
085:
086: /**
087: * @return
088: */
089: public Boolean getActiveInd() {
090: return workgroup.getActiveInd();
091: }
092:
093: /**
094: * @param activeInd
095: */
096: public void setActiveInd(Boolean activeInd) {
097: workgroup.setActiveInd(activeInd);
098: }
099:
100: public String getActiveIndDisplay() {
101: if (workgroup.getActiveInd() == null) {
102: return EdenConstants.INACTIVE_LABEL_LOWER;
103: }
104: return CodeTranslator.getActiveIndicatorLabel(workgroup
105: .getActiveInd());
106: }
107:
108: /**
109: * @return
110: */
111: public String getDescription() {
112: return workgroup.getDescription();
113: }
114:
115: /**
116: * @return
117: */
118: public GroupNameId getGroupNameId() {
119: return workgroup.getGroupNameId();
120: }
121:
122: /**
123: * @return
124: */
125: public WorkflowGroupId getWorkflowGroupId() {
126: return workgroup.getWorkflowGroupId();
127: }
128:
129: /**
130: * @param description
131: */
132: public void setDescription(String description) {
133: workgroup.setDescription(description);
134: }
135:
136: /**
137: * @param groupNameId
138: */
139: public void setGroupNameId(GroupNameId groupNameId) {
140: workgroup.setGroupNameId(groupNameId);
141: }
142:
143: /**
144: * @param workflowGroupId
145: */
146: public void setWorkflowGroupId(WorkflowGroupId workflowGroupId) {
147: workgroup.setWorkflowGroupId(workflowGroupId);
148: }
149:
150: public Long getWorkgroupId() {
151: if (getWorkflowGroupId() == null)
152: return null;
153: return getWorkflowGroupId().getGroupId();
154: }
155:
156: public String getWorkgroupName() {
157: if (getGroupNameId() == null)
158: return null;
159: return getGroupNameId().getNameId();
160: }
161:
162: /**
163: * @param workgroupType
164: */
165: public void setWorkgroupType(String workgroupType) {
166: workgroup.setWorkgroupType(workgroupType);
167: }
168:
169: public String getDisplayName() {
170: return workgroup.getDisplayName();
171: }
172:
173: public String toString() {
174: return "[WebWorkgroup: workgroup=" + workgroup + "]";
175: }
176:
177: public List<Extension> getExtensions() {
178: return workgroup.getExtensions();
179: }
180:
181: public void setExtensions(List<Extension> extensions) {
182: workgroup.setExtensions(extensions);
183: }
184:
185: public MyColumns getMyColumns() {
186: return myColumns;
187: }
188:
189: public void setMyColumns(MyColumns myColumns) {
190: this .myColumns = myColumns;
191: }
192:
193: public List<Recipient> getMembers() {
194: return workgroup.getMembers();
195: }
196:
197: public List<WorkflowUser> getUsers() {
198: return workgroup.getUsers();
199: }
200:
201: public boolean hasMember(Recipient member) {
202: return workgroup.hasMember(member);
203: }
204:
205: public void setMembers(List<Recipient> members) {
206: workgroup.setMembers(members);
207: }
208:
209: }
|