1
package org.hisp.dhis.jdbc;
4
* Copyright (c) 2004-2007, University of Oslo
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
* * Neither the name of the HISP project nor the names of its contributors may
15
* be used to endorse or promote products derived from this software without
16
* specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
import java.util.Date;
33
import org.hisp.dhis.period.Period;
36
* @author Lars Helge Overland
37
* @version $Id: StatementBuilder.java 5715 2008-09-17 14:05:28Z larshelg $
39
public interface StatementBuilder
42
* Sets the index of the auto increment column of the statement.
44
* @param index the index.
46
void setAutoIncrementColumnIndex( int index );
49
* Sets the name of the auto increment column of the statement.
51
* @param name the name.
53
void setAutoIncrementColumnName( String name );
56
* Sets the name of the identifier column of the current object.
58
* @param identifierColumnName the name of the identifier column.
60
void setIdentifierColumnName( String identifierColumnName );
63
* Sets the value of identifier column of the current object.
65
* @param identifierColumnValue the value of the identifier column.
67
void setIdentifierColumnValue( Integer identifierColumnValue );
70
* Adds a column to the column list of the statement.
72
* @param column the column name.
74
void setColumn( String column );
77
* Adds a string to the value list of the statement.
79
* @param value the string value.
81
void setString( String value );
84
* Adds an int to the value list of the statement.
86
* @param value the int value.
88
void setInt( Integer value );
91
* Adds a double to the value list of the statement.
93
* @param value the double value.
95
void setDouble( Double value );
98
* Adds a boolean to the value list of the statement.
100
* @param value the boolean value.
102
void setBoolean( boolean value );
105
* Adds a date to the value list of the statement.
107
* @param value the date.
109
void setDate( Date value );
112
* Creates the opening of an insert SQL statement. The columns are added with
113
* the <code>setColumn( String )</code> method. The returned String is on the
114
* form <blockquote>INSERT INTO table ( column1, column2 ) VALUES </blockquote>.
116
* @param table the table to use in the SQL statement.
117
* @return the opening of an insert SQL statement.
119
String getInsertStatementOpening( String table );
122
* Creates the opening of an insert SQL statement with no columns defined.
124
* @param table the table to use in the SQL statement.
125
* @return the opening of an insert SQL statement.
127
String getNoColumnInsertStatementOpening( String table );
130
* Creates a value list for an insert SQL statement. The values are added with
131
* the various <code>setFoo( .. )</code> methods. The returned String is on the
132
* form <blockquote>( value1, value2 )</blockquote>.
134
* @return a value list for an insert SQL statement.
136
String getInsertStatementValues();
139
* Creates an update SQL statement. The columns are added with the
140
* <code>setColumn(..)</code> method, the values are added with the
141
* various <code>setFoo(..)</code> methods.
143
* @param table the name of the table.
146
String getUpdateStatement( String table );
149
* Creates a SELECT statement for the given parameters.
151
* @param table the table to use in the statement.
152
* @param returnField the table field to return from the query.
153
* @param compareField the table field to compare with the value.
154
* @param value the value to compare with the compareField.
155
* @return a SELECT statement for the given parameters.
157
String getValueStatement( String table, String returnField, String compareField, String value );
160
* Creates a SELECT statement for the given parameters.
162
* @param table the table to use in the statement.
163
* @param returnField1 the first table field to return from the query.
164
* @param returnField2 the second table field to return from the query.
165
* @param compareField1 the first table field to compare with the value.
166
* @param value1 the value to compare with the first compareField.
167
* @param compareField2 the second table field to compare with the value.
168
* @param value2 the value to compare with the second compareField.
169
* @return a SELECT statement for the given parameters.
171
String getValueStatement( String table, String returnField1, String returnField2, String compareField1, String value1, String compareField2, String value2 );
174
* Creates a SELECT statement for the given parameters.
176
* @param table the table to use in the statement.
177
* @param returnField the table field to return from the query.
178
* @param fieldMap the map of fields and values to compare.
179
* @param union true for AND, false for OR
180
* @return a SELECT statement for the given parameters.
182
String getValueStatement( String table, String returnField, Map<String, String> fieldMap, boolean union );
185
* Returns the name of a double column type.
186
* @return the name of a double column type.
188
String getDoubleColumnType();
191
* Creates a SELECT statement returning the identifier of the given Period.
193
* @param period the Period to use in the statement.
194
* @return a SELECT statement returning the identifier of the given Period.
196
String getPeriodIdentifierStatement( Period period );
199
* Creates a create table statement fot the aggregated datavalue table.
200
* @return a create table statement fot the aggregated datavalue table.
202
String getCreateAggregatedDataValueTable();
205
* Creates a create table statement for the aggregated indicatorvalue table.
206
* @return a create table statement for the aggregated indicatorvalue table.
208
String getCreateAggregatedIndicatorTable();
211
* Creates a create table statement for the aggregated datasetcompleteness table.
212
* @return a create table statement for the aggregated datasetcompleteness table.
214
String getCreateDataSetCompletenessTable();
217
* Creates a create index statement for the datavalue table.
218
* @return a create index statement for the datavalue table.
220
String getCreateDataValueIndex();
223
* Creates a delete periods of type relative statement.
224
* @return a delete periods of type relative statement.
226
String getDeleteRelativePeriods();
229
* Creates a delete datavalue statement.
230
* @return a delete datavalue statement.
232
String getDeleteZeroDataValues();