Skip to content

Commit c12e0ae

Browse files
committed
refactor(Discovery v2): Make final adjustments from API changes
1 parent 32b4e9a commit c12e0ae

File tree

5 files changed

+55
-240
lines changed

5 files changed

+55
-240
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.ibm.watson.discovery.v2.model.QueryNoticesResponse;
4343
import com.ibm.watson.discovery.v2.model.QueryOptions;
4444
import com.ibm.watson.discovery.v2.model.QueryResponse;
45-
import com.ibm.watson.discovery.v2.model.TrainingExample;
4645
import com.ibm.watson.discovery.v2.model.TrainingQuery;
4746
import com.ibm.watson.discovery.v2.model.TrainingQuerySet;
4847
import com.ibm.watson.discovery.v2.model.UpdateDocumentOptions;
@@ -215,15 +214,13 @@ public ServiceCall<Completions> getAutocompletion(GetAutocompletionOptions getAu
215214
builder.header(header.getKey(), header.getValue());
216215
}
217216
builder.header("Accept", "application/json");
217+
builder.query("prefix", getAutocompletionOptions.prefix());
218218
if (getAutocompletionOptions.collectionIds() != null) {
219219
builder.query("collection_ids", RequestUtils.join(getAutocompletionOptions.collectionIds(), ","));
220220
}
221221
if (getAutocompletionOptions.field() != null) {
222222
builder.query("field", getAutocompletionOptions.field());
223223
}
224-
if (getAutocompletionOptions.prefix() != null) {
225-
builder.query("prefix", getAutocompletionOptions.prefix());
226-
}
227224
if (getAutocompletionOptions.count() != null) {
228225
builder.query("count", String.valueOf(getAutocompletionOptions.count()));
229226
}
@@ -264,27 +261,12 @@ public ServiceCall<QueryNoticesResponse> queryNotices(QueryNoticesOptions queryN
264261
if (queryNoticesOptions.naturalLanguageQuery() != null) {
265262
builder.query("natural_language_query", queryNoticesOptions.naturalLanguageQuery());
266263
}
267-
if (queryNoticesOptions.aggregation() != null) {
268-
builder.query("aggregation", queryNoticesOptions.aggregation());
269-
}
270264
if (queryNoticesOptions.count() != null) {
271265
builder.query("count", String.valueOf(queryNoticesOptions.count()));
272266
}
273-
if (queryNoticesOptions.xReturn() != null) {
274-
builder.query("return", RequestUtils.join(queryNoticesOptions.xReturn(), ","));
275-
}
276267
if (queryNoticesOptions.offset() != null) {
277268
builder.query("offset", String.valueOf(queryNoticesOptions.offset()));
278269
}
279-
if (queryNoticesOptions.sort() != null) {
280-
builder.query("sort", RequestUtils.join(queryNoticesOptions.sort(), ","));
281-
}
282-
if (queryNoticesOptions.highlight() != null) {
283-
builder.query("highlight", String.valueOf(queryNoticesOptions.highlight()));
284-
}
285-
if (queryNoticesOptions.spellingSuggestions() != null) {
286-
builder.query("spelling_suggestions", String.valueOf(queryNoticesOptions.spellingSuggestions()));
287-
}
288270
ResponseConverter<QueryNoticesResponse> responseConverter = ResponseConverterUtils.getValue(
289271
new com.google.gson.reflect.TypeToken<QueryNoticesResponse>() {
290272
}.getType());
@@ -633,9 +615,9 @@ public ServiceCall<TrainingQuery> getTrainingQuery(GetTrainingQueryOptions getTr
633615
* Updates an existing training query and it's examples.
634616
*
635617
* @param updateTrainingQueryOptions the {@link UpdateTrainingQueryOptions} containing the options for the call
636-
* @return a {@link ServiceCall} with a response type of {@link TrainingExample}
618+
* @return a {@link ServiceCall} with a response type of {@link TrainingQuery}
637619
*/
638-
public ServiceCall<TrainingExample> updateTrainingQuery(UpdateTrainingQueryOptions updateTrainingQueryOptions) {
620+
public ServiceCall<TrainingQuery> updateTrainingQuery(UpdateTrainingQueryOptions updateTrainingQueryOptions) {
639621
com.ibm.cloud.sdk.core.util.Validator.notNull(updateTrainingQueryOptions,
640622
"updateTrainingQueryOptions cannot be null");
641623
String[] pathSegments = { "v2/projects", "training_data/queries" };
@@ -660,8 +642,8 @@ public ServiceCall<TrainingExample> updateTrainingQuery(UpdateTrainingQueryOptio
660642
updateTrainingQueryOptions.examples()));
661643
}
662644
builder.bodyJson(contentJson);
663-
ResponseConverter<TrainingExample> responseConverter = ResponseConverterUtils.getValue(
664-
new com.google.gson.reflect.TypeToken<TrainingExample>() {
645+
ResponseConverter<TrainingQuery> responseConverter = ResponseConverterUtils.getValue(
646+
new com.google.gson.reflect.TypeToken<TrainingQuery>() {
665647
}.getType());
666648
return createServiceCall(builder.build(), responseConverter);
667649
}

discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@
2323
public class GetAutocompletionOptions extends GenericModel {
2424

2525
private String projectId;
26+
private String prefix;
2627
private List<String> collectionIds;
2728
private String field;
28-
private String prefix;
2929
private Long count;
3030

3131
/**
3232
* Builder.
3333
*/
3434
public static class Builder {
3535
private String projectId;
36+
private String prefix;
3637
private List<String> collectionIds;
3738
private String field;
38-
private String prefix;
3939
private Long count;
4040

4141
private Builder(GetAutocompletionOptions getAutocompletionOptions) {
4242
this.projectId = getAutocompletionOptions.projectId;
43+
this.prefix = getAutocompletionOptions.prefix;
4344
this.collectionIds = getAutocompletionOptions.collectionIds;
4445
this.field = getAutocompletionOptions.field;
45-
this.prefix = getAutocompletionOptions.prefix;
4646
this.count = getAutocompletionOptions.count;
4747
}
4848

@@ -56,9 +56,11 @@ public Builder() {
5656
* Instantiates a new builder with required properties.
5757
*
5858
* @param projectId the projectId
59+
* @param prefix the prefix
5960
*/
60-
public Builder(String projectId) {
61+
public Builder(String projectId, String prefix) {
6162
this.projectId = projectId;
63+
this.prefix = prefix;
6264
}
6365

6466
/**
@@ -97,6 +99,17 @@ public Builder projectId(String projectId) {
9799
return this;
98100
}
99101

102+
/**
103+
* Set the prefix.
104+
*
105+
* @param prefix the prefix
106+
* @return the GetAutocompletionOptions builder
107+
*/
108+
public Builder prefix(String prefix) {
109+
this.prefix = prefix;
110+
return this;
111+
}
112+
100113
/**
101114
* Set the collectionIds.
102115
* Existing collectionIds will be replaced.
@@ -120,17 +133,6 @@ public Builder field(String field) {
120133
return this;
121134
}
122135

123-
/**
124-
* Set the prefix.
125-
*
126-
* @param prefix the prefix
127-
* @return the GetAutocompletionOptions builder
128-
*/
129-
public Builder prefix(String prefix) {
130-
this.prefix = prefix;
131-
return this;
132-
}
133-
134136
/**
135137
* Set the count.
136138
*
@@ -146,10 +148,12 @@ public Builder count(long count) {
146148
private GetAutocompletionOptions(Builder builder) {
147149
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId,
148150
"projectId cannot be empty");
151+
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.prefix,
152+
"prefix cannot be null");
149153
projectId = builder.projectId;
154+
prefix = builder.prefix;
150155
collectionIds = builder.collectionIds;
151156
field = builder.field;
152-
prefix = builder.prefix;
153157
count = builder.count;
154158
}
155159

@@ -173,6 +177,18 @@ public String projectId() {
173177
return projectId;
174178
}
175179

180+
/**
181+
* Gets the prefix.
182+
*
183+
* The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to `Hot`, `Housing`, or `How
184+
* do I upgrade`. Possible completions are.
185+
*
186+
* @return the prefix
187+
*/
188+
public String prefix() {
189+
return prefix;
190+
}
191+
176192
/**
177193
* Gets the collectionIds.
178194
*
@@ -196,18 +212,6 @@ public String field() {
196212
return field;
197213
}
198214

199-
/**
200-
* Gets the prefix.
201-
*
202-
* The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to `Hot`, `Housing`, or `How
203-
* do I upgrade`. Possible completions are.
204-
*
205-
* @return the prefix
206-
*/
207-
public String prefix() {
208-
return prefix;
209-
}
210-
211215
/**
212216
* Gets the count.
213217
*

discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public interface Severity {
3737
private Date created;
3838
@SerializedName("document_id")
3939
private String documentId;
40+
@SerializedName("collection_id")
41+
private String collectionId;
4042
@SerializedName("query_id")
4143
private String queryId;
4244
private String severity;
@@ -83,6 +85,17 @@ public String getDocumentId() {
8385
return documentId;
8486
}
8587

88+
/**
89+
* Gets the collectionId.
90+
*
91+
* Unique identifier of the collection.
92+
*
93+
* @return the collectionId
94+
*/
95+
public String getCollectionId() {
96+
return collectionId;
97+
}
98+
8699
/**
87100
* Gets the queryId.
88101
*

0 commit comments

Comments
 (0)