001: /**
002: * Objective Database Abstraction Layer (ODAL)
003: * Copyright (c) 2004, The ODAL Development Group
004: * All rights reserved.
005: * For definition of the ODAL Development Group please refer to LICENCE.txt file
006: *
007: * Distributable under LGPL license.
008: * See terms of license at gnu.org.
009: */package com.completex.objective.components.persistency;
010:
011: import com.completex.objective.components.persistency.core.Join;
012:
013: /**
014: * Describes compound persistent object - one that is based on array of other
015: * persistent objects
016: *
017: * @author Gennady Krizhevsky
018: */
019: public interface Compound extends PersistentObjectFactory {
020:
021: public static final ImplicitJoinMode INNER = ImplicitJoinMode.INNER;
022: public static final ImplicitJoinMode OUTER = ImplicitJoinMode.OUTER;
023: public static final ImplicitJoinMode NONE = ImplicitJoinMode.NONE;
024:
025: /**
026: * Returns number of compound etries
027: *
028: * @return number of compound etries
029: */
030: int compoundSize();
031:
032: /**
033: * Sets <tt>PersistentObject</tt> - compound entry at specific index
034: *
035: * @param index index which entry to be set
036: * @param persistentObject compound entry
037: */
038: void compoundEntry(int index, PersistentObject persistentObject);
039:
040: /**
041: * Returns <tt>PersistentObject</tt> - compound entry at specific index
042: *
043: * @param index index which entry to be returned
044: * @return <tt>PersistentObject</tt> - compound entry
045: * @throws IndexOutOfBoundsException if there is no entry at requested index
046: */
047: PersistentObject compoundEntry(int index);
048:
049: /**
050: * Returns <tt>PersistentObject []</tt> - compound entries of this object
051: *
052: * @return <tt>PersistentObject []</tt> - compound entries of this object
053: */
054: PersistentObject[] compoundEntries();
055:
056: /**
057: * Returns true if this is this type of object can be the 1st object of PersistentObject[]
058: * of compound PersistentObject.
059: *
060: * @return true if this is the 1st object in PersistentObject[] of compound PersistentObject
061: */
062: boolean selfReferencing();
063:
064: /**
065: * Returns implicit join mode
066: *
067: * @see ImplicitJoinMode
068: * @return implicit join mode
069: */
070: ImplicitJoinMode implicitJoinMode();
071:
072: /**
073: * This method will be called on compound object to create default
074: * join
075: * @return created join
076: */
077: Join join();
078:
079: /**
080: * This method will create join implicitely based on the mutual references
081: * It is more coarse than joinImplicitely(Join.Type [] joinTypes) one
082: * since there are only 3 possibilities: OUTER, when all the objects with index > 0
083: * join the [0] one with left outer join, and INNER, when all the objects are joined
084: * with INNER join.
085: * @return created join
086: */
087: Join joinImplicitely(Compound.ImplicitJoinMode implicitJoinMode);
088:
089: /**
090: * This method will create join implicitely based on the mutual references
091: * To run it all the persistentObjects have to exist.
092: * As a result, all the objects with index > 0 will joing the one with index 0
093: * @return created join
094: */
095: Join joinImplicitely(Join.Type[] joinTypes);
096:
097: /**
098: * Populate compound Entry By Join
099: *
100: * @param indexFrom - entry index of the master <tt>PersistentObject</tt>
101: * @param indexTo - entry index of the slave <tt>PersistentObject</tt>
102: */
103: void populateCompoundEntryByJoin(int indexFrom, int indexTo);
104:
105: /**
106: * Populates all entries by join
107: */
108: void populateCompoundEntries();
109:
110: /**
111: * Returns true if cascade insert is to be performed based on entries joins
112: *
113: * @return true if cascade insert is to be performed based on entries joins
114: */
115: boolean compoundCascadeInsert();
116:
117: /**
118: * Returns true if cascade delete is to be performed based on entries joins
119: *
120: * @return true if cascade delete is to be performed based on entries joins
121: */
122: boolean compoundCascadeDelete();
123:
124: /**
125: * Returns true if cascade insert is to be performed based on entries joins
126: * for entry specified by index parameter
127: *
128: * @param index
129: * @return true if cascade insert is to be performed based on entries joins
130: * for entry specified by index parameter
131: */
132: boolean compoundCascadeInsert(int index);
133:
134: /**
135: * Sets flag to indicate if cascade insert is to be performed based on entries joins
136: * for entry specified by index parameter
137: *
138: * @param index
139: * @param compoundCascadeInsert flag to indicate if cascade insert is to be performed based on entries joins
140: * for entry specified by index parameter
141: */
142: void compoundCascadeInsert(int index, boolean compoundCascadeInsert);
143:
144: /**
145: * Returns true if cascade delete is to be performed based on entries joins
146: * for entry specified by index parameter
147: *
148: * @param index
149: * @return true if cascade delete is to be performed based on entries joins
150: * for entry specified by index parameter
151: */
152: boolean compoundCascadeDelete(int index);
153:
154: /**
155: * Sets flag to indicate if cascade delete is to be performed based on entries joins
156: * for entry specified by index parameter
157: *
158: * @param index
159: * @param compoundCascadeDelete flag to indicate if cascade delete is to be performed based on entries joins
160: * for entry specified by index parameter
161: */
162: void compoundCascadeDelete(int index, boolean compoundCascadeDelete);
163:
164: /**
165: * Returns true if this object has been modified
166: *
167: * @return true if this object has been modified
168: */
169: boolean dirty();
170:
171: /**
172: * Joins all the compound entries according to Compound.ImplicitJoinMode passed
173: *
174: * @param implicitJoinMode
175: * @return new Join
176: */
177: Join join(ImplicitJoinMode implicitJoinMode);
178:
179: /**
180: * Sets implicitJoinMode
181: *
182: * @param implicitJoinMode
183: */
184: void implicitJoinMode(ImplicitJoinMode implicitJoinMode);
185:
186: /**
187: * Type of implicit (based on primary-foreign key relationship) join
188: */
189: public static class ImplicitJoinMode {
190:
191: public static final ImplicitJoinMode INNER = new ImplicitJoinMode(
192: Join.INNER.toString());
193: public static final ImplicitJoinMode OUTER = new ImplicitJoinMode(
194: Join.LEFT.toString());
195: public static final ImplicitJoinMode NONE = new ImplicitJoinMode(
196: "NONE");
197:
198: private String name;
199:
200: private ImplicitJoinMode(String name) {
201: this .name = name;
202: }
203:
204: public String toString() {
205: return name;
206: }
207: }
208:
209: }
|