~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-api/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.hisp.dhis.jdbc;
 
2
 
 
3
/*
 
4
 * Copyright (c) 2004-2007, University of Oslo
 
5
 * All rights reserved.
 
6
 *
 
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.
 
17
 *
 
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.
 
28
 */
 
29
 
 
30
import java.util.Date;
 
31
import java.util.Map;
 
32
 
 
33
import org.hisp.dhis.period.Period;
 
34
 
 
35
/**
 
36
 * @author Lars Helge Overland
 
37
 * @version $Id: StatementBuilder.java 5715 2008-09-17 14:05:28Z larshelg $
 
38
 */
 
39
public interface StatementBuilder
 
40
{
 
41
    /**
 
42
     * Sets the index of the auto increment column of the statement.
 
43
     * 
 
44
     * @param index the index.
 
45
     */
 
46
    void setAutoIncrementColumnIndex( int index );
 
47
    
 
48
    /**
 
49
     * Sets the name of the auto increment column of the statement.
 
50
     * 
 
51
     * @param name the name.
 
52
     */
 
53
    void setAutoIncrementColumnName( String name );
 
54
    
 
55
    /**
 
56
     * Sets the name of the identifier column of the current object.
 
57
     * 
 
58
     * @param identifierColumnName the name of the identifier column.
 
59
     */
 
60
    void setIdentifierColumnName( String identifierColumnName );
 
61
    
 
62
    /**
 
63
     * Sets the value of identifier column of the current object.
 
64
     * 
 
65
     * @param identifierColumnValue the value of the identifier column.
 
66
     */    
 
67
    void setIdentifierColumnValue( Integer identifierColumnValue );
 
68
    
 
69
    /**
 
70
     * Adds a column to the column list of the statement.
 
71
     * 
 
72
     * @param column the column name.
 
73
     */
 
74
    void setColumn( String column );
 
75
    
 
76
    /**
 
77
     * Adds a string to the value list of the statement.
 
78
     * 
 
79
     * @param value the string value.
 
80
     */
 
81
    void setString( String value );
 
82
    
 
83
    /**
 
84
     * Adds an int to the value list of the statement.
 
85
     * 
 
86
     * @param value the int value.
 
87
     */
 
88
    void setInt( Integer value );
 
89
    
 
90
    /**
 
91
     * Adds a double to the value list of the statement.
 
92
     * 
 
93
     * @param value the double value.
 
94
     */
 
95
    void setDouble( Double value );
 
96
 
 
97
    /**
 
98
     * Adds a boolean to the value list of the statement.
 
99
     * 
 
100
     * @param value the boolean value.
 
101
     */
 
102
    void setBoolean( boolean value );
 
103
    
 
104
    /**
 
105
     * Adds a date to the value list of the statement.
 
106
     * 
 
107
     * @param value the date.
 
108
     */
 
109
    void setDate( Date value );
 
110
    
 
111
    /**
 
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>.
 
115
     * 
 
116
     * @param table the table to use in the SQL statement.
 
117
     * @return the opening of an insert SQL statement.
 
118
     */
 
119
    String getInsertStatementOpening( String table );
 
120
    
 
121
    /**
 
122
     * Creates the opening of an insert SQL statement with no columns defined.
 
123
     * 
 
124
     * @param table the table to use in the SQL statement.
 
125
     * @return the opening of an insert SQL statement.
 
126
     */
 
127
    String getNoColumnInsertStatementOpening( String table );
 
128
    
 
129
    /**
 
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>.
 
133
     * 
 
134
     * @return a value list for an insert SQL statement.
 
135
     */
 
136
    String getInsertStatementValues();
 
137
    
 
138
    /**
 
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.
 
142
     * 
 
143
     * @param table the name of the table.
 
144
     * @return
 
145
     */
 
146
    String getUpdateStatement( String table );
 
147
    
 
148
    /**
 
149
     * Creates a SELECT statement for the given parameters.
 
150
     * 
 
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.
 
156
     */
 
157
    String getValueStatement( String table, String returnField, String compareField, String value );
 
158
    
 
159
    /**
 
160
     * Creates a SELECT statement for the given parameters.
 
161
     * 
 
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.
 
170
     */
 
171
    String getValueStatement( String table, String returnField1, String returnField2, String compareField1, String value1, String compareField2, String value2 );
 
172
    
 
173
    /**
 
174
     * Creates a SELECT statement for the given parameters.
 
175
     * 
 
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.
 
181
     */
 
182
    String getValueStatement( String table, String returnField, Map<String, String> fieldMap, boolean union );
 
183
    
 
184
    /**
 
185
     * Returns the name of a double column type.
 
186
     * @return the name of a double column type.
 
187
     */
 
188
    String getDoubleColumnType();
 
189
    
 
190
    /**
 
191
     * Creates a SELECT statement returning the identifier of the given Period.
 
192
     * 
 
193
     * @param period the Period to use in the statement. 
 
194
     * @return a SELECT statement returning the identifier of the given Period.
 
195
     */
 
196
    String getPeriodIdentifierStatement( Period period );
 
197
    
 
198
    /**
 
199
     * Creates a create table statement fot the aggregated datavalue table.
 
200
     * @return a create table statement fot the aggregated datavalue table.
 
201
     */
 
202
    String getCreateAggregatedDataValueTable();
 
203
    
 
204
    /**
 
205
     * Creates a create table statement for the aggregated indicatorvalue table.
 
206
     * @return a create table statement for the aggregated indicatorvalue table.
 
207
     */    
 
208
    String getCreateAggregatedIndicatorTable();
 
209
 
 
210
    /**
 
211
     * Creates a create table statement for the aggregated datasetcompleteness table.
 
212
     * @return a create table statement for the aggregated datasetcompleteness table.
 
213
     */
 
214
    String getCreateDataSetCompletenessTable();
 
215
    
 
216
    /**
 
217
     * Creates a create index statement for the datavalue table.
 
218
     * @return a create index statement for the datavalue table.
 
219
     */
 
220
    String getCreateDataValueIndex();
 
221
    
 
222
    /**
 
223
     * Creates a delete periods of type relative statement.
 
224
     * @return a delete periods of type relative statement.
 
225
     */
 
226
    String getDeleteRelativePeriods();
 
227
    
 
228
    /**
 
229
     * Creates a delete datavalue statement.
 
230
     * @return a delete datavalue statement.
 
231
     */
 
232
    String getDeleteZeroDataValues();
 
233
}