Skip to content

Commit 79ea473

Browse files
committed
refactor(Compare and Comply): Change getBatches to listBatches
1 parent f9a8460 commit 79ea473

9 files changed

Lines changed: 114 additions & 95 deletions

File tree

‎compare-comply/src/main/java/com/ibm/watson/developer_cloud/compare_comply/v1/CompareComply.java‎

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
import com.ibm.watson.developer_cloud.compare_comply.v1.model.FeedbackList;
2828
import com.ibm.watson.developer_cloud.compare_comply.v1.model.FeedbackReturn;
2929
import com.ibm.watson.developer_cloud.compare_comply.v1.model.GetBatchOptions;
30-
import com.ibm.watson.developer_cloud.compare_comply.v1.model.GetBatchesOptions;
3130
import com.ibm.watson.developer_cloud.compare_comply.v1.model.GetFeedback;
3231
import com.ibm.watson.developer_cloud.compare_comply.v1.model.GetFeedbackOptions;
3332
import com.ibm.watson.developer_cloud.compare_comply.v1.model.HTMLReturn;
33+
import com.ibm.watson.developer_cloud.compare_comply.v1.model.ListBatchesOptions;
3434
import com.ibm.watson.developer_cloud.compare_comply.v1.model.ListFeedbackOptions;
3535
import com.ibm.watson.developer_cloud.compare_comply.v1.model.TableReturn;
3636
import com.ibm.watson.developer_cloud.compare_comply.v1.model.UpdateBatchOptions;
@@ -136,7 +136,8 @@ public ServiceCall<ClassifyReturn> classifyElements(ClassifyElementsOptions clas
136136
}
137137
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
138138
multipartBuilder.setType(MultipartBody.FORM);
139-
RequestBody fileBody = RequestUtils.inputStreamBody(classifyElementsOptions.file(), "application/pdf");
139+
RequestBody fileBody = RequestUtils.inputStreamBody(classifyElementsOptions.file(), classifyElementsOptions
140+
.fileContentType());
140141
multipartBuilder.addFormDataPart("file", classifyElementsOptions.filename(), fileBody);
141142
builder.body(multipartBuilder.build());
142143
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassifyReturn.class));
@@ -160,7 +161,8 @@ public ServiceCall<TableReturn> extractTables(ExtractTablesOptions extractTables
160161
}
161162
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
162163
multipartBuilder.setType(MultipartBody.FORM);
163-
RequestBody fileBody = RequestUtils.inputStreamBody(extractTablesOptions.file(), "application/pdf");
164+
RequestBody fileBody = RequestUtils.inputStreamBody(extractTablesOptions.file(), extractTablesOptions
165+
.fileContentType());
164166
multipartBuilder.addFormDataPart("file", extractTablesOptions.filename(), fileBody);
165167
builder.body(multipartBuilder.build());
166168
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TableReturn.class));
@@ -212,22 +214,19 @@ public ServiceCall<CompareReturn> compareDocuments(CompareDocumentsOptions compa
212214
* @return a {@link ServiceCall} with a response type of {@link FeedbackReturn}
213215
*/
214216
public ServiceCall<FeedbackReturn> addFeedback(AddFeedbackOptions addFeedbackOptions) {
217+
Validator.notNull(addFeedbackOptions, "addFeedbackOptions cannot be null");
215218
String[] pathSegments = { "v1/feedback" };
216219
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
217220
builder.query(VERSION, versionDate);
218-
if (addFeedbackOptions != null) {
219-
final JsonObject contentJson = new JsonObject();
220-
if (addFeedbackOptions.userId() != null) {
221-
contentJson.addProperty("user_id", addFeedbackOptions.userId());
222-
}
223-
if (addFeedbackOptions.comment() != null) {
224-
contentJson.addProperty("comment", addFeedbackOptions.comment());
225-
}
226-
if (addFeedbackOptions.feedbackData() != null) {
227-
contentJson.add("feedback_data", GsonSingleton.getGson().toJsonTree(addFeedbackOptions.feedbackData()));
228-
}
229-
builder.bodyJson(contentJson);
221+
final JsonObject contentJson = new JsonObject();
222+
if (addFeedbackOptions.userId() != null) {
223+
contentJson.addProperty("user_id", addFeedbackOptions.userId());
224+
}
225+
if (addFeedbackOptions.comment() != null) {
226+
contentJson.addProperty("comment", addFeedbackOptions.comment());
230227
}
228+
contentJson.add("feedback_data", GsonSingleton.getGson().toJsonTree(addFeedbackOptions.feedbackData()));
229+
builder.bodyJson(contentJson);
231230
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(FeedbackReturn.class));
232231
}
233232

@@ -346,8 +345,7 @@ public ServiceCall<FeedbackList> listFeedback() {
346345
*
347346
* Run Compare and Comply methods over a collection of input documents.
348347
* **Important:** Batch processing requires the use of the [IBM Cloud Object Storage
349-
* service]
350-
* (https://console.bluemix.net/docs/services/cloud-object-storage/about-cos.html#about-ibm-cloud-object-storage).
348+
* service](https://console.bluemix.net/docs/services/cloud-object-storage/about-cos.html#about-ibm-cloud-object-storage).
351349
* The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using batch
352350
* processing](https://console.bluemix.net/docs/services/compare-comply/batching.html#before-you-batch).
353351
*
@@ -404,14 +402,14 @@ public ServiceCall<BatchStatus> getBatch(GetBatchOptions getBatchOptions) {
404402
*
405403
* Gets the list of batch-processing jobs submitted by users.
406404
*
407-
* @param getBatchesOptions the {@link GetBatchesOptions} containing the options for the call
405+
* @param listBatchesOptions the {@link ListBatchesOptions} containing the options for the call
408406
* @return a {@link ServiceCall} with a response type of {@link Batches}
409407
*/
410-
public ServiceCall<Batches> getBatches(GetBatchesOptions getBatchesOptions) {
408+
public ServiceCall<Batches> listBatches(ListBatchesOptions listBatchesOptions) {
411409
String[] pathSegments = { "v1/batches" };
412410
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
413411
builder.query(VERSION, versionDate);
414-
if (getBatchesOptions != null) {
412+
if (listBatchesOptions != null) {
415413
}
416414
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Batches.class));
417415
}
@@ -423,8 +421,8 @@ public ServiceCall<Batches> getBatches(GetBatchesOptions getBatchesOptions) {
423421
*
424422
* @return a {@link ServiceCall} with a response type of {@link Batches}
425423
*/
426-
public ServiceCall<Batches> getBatches() {
427-
return getBatches(null);
424+
public ServiceCall<Batches> listBatches() {
425+
return listBatches(null);
428426
}
429427

430428
/**

‎compare-comply/src/main/java/com/ibm/watson/developer_cloud/compare_comply/v1/model/AddFeedbackOptions.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.ibm.watson.developer_cloud.compare_comply.v1.model;
1414

1515
import com.ibm.watson.developer_cloud.service.model.GenericModel;
16+
import com.ibm.watson.developer_cloud.util.Validator;
1617

1718
/**
1819
* The addFeedback options.
@@ -43,6 +44,15 @@ private Builder(AddFeedbackOptions addFeedbackOptions) {
4344
public Builder() {
4445
}
4546

47+
/**
48+
* Instantiates a new builder with required properties.
49+
*
50+
* @param feedbackData the feedbackData
51+
*/
52+
public Builder(FeedbackDataInput feedbackData) {
53+
this.feedbackData = feedbackData;
54+
}
55+
4656
/**
4757
* Builds a AddFeedbackOptions.
4858
*
@@ -87,6 +97,7 @@ public Builder feedbackData(FeedbackDataInput feedbackData) {
8797
}
8898

8999
private AddFeedbackOptions(Builder builder) {
100+
Validator.notNull(builder.feedbackData, "feedbackData cannot be null");
90101
userId = builder.userId;
91102
comment = builder.comment;
92103
feedbackData = builder.feedbackData;

‎compare-comply/src/main/java/com/ibm/watson/developer_cloud/compare_comply/v1/model/ClassifyElementsOptions.java‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public interface ModelId {
4040
private InputStream file;
4141
private String filename;
4242
private String modelId;
43+
private String fileContentType;
4344

4445
/**
4546
* Builder.
@@ -48,11 +49,13 @@ public static class Builder {
4849
private InputStream file;
4950
private String filename;
5051
private String modelId;
52+
private String fileContentType;
5153

5254
private Builder(ClassifyElementsOptions classifyElementsOptions) {
5355
file = classifyElementsOptions.file;
5456
filename = classifyElementsOptions.filename;
5557
modelId = classifyElementsOptions.modelId;
58+
fileContentType = classifyElementsOptions.fileContentType;
5659
}
5760

5861
/**
@@ -112,6 +115,17 @@ public Builder modelId(String modelId) {
112115
return this;
113116
}
114117

118+
/**
119+
* Set the fileContentType.
120+
*
121+
* @param fileContentType the fileContentType
122+
* @return the ClassifyElementsOptions builder
123+
*/
124+
public Builder fileContentType(String fileContentType) {
125+
this.fileContentType = fileContentType;
126+
return this;
127+
}
128+
115129
/**
116130
* Set the file.
117131
*
@@ -132,6 +146,7 @@ private ClassifyElementsOptions(Builder builder) {
132146
file = builder.file;
133147
filename = builder.filename;
134148
modelId = builder.modelId;
149+
fileContentType = builder.fileContentType;
135150
}
136151

137152
/**
@@ -146,7 +161,7 @@ public Builder newBuilder() {
146161
/**
147162
* Gets the file.
148163
*
149-
* The PDF file to convert.
164+
* The input file to convert.
150165
*
151166
* @return the file
152167
*/
@@ -177,4 +192,15 @@ public String filename() {
177192
public String modelId() {
178193
return modelId;
179194
}
195+
196+
/**
197+
* Gets the fileContentType.
198+
*
199+
* The content type of file. Values for this parameter can be obtained from the HttpMediaType class.
200+
*
201+
* @return the fileContentType
202+
*/
203+
public String fileContentType() {
204+
return fileContentType;
205+
}
180206
}

‎compare-comply/src/main/java/com/ibm/watson/developer_cloud/compare_comply/v1/model/ConvertToHtmlOptions.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public Builder newBuilder() {
164164
/**
165165
* Gets the file.
166166
*
167-
* The file to convert.
167+
* The input file to convert.
168168
*
169169
* @return the file
170170
*/

‎compare-comply/src/main/java/com/ibm/watson/developer_cloud/compare_comply/v1/model/ExtractTablesOptions.java‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public interface ModelId {
4040
private InputStream file;
4141
private String filename;
4242
private String modelId;
43+
private String fileContentType;
4344

4445
/**
4546
* Builder.
@@ -48,11 +49,13 @@ public static class Builder {
4849
private InputStream file;
4950
private String filename;
5051
private String modelId;
52+
private String fileContentType;
5153

5254
private Builder(ExtractTablesOptions extractTablesOptions) {
5355
file = extractTablesOptions.file;
5456
filename = extractTablesOptions.filename;
5557
modelId = extractTablesOptions.modelId;
58+
fileContentType = extractTablesOptions.fileContentType;
5659
}
5760

5861
/**
@@ -112,6 +115,17 @@ public Builder modelId(String modelId) {
112115
return this;
113116
}
114117

118+
/**
119+
* Set the fileContentType.
120+
*
121+
* @param fileContentType the fileContentType
122+
* @return the ExtractTablesOptions builder
123+
*/
124+
public Builder fileContentType(String fileContentType) {
125+
this.fileContentType = fileContentType;
126+
return this;
127+
}
128+
115129
/**
116130
* Set the file.
117131
*
@@ -132,6 +146,7 @@ private ExtractTablesOptions(Builder builder) {
132146
file = builder.file;
133147
filename = builder.filename;
134148
modelId = builder.modelId;
149+
fileContentType = builder.fileContentType;
135150
}
136151

137152
/**
@@ -146,7 +161,7 @@ public Builder newBuilder() {
146161
/**
147162
* Gets the file.
148163
*
149-
* The PDF file on which to run table extraction.
164+
* The input file on which to run table extraction.
150165
*
151166
* @return the file
152167
*/
@@ -177,4 +192,15 @@ public String filename() {
177192
public String modelId() {
178193
return modelId;
179194
}
195+
196+
/**
197+
* Gets the fileContentType.
198+
*
199+
* The content type of file. Values for this parameter can be obtained from the HttpMediaType class.
200+
*
201+
* @return the fileContentType
202+
*/
203+
public String fileContentType() {
204+
return fileContentType;
205+
}
180206
}

‎compare-comply/src/main/java/com/ibm/watson/developer_cloud/compare_comply/v1/model/FeedbackDataInput.java‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
*/
2121
public class FeedbackDataInput extends GenericModel {
2222

23-
@SerializedName("user_id")
24-
private String userId;
25-
private String comment;
2623
@SerializedName("feedback_type")
2724
private String feedbackType;
2825
private ShortDoc document;
@@ -37,28 +34,6 @@ public class FeedbackDataInput extends GenericModel {
3734
@SerializedName("updated_labels")
3835
private UpdatedLabelsIn updatedLabels;
3936

40-
/**
41-
* Gets the userId.
42-
*
43-
* An optional identifier of the user submitting feedback.
44-
*
45-
* @return the userId
46-
*/
47-
public String getUserId() {
48-
return userId;
49-
}
50-
51-
/**
52-
* Gets the comment.
53-
*
54-
* An optional comment about the feedback.
55-
*
56-
* @return the comment
57-
*/
58-
public String getComment() {
59-
return comment;
60-
}
61-
6237
/**
6338
* Gets the feedbackType.
6439
*
@@ -148,24 +123,6 @@ public UpdatedLabelsIn getUpdatedLabels() {
148123
return updatedLabels;
149124
}
150125

151-
/**
152-
* Sets the userId.
153-
*
154-
* @param userId the new userId
155-
*/
156-
public void setUserId(final String userId) {
157-
this.userId = userId;
158-
}
159-
160-
/**
161-
* Sets the comment.
162-
*
163-
* @param comment the new comment
164-
*/
165-
public void setComment(final String comment) {
166-
this.comment = comment;
167-
}
168-
169126
/**
170127
* Sets the feedbackType.
171128
*

0 commit comments

Comments
 (0)