diff --git a/examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java b/examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java new file mode 100644 index 00000000000..7f21b982a03 --- /dev/null +++ b/examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java @@ -0,0 +1,35 @@ +package com.ibm.watson.developer_cloud.text_to_speech.v1; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +import com.ibm.watson.developer_cloud.http.HttpMediaType; +import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation; +import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationResult; +import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech; +import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; + +public class TranslateAndSynthesizeExample { + + public static void main(String[] args) throws IOException { + LanguageTranslation translator = new LanguageTranslation(); + translator.setUsernameAndPassword("username", "password"); + + TextToSpeech synthesizer = new TextToSpeech(); + synthesizer.setUsernameAndPassword("username", "password"); + + String text = "Greetings from Watson Developer Cloudl"; + + // translate + TranslationResult translationResult = translator.translate(text, "en", "es"); + String translation = translationResult.getTranslations().get(0).getTranslation(); + + // synthesize + InputStream in = synthesizer.synthesize(translation, Voice.ES_LAURA, HttpMediaType.AUDIO_WAV); + Files.copy(in, Paths.get("output.wav"), StandardCopyOption.REPLACE_EXISTING); + + } +} diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguage.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguage.java index 4d3fdf8474a..913be71f3ae 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguage.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguage.java @@ -80,7 +80,7 @@ public class AlchemyLanguage extends AlchemyService { public static final String XPATH = "xpath"; public static final String TARGETS = "targets"; public static final String ANCHOR_DATE = "anchorDate"; - + // language to be used with request private LanguageSelection language = LanguageSelection.DETECT; diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVision.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVision.java index 79b4c582816..8fc4d48e7a3 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVision.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVision.java @@ -177,13 +177,13 @@ public ImageKeywords getImageKeywords(File image, Boolean forceShowAll, Boolean params.put(KNOWLEDGE_GRAPH, knowledgeGraph ? 1 : 0); ImageKeywords imageKeywords = executeRequest(params, AlchemyAPI.image_keywords, ImageKeywords.class); - + // Remove the NO_TAGS keywords ListIterator iter = imageKeywords.getImageKeywords().listIterator(); - while (iter.hasNext()){ - if (iter.next().getText().equals(NO_TAGS)){ - iter.remove(); - } + while (iter.hasNext()) { + if (iter.next().getText().equals(NO_TAGS)) { + iter.remove(); + } } return imageKeywords; } diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/DocumentPublicationDate.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/DocumentPublicationDate.java index eb8a07adda9..e3a7ac721b0 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/DocumentPublicationDate.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/DocumentPublicationDate.java @@ -1,17 +1,15 @@ /** * Copyright 2015 IBM Corp. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package com.ibm.watson.developer_cloud.alchemy.v1.model; diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageFace.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageFace.java index 73f43c3eade..aab261b277c 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageFace.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageFace.java @@ -126,19 +126,19 @@ public void setScore(Double score) { private Gender gender; /** The height. */ - private String height; + private Integer height; /** The identity. */ private Identity identity; /** The position x. */ - private String positionX; + private Integer positionX; /** The position y. */ - private String positionY; + private Integer positionY; /** The width. */ - private String width; + private Integer width; /** * Gets the age. @@ -163,7 +163,7 @@ public Gender getGender() { * * @return The height */ - public String getHeight() { + public Integer getHeight() { return height; } @@ -181,7 +181,7 @@ public Identity getIdentity() { * * @return The positionX */ - public String getPositionX() { + public Integer getPositionX() { return positionX; } @@ -190,7 +190,7 @@ public String getPositionX() { * * @return The positionY */ - public String getPositionY() { + public Integer getPositionY() { return positionY; } @@ -199,7 +199,7 @@ public String getPositionY() { * * @return The width */ - public String getWidth() { + public Integer getWidth() { return width; } @@ -226,7 +226,7 @@ public void setGender(Gender gender) { * * @param height The height */ - public void setHeight(String height) { + public void setHeight(Integer height) { this.height = height; } @@ -244,7 +244,7 @@ public void setIdentity(Identity identity) { * * @param positionX The positionX */ - public void setPositionX(String positionX) { + public void setPositionX(Integer positionX) { this.positionX = positionX; } @@ -253,7 +253,7 @@ public void setPositionX(String positionX) { * * @param positionY The positionY */ - public void setPositionY(String positionY) { + public void setPositionY(Integer positionY) { this.positionY = positionY; } @@ -262,7 +262,7 @@ public void setPositionY(String positionY) { * * @param width The width */ - public void setWidth(String width) { + public void setWidth(Integer width) { this.width = width; } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java index 3c091b2714a..c341b8eeb44 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java @@ -81,8 +81,8 @@ public void setHierarchy(String hierarchy) { } /** - * Gets the hierarchy. A value is only present if the request that produced this instance - * was made with {@code knowledgeGraph = true}. + * Gets the hierarchy. A value is only present if the request that produced this instance was made + * with {@code knowledgeGraph = true}. * * @return The hierarchy, if it exists. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneText.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneText.java index 5dad8509ed6..bc9303a83ba 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneText.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneText.java @@ -32,7 +32,7 @@ public class ImageSceneText extends AlchemyGenericModel { /** The scene text. */ private String sceneText; - + /** * Gets the image faces. * @@ -59,7 +59,7 @@ public String getUrl() { public String getSceneText() { return sceneText; } - + /** * Sets the image faces. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneTextLine.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneTextLine.java index 4251a08926a..4e6c81ea60b 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneTextLine.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageSceneTextLine.java @@ -28,16 +28,16 @@ public class ImageSceneTextLine extends GenericModel { * Region. */ public static class Region extends GenericModel { - + /** The height. */ private Integer height; - + /** The width. */ private Integer width; - + /** The x. */ private Integer x; - + /** The y. */ private Integer y; @@ -118,13 +118,13 @@ public void setY(Integer y) { * A word within a line of text. */ public static class Word extends GenericModel { - + /** The confidence. */ private Double confidence; - + /** The region. */ private Region region; - + /** The text. */ private String text; @@ -186,13 +186,13 @@ public void setText(String text) { /** The confidence. */ private Double confidence; - + /** The region. */ private Region region; - + /** The text. */ private String text; - + /** The words. */ private List words; diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/LanguageSelection.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/LanguageSelection.java index fdf1df407ee..e36a65053f2 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/LanguageSelection.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/LanguageSelection.java @@ -1,13 +1,5 @@ package com.ibm.watson.developer_cloud.alchemy.v1.model; public enum LanguageSelection { - ENGLISH, - FRENCH, - GERMAN, - ITALIAN, - PORTUGESE, - RUSSIAN, - SPANISH, - SWEDISH, - DETECT + ENGLISH, FRENCH, GERMAN, ITALIAN, PORTUGESE, RUSSIAN, SPANISH, SWEDISH, DETECT } diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Sentiment.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Sentiment.java index dd380d0a651..764562b33b6 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Sentiment.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Sentiment.java @@ -30,16 +30,13 @@ public class Sentiment extends GenericModel { public enum SentimentType { /** negative sentiment. */ - @SerializedName("negative") - NEGATIVE, + @SerializedName("negative") NEGATIVE, /** neutral sentiment. */ - @SerializedName("neutral") - NEUTRAL, + @SerializedName("neutral") NEUTRAL, /** positive sentiment. */ - @SerializedName("positive") - POSITIVE + @SerializedName("positive") POSITIVE } /** The mixed. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/util/PublicationDateTypeAdapter.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/util/PublicationDateTypeAdapter.java index 5fbe9ab8e6a..d7002971082 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/util/PublicationDateTypeAdapter.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/util/PublicationDateTypeAdapter.java @@ -58,7 +58,8 @@ public PublicationDate read(JsonReader reader) throws IOException { if (name.equals("confident")) { final String confidentAsString = reader.nextString(); - publicationDate.setConfident(confidentAsString != null && !confidentAsString.equals("no") && !confidentAsString.equals("false")); + publicationDate.setConfident(confidentAsString != null && !confidentAsString.equals("no") + && !confidentAsString.equals("false")); } else if (name.equals("date")) { final String dateAsString = reader.nextString(); if (dateAsString != null && !dateAsString.isEmpty()) diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansion.java b/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansion.java index 757c5bb7788..1e465753c9d 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansion.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansion.java @@ -37,8 +37,8 @@ * similar contexts. * * @version v1 - * @see + * @see * Concept Expansion */ public class ConceptExpansion extends WatsonService { @@ -111,12 +111,13 @@ public Job createJob(final String label, final String[] seeds) { * *
    *  { result:"apple", prevalence:"20" }
-   * 
+ * + * * @return the concept as POJO Object */ private Concept formatConcept(JsonObject conceptJson) { - return new Concept(conceptJson.get(RESULT).getAsString(), conceptJson.get(PREVALENCE) - .getAsDouble()); + return new Concept(conceptJson.get(RESULT).getAsString(), + conceptJson.get(PREVALENCE).getAsDouble()); } /** diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/model/package-info.java b/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/model/package-info.java index 9082afb973a..5501e0cb475 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/model/package-info.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/model/package-info.java @@ -1,17 +1,15 @@ /** * Copyright 2015 IBM Corp. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package com.ibm.watson.developer_cloud.concept_expansion.v1.model; diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/package-info.java b/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/package-info.java index a2b350223f7..5bb6e2a3a03 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/package-info.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_expansion/v1/package-info.java @@ -1,17 +1,15 @@ /** * Copyright 2015 IBM Corp. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package com.ibm.watson.developer_cloud.concept_expansion.v1; diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsights.java b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsights.java index eef1feccf9f..5d6e17cda6c 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsights.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsights.java @@ -60,8 +60,8 @@ * on content that has been ingested from the English language Wikipedia. * * @version v2 - * @see + * @see * Concept Insights */ public class ConceptInsights extends WatsonService { @@ -216,10 +216,9 @@ public Annotations annotateText(final Graph graph, final String text) { final String graphId = IDHelper.getGraphId(graph, getFirstAccountId()); Validate.notEmpty(text, "text cannot be empty"); - final Request request = - RequestBuilder.post(API_VERSION + graphId + ANNOTATE_TEXT_PATH) - .withBodyContent(text, HttpMediaType.TEXT_PLAIN) - .withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON).build(); + final Request request = RequestBuilder.post(API_VERSION + graphId + ANNOTATE_TEXT_PATH) + .withBodyContent(text, HttpMediaType.TEXT_PLAIN) + .withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON).build(); final Response response = execute(request); return ResponseUtil.getObject(response, Annotations.class); @@ -284,11 +283,10 @@ public QueryConcepts conceptualSearch(Corpus corpus, Map paramet */ public void createCorpus(final Corpus corpus) { final String corpusId = IDHelper.getCorpusId(corpus, getFirstAccountId()); - final Request request = - RequestBuilder - .put(API_VERSION + corpusId) - .withBodyContent(GsonSingleton.getGsonWithoutPrettyPrinting().toJson(corpus), HttpMediaType.APPLICATION_JSON) - .build(); + final Request request = RequestBuilder.put(API_VERSION + corpusId) + .withBodyContent(GsonSingleton.getGsonWithoutPrettyPrinting().toJson(corpus), + HttpMediaType.APPLICATION_JSON) + .build(); executeWithoutResponse(request); } @@ -299,11 +297,10 @@ public void createCorpus(final Corpus corpus) { */ public void createDocument(final Document document) { IDHelper.getDocumentId(document); - final Request request = - RequestBuilder - .put(API_VERSION + document.getId()) - .withBodyContent(GsonSingleton.getGsonWithoutPrettyPrinting().toJson(document), - HttpMediaType.APPLICATION_JSON).build(); + final Request request = RequestBuilder.put(API_VERSION + document.getId()) + .withBodyContent(GsonSingleton.getGsonWithoutPrettyPrinting().toJson(document), + HttpMediaType.APPLICATION_JSON) + .build(); executeWithoutResponse(request); } @@ -456,7 +453,8 @@ public CorpusProcessingState getCorpusProcessingState(final Corpus corpus) { * * @return {@link Concepts} */ - public Concepts getCorpusRelatedConcepts(final Corpus corpus, final Map parameters) { + public Concepts getCorpusRelatedConcepts(final Corpus corpus, + final Map parameters) { final String corpusId = IDHelper.getCorpusId(corpus, getFirstAccountId()); final Map queryParameters = new HashMap(); @@ -711,7 +709,7 @@ public Corpora listCorpora(final String accountId) { public Documents listDocuments(final Corpus corpus) { return listDocuments(corpus, null); } - + /** * Retrieves the documents of a given corpus. * @@ -748,7 +746,8 @@ public Documents listDocuments(final Corpus corpus, final Map pa queryParameters.put(QUERY, parameters.get(QUERY)); } } - return executeRequest(API_VERSION + corpusId + DOCUMENTS_PATH, queryParameters, Documents.class); + return executeRequest(API_VERSION + corpusId + DOCUMENTS_PATH, queryParameters, + Documents.class); } /** @@ -820,7 +819,8 @@ public Matches searchCorpusByLabel(final Corpus corpus, final Map * @return {@link Matches} */ - public Matches searchGraphsConceptByLabel(final Graph graph, final Map parameters) { + public Matches searchGraphsConceptByLabel(final Graph graph, + final Map parameters) { final String graphId = IDHelper.getGraphId(graph, getFirstAccountId()); Validate.notEmpty((String) parameters.get(QUERY), "query cannot be empty"); @@ -836,7 +836,8 @@ public Matches searchGraphsConceptByLabel(final Graph graph, final Map getAccountPermissions() { return accountPermissions; } + /** + * Corpus access. + */ + public enum Access { + + @SerializedName("public") PUBLIC, + + @SerializedName("private") PRIVATE; + } + /** * Gets the id. * @@ -157,7 +165,7 @@ public String getName() { * * @param access The access */ - public void setAccess(String access) { + public void setAccess(Access access) { this.access = access; } @@ -170,6 +178,18 @@ public void setAccountPermissions(List accountPermissions) { this.accountPermissions = accountPermissions; } + /** + * Adds an {@link AccountPermission}. + * + * @param accountPermission the account permission + */ + public void addAccountPermissions(AccountPermission accountPermission) { + if (this.accountPermissions == null) + this.accountPermissions = new ArrayList(); + + this.accountPermissions.add(accountPermission); + } + /** * Sets the id. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/package-info.java b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/package-info.java index 316a1917436..808628da459 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/package-info.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/package-info.java @@ -11,4 +11,4 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package com.ibm.watson.developer_cloud.concept_insights.v2.model; \ No newline at end of file +package com.ibm.watson.developer_cloud.concept_insights.v2.model; diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/package-info.java b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/package-info.java index caac256f9bd..14c81170f03 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/package-info.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/package-info.java @@ -11,4 +11,4 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package com.ibm.watson.developer_cloud.concept_insights.v2; \ No newline at end of file +package com.ibm.watson.developer_cloud.concept_insights.v2; diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java index 989839a9963..20e90db437a 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java @@ -34,7 +34,7 @@ public class IDHelper { * The CONCEPT_ID_REGEX. (format is "/graphs/{account_id}/{graph}/concepts/{concept}") */ private final static String CONCEPT_ID_REGEX = - "^/graphs/[_\\-\\w\\s]*/[_\\-\\w\\s]*/concepts/[_\\-\\w\\s]*$"; + "^/graphs/[_\\-\\w\\s]*/[_\\-\\w\\s]*/concepts/[_\\-\\w\\s\\(\\)]*$"; /** * The CORPUS_ID_REGEX. (format is "/corpora/{account_id}/{corpus}") diff --git a/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java b/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java index 6ce0e7c0bde..198c402f274 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java +++ b/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java @@ -184,5 +184,5 @@ public interface HttpHeaders { /** Allow Watson to collect the payload. */ public static final String X_WATSON_LEARNING_OPT_OUT = "X-Watson-Learning-Opt-Out"; - + } diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java index cb34184350e..e790c791cfe 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java @@ -278,7 +278,7 @@ private TranslationResult translateRequest(String text, String modelId, String s final RequestBuilder requestBuilder = RequestBuilder.post(PATH_TRANSLATE) .withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON); - + if (source != null && !source.isEmpty()) contentJson.addProperty(SOURCE, source); diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java index d188ff15cab..a5787444359 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java @@ -45,6 +45,18 @@ public int getCharacterCount() { return characterCount; } + /** + * Gets the first translation. + * + * @return the first translation + */ + public String getFirstTranslation() { + if (translations != null && !translations.isEmpty()) + return translations.get(0).getTranslation(); + else + return null; + } + /** * Gets the translations. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java b/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java index 94925938d30..74c08dd759e 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java +++ b/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java @@ -40,8 +40,8 @@ * it hasn't seen before. The response includes the name of the top classes and confidence values. * * @version v1 - * @see + * @see * Natural Language Classifier */ public class NaturalLanguageClassifier extends WatsonService { @@ -124,12 +124,10 @@ public Classifier createClassifier(final String name, final String language, contentJson.addProperty(NAME, name); } - final RequestBody body = - new MultipartBuilder() - .type(MultipartBuilder.FORM) - .addPart(Headers.of(HttpHeaders.CONTENT_DISPOSITION, FORM_DATA_TRAINING_DATA), - RequestBody.create(HttpMediaType.BINARY_FILE, trainingData)) - .addFormDataPart(TRAINING_METADATA, contentJson.toString()).build(); + final RequestBody body = new MultipartBuilder().type(MultipartBuilder.FORM) + .addPart(Headers.of(HttpHeaders.CONTENT_DISPOSITION, FORM_DATA_TRAINING_DATA), + RequestBody.create(HttpMediaType.BINARY_FILE, trainingData)) + .addFormDataPart(TRAINING_METADATA, contentJson.toString()).build(); final Request request = RequestBuilder.post(PATH_CLASSIFIERS).withBody(body).build(); diff --git a/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java b/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java index 9690ee9c627..55b90e7a4e1 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java +++ b/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java @@ -32,24 +32,19 @@ public class Classifier extends GenericModel { public enum Status { /** The available. */ - @SerializedName("Available") - AVAILABLE, + @SerializedName("Available") AVAILABLE, /** The failed. */ - @SerializedName("Failed") - FAILED, + @SerializedName("Failed") FAILED, /** The non existent. */ - @SerializedName("Non Existent") - NON_EXISTENT, + @SerializedName("Non Existent") NON_EXISTENT, /** The training. */ - @SerializedName("Training") - TRAINING, + @SerializedName("Training") TRAINING, /** The unavailable. */ - @SerializedName("Unavailable") - UNAVAILABLE + @SerializedName("Unavailable") UNAVAILABLE } /** The created. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsights.java b/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsights.java index 0a7f2f0fc37..965e0641f81 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsights.java +++ b/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsights.java @@ -35,8 +35,8 @@ * tweets, forum posts, and more. * * @version v2 - * @see + * @see * Personality Insights */ public class PersonalityInsights extends WatsonService { @@ -48,8 +48,8 @@ public class PersonalityInsights extends WatsonService { private static final String URL = "https://gateway.watsonplatform.net/personality-insights/api"; - private static final Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, - new TimestampTypeAdapter()).create(); + private static final Gson gson = + new GsonBuilder().registerTypeAdapter(Date.class, new TimestampTypeAdapter()).create(); /** The Constant HEADERS (value is "headers"). */ private static final String HEADERS = "headers"; diff --git a/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/model/ProfileOptions.java b/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/model/ProfileOptions.java index f691da372f9..6416d5552cf 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/model/ProfileOptions.java +++ b/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/model/ProfileOptions.java @@ -104,11 +104,9 @@ public Language getLanguage() { */ public enum Language { - @SerializedName("en") - ENGLISH("en"), + @SerializedName("en") ENGLISH("en"), - @SerializedName("es") - SPANISH("es"); + @SerializedName("es") SPANISH("es"); private final String text; @@ -136,11 +134,9 @@ public String toString() { */ public enum AcceptLanguage { - @SerializedName("en") - ENGLISH("en"), + @SerializedName("en") ENGLISH("en"), - @SerializedName("es") - SPANISH("es"); + @SerializedName("es") SPANISH("es"); private final String text; diff --git a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java index e55cb181120..799c4db2710 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java +++ b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java @@ -26,8 +26,8 @@ * verbs, subjects, objects, etc.) * * @version v1 - * @see + * @see * Relationship Extraction */ public class RelationshipExtraction extends WatsonService { @@ -38,7 +38,7 @@ public class RelationshipExtraction extends WatsonService { /** The dataset. */ private Dataset dataset; - + /** The return type. */ private String returnType = "xml"; @@ -74,9 +74,8 @@ public String extract(final String text) { Validate.notNull(dataset, "dataset cannot be null"); Validate.notNull(text, "text cannot be null"); - final Request request = - RequestBuilder.post("/v1/sire/0") - .withForm("sid", dataset.getId(), "rt", returnType, "txt", text).build(); + final Request request = RequestBuilder.post("/v1/sire/0") + .withForm("sid", dataset.getId(), "rt", returnType, "txt", text).build(); final Response response = execute(request); return ResponseUtil.getString(response); } @@ -99,7 +98,7 @@ public Dataset getDataset() { public void setDataset(final Dataset dataset) { this.dataset = dataset; } - + /** * Sets the returnType. * @@ -111,6 +110,6 @@ public void setReturnType(final ReturnType returnType) { } else if (returnType == ReturnType.JSON) { this.returnType = "json"; } - } + } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java index b4a9dfa5523..ab8c65bd4a5 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java +++ b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java @@ -1,6 +1,5 @@ package com.ibm.watson.developer_cloud.relationship_extraction.v1; public enum ReturnType { - XML, - JSON + XML, JSON } diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRank.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRank.java index 81398c1b12b..b0c895feea7 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRank.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRank.java @@ -50,12 +50,12 @@ * their end users based on their question or query. * * @version v1 - * @see + * @see * Retrieve and Rank */ -public class RetrieveAndRank extends WatsonService implements ClusterLifecycleManager, - SolrConfigManager { +public class RetrieveAndRank extends WatsonService + implements ClusterLifecycleManager, SolrConfigManager { private static final String ANSWERS = "answers"; private static final Logger log = Logger.getLogger(RetrieveAndRank.class.getName()); @@ -110,8 +110,8 @@ private String createConfigPath(String solrClusterId, String configName) { */ public Ranker createRanker(final String name, final File training) { Validate.notNull(training, "training file cannot be null"); - Validate.isTrue(training.exists(), "training file: " + training.getAbsolutePath() - + " not found"); + Validate.isTrue(training.exists(), + "training file: " + training.getAbsolutePath() + " not found"); final JsonObject contentJson = new JsonObject(); @@ -119,16 +119,13 @@ public Ranker createRanker(final String name, final File training) { contentJson.addProperty(NAME, name); } - final RequestBody body = - new MultipartBuilder() - .type(MultipartBuilder.FORM) - .addPart( - Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"training_data\""), - RequestBody.create(HttpMediaType.BINARY_FILE, training)) - .addPart( - Headers - .of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"training_metadata\""), - RequestBody.create(HttpMediaType.TEXT, contentJson.toString())).build(); + final RequestBody body = new MultipartBuilder().type(MultipartBuilder.FORM) + .addPart(Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"training_data\""), + RequestBody.create(HttpMediaType.BINARY_FILE, training)) + .addPart( + Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"training_metadata\""), + RequestBody.create(HttpMediaType.TEXT, contentJson.toString())) + .build(); final Request request = RequestBuilder.post(PATH_CREATE_RANKER).withBody(body).build(); @@ -253,9 +250,8 @@ public SolrCluster getSolrCluster(String solrClusterId) { /* * (non-Javadoc) * - * @see - * com.ibm.watson.developer_cloud.retrieve_and_rank.v1.SolrConfigManager#getSolrClusterConfiguration - * (java.lang.String, java.lang.String) + * @see com.ibm.watson.developer_cloud.retrieve_and_rank.v1.SolrConfigManager# + * getSolrClusterConfiguration (java.lang.String, java.lang.String) */ @Override public InputStream getSolrClusterConfiguration(String solrClusterId, String configName) { @@ -274,9 +270,8 @@ public InputStream getSolrClusterConfiguration(String solrClusterId, String conf /* * (non-Javadoc) * - * @see - * com.ibm.watson.developer_cloud.retrieve_and_rank.v1.SolrConfigManager#getSolrClusterConfigurations - * (java.lang.String) + * @see com.ibm.watson.developer_cloud.retrieve_and_rank.v1.SolrConfigManager# + * getSolrClusterConfigurations (java.lang.String) */ @Override public List getSolrClusterConfigurations(String solrClusterId) { @@ -327,15 +322,12 @@ public Ranking rank(final String rankerID, final File answers, Integer topAnswer final JsonObject contentJson = new JsonObject(); contentJson.addProperty(ANSWERS, (topAnswers != null && topAnswers > 0) ? topAnswers : 10); - final RequestBody body = - new MultipartBuilder() - .type(MultipartBuilder.FORM) - .addPart( - Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"answer_data\""), - RequestBody.create(HttpMediaType.BINARY_FILE, answers)) - .addPart( - Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"answer_metadata\""), - RequestBody.create(HttpMediaType.TEXT, contentJson.toString())).build(); + final RequestBody body = new MultipartBuilder().type(MultipartBuilder.FORM) + .addPart(Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"answer_data\""), + RequestBody.create(HttpMediaType.BINARY_FILE, answers)) + .addPart(Headers.of(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=\"answer_metadata\""), + RequestBody.create(HttpMediaType.TEXT, contentJson.toString())) + .build(); final String path = String.format(PATH_RANK, rankerID); final Request request = RequestBuilder.post(path).withBody(body).build(); @@ -379,8 +371,8 @@ public void uploadSolrClusterConfigurationZip(String solrClusterId, String confi File zippedConfig) { final String configPath = createConfigPath(solrClusterId, configName); final RequestBuilder requestBuilder = RequestBuilder.post(configPath); - requestBuilder.withBody(RequestBody.create(MediaType.parse(HttpMediaType.APPLICATION_ZIP), - zippedConfig)); + requestBuilder + .withBody(RequestBody.create(MediaType.parse(HttpMediaType.APPLICATION_ZIP), zippedConfig)); executeWithoutResponse(requestBuilder.build()); } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/SolrConfigManager.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/SolrConfigManager.java index d6e91c49465..db85c648d7a 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/SolrConfigManager.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/SolrConfigManager.java @@ -54,7 +54,8 @@ void uploadSolrClusterConfigurationZip(final String solrClusterId, final String * @return an InputStream containing the zipped configuration if it exists in ZooKeeper or null if * it is not found */ - InputStream getSolrClusterConfiguration(final String solrClusterId, final String configurationName); + InputStream getSolrClusterConfiguration(final String solrClusterId, + final String configurationName); /** * Uploads a configuration {@link File} to ZooKeeper's namespace, including schema.xml, diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/Ranker.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/Ranker.java index bd9f510080f..5b3a71f4b0d 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/Ranker.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/Ranker.java @@ -32,24 +32,19 @@ public class Ranker extends GenericModel { public enum Status { /** The available. */ - @SerializedName("Available") - AVAILABLE, + @SerializedName("Available") AVAILABLE, /** The failed. */ - @SerializedName("Failed") - FAILED, + @SerializedName("Failed") FAILED, /** The non existent. */ - @SerializedName("Non Existent") - NON_EXISTENT, + @SerializedName("Non Existent") NON_EXISTENT, /** The training. */ - @SerializedName("Training") - TRAINING, + @SerializedName("Training") TRAINING, /** The unavailable. */ - @SerializedName("Unavailable") - UNAVAILABLE + @SerializedName("Unavailable") UNAVAILABLE } /** The created. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/util/ZipUtils.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/util/ZipUtils.java index c082ec1b9b5..9b2e7969a61 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/util/ZipUtils.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/util/ZipUtils.java @@ -93,12 +93,11 @@ private static void writeZipEntry(ZipOutputStream out, String name, byte[] data) } private static void addFilesToZip(final File currentParentDir, final ZipOutputStream out, - final File globalParentDir) - throws IOException { + final File globalParentDir) throws IOException { for (final File child : currentParentDir.listFiles()) { - if(child.isDirectory()){ + if (child.isDirectory()) { addFilesToZip(child, out, globalParentDir); - } else if (child.isFile()){ + } else if (child.isFile()) { writeZipEntry(out, globalParentDir.toURI().relativize(child.toURI()).toString(), readBytes(child)); } diff --git a/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/MediaTypeUtils.java b/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/MediaTypeUtils.java index a39be516554..4e4debf587f 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/MediaTypeUtils.java +++ b/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/MediaTypeUtils.java @@ -26,9 +26,8 @@ public class MediaTypeUtils { private static String[] SUPPORTED_EXTENSION = {".wav", ".ogg", ".oga", ".flac", ".raw"}; - private static String[] SUPPORTED_MEDIA_TYPES = {HttpMediaType.AUDIO_WAV, - HttpMediaType.AUDIO_OGG, HttpMediaType.AUDIO_OGG, HttpMediaType.AUDIO_FLAC, - HttpMediaType.AUDIO_RAW}; + private static String[] SUPPORTED_MEDIA_TYPES = {HttpMediaType.AUDIO_WAV, HttpMediaType.AUDIO_OGG, + HttpMediaType.AUDIO_OGG, HttpMediaType.AUDIO_FLAC, HttpMediaType.AUDIO_RAW}; /** * Returns the media type for a given file. diff --git a/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java b/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java index d8ce54f460c..4ff7e172b59 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java +++ b/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java @@ -43,6 +43,7 @@ public class WebSocketSpeechToTextClient { public class WebSocketListener extends WebSocketAdapter { private RecognizeDelegate delegate; private boolean audioSent = false; + /** * Instantiates a new WebSocket listener. * @@ -68,7 +69,8 @@ public void onTextMessage(WebSocket websocket, String message) { if (json.has(ERROR)) { delegate.onError(new RuntimeException(json.get(ERROR).getAsString())); } else if (json.has(RESULTS)) { - SpeechResults transcript = GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(message, SpeechResults.class); + SpeechResults transcript = + GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(message, SpeechResults.class); delegate.onMessage(transcript); } else if (audioSent) { websocket.sendClose(); @@ -81,9 +83,8 @@ public void onTextMessage(WebSocket websocket, String message) { /* * (non-Javadoc) * - * @see - * com.neovisionaries.ws.client.WebSocketAdapter#onConnected(com.neovisionaries.ws.client.WebSocket - * , java.util.Map) + * @see com.neovisionaries.ws.client.WebSocketAdapter#onConnected(com.neovisionaries.ws.client. + * WebSocket , java.util.Map) */ @Override public void onConnected(WebSocket websocket, Map> headers) @@ -120,9 +121,8 @@ public void onError(WebSocket websocket, WebSocketException cause) throws Except /* * (non-Javadoc) * - * @see - * com.neovisionaries.ws.client.WebSocketAdapter#handleCallbackError(com.neovisionaries.ws.client - * .WebSocket, java.lang.Throwable) + * @see com.neovisionaries.ws.client.WebSocketAdapter#handleCallbackError(com.neovisionaries.ws. + * client .WebSocket, java.lang.Throwable) */ @Override public void handleCallbackError(WebSocket websocket, Throwable cause) throws Exception { @@ -142,7 +142,8 @@ public void handleCallbackError(WebSocket websocket, Throwable cause) throws Exc * *
    * wss://stream.watsonplatform.net/speech-to-text/api/v1/api/recognize
-   * 
+ * + * * @param token the authorization token */ public WebSocketSpeechToTextClient(String webSocketUrl, String token) { @@ -173,10 +174,10 @@ public void recognize(InputStream stream, RecognizeOptions options, RecognizeDel // 4. Send the input stream as binary data sendInputStream(ws, stream); - + // 5. Tell the listener that we sent the audio listener.audioSent = true; - + // 5. Send stop message ws.sendText(buildStopMessage()); @@ -213,8 +214,8 @@ private String buildStopMessage() { * @throws InterruptedException if any thread has interrupted the current thread. The interrupted * status of the current thread is cleared when this exception is thrown. */ - private void sendInputStream(WebSocket ws, InputStream stream) throws IOException, - InterruptedException { + private void sendInputStream(WebSocket ws, InputStream stream) + throws IOException, InterruptedException { byte[] buffer = new byte[FOUR_KB]; int read; while ((read = stream.read(buffer)) > 0) { diff --git a/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java b/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java index a3efb39451f..9d712486fd4 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java +++ b/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java @@ -34,9 +34,9 @@ * text to an audio signal. The audio is streamed back to the client with minimal delay. * * @version v1 - * @see - * Text to Speech + * @see Text + * to Speech */ public class TextToSpeech extends WatsonService { @@ -65,8 +65,8 @@ public List getVoices() { final Request request = RequestBuilder.get("/v1/voices").build(); final Response response = execute(request); final JsonObject jsonObject = ResponseUtil.getJsonObject(response); - final List voices = - GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(jsonObject.get("voices"), listVoiceType); + final List voices = GsonSingleton.getGsonWithoutPrettyPrinting() + .fromJson(jsonObject.get("voices"), listVoiceType); return voices; } diff --git a/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ElementTone.java b/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ElementTone.java index e427276f406..fc2e6716b66 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ElementTone.java +++ b/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ElementTone.java @@ -19,41 +19,41 @@ import com.ibm.watson.developer_cloud.service.model.GenericModel; /** - * This object represents the results of Tone analysis on an element; which may be a document or a sentence. - * Its structure is a 2-level tree, with tone categories in the top level and the individual tones (and their - * scores) in leaves. + * This object represents the results of Tone analysis on an element; which may be a document or a + * sentence. Its structure is a 2-level tree, with tone categories in the top level and the + * individual tones (and their scores) in leaves. * */ public class ElementTone extends GenericModel { - @SerializedName("tone_categories") - private List tones; - - /** - * Gets the tones. - * - * @return the tones - */ - public List getTones() { - return tones; - } - - /** - * Sets the tones. - * - * @param tones the new tones - */ - public void setTones(List tones) { - this.tones = tones; - } - - /** - * Adds the tone. - * - * @param tone the tone - */ - public void addTone(ToneCategory tone) { - this.tones.add(tone); - } - + @SerializedName("tone_categories") + private List tones; + + /** + * Gets the tones. + * + * @return the tones + */ + public List getTones() { + return tones; + } + + /** + * Sets the tones. + * + * @param tones the new tones + */ + public void setTones(List tones) { + this.tones = tones; + } + + /** + * Adds the tone. + * + * @param tone the tone + */ + public void addTone(ToneCategory tone) { + this.tones.add(tone); + } + } diff --git a/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java b/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java index ca4626309c6..e19c838d82f 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java +++ b/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java @@ -17,7 +17,7 @@ public class DateDeserializer implements JsonDeserializer { private static final String DATE_WITHOUT_SECONDS = "yyyy-MM-dd'T'HH:mm:ssZ"; private static final String DATE_FROM_DIALOG = "yyyy-MM-dd HH:mm:ss"; private static final String DATE_FROM_ALCHEMY = "yyyyMMdd'T'HHmmss"; - + private static final SimpleDateFormat utc = new SimpleDateFormat(DATE_UTC); private static final SimpleDateFormat utcWithoutSec = new SimpleDateFormat(DATE_WITHOUT_SECONDS); private static final SimpleDateFormat dialogDate = new SimpleDateFormat(DATE_FROM_DIALOG); diff --git a/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java b/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java index b29be4dcbe4..d784b7be60c 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java +++ b/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java @@ -36,12 +36,12 @@ public class GsonSingleton { */ private static Gson createGson(Boolean prettyPrint) { GsonBuilder builder = new GsonBuilder(); - + registerTypeAdapters(builder); - + if (prettyPrint) builder.setPrettyPrinting(); - + return builder.create(); } @@ -62,7 +62,7 @@ public static Gson getGsonWithoutPrettyPrinting() { } return gsonWithoutPrinting; } - + /** * Gets the Gson instance. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsights.java b/src/main/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsights.java index 35a981a29da..48317f218f0 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsights.java +++ b/src/main/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsights.java @@ -29,8 +29,8 @@ * based on their visual appearance / content. * * @version v1 - * @see + * @see * Visual Insights */ public class VisualInsights extends WatsonService { @@ -117,10 +117,8 @@ public Summary getSummary(final File imagesFile) { final MediaType mediaType = HttpMediaType.BINARY_FILE; final RequestBody body = - new MultipartBuilder() - .type(MultipartBuilder.FORM) - .addFormDataPart(IMAGES_FILE, imagesFile.getName(), - RequestBody.create(mediaType, imagesFile)).build(); + new MultipartBuilder().type(MultipartBuilder.FORM).addFormDataPart(IMAGES_FILE, + imagesFile.getName(), RequestBody.create(mediaType, imagesFile)).build(); final RequestBuilder requestBuilder = RequestBuilder.post(SUMMARY_PATH).withBody(body); diff --git a/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v1/VisualRecognition.java b/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v1/VisualRecognition.java index ad6f2c658ea..4c67e07c793 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v1/VisualRecognition.java +++ b/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v1/VisualRecognition.java @@ -33,8 +33,8 @@ * any accompanying descriptive text. * * @version v1 - * @see + * @see * Visual Recognition */ public class VisualRecognition extends WatsonService { @@ -108,7 +108,8 @@ public VisualRecognitionImages recognize(final String imageName, final InputStre InputStreamRequestBody.create(HttpMediaType.BINARY_FILE, image)); if (labelSet != null) - bodyBuilder.addFormDataPart(LABELS_TO_CHECK, GsonSingleton.getGsonWithoutPrettyPrinting().toJson(labelSet)); + bodyBuilder.addFormDataPart(LABELS_TO_CHECK, + GsonSingleton.getGsonWithoutPrettyPrinting().toJson(labelSet)); requestBuilder.withBody(bodyBuilder.build()); diff --git a/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognition.java b/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognition.java index 0fa1e38c08f..656e60d3063 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognition.java +++ b/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognition.java @@ -41,8 +41,8 @@ * specific results that are tailored to your needs. * * @version v2 - * @see + * @see * Visual Recognition */ public class VisualRecognition extends WatsonService { @@ -125,7 +125,8 @@ public VisualClassification classify(final File imagesFile) { * @param classifiers the classifiers * @return the visual recognition images */ - public VisualClassification classify(final File imagesFile, final VisualClassifier... classifiers) { + public VisualClassification classify(final File imagesFile, + final VisualClassifier... classifiers) { Validate.isTrue(imagesFile != null && imagesFile.exists(), "image cannot be null or not be found"); @@ -176,9 +177,8 @@ public VisualClassification classify(final String filename, final InputStream im bodyBuilder.addFormDataPart(CLASSIFIER_IDS, classifierIds.toString()); } - RequestBuilder requestBuilder = - RequestBuilder.post(PATH_CLASSIFY).withQuery(VERSION, versionDate) - .withBody(bodyBuilder.build()); + RequestBuilder requestBuilder = RequestBuilder.post(PATH_CLASSIFY) + .withQuery(VERSION, versionDate).withBody(bodyBuilder.build()); return executeRequest(requestBuilder.build(), VisualClassification.class); } @@ -237,18 +237,15 @@ public VisualClassifier createClassifier(final String name, final File positiveI Validate.isTrue(name != null && !name.isEmpty(), "name cannot be null or empty"); // POST body - RequestBody body = - new MultipartBuilder() - .type(MultipartBuilder.FORM) - .addFormDataPart(POSITIVE_EXAMPLES, positiveImages.getName(), - RequestBody.create(HttpMediaType.BINARY_FILE, positiveImages)) - .addFormDataPart(NEGATIVE_EXAMPLES, negativeImages.getName(), - RequestBody.create(HttpMediaType.BINARY_FILE, negativeImages)) - .addFormDataPart(NAME, name).build(); + RequestBody body = new MultipartBuilder().type(MultipartBuilder.FORM) + .addFormDataPart(POSITIVE_EXAMPLES, positiveImages.getName(), + RequestBody.create(HttpMediaType.BINARY_FILE, positiveImages)) + .addFormDataPart(NEGATIVE_EXAMPLES, negativeImages.getName(), + RequestBody.create(HttpMediaType.BINARY_FILE, negativeImages)) + .addFormDataPart(NAME, name).build(); - Request request = - RequestBuilder.post(PATH_CLASSIFIERS).withQuery(VERSION, versionDate).withBody(body) - .build(); + Request request = RequestBuilder.post(PATH_CLASSIFIERS).withQuery(VERSION, versionDate) + .withBody(body).build(); return executeRequest(request, VisualClassifier.class); } @@ -264,9 +261,8 @@ public void deleteClassifier(String classifierId) { Validate.isTrue(classifierId != null && !classifierId.isEmpty(), "classifierId cannot be null or empty"); - Request request = - RequestBuilder.delete(String.format(PATH_CLASSIFIER, classifierId)) - .withQuery(VERSION, versionDate).build(); + Request request = RequestBuilder.delete(String.format(PATH_CLASSIFIER, classifierId)) + .withQuery(VERSION, versionDate).build(); executeWithoutResponse(request); } @@ -281,9 +277,8 @@ public VisualClassifier getClassifier(String classifierId) { Validate.isTrue(classifierId != null && !classifierId.isEmpty(), "classifierId cannot be null or empty"); - Request request = - RequestBuilder.get(String.format(PATH_CLASSIFIER, classifierId)) - .withQuery(VERSION, versionDate).build(); + Request request = RequestBuilder.get(String.format(PATH_CLASSIFIER, classifierId)) + .withQuery(VERSION, versionDate).build(); return executeRequest(request, VisualClassifier.class); } @@ -294,9 +289,8 @@ public VisualClassifier getClassifier(String classifierId) { * @see VisualClassifier */ public List getClassifiers() { - Request request = - RequestBuilder.get(PATH_CLASSIFIERS).withQuery(VERSION, versionDate) - .withQuery(VERBOSE, true).build(); + Request request = RequestBuilder.get(PATH_CLASSIFIERS).withQuery(VERSION, versionDate) + .withQuery(VERBOSE, true).build(); VisualClassifiers classifiers = executeRequest(request, VisualClassifiers.class); return classifiers.getClassifiers(); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java b/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java index a5d94ffcf8b..22ceca76aeb 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java @@ -25,6 +25,8 @@ import com.ibm.watson.developer_cloud.WatsonServiceTest; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Account; +import com.ibm.watson.developer_cloud.concept_insights.v2.model.AccountPermission; +import com.ibm.watson.developer_cloud.concept_insights.v2.model.AccountPermission.Permission; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Accounts; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Annotations; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Concept; @@ -32,6 +34,7 @@ import com.ibm.watson.developer_cloud.concept_insights.v2.model.Concepts; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Corpora; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Corpus; +import com.ibm.watson.developer_cloud.concept_insights.v2.model.Corpus.Access; import com.ibm.watson.developer_cloud.concept_insights.v2.model.CorpusProcessingState; import com.ibm.watson.developer_cloud.concept_insights.v2.model.CorpusStats; import com.ibm.watson.developer_cloud.concept_insights.v2.model.Document; @@ -339,12 +342,13 @@ public void testGetGraphs() { @Test public void testCreateAndDeleteCorpus() { final String name = UUID.randomUUID().toString(); - final Account account = service.getAccountsInfo().getAccounts().get(0); - Corpus corpus = new Corpus(account.getId(), name); + final String account = service.getFirstAccountId(); + Corpus corpus = new Corpus(account, name); + corpus.addAccountPermissions(new AccountPermission(account, Permission.READ_WRITE_ADMIN)); try { service.createCorpus(corpus); corpus = service.getCorpus(corpus); - corpus.setAccess(Corpus.ACCESS_PUBLIC); + corpus.setAccess(Access.PUBLIC); service.updateCorpus(corpus); } finally { service.deleteCorpus(corpus); @@ -363,7 +367,7 @@ public void testGetGraphsLabelSearch() { final RequestedFields fs = new RequestedFields(); fs.include("abstract"); - params.put("concept_fields", fs); + params.put(ConceptInsights.CONCEPT_FIELDS, fs); final Matches matches = service.searchGraphsConceptByLabel(Graph.WIKIPEDIA, params); Assert.assertNotNull(matches);