001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.sql.framework.model;
042:
043: import java.util.List;
044: import org.netbeans.modules.sql.framework.common.jdbc.SQLDBConnectionDefinition;
045: import org.w3c.dom.Element;
046: import net.java.hulp.i18n.Logger;
047: import com.sun.sql.framework.exception.BaseException;
048: import org.netbeans.modules.etl.logger.Localizer;
049: import org.netbeans.modules.etl.logger.LogUtil;
050:
051: /**
052: * SQL Framework Object factory
053: *
054: * @author Ritesh Adval
055: * @version $Revision$
056: */
057: public abstract class SQLModelObjectFactory {
058:
059: private static SQLModelObjectFactory instance = null;
060: private static final String LOG_CATEGORY = SQLModelObjectFactory.class
061: .getName();
062: private static transient final Logger mLogger = LogUtil
063: .getLogger(SQLModelObjectFactory.class.getName());
064: private static transient final Localizer mLoc = Localizer.get();
065:
066: /**
067: * Returns Singlton-instance of SQL Framework Object factory
068: *
069: * @return SQLModelObjectFactory factory instance
070: */
071: public static SQLModelObjectFactory getInstance() {
072: if (instance == null) {
073: try {
074: Class implClass = Class
075: .forName("org.netbeans.modules.sql.framework.model.impl.SQLModelObjectFactoryImpl");
076: instance = (SQLModelObjectFactory) implClass
077: .newInstance();
078: } catch (Exception ex) {
079: mLogger.errorNoloc(mLoc.t(
080: "PRSR135: Can't instantiate factory class{0}",
081: LOG_CATEGORY), ex);
082: }
083: }
084: return instance;
085: }
086:
087: /**
088: * Create a ConditionColumn
089: *
090: * @return ConditionColumn
091: */
092: public abstract ColumnRef createColumnRef();
093:
094: /**
095: * Create a ConditionColumn for a SQLDBColumn
096: *
097: * @param column
098: * @return ConditionColumn
099: */
100: public abstract ColumnRef createColumnRef(SQLDBColumn column);
101:
102: /**
103: * Create an extended DB Connection Definition
104: *
105: * @return SQLDBConnectionDefinition
106: */
107: public abstract SQLDBConnectionDefinition createDBConnectionDefinition();
108:
109: public abstract SQLDBConnectionDefinition createDBConnectionDefinition(
110: DBConnectionDefinition conf);
111:
112: public abstract SQLDBConnectionDefinition createDBConnectionDefinition(
113: String name, String dbType, String driverClass, String url,
114: String user, String password, String description);
115:
116: /**
117: * Create an extended DB Connection Definition from a given XML Element that hold the
118: * connection informations.
119: *
120: * @param element XML Element
121: * @return SQLDBConnectionDefinition
122: * @throws BaseException
123: */
124: public abstract SQLDBConnectionDefinition createDBConnectionDefinition(
125: Element element) throws BaseException;
126:
127: /**
128: * Create a DBModel Object
129: *
130: * @return SQLDBModel
131: */
132: public abstract SQLDBModel createDBModel(int type);
133:
134: /**
135: * create a DBModel Object
136: *
137: * @param src DatabaseModel
138: * @param modelType int
139: * @param sqlParent SQLFrameworkParentObject
140: * @return SQLDBModel
141: */
142: public abstract SQLDBModel createDBModel(DatabaseModel src,
143: int modelType, SQLFrameworkParentObject sqlParent);
144:
145: /**
146: * Create a SQLGroupBy Object
147: *
148: * @return SQLGroupBy
149: */
150: public abstract SQLGroupBy createGroupBy();
151:
152: /**
153: * Create a SQLGroupBy Object
154: *
155: * @param columns List of columns
156: * @param parent Table that holds the GroupBy object
157: * @return SQLGroupBy
158: */
159: public abstract SQLGroupBy createGroupBy(List columns, Object parent);
160:
161: /**
162: * Create a SQLFilter that accepts a single input (e.g., IS NULL, IS NOT NULL).
163: *
164: * @return
165: */
166: public abstract SQLFilter createLeftUnarySQLFilter();
167:
168: /**
169: * Create a SQLFilter that accepts a single input (e.g., NOT).
170: *
171: * @return
172: */
173: public abstract SQLFilter createRightUnarySQLFilter();
174:
175: public abstract RuntimeDatabaseModel createRuntimeDatabaseModel();
176:
177: public abstract RuntimeInput createRuntimeInput();
178:
179: public abstract RuntimeInput createRuntimeInput(RuntimeInput rinput);
180:
181: public abstract RuntimeOutput createRuntimeOutput();
182:
183: public abstract RuntimeOutput createRuntimeOutput(
184: RuntimeOutput routput);
185:
186: /**
187: * Create a Source Column for a given DB Column
188: *
189: * @param src DBColumn
190: * @return SourceColumn
191: */
192: public abstract SourceColumn createSourceColumn(DBColumn src);
193:
194: /**
195: * Create a Source Column
196: *
197: * @param colName String
198: * @param sqlJdbcType int
199: * @param colScale int
200: * @param colPrecision int
201: * @param isNullable boolean
202: * @return SourceColumn
203: */
204: public abstract SourceColumn createSourceColumn(String colName,
205: int sqlJdbcType, int colScale, int colPrecision,
206: boolean isNullable);
207:
208: /**
209: * Create a Source Column
210: *
211: * @param colName String
212: * @param sqlJdbcType int
213: * @param colScale int
214: * @param colPrecision int
215: * @param isPrimaryKey boolean
216: * @param isForeignKey boolean
217: * @param isIndexed boolean
218: * @param isNullable boolean
219: * @return SourceColumn
220: */
221: public abstract SourceColumn createSourceColumn(String colName,
222: int sqlJdbcType, int colScale, int colPrecision,
223: boolean isPrimaryKey, boolean isForeignKey,
224: boolean isIndexed, boolean isNullable);
225:
226: /**
227: * Create a SourceTable
228: *
229: * @param source DBTable
230: * @return SourceTable
231: */
232: public abstract SourceTable createSourceTable(DBTable source);
233:
234: /**
235: * Create a SourceTable
236: *
237: * @param name String
238: * @param schema String
239: * @param catalog String
240: * @return SourceTable
241: */
242: public abstract SourceTable createSourceTable(String name,
243: String schema, String catalog);
244:
245: /**
246: * Create a SQLCondition Object
247: *
248: * @param conditionName String
249: * @return SQLCondition
250: */
251: public abstract SQLCondition createSQLCondition(String conditionName);
252:
253: /**
254: * Creates an empty SQL Definition Object
255: *
256: * @return SQLDefinition
257: */
258: public abstract SQLDefinition createSQLDefinition();
259:
260: /**
261: * Creates a SQL Definition Object for a given XML Element, that hold the definition
262: * information
263: *
264: * @return SQLDefinition
265: */
266: public abstract SQLDefinition createSQLDefinition(Element element)
267: throws BaseException;
268:
269: /**
270: * Creates a SQL Definition Object for a given XML Element, that hold the definition
271: * information and links itself to the container/parent
272: *
273: * @param element
274: * @param parent SQLFrameworkParentObject
275: * @return SQLDefinition
276: * @throws BaseException
277: */
278: public abstract SQLDefinition createSQLDefinition(Element element,
279: SQLFrameworkParentObject parent) throws BaseException;
280:
281: /**
282: * Creates a named empty SQL Definition Object
283: *
284: * @return SQLDefinition
285: */
286: public abstract SQLDefinition createSQLDefinition(String defName);
287:
288: /**
289: * Create a SQLFilter
290: *
291: * @return SQLFilter
292: */
293: public abstract SQLFilter createSQLFilter();
294:
295: /**
296: * Create SQLFilter for a given XML Element
297: *
298: * @param element
299: * @return SQLFilter
300: * @throws BaseException
301: */
302: public abstract SQLFilter createSQLFilter(Element element)
303: throws BaseException;
304:
305: /**
306: * @return
307: */
308: public abstract SQLJoinOperator createSQLJoinOperator();
309:
310: /**
311: * Create a SQLJoinTable
312: *
313: * @param source SourceTable
314: * @return SQLJoinTable
315: */
316: public abstract SQLJoinTable createSQLJoinTable(SourceTable source);
317:
318: public abstract SQLJoinView createSQLJoinView();
319:
320: /**
321: * Create a SQLLiteral
322: *
323: * @param name String
324: * @param value String
325: * @param jdbcType int
326: * @return SQLLiteral
327: * @throws BaseException
328: */
329: public abstract SQLLiteral createSQLLiteral(String name,
330: String value, int jdbcType) throws BaseException;
331:
332: /**
333: * Create a SQLPredicate
334: *
335: * @return SQLPredicate
336: */
337: public abstract SQLPredicate createSQLPredicate();
338:
339: /**
340: * Create a Target Column for a given DB Column
341: *
342: * @param src DBColumn
343: * @return TargetColumn
344: */
345: public abstract TargetColumn createTargetColumn(DBColumn src);
346:
347: /**
348: * Create a Target Column
349: *
350: * @param colName String
351: * @param sqlJdbcType int
352: * @param colScale int
353: * @param colPrecision int
354: * @param isNullable boolean
355: * @return TargetColumn
356: */
357: public abstract TargetColumn createTargetColumn(String colName,
358: int sqlJdbcType, int colScale, int colPrecision,
359: boolean isNullable);
360:
361: /**
362: * Create a Target Column
363: *
364: * @param colName String
365: * @param sqlJdbcType int
366: * @param colScale int
367: * @param colPrecision int
368: * @param isPrimaryKey boolean
369: * @param isForeignKey boolean
370: * @param isIndexed boolean
371: * @param isNullable boolean
372: * @return TargetColumn
373: */
374: public abstract TargetColumn createTargetColumn(String colName,
375: int sqlJdbcType, int colScale, int colPrecision,
376: boolean isPrimaryKey, boolean isForeignKey,
377: boolean isIndexed, boolean isNullable);
378:
379: /**
380: * Create a TargetTable
381: *
382: * @param source DBTable
383: * @return TargetTable
384: */
385: public abstract TargetTable createTargetTable(DBTable source);
386:
387: /**
388: * Create a TargetTable
389: *
390: * @param name String
391: * @param schema String
392: * @param catalog String
393: * @return TargetTable
394: */
395: public abstract TargetTable createTargetTable(String name,
396: String schema, String catalog);
397:
398: public abstract ValidationInfo createValidationInfo(Object obj,
399: String description, int vType);
400:
401: /**
402: * Create a SQLVisibleLiteral
403: *
404: * @param name String
405: * @param value String
406: * @param jdbcType int
407: * @return SQLLiteral
408: * @throws BaseException
409: */
410: public abstract VisibleSQLLiteral createVisibleSQLLiteral(
411: String name, String value, int jdbcType)
412: throws BaseException;
413:
414: /**
415: * Create a VisibleSQLPredicate
416: *
417: * @return VisibleSQLPredicate
418: */
419: public abstract VisibleSQLPredicate createVisibleSQLPredicate();
420: }
|