001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.core.storage;
034:
035: import com.flexive.shared.content.FxPK;
036: import com.flexive.shared.tree.FxTreeMode;
037: import com.flexive.shared.tree.FxTreeNode;
038:
039: import java.io.Serializable;
040:
041: /**
042: * Information about a tree node that implementation specific and provide information about parameters
043: * relevant to the nested set model.
044: *
045: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046: * @author Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
047: */
048: public abstract class FxTreeNodeInfo implements Serializable {
049: private static final long serialVersionUID = 6152424443687210402L;
050:
051: protected int totalChildCount;
052: protected int directChildCount;
053: protected int depth;
054: protected long parentId;
055: protected long id;
056: protected String name;
057: protected FxPK reference;
058: protected long ACLId;
059: protected FxTreeMode mode;
060: protected int position;
061: protected String template;
062: protected long modifiedAt;
063: protected boolean mayEdit, mayDelete, mayRelate, mayExport,
064: mayCreate;
065:
066: /**
067: * Ctor
068: *
069: * @param totalChildCount total number of children
070: * @param directChildCount number of direct children
071: * @param depth depth of this node
072: * @param parentId parent id
073: * @param id node id
074: * @param name name
075: * @param reference referenced content
076: * @param ACLId ACL of the referenced content
077: * @param mode tree mode
078: * @param position position
079: * @param template template
080: * @param modifiedAt last modified at
081: * @param mayEdit edit permission of the referenced ACL
082: * @param mayCreate create permission of the referenced ACL
083: * @param mayDelete delete permission of the referenced ACL
084: * @param mayRelate relate permission of the referenced ACL
085: * @param mayExport export permission of the referenced ACL
086: */
087: protected FxTreeNodeInfo(int totalChildCount, int directChildCount,
088: int depth, long parentId, long id, String name,
089: FxPK reference, long ACLId, FxTreeMode mode, int position,
090: String template, long modifiedAt, boolean mayEdit,
091: boolean mayDelete, boolean mayRelate, boolean mayExport,
092: boolean mayCreate) {
093: this .totalChildCount = totalChildCount;
094: this .directChildCount = directChildCount;
095: this .depth = depth;
096: this .parentId = parentId;
097: this .id = id;
098: this .name = name;
099: this .reference = reference;
100: this .ACLId = ACLId;
101: this .mode = mode;
102: this .position = position;
103: this .template = template;
104: this .modifiedAt = modifiedAt;
105: this .mayEdit = mayEdit;
106: this .mayDelete = mayDelete;
107: this .mayRelate = mayRelate;
108: this .mayExport = mayExport;
109: this .mayCreate = mayCreate;
110: }
111:
112: /**
113: * Default constructor
114: */
115: protected FxTreeNodeInfo() {
116: }
117:
118: /**
119: * Get the left slot
120: *
121: * @return left slot
122: */
123: public abstract Number getLeft();
124:
125: /**
126: * Get the right slot
127: *
128: * @return right slot
129: */
130: public abstract Number getRight();
131:
132: /**
133: * Get the parent left position
134: *
135: * @return parent left position
136: */
137: public abstract Number getParentLeft();
138:
139: /**
140: * Get the parent right position
141: *
142: * @return parent right position
143: */
144: public abstract Number getParentRight();
145:
146: /**
147: * Get the total number of children
148: *
149: * @return total number of children
150: */
151: public int getTotalChildCount() {
152: return totalChildCount;
153: }
154:
155: /**
156: * Get the number of direct children
157: *
158: * @return number of direct children
159: */
160: public int getDirectChildCount() {
161: return directChildCount;
162: }
163:
164: /**
165: * Get the depth of this node relative to the root node
166: *
167: * @return depth
168: */
169: public int getDepth() {
170: return depth;
171: }
172:
173: /**
174: * Get the id of the parent node
175: *
176: * @return id of the parent node
177: */
178: public long getParentId() {
179: return parentId;
180: }
181:
182: /**
183: * Get the id of the node
184: *
185: * @return id of the node
186: */
187: public long getId() {
188: return id;
189: }
190:
191: /**
192: * Get the name of the node
193: *
194: * @return name
195: */
196: public String getName() {
197: return name;
198: }
199:
200: /**
201: * Get the primary key of the referenced content
202: *
203: * @return primary key of the referenced content
204: */
205: public FxPK getReference() {
206: return reference;
207: }
208:
209: /**
210: * Get the id of the ACL assigned to the referenced content
211: *
212: * @return id of the ACL assigned to the referenced content
213: */
214: public long getACLId() {
215: return ACLId;
216: }
217:
218: /**
219: * ACL: Edit permission for the calling user
220: *
221: * @return ACL: Edit permission for the calling user
222: */
223: public boolean isMayEdit() {
224: return mayEdit;
225: }
226:
227: /**
228: * ACL: Delete permission for the calling user
229: *
230: * @return ACL: Delete permission for the calling user
231: */
232: public boolean isMayDelete() {
233: return mayDelete;
234: }
235:
236: /**
237: * ACL: Relate permission for the calling user
238: *
239: * @return ACL: Relate permission for the calling user
240: */
241: public boolean isMayRelate() {
242: return mayRelate;
243: }
244:
245: /**
246: * ACL: Export permission for the calling user
247: *
248: * @return ACL: Export permission for the calling user
249: */
250: public boolean isMayExport() {
251: return mayExport;
252: }
253:
254: /**
255: * ACL: Create permission for the calling user
256: *
257: * @return ACL: Create permission for the calling user
258: */
259: public boolean isMayCreate() {
260: return mayCreate;
261: }
262:
263: /**
264: * Get the "tree" this node belongs to
265: *
266: * @return the "tree" this node belongs to
267: */
268: public FxTreeMode getMode() {
269: return mode;
270: }
271:
272: /**
273: * Position in the hierarchy level below the parent node
274: *
275: * @return position
276: */
277: public int getPosition() {
278: return position;
279: }
280:
281: /**
282: * Get the assigned template
283: *
284: * @return assigned template
285: */
286: public String getTemplate() {
287: return template;
288: }
289:
290: /**
291: * Comparator for the template
292: *
293: * @param compareTo template to compare to
294: * @return has template
295: */
296: public boolean hasTemplate(String compareTo) {
297: return !((template == null && compareTo != null) || (template != null && compareTo == null))
298: && (template == null || template.equals(compareTo));
299: }
300:
301: /**
302: * Get the last modification timestamp
303: *
304: * @return last modification timestamp
305: */
306: public long getModifiedAt() {
307: return modifiedAt;
308: }
309:
310: /**
311: * Returns true if this is the root node.
312: *
313: * @return true if this is the root node
314: */
315: public boolean isRoot() {
316: return this .id == FxTreeNode.ROOT_NODE;
317: }
318:
319: /**
320: * Are children attached to this node?
321: *
322: * @return if children are attached to this node
323: */
324: public boolean hasChildren() {
325: return totalChildCount > 0;
326: }
327:
328: /**
329: * Returns true if the node is a child.
330: *
331: * @param node the node to check
332: * @return true if the given node is a child
333: */
334: public abstract boolean isParentOf(FxTreeNodeInfo node);
335: }
|