Inquire Client usage in Scala

import java.io.File
import java.util.Comparator
import math.Integral
import com.artisol.teneo.inquire.client.Client
import java.util
import collection.mutable.{Map => MMap}
import java.util.Collections._
import java.util.{Map => JMap}
object Main extends App
{

var javamap: java.util.Map[String,Object]=new util.HashMap()
javamap.put(“timeout”,“1000”)
javamap.put(“esPageSize”,“10”)
println(javamap)
Client.init(this,"***********",javamap)
// Client.init.login("
", “*************************”)

// x.put(“esPageSize”,10)
//println(x)

}

I am getthing the following error when I try to run the scala code to use teneo inquire client API. Also, I get the same error when I invoke the API through groovy function or class. But the API works when used directly inside groovy main function. Looks like it is a scope issue. If there is a work around for this that would be great.

Exception in thread “main” groovy.lang.MissingPropertyException: No such property: tql for class: Main$
** at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65)**
** at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:498)**
** at com.artisol.teneo.inquire.client.Client.init(Client.groovy:61)**
** at Main$.delayedEndpoint$Main$1(SbtExampleProject.scala:18)**
** at Main$delayedInit$body.apply(SbtExampleProject.scala:11)**
** at scala.Function0.apply$mcV$sp(Function0.scala:39)**
** at scala.Function0.apply$mcV$sp$(Function0.scala:39)**
** at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)**
** at scala.App.$anonfun$main$1(App.scala:76)**
** at scala.App.$anonfun$main$1$adapted(App.scala:76)**
** at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)**
** at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)**
** at scala.collection.AbstractIterable.foreach(Iterable.scala:919)**
** at scala.App.main(App.scala:76)**
** at scala.App.main$(App.scala:74)**
** at Main$.main(SbtExampleProject.scala:11)**
** at Main.main(SbtExampleProject.scala)**

Hi Mohammed-zaib, welcome to the forum!

I am having a hard time understanding the question. Do you mind giving me more context for this case? A code snippet and telling me what the goal is would be highly appreciated.

Warm Regards,

HI All,

I am sorry for the previous post. I posted the error by mistake. Here is the context to entire error.

I am running the following scala code to use teneo inquire client API through Scala.

import java.io.File
import java.util.Comparator
import math.Integral
import com.artisol.teneo.inquire.client.Client
import java.util
import collection.mutable.{Map => MMap}
import java.util.Collections._
import java.util.{Map => JMap}
object Main extends App
{

var javamap: java.util.Map[String,Object]=new util.HashMap()
javamap.put(“timeout”,“1000”)
javamap.put(“esPageSize”,“10”)
println(javamap)
Client.init(this,“",javamap)
Client.init.login("
", "
***********”)

x.put(“esPageSize”,10)
println(x)

}

The above error mentioned is what I am getting when I run this scala code. Looks to be scope of the variable issue. I get the same error when I try to invoke teneo Inquire client API through function or class in groovy. However, in groovy it works fine through main function.

Hi @Ramazan,

Sorry for the inconvenience. It was my first post, and I wasn’t able to overwrite the post as my account was not verified. I have now corrected the post. Let me know if you have any questions.

1 Like

Hi Mohammed-Zaib,

I would suggest using QueryClient in the case of Scala. The approach you took is more suited/specialized to groovy

Here is a code snippet to use for inspiration,

package playground
import com.artisol.teneo.inquire.clientapi.QueryClient
import java.util

object helloFresh extends App {
  val backendUrl: String = "https://domain.data.teneo.ai/teneo-inquire-query/rest"
  var clientParameters: util.HashMap[String, Object] = new util.HashMap[String, Object]()
  clientParameters.put("timeout", 1000.asInstanceOf[AnyRef])
  clientParameters.put("esPageSize", 10.asInstanceOf[AnyRef])

  val clientApi: QueryClient = QueryClient.create(backendUrl)
  val user: String = "user"
  val pass: String = "pass"
  clientApi.login(user, pass)

  val lds: String = ""
  val tql: String = "some_tql_query"
  val result = clientApi.executeQuery(lds, tql, clientParameters)
}

Please let me know if you have any other thoughts or questions.

Warm regards,