Skip to content

Commit bbf16cc

Browse files
authored
Merge pull request #917 from watson-developer-cloud/codegen/discovery
Add support for remaining Discovery aggregations
2 parents a96b15f + 9b6f55b commit bbf16cc

25 files changed

+879
-82
lines changed

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ public ServiceCall<Void> deleteConfiguration(DeleteConfigurationOptions deleteCo
336336
public ServiceCall<Configuration> getConfiguration(GetConfigurationOptions getConfigurationOptions) {
337337
Validator.notNull(getConfigurationOptions, "getConfigurationOptions cannot be null");
338338
String[] pathSegments = { "v1/environments", "configurations" };
339-
String[] pathParameters = { getConfigurationOptions.environmentId(), getConfigurationOptions
340-
.configurationId() };
339+
String[] pathParameters = { getConfigurationOptions.environmentId(), getConfigurationOptions.configurationId() };
341340
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
342341
pathParameters));
343342
builder.query(VERSION, versionDate);
@@ -979,6 +978,9 @@ public ServiceCall<QueryEntitiesResponse> queryEntities(QueryEntitiesOptions que
979978
if (queryEntitiesOptions.count() != null) {
980979
contentJson.addProperty("count", queryEntitiesOptions.count());
981980
}
981+
if (queryEntitiesOptions.evidenceCount() != null) {
982+
contentJson.addProperty("evidence_count", queryEntitiesOptions.evidenceCount());
983+
}
982984
builder.bodyJson(contentJson);
983985
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryEntitiesResponse.class));
984986
}
@@ -1087,6 +1089,9 @@ public ServiceCall<QueryRelationsResponse> queryRelations(QueryRelationsOptions
10871089
if (queryRelationsOptions.count() != null) {
10881090
contentJson.addProperty("count", queryRelationsOptions.count());
10891091
}
1092+
if (queryRelationsOptions.evidenceCount() != null) {
1093+
contentJson.addProperty("evidence_count", queryRelationsOptions.evidenceCount());
1094+
}
10901095
builder.bodyJson(contentJson);
10911096
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryRelationsResponse.class));
10921097
}
@@ -1257,8 +1262,8 @@ public ServiceCall<TrainingExampleList> listTrainingExamples(
12571262
ListTrainingExamplesOptions listTrainingExamplesOptions) {
12581263
Validator.notNull(listTrainingExamplesOptions, "listTrainingExamplesOptions cannot be null");
12591264
String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" };
1260-
String[] pathParameters = { listTrainingExamplesOptions.environmentId(), listTrainingExamplesOptions
1261-
.collectionId(), listTrainingExamplesOptions.queryId() };
1265+
String[] pathParameters = { listTrainingExamplesOptions.environmentId(), listTrainingExamplesOptions.collectionId(),
1266+
listTrainingExamplesOptions.queryId() };
12621267
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
12631268
pathParameters));
12641269
builder.query(VERSION, versionDate);

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Calculation.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@
1717
*/
1818
public class Calculation extends QueryAggregation {
1919

20+
private String field;
2021
private Double value;
2122

23+
/**
24+
* Gets the field.
25+
*
26+
* The field where the aggregation is located in the document.
27+
*
28+
* @return the field
29+
*/
30+
public String getField() {
31+
return field;
32+
}
33+
2234
/**
2335
* Gets the value.
2436
*
25-
* Value of the aggregation. (For 'max' and 'min' type).
37+
* Value of the aggregation.
2638
*
2739
* @return the value
2840
*/

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Conversions.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class Conversions extends GenericModel {
2525
private PdfSettings pdf;
2626
private WordSettings word;
2727
private HtmlSettings html;
28+
private SegmentSettings segment;
2829
@SerializedName("json_normalizations")
2930
private List<NormalizationOperation> jsonNormalizations;
3031

@@ -61,6 +62,17 @@ public HtmlSettings getHtml() {
6162
return html;
6263
}
6364

65+
/**
66+
* Gets the segment.
67+
*
68+
* A list of Document Segmentation settings.
69+
*
70+
* @return the segment
71+
*/
72+
public SegmentSettings getSegment() {
73+
return segment;
74+
}
75+
6476
/**
6577
* Gets the jsonNormalizations.
6678
*
@@ -100,6 +112,15 @@ public void setHtml(final HtmlSettings html) {
100112
this.html = html;
101113
}
102114

115+
/**
116+
* Sets the segment.
117+
*
118+
* @param segment the new segment
119+
*/
120+
public void setSegment(final SegmentSettings segment) {
121+
this.segment = segment;
122+
}
123+
103124
/**
104125
* Sets the jsonNormalizations.
105126
*
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.developer_cloud.discovery.v1.model;
14+
15+
/**
16+
* Filter.
17+
*/
18+
public class Filter extends QueryAggregation {
19+
20+
private String match;
21+
22+
/**
23+
* Gets the match.
24+
*
25+
* The match the aggregated results queried for.
26+
*
27+
* @return the match
28+
*/
29+
public String getMatch() {
30+
return match;
31+
}
32+
}

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Histogram.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@
1717
*/
1818
public class Histogram extends QueryAggregation {
1919

20+
private String field;
2021
private Long interval;
2122

23+
/**
24+
* Gets the field.
25+
*
26+
* The field where the aggregation is located in the document.
27+
*
28+
* @return the field
29+
*/
30+
public String getField() {
31+
return field;
32+
}
33+
2234
/**
2335
* Gets the interval.
2436
*
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.developer_cloud.discovery.v1.model;
14+
15+
/**
16+
* Nested.
17+
*/
18+
public class Nested extends QueryAggregation {
19+
20+
private String path;
21+
22+
/**
23+
* Gets the path.
24+
*
25+
* The area of the results the aggregation was restricted to.
26+
*
27+
* @return the path
28+
*/
29+
public String getPath() {
30+
return path;
31+
}
32+
}

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
public class QueryAggregation extends GenericModel {
2727

2828
private String type;
29-
private String field;
3029
private List<AggregationResult> results;
31-
private String match;
3230
@SerializedName("matching_results")
3331
private Long matchingResults;
3432
private List<QueryAggregation> aggregations;
@@ -44,17 +42,6 @@ public String getType() {
4442
return type;
4543
}
4644

47-
/**
48-
* Gets the field.
49-
*
50-
* The field where the aggregation is located in the document.
51-
*
52-
* @return the field
53-
*/
54-
public String getField() {
55-
return field;
56-
}
57-
5845
/**
5946
* Gets the results.
6047
*
@@ -64,17 +51,6 @@ public List<AggregationResult> getResults() {
6451
return results;
6552
}
6653

67-
/**
68-
* Gets the match.
69-
*
70-
* The match the aggregated results queried for.
71-
*
72-
* @return the match
73-
*/
74-
public String getMatch() {
75-
return match;
76-
}
77-
7854
/**
7955
* Gets the matchingResults.
8056
*
@@ -106,15 +82,6 @@ public void setType(final String type) {
10682
this.type = type;
10783
}
10884

109-
/**
110-
* Sets the field.
111-
*
112-
* @param field the new field
113-
*/
114-
public void setField(final String field) {
115-
this.field = field;
116-
}
117-
11885
/**
11986
* Sets the results.
12087
*
@@ -124,15 +91,6 @@ public void setResults(final List<AggregationResult> results) {
12491
this.results = results;
12592
}
12693

127-
/**
128-
* Sets the match.
129-
*
130-
* @param match the new match
131-
*/
132-
public void setMatch(final String match) {
133-
this.match = match;
134-
}
135-
13694
/**
13795
* Sets the matchingResults.
13896
*

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesOptions.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class QueryEntitiesOptions extends GenericModel {
2626
private QueryEntitiesEntity entity;
2727
private QueryEntitiesContext context;
2828
private Long count;
29+
private Long evidenceCount;
2930

3031
/**
3132
* Builder.
@@ -37,6 +38,7 @@ public static class Builder {
3738
private QueryEntitiesEntity entity;
3839
private QueryEntitiesContext context;
3940
private Long count;
41+
private Long evidenceCount;
4042

4143
private Builder(QueryEntitiesOptions queryEntitiesOptions) {
4244
environmentId = queryEntitiesOptions.environmentId;
@@ -45,6 +47,7 @@ private Builder(QueryEntitiesOptions queryEntitiesOptions) {
4547
entity = queryEntitiesOptions.entity;
4648
context = queryEntitiesOptions.context;
4749
count = queryEntitiesOptions.count;
50+
evidenceCount = queryEntitiesOptions.evidenceCount;
4851
}
4952

5053
/**
@@ -138,6 +141,17 @@ public Builder count(long count) {
138141
this.count = count;
139142
return this;
140143
}
144+
145+
/**
146+
* Set the evidenceCount.
147+
*
148+
* @param evidenceCount the evidenceCount
149+
* @return the QueryEntitiesOptions builder
150+
*/
151+
public Builder evidenceCount(long evidenceCount) {
152+
this.evidenceCount = evidenceCount;
153+
return this;
154+
}
141155
}
142156

143157
private QueryEntitiesOptions(Builder builder) {
@@ -149,6 +163,7 @@ private QueryEntitiesOptions(Builder builder) {
149163
entity = builder.entity;
150164
context = builder.context;
151165
count = builder.count;
166+
evidenceCount = builder.evidenceCount;
152167
}
153168

154169
/**
@@ -185,7 +200,7 @@ public String collectionId() {
185200
/**
186201
* Gets the feature.
187202
*
188-
* The entity query feature to perform. Must be `disambiguate`.
203+
* The entity query feature to perform. Supported features are `disambiguate` and `similar_entities`.
189204
*
190205
* @return the feature
191206
*/
@@ -226,4 +241,16 @@ public QueryEntitiesContext context() {
226241
public Long count() {
227242
return count;
228243
}
244+
245+
/**
246+
* Gets the evidenceCount.
247+
*
248+
* The number of evidence items to return for each result. The default is `0`. The maximum number of evidence items
249+
* per query is 10,000.
250+
*
251+
* @return the evidenceCount
252+
*/
253+
public Long evidenceCount() {
254+
return evidenceCount;
255+
}
229256
}

discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
*/
2222
public class QueryEntitiesResponse extends GenericModel {
2323

24-
private List<QueryEntitiesEntity> entities;
24+
private List<QueryEntitiesResponseItem> entities;
2525

2626
/**
2727
* Gets the entities.
2828
*
2929
* @return the entities
3030
*/
31-
public List<QueryEntitiesEntity> getEntities() {
31+
public List<QueryEntitiesResponseItem> getEntities() {
3232
return entities;
3333
}
3434
}

0 commit comments

Comments
 (0)