This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-296
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-296 by this push:
     new 41327cb  WIP.
41327cb is described below

commit 41327cb98eb09df96458f043912b9ed35c3c1567
Author: unknown <[email protected]>
AuthorDate: Wed May 26 16:23:34 2021 -0700

    WIP.
---
 .../model/intent/compiler/NCIdlCompilerBase.scala    |  9 +++++----
 .../model/intent/compiler/NCIdlCompilerGlobal.scala  |  2 +-
 .../model/intent/solver/NCIntentSolverEngine.scala   |  9 +--------
 .../model/intent/solver/NCIntentSolverVariant.scala  |  1 -
 .../apache/nlpcraft/model/tools/cmdline/NCCli.scala  |  4 ++--
 .../org/apache/nlpcraft/probe/NCProbeBoot.scala      |  4 ++--
 .../apache/nlpcraft/server/rest/NCBasicRestApi.scala | 20 ++++++++++++++------
 .../scala/org/apache/nlpcraft/server/sql/NCSql.scala |  2 +-
 .../apache/nlpcraft/server/sql/NCSqlManager.scala    | 11 ++++++-----
 9 files changed, 32 insertions(+), 30 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
index aaf1462..e314cba 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
@@ -30,7 +30,7 @@ import java.time.temporal.IsoFields
 import java.time.{LocalDate, LocalTime}
 import java.util
 import java.util.{Calendar, Collections, Collection => JColl, List => JList, 
Map => JMap}
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters.{CollectionHasAsScala, IterableHasAsJava}
 
 trait NCIdlCompilerBase {
     type S = NCIdlStack
@@ -387,6 +387,7 @@ trait NCIdlCompilerBase {
         val (x1, x2) = pop2()(stack, ctx)
 
         def doEq(v1: Object, v2: Object): Boolean = {
+            //noinspection ComparingUnrelatedTypes
             if (v1 eq v2) true
             else if (v1 == null && v2 == null) true
             else if ((v1 == null && v2 != null) || (v1 != null && v2 == null)) 
false
@@ -740,7 +741,7 @@ trait NCIdlCompilerBase {
                     if (lst.isEmpty)
                         throw newRuntimeError(s"Unexpected empty list in IDL 
function: $fun()")
                     else {
-                        val seq: Seq[Double] = lst.asScala.map(p => 
JDouble.valueOf(p.toString).doubleValue())
+                        val seq: Seq[Double] = lst.asScala.map(p => 
JDouble.valueOf(p.toString).doubleValue()).toSeq
 
                         Z(seq.sum / seq.length, n)
                     }
@@ -762,7 +763,7 @@ trait NCIdlCompilerBase {
                     if (lst.isEmpty)
                         throw newRuntimeError(s"Unexpected empty list in IDL 
function: $fun()")
                     else {
-                        val seq: Seq[Double] = lst.asScala.map(p => 
JDouble.valueOf(p.toString).doubleValue())
+                        val seq: Seq[Double] = lst.asScala.map(p => 
JDouble.valueOf(p.toString).doubleValue()).toSeq
 
                         val mean = seq.sum / seq.length
                         val stdDev = Math.sqrt(seq.map( _ - mean).map(t => t * 
t).sum / seq.length)
@@ -869,7 +870,7 @@ trait NCIdlCompilerBase {
             stack.push(() => {
                 val Z(v, n) = x()
 
-                val jl = toList(v).asScala.distinct.asJava
+                val jl = toList(v).asScala.toSeq.distinct.asJava
 
                 Z(jl, n)
             })
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerGlobal.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerGlobal.scala
index dcdce77..31fdf86 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerGlobal.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerGlobal.scala
@@ -40,7 +40,7 @@ object NCIdlCompilerGlobal {
      */
     private def clearImportCache(): Unit =
         importCache.synchronized {
-            importCache.clear
+            importCache.clear()
         }
 
     /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
index 47db236..d26c8c2 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
@@ -29,8 +29,6 @@ import org.apache.nlpcraft.model.{NCContext, 
NCDialogFlowItem, NCIntentMatch, NC
 import org.apache.nlpcraft.probe.mgrs.dialogflow.NCDialogFlowManager
 
 import java.util.function.Function
-import scala.collection.JavaConverters._
-import scala.collection.convert.ImplicitConversions._
 import scala.collection.mutable
 
 /**
@@ -119,12 +117,7 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
             res
         }
 
-        /**
-         *
-         * @return
-         */
-        def toSeq: Seq[Int] = buf
-
+        def toSeq: Seq[Int] = buf.toSeq
         def toAnsiString: String = buf.mkString(y(bo("[")), ", ", y(bo("]")))
     }
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
index 561cd8b..deabc32 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
@@ -21,7 +21,6 @@ import org.apache.nlpcraft.common._
 import org.apache.nlpcraft.model.NCToken
 import org.apache.nlpcraft.model.impl.NCTokenPimp._
 
-import scala.collection.JavaConverters._
 import java.util
 
 /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 8493f51..d92c189 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -846,7 +846,7 @@ object NCCli extends NCCliBase {
                 breakable {
                     for (_ <- 0 until lines)
                         in.readLine() match {
-                            case null => break
+                            case null => break()
                             case line => tail ::= line
                         }
                 }
@@ -1882,7 +1882,7 @@ object NCCli extends NCCliBase {
         outEntry: String,
         extractHeader: Option[Seq[String] => (Int, Int)],
         repls: (String, String)*
-    ) {
+    ): Unit = {
         val key = s"$zipInDir/$inEntry"
 
         require(PRJ_TEMPLATES.contains(key), s"Unexpected template entry for: 
$key")
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
index 5b0d196..138b777 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
@@ -433,7 +433,7 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
     /**
       * Prints ASCII-logo.
       */
-    private def asciiLogo() {
+    private def asciiLogo(): Unit = {
         val ver = NCVersion.getCurrent
 
         println(
@@ -469,7 +469,7 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
     /**
       * Asks server start.
       */
-    private def ackStart() {
+    private def ackStart(): Unit = {
         val dur = s"[${U.format((U.now() - execStart) / 1000.0, 2)} sec]"
         
         val tbl = NCAsciiTable()
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
index 8edb6b9..45ab892 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
@@ -48,8 +48,8 @@ import org.apache.nlpcraft.server.user.NCUserManager
 import spray.json.DefaultJsonProtocol._
 import spray.json.{JsObject, JsValue, RootJsonFormat}
 
-import scala.collection.JavaConverters._
 import scala.concurrent.{ExecutionContext, Future}
+import scala.jdk.CollectionConverters._
 
 /**
   * REST API default implementation.
@@ -138,7 +138,6 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
     /**
       *
       * @param o
-      * @throws
       * @return
       */
     @throws[NCE]
@@ -146,7 +145,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
         try
             JS_MAPPER.writeValueAsString(o)
         catch {
-            case e: JsonProcessingException => throw new NCE(s"JSON 
serialization error for: $o", e)
+            case e: JsonProcessingException => throw new NCE(s"JSON 
serialization error.", e)
         }
 
     /**
@@ -246,7 +245,6 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
             "intentId" -> s.intentId.orNull
         ).filter(_._2 != null).asJava
 
-
     /**
       * Extracts and checks JSON.
       *
@@ -846,7 +844,12 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
                 "mdlId" -> req.mdlId,
                 "usrExtId" -> req.usrExtId.orNull,
                 "usrId" -> req.usrId.getOrElse(-1)) { span =>
-                checkLength("acsTok" -> req.acsTok, "mdlId" -> req.mdlId, 
"usrExtId" -> req.usrExtId)
+                //noinspection DuplicatedCode
+                checkLength(
+                    "acsTok" -> req.acsTok,
+                    "mdlId" -> req.mdlId,
+                    "usrExtId" -> req.usrExtId
+                )
 
                 val acsUsr = authenticate(req.acsTok)
 
@@ -886,7 +889,12 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
                 "usrExtId" -> req.usrExtId.orNull,
                 "mdlId" -> req.mdlId,
                 "usrId" -> req.usrId.getOrElse(-1)) { span =>
-                checkLength("acsTok" -> req.acsTok, "mdlId" -> req.mdlId, 
"usrExtId" -> req.usrExtId)
+                //noinspection DuplicatedCode
+                checkLength(
+                    "acsTok" -> req.acsTok,
+                    "mdlId" -> req.mdlId,
+                    "usrExtId" -> req.usrExtId
+                )
 
                 val acsUsr = authenticate(req.acsTok)
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala
index 6020350..d8e2eac 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala
@@ -19,7 +19,6 @@ package org.apache.nlpcraft.server.sql
 
 import java.sql.Types._
 import java.sql.{Connection, PreparedStatement, ResultSet, SQLException, 
Timestamp}
-
 import com.mchange.v2.c3p0.ComboPooledDataSource
 import com.typesafe.scalalogging.LazyLogging
 import org.apache.ignite.{Ignite, IgniteAtomicSequence, IgniteJdbcThinDriver}
@@ -29,6 +28,7 @@ import org.apache.nlpcraft.common.config.NCConfigurable
 import org.apache.nlpcraft.server.tx.NCTxManager
 
 import scala.collection._
+import scala.util.Using
 import scala.util.control.Exception._
 
 /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala
index 142fd4f..a1f690b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala
@@ -29,6 +29,7 @@ import org.apache.nlpcraft.server.mdo._
 import org.apache.nlpcraft.server.sql.NCSql.Implicits._
 
 import java.sql.Timestamp
+import scala.collection.mutable
 
 /**
   * Provides basic CRUD and often used operations on RDBMS.
@@ -82,7 +83,7 @@ object NCSqlManager extends NCService with NCIgniteInstance {
         try
             if (m != null) U.compress(JS_MAPPER.writeValueAsString(m)) else 
null
         catch {
-            case e: JsonProcessingException => throw new NCE(s"JSON 
serialization error for: $m", e)
+            case e: JsonProcessingException => throw new NCE(s"JSON 
serialization error.", e)
         }
     }
 
@@ -270,7 +271,7 @@ object NCSqlManager extends NCService with NCIgniteInstance 
{
         propsOpt: Option[String],
         parent: Span
     ): Int =
-        startScopedSpan("updateUser", parent, "usrId" -> id) { span =>
+        startScopedSpan("updateUser", parent, "usrId" -> id) { _ =>
             NCSql.update(
                 s"""
                    |UPDATE nc_user
@@ -642,7 +643,7 @@ object NCSqlManager extends NCService with NCIgniteInstance 
{
             "usrId" -> id,
             "compId" -> compId,
             "email" -> email.orNull,
-            "usrExtId" -> usrExtId.orNull) { span =>
+            "usrExtId" -> usrExtId.orNull) { _ =>
             val now = U.nowUtcTs()
 
             // Insert user.
@@ -966,7 +967,7 @@ object NCSqlManager extends NCService with NCIgniteInstance 
{
             "userId" -> userId.getOrElse(() => null)
         ) { _ =>
             var sql = "SELECT * FROM feedback WHERE user_id IN (SELECT id from 
nc_user WHERE company_id = ?)"
-            val params = collection.mutable.Buffer.empty[Any]
+            val params = mutable.Buffer.empty[Any]
 
             params += companyId
 
@@ -981,7 +982,7 @@ object NCSqlManager extends NCService with NCIgniteInstance 
{
             add("srv_req_id", srvReqId)
             add("user_id", userId)
 
-            NCSql.select[NCFeedbackMdo](sql, params :_*)
+            NCSql.select[NCFeedbackMdo](sql, params.toSeq :_*)
         }
     }
 

Reply via email to