aboutsummaryrefslogtreecommitdiffstats
path: root/src/site/tools.mkd
diff options
context:
space:
mode:
Diffstat (limited to 'src/site/tools.mkd')
-rw-r--r--src/site/tools.mkd98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/site/tools.mkd b/src/site/tools.mkd
deleted file mode 100644
index 1e38f4b..0000000
--- a/src/site/tools.mkd
+++ /dev/null
@@ -1,98 +0,0 @@
-## Model Generation
-If you do not have or do not want to annotate your existing model classes, you can use the included model generation tool to create iciql model classes.
-
----FIXED---
- win: java -cp iciql.jar;your_db_driver.jar <parameters>
-*nix: java -cp iciql.jar:your_db_driver.jar <parameters>
----FIXED---
-
-### Parameters
-<table class="table">
-<tr><th>-url</th><td>JDBC url for the database</td><td><em>REQUIRED</em></td></tr>
-<tr><th>-username</th><td>username for JDBC connection</td><td><em>optional</em></td></tr>
-<tr><th>-password</th><td>password for JDBC connection</td><td><em>optional</em></td></tr>
-<tr><th>-schema</th><td>the target schema for model generation</td><td><em>default:</em> all schemas</td></tr>
-<tr><th>-table</th><td>the target table for model generation</td><td><em>default:</em> all tables</td></tr>
-<tr><th>-package</th><td>the destination package name for generated models</td><td><em>default:</em> default package</td></tr>
-<tr><th>-folder</th><td>the output folder for .java files</td><td><em>default:</em> current folder</td></tr>
-<tr><th>-annotateSchema</th><td>include the schema name in the class annotations</td><td><em>default:</em> true</td></tr>
-<tr><th>-trimStrings</th><td>annotate trimStrings=true for any VARCHAR string mappings &nbsp; </td><td><em>default:</em> false</td></tr>
-</table>
-
-## Model Validation
-Iciql can validate your model classes against your database to ensure that your models are optimally defined and are consistent with the current table and index definitions.
-
-Each `com.iciql.ValidationRemark` returned by the validation has an associated level from the following enum:
----JAVA---
-public static enum Level {
- CONSIDER, WARN, ERROR;
-}
----JAVA---
-
-A typical validation may output recommendations for adjusting a model field annotation such as setting the *maxLength* of a string to match the length of its linked VARCHAR column.
-
-### Sample Model Validation using JUnit 4
----JAVA---
-import static org.junit.Assert.assertTrue;
-
-import java.sql.SQLException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ErrorCollector;
-
-import com.iciql.Db;
-import com.iciql.DbInspector;
-import com.iciql.ValidationRemark;
-import com.iciql.test.models.Product;
-import com.iciql.test.models.ProductAnnotationOnly;
-import com.iciql.test.models.ProductMixedAnnotation;
-
-public class ValidateModels {
-
- /*
- * The ErrorCollector Rule allows execution of a test to continue after the
- * first problem is found and report them all at once
- */
- @Rule
- public ErrorCollector errorCollector = new ErrorCollector();
-
- private Db db;
-
- @Before
- public void setUp() {
- db = Db.open("jdbc:h2:mem:", "sa", "sa");
- }
-
- @After
- public void tearDown() {
- db.close();
- }
-
- @Test
- public void testValidateModels() {
- DbInspector inspector = new DbInspector(db);
- validateModel(inspector, new Product());
- validateModel(inspector, new ProductAnnotationOnly());
- validateModel(inspector, new ProductMixedAnnotation());
- }
-
- private void validateModel(DbInspector inspector, Object o) {
- List<ValidationRemark> remarks = inspector.validateModel(o, false);
- assertTrue("Validation remarks are null for " + o.getClass().getName(), remarks != null);
- log("Validation remarks for " + o.getClass().getName());
- for (ValidationRemark remark : remarks) {
- log(remark.toString());
- if (remark.isError()) {
- errorCollector.addError(new SQLException(remark.toString()));
- }
- }
- }
-
- private void log(String message) {
- System.out.println(message);
- }
-}
----JAVA--- \ No newline at end of file