Skip to content

Commit 955742b

Browse files
committed
fix(Discovery v1): Ensure collectionIds are supplied to avoid service error
1 parent b95388a commit 955742b

File tree

1 file changed

+54
-50
lines changed

1 file changed

+54
-50
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java

+54-50
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2019.
2+
* (C) Copyright IBM Corp. 2020.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -19,34 +19,35 @@
1919
*/
2020
public class FederatedQueryOptions extends GenericModel {
2121

22-
private String environmentId;
23-
private String filter;
24-
private String query;
25-
private String naturalLanguageQuery;
26-
private Boolean passages;
27-
private String aggregation;
28-
private Long count;
29-
private String xReturn;
30-
private Long offset;
31-
private String sort;
32-
private Boolean highlight;
33-
private String passagesFields;
34-
private Long passagesCount;
35-
private Long passagesCharacters;
36-
private Boolean deduplicate;
37-
private String deduplicateField;
38-
private Boolean similar;
39-
private String similarDocumentIds;
40-
private String similarFields;
41-
private String bias;
42-
private String collectionIds;
43-
private Boolean xWatsonLoggingOptOut;
22+
protected String environmentId;
23+
protected String collectionIds;
24+
protected String filter;
25+
protected String query;
26+
protected String naturalLanguageQuery;
27+
protected Boolean passages;
28+
protected String aggregation;
29+
protected Long count;
30+
protected String xReturn;
31+
protected Long offset;
32+
protected String sort;
33+
protected Boolean highlight;
34+
protected String passagesFields;
35+
protected Long passagesCount;
36+
protected Long passagesCharacters;
37+
protected Boolean deduplicate;
38+
protected String deduplicateField;
39+
protected Boolean similar;
40+
protected String similarDocumentIds;
41+
protected String similarFields;
42+
protected String bias;
43+
protected Boolean xWatsonLoggingOptOut;
4444

4545
/**
4646
* Builder.
4747
*/
4848
public static class Builder {
4949
private String environmentId;
50+
private String collectionIds;
5051
private String filter;
5152
private String query;
5253
private String naturalLanguageQuery;
@@ -66,11 +67,11 @@ public static class Builder {
6667
private String similarDocumentIds;
6768
private String similarFields;
6869
private String bias;
69-
private String collectionIds;
7070
private Boolean xWatsonLoggingOptOut;
7171

7272
private Builder(FederatedQueryOptions federatedQueryOptions) {
7373
this.environmentId = federatedQueryOptions.environmentId;
74+
this.collectionIds = federatedQueryOptions.collectionIds;
7475
this.filter = federatedQueryOptions.filter;
7576
this.query = federatedQueryOptions.query;
7677
this.naturalLanguageQuery = federatedQueryOptions.naturalLanguageQuery;
@@ -90,7 +91,6 @@ private Builder(FederatedQueryOptions federatedQueryOptions) {
9091
this.similarDocumentIds = federatedQueryOptions.similarDocumentIds;
9192
this.similarFields = federatedQueryOptions.similarFields;
9293
this.bias = federatedQueryOptions.bias;
93-
this.collectionIds = federatedQueryOptions.collectionIds;
9494
this.xWatsonLoggingOptOut = federatedQueryOptions.xWatsonLoggingOptOut;
9595
}
9696

@@ -104,9 +104,11 @@ public Builder() {
104104
* Instantiates a new builder with required properties.
105105
*
106106
* @param environmentId the environmentId
107+
* @param collectionIds the collectionIds
107108
*/
108-
public Builder(String environmentId) {
109+
public Builder(String environmentId, String collectionIds) {
109110
this.environmentId = environmentId;
111+
this.collectionIds = collectionIds;
110112
}
111113

112114
/**
@@ -129,6 +131,17 @@ public Builder environmentId(String environmentId) {
129131
return this;
130132
}
131133

134+
/**
135+
* Set the collectionIds.
136+
*
137+
* @param collectionIds the collectionIds
138+
* @return the FederatedQueryOptions builder
139+
*/
140+
public Builder collectionIds(String collectionIds) {
141+
this.collectionIds = collectionIds;
142+
return this;
143+
}
144+
132145
/**
133146
* Set the filter.
134147
*
@@ -338,17 +351,6 @@ public Builder bias(String bias) {
338351
return this;
339352
}
340353

341-
/**
342-
* Set the collectionIds.
343-
*
344-
* @param collectionIds the collectionIds
345-
* @return the FederatedQueryOptions builder
346-
*/
347-
public Builder collectionIds(String collectionIds) {
348-
this.collectionIds = collectionIds;
349-
return this;
350-
}
351-
352354
/**
353355
* Set the xWatsonLoggingOptOut.
354356
*
@@ -361,10 +363,13 @@ public Builder xWatsonLoggingOptOut(Boolean xWatsonLoggingOptOut) {
361363
}
362364
}
363365

364-
private FederatedQueryOptions(Builder builder) {
366+
protected FederatedQueryOptions(Builder builder) {
365367
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId,
366368
"environmentId cannot be empty");
369+
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionIds,
370+
"collectionIds cannot be null");
367371
environmentId = builder.environmentId;
372+
collectionIds = builder.collectionIds;
368373
filter = builder.filter;
369374
query = builder.query;
370375
naturalLanguageQuery = builder.naturalLanguageQuery;
@@ -384,7 +389,6 @@ private FederatedQueryOptions(Builder builder) {
384389
similarDocumentIds = builder.similarDocumentIds;
385390
similarFields = builder.similarFields;
386391
bias = builder.bias;
387-
collectionIds = builder.collectionIds;
388392
xWatsonLoggingOptOut = builder.xWatsonLoggingOptOut;
389393
}
390394

@@ -408,6 +412,17 @@ public String environmentId() {
408412
return environmentId;
409413
}
410414

415+
/**
416+
* Gets the collectionIds.
417+
*
418+
* A comma-separated list of collection IDs to be queried against.
419+
*
420+
* @return the collectionIds
421+
*/
422+
public String collectionIds() {
423+
return collectionIds;
424+
}
425+
411426
/**
412427
* Gets the filter.
413428
*
@@ -640,17 +655,6 @@ public String bias() {
640655
return bias;
641656
}
642657

643-
/**
644-
* Gets the collectionIds.
645-
*
646-
* A comma-separated list of collection IDs to be queried against.
647-
*
648-
* @return the collectionIds
649-
*/
650-
public String collectionIds() {
651-
return collectionIds;
652-
}
653-
654658
/**
655659
* Gets the xWatsonLoggingOptOut.
656660
*

0 commit comments

Comments
 (0)