Skip to content

Commit eaa04b7

Browse files
committed
Update README to include new stored procedure support.
1 parent 0a29f7a commit eaa04b7

File tree

1 file changed

+65
-17
lines changed

1 file changed

+65
-17
lines changed

README.md

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,36 @@ The **UncheckedThrow** class uses type erasure to enable client code to throw ch
2424

2525
## DatabaseUtils
2626

27-
The **DatabaseUtils** class provides facilities that enable you to define collections of Oracle database queries and execute them easily. Query collections are defined as Java enumerations that implement the `QueryAPI` interface:
27+
**DatabaseUtils** provides facilities that enable you to define collections of database queries and stored procedures in an easy-to-execute format.
28+
29+
Query collections are defined as Java enumerations that implement the `QueryAPI` interface:
2830
* `getQueryStr` - Get the query string for this constant. This is the actual query that's sent to the database.
2931
* `getArgNames` - Get the names of the arguments for this query. This provides diagnostic information if the incorrect number of arguments is specified by the client.
30-
* `getArgCount` - Get the number of arguments required by this query. This enables **DatabaseUtils** to verify that the correct number of arguments has been specified by the client.
3132
* `getConnection` - Get the connection string associated with this query. This eliminates the need for the client to provide this information.
32-
* `getEnum` - Get the enumeration to which this query belongs. This enables **DatabaseUtils** to retrieve the name of the query's enumerated constant for diagnostic messages.
33-
34-
To maximize usability and configurability, we recommend the following implementation strategy for your query collections:
35-
* Define your query collection as an enumeration that implements `QueryAPI`.
36-
* Define each query constant with a property name and a name for each argument (if any).
37-
* To assist users of your queries, preface their names with a type indicator (**GET** or **UPDATE**).
38-
* Back the query collection with a configuration that implements the `Settings API`:
39-
* groupId: com.nordstrom.tools
33+
* `getEnum` - Get the enumeration to which this query belongs. This enables `executeQuery(Class, QueryAPI, Object[])` to retrieve the name of the query's enumerated constant for diagnostic messages.
34+
35+
Store procedure collections are defined as Java enumerations that implement the `SProcAPI` interface:
36+
* `getSignature` - Get the signature for this stored procedure object. This defines the name of the stored procedure and the modes of its arguments. If the stored procedure accepts varargs, this will also be indicated.
37+
* `getArgTypes` - Get the argument types for this stored procedure object.
38+
* `getConnection` - Get the connection string associated with this stored procedure. This eliminates the need for the client to provide this information.
39+
* `getEnum` - Get the enumeration to which this stored procedure belongs. This enables `executeStoredProcedure(Class, SProcAPI, Object[])` to retrieve the name of the stored procedured's enumerated constant for diagnostic messages.
40+
41+
To maximize usability and configurability, we recommend the following implementation strategy:
42+
* Define your collection as an enumeration:
43+
* Query collections implement `QueryAPI`.
44+
* Stored procedure collections implement `SProcAPI`.
45+
* Define each constant:
46+
* (query) Specify a property name and a name for each argument (if any).
47+
* (sproc) Declare the signature and the type for each argument (if any).
48+
* To assist users of your queries, preface their names with a type indicator (<b>GET</b> or <b>UPDATE</b>).
49+
* Back query collections with configurations that implement the **`Settings API`**:
50+
* groupId: com.nordstrom.test-automation.tools
4051
* artifactId: settings
4152
* className: com.nordstrom.automation.settings.SettingsCore
42-
* To support execution on multiple endpoints, implement `getConnection` with sub-configurations or other dynamic data sources (e.g. - web service).
4353

44-
##### Query Collection Example
54+
* To support execution on multiple endpoints, implement `QueryAPI.getConnection()` or `SProcAPI.getConnection()` with sub-configurations or other dynamic data sources (e.g. - web service).
55+
56+
#### Query Collection Example
4557

4658
```java
4759
public class OpctConfig extends SettingsCore<OpctConfig.OpctValues> {
@@ -105,11 +117,6 @@ public class OpctConfig extends SettingsCore<OpctConfig.OpctValues> {
105117
return args;
106118
}
107119

108-
@Override
109-
public int getArgCount() {
110-
return args.length;
111-
}
112-
113120
@Override
114121
public String getConnection() {
115122
if (rmsQueries.contains(this)) {
@@ -162,6 +169,47 @@ public class OpctConfig extends SettingsCore<OpctConfig.OpctValues> {
162169
public static OpctConfig getConfig() {
163170
return OpctValues.config;
164171
}
172+
173+
public enum SProcValues implements SProcAPI {
174+
/** args: [ ] */
175+
SHOW_SUPPLIERS("SHOW_SUPPLIERS()"),
176+
/** args: [ coffee_name, supplier_name ] */
177+
GET_SUPPLIER_OF_COFFEE("GET_SUPPLIER_OF_COFFEE(>, <)", Types.VARCHAR, Types.VARCHAR),
178+
/** args: [ coffee_name, max_percent, new_price ] */
179+
RAISE_PRICE("RAISE_PRICE(>, >, =)", Types.VARCHAR, Types.REAL, Types.NUMERIC),
180+
/** args: [ str, val... ] */
181+
IN_VARARGS("IN_VARARGS(<, >:)", Types.VARCHAR, Types.INTEGER),
182+
/** args: [ val, str... ] */
183+
OUT_VARARGS("OUT_VARARGS(>, <:)", Types.INTEGER, Types.VARCHAR);
184+
185+
private int[] argTypes;
186+
private String signature;
187+
188+
SProcValues(String signature, int... argTypes) {
189+
this.signature = signature;
190+
this.argTypes = argTypes;
191+
}
192+
193+
@Override
194+
public String getSignature() {
195+
return signature;
196+
}
197+
198+
@Override
199+
public int[] getArgTypes () {
200+
return argTypes;
201+
}
202+
203+
@Override
204+
public String getConnection() {
205+
return OpctValues.getRmsConnect();
206+
}
207+
208+
@Override
209+
public Enum<SProcValues> getEnum() {
210+
return this;
211+
}
212+
}
165213
}
166214
```
167215

0 commit comments

Comments
 (0)