KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > listdata > persist > db > ListDatabaseSchema


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: ListDatabaseSchema.java,v 1.10 2007/01/07 06:14:23 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.patterns.listdata.persist.db;
23
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import org.opensubsystems.core.error.OSSException;
28 import org.opensubsystems.core.persist.db.DatabaseSchema;
29 import org.opensubsystems.patterns.listdata.data.ListOptions;
30
31 /**
32  * Base class for schemas allowing retrieving list of data objects.
33  *
34  * @version $Id: ListDatabaseSchema.java,v 1.10 2007/01/07 06:14:23 bastafidli Exp $
35  * @author Peter Satury
36  * @code.reviewer Miro Halas
37  * @code.reviewed 1.8 2006/08/07 22:28:19 jlegeny
38  */

39 public interface ListDatabaseSchema extends DatabaseSchema
40 {
41    /**
42     * Get query to select list of data objects.
43     *
44     * @param options - options describing what data objects to retrieve
45     * @param iDataType - data type for which to retrieve the list
46     * @return String - query
47     * @throws OSSException - an error has occured
48     */

49    String JavaDoc getSelectList(
50       ListOptions options,
51       // TODO: Improve: The data type should be part of the list options rather then
52
// specifying it explicitely like this
53
int iDataType
54    ) throws OSSException;
55    
56    /**
57     * Get from and where clause parts of the query in situation that the specified
58     * conditions refer to attributes, which are located in multiple tables.
59     *
60     * @param conditions - list of DataConditions specifying what attributes will
61     * be included in the query
62     * @param columns - array of all columns to retrieve
63     * @return String[] - index 0 - from clause specifying all tables where the
64     * attributes are located without the from
65     * - index 1 - where clause specifying if there are multiple
66     * tables how to navigate from one to another
67     */

68    String JavaDoc[] getJoinFromWhere(
69       List JavaDoc conditions,
70       int[] columns
71    );
72    
73    /**
74     * Convert any attribute regardless if it is in the main table or in join
75     * table into database column name.
76     *
77     * @param specific - if true - table_name.table_column, if false only table_column
78     * @param columns - specific array of columns codes
79     * @param prefixes - specific array of prefixes to prepend before each column,
80     * each prefix will be mapped with column and the same index
81     * they will be directly prepended or appended to the column
82     * name and therefore they need to contain any extra space if
83     * necessary,
84     * specify null, if no prefixes should be prepended
85     * @param postfixes - specific array of postfixes to prepend before each column,
86     * each prefix will be mapped with column and the same index
87     * they will be directly prepended or appended to the column
88     * name and therefore they need to contain any extra space if
89     * necessary,
90     * specify null, if no prefixes should be prepended
91     * @param buffer - buffer to use for column codes construction, it may
92     * already contain some value, if null, new one will be allocated
93     * @return StringBuffer - specific columns of table divided by comma
94     * with specified prefixes and postfixes
95     * @throws OSSException - error in columns find
96     */

97    StringBuffer JavaDoc getColumns(
98       boolean specific,
99       int[] columns,
100       Object JavaDoc[] prefixes,
101       Object JavaDoc[] postfixes,
102       StringBuffer JavaDoc buffer
103    ) throws OSSException;
104
105    /**
106     * Get collection of all columns that has to be retrieved for each data object
107     * supported by this schema. This method is required because the ListOptions
108     * allow use to specify columns that should be retrieved. If user interface
109     * allows user to specify these columns, the application may still need
110     * additional perhaps internal columns that needs to be retrieved as well for
111     * it to function correctly.
112     *
113     * @return Map - key is the data type, value is the int array (int[]) of
114     * column codes which has to be retrieved for a given data object.
115     */

116    Map JavaDoc getMandatoryRetrieveColumns();
117
118    /**
119     * Get collection of all columns that can be used to sort data objects
120     * supported by this schema. This method is required since some databases
121     * do not allow use all columns in ORDER BY clases depending on the type
122     * of the column.
123     *
124     * @return Map - Key is the data type, value is the array of column codes
125     * (int[])which can be used for sorting.
126     */

127    Map JavaDoc getSortableColumns();
128
129    /**
130     * Check if the the data object will use specified index for constructing query
131     * to retrieve records into the list.
132     *
133     * @param strIndexName - name of the index that will be checked for existency
134     * @return boolean - true if data object will use index
135     */

136    boolean isExistingIndex(
137       String JavaDoc strIndexName
138    );
139 }
140
Popular Tags