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.data.model;
021:
022: import java.io.Serializable;
023: import java.util.Collection;
024: import java.util.List;
025: import java.util.Map;
026:
027: /**
028: * originally Tree.java
029: * @author esmiley@stanford.edu
030: * @version $Id: Tree.java 632 2005-07-14 21:22:50Z janderse@umich.edu $
031: */
032: public interface Tree extends Serializable {
033: /**
034: *
035: *
036: * @return
037: */
038: public Long getCurrentId();
039:
040: /**
041: *
042: *
043: * @param id
044: */
045: public void setCurrentId(Long id);
046:
047: /**
048: *
049: *
050: * @return
051: */
052: public boolean currentObjectIsParent();
053:
054: /**
055: *
056: *
057: * @return
058: */
059: public Object getCurrentObject();
060:
061: /**
062: *
063: *
064: * @return
065: */
066: public Object getParent();
067:
068: /**
069: * This is used to get the String id suitable for use in a
070: * javascript tree.
071: */
072: public String getCurrentObjectHTMLId();
073:
074: /**
075: * Get the current level.
076: *
077: * @return A String that represents the level we're on (1 is root node,
078: * 2 is first level child, etc..
079: */
080: public String getCurrentLevel();
081:
082: /**
083: * This returns a collection of String properties that can be
084: * displayed in a table. If (currentObjectId == null), returns
085: * the list of column headers.
086: */
087: public Collection getCurrentObjectProperties();
088:
089: /**
090: * This takes in an array of method names used to get the properties.
091: * These are used to return a collection of String properties that
092: * can then be displayed in a javascript tree.<p> This does not
093: * have to be implemented -- it will be a dummy method for most
094: * trees.
095: *
096: * i.e.
097: * <pre>
098: * String[] methods = new String[3];
099: * methods[0] = "getName";
100: * methods[1] = "getNumberOfSubpools";
101: * methods[2] = "getDescription";
102: * </pre><p>
103: *
104: * Which might produce:<br>
105: * { "Biology 101", "3", "Basic Biology Questions" }<br>
106: * when getCurrentObjectProperties() is called.
107: */
108: public void setPropertyMethods(String[] methods);
109:
110: /**
111: *
112: *
113: * @return
114: */
115: public Map getAllObjects();
116:
117: /**
118: * A collection of objects in proper sorted order for a tree.
119: */
120: public Collection getSortedObjects();
121:
122: /**
123: * A collection of objects in proper sorted order for a subpool tree.
124: */
125: public Collection getSortedObjects(Long parentId);
126:
127: /**
128: *
129: *
130: * @param parentID
131: *
132: * @return
133: */
134: public Map getChildren(Long parentID);
135:
136: /**
137: *
138: *
139: * @return
140: */
141: public Map getChildren();
142:
143: /**
144: *
145: *
146: * @param parentID
147: *
148: * @return
149: */
150: public List getChildList(Long parentID);
151:
152: /**
153: *
154: *
155: * @return
156: */
157: public List getChildList();
158:
159: /**
160: *
161: *
162: * @return
163: */
164: public List getRootNodeList();
165:
166: /**
167: * This gets the property by which siblings will be sorted.
168: */
169: public String getSortProperty();
170:
171: /**
172: * This sets the property by which siblings will be sorted.
173: */
174: public void setSortProperty(String sortBy);
175:
176: /**
177: * This sorts the tree by the property .
178: */
179: public void sortByProperty(String sortProperty,
180: boolean sortAscending);
181:
182: /**
183: * THis checks to see if given two pools have a common ancestor
184: */
185: public boolean haveCommonRoot(Long poolIdA, Long poolIdB);
186:
187: /**
188: * Is a pool a descendant of the other?
189: */
190: public boolean isDescendantOf(Long poolA, Long poolB);
191:
192: /**
193: * This returns the level of the pool inside a pool tree, Root being 0.
194: */
195: public int poolLevel(Long poolId);
196:
197: }
|