You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/03/18 01:25:20 UTC

[incubator-nlpcraft] branch master updated: WIP on sqlgen documentation.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 14e46fd  WIP on sqlgen documentation.
14e46fd is described below

commit 14e46fdda96522e3a636ec890f0da57fbec8924b
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Tue Mar 17 18:25:07 2020 -0700

    WIP on sqlgen documentation.
---
 docker/Dockerfile                                  |  2 +-
 .../model/tools/sqlgen/NCSqlException.java         | 17 +++++++++++++++++
 .../model/tools/sqlgen/NCSqlModelGenerator.java    |  4 ++--
 .../model/tools/sqlgen/NCSqlSchemaBuilder.java     |  4 ++--
 .../nlpcraft/model/tools/sqlgen/NCSqlUtils.java    | 22 +++++++++++-----------
 .../sqlgen/impl/NCSqlModelGeneratorImpl.scala      |  4 ++--
 ...CSqlUtilsAdapter.scala => NCSqlUtilsImpl.scala} |  2 +-
 .../nlpcraft/model/tools/sqlgen/package-info.java  |  5 +++++
 8 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/docker/Dockerfile b/docker/Dockerfile
index c3a6914..373b90f 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -20,7 +20,7 @@ LABEL Software="https://nlpcraft.apache.org"
 LABEL License="Apache 2.0, https://www.apache.org/licenses/LICENSE-2.0"
 LABEL Licensor="Copyright 2020 (C) Apache Software Foundation"
 ARG JAR_FILE
-COPY $JAR_FILE nlpcraft-all-deps.jar
+COPY $JAR_FILE apache-nlpcraft-all-deps.jar
 ENTRYPOINT ["java", \
 "-XX:+UnlockExperimentalVMOptions", \
 "-XX:+UseCGroupMemoryLimitForHeap", \
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlException.java b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlException.java
index a7e9d76..17dde35 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlException.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlException.java
@@ -17,11 +17,28 @@
 
 package org.apache.nlpcraft.model.tools.sqlgen;
 
+/**
+ * Exception thrown by various classes in model stub generator utility.
+ *
+ * @see NCSqlUtils
+ * @see NCSqlSchemaBuilder
+ */
 public class NCSqlException extends RuntimeException {
+    /**
+     * Creates new exception.
+     *
+     * @param message Error message.
+     */
     public NCSqlException(String message) {
         super(message);
     }
 
+    /**
+     * Creates new exception.
+     *
+     * @param message Error message.
+     * @param cause Optional cause of this exception.
+     */
     public NCSqlException(String message, Throwable cause) {
         super(message, cause);
     }
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlModelGenerator.java b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlModelGenerator.java
index d744487..a9708c1 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlModelGenerator.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlModelGenerator.java
@@ -26,9 +26,9 @@ import org.apache.nlpcraft.model.tools.sqlgen.impl.NCSqlModelGeneratorImpl;
  * want to generate NLPCraft model stub. After the model stub is generated you need to further configure and customize
  * it for your specific needs.
  * <p>
- * Run this class with <code>--help</code> parameter to get a full up-to-date documentation:
+ * Run this class with <code>--help</code> parameter to get a full documentation:
  * <pre class="brush:plain">
- * java -cp nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator --help
+ * java -cp apache-nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator --help
  * </pre>
  */
 public class NCSqlModelGenerator {
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlSchemaBuilder.java b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlSchemaBuilder.java
index 87e572a..2289366 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlSchemaBuilder.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlSchemaBuilder.java
@@ -18,10 +18,10 @@
 package org.apache.nlpcraft.model.tools.sqlgen;
 
 import org.apache.nlpcraft.model.NCModel;
-import org.apache.nlpcraft.model.tools.sqlgen.impl.NCSqlUtilsAdapter;
+import org.apache.nlpcraft.model.tools.sqlgen.impl.NCSqlUtilsImpl;
 
 public class NCSqlSchemaBuilder {
     public static NCSqlSchema makeSchema(NCModel model) {
-        return NCSqlUtilsAdapter.makeSchema(model);
+        return NCSqlUtilsImpl.makeSchema(model);
     }
 }
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlUtils.java b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlUtils.java
index 6badd41..3d254e2 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlUtils.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/NCSqlUtils.java
@@ -18,7 +18,7 @@
 package org.apache.nlpcraft.model.tools.sqlgen;
 
 import org.apache.nlpcraft.model.NCToken;
-import org.apache.nlpcraft.model.tools.sqlgen.impl.NCSqlUtilsAdapter;
+import org.apache.nlpcraft.model.tools.sqlgen.impl.NCSqlUtilsImpl;
 
 import java.util.List;
 
@@ -27,42 +27,42 @@ import java.util.List;
  */
 public class NCSqlUtils {
     public static NCSqlLimit extractLimit(NCSqlSchema schema, List<NCToken> variant, NCToken limitTok) {
-        return NCSqlUtilsAdapter.extractLimit(schema, variant, limitTok);
+        return NCSqlUtilsImpl.extractLimit(schema, variant, limitTok);
     }
 
     public static List<NCSqlSimpleCondition> extractDateRangeConditions(NCSqlSchema schema, NCToken colTok, NCToken dateTok) {
-        return NCSqlUtilsAdapter.extractDateRangeConditions(schema, colTok, dateTok);
+        return NCSqlUtilsImpl.extractDateRangeConditions(schema, colTok, dateTok);
     }
 
     public static List<NCSqlSimpleCondition> extractNumConditions(NCSqlSchema schema, NCToken colTok, NCToken numTok) {
-        return NCSqlUtilsAdapter.extractNumConditions(schema, colTok, numTok);
+        return NCSqlUtilsImpl.extractNumConditions(schema, colTok, numTok);
     }
 
     public static List<NCSqlInCondition> extractValuesConditions(NCSqlSchema schema, NCToken... allValsToks) {
-        return NCSqlUtilsAdapter.extractValuesConditions(schema, allValsToks);
+        return NCSqlUtilsImpl.extractValuesConditions(schema, allValsToks);
     }
 
     public static NCSqlSort extractSorts(NCSqlSchema schema, List<NCToken> variant, NCToken sortTok) {
-        return NCSqlUtilsAdapter.extractSorts(schema, variant, sortTok);
+        return NCSqlUtilsImpl.extractSorts(schema, variant, sortTok);
     }
 
     public static NCSqlAggregate extractAggregate(NCSqlSchema schema, List<NCToken> variant, NCToken aggrFunc, NCToken aggrGroupOpt) {
-        return NCSqlUtilsAdapter.extractAggregate(schema, variant, aggrFunc, aggrGroupOpt);
+        return NCSqlUtilsImpl.extractAggregate(schema, variant, aggrFunc, aggrGroupOpt);
     }
 
     public static NCSqlTable extractTable(NCSqlSchema schema, NCToken tok) {
-        return NCSqlUtilsAdapter.extractTable(schema, tok);
+        return NCSqlUtilsImpl.extractTable(schema, tok);
     }
 
     public static NCSqlColumn extractColumn(NCSqlSchema schema, NCToken tok) {
-        return NCSqlUtilsAdapter.extractColumn(schema, tok);
+        return NCSqlUtilsImpl.extractColumn(schema, tok);
     }
 
     public static NCSqlDateRange extractDateRange(NCToken tok) {
-        return NCSqlUtilsAdapter.extractDateRange(tok);
+        return NCSqlUtilsImpl.extractDateRange(tok);
     }
 
     public static NCToken findAnyColumnToken(NCToken tok) {
-        return NCSqlUtilsAdapter.findAnyColumnToken(tok);
+        return NCSqlUtilsImpl.findAnyColumnToken(tok);
     }
 }
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala
index 4276195..d906ae2 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala
@@ -568,7 +568,7 @@ object NCSqlModelGeneratorImpl {
                    |    NCSqlModelGenerator -- NLPCraft model generator for SQL databases.
                    |
                    |SYNOPSIS:
-                   |    java -cp nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator [PARAMETERS]
+                   |    java -cp apache-nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator [PARAMETERS]
                    |
                    |DESCRIPTION:
                    |    This utility generates NLPCraft model stub for a given SQL database schema. You
@@ -672,7 +672,7 @@ object NCSqlModelGeneratorImpl {
                |                             do not start with '_'.
                |
                |EXAMPLES:
-               |    java -cp nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator
+               |    java -cp apache-nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator
                |        -r jdbc:postgresql://localhost:5432/mydb
                |        -d org.postgresql.Driver
                |        -f "tbl_, col_"
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlUtilsAdapter.scala b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlUtilsImpl.scala
similarity index 99%
rename from src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlUtilsAdapter.scala
rename to src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlUtilsImpl.scala
index 69e67e5..54605ca 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlUtilsAdapter.scala
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlUtilsImpl.scala
@@ -25,7 +25,7 @@ import org.apache.nlpcraft.model.{NCModel, NCToken}
 
 import scala.collection.JavaConverters._
 
-object NCSqlUtilsAdapter {
+object NCSqlUtilsImpl {
     private def extractSqlColumn(schema: NCSqlSchema, colTok: NCToken): NCSqlColumn = {
         val tab: String = colTok.meta("sql:tablename")
         val col: String = colTok.meta("sql:name")
diff --git a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/package-info.java b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/package-info.java
index 44ec1ee..a0c66bb 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/package-info.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/package-info.java
@@ -17,5 +17,10 @@
 
 /**
  * Contains model stub generator for SQL RDBMS.
+ * <p>
+ * Run the following from the command line to get a full documentation:
+ * <pre class="brush:plain">
+ * java -cp apache-nlpcraft-x.x.x-all-deps.jar org.apache.nlpcraft.model.tools.sqlgen.NCSqlModelGenerator --help
+ * </pre>
  */
 package org.apache.nlpcraft.model.tools.sqlgen;
\ No newline at end of file