01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18: /*
19: * Created on Jan 13, 2004
20: */
21: package org.apache.roller.pojos;
22:
23: import org.apache.roller.RollerException;
24: import java.util.List;
25:
26: /**
27: * Abstract base class for hierarchical persistent objects. Provides generic
28: * implementations of save and remove that know how to handle parents, children,
29: * and descendents.
30: *
31: * @author David M Johnson
32: */
33: public abstract class HierarchicalPersistentObject extends
34: PersistentObject {
35: HierarchicalPersistentObject mNewParent = null;
36:
37: /** Create an association between object and ancestor. */
38: public abstract Assoc createAssoc(
39: HierarchicalPersistentObject object,
40: HierarchicalPersistentObject ancestor, String relation)
41: throws RollerException;
42:
43: /** Name of association class which must implement Assoc. */
44: public abstract Class getAssocClass();
45:
46: /** Name of object propery in association class */
47: public abstract String getObjectPropertyName();
48:
49: /** Name of ancestor propery in association class */
50: public abstract String getAncestorPropertyName();
51:
52: /** Set new parent - invalidates getPath() until object is saved(). */
53: public abstract void setParent(HierarchicalPersistentObject parent);
54:
55: public abstract Assoc getParentAssoc() throws RollerException;
56:
57: public abstract List getChildAssocs() throws RollerException;
58:
59: public abstract List getAllDescendentAssocs()
60: throws RollerException;
61:
62: public abstract List getAncestorAssocs() throws RollerException;
63:
64: /** Returns true if this object is in use and should not be deleted */
65: public abstract boolean isInUse() throws RollerException;
66:
67: /** Should be needed only be manager objects */
68: public HierarchicalPersistentObject getNewParent() {
69: return mNewParent;
70: }
71:
72: }
|