001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/help/tags/sakai_2-4-1/help-component-shared/src/java/org/sakaiproject/component/app/help/model/CategoryBean.java $
003: * $Id: CategoryBean.java 7755 2006-04-13 11:06:55Z marquard@ched.uct.ac.za $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004 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.help.model;
021:
022: import java.util.HashSet;
023: import java.util.Set;
024:
025: import org.sakaiproject.api.app.help.Category;
026: import org.sakaiproject.component.cover.ServerConfigurationService;
027:
028: /**
029: * category bean
030: * @version $Id: CategoryBean.java 7755 2006-04-13 11:06:55Z marquard@ched.uct.ac.za $
031: */
032: public class CategoryBean implements Category, Comparable {
033: private Long id;
034: private String name;
035: private Set resources = new HashSet();
036: private Set categories = new HashSet();
037: private Category parent;
038:
039: /**
040: * get id
041: * @return Returns the id.
042: */
043: public Long getId() {
044: return id;
045: }
046:
047: /**
048: * set id
049: * @param id The id to set.
050: */
051: public void setId(Long id) {
052: this .id = id;
053: }
054:
055: /**
056: * @see org.sakaiproject.api.app.help.Category#getCategories()
057: */
058: public Set getCategories() {
059: return categories;
060: }
061:
062: /**
063: * @see org.sakaiproject.api.app.help.Category#getName()
064: */
065: public String getName() {
066: return name;
067: }
068:
069: /**
070: * @see org.sakaiproject.api.app.help.Category#getResources()
071: */
072: public Set getResources() {
073: return resources;
074: }
075:
076: /**
077: * @see org.sakaiproject.api.app.help.Category#setCategories(java.util.Set)
078: */
079: public void setCategories(Set categories) {
080: this .categories = categories;
081: }
082:
083: /**
084: * @see org.sakaiproject.api.help.Category#setName(java.lang.String)
085: */
086: public void setName(String name) {
087: this .name = name;
088: }
089:
090: /**
091: * @see org.sakaiproject.api.app.help.Category#setResources(java.util.Set)
092: */
093: public void setResources(Set resources) {
094: this .resources = resources;
095: }
096:
097: /**
098: * @see org.sakaiproject.api.app.help.Category#getParent()
099: */
100: public Category getParent() {
101: return parent;
102: }
103:
104: public void setParent(Category parent) {
105: this .parent = parent;
106: }
107:
108: /**
109: * @see java.lang.Object#equals(java.lang.Object)
110: */
111: public boolean equals(Object obj) {
112: if (this == obj)
113: return true;
114: if (!(obj instanceof CategoryBean))
115: return false;
116: CategoryBean other = (CategoryBean) obj;
117: return this .name.equals(other.name);
118: }
119:
120: /**
121: * @see java.lang.Object#hashCode()
122: */
123: public int hashCode() {
124: return name.hashCode();
125: }
126:
127: public int compareTo(Object o) {
128: CategoryBean cb = (CategoryBean) o;
129:
130: if (!"".equals(ServerConfigurationService
131: .getString("help.location"))) {
132: return id.compareTo(cb.id);
133: } else {
134: return name.compareTo(cb.name);
135: }
136: }
137: }
|