You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metamodel.apache.org by ka...@apache.org on 2016/05/16 03:53:36 UTC

[01/42] metamodel git commit: METAMODEL-227: Fixed

Repository: metamodel
Updated Branches:
  refs/heads/5.x 95226631f -> 6d50f0e31


METAMODEL-227: Fixed

Fixes #83

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/f779f43c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/f779f43c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/f779f43c

Branch: refs/heads/5.x
Commit: f779f43cd048ce9fb5c05bb92ee31a9039a3a4fa
Parents: b2eca1c
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sat Jan 2 20:34:23 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Jan 2 20:34:23 2016 +0100

----------------------------------------------------------------------
 CHANGES.md                                      |  4 ++
 .../org/apache/metamodel/csv/CsvWriter.java     | 37 ++++++++++++-----
 .../org/apache/metamodel/csv/CsvWriterTest.java | 43 ++++++++++++++++++++
 3 files changed, 73 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/f779f43c/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index a5d8796..0a0d387 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,7 @@
+### Apache MetaModel 4.5.1 (work-in-progress)
+
+ * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
+
 ### Apache MetaModel 4.5.0
 
  * [METAMODEL-212] - New module for ElasticSearch via REST client.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/f779f43c/csv/src/main/java/org/apache/metamodel/csv/CsvWriter.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvWriter.java b/csv/src/main/java/org/apache/metamodel/csv/CsvWriter.java
index 1d0b424..bf640e1 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvWriter.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvWriter.java
@@ -59,7 +59,7 @@ public final class CsvWriter {
                 sb.append(quoteChar);
             }
 
-            sb.append(stringContainsSpecialCharacters(nextElement) ? processLine(nextElement) : nextElement);
+            sb.append(valueNeedsEscaping(nextElement) ? processValue(nextElement) : nextElement);
 
             if (quoteChar != CsvConfiguration.NOT_A_CHAR) {
                 sb.append(quoteChar);
@@ -71,24 +71,39 @@ public final class CsvWriter {
 
     }
 
-    private boolean stringContainsSpecialCharacters(String line) {
-        return line.indexOf(_configuration.getQuoteChar()) != -1 || line.indexOf(_configuration.getEscapeChar()) != -1;
+    private boolean valueNeedsEscaping(String line) {
+        boolean result = line.indexOf(_configuration.getQuoteChar()) != -1
+                || line.indexOf(_configuration.getEscapeChar()) != -1;
+        if (!result) {
+            result = _configuration.getQuoteChar() == CsvConfiguration.NOT_A_CHAR
+                    && line.indexOf(_configuration.getSeparatorChar()) != -1;
+        }
+        return result;
     }
 
-    private StringBuilder processLine(String nextElement) {
-        final StringBuilder sb = new StringBuilder(INITIAL_STRING_SIZE);
-        for (int j = 0; j < nextElement.length(); j++) {
-            final char nextChar = nextElement.charAt(j);
-            final char escapeChar = _configuration.getEscapeChar();
-            if (escapeChar != CsvConfiguration.NOT_A_CHAR && nextChar == _configuration.getQuoteChar()) {
+    private String processValue(String value) {
+        final char escapeChar = _configuration.getEscapeChar();
+        if (escapeChar == CsvConfiguration.NOT_A_CHAR) {
+            return value;
+        }
+
+        final char quoteChar = _configuration.getQuoteChar();
+        final char separatorChar = _configuration.getSeparatorChar();
+
+        final StringBuilder sb = new StringBuilder(value.length() + 10);
+        for (int j = 0; j < value.length(); j++) {
+            final char nextChar = value.charAt(j);
+            if (nextChar == quoteChar) {
+                sb.append(escapeChar).append(nextChar);
+            } else if (nextChar == escapeChar) {
                 sb.append(escapeChar).append(nextChar);
-            } else if (escapeChar != CsvConfiguration.NOT_A_CHAR && nextChar == escapeChar) {
+            } else if (quoteChar == CsvConfiguration.NOT_A_CHAR && nextChar == separatorChar) {
                 sb.append(escapeChar).append(nextChar);
             } else {
                 sb.append(nextChar);
             }
         }
 
-        return sb;
+        return sb.toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/f779f43c/csv/src/test/java/org/apache/metamodel/csv/CsvWriterTest.java
----------------------------------------------------------------------
diff --git a/csv/src/test/java/org/apache/metamodel/csv/CsvWriterTest.java b/csv/src/test/java/org/apache/metamodel/csv/CsvWriterTest.java
new file mode 100644
index 0000000..75f0c63
--- /dev/null
+++ b/csv/src/test/java/org/apache/metamodel/csv/CsvWriterTest.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.csv;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CsvWriterTest {
+
+    @Test
+    public void testBuildLineWithSeparatorInValue() throws Exception {
+        CsvConfiguration configuration = new CsvConfiguration(1, "UTF-8", ',', '"', '\\');
+        CsvWriter writer = new CsvWriter(configuration);
+        String line = writer.buildLine(new String[] {"0", "1,2", "3'4", "5\\6"});
+        assertEquals("\"0\",\"1,2\",\"3'4\",\"5\\\\6\"\n", line);
+    }
+    
+
+    @Test
+    public void testBuildLineWithSeparatorInValueAndNoQuoteCharacterSet() throws Exception {
+        CsvConfiguration configuration = new CsvConfiguration(1, "UTF-8", ',', CsvConfiguration.NOT_A_CHAR, '\\');
+        CsvWriter writer = new CsvWriter(configuration);
+        String line = writer.buildLine(new String[] {"0", "1,2", "3'4", "5\\6"});
+        assertEquals("0,1\\,2,3'4,5\\\\6\n", line);
+    }
+}


[28/42] metamodel git commit: METAMODEL-244: Moved to pkg org.apache.metamodel.schema.naming

Posted by ka...@apache.org.
METAMODEL-244: Moved to pkg org.apache.metamodel.schema.naming

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/a2314f8d
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/a2314f8d
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/a2314f8d

Branch: refs/heads/5.x
Commit: a2314f8da2379f7c6da264b1f20071fa77ac832e
Parents: 0fcc4de
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Apr 24 13:54:40 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Apr 24 13:54:40 2016 -0700

----------------------------------------------------------------------
 .../builder/AlphabeticColumnNamingStrategy.java | 43 -------------
 .../schema/builder/ColumnNamingContext.java     | 52 ----------------
 .../schema/builder/ColumnNamingContextImpl.java | 64 --------------------
 .../schema/builder/ColumnNamingSession.java     | 47 --------------
 .../schema/builder/ColumnNamingStrategy.java    | 31 ----------
 .../builder/DefaultColumnNamingStrategy.java    | 33 ----------
 ...tingIntrinsicSwitchColumnNamingStrategy.java |  4 ++
 .../builder/UniqueColumnNamingStrategy.java     | 62 -------------------
 .../naming/AlphabeticColumnNamingStrategy.java  | 43 +++++++++++++
 .../schema/naming/ColumnNamingContext.java      | 52 ++++++++++++++++
 .../schema/naming/ColumnNamingContextImpl.java  | 64 ++++++++++++++++++++
 .../schema/naming/ColumnNamingSession.java      | 47 ++++++++++++++
 .../schema/naming/ColumnNamingStrategy.java     | 31 ++++++++++
 .../naming/DefaultColumnNamingStrategy.java     | 35 +++++++++++
 .../naming/UniqueColumnNamingStrategy.java      | 62 +++++++++++++++++++
 .../DefaultColumnNamingStrategyTest.java        | 46 --------------
 .../naming/DefaultColumnNamingStrategyTest.java | 49 +++++++++++++++
 .../apache/metamodel/csv/CsvConfiguration.java  |  4 +-
 .../java/org/apache/metamodel/csv/CsvTable.java |  6 +-
 .../fixedwidth/FixedWidthConfiguration.java     |  4 +-
 .../fixedwidth/FixedWidthDataContext.java       |  6 +-
 21 files changed, 397 insertions(+), 388 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
deleted file mode 100644
index 91d1b85..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import org.apache.metamodel.util.AlphabeticSequence;
-
-public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
-
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public ColumnNamingSession startColumnNamingSession() {
-        return new ColumnNamingSession() {
-            private final AlphabeticSequence seq = new AlphabeticSequence();
-
-            @Override
-            public String getNextColumnName(ColumnNamingContext ctx) {
-                return seq.next();
-            }
-
-            @Override
-            public void close() {
-            }
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java
deleted file mode 100644
index 5bcfe56..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import org.apache.metamodel.schema.Table;
-
-/**
- * Defines the context for naming a single column in a
- * {@link ColumnNamingStrategy} session.
- */
-public interface ColumnNamingContext {
-
-    /**
-     * Gets the index of the column being named.
-     * 
-     * @return
-     */
-    public int getColumnIndex();
-
-    /**
-     * Gets the {@link Table} that the column is to pertain to. If the table is
-     * not yet available then this may return null.
-     * 
-     * @return
-     */
-    public Table getTable();
-
-    /**
-     * Gets the intrinsic column name, if this is defined in the datastore
-     * itself. This may be in the form of a header or such. Sometimes intrinsic
-     * column names exist only for some columns and sometimes there may be
-     * duplicate names or other anomalies which are often discouraged.
-     * 
-     * @return
-     */
-    public String getIntrinsicColumnName();
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java
deleted file mode 100644
index cd04f98..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import org.apache.metamodel.schema.Table;
-
-public class ColumnNamingContextImpl implements ColumnNamingContext {
-
-    private final int columnIndex;
-    private final Table table;
-    private final String intrinsicColumnName;
-
-    /**
-     * 
-     * @param table
-     * @param intrinsicColumnName
-     * @param columnIndex
-     */
-    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
-        this.table = table;
-        this.intrinsicColumnName = intrinsicColumnName;
-        this.columnIndex = columnIndex;
-    }
-
-    /**
-     * 
-     * @param columnIndex
-     */
-    public ColumnNamingContextImpl(int columnIndex) {
-        this(null, null, columnIndex);
-    }
-
-    @Override
-    public int getColumnIndex() {
-        return columnIndex;
-    }
-
-    @Override
-    public Table getTable() {
-        return table;
-    }
-
-    @Override
-    public String getIntrinsicColumnName() {
-        return intrinsicColumnName;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java
deleted file mode 100644
index 2c6f7b2..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import java.io.Closeable;
-
-import org.apache.metamodel.schema.Column;
-import org.apache.metamodel.schema.Table;
-
-/**
- * Represents a 'session' in which a single {@link Table}'s {@link Column}s are
- * named.
- */
-public interface ColumnNamingSession extends Closeable {
-
-    /**
-     * Provides the name to apply for a given column.
-     * 
-     * @param ctx
-     *            the context of the column naming taking place. This contains
-     *            column index, intrinsic name etc. if available.
-     * @return the name to provide to the column.
-     */
-    public String getNextColumnName(ColumnNamingContext ctx);
-
-    /**
-     * Ends the column naming session.
-     */
-    @Override
-    public void close();
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
deleted file mode 100644
index 2219fb7..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import java.io.Serializable;
-
-/**
- * A strategy that defines how columns are logically named. Such strategies are
- * mostly used when a particular datastore is not itself intrinsically
- * specifying the column name.
- */
-public interface ColumnNamingStrategy extends Serializable {
-    
-    public ColumnNamingSession startColumnNamingSession();
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
deleted file mode 100644
index 2cc9fb7..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-/**
- * The default (in most cases) {@link ColumnNamingStrategy} to use when no other
- * strategy is specified.
- */
-public class DefaultColumnNamingStrategy extends DelegatingIntrinsicSwitchColumnNamingStrategy {
-
-    private static final long serialVersionUID = 1L;
-
-    public DefaultColumnNamingStrategy() {
-        super(new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
index 612f81d..4fa5d30 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@ -18,6 +18,10 @@
  */
 package org.apache.metamodel.schema.builder;
 
+import org.apache.metamodel.schema.naming.ColumnNamingContext;
+import org.apache.metamodel.schema.naming.ColumnNamingSession;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+
 /**
  * A {@link ColumnNamingStrategy} that switches between two other
  * {@link ColumnNamingStrategy} delegates depending on the availability of a

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
deleted file mode 100644
index 17e7830..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
- * ensures that all column names are unique. When duplicate names are
- * encountered a number will be appended yielding column names like "name",
- * "name1", "name2" etc.
- */
-public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
-
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public ColumnNamingSession startColumnNamingSession() {
-        return new ColumnNamingSession() {
-
-            private final Set<String> names = new HashSet<>();
-
-            @Override
-            public String getNextColumnName(ColumnNamingContext ctx) {
-                final String intrinsicName = ctx.getIntrinsicColumnName();
-                boolean unique = names.add(intrinsicName);
-                if (unique) {
-                    return intrinsicName;
-                }
-
-                String newName = null;
-                for (int i = 2; !unique; i++) {
-                    newName = intrinsicName + i;
-                    unique = names.add(newName);
-                }
-                return newName;
-            }
-
-            @Override
-            public void close() {
-            }
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
new file mode 100644
index 0000000..f6575c7
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.util.AlphabeticSequence;
+
+public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        return new ColumnNamingSession() {
+            private final AlphabeticSequence seq = new AlphabeticSequence();
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                return seq.next();
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
new file mode 100644
index 0000000..b613913
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.Table;
+
+/**
+ * Defines the context for naming a single column in a
+ * {@link ColumnNamingStrategy} session.
+ */
+public interface ColumnNamingContext {
+
+    /**
+     * Gets the index of the column being named.
+     * 
+     * @return
+     */
+    public int getColumnIndex();
+
+    /**
+     * Gets the {@link Table} that the column is to pertain to. If the table is
+     * not yet available then this may return null.
+     * 
+     * @return
+     */
+    public Table getTable();
+
+    /**
+     * Gets the intrinsic column name, if this is defined in the datastore
+     * itself. This may be in the form of a header or such. Sometimes intrinsic
+     * column names exist only for some columns and sometimes there may be
+     * duplicate names or other anomalies which are often discouraged.
+     * 
+     * @return
+     */
+    public String getIntrinsicColumnName();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
new file mode 100644
index 0000000..cc7a24e
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.Table;
+
+public class ColumnNamingContextImpl implements ColumnNamingContext {
+
+    private final int columnIndex;
+    private final Table table;
+    private final String intrinsicColumnName;
+
+    /**
+     * 
+     * @param table
+     * @param intrinsicColumnName
+     * @param columnIndex
+     */
+    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
+        this.table = table;
+        this.intrinsicColumnName = intrinsicColumnName;
+        this.columnIndex = columnIndex;
+    }
+
+    /**
+     * 
+     * @param columnIndex
+     */
+    public ColumnNamingContextImpl(int columnIndex) {
+        this(null, null, columnIndex);
+    }
+
+    @Override
+    public int getColumnIndex() {
+        return columnIndex;
+    }
+
+    @Override
+    public Table getTable() {
+        return table;
+    }
+
+    @Override
+    public String getIntrinsicColumnName() {
+        return intrinsicColumnName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingSession.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingSession.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingSession.java
new file mode 100644
index 0000000..85e5261
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingSession.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import java.io.Closeable;
+
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Table;
+
+/**
+ * Represents a 'session' in which a single {@link Table}'s {@link Column}s are
+ * named.
+ */
+public interface ColumnNamingSession extends Closeable {
+
+    /**
+     * Provides the name to apply for a given column.
+     * 
+     * @param ctx
+     *            the context of the column naming taking place. This contains
+     *            column index, intrinsic name etc. if available.
+     * @return the name to provide to the column.
+     */
+    public String getNextColumnName(ColumnNamingContext ctx);
+
+    /**
+     * Ends the column naming session.
+     */
+    @Override
+    public void close();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
new file mode 100644
index 0000000..6ccccbf
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import java.io.Serializable;
+
+/**
+ * A strategy that defines how columns are logically named. Such strategies are
+ * mostly used when a particular datastore is not itself intrinsically
+ * specifying the column name.
+ */
+public interface ColumnNamingStrategy extends Serializable {
+    
+    public ColumnNamingSession startColumnNamingSession();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java
new file mode 100644
index 0000000..f0bcb23
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.builder.DelegatingIntrinsicSwitchColumnNamingStrategy;
+
+/**
+ * The default (in most cases) {@link ColumnNamingStrategy} to use when no other
+ * strategy is specified.
+ */
+public class DefaultColumnNamingStrategy extends DelegatingIntrinsicSwitchColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    public DefaultColumnNamingStrategy() {
+        super(new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
new file mode 100644
index 0000000..e5288fe
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
+ * ensures that all column names are unique. When duplicate names are
+ * encountered a number will be appended yielding column names like "name",
+ * "name1", "name2" etc.
+ */
+public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        return new ColumnNamingSession() {
+
+            private final Set<String> names = new HashSet<>();
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                final String intrinsicName = ctx.getIntrinsicColumnName();
+                boolean unique = names.add(intrinsicName);
+                if (unique) {
+                    return intrinsicName;
+                }
+
+                String newName = null;
+                for (int i = 2; !unique; i++) {
+                    newName = intrinsicName + i;
+                    unique = names.add(newName);
+                }
+                return newName;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java
deleted file mode 100644
index b903065..0000000
--- a/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class DefaultColumnNamingStrategyTest {
-
-    private final DefaultColumnNamingStrategy namingStrategy = new DefaultColumnNamingStrategy();
-
-    @Test
-    public void testDuplicateColumnNames() throws Exception {
-        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
-            assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
-            assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
-            assertEquals("foo2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
-        }
-    }
-
-    @Test
-    public void testNoIntrinsicColumnNames() throws Exception {
-        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
-            assertEquals("A", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 0)));
-            assertEquals("B", session.getNextColumnName(new ColumnNamingContextImpl(null, null, 1)));
-            assertEquals("C", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 2)));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
new file mode 100644
index 0000000..c8c408b
--- /dev/null
+++ b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import static org.junit.Assert.*;
+
+import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.naming.ColumnNamingSession;
+import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
+import org.junit.Test;
+
+public class DefaultColumnNamingStrategyTest {
+
+    private final DefaultColumnNamingStrategy namingStrategy = new DefaultColumnNamingStrategy();
+
+    @Test
+    public void testDuplicateColumnNames() throws Exception {
+        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
+            assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
+            assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
+            assertEquals("foo2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
+        }
+    }
+
+    @Test
+    public void testNoIntrinsicColumnNames() throws Exception {
+        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
+            assertEquals("A", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 0)));
+            assertEquals("B", session.getNextColumnName(new ColumnNamingContextImpl(null, null, 1)));
+            assertEquals("C", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 2)));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
index 4d1874c..dd1c8ac 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
@@ -21,8 +21,8 @@ package org.apache.metamodel.csv;
 import java.io.Serializable;
 import java.util.List;
 
-import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
-import org.apache.metamodel.schema.builder.DefaultColumnNamingStrategy;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java b/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
index e2a665d..334af7e 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
@@ -27,9 +27,9 @@ import org.apache.metamodel.schema.MutableColumn;
 import org.apache.metamodel.schema.Relationship;
 import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.TableType;
-import org.apache.metamodel.schema.builder.ColumnNamingContextImpl;
-import org.apache.metamodel.schema.builder.ColumnNamingSession;
-import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
+import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.naming.ColumnNamingSession;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 
 import au.com.bytecode.opencsv.CSVReader;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index 9c0dd46..bbdd0ad 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -23,8 +23,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
-import org.apache.metamodel.schema.builder.DefaultColumnNamingStrategy;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a2314f8d/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
index 25a8457..d28a0b2 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
@@ -33,9 +33,9 @@ import org.apache.metamodel.schema.MutableTable;
 import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.Table;
 import org.apache.metamodel.schema.TableType;
-import org.apache.metamodel.schema.builder.ColumnNamingContextImpl;
-import org.apache.metamodel.schema.builder.ColumnNamingSession;
-import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
+import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.naming.ColumnNamingSession;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 import org.apache.metamodel.util.FileResource;
 import org.apache.metamodel.util.Resource;


[11/42] metamodel git commit: Preparing CHANGES.md for MetaModel 4.5.1 release

Posted by ka...@apache.org.
Preparing CHANGES.md for MetaModel 4.5.1 release

Fixes #87

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/c4f386be
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/c4f386be
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/c4f386be

Branch: refs/heads/5.x
Commit: c4f386be7f34117bdfedd44c1aac63311a413b0d
Parents: 67a0c96
Author: Kasper S�rensen <i....@gmail.com>
Authored: Tue Feb 9 13:39:53 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Tue Feb 9 13:39:53 2016 +0100

----------------------------------------------------------------------
 CHANGES.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4f386be/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 39aa75e..368e0a2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-### Apache MetaModel 4.5.1 (work-in-progress)
+### Apache MetaModel 4.5.1
 
  * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
  * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.


[36/42] metamodel git commit: Merging patch from https://reviews.apache.org/r/46902

Posted by ka...@apache.org.
Merging patch from https://reviews.apache.org/r/46902


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/0af76cc9
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/0af76cc9
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/0af76cc9

Branch: refs/heads/5.x
Commit: 0af76cc9a9311fc5a0fe246224d0c773d5f638b7
Parents: 47c6d56
Author: Tomasz Guzialek <to...@apache.org>
Authored: Mon May 2 22:32:07 2016 +0200
Committer: Tomasz Guzialek <to...@apache.org>
Committed: Mon May 2 22:32:07 2016 +0200

----------------------------------------------------------------------
 .../apache/metamodel/DataContextFactory.java    | 92 ++++++++++++++++++++
 1 file changed, 92 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/0af76cc9/full/src/main/java/org/apache/metamodel/DataContextFactory.java
----------------------------------------------------------------------
diff --git a/full/src/main/java/org/apache/metamodel/DataContextFactory.java b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
index 2b3dae2..0bf3618 100644
--- a/full/src/main/java/org/apache/metamodel/DataContextFactory.java
+++ b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
@@ -24,6 +24,7 @@ import java.net.URL;
 import java.sql.Connection;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 
 import javax.sql.DataSource;
 
@@ -37,10 +38,14 @@ import org.apache.metamodel.excel.ExcelConfiguration;
 import org.apache.metamodel.excel.ExcelDataContext;
 import org.apache.metamodel.fixedwidth.FixedWidthConfiguration;
 import org.apache.metamodel.fixedwidth.FixedWidthDataContext;
+import org.apache.metamodel.hbase.HBaseConfiguration;
+import org.apache.metamodel.hbase.HBaseDataContext;
 import org.apache.metamodel.jdbc.JdbcDataContext;
 import org.apache.metamodel.json.JsonDataContext;
 import org.apache.metamodel.mongodb.mongo3.MongoDbDataContext;
 import org.apache.metamodel.openoffice.OpenOfficeDataContext;
+import org.apache.metamodel.pojo.PojoDataContext;
+import org.apache.metamodel.pojo.TableDataProvider;
 import org.apache.metamodel.salesforce.SalesforceDataContext;
 import org.apache.metamodel.schema.TableType;
 import org.apache.metamodel.sugarcrm.SugarCrmDataContext;
@@ -689,4 +694,91 @@ public class DataContextFactory {
     public static DataContext createCassandraDataContext(Cluster cluster, String keySpaceName) {
         return new CassandraDataContext(cluster, keySpaceName);
     }
+    
+	/**
+	 * Creates a new HBase datacontext.
+	 * 
+	 * @param configuration
+	 *            {@code HBaseConfiguration} object containing detailed HBase
+	 *            configuration properties.
+	 * 
+	 * @return a DataContext object that matches the request
+	 */
+    public static DataContext createHBaseDataContext(HBaseConfiguration configuration){
+    	return new HBaseDataContext(configuration);
+    }
+    
+	/**
+	 * Creates a new HBase datacontext.
+	 * 
+	 * @param configuration
+	 *            {@code HBaseConfiguration} object containing detailed HBase
+	 *            configuration properties.
+	 * 
+	 * @param connection
+	 *            A cluster connection encapsulating lower level individual
+	 *            connections to actual servers and a connection to zookeeper.
+	 * 
+	 * @return a DataContext object that matches the request
+	 */
+	public static DataContext createHBaseDataContext(HBaseConfiguration configuration,org.apache.hadoop.hbase.client.Connection connection) {
+		return new HBaseDataContext(configuration, connection);
+	}
+	
+	/**
+	 * Creates a new POJO data context that is empty but can be populated at
+	 * will.
+	 * 
+	 * @return a DataContext object that matches the request
+	 * 
+	 */
+	public static DataContext createPojoDataContext() {
+		return new PojoDataContext();
+	}
+
+	/**
+	 * Creates a new POJO data context based on the provided
+	 * {@link TableDataProvider}s.
+	 * 
+	 * @param tables
+	 *            list of tables
+	 * 
+	 * @return DataContext object that matches the request
+	 */
+	public static DataContext createPojoDataContext(List<TableDataProvider<?>> tables) {
+		return new PojoDataContext(tables);
+	}
+
+	/**
+	 * Creates a new POJO data context based on the provided
+	 * {@link TableDataProvider}s.
+	 * 
+	 * @param schemaName
+	 *            the name of the created schema
+	 * 
+	 * @param tables
+	 *            table information
+	 * 
+	 * @return DataContext object that matches the request
+	 * 
+	 */
+	public static DataContext createPojoDataContext(String schemaName,TableDataProvider<?>[] tables) {
+		return new PojoDataContext(schemaName, tables);
+	}
+
+	/**
+	 * Creates a new POJO data context based on the provided
+	 * {@link TableDataProvider}s.
+	 * 
+	 * @param schemaName
+	 *            the name of the created schema
+	 * 
+	 * @param tables
+	 *            list of tables
+	 * 
+	 * @return DataContext object that matches the request
+	 */
+	public static DataContext createPojoDataContext(String schemaName,List<TableDataProvider<?>> tables) {
+		return new PojoDataContext(schemaName, tables);
+	}
 }
\ No newline at end of file


[07/42] metamodel git commit: METAMODEL-183: Fixed

Posted by ka...@apache.org.
METAMODEL-183: Fixed

Fixes #86

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/365fae3a
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/365fae3a
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/365fae3a

Branch: refs/heads/5.x
Commit: 365fae3a336bfd7f32ef4b34a8e3b0d50848bc09
Parents: 8e2df82
Author: Xiaomeng Zhao <xi...@gmail.com>
Authored: Sat Jan 23 17:38:58 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Jan 23 17:38:58 2016 +0100

----------------------------------------------------------------------
 full/pom.xml                                    |   7 +-
 .../apache/metamodel/DataContextFactory.java    |  13 +-
 mongodb/common/pom.xml                          |  67 ++
 .../metamodel/mongodb/common/MongoDBUtils.java  |  93 +++
 .../mongodb/common/MongoDbTableDef.java         |  46 ++
 mongodb/mongo2/pom.xml                          |  70 ++
 .../mongo2/DefaultWriteConcernAdvisor.java      |  32 +
 .../mongodb/mongo2/MongoDbDataContext.java      | 528 +++++++++++++++
 .../mongodb/mongo2/MongoDbDataSet.java          |  84 +++
 .../mongodb/mongo2/MongoDbDeleteBuilder.java    |  56 ++
 .../mongodb/mongo2/MongoDbDropTableBuilder.java |  43 ++
 .../mongodb/mongo2/MongoDbInsertionBuilder.java |  64 ++
 .../mongo2/MongoDbTableCreationBuilder.java     |  57 ++
 .../mongodb/mongo2/MongoDbUpdateCallback.java   | 115 ++++
 .../mongo2/SimpleWriteConcernAdvisor.java       |  50 ++
 .../mongodb/mongo2/WriteConcernAdvisor.java     |  35 +
 .../metamodel/mongodb/mongo2/package-info.java  |  23 +
 .../mongodb/mongo2/MongoDbDataContextTest.java  | 635 ++++++++++++++++++
 .../mongodb/mongo2/MongoDbDataCopyer.java       | 124 ++++
 .../mongodb/mongo2/MongoDbTestCase.java         | 111 ++++
 mongodb/mongo3/pom.xml                          |  70 ++
 .../mongo3/DefaultWriteConcernAdvisor.java      |  32 +
 .../mongodb/mongo3/MongoDbDataContext.java      | 556 ++++++++++++++++
 .../mongodb/mongo3/MongoDbDataSet.java          |  84 +++
 .../mongodb/mongo3/MongoDbDeleteBuilder.java    |  53 ++
 .../mongodb/mongo3/MongoDbDropTableBuilder.java |  43 ++
 .../mongodb/mongo3/MongoDbInsertionBuilder.java |  63 ++
 .../mongo3/MongoDbTableCreationBuilder.java     |  57 ++
 .../mongodb/mongo3/MongoDbUpdateCallback.java   | 119 ++++
 .../mongo3/SimpleWriteConcernAdvisor.java       |  51 ++
 .../mongodb/mongo3/WriteConcernAdvisor.java     |  36 ++
 .../metamodel/mongodb/mongo3/package-info.java  |  23 +
 .../mongodb/mongo3/MongoDbDataContextTest.java  | 613 ++++++++++++++++++
 .../mongodb/mongo3/MongoDbDataCopyer.java       | 127 ++++
 .../mongodb/mongo3/MongoDbTestCase.java         | 111 ++++
 mongodb/pom.xml                                 |  43 +-
 .../mongodb/DefaultWriteConcernAdvisor.java     |  32 -
 .../apache/metamodel/mongodb/MongoDBUtils.java  |  77 ---
 .../metamodel/mongodb/MongoDbDataContext.java   | 526 ---------------
 .../metamodel/mongodb/MongoDbDataSet.java       |  83 ---
 .../metamodel/mongodb/MongoDbDeleteBuilder.java |  56 --
 .../mongodb/MongoDbDropTableBuilder.java        |  43 --
 .../mongodb/MongoDbInsertionBuilder.java        |  64 --
 .../mongodb/MongoDbTableCreationBuilder.java    |  57 --
 .../metamodel/mongodb/MongoDbTableDef.java      |  46 --
 .../mongodb/MongoDbUpdateCallback.java          | 115 ----
 .../mongodb/SimpleWriteConcernAdvisor.java      |  50 --
 .../metamodel/mongodb/WriteConcernAdvisor.java  |  35 -
 .../apache/metamodel/mongodb/package-info.java  |  23 -
 .../mongodb/MongoDbDataContextTest.java         | 636 -------------------
 .../metamodel/mongodb/MongoDbDataCopyer.java    | 124 ----
 .../metamodel/mongodb/MongoDbTestCase.java      | 111 ----
 .../MongoDbDataContextFactoryBeanDelegate.java  |   2 +-
 53 files changed, 4292 insertions(+), 2122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 4738093..3602e45 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -181,8 +181,13 @@ under the License.
 			<version>${project.version}</version>
 		</dependency>
 		<dependency>
+            <groupId>org.apache.metamodel</groupId>
+            <artifactId>MetaModel-mongodb-mongo3</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+		<dependency>
 			<groupId>org.apache.metamodel</groupId>
-			<artifactId>MetaModel-mongodb</artifactId>
+			<artifactId>MetaModel-mongodb-mongo2</artifactId>
 			<version>${project.version}</version>
 		</dependency>
 		<dependency>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/full/src/main/java/org/apache/metamodel/DataContextFactory.java
----------------------------------------------------------------------
diff --git a/full/src/main/java/org/apache/metamodel/DataContextFactory.java b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
index 37776e9..2b3dae2 100644
--- a/full/src/main/java/org/apache/metamodel/DataContextFactory.java
+++ b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
@@ -39,7 +39,7 @@ import org.apache.metamodel.fixedwidth.FixedWidthConfiguration;
 import org.apache.metamodel.fixedwidth.FixedWidthDataContext;
 import org.apache.metamodel.jdbc.JdbcDataContext;
 import org.apache.metamodel.json.JsonDataContext;
-import org.apache.metamodel.mongodb.MongoDbDataContext;
+import org.apache.metamodel.mongodb.mongo3.MongoDbDataContext;
 import org.apache.metamodel.openoffice.OpenOfficeDataContext;
 import org.apache.metamodel.salesforce.SalesforceDataContext;
 import org.apache.metamodel.schema.TableType;
@@ -53,10 +53,10 @@ import org.xml.sax.InputSource;
 
 import com.datastax.driver.core.Cluster;
 import com.google.common.base.Strings;
-import com.mongodb.DB;
 import com.mongodb.MongoClient;
 import com.mongodb.MongoCredential;
 import com.mongodb.ServerAddress;
+import com.mongodb.client.MongoDatabase;
 
 import io.searchbox.client.JestClient;
 
@@ -547,14 +547,15 @@ public class DataContextFactory {
             } else {
                 serverAddress = new ServerAddress(hostname, port);
             }
-
-            final DB mongoDb;
+            MongoClient mongoClient = null;
+            final MongoDatabase mongoDb;
             if (Strings.isNullOrEmpty(username)) {
-                mongoDb = new MongoClient(serverAddress).getDB(databaseName);
+                mongoClient = new MongoClient(serverAddress);
             } else {
                 final MongoCredential credential = MongoCredential.createCredential(username, databaseName, password);
-                mongoDb = new MongoClient(serverAddress, Arrays.asList(credential)).getDB(databaseName);
+                mongoClient = new MongoClient(serverAddress, Arrays.asList(credential));
             }
+            mongoDb = mongoClient.getDatabase(databaseName);
 
             if (tableDefs == null || tableDefs.length == 0) {
                 return new MongoDbDataContext(mongoDb);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
new file mode 100644
index 0000000..2ef9d14
--- /dev/null
+++ b/mongodb/common/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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
+
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<artifactId>MetaModel-mongodb</artifactId>
+		<groupId>org.apache.metamodel</groupId>
+		<version>4.5.1-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>MetaModel-mongodb-common</artifactId>
+	<name>MetaModel module for MongoDB commons</name>
+	
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-core</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>3.1.0</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<!-- Test dependencies -->
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-jdbc</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.derby</groupId>
+			<artifactId>derby</artifactId>
+			<version>10.8.1.2</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-nop</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
----------------------------------------------------------------------
diff --git a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
new file mode 100644
index 0000000..f7a5729
--- /dev/null
+++ b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.common;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.metamodel.data.DataSetHeader;
+import org.apache.metamodel.data.DefaultRow;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.util.CollectionUtils;
+
+import com.mongodb.DBObject;
+
+/**
+ * A utility class for MongoDB module.
+ */
+public class MongoDBUtils {
+
+    /**
+     * Converts a MongoDB data object {@link DBObject} into MetaModel
+     * {@link Row}.
+     * 
+     * @param dbObject
+     *            a MongoDB object storing data.
+     * @param header
+     *            a header describing the columns of the data stored.
+     * @return the MetaModel {@link Row} result object.
+     */
+    public static Row toRow(DBObject dbObject, DataSetHeader header) {
+        if (dbObject == null) {
+            return null;
+        }
+
+        final Map<?,?> map = dbObject.toMap();
+        return toRow(map, header);
+    }
+    
+    /**
+     * Converts a map into MetaModel. This map stores data of a MongoDB document.
+     * 
+     * @param dbObject
+     *            a map object storing data of a MongoDB document.
+     * @param header
+     *            a header describing the columns of the data stored.
+     * @return the MetaModel {@link Row} result object.
+     */
+    public static Row toRow(Map<?,?> map, DataSetHeader header) {
+        if (map == null) {
+            return null;
+        }
+
+        final int size = header.size();
+        final Object[] values = new Object[size];
+        for (int i = 0; i < values.length; i++) {
+            final SelectItem selectItem = header.getSelectItem(i);
+            final String key = selectItem.getColumn().getName();
+            final Object value = CollectionUtils.find(map, key);
+            values[i] = toValue(selectItem.getColumn(), value);
+        }
+        return new DefaultRow(header, values);
+    }
+
+    private static Object toValue(Column column, Object value) {
+        if (value instanceof List) {
+            return value;
+        }
+        if (value instanceof DBObject) {
+            DBObject basicDBObject = (DBObject) value;
+            return basicDBObject.toMap();
+        }
+        return value;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
----------------------------------------------------------------------
diff --git a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
new file mode 100644
index 0000000..9bb6174
--- /dev/null
+++ b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.common;
+
+import java.io.Serializable;
+
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.util.SimpleTableDef;
+
+/**
+ * Defines a table layout for {@link MongoDbDataContext} tables. This class can
+ * be used as an instruction set for the {@link MongoDbDataContext} to specify
+ * which collections, which columns (and their types) should be included in the
+ * schema structure of a Mongo DB database.
+ * 
+ * @deprecated use {@link SimpleTableDef} instead.
+ */
+@Deprecated
+public final class MongoDbTableDef extends SimpleTableDef implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    public MongoDbTableDef(String name, String[] columnNames, ColumnType[] columnTypes) {
+        super(name, columnNames, columnTypes);
+    }
+
+    public MongoDbTableDef(String name, String[] columnNames) {
+        super(name, columnNames);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
new file mode 100644
index 0000000..24b1bca
--- /dev/null
+++ b/mongodb/mongo2/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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
+
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<artifactId>MetaModel-mongodb</artifactId>
+		<groupId>org.apache.metamodel</groupId>
+		<version>4.5.1-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>MetaModel-mongodb-mongo2</artifactId>
+	<name>MetaModel module for MongoDB databases under version 3</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-core</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+            <groupId>org.apache.metamodel</groupId>
+            <artifactId>MetaModel-mongodb-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>2.14.0</version>
+		</dependency>
+
+		<!-- Test dependencies -->
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-jdbc</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.derby</groupId>
+			<artifactId>derby</artifactId>
+			<version>10.8.1.2</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-nop</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/DefaultWriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/DefaultWriteConcernAdvisor.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/DefaultWriteConcernAdvisor.java
new file mode 100644
index 0000000..4f87a34
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/DefaultWriteConcernAdvisor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import com.mongodb.WriteConcern;
+
+/**
+ * Default {@link WriteConcernAdvisor}. Always returns
+ * {@link WriteConcern#NORMAL}.
+ */
+public class DefaultWriteConcernAdvisor extends SimpleWriteConcernAdvisor {
+
+    public DefaultWriteConcernAdvisor() {
+        super(WriteConcern.NORMAL);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
new file mode 100644
index 0000000..cfeb836
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
@@ -0,0 +1,528 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.QueryPostprocessDataContext;
+import org.apache.metamodel.UpdateScript;
+import org.apache.metamodel.UpdateableDataContext;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.DataSetHeader;
+import org.apache.metamodel.data.InMemoryDataSet;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.data.SimpleDataSetHeader;
+import org.apache.metamodel.mongodb.common.MongoDBUtils;
+import org.apache.metamodel.mongodb.common.MongoDbTableDef;
+import org.apache.metamodel.query.FilterItem;
+import org.apache.metamodel.query.FromItem;
+import org.apache.metamodel.query.OperatorType;
+import org.apache.metamodel.query.Query;
+import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.ColumnTypeImpl;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.SimpleTableDef;
+import org.bson.types.ObjectId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.BasicDBList;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.WriteConcern;
+
+/**
+ * DataContext implementation for MongoDB.
+ *
+ * Since MongoDB has no schema, a virtual schema will be used in this
+ * DataContext. This implementation supports either automatic discovery of a
+ * schema or manual specification of a schema, through the
+ * {@link MongoDbTableDef} class.
+ */
+public class MongoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
+
+    private final DB _mongoDb;
+    private final SimpleTableDef[] _tableDefs;
+    private WriteConcernAdvisor _writeConcernAdvisor;
+    private Schema _schema;
+
+    /**
+     * Constructor available for backwards compatibility
+     *
+     * @deprecated use {@link #MongoDbDataContext(DB, SimpleTableDef...)}
+     *             instead
+     */
+    @Deprecated
+    public MongoDbDataContext(DB mongoDb, MongoDbTableDef... tableDefs) {
+        this(mongoDb, (SimpleTableDef[]) tableDefs);
+    }
+
+    /**
+     * Constructs a {@link MongoDbDataContext}. This constructor accepts a
+     * custom array of {@link MongoDbTableDef}s which allows the user to define
+     * his own view on the collections in the database.
+     *
+     * @param mongoDb
+     *            the mongo db connection
+     * @param tableDefs
+     *            an array of {@link MongoDbTableDef}s, which define the table
+     *            and column model of the mongo db collections. (consider using
+     *            {@link #detectSchema(DB)} or {@link #detectTable(DB, String)}
+     *            ).
+     */
+    public MongoDbDataContext(DB mongoDb, SimpleTableDef... tableDefs) {
+        _mongoDb = mongoDb;
+        _tableDefs = tableDefs;
+        _schema = null;
+    }
+
+    /**
+     * Constructs a {@link MongoDbDataContext} and automatically detects the
+     * schema structure/view on all collections (see {@link #detectSchema(DB)}).
+     *
+     * @param mongoDb
+     *            the mongo db connection
+     */
+    public MongoDbDataContext(DB mongoDb) {
+        this(mongoDb, detectSchema(mongoDb));
+    }
+
+    /**
+     * Performs an analysis of the available collections in a Mongo {@link DB}
+     * instance and tries to detect the table's structure based on the first
+     * 1000 documents in each collection.
+     *
+     * @param db
+     *            the mongo db to inspect
+     * @return a mutable schema instance, useful for further fine tuning by the
+     *         user.
+     * @see #detectTable(DB, String)
+     */
+    public static SimpleTableDef[] detectSchema(DB db) {
+        Set<String> collectionNames = db.getCollectionNames();
+        SimpleTableDef[] result = new SimpleTableDef[collectionNames.size()];
+        int i = 0;
+        for (String collectionName : collectionNames) {
+            SimpleTableDef table = detectTable(db, collectionName);
+            result[i] = table;
+            i++;
+        }
+        return result;
+    }
+
+    /**
+     * Performs an analysis of an available collection in a Mongo {@link DB}
+     * instance and tries to detect the table structure based on the first 1000
+     * documents in the collection.
+     *
+     * @param db
+     *            the mongo DB
+     * @param collectionName
+     *            the name of the collection
+     * @return a table definition for mongo db.
+     */
+    public static SimpleTableDef detectTable(DB db, String collectionName) {
+        final DBCollection collection = db.getCollection(collectionName);
+        final DBCursor cursor = collection.find().limit(1000);
+
+        final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
+        while (cursor.hasNext()) {
+            DBObject object = cursor.next();
+            Set<String> keysInObject = object.keySet();
+            for (String key : keysInObject) {
+                Set<Class<?>> types = columnsAndTypes.get(key);
+                if (types == null) {
+                    types = new HashSet<Class<?>>();
+                    columnsAndTypes.put(key, types);
+                }
+                Object value = object.get(key);
+                if (value != null) {
+                    types.add(value.getClass());
+                }
+            }
+        }
+        cursor.close();
+
+        final String[] columnNames = new String[columnsAndTypes.size()];
+        final ColumnType[] columnTypes = new ColumnType[columnsAndTypes.size()];
+
+        int i = 0;
+        for (Entry<String, Set<Class<?>>> columnAndTypes : columnsAndTypes.entrySet()) {
+            final String columnName = columnAndTypes.getKey();
+            final Set<Class<?>> columnTypeSet = columnAndTypes.getValue();
+            final Class<?> columnType;
+            if (columnTypeSet.size() == 1) {
+                columnType = columnTypeSet.iterator().next();
+            } else {
+                columnType = Object.class;
+            }
+            columnNames[i] = columnName;
+            if (columnType == ObjectId.class) {
+                columnTypes[i] = ColumnType.ROWID;
+            } else {
+                columnTypes[i] = ColumnTypeImpl.convertColumnType(columnType);
+            }
+            i++;
+        }
+
+        return new SimpleTableDef(collectionName, columnNames, columnTypes);
+    }
+
+    @Override
+    protected Schema getMainSchema() throws MetaModelException {
+        if (_schema == null) {
+            MutableSchema schema = new MutableSchema(getMainSchemaName());
+            for (SimpleTableDef tableDef : _tableDefs) {
+
+                MutableTable table = tableDef.toTable().setSchema(schema);
+                Column[] rowIdColumns = table.getColumnsOfType(ColumnType.ROWID);
+                for (Column column : rowIdColumns) {
+                    if (column instanceof MutableColumn) {
+                        ((MutableColumn) column).setPrimaryKey(true);
+                    }
+                }
+
+                schema.addTable(table);
+            }
+
+            _schema = schema;
+        }
+        return _schema;
+    }
+
+    @Override
+    protected String getMainSchemaName() throws MetaModelException {
+        return _mongoDb.getName();
+    }
+
+    @Override
+    protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
+        final DBCollection collection = _mongoDb.getCollection(table.getName());
+
+        final DBObject query = createMongoDbQuery(table, whereItems);
+
+        logger.info("Executing MongoDB 'count' query: {}", query);
+        final long count = collection.count(query);
+
+        return count;
+    }
+
+    @Override
+    protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
+            Object keyValue) {
+        final DBCollection collection = _mongoDb.getCollection(table.getName());
+
+        List<FilterItem> whereItems = new ArrayList<FilterItem>();
+        SelectItem selectItem = new SelectItem(primaryKeyColumn);
+        FilterItem primaryKeyWhereItem = new FilterItem(selectItem, OperatorType.EQUALS_TO, keyValue);
+        whereItems.add(primaryKeyWhereItem);
+        final DBObject query = createMongoDbQuery(table, whereItems);
+        final DBObject resultDBObject = collection.findOne(query);
+
+        DataSetHeader header = new SimpleDataSetHeader(selectItems);
+
+        Row row = MongoDBUtils.toRow(resultDBObject, header);
+
+        return row;
+    }
+
+    @Override
+    public DataSet executeQuery(Query query) {
+        // Check for queries containing only simple selects and where clauses,
+        // or if it is a COUNT(*) query.
+
+        // if from clause only contains a main schema table
+        List<FromItem> fromItems = query.getFromClause().getItems();
+        if (fromItems.size() == 1 && fromItems.get(0).getTable() != null
+                && fromItems.get(0).getTable().getSchema() == _schema) {
+            final Table table = fromItems.get(0).getTable();
+
+            // if GROUP BY, HAVING and ORDER BY clauses are not specified
+            if (query.getGroupByClause().isEmpty() && query.getHavingClause().isEmpty()
+                    && query.getOrderByClause().isEmpty()) {
+
+                final List<FilterItem> whereItems = query.getWhereClause().getItems();
+
+                // if all of the select items are "pure" column selection
+                boolean allSelectItemsAreColumns = true;
+                List<SelectItem> selectItems = query.getSelectClause().getItems();
+
+                // if it is a
+                // "SELECT [columns] FROM [table] WHERE [conditions]"
+                // query.
+                for (SelectItem selectItem : selectItems) {
+                    if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
+                        allSelectItemsAreColumns = false;
+                        break;
+                    }
+                }
+
+                if (allSelectItemsAreColumns) {
+                    logger.debug("Query can be expressed in full MongoDB, no post processing needed.");
+
+                    // prepare for a non-post-processed query
+                    Column[] columns = new Column[selectItems.size()];
+                    for (int i = 0; i < columns.length; i++) {
+                        columns[i] = selectItems.get(i).getColumn();
+                    }
+
+                    // checking if the query is a primary key lookup query
+                    if (whereItems.size() == 1) {
+                        final FilterItem whereItem = whereItems.get(0);
+                        final SelectItem selectItem = whereItem.getSelectItem();
+                        if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
+                            final Column column = selectItem.getColumn();
+                            if (column.isPrimaryKey() && OperatorType.EQUALS_TO.equals(whereItem.getOperator())) {
+                                logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
+                                final Object operand = whereItem.getOperand();
+                                final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
+                                if (row == null) {
+                                    logger.debug("DataContext did not return any primary key lookup query results. Proceeding "
+                                            + "with manual lookup.");
+                                } else {
+                                    final DataSetHeader header = new SimpleDataSetHeader(selectItems);
+                                    return new InMemoryDataSet(header, row);
+                                }
+                            }
+                        }
+                    }
+
+                    int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
+                    int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
+
+                    final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                            maxRows, false);
+                    return dataSet;
+                }
+            }
+        }
+
+        logger.debug("Query will be simplified for MongoDB and post processed.");
+        return super.executeQuery(query);
+    }
+
+    private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
+            int firstRow, int maxRows, boolean queryPostProcessed) {
+        final DBCollection collection = _mongoDb.getCollection(table.getName());
+
+        final DBObject query = createMongoDbQuery(table, whereItems);
+
+        logger.info("Executing MongoDB 'find' query: {}", query);
+        DBCursor cursor = collection.find(query);
+
+        if (maxRows > 0) {
+            cursor = cursor.limit(maxRows);
+        }
+        if (firstRow > 1) {
+            final int skip = firstRow - 1;
+            cursor = cursor.skip(skip);
+        }
+
+        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+    }
+
+    protected BasicDBObject createMongoDbQuery(Table table, List<FilterItem> whereItems) {
+        assert _schema == table.getSchema();
+
+        final BasicDBObject query = new BasicDBObject();
+        if (whereItems != null && !whereItems.isEmpty()) {
+            for (FilterItem item : whereItems) {
+                convertToCursorObject(query, item);
+            }
+        }
+
+        return query;
+    }
+
+    private void convertToCursorObject(BasicDBObject query, FilterItem item) {
+        if (item.isCompoundFilter()) {
+
+            BasicDBList orList = new BasicDBList();
+
+            final FilterItem[] childItems = item.getChildItems();
+            for (FilterItem childItem : childItems) {
+                BasicDBObject childObject = new BasicDBObject();
+                convertToCursorObject(childObject, childItem);
+                orList.add(childObject);
+            }
+
+            query.put("$or", orList);
+
+        } else {
+
+            final Column column = item.getSelectItem().getColumn();
+            final String columnName = column.getName();
+            final String operatorName = getOperatorName(item);
+
+            Object operand = item.getOperand();
+            if (ObjectId.isValid(String.valueOf(operand))) {
+                operand = new ObjectId(String.valueOf(operand));
+            }
+
+            final BasicDBObject existingFilterObject = (BasicDBObject) query.get(columnName);
+            if (existingFilterObject == null) {
+                if (operatorName == null) {
+                    if (OperatorType.LIKE.equals(item.getOperator())) {
+                        query.put(columnName, turnOperandIntoRegExp(operand));
+                    } else {
+                        query.put(columnName, operand);
+                    }
+                } else {
+                    query.put(columnName, new BasicDBObject(operatorName, operand));
+                }
+            } else {
+                if (operatorName == null) {
+                    throw new IllegalStateException("Cannot retrieve records for a column with two EQUALS_TO operators");
+                } else {
+                    existingFilterObject.append(operatorName, operand);
+                }
+            }
+        }
+    }
+
+    private String getOperatorName(FilterItem item) {
+        final OperatorType operator = item.getOperator();
+
+        if (OperatorType.EQUALS_TO.equals(operator)) {
+            return null;
+        }
+        if (OperatorType.LIKE.equals(operator)) {
+            return null;
+        }
+        if (OperatorType.LESS_THAN.equals(operator)) {
+            return "$lt";
+        }
+        if (OperatorType.LESS_THAN_OR_EQUAL.equals(operator)) {
+            return "$lte";
+        }
+        if (OperatorType.GREATER_THAN.equals(operator)) {
+            return "$gt";
+        }
+        if (OperatorType.GREATER_THAN_OR_EQUAL.equals(operator)) {
+            return "$gte";
+        }
+        if (OperatorType.DIFFERENT_FROM.equals(operator)) {
+            return "$ne";
+        }
+        if (OperatorType.IN.equals(operator)) {
+            return "$in";
+        }
+
+        throw new IllegalStateException("Unsupported operator type: " + operator);
+    }
+
+    private Pattern turnOperandIntoRegExp(Object operand) {
+        StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operand.toString()));
+        operandAsRegExp.insert(0, "^").append("$");
+        return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE);
+    }
+
+    private String replaceWildCardLikeChars(String operand) {
+        return operand.replaceAll("%", ".*");
+    }
+
+    @Override
+    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
+        return materializeMainSchemaTableInternal(table, columns, null, 1, maxRows, true);
+    }
+
+    @Override
+    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows) {
+        return materializeMainSchemaTableInternal(table, columns, null, firstRow, maxRows, true);
+    }
+
+    /**
+     * Executes an update with a specific {@link WriteConcernAdvisor}.
+     */
+    public void executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
+        MongoDbUpdateCallback callback = new MongoDbUpdateCallback(this, writeConcernAdvisor);
+        try {
+            update.run(callback);
+        } finally {
+            callback.close();
+        }
+    }
+
+    /**
+     * Executes an update with a specific {@link WriteConcern}.
+     */
+    public void executeUpdate(UpdateScript update, WriteConcern writeConcern) {
+        executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
+    }
+
+    @Override
+    public void executeUpdate(UpdateScript update) {
+        executeUpdate(update, getWriteConcernAdvisor());
+    }
+
+    /**
+     * Gets the {@link WriteConcernAdvisor} to use on
+     * {@link #executeUpdate(UpdateScript)} calls.
+     */
+    public WriteConcernAdvisor getWriteConcernAdvisor() {
+        if (_writeConcernAdvisor == null) {
+            return new DefaultWriteConcernAdvisor();
+        }
+        return _writeConcernAdvisor;
+    }
+
+    /**
+     * Sets a global {@link WriteConcern} advisor to use on
+     * {@link #executeUpdate(UpdateScript)}.
+     */
+    public void setWriteConcernAdvisor(WriteConcernAdvisor writeConcernAdvisor) {
+        _writeConcernAdvisor = writeConcernAdvisor;
+    }
+
+    /**
+     * Gets the {@link DB} instance that this {@link DataContext} is backed by.
+     */
+    public DB getMongoDb() {
+        return _mongoDb;
+    }
+
+    protected void addTable(MutableTable table) {
+        if (_schema instanceof MutableSchema) {
+            MutableSchema mutableSchema = (MutableSchema) _schema;
+            mutableSchema.addTable(table);
+        } else {
+            throw new UnsupportedOperationException("Schema is not mutable");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
new file mode 100644
index 0000000..8c2a107
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import org.apache.metamodel.data.AbstractDataSet;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.mongodb.common.MongoDBUtils;
+import org.apache.metamodel.schema.Column;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+final class MongoDbDataSet extends AbstractDataSet {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
+
+    private final DBCursor _cursor;
+    private final boolean _queryPostProcessed;
+
+    private boolean _closed;
+    private volatile DBObject _dbObject;
+
+    public MongoDbDataSet(DBCursor cursor, Column[] columns, boolean queryPostProcessed) {
+        super(columns);
+        _cursor = cursor;
+        _queryPostProcessed = queryPostProcessed;
+        _closed = false;
+    }
+
+    public boolean isQueryPostProcessed() {
+        return _queryPostProcessed;
+    }
+
+    @Override
+    public void close() {
+        super.close();
+        _cursor.close();
+        _closed = true;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+        if (!_closed) {
+            logger.warn("finalize() invoked, but DataSet is not closed. Invoking close() on {}", this);
+            close();
+        }
+    }
+
+    @Override
+    public boolean next() {
+        if (_cursor.hasNext()) {
+            _dbObject = _cursor.next();
+            return true;
+        } else {
+            _dbObject = null;
+            return false;
+        }
+    }
+
+    @Override
+    public Row getRow() {
+        return MongoDBUtils.toRow(_dbObject, getHeader());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDeleteBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDeleteBuilder.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDeleteBuilder.java
new file mode 100644
index 0000000..2ee1977
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDeleteBuilder.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.delete.AbstractRowDeletionBuilder;
+import org.apache.metamodel.schema.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.WriteConcern;
+import com.mongodb.WriteResult;
+
+final class MongoDbDeleteBuilder extends AbstractRowDeletionBuilder {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbDeleteBuilder.class);
+
+    private final MongoDbUpdateCallback _updateCallback;
+
+    public MongoDbDeleteBuilder(MongoDbUpdateCallback updateCallback, Table table) {
+        super(table);
+        _updateCallback = updateCallback;
+    }
+
+    @Override
+    public void execute() throws MetaModelException {
+        final DBCollection collection = _updateCallback.getCollection(getTable().getName());
+
+        final MongoDbDataContext dataContext = _updateCallback.getDataContext();
+        final BasicDBObject query = dataContext.createMongoDbQuery(getTable(), getWhereItems());
+        
+        WriteConcern writeConcern = _updateCallback.getWriteConcernAdvisor().adviceDeleteQuery(collection, query);
+        
+        final WriteResult writeResult = collection.remove(query, writeConcern);
+        logger.info("Remove returned result: {}", writeResult);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDropTableBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDropTableBuilder.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDropTableBuilder.java
new file mode 100644
index 0000000..a9f8d0c
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDropTableBuilder.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.drop.AbstractTableDropBuilder;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.Table;
+
+final class MongoDbDropTableBuilder extends AbstractTableDropBuilder {
+
+    private final MongoDbUpdateCallback _updateCallback;
+
+    public MongoDbDropTableBuilder(MongoDbUpdateCallback updateCallback, Table table) {
+        super(table);
+        _updateCallback = updateCallback;
+    }
+
+    @Override
+    public void execute() throws MetaModelException {
+        Table table = getTable();
+        _updateCallback.removeCollection(table.getName());
+        MutableSchema schema = (MutableSchema) table.getSchema();
+        schema.removeTable(table);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbInsertionBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbInsertionBuilder.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbInsertionBuilder.java
new file mode 100644
index 0000000..d9cd583
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbInsertionBuilder.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.insert.AbstractRowInsertionBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Table;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.WriteConcern;
+import com.mongodb.WriteResult;
+
+final class MongoDbInsertionBuilder extends AbstractRowInsertionBuilder<MongoDbUpdateCallback> implements RowInsertionBuilder {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbInsertionBuilder.class);
+
+    public MongoDbInsertionBuilder(MongoDbUpdateCallback updateCallback, Table table) {
+        super(updateCallback, table);
+    }
+
+    @Override
+    public void execute() throws MetaModelException {
+        final Column[] columns = getColumns();
+        final Object[] values = getValues();
+
+        final BasicDBObject doc = new BasicDBObject();
+
+        for (int i = 0; i < values.length; i++) {
+            Object value = values[i];
+            if (value != null) {
+                doc.put(columns[i].getName(), value);
+            }
+        }
+
+        final MongoDbUpdateCallback updateCallback = getUpdateCallback();
+        final DBCollection collection = updateCallback.getCollection(getTable().getName());
+
+        final WriteConcern writeConcern = updateCallback.getWriteConcernAdvisor().adviceInsert(collection, doc);
+
+        final WriteResult writeResult = collection.insert(doc, writeConcern);
+        logger.info("Insert returned result: {}", writeResult);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbTableCreationBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbTableCreationBuilder.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbTableCreationBuilder.java
new file mode 100644
index 0000000..c93acf1
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbTableCreationBuilder.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.create.AbstractTableCreationBuilder;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.ImmutableColumn;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+
+final class MongoDbTableCreationBuilder extends
+		AbstractTableCreationBuilder<MongoDbUpdateCallback> implements
+		TableCreationBuilder {
+
+	public MongoDbTableCreationBuilder(MongoDbUpdateCallback updateCallback,
+			Schema schema, String name) {
+		super(updateCallback, schema, name);
+	}
+
+	@Override
+	public Table execute() throws MetaModelException {
+		final MongoDbDataContext dataContext = getUpdateCallback()
+				.getDataContext();
+		final Schema schema = dataContext.getDefaultSchema();
+		final MutableTable table = getTable();
+		if (table.getColumnByName("_id") == null) {
+			// all mongo db collections have an _id field as the first field.
+			ImmutableColumn idColumn = new ImmutableColumn("_id",
+					ColumnType.ROWID, table, table.getColumnCount(), null,
+					null, null, null, true, null, true);
+			table.addColumn(idColumn);
+		}
+		table.setSchema(schema);
+		getUpdateCallback().createCollection(table.getName());
+		dataContext.addTable(table);
+		return table;
+	}
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbUpdateCallback.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbUpdateCallback.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbUpdateCallback.java
new file mode 100644
index 0000000..046f20c
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbUpdateCallback.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import java.io.Closeable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.metamodel.AbstractUpdateCallback;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.delete.RowDeletionBuilder;
+import org.apache.metamodel.drop.TableDropBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+
+final class MongoDbUpdateCallback extends AbstractUpdateCallback implements UpdateCallback, Closeable {
+
+    private final MongoDbDataContext _dataContext;
+    private final Map<String, DBCollection> _collections;
+    private final WriteConcernAdvisor _writeConcernAdvisor;
+
+    public MongoDbUpdateCallback(MongoDbDataContext dataContext, WriteConcernAdvisor writeConcernAdvisor) {
+        super(dataContext);
+        _dataContext = dataContext;
+        _writeConcernAdvisor = writeConcernAdvisor;
+        _collections = new HashMap<String, DBCollection>();
+    }
+
+    @Override
+    public MongoDbDataContext getDataContext() {
+        return _dataContext;
+    }
+    
+    public WriteConcernAdvisor getWriteConcernAdvisor() {
+        return _writeConcernAdvisor;
+    }
+
+    @Override
+    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
+            IllegalStateException {
+        return new MongoDbTableCreationBuilder(this, schema, name);
+    }
+
+    @Override
+    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException {
+        return new MongoDbInsertionBuilder(this, table);
+    }
+
+    protected void createCollection(String name) {
+        DBCollection collection = _dataContext.getMongoDb().createCollection(name, new BasicDBObject());
+        _collections.put(name, collection);
+    }
+
+    protected void removeCollection(String name) {
+        DBCollection collection = getCollection(name);
+        _collections.remove(name);
+        collection.drop();
+    }
+
+    protected DBCollection getCollection(String name) {
+        DBCollection collection = _collections.get(name);
+        if (collection == null) {
+            collection = _dataContext.getMongoDb().getCollection(name);
+            _collections.put(name, collection);
+        }
+        return collection;
+    }
+
+    @Override
+    public void close() {
+        _collections.clear();
+    }
+
+    @Override
+    public boolean isDropTableSupported() {
+        return true;
+    }
+
+    @Override
+    public TableDropBuilder dropTable(Table table) throws UnsupportedOperationException {
+        return new MongoDbDropTableBuilder(this, table);
+    }
+
+    @Override
+    public boolean isDeleteSupported() {
+        return true;
+    }
+
+    @Override
+    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new MongoDbDeleteBuilder(this, table);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/SimpleWriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/SimpleWriteConcernAdvisor.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/SimpleWriteConcernAdvisor.java
new file mode 100644
index 0000000..2854615
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/SimpleWriteConcernAdvisor.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.WriteConcern;
+
+/**
+ * A simple {@link WriteConcernAdvisor} that always returns the same write
+ * concern.
+ */
+public class SimpleWriteConcernAdvisor implements WriteConcernAdvisor {
+
+    private final WriteConcern _writeConcern;
+
+    public SimpleWriteConcernAdvisor(WriteConcern writeConcern) {
+        if (writeConcern == null) {
+            throw new IllegalArgumentException("WriteConcern cannot be null");
+        }
+        _writeConcern = writeConcern;
+    }
+
+    @Override
+    public WriteConcern adviceDeleteQuery(DBCollection collection, BasicDBObject query) {
+        return _writeConcern;
+    }
+
+    @Override
+    public WriteConcern adviceInsert(DBCollection collection, BasicDBObject document) {
+        return _writeConcern;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/WriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/WriteConcernAdvisor.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/WriteConcernAdvisor.java
new file mode 100644
index 0000000..a9a89e9
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/WriteConcernAdvisor.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.WriteConcern;
+
+/**
+ * Interface for component that advices MetaModel on which {@link WriteConcern}
+ * to apply to given operations
+ */
+public interface WriteConcernAdvisor {
+
+    public WriteConcern adviceDeleteQuery(DBCollection collection, BasicDBObject query);
+
+    public WriteConcern adviceInsert(DBCollection collection, BasicDBObject document);
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/package-info.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/package-info.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/package-info.java
new file mode 100644
index 0000000..b6ffb14
--- /dev/null
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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.
+ */
+/**
+ * Module package for MongoDB support
+ */
+package org.apache.metamodel.mongodb.mongo2;
+


[34/42] metamodel git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/metamodel.git

Posted by ka...@apache.org.
Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/metamodel.git

Conflicts:
	CHANGES.md

Closes #96

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/025d07f0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/025d07f0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/025d07f0

Branch: refs/heads/5.x
Commit: 025d07f00cc54d63a7edf5cc41187a88b8ab3a81
Parents: cca0cba bf439b4
Author: kaspersorensen <i....@gmail.com>
Authored: Tue Apr 26 12:47:08 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Apr 26 12:47:08 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                                         | 1 +
 .../metamodel/util/LegacyDeserializationObjectInputStream.java     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/025d07f0/CHANGES.md
----------------------------------------------------------------------
diff --cc CHANGES.md
index ee40ff0,546f31c..4356071
--- a/CHANGES.md
+++ b/CHANGES.md
@@@ -2,7 -2,7 +2,8 @@@
  
   * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
   * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
 + * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
+  * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
  
  ### Apache MetaModel 4.5.2
  


[29/42] metamodel git commit: METAMODEL-242: Fixed

Posted by ka...@apache.org.
METAMODEL-242: Fixed

Closes #93

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/bf439b44
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/bf439b44
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/bf439b44

Branch: refs/heads/5.x
Commit: bf439b44d03e6cc6b78b95504cc429c48f1e023e
Parents: 820b1f2
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Apr 24 13:56:57 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Apr 24 13:56:57 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                                         | 1 +
 .../metamodel/util/LegacyDeserializationObjectInputStream.java     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/bf439b44/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 9be1b35..546f31c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
 
  * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
  * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
+ * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
 
 ### Apache MetaModel 4.5.2
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/bf439b44/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java b/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
index 289f823..c4d4570 100644
--- a/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
+++ b/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
@@ -235,7 +235,7 @@ public class LegacyDeserializationObjectInputStream extends ObjectInputStream {
             break;
         case CLASS_NAME_FUNCTION_TYPE:
             if (isEnumExpected(objectStreamClass)) {
-                final ObjectStreamClass legacyOperatorTypeResult = ObjectStreamClass.lookup(LegacyOperatorType.class);
+                final ObjectStreamClass legacyOperatorTypeResult = ObjectStreamClass.lookup(LegacyFunctionType.class);
                 return legacyOperatorTypeResult;
             }
             break;


[33/42] metamodel git commit: Updated CHANGES.md

Posted by ka...@apache.org.
Updated CHANGES.md

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/cca0cba4
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/cca0cba4
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/cca0cba4

Branch: refs/heads/5.x
Commit: cca0cba47b5457ac40797ac38b6520255d9c9e19
Parents: 4107590
Author: kaspersorensen <i....@gmail.com>
Authored: Tue Apr 26 12:45:07 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Apr 26 12:45:07 2016 -0700

----------------------------------------------------------------------
 CHANGES.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/cca0cba4/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 9be1b35..ee40ff0 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
 
  * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
  * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
+ * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
 
 ### Apache MetaModel 4.5.2
 


[31/42] metamodel git commit: Removed DefaultColumnNamingStrategy in favor of a factory method

Posted by ka...@apache.org.
Removed DefaultColumnNamingStrategy in favor of a factory method

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/c1e1d52f
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/c1e1d52f
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/c1e1d52f

Branch: refs/heads/5.x
Commit: c1e1d52f9517f2a60c7d04033445517abbda0bbc
Parents: 28cd2cd
Author: kaspersorensen <i....@gmail.com>
Authored: Tue Apr 26 12:08:47 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Apr 26 12:08:47 2016 -0700

----------------------------------------------------------------------
 ...tingIntrinsicSwitchColumnNamingStrategy.java | 64 --------------------
 .../schema/naming/ColumnNamingStrategies.java   | 35 +++++++++++
 .../naming/DefaultColumnNamingStrategy.java     | 35 -----------
 ...tingIntrinsicSwitchColumnNamingStrategy.java | 60 ++++++++++++++++++
 .../naming/DefaultColumnNamingStrategyTest.java |  7 +--
 .../apache/metamodel/csv/CsvConfiguration.java  |  4 +-
 .../fixedwidth/FixedWidthConfiguration.java     |  4 +-
 7 files changed, 101 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
deleted file mode 100644
index 4fa5d30..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.builder;
-
-import org.apache.metamodel.schema.naming.ColumnNamingContext;
-import org.apache.metamodel.schema.naming.ColumnNamingSession;
-import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-
-/**
- * A {@link ColumnNamingStrategy} that switches between two other
- * {@link ColumnNamingStrategy} delegates depending on the availability of a
- * intrinsic column name.
- */
-public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
-
-    private static final long serialVersionUID = 1L;
-    private final ColumnNamingStrategy intrinsicStrategy;
-    private final ColumnNamingStrategy nonIntrinsicStrategy;
-
-    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
-            ColumnNamingStrategy nonIntrinsicStrategy) {
-        this.intrinsicStrategy = intrinsicStrategy;
-        this.nonIntrinsicStrategy = nonIntrinsicStrategy;
-    }
-
-    @Override
-    public ColumnNamingSession startColumnNamingSession() {
-        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
-        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
-        return new ColumnNamingSession() {
-
-            @Override
-            public String getNextColumnName(ColumnNamingContext ctx) {
-                final String intrinsicColumnName = ctx.getIntrinsicColumnName();
-                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
-                    return nonIntrinsicSession.getNextColumnName(ctx);
-                }
-                return intrinsicSession.getNextColumnName(ctx);
-            }
-
-            @Override
-            public void close() {
-                intrinsicSession.close();
-                nonIntrinsicSession.close();
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
new file mode 100644
index 0000000..de78338
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+/**
+ * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
+ */
+public class ColumnNamingStrategies {
+
+    private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(
+            new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
+
+    private ColumnNamingStrategies() {
+    }
+
+    public static ColumnNamingStrategy defaultStrategy() {
+        return DEFAULT_STRATEGY;
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java
deleted file mode 100644
index f0bcb23..0000000
--- a/core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.naming;
-
-import org.apache.metamodel.schema.builder.DelegatingIntrinsicSwitchColumnNamingStrategy;
-
-/**
- * The default (in most cases) {@link ColumnNamingStrategy} to use when no other
- * strategy is specified.
- */
-public class DefaultColumnNamingStrategy extends DelegatingIntrinsicSwitchColumnNamingStrategy {
-
-    private static final long serialVersionUID = 1L;
-
-    public DefaultColumnNamingStrategy() {
-        super(new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
new file mode 100644
index 0000000..e18cb3a
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+/**
+ * A {@link ColumnNamingStrategy} that switches between two other
+ * {@link ColumnNamingStrategy} delegates depending on the availability of a
+ * intrinsic column name.
+ */
+public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+    private final ColumnNamingStrategy intrinsicStrategy;
+    private final ColumnNamingStrategy nonIntrinsicStrategy;
+
+    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
+            ColumnNamingStrategy nonIntrinsicStrategy) {
+        this.intrinsicStrategy = intrinsicStrategy;
+        this.nonIntrinsicStrategy = nonIntrinsicStrategy;
+    }
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
+        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
+        return new ColumnNamingSession() {
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                final String intrinsicColumnName = ctx.getIntrinsicColumnName();
+                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
+                    return nonIntrinsicSession.getNextColumnName(ctx);
+                }
+                return intrinsicSession.getNextColumnName(ctx);
+            }
+
+            @Override
+            public void close() {
+                intrinsicSession.close();
+                nonIntrinsicSession.close();
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
index a293939..eb618c2 100644
--- a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
+++ b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
@@ -18,16 +18,13 @@
  */
 package org.apache.metamodel.schema.naming;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
-import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
-import org.apache.metamodel.schema.naming.ColumnNamingSession;
-import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.junit.Test;
 
 public class DefaultColumnNamingStrategyTest {
 
-    private final DefaultColumnNamingStrategy namingStrategy = new DefaultColumnNamingStrategy();
+    private final ColumnNamingStrategy namingStrategy = ColumnNamingStrategies.defaultStrategy();
 
     @Test
     public void testDuplicateColumnNames() throws Exception {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
index dd1c8ac..abcf2d4 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
@@ -21,8 +21,8 @@ package org.apache.metamodel.csv;
 import java.io.Serializable;
 import java.util.List;
 
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
 import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -103,7 +103,7 @@ public final class CsvConfiguration extends BaseObject implements Serializable {
      */
     public ColumnNamingStrategy getColumnNamingStrategy() {
         if (columnNamingStrategy == null) {
-            return new DefaultColumnNamingStrategy();
+            return ColumnNamingStrategies.defaultStrategy();
         }
         return columnNamingStrategy;
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c1e1d52f/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index bbdd0ad..6e9f0f1 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -23,8 +23,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
 import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -100,7 +100,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
 	 */
 	public ColumnNamingStrategy getColumnNamingStrategy() {
 	    if (columnNamingStrategy == null) {
-	        return new DefaultColumnNamingStrategy();
+	        return ColumnNamingStrategies.defaultStrategy();
 	    }
         return columnNamingStrategy;
     }


[09/42] metamodel git commit: METAMODEL-231: Fixed

Posted by ka...@apache.org.
METAMODEL-231: Fixed

Fixes #88

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/4f4cefdb
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/4f4cefdb
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/4f4cefdb

Branch: refs/heads/5.x
Commit: 4f4cefdbbe890291def12107b1b20ca6a5b96141
Parents: 63262e9
Author: Tomasz Guzialek <to...@guzialek.info>
Authored: Sat Jan 30 12:31:44 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Jan 30 12:31:44 2016 +0100

----------------------------------------------------------------------
 CHANGES.md                                                |  1 +
 .../java/org/apache/metamodel/neo4j/Neo4jDataContext.java |  4 +++-
 .../org/apache/metamodel/neo4j/Neo4jDataContextTest.java  | 10 ++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/4f4cefdb/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 773a57d..13f1694 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
 
  * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
  * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
+ * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
 
 ### Apache MetaModel 4.5.0
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/4f4cefdb/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
----------------------------------------------------------------------
diff --git a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
index 568ad71..cb0b2ac 100644
--- a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
+++ b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
@@ -19,7 +19,9 @@
 package org.apache.metamodel.neo4j;
 
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.http.HttpHost;
 import org.apache.http.client.methods.HttpGet;
@@ -170,7 +172,7 @@ public class Neo4jDataContext extends QueryPostprocessDataContext implements Dat
                     }
                 }
 
-                List<String> relationshipPropertiesPerLabel = new ArrayList<String>();
+                Set<String> relationshipPropertiesPerLabel = new LinkedHashSet<String>();
                 for (JSONObject node : nodesPerLabel) {
                     Integer nodeId = (Integer) node.getJSONObject("metadata").get("id");
                     List<JSONObject> relationshipsPerNode = getOutgoingRelationshipsPerNode(nodeId);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/4f4cefdb/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
----------------------------------------------------------------------
diff --git a/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java b/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
index d4e3774..1246ce2 100644
--- a/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
+++ b/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
@@ -100,12 +100,22 @@ public class Neo4jDataContextTest extends Neo4jTestCase {
         requestWrapper.executeCypherQuery("CREATE (n:JUnitPerson { name: 'Tomasz', age: 26})");
         requestWrapper.executeCypherQuery("CREATE (n:JUnitPerson { name: 'Philomeena', age: 18})");
         requestWrapper.executeCypherQuery("CREATE (n:JUnitBook { title: 'Introduction to algorithms'})");
+        requestWrapper.executeCypherQuery("CREATE (n:JUnitBook { title: 'Rich Dad Poor Dad'})");
         requestWrapper.executeCypherQuery("MATCH (a:JUnitPerson),(b:JUnitBook)"
                 + "WHERE a.name = 'Tomasz' AND b.title = 'Introduction to algorithms'"
                 + "CREATE (a)-[r:HAS_READ { rating : 5 }]->(b)");
         requestWrapper.executeCypherQuery("MATCH (a:JUnitPerson),(b:JUnitBook)"
                 + "WHERE a.name = 'Philomeena' AND b.title = 'Introduction to algorithms'"
                 + "CREATE (a)-[r:HAS_BROWSED]->(b)");
+        requestWrapper.executeCypherQuery("MATCH (a:JUnitPerson),(b:JUnitBook)"
+                + "WHERE a.name = 'Philomeena' AND b.title = 'Introduction to algorithms'"
+                + "CREATE (a)-[r:HAS_BROWSED]->(b)");
+        requestWrapper.executeCypherQuery("MATCH (a:JUnitPerson),(b:JUnitBook)"
+                + "WHERE a.name = 'Tomasz' AND b.title = 'Rich Dad Poor Dad'"
+                + "CREATE (a)-[r:HAS_READ { rating : 4 }]->(b)");
+        requestWrapper.executeCypherQuery("MATCH (a:JUnitPerson),(b:JUnitBook)"
+                + "WHERE a.name = 'Philomeena' AND b.title = 'Rich Dad Poor Dad'"
+                + "CREATE (a)-[r:HAS_READ { rating : 2 }]->(b)");
 
         Neo4jDataContext strategy = new Neo4jDataContext(getHostname(), getPort(), getUsername(), getPassword());
         Schema schema = strategy.getSchemaByName(strategy.getDefaultSchemaName());


[23/42] metamodel git commit: Fixed typo in .gitignore. Updated CHANGES.md.

Posted by ka...@apache.org.
Fixed typo in .gitignore. Updated CHANGES.md.

Closes #94
Closes #95

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/820b1f2b
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/820b1f2b
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/820b1f2b

Branch: refs/heads/5.x
Commit: 820b1f2b0be6462281321758a4a167965ec12ea7
Parents: c5a233a
Author: kaspersorensen <i....@gmail.com>
Authored: Thu Apr 21 16:25:56 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Thu Apr 21 16:28:46 2016 -0700

----------------------------------------------------------------------
 .gitignore | 2 +-
 CHANGES.md | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/820b1f2b/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 960f35f..e624e20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
 .project
-.settings
+.settings/
 .classpath
 .metadata/
 target/

http://git-wip-us.apache.org/repos/asf/metamodel/blob/820b1f2b/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 9ed7dc4..9be1b35 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,8 @@
+### Apache MetaModel 4.5.3 (work in progress)
+
+ * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
+ * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
+
 ### Apache MetaModel 4.5.2
 
  * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.


[39/42] metamodel git commit: METAMODEL-252: Fixed

Posted by ka...@apache.org.
METAMODEL-252: Fixed

Closes #100

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/152f8487
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/152f8487
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/152f8487

Branch: refs/heads/5.x
Commit: 152f8487a31051733e33f01c06c97d4c6742d26f
Parents: a6093c1
Author: Dennis Du Kr�ger <d...@hp23c.dk>
Authored: Thu May 12 20:18:41 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Thu May 12 20:18:41 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      | 339 ++++++++++---------
 .../metamodel/jdbc/JdbcMetadataLoader.java      |  19 ++
 2 files changed, 189 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/152f8487/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 2bb7572..25a7ed4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,169 +1,170 @@
-### Apache MetaModel 4.5.3 (work in progress)
-
- * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
- * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
- * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
- * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
- * [METAMODEL-247] - Added FixedWidthConfigurationReader for reading fixed width file metadata from external files.
- * [METAMODEL-159] - DataContextFactory misses methods to create HBase and POJO data contexts
-
-### Apache MetaModel 4.5.2
-
- * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.
-
-### Apache MetaModel 4.5.1
-
- * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
- * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
- * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
- * [METAMODEL-228] - Fixed a bug causing Number.class to not be converted to ColumnType.NUMBER.
-
-### Apache MetaModel 4.5.0
-
- * [METAMODEL-212] - New module for ElasticSearch via REST client.
- * [METAMODEL-99] - New module for Neo4j connectivity with MetaModel.
- * [METAMODEL-207] - Ensured the serializability of the SingleLineCsvRow class.
- * [METAMODEL-211] - Fixed a bug related to lookup by primary key (_id) on MongoDB.
- * [METAMODEL-216] - Added new aggregate functions: FIRST, LAST and RANDOM.
- * [METAMODEL-195] - Added new function MAP_VALUE which allows extracting a nested value from within a key/value map field.
- * [METAMODEL-15] - Query parser support for table names with space. Delimitters can be double quote or square brackets. 
- * [METAMODEL-215] - Improved the capability of NumberComparator to support Integer, Long, Double, BigInteger and other built-in Number classes.
- * [METAMODEL-218] - Fixed conversion of STRING and NUMBER types to database-specific types in JDBC module.
- * [METAMODEL-205] - Added validation of Excel sheet name before attempting to create table (sheet).
- * [METAMODEL-219] - Made HdfsResource capable of incorporating Hadoop configuration files core-site.xml and hdfs-site.xml
- * [METAMODEL-220] - Made HdfsResource capable of working with other URI schemes than 'hdfs'.
-
-### Apache MetaModel 4.4.1
-
- * [METAMODEL-198] - Fixed support for JDBC TIMESTAMP precision to match the underlying database's precision.
- * [METAMODEL-200] - Added optional "APPROXIMATE" keyword to query syntax for aggregate functions.
- * [METAMODEL-144] - Automated binary packaging of the MetaModel project.
- * [METAMODEL-197] - ElasticSearch schema update/change after CREATE TABLE statements.
- * [METAMODEL-199] - Fixed a bug in query parser when parsing two consecutive WHERE items with parentheses around them.
- * [METAMODEL-203] - Upgraded MongoDB dependency version and API to the 3.x line.
-
-### Apache MetaModel 4.4.0
-
- * [METAMODEL-192] - Added support for Scalar functions. We have a basic set of datatype conversion functions as well as support for UDF via implementing the ScalarFunction interface.
- * [METAMODEL-194] - Added support for setting the "Max rows" flag of a query to 0. This will always return an empty dataset.
- * [METAMODEL-173] - Improved CSV writing to non-file destinations. Added .write() and .append() methods to Resource interface.
- * [METAMODEL-170] - Dropped support for Java 6.
- * [METAMODEL-176] - Trimmed the transient dependencies of the JDBC module.
- * [METAMODEL-178] - Added AggregateFunction and ScalarFunction interfaces. Changed FunctionType enum to be super-interface of those. Compatibility is retained but a recompile of code using FunctionType is needed.
- * [METAMODEL-188] - Changed OperatorType enum to be an interface. Compatibility is retained but a recompile of code is needed.
- * [METAMODEL-179] - Ensured that HdfsResource is not closing a shared HDFS file system reference.
- * [METAMODEL-171] - Made integration tests for Cassandra module function properly in all environments.
- * [METAMODEL-177] - Fixed a bug pertaining to the serializability of HdfsResource.
- * [METAMODEL-172] - ElasticSearch Date types should be converted properly.
- * [METAMODEL-184] - ElasticSearch querying with "IS NULL" and "IS NOT NULL" now uses MissingFilter and ExistsFilter.
- * [METAMODEL-190] - Improved decimal number support in Excel module.
- * [METAMODEL-187] - Improved memory consumption of Excel module by passing random-access-file handles to POI when possible.
- * [METAMODEL-191] - Resolved a number of dependency conflicts/overlaps when combining multiple MetaModel modules.
- * [METAMODEL-157] - Fixed an issue in DELETE FROM statements with WHERE clauses requiring client-side data type conversion on JDBC databases.
- * [METAMODEL-182] - Improved HdfsResource and FileResource directory-based implementations by adding also getSize() and getLastModified() directory-based implementations.
-
-### Apache MetaModel 4.3.6
-
- * [METAMODEL-161] - Upgraded HBase client API to version 1.1.1
- * [METAMODEL-160] - Added support for Apache Hive via the JDBC module of MetaModel.
- * [METAMODEL-162] - Made HdfsResource Serializable and added property getters
- * [METAMODEL-163] - Made FileResource and HdfsResource work with folders containing file chunks instead of only single files
- * [METAMODEL-104] - Added 'hadoop' and 'hbase' modules to dependencies of 'MetaModel-full'.
- * [METAMODEL-164] - Fixed a bug in data type parsing of ElasticSearch mapping document.
-
-### Apache MetaModel 4.3.5
-
- * [METAMODEL-148] - Added a 'hadoop' module with a HdfsResource class to allow CSV, Excel and Fixed-width file access on HDFS.
- * [METAMODEL-152] - Fixed an issue of not clearing schema cache when refreshSchemas() is invoked.
- * [METAMODEL-149] - Added support for COUNTER data type in Cassandra.
- * [METAMODEL-151] - Added support for DOUBLE data type mapping in PostgreSQL
- * [METAMODEL-154] - Use embedded Cassandra server for integration tests.
-
-### Apache MetaModel 4.3.4
-
- * [METAMODEL-136] - Added LIKE operator native support (using conversion to regex) for MongoDB.
- * [METAMODEL-138] - Allow empty characters before AS keyword in query parsing.
- * [METAMODEL-141] - Improved mapping of ColumnType to SQL data types for Oracle, SQL Server, MySQL, DB2 and PostgreSQL
- * [METAMODEL-142] - Ensured that JDBC schema refreshes in an UpdateScript is using same Connection/Transaction as rest of operations
- * [METAMODEL-133] - Improved query parser support for multiple JOINs in same query.
- * [METAMODEL-140] - Fixed support for ElasticSearch mappings with additional property attributes.
-
-### Apache MetaModel 4.3.3
-
- * [METAMODEL-123] - Added compatibility with ElasticSearch version 1.4.x
- * [METAMODEL-93] - Added compatibility with Apache HBase version 1.0.0
- * [METAMODEL-124] - Invoked ElasticSearch cross-version incompatible methods via reflection
- * [METAMODEL-125] - Added support for comma-separated select items in Query.select(String) method argument.
- * [METAMODEL-128] - Fixed bug in DataSet ordering when aggregation functions are applied to non-JDBC modules.
- * [METAMODEL-131] - Added support for composite primary keys in JDBC CREATE TABLE statements.
-
-### Apache MetaModel 4.3.2
-
- * [METAMODEL-78] - Fixed a bug that caused SELECT DISTINCT to sometimes return duplicates records on certain DataContext implementations.
- * [METAMODEL-106] - Improved handling of invalid or non-existing index names passed to ElasticSearchDataContext
- * [METAMODEL-79] - Added update execution support on ElasticSearch module. Increased capability of pushing down WHERE items to ElasticSearch searches.
- * [METAMODEL-115] - Improved query parsing to allow lower-case function names, operators etc.
-
-### Apache MetaModel 4.3.1
-
- * [METAMODEL-100] - Fixed bug when having multiple columns of same name. Added column no. comparison when calling Column.equals(...).
-
-### Apache MetaModel 4.3.0-incubating
-
- * [METAMODEL-77] - New module 'elasticsearch' for connecting and modeling ElasticSearch indexes through MetaModel.
- * [METAMODEL-18] - New module 'cassandra' for connecting and modelling Apache Cassandra databases through MetaModel.
- * [METAMODEL-83] - Added new operator types: GREATER_THAN_OR_EQUAL ('>=') and LESS_THAN_OR_EQUAL ('<=').
- * [METAMODEL-92] - For JSON, MongoDB and CouchDB: Made it possible to specify column names referring nested fields such as "name.first" or "addresses[0].city".
- * [METAMODEL-76] - Query parser improved to handle filters without spaces inbetween operator and operands.
- * [METAMODEL-95] - Fixed a critical bug in the Salesforce.com module which caused all number values to be interpreted as '1'.
- * [METAMODEL-74] - Fixed a bug related to skipping blank values when applying an aggregate function (SUM, AVG etc.)
- * [METAMODEL-85] - Fixed a bug that caused NULL values to be evaluated with equal-sign in JDBC update and delete statements instead of 'IS NULL'.
- 
-### Apache MetaModel 4.2.0-incubating
-
- * [METAMODEL-38] - New module 'json' for handling json files (containing JSON arrays of documents or line-delimited JSON documents)
- * [METAMODEL-54] - ColumnType converted from enum to interface to allow for further specialization in modules.
- * [METAMODEL-57] - Changed the column type VARCHAR into STRING for the modules: CSV, Fixedwidth, Excel and XML.
- * [METAMODEL-56] - Made separate column types for converted JDBC LOBs - "CLOB as String" and "BLOB as bytes".
- * [METAMODEL-46] - Improved row-lookup by primary key (ID) in CouchDB
- * [METAMODEL-58] - Fixed a bug related to using CreateTable class and primary keys not getting created.
- * [METAMODEL-3]  - Improved writing of Byte-Order-Mark (BOM) for various encoding spelling variants.
- * [METAMODEL-70] - Made the build compatible with both JDK versions 6 and 7.
- * [METAMODEL-59] - Fixed a bug related to handling of date/time literals in MS SQL Server queries.
- * [METAMODEL-60] - Fixed a bug related to DISTINCT and TOP keywords in MS SQL Server queries.
- * [METAMODEL-45] - Improved and standardized way of handling integration test connection information towards external databases.
- * [METAMODEL-62] - Fixed a bug related to fault-tolerant handling of malformed CSV lines when reading CSVs in single-line mode
- * [METAMODEL-68] - Made it possible to create a CSV table without a header line in the file, if the user configures it.
- * [METAMODEL-67] - Upgraded Jackson (JSON library) dependency from org.codehaus namespace to the newer com.fasterxml namespace.
- * [METAMODEL-69] - Fixed issue with deserialization of ColumnType into the new interface instead of the old enum.
-
-### Apache MetaModel 4.1.0-incubating
-
- * [METAMODEL-13] - Added support for Apache HBase via the new module "MetaModel-hbase"
- * [METAMODEL-41] - Added a parser for SimpleTableDef objects (SimpleTableDefParser). It parses statements similar to CREATE TABLE statements, although without the "CREATE TABLE" prefix. For example: foo (bar INTEGER, baz VARCHAR)
- * [METAMODEL-11] - New module "MetaModel-spring" which adds a convenient FactoryBean to produce various types of DataContext objects based on externalizable parameters, for Spring framework users.
- * [METAMODEL-32] - Fixed thread-safety issue in Excel module when tables (sheets) metadata is updated.
- * [METAMODEL-47] - Fixed issue in Excel of loading schema if query is fired based on metadata from a previous DataContext instance.
- * [METAMODEL-35] - Improved query rewriting for DB2 when paged queries contain ORDER BY clause.
- * [METAMODEL-44] - Added an optional method for QueryPostprocessDataContext implementations to do a row-lookup by primary key value.
- * [METAMODEL-43] - Made CSV datastores skip empty lines in file instead of treating them of rows with null values.
- * [METAMODEL-39] - Added pooling of active/used Connections and PreparedStatements in JDBC compiled queries.
- * [METAMODEL-34] - Updated LICENSE file to not include bundled dependencies' licenses.
- * [METAMODEL-33] - Ensured that Apache Rat plugin for Maven is properly activated.
- * [METAMODEL-37] - Removed old site sources from project.
-
-### Apache MetaModel 4.0.0-incubating
-
- * [METAMODEL-9] - SalesforceDataSet is throwing exception for insert sql of record having date/time.
- * [METAMODEL-4] - Use folder name as schema name for file based DataContexts
- * [METAMODEL-5] - Faster CsvDataContext implementation for single-line values
- * [METAMODEL-26] - Provide endpoint URL with SalesforceDataContext
- * Upgraded Apache POI dependency to v. 3.9
- * Improved fluent Query builder API by adding string parameter based methods for joining tables
- * Added a utility ObjectInputStream for deserializing legacy MetaModel objects
- * Performance improvement to CSV reading when values are only single line based
- * Setting up the project on apache infrastructure
- * [METAMODEL-10] - Exclude Jackcess dependency (Access module) from MetaModel
- * Renaming the package hierarchy from org.eobjects.metamodel to org.apache.metamodel
- * [METAMODEL-29] - Fixed issue in CreateTable builder class, causing it to only support a single column definition
- * [METAMODEL-30] - Fixed issue with count(*) queries on CSV resources that does not provide a byte stream length 
+### Apache MetaModel 4.5.3 (work in progress)
+
+ * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
+ * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
+ * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
+ * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
+ * [METAMODEL-247] - Added FixedWidthConfigurationReader for reading fixed width file metadata from external files.
+ * [METAMODEL-159] - DataContextFactory misses methods to create HBase and POJO data contexts.
+ * [METAMODEL-252] - Fixed a bug that caused JDBC updates to unnecessarily refresh schema objects.
+
+### Apache MetaModel 4.5.2
+
+ * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.
+
+### Apache MetaModel 4.5.1
+
+ * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
+ * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
+ * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
+ * [METAMODEL-228] - Fixed a bug causing Number.class to not be converted to ColumnType.NUMBER.
+
+### Apache MetaModel 4.5.0
+
+ * [METAMODEL-212] - New module for ElasticSearch via REST client.
+ * [METAMODEL-99] - New module for Neo4j connectivity with MetaModel.
+ * [METAMODEL-207] - Ensured the serializability of the SingleLineCsvRow class.
+ * [METAMODEL-211] - Fixed a bug related to lookup by primary key (_id) on MongoDB.
+ * [METAMODEL-216] - Added new aggregate functions: FIRST, LAST and RANDOM.
+ * [METAMODEL-195] - Added new function MAP_VALUE which allows extracting a nested value from within a key/value map field.
+ * [METAMODEL-15] - Query parser support for table names with space. Delimitters can be double quote or square brackets. 
+ * [METAMODEL-215] - Improved the capability of NumberComparator to support Integer, Long, Double, BigInteger and other built-in Number classes.
+ * [METAMODEL-218] - Fixed conversion of STRING and NUMBER types to database-specific types in JDBC module.
+ * [METAMODEL-205] - Added validation of Excel sheet name before attempting to create table (sheet).
+ * [METAMODEL-219] - Made HdfsResource capable of incorporating Hadoop configuration files core-site.xml and hdfs-site.xml
+ * [METAMODEL-220] - Made HdfsResource capable of working with other URI schemes than 'hdfs'.
+
+### Apache MetaModel 4.4.1
+
+ * [METAMODEL-198] - Fixed support for JDBC TIMESTAMP precision to match the underlying database's precision.
+ * [METAMODEL-200] - Added optional "APPROXIMATE" keyword to query syntax for aggregate functions.
+ * [METAMODEL-144] - Automated binary packaging of the MetaModel project.
+ * [METAMODEL-197] - ElasticSearch schema update/change after CREATE TABLE statements.
+ * [METAMODEL-199] - Fixed a bug in query parser when parsing two consecutive WHERE items with parentheses around them.
+ * [METAMODEL-203] - Upgraded MongoDB dependency version and API to the 3.x line.
+
+### Apache MetaModel 4.4.0
+
+ * [METAMODEL-192] - Added support for Scalar functions. We have a basic set of datatype conversion functions as well as support for UDF via implementing the ScalarFunction interface.
+ * [METAMODEL-194] - Added support for setting the "Max rows" flag of a query to 0. This will always return an empty dataset.
+ * [METAMODEL-173] - Improved CSV writing to non-file destinations. Added .write() and .append() methods to Resource interface.
+ * [METAMODEL-170] - Dropped support for Java 6.
+ * [METAMODEL-176] - Trimmed the transient dependencies of the JDBC module.
+ * [METAMODEL-178] - Added AggregateFunction and ScalarFunction interfaces. Changed FunctionType enum to be super-interface of those. Compatibility is retained but a recompile of code using FunctionType is needed.
+ * [METAMODEL-188] - Changed OperatorType enum to be an interface. Compatibility is retained but a recompile of code is needed.
+ * [METAMODEL-179] - Ensured that HdfsResource is not closing a shared HDFS file system reference.
+ * [METAMODEL-171] - Made integration tests for Cassandra module function properly in all environments.
+ * [METAMODEL-177] - Fixed a bug pertaining to the serializability of HdfsResource.
+ * [METAMODEL-172] - ElasticSearch Date types should be converted properly.
+ * [METAMODEL-184] - ElasticSearch querying with "IS NULL" and "IS NOT NULL" now uses MissingFilter and ExistsFilter.
+ * [METAMODEL-190] - Improved decimal number support in Excel module.
+ * [METAMODEL-187] - Improved memory consumption of Excel module by passing random-access-file handles to POI when possible.
+ * [METAMODEL-191] - Resolved a number of dependency conflicts/overlaps when combining multiple MetaModel modules.
+ * [METAMODEL-157] - Fixed an issue in DELETE FROM statements with WHERE clauses requiring client-side data type conversion on JDBC databases.
+ * [METAMODEL-182] - Improved HdfsResource and FileResource directory-based implementations by adding also getSize() and getLastModified() directory-based implementations.
+
+### Apache MetaModel 4.3.6
+
+ * [METAMODEL-161] - Upgraded HBase client API to version 1.1.1
+ * [METAMODEL-160] - Added support for Apache Hive via the JDBC module of MetaModel.
+ * [METAMODEL-162] - Made HdfsResource Serializable and added property getters
+ * [METAMODEL-163] - Made FileResource and HdfsResource work with folders containing file chunks instead of only single files
+ * [METAMODEL-104] - Added 'hadoop' and 'hbase' modules to dependencies of 'MetaModel-full'.
+ * [METAMODEL-164] - Fixed a bug in data type parsing of ElasticSearch mapping document.
+
+### Apache MetaModel 4.3.5
+
+ * [METAMODEL-148] - Added a 'hadoop' module with a HdfsResource class to allow CSV, Excel and Fixed-width file access on HDFS.
+ * [METAMODEL-152] - Fixed an issue of not clearing schema cache when refreshSchemas() is invoked.
+ * [METAMODEL-149] - Added support for COUNTER data type in Cassandra.
+ * [METAMODEL-151] - Added support for DOUBLE data type mapping in PostgreSQL
+ * [METAMODEL-154] - Use embedded Cassandra server for integration tests.
+
+### Apache MetaModel 4.3.4
+
+ * [METAMODEL-136] - Added LIKE operator native support (using conversion to regex) for MongoDB.
+ * [METAMODEL-138] - Allow empty characters before AS keyword in query parsing.
+ * [METAMODEL-141] - Improved mapping of ColumnType to SQL data types for Oracle, SQL Server, MySQL, DB2 and PostgreSQL
+ * [METAMODEL-142] - Ensured that JDBC schema refreshes in an UpdateScript is using same Connection/Transaction as rest of operations
+ * [METAMODEL-133] - Improved query parser support for multiple JOINs in same query.
+ * [METAMODEL-140] - Fixed support for ElasticSearch mappings with additional property attributes.
+
+### Apache MetaModel 4.3.3
+
+ * [METAMODEL-123] - Added compatibility with ElasticSearch version 1.4.x
+ * [METAMODEL-93] - Added compatibility with Apache HBase version 1.0.0
+ * [METAMODEL-124] - Invoked ElasticSearch cross-version incompatible methods via reflection
+ * [METAMODEL-125] - Added support for comma-separated select items in Query.select(String) method argument.
+ * [METAMODEL-128] - Fixed bug in DataSet ordering when aggregation functions are applied to non-JDBC modules.
+ * [METAMODEL-131] - Added support for composite primary keys in JDBC CREATE TABLE statements.
+
+### Apache MetaModel 4.3.2
+
+ * [METAMODEL-78] - Fixed a bug that caused SELECT DISTINCT to sometimes return duplicates records on certain DataContext implementations.
+ * [METAMODEL-106] - Improved handling of invalid or non-existing index names passed to ElasticSearchDataContext
+ * [METAMODEL-79] - Added update execution support on ElasticSearch module. Increased capability of pushing down WHERE items to ElasticSearch searches.
+ * [METAMODEL-115] - Improved query parsing to allow lower-case function names, operators etc.
+
+### Apache MetaModel 4.3.1
+
+ * [METAMODEL-100] - Fixed bug when having multiple columns of same name. Added column no. comparison when calling Column.equals(...).
+
+### Apache MetaModel 4.3.0-incubating
+
+ * [METAMODEL-77] - New module 'elasticsearch' for connecting and modeling ElasticSearch indexes through MetaModel.
+ * [METAMODEL-18] - New module 'cassandra' for connecting and modelling Apache Cassandra databases through MetaModel.
+ * [METAMODEL-83] - Added new operator types: GREATER_THAN_OR_EQUAL ('>=') and LESS_THAN_OR_EQUAL ('<=').
+ * [METAMODEL-92] - For JSON, MongoDB and CouchDB: Made it possible to specify column names referring nested fields such as "name.first" or "addresses[0].city".
+ * [METAMODEL-76] - Query parser improved to handle filters without spaces inbetween operator and operands.
+ * [METAMODEL-95] - Fixed a critical bug in the Salesforce.com module which caused all number values to be interpreted as '1'.
+ * [METAMODEL-74] - Fixed a bug related to skipping blank values when applying an aggregate function (SUM, AVG etc.)
+ * [METAMODEL-85] - Fixed a bug that caused NULL values to be evaluated with equal-sign in JDBC update and delete statements instead of 'IS NULL'.
+ 
+### Apache MetaModel 4.2.0-incubating
+
+ * [METAMODEL-38] - New module 'json' for handling json files (containing JSON arrays of documents or line-delimited JSON documents)
+ * [METAMODEL-54] - ColumnType converted from enum to interface to allow for further specialization in modules.
+ * [METAMODEL-57] - Changed the column type VARCHAR into STRING for the modules: CSV, Fixedwidth, Excel and XML.
+ * [METAMODEL-56] - Made separate column types for converted JDBC LOBs - "CLOB as String" and "BLOB as bytes".
+ * [METAMODEL-46] - Improved row-lookup by primary key (ID) in CouchDB
+ * [METAMODEL-58] - Fixed a bug related to using CreateTable class and primary keys not getting created.
+ * [METAMODEL-3]  - Improved writing of Byte-Order-Mark (BOM) for various encoding spelling variants.
+ * [METAMODEL-70] - Made the build compatible with both JDK versions 6 and 7.
+ * [METAMODEL-59] - Fixed a bug related to handling of date/time literals in MS SQL Server queries.
+ * [METAMODEL-60] - Fixed a bug related to DISTINCT and TOP keywords in MS SQL Server queries.
+ * [METAMODEL-45] - Improved and standardized way of handling integration test connection information towards external databases.
+ * [METAMODEL-62] - Fixed a bug related to fault-tolerant handling of malformed CSV lines when reading CSVs in single-line mode
+ * [METAMODEL-68] - Made it possible to create a CSV table without a header line in the file, if the user configures it.
+ * [METAMODEL-67] - Upgraded Jackson (JSON library) dependency from org.codehaus namespace to the newer com.fasterxml namespace.
+ * [METAMODEL-69] - Fixed issue with deserialization of ColumnType into the new interface instead of the old enum.
+
+### Apache MetaModel 4.1.0-incubating
+
+ * [METAMODEL-13] - Added support for Apache HBase via the new module "MetaModel-hbase"
+ * [METAMODEL-41] - Added a parser for SimpleTableDef objects (SimpleTableDefParser). It parses statements similar to CREATE TABLE statements, although without the "CREATE TABLE" prefix. For example: foo (bar INTEGER, baz VARCHAR)
+ * [METAMODEL-11] - New module "MetaModel-spring" which adds a convenient FactoryBean to produce various types of DataContext objects based on externalizable parameters, for Spring framework users.
+ * [METAMODEL-32] - Fixed thread-safety issue in Excel module when tables (sheets) metadata is updated.
+ * [METAMODEL-47] - Fixed issue in Excel of loading schema if query is fired based on metadata from a previous DataContext instance.
+ * [METAMODEL-35] - Improved query rewriting for DB2 when paged queries contain ORDER BY clause.
+ * [METAMODEL-44] - Added an optional method for QueryPostprocessDataContext implementations to do a row-lookup by primary key value.
+ * [METAMODEL-43] - Made CSV datastores skip empty lines in file instead of treating them of rows with null values.
+ * [METAMODEL-39] - Added pooling of active/used Connections and PreparedStatements in JDBC compiled queries.
+ * [METAMODEL-34] - Updated LICENSE file to not include bundled dependencies' licenses.
+ * [METAMODEL-33] - Ensured that Apache Rat plugin for Maven is properly activated.
+ * [METAMODEL-37] - Removed old site sources from project.
+
+### Apache MetaModel 4.0.0-incubating
+
+ * [METAMODEL-9] - SalesforceDataSet is throwing exception for insert sql of record having date/time.
+ * [METAMODEL-4] - Use folder name as schema name for file based DataContexts
+ * [METAMODEL-5] - Faster CsvDataContext implementation for single-line values
+ * [METAMODEL-26] - Provide endpoint URL with SalesforceDataContext
+ * Upgraded Apache POI dependency to v. 3.9
+ * Improved fluent Query builder API by adding string parameter based methods for joining tables
+ * Added a utility ObjectInputStream for deserializing legacy MetaModel objects
+ * Performance improvement to CSV reading when values are only single line based
+ * Setting up the project on apache infrastructure
+ * [METAMODEL-10] - Exclude Jackcess dependency (Access module) from MetaModel
+ * Renaming the package hierarchy from org.eobjects.metamodel to org.apache.metamodel
+ * [METAMODEL-29] - Fixed issue in CreateTable builder class, causing it to only support a single column definition
+ * [METAMODEL-30] - Fixed issue with count(*) queries on CSV resources that does not provide a byte stream length 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/152f8487/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
index 2254617..5d5697e 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
@@ -149,6 +149,11 @@ final class JdbcMetadataLoader implements MetadataLoader {
     
     @Override
     public void loadIndexes(JdbcTable jdbcTable) {
+        final int identity = System.identityHashCode(jdbcTable);
+        if (_loadedIndexes.contains(identity)) {
+            return;
+        }
+
         final Connection connection = _dataContext.getConnection();
         try {
             loadIndexes(jdbcTable, connection);
@@ -180,6 +185,11 @@ final class JdbcMetadataLoader implements MetadataLoader {
     
     @Override
     public void loadPrimaryKeys(JdbcTable jdbcTable) {
+        final int identity = System.identityHashCode(jdbcTable);
+        if (_loadedPrimaryKeys.contains(identity)) {
+            return;
+        }
+
         final Connection connection = _dataContext.getConnection();
         try {
             loadPrimaryKeys(jdbcTable, connection);
@@ -268,6 +278,11 @@ final class JdbcMetadataLoader implements MetadataLoader {
     
     @Override
     public void loadColumns(JdbcTable jdbcTable) {
+        final int identity = System.identityHashCode(jdbcTable);
+        if (_loadedColumns.contains(identity)) {
+            return;
+        }
+
         final Connection connection = _dataContext.getConnection();
         try {
             loadColumns(jdbcTable, connection);
@@ -384,6 +399,10 @@ final class JdbcMetadataLoader implements MetadataLoader {
     
     @Override
     public void loadRelations(JdbcSchema jdbcSchema) {
+        final int identity = System.identityHashCode(jdbcSchema);
+        if (_loadedRelations.contains(identity)) {
+            return;
+        }
         final Connection connection = _dataContext.getConnection();
         try {
             loadRelations(jdbcSchema, connection);


[40/42] metamodel git commit: METAMODEL-1082: Fixed

Posted by ka...@apache.org.
METAMODEL-1082: Fixed

Closes #98

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/2e39b501
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/2e39b501
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/2e39b501

Branch: refs/heads/5.x
Commit: 2e39b501091e530ffc39a32767a9e650c1fdcab8
Parents: 152f848
Author: Kasper S�rensen <i....@gmail.com>
Authored: Fri May 13 08:48:23 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Fri May 13 08:48:23 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      |   1 +
 .../common/ElasticSearchUtils.java              |  91 +++++--
 .../ElasticSearchCreateTableBuilder.java        |  10 +-
 .../nativeclient/NativeElasticSearchUtils.java  |   3 +-
 elasticsearch/rest/pom.xml                      |   2 +-
 .../rest/ElasticSearchRestDataContext.java      |   4 +-
 .../JestElasticSearchCreateTableBuilder.java    |  20 +-
 .../rest/JestElasticSearchDataSet.java          |   2 +-
 .../rest/JestElasticSearchDeleteBuilder.java    |   2 +-
 .../rest/JestElasticSearchDropTableBuilder.java |   5 +-
 .../rest/JestElasticSearchInsertBuilder.java    |  33 ++-
 .../rest/JestElasticSearchUpdateCallback.java   | 249 ++++++++++++-------
 12 files changed, 274 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 25a7ed4..66d1917 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@
  * [METAMODEL-247] - Added FixedWidthConfigurationReader for reading fixed width file metadata from external files.
  * [METAMODEL-159] - DataContextFactory misses methods to create HBase and POJO data contexts.
  * [METAMODEL-252] - Fixed a bug that caused JDBC updates to unnecessarily refresh schema objects.
+ * [METAMODEL-1082] - Improved performance of batch ElasticSearch operations by using bulk API.
 
 ### Apache MetaModel 4.5.2
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/common/src/main/java/org/apache/metamodel/elasticsearch/common/ElasticSearchUtils.java
----------------------------------------------------------------------
diff --git a/elasticsearch/common/src/main/java/org/apache/metamodel/elasticsearch/common/ElasticSearchUtils.java b/elasticsearch/common/src/main/java/org/apache/metamodel/elasticsearch/common/ElasticSearchUtils.java
index 11d35bd..b298d11 100644
--- a/elasticsearch/common/src/main/java/org/apache/metamodel/elasticsearch/common/ElasticSearchUtils.java
+++ b/elasticsearch/common/src/main/java/org/apache/metamodel/elasticsearch/common/ElasticSearchUtils.java
@@ -21,7 +21,10 @@ package org.apache.metamodel.elasticsearch.common;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.metamodel.query.FilterItem;
 import org.apache.metamodel.query.LogicalOperator;
@@ -40,29 +43,34 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ElasticSearchUtils {
-    public static final String FIELD_ID = "_id";
+
     private static final Logger logger = LoggerFactory.getLogger(ElasticSearchUtils.class);
 
+    public static final String FIELD_ID = "_id";
+    public static final String SYSTEM_PROPERTY_STRIP_INVALID_FIELD_CHARS = "metamodel.elasticsearch.strip_invalid_field_chars";
+
     /**
      * Gets a "filter" query which is both 1.x and 2.x compatible.
      */
     private static QueryBuilder getFilteredQuery(String prefix, String fieldName) {
-        // 1.x: itemQueryBuilder = QueryBuilders.filteredQuery(null, FilterBuilders.missingFilter(fieldName));
-        // 2.x: itemQueryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.missingQuery(fieldName));
+        // 1.x: itemQueryBuilder = QueryBuilders.filteredQuery(null,
+        // FilterBuilders.missingFilter(fieldName));
+        // 2.x: itemQueryBuilder =
+        // QueryBuilders.boolQuery().must(QueryBuilders.missingQuery(fieldName));
         try {
             try {
                 Method method = QueryBuilders.class.getDeclaredMethod(prefix + "Query", String.class);
                 method.setAccessible(true);
                 return QueryBuilders.boolQuery().must((QueryBuilder) method.invoke(null, fieldName));
             } catch (NoSuchMethodException e) {
-                Class<?> clazz = ElasticSearchUtils.class.getClassLoader()
-                        .loadClass("org.elasticsearch.index.query.FilterBuilders");
+                Class<?> clazz = ElasticSearchUtils.class.getClassLoader().loadClass(
+                        "org.elasticsearch.index.query.FilterBuilders");
                 Method filterBuilderMethod = clazz.getDeclaredMethod(prefix + "Filter", String.class);
                 filterBuilderMethod.setAccessible(true);
-                Method queryBuildersFilteredQueryMethod =
-                        QueryBuilders.class.getDeclaredMethod("filteredQuery", QueryBuilder.class, FilterBuilder.class);
-                return (QueryBuilder) queryBuildersFilteredQueryMethod.invoke(null, null,
-                        filterBuilderMethod.invoke(null, fieldName));
+                Method queryBuildersFilteredQueryMethod = QueryBuilders.class.getDeclaredMethod("filteredQuery",
+                        QueryBuilder.class, FilterBuilder.class);
+                return (QueryBuilder) queryBuildersFilteredQueryMethod.invoke(null, null, filterBuilderMethod.invoke(
+                        null, fieldName));
             }
         } catch (Exception e) {
             logger.error("Failed to resolve/invoke filtering method", e);
@@ -78,34 +86,63 @@ public class ElasticSearchUtils {
         return getFilteredQuery("exists", fieldName);
     }
 
-    public static List<Object> getSourceProperties(final MutableTable table) {
+    public static Map<String, ?> getMappingSource(final MutableTable table) {
         if (table.getColumnByName(FIELD_ID) == null) {
-            final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING)
-                    .setTable(table).setPrimaryKey(true);
+            final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey(
+                    true);
             table.addColumn(0, idColumn);
         }
 
-        final List<Object> sourceProperties = new ArrayList<>();
-
+        final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>();
+        
         for (Column column : table.getColumns()) {
-            // each column is defined as a property pair of the form: ("field1",
-            // "type=string,store=true")
             final String columnName = column.getName();
             if (FIELD_ID.equals(columnName)) {
                 // do nothing - the ID is a client-side construct
                 continue;
             }
-            sourceProperties.add(columnName);
+            
+            final String fieldName = getValidatedFieldName(columnName);
+            final Map<String, String> propertyMap = new HashMap<>();
+            final String type = getType(column);
+            propertyMap.put("type", type);
+            
+            propertiesMap.put(fieldName, propertyMap);
+        }
 
-            String type = getType(column);
-            if (type == null) {
-                sourceProperties.add("store=true");
+        HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>();
+        docTypeMap.put("properties", propertiesMap);
+        
+        final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>();
+        mapping.put(table.getName(), docTypeMap);
+        return mapping;
+    }
+
+    /**
+     * Field name special characters are:
+     * 
+     * . (used for navigation between name components)
+     * 
+     * # (for delimiting name components in _uid, should work, but is
+     * discouraged)
+     * 
+     * * (for matching names)
+     * 
+     * @param fieldName
+     * @return
+     */
+    public static String getValidatedFieldName(String fieldName) {
+        if (fieldName == null || fieldName.isEmpty()) {
+            throw new IllegalArgumentException("Field name cannot be null or empty");
+        }
+        if (fieldName.contains(".") || fieldName.contains("#") || fieldName.contains("*")) {
+            if ("true".equalsIgnoreCase(System.getProperty(SYSTEM_PROPERTY_STRIP_INVALID_FIELD_CHARS, "true"))) {
+                fieldName = fieldName.replace('.', '_').replace('#', '_').replace('*', '_');
             } else {
-                sourceProperties.add("type=" + type + ",store=true");
+                throw new IllegalArgumentException("Field name '" + fieldName + "' contains illegal character (.#*)");
             }
         }
-
-        return sourceProperties;
+        return fieldName;
     }
 
     /**
@@ -154,8 +191,8 @@ public class ElasticSearchUtils {
             return "object";
         }
 
-        throw new UnsupportedOperationException("Unsupported column type '" + type.getName() + "' of column '"
-                + column.getName() + "' - cannot translate to an ElasticSearch type.");
+        throw new UnsupportedOperationException("Unsupported column type '" + type.getName() + "' of column '" + column
+                .getName() + "' - cannot translate to an ElasticSearch type.");
     }
 
     /**
@@ -204,8 +241,8 @@ public class ElasticSearchUtils {
                     if (operand == null) {
                         itemQueryBuilder = getExistsQuery(fieldName);
                     } else {
-                        itemQueryBuilder = QueryBuilders.boolQuery().mustNot(
-                                QueryBuilders.termQuery(fieldName, operand));
+                        itemQueryBuilder = QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery(fieldName,
+                                operand));
                     }
                 } else if (OperatorType.IN.equals(operator)) {
                     final List<?> operands = CollectionUtils.toList(operand);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchCreateTableBuilder.java
----------------------------------------------------------------------
diff --git a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchCreateTableBuilder.java b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchCreateTableBuilder.java
index 5d6701c..f27e8ac 100644
--- a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchCreateTableBuilder.java
+++ b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchCreateTableBuilder.java
@@ -18,7 +18,7 @@
  */
 package org.apache.metamodel.elasticsearch.nativeclient;
 
-import java.util.List;
+import java.util.Map;
 
 import org.apache.metamodel.MetaModelException;
 import org.apache.metamodel.create.AbstractTableCreationBuilder;
@@ -44,15 +44,15 @@ final class ElasticSearchCreateTableBuilder extends AbstractTableCreationBuilder
     @Override
     public Table execute() throws MetaModelException {
         final MutableTable table = getTable();
-        final List<Object> sourceProperties = ElasticSearchUtils.getSourceProperties(table);
+        final Map<String, ?> source = ElasticSearchUtils.getMappingSource(table);
 
         final ElasticSearchDataContext dataContext = getUpdateCallback().getDataContext();
         final IndicesAdminClient indicesAdmin = dataContext.getElasticSearchClient().admin().indices();
         final String indexName = dataContext.getIndexName();
 
-        final PutMappingRequestBuilder requestBuilder = new PutMappingRequestBuilder(indicesAdmin)
-                .setIndices(indexName).setType(table.getName());
-        requestBuilder.setSource(sourceProperties.toArray());
+        final PutMappingRequestBuilder requestBuilder = new PutMappingRequestBuilder(indicesAdmin).setIndices(indexName)
+                .setType(table.getName());
+        requestBuilder.setSource(source);
         final PutMappingResponse result = requestBuilder.execute().actionGet();
 
         logger.debug("PutMapping response: acknowledged={}", result.isAcknowledged());

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/NativeElasticSearchUtils.java
----------------------------------------------------------------------
diff --git a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/NativeElasticSearchUtils.java b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/NativeElasticSearchUtils.java
index 1efb0c8..822ef1b 100644
--- a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/NativeElasticSearchUtils.java
+++ b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/NativeElasticSearchUtils.java
@@ -41,7 +41,8 @@ final class NativeElasticSearchUtils {
             final Column column = selectItem.getColumn();
 
             assert column != null;
-            assert selectItem.getFunction() == null;
+            assert selectItem.getAggregateFunction() == null;
+            assert selectItem.getScalarFunction() == null;
 
             if (column.isPrimaryKey()) {
                 values[i] = documentId;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 16c0555..92f7393 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -27,7 +27,7 @@ under the License.
 	<modelVersion>4.0.0</modelVersion>
 
 	<properties>
-		<jest.version>0.1.7</jest.version>
+		<jest.version>2.0.2</jest.version>
 		<elasticsearch.version>1.4.4</elasticsearch.version>
 	</properties>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
index 6b8ac51..c452d7b 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.metamodel.BatchUpdateScript;
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.MetaModelException;
 import org.apache.metamodel.QueryPostprocessDataContext;
@@ -354,7 +355,8 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
 
     @Override
     public void executeUpdate(UpdateScript update) {
-        final JestElasticSearchUpdateCallback callback = new JestElasticSearchUpdateCallback(this);
+        final boolean isBatch = update instanceof BatchUpdateScript;
+        final JestElasticSearchUpdateCallback callback = new JestElasticSearchUpdateCallback(this, isBatch);
         update.run(callback);
         callback.onExecuteUpdateFinished();
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchCreateTableBuilder.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchCreateTableBuilder.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchCreateTableBuilder.java
index cc26c8d..3e71c4d 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchCreateTableBuilder.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchCreateTableBuilder.java
@@ -18,29 +18,35 @@
  */
 package org.apache.metamodel.elasticsearch.rest;
 
-import io.searchbox.indices.mapping.PutMapping;
+import java.util.Map;
+
 import org.apache.metamodel.MetaModelException;
 import org.apache.metamodel.create.AbstractTableCreationBuilder;
 import org.apache.metamodel.elasticsearch.common.ElasticSearchUtils;
-import org.apache.metamodel.schema.*;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
 
-import java.util.List;
+import io.searchbox.indices.mapping.PutMapping;
 
 final class JestElasticSearchCreateTableBuilder extends AbstractTableCreationBuilder<JestElasticSearchUpdateCallback> {
-    public JestElasticSearchCreateTableBuilder(JestElasticSearchUpdateCallback updateCallback, Schema schema, String name) {
+    
+    public JestElasticSearchCreateTableBuilder(JestElasticSearchUpdateCallback updateCallback, Schema schema,
+            String name) {
         super(updateCallback, schema, name);
     }
 
     @Override
     public Table execute() throws MetaModelException {
         final MutableTable table = getTable();
-        final List<Object> sourceProperties = ElasticSearchUtils.getSourceProperties(table);
+        final Map<String, ?> source = ElasticSearchUtils.getMappingSource(table);
 
         final ElasticSearchRestDataContext dataContext = getUpdateCallback().getDataContext();
         final String indexName = dataContext.getIndexName();
 
-        final PutMapping putMapping = new PutMapping.Builder(indexName, table.getName(), sourceProperties).build();
-        JestClientExecutor.execute(dataContext.getElasticSearchClient(), putMapping);
+        final PutMapping putMapping = new PutMapping.Builder(indexName, table.getName(), source).build();
+        getUpdateCallback().execute(putMapping);
 
         final MutableSchema schema = (MutableSchema) getSchema();
         schema.addTable(table);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDataSet.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDataSet.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDataSet.java
index 9678b48..7f485ba 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDataSet.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDataSet.java
@@ -106,7 +106,7 @@ final class JestElasticSearchDataSet extends AbstractDataSet {
         }
 
         // try to scroll to the next set of hits
-        SearchScroll scroll = new SearchScroll.Builder(scrollId.getAsString(), ElasticSearchRestDataContext.TIMEOUT_SCROLL).build();
+        final SearchScroll scroll = new SearchScroll.Builder(scrollId.getAsString(), ElasticSearchRestDataContext.TIMEOUT_SCROLL).build();
 
         _searchResponse = JestClientExecutor.execute(_client, scroll);
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDeleteBuilder.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDeleteBuilder.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDeleteBuilder.java
index a4c0c03..cc1c3e7 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDeleteBuilder.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDeleteBuilder.java
@@ -71,6 +71,6 @@ final class JestElasticSearchDeleteBuilder extends AbstractRowDeletionBuilder {
                 new DeleteByQuery.Builder(searchSourceBuilder.toString()).addIndex(indexName).addType(
                         documentType).build();
 
-        JestClientExecutor.execute(dataContext.getElasticSearchClient(), deleteByQuery);
+        _updateCallback.execute(deleteByQuery);
     }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDropTableBuilder.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDropTableBuilder.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDropTableBuilder.java
index d4ddd19..8a1ac71 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDropTableBuilder.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchDropTableBuilder.java
@@ -18,7 +18,6 @@
  */
 package org.apache.metamodel.elasticsearch.rest;
 
-import io.searchbox.indices.mapping.DeleteMapping;
 import org.apache.metamodel.MetaModelException;
 import org.apache.metamodel.drop.AbstractTableDropBuilder;
 import org.apache.metamodel.drop.TableDropBuilder;
@@ -27,6 +26,8 @@ import org.apache.metamodel.schema.Table;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import io.searchbox.indices.mapping.DeleteMapping;
+
 /**
  * {@link TableDropBuilder} for dropping tables (document types) in an
  * ElasticSearch index.
@@ -52,7 +53,7 @@ final class JestElasticSearchDropTableBuilder extends AbstractTableDropBuilder {
 
         final DeleteMapping deleteIndex = new DeleteMapping.Builder(dataContext.getIndexName(), documentType).build();
 
-        JestClientExecutor.execute(dataContext.getElasticSearchClient(), deleteIndex);
+        _updateCallback.execute(deleteIndex);
 
         final MutableSchema schema = (MutableSchema) table.getSchema();
         schema.removeTable(table);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchInsertBuilder.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchInsertBuilder.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchInsertBuilder.java
index 327d7d3..746538d 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchInsertBuilder.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchInsertBuilder.java
@@ -18,60 +18,57 @@
  */
 package org.apache.metamodel.elasticsearch.rest;
 
-import io.searchbox.core.DocumentResult;
-import io.searchbox.core.Index;
-import io.searchbox.params.Parameters;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.elasticsearch.common.ElasticSearchUtils;
 import org.apache.metamodel.insert.AbstractRowInsertionBuilder;
 import org.apache.metamodel.schema.Column;
 import org.apache.metamodel.schema.Table;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
-import java.util.Map;
+import io.searchbox.core.Index;
+import io.searchbox.params.Parameters;
 
 final class JestElasticSearchInsertBuilder extends AbstractRowInsertionBuilder<JestElasticSearchUpdateCallback> {
 
-    private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchInsertBuilder.class);
-
     public JestElasticSearchInsertBuilder(JestElasticSearchUpdateCallback updateCallback, Table table) {
         super(updateCallback, table);
     }
 
     @Override
     public void execute() throws MetaModelException {
-        final ElasticSearchRestDataContext dataContext = getUpdateCallback().getDataContext();
+        final JestElasticSearchUpdateCallback updateCallback = getUpdateCallback();
+        final ElasticSearchRestDataContext dataContext = updateCallback.getDataContext();
         final String indexName = dataContext.getIndexName();
         final String documentType = getTable().getName();
 
-
         final Map<String, Object> source = new HashMap<>();
         final Column[] columns = getColumns();
         final Object[] values = getValues();
         String id = null;
         for (int i = 0; i < columns.length; i++) {
             if (isSet(columns[i])) {
-                final String name = columns[i].getName();
+                final String columnName = columns[i].getName();
+
                 final Object value = values[i];
-                if (ElasticSearchRestDataContext.FIELD_ID.equals(name)) {
+                if (ElasticSearchRestDataContext.FIELD_ID.equals(columnName)) {
                     if (value != null) {
                         id = value.toString();
                     }
                 } else {
-                    source.put(name, value);
+                    final String fieldName = ElasticSearchUtils.getValidatedFieldName(columnName);
+                    source.put(fieldName, value);
                 }
             }
         }
 
         assert !source.isEmpty();
 
-        Index index = new Index.Builder(source).index(indexName).type(documentType).id(id).setParameter(
+        final Index index = new Index.Builder(source).index(indexName).type(documentType).id(id).setParameter(
                 Parameters.OP_TYPE, "create").build();
 
-        final DocumentResult result = JestClientExecutor.execute(dataContext.getElasticSearchClient(), index);
-
-        logger.debug("Inserted document: id={}", result.getId());
+        getUpdateCallback().execute(index);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2e39b501/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
index ca2ed13..521955d 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
@@ -1,84 +1,165 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.elasticsearch.rest;
-
-import io.searchbox.indices.Refresh;
-import org.apache.metamodel.AbstractUpdateCallback;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.create.TableCreationBuilder;
-import org.apache.metamodel.delete.RowDeletionBuilder;
-import org.apache.metamodel.drop.TableDropBuilder;
-import org.apache.metamodel.insert.RowInsertionBuilder;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-
-/**
- * {@link UpdateCallback} implementation for {@link ElasticSearchRestDataContext}.
- */
-final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
-    public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext) {
-        super(dataContext);
-    }
-
-    @Override
-    public ElasticSearchRestDataContext getDataContext() {
-        return (ElasticSearchRestDataContext) super.getDataContext();
-    }
-
-    @Override
-    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
-            IllegalStateException {
-        return new JestElasticSearchCreateTableBuilder(this, schema, name);
-    }
-
-    @Override
-    public boolean isDropTableSupported() {
-        return true;
-    }
-
-    @Override
-    public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
-            UnsupportedOperationException {
-        return new JestElasticSearchDropTableBuilder(this, table);
-    }
-
-    @Override
-    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
-            UnsupportedOperationException {
-        return new JestElasticSearchInsertBuilder(this, table);
-    }
-
-    @Override
-    public boolean isDeleteSupported() {
-        return true;
-    }
-
-    @Override
-    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
-            UnsupportedOperationException {
-        return new JestElasticSearchDeleteBuilder(this, table);
-    }
-
-    public void onExecuteUpdateFinished() {
-        final String indexName = getDataContext().getIndexName();
-        Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
-
-        JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.elasticsearch.rest;
+
+import java.util.List;
+
+import org.apache.metamodel.AbstractUpdateCallback;
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.delete.RowDeletionBuilder;
+import org.apache.metamodel.drop.TableDropBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.searchbox.action.Action;
+import io.searchbox.action.BulkableAction;
+import io.searchbox.client.JestResult;
+import io.searchbox.core.Bulk;
+import io.searchbox.core.Bulk.Builder;
+import io.searchbox.core.BulkResult;
+import io.searchbox.core.BulkResult.BulkResultItem;
+import io.searchbox.indices.Refresh;
+
+/**
+ * {@link UpdateCallback} implementation for
+ * {@link ElasticSearchRestDataContext}.
+ */
+final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
+
+    private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);
+
+    private static final int BULK_BUFFER_SIZE = 1000;
+
+    private Bulk.Builder bulkBuilder;
+    private int bulkActionCount = 0;
+    private final boolean isBatch;
+
+    public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {
+        super(dataContext);
+        this.isBatch = isBatch;
+    }
+
+    private boolean isBatch() {
+        return isBatch;
+    }
+
+    @Override
+    public ElasticSearchRestDataContext getDataContext() {
+        return (ElasticSearchRestDataContext) super.getDataContext();
+    }
+
+    @Override
+    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
+            IllegalStateException {
+        return new JestElasticSearchCreateTableBuilder(this, schema, name);
+    }
+
+    @Override
+    public boolean isDropTableSupported() {
+        return true;
+    }
+
+    @Override
+    public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new JestElasticSearchDropTableBuilder(this, table);
+    }
+
+    @Override
+    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new JestElasticSearchInsertBuilder(this, table);
+    }
+
+    @Override
+    public boolean isDeleteSupported() {
+        return true;
+    }
+
+    @Override
+    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new JestElasticSearchDeleteBuilder(this, table);
+    }
+
+    public void onExecuteUpdateFinished() {
+        if (isBatch()) {
+            flushBulkActions();
+        }
+
+        final String indexName = getDataContext().getIndexName();
+        final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
+
+        JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
+    }
+
+    private void flushBulkActions() {
+        if (bulkBuilder == null || bulkActionCount == 0) {
+            // nothing to flush
+            return;
+        }
+        final Bulk bulk = getBulkBuilder().build();
+        logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());
+        executeBlocking(bulk);
+
+        bulkActionCount = 0;
+        bulkBuilder = null;
+    }
+
+    public void execute(Action<?> action) {
+        if (isBatch() && action instanceof BulkableAction) {
+            final Bulk.Builder bulkBuilder = getBulkBuilder();
+            bulkBuilder.addAction((BulkableAction<?>) action);
+            bulkActionCount++;
+            if (bulkActionCount == BULK_BUFFER_SIZE) {
+                flushBulkActions();
+            }
+        } else {
+            executeBlocking(action);
+        }
+    }
+
+    private void executeBlocking(Action<?> action) {
+        final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);
+        if (!result.isSucceeded()) {
+            if (result instanceof BulkResult) {
+                final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();
+                for (int i = 0; i < failedItems.size(); i++) {
+                    final BulkResultItem failedItem = failedItems.get(i);
+                    logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);
+                }
+            }
+            throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());
+        }
+    }
+
+    private Builder getBulkBuilder() {
+        if (bulkBuilder == null) {
+            bulkBuilder = new Bulk.Builder();
+            bulkBuilder.defaultIndex(getDataContext().getIndexName());
+        }
+        return bulkBuilder;
+    }
+}


[13/42] metamodel git commit: [maven-release-plugin] prepare for next development iteration

Posted by ka...@apache.org.
[maven-release-plugin] prepare for next development iteration


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/426396a3
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/426396a3
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/426396a3

Branch: refs/heads/5.x
Commit: 426396a3ba01ce6c1834b67498cbff36103c7c36
Parents: d6c8052
Author: Kasper S�rensen <i....@gmail.com>
Authored: Tue Feb 9 13:45:44 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Tue Feb 9 13:45:44 2016 +0100

----------------------------------------------------------------------
 cassandra/pom.xml            | 2 +-
 core/pom.xml                 | 2 +-
 couchdb/pom.xml              | 2 +-
 csv/pom.xml                  | 2 +-
 elasticsearch/common/pom.xml | 2 +-
 elasticsearch/native/pom.xml | 2 +-
 elasticsearch/pom.xml        | 2 +-
 elasticsearch/rest/pom.xml   | 2 +-
 excel/pom.xml                | 2 +-
 fixedwidth/pom.xml           | 2 +-
 full/pom.xml                 | 2 +-
 hadoop/pom.xml               | 2 +-
 hbase/pom.xml                | 2 +-
 jdbc/pom.xml                 | 2 +-
 json/pom.xml                 | 2 +-
 mongodb/common/pom.xml       | 2 +-
 mongodb/mongo2/pom.xml       | 2 +-
 mongodb/mongo3/pom.xml       | 2 +-
 mongodb/pom.xml              | 2 +-
 neo4j/pom.xml                | 2 +-
 openoffice/pom.xml           | 2 +-
 pojo/pom.xml                 | 2 +-
 pom.xml                      | 4 ++--
 salesforce/pom.xml           | 2 +-
 spring/pom.xml               | 2 +-
 sugarcrm/pom.xml             | 2 +-
 xml/pom.xml                  | 2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 1f9a461..be61f5b 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-cassandra</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index c91c638..dc98591 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-core</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index 06dca33..df359d8 100644
--- a/couchdb/pom.xml
+++ b/couchdb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-couchdb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index e50fd1e..b456d27 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-csv</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index b95a5a8..8315863 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 6aeb6c1..3929417 100644
--- a/elasticsearch/native/pom.xml
+++ b/elasticsearch/native/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index efd0771..8fa5ed9 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-elasticsearch</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index a2b6420..3ec49c3 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index e50cf54..17d5202 100644
--- a/excel/pom.xml
+++ b/excel/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-excel</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 56ebbc5..50bcf91 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-fixedwidth</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index adf3a98..e2528ba 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-full</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 7ce7307..a5fb978 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hadoop</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index a8ad0b1..dc44c09 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hbase</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 6a1fefe..d683641 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-jdbc</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 09e228a..2582cde 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-json</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index a3bd7b5..5b98d2b 100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-common</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 39370d4..5238cc2 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index c293890..ab315d8 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 22665c1..be1df79 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 4786787..7bec724 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-neo4j</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index 59e2fd2..dffa885 100644
--- a/openoffice/pom.xml
+++ b/openoffice/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-openoffice</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 647d951..b0b6cec 100644
--- a/pojo/pom.xml
+++ b/pojo/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-pojo</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 668b44a..9f3ba1d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
 		<url>https://git-wip-us.apache.org/repos/asf?p=metamodel.git</url>
 		<connection>scm:git:http://git-wip-us.apache.org/repos/asf/metamodel.git</connection>
 		<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/metamodel.git</developerConnection>
-		<tag>MetaModel-4.5.1</tag>
+		<tag>HEAD</tag>
 	</scm>
 	<groupId>org.apache.metamodel</groupId>
 	<artifactId>MetaModel</artifactId>
-	<version>4.5.1</version>
+	<version>4.5.2-SNAPSHOT</version>
 	<name>MetaModel</name>
 	<description>MetaModel is a library that encapsulates the differences and enhances 
 		the capabilities of different datastores. Rich querying abilities are

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 9ace7ed..6b1f959 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-salesforce</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index 266d26c..a6f6bb3 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-spring</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 083a1b2..9269ade 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-sugarcrm</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/426396a3/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 317a313..0506e51 100644
--- a/xml/pom.xml
+++ b/xml/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1</version>
+		<version>4.5.2-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-xml</artifactId>


[15/42] metamodel git commit: Closes #89

Posted by ka...@apache.org.
Closes #89


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/496a839a
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/496a839a
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/496a839a

Branch: refs/heads/5.x
Commit: 496a839a26add619dbc27adb5431acacfa025078
Parents: aeddd80
Author: Kasper S�rensen <i....@gmail.com>
Authored: Tue Mar 8 15:56:53 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Tue Mar 8 15:56:53 2016 +0100

----------------------------------------------------------------------

----------------------------------------------------------------------



[30/42] metamodel git commit: Added underscore to generated name's suffix

Posted by ka...@apache.org.
Added underscore to generated name's suffix

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/28cd2cd0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/28cd2cd0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/28cd2cd0

Branch: refs/heads/5.x
Commit: 28cd2cd07f4bd385fed81dab10df8cf369e33fd5
Parents: a2314f8
Author: kaspersorensen <i....@gmail.com>
Authored: Tue Apr 26 08:28:37 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Apr 26 08:28:37 2016 -0700

----------------------------------------------------------------------
 .../metamodel/schema/naming/UniqueColumnNamingStrategy.java      | 4 ++--
 .../metamodel/schema/naming/DefaultColumnNamingStrategyTest.java | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/28cd2cd0/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
index e5288fe..d4d21dd 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
@@ -25,7 +25,7 @@ import java.util.Set;
  * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
  * ensures that all column names are unique. When duplicate names are
  * encountered a number will be appended yielding column names like "name",
- * "name1", "name2" etc.
+ * "name_2", "name_3" etc.
  */
 public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
 
@@ -47,7 +47,7 @@ public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
 
                 String newName = null;
                 for (int i = 2; !unique; i++) {
-                    newName = intrinsicName + i;
+                    newName = intrinsicName + '_' + i;
                     unique = names.add(newName);
                 }
                 return newName;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/28cd2cd0/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
index c8c408b..a293939 100644
--- a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
+++ b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
@@ -34,7 +34,7 @@ public class DefaultColumnNamingStrategyTest {
         try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
             assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
             assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
-            assertEquals("foo2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
+            assertEquals("foo_2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
         }
     }
 


[26/42] metamodel git commit: METAMODEL-244: Scoped the column naming session and state into an object

Posted by ka...@apache.org.
METAMODEL-244: Scoped the column naming session and state into an object

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/d5b9e12a
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/d5b9e12a
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/d5b9e12a

Branch: refs/heads/5.x
Commit: d5b9e12a016e94af78cceeeaf966a226afe8650d
Parents: 0da8f1a
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Apr 24 13:32:15 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Apr 24 13:32:15 2016 -0700

----------------------------------------------------------------------
 .../builder/AlphabeticColumnNamingStrategy.java | 19 ++++++--
 .../schema/builder/ColumnNamingSession.java     | 47 ++++++++++++++++++++
 .../schema/builder/ColumnNamingStrategy.java    | 16 +++----
 ...tingIntrinsicSwitchColumnNamingStrategy.java | 28 +++++++++---
 .../builder/UniqueColumnNamingStrategy.java     | 40 +++++++++++------
 .../fixedwidth/FixedWidthDataContext.java       | 11 +++--
 6 files changed, 121 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/d5b9e12a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
index 83679a3..91d1b85 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
@@ -21,12 +21,23 @@ package org.apache.metamodel.schema.builder;
 import org.apache.metamodel.util.AlphabeticSequence;
 
 public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
-    
-    private final AlphabeticSequence seq = new AlphabeticSequence();
+
+    private static final long serialVersionUID = 1L;
 
     @Override
-    public String getNextColumnName(ColumnNamingContext ctx) {
-        return seq.next();
+    public ColumnNamingSession startColumnNamingSession() {
+        return new ColumnNamingSession() {
+            private final AlphabeticSequence seq = new AlphabeticSequence();
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                return seq.next();
+            }
+
+            @Override
+            public void close() {
+            }
+        };
     }
 
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d5b9e12a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java
new file mode 100644
index 0000000..2c6f7b2
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingSession.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+import java.io.Closeable;
+
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Table;
+
+/**
+ * Represents a 'session' in which a single {@link Table}'s {@link Column}s are
+ * named.
+ */
+public interface ColumnNamingSession extends Closeable {
+
+    /**
+     * Provides the name to apply for a given column.
+     * 
+     * @param ctx
+     *            the context of the column naming taking place. This contains
+     *            column index, intrinsic name etc. if available.
+     * @return the name to provide to the column.
+     */
+    public String getNextColumnName(ColumnNamingContext ctx);
+
+    /**
+     * Ends the column naming session.
+     */
+    @Override
+    public void close();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d5b9e12a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
index 4923c58..2219fb7 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
@@ -18,20 +18,14 @@
  */
 package org.apache.metamodel.schema.builder;
 
+import java.io.Serializable;
+
 /**
  * A strategy that defines how columns are logically named. Such strategies are
  * mostly used when a particular datastore is not itself intrinsically
  * specifying the column name.
  */
-public interface ColumnNamingStrategy {
-
-    /**
-     * Provides the name to apply for a given column.
-     * 
-     * @param ctx
-     *            the context of the column naming taking place. This contains
-     *            column index, intrinsic name etc. if available.
-     * @return the name to provide to the column.
-     */
-    public String getNextColumnName(ColumnNamingContext ctx);
+public interface ColumnNamingStrategy extends Serializable {
+    
+    public ColumnNamingSession startColumnNamingSession();
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d5b9e12a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
index 99cdaf5..612f81d 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@ -25,6 +25,7 @@ package org.apache.metamodel.schema.builder;
  */
 public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
 
+    private static final long serialVersionUID = 1L;
     private final ColumnNamingStrategy intrinsicStrategy;
     private final ColumnNamingStrategy nonIntrinsicStrategy;
 
@@ -35,12 +36,25 @@ public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNami
     }
 
     @Override
-    public String getNextColumnName(ColumnNamingContext ctx) {
-        final String intrinsicColumnName = ctx.getIntrinsicColumnName();
-        if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
-            return nonIntrinsicStrategy.getNextColumnName(ctx);
-        }
-        return intrinsicStrategy.getNextColumnName(ctx);
-    }
+    public ColumnNamingSession startColumnNamingSession() {
+        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
+        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
+        return new ColumnNamingSession() {
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                final String intrinsicColumnName = ctx.getIntrinsicColumnName();
+                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
+                    return nonIntrinsicSession.getNextColumnName(ctx);
+                }
+                return intrinsicSession.getNextColumnName(ctx);
+            }
 
+            @Override
+            public void close() {
+                intrinsicSession.close();
+                nonIntrinsicSession.close();
+            }
+        };
+    }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d5b9e12a/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
index 9371059..17e7830 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
@@ -29,22 +29,34 @@ import java.util.Set;
  */
 public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
 
-    private final Set<String> names = new HashSet<>();
+    private static final long serialVersionUID = 1L;
 
     @Override
-    public String getNextColumnName(ColumnNamingContext ctx) {
-        final String intrinsicName = ctx.getIntrinsicColumnName();
-        boolean unique = names.add(intrinsicName);
-        if (unique) {
-            return intrinsicName;
-        }
-
-        String newName = null;
-        for (int i = 2; !unique; i++) {
-            newName = intrinsicName + i;
-            unique = names.add(newName);
-        }
-        return newName;
+    public ColumnNamingSession startColumnNamingSession() {
+        return new ColumnNamingSession() {
+
+            private final Set<String> names = new HashSet<>();
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                final String intrinsicName = ctx.getIntrinsicColumnName();
+                boolean unique = names.add(intrinsicName);
+                if (unique) {
+                    return intrinsicName;
+                }
+
+                String newName = null;
+                for (int i = 2; !unique; i++) {
+                    newName = intrinsicName + i;
+                    unique = names.add(newName);
+                }
+                return newName;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
     }
 
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d5b9e12a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
index 0a326cc..25a8457 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
@@ -34,6 +34,7 @@ import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.Table;
 import org.apache.metamodel.schema.TableType;
 import org.apache.metamodel.schema.builder.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.builder.ColumnNamingSession;
 import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 import org.apache.metamodel.util.FileResource;
@@ -134,10 +135,12 @@ public class FixedWidthDataContext extends QueryPostprocessDataContext {
             }
             final ColumnNamingStrategy columnNamingStrategy = _configuration.getColumnNamingStrategy();
             if (columnNames != null) {
-                for (int i = 0; i < columnNames.length; i++) {
-                    final String intrinsicColumnName = hasColumnHeader ? columnNames[i] : null;
-                    columnNames[i] = columnNamingStrategy.getNextColumnName(new ColumnNamingContextImpl(table,
-                            intrinsicColumnName, i));
+                try (final ColumnNamingSession columnNamingSession = columnNamingStrategy.startColumnNamingSession()) {
+                    for (int i = 0; i < columnNames.length; i++) {
+                        final String intrinsicColumnName = hasColumnHeader ? columnNames[i] : null;
+                        columnNames[i] = columnNamingSession.getNextColumnName(new ColumnNamingContextImpl(table,
+                                intrinsicColumnName, i));
+                    }
                 }
             }
         } finally {


[17/42] metamodel git commit: Fixes 'mvn javadoc:javadoc' errors with Java 8 javadoc linter

Posted by ka...@apache.org.
Fixes 'mvn javadoc:javadoc' errors with Java 8 javadoc linter

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/60a4c56e
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/60a4c56e
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/60a4c56e

Branch: refs/heads/5.x
Commit: 60a4c56e1043b8981f90b9b4d28c7772c7d370a9
Parents: 8ea5ef5
Author: Kasper S�rensen <i....@gmail.com>
Authored: Thu Mar 10 20:16:27 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Thu Mar 10 20:16:27 2016 +0100

----------------------------------------------------------------------
 .travis.yml                                             |  2 +-
 .../src/main/java/org/apache/metamodel/DataContext.java |  2 +-
 .../org/apache/metamodel/convert/TypeConverter.java     |  2 +-
 .../main/java/org/apache/metamodel/data/DefaultRow.java |  2 +-
 .../java/org/apache/metamodel/query/OperatorType.java   |  2 +-
 .../org/apache/metamodel/query/OperatorTypeImpl.java    |  4 ++--
 .../metamodel/query/builder/SatisfiedQueryBuilder.java  |  2 +-
 .../main/java/org/apache/metamodel/schema/Schema.java   |  2 +-
 .../main/java/org/apache/metamodel/schema/Table.java    |  2 +-
 .../java/org/apache/metamodel/util/FormatHelper.java    |  2 +-
 .../org/apache/metamodel/util/SimpleTableDefParser.java |  4 ----
 .../nativeclient/ElasticSearchDataContext.java          |  4 ++--
 .../rest/ElasticSearchRestDataContext.java              |  4 ++--
 .../metamodel/jdbc/dialects/AbstractQueryRewriter.java  |  1 -
 .../apache/metamodel/mongodb/common/MongoDBUtils.java   |  2 +-
 .../metamodel/mongodb/common/MongoDbTableDef.java       |  4 ++--
 .../metamodel/mongodb/mongo3/MongoDbDataContext.java    | 12 ++++++------
 pom.xml                                                 |  5 +----
 sugarcrm/pom.xml                                        |  7 +++++++
 .../org/apache/metamodel/xml/XmlDomDataContext.java     |  4 ++--
 20 files changed, 34 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 14f8734..46a372d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,7 +16,7 @@ services:
   - mongodb
   
 after_success:
-  - mvn test
+  - mvn test javadoc:javadoc
  
 notifications:
   email: false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/DataContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/DataContext.java b/core/src/main/java/org/apache/metamodel/DataContext.java
index 28d5921..132ecfb 100644
--- a/core/src/main/java/org/apache/metamodel/DataContext.java
+++ b/core/src/main/java/org/apache/metamodel/DataContext.java
@@ -163,7 +163,7 @@ public interface DataContext {
      * {@link #parseQuery(String)} and then {@link #executeQuery(Query)} with
      * the parsed query.
      * 
-     * @param query
+     * @param queryString
      *            the SQL query to parse
      * @return the {@link DataSet} produced from executing the query
      * @throws MetaModelException

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/convert/TypeConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/convert/TypeConverter.java b/core/src/main/java/org/apache/metamodel/convert/TypeConverter.java
index e49345e..48ccca0 100644
--- a/core/src/main/java/org/apache/metamodel/convert/TypeConverter.java
+++ b/core/src/main/java/org/apache/metamodel/convert/TypeConverter.java
@@ -22,7 +22,7 @@ package org.apache.metamodel.convert;
  * Defines an interface for converting values from and to their physical
  * materializations and their virtual representations.
  * 
- * @see ConvertedDataContext
+ * @see Converters
  * 
  * @param <P>
  *            the physical type of value

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/data/DefaultRow.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/data/DefaultRow.java b/core/src/main/java/org/apache/metamodel/data/DefaultRow.java
index 7ca1dfc..0e1fdf7 100644
--- a/core/src/main/java/org/apache/metamodel/data/DefaultRow.java
+++ b/core/src/main/java/org/apache/metamodel/data/DefaultRow.java
@@ -194,7 +194,7 @@ public final class DefaultRow extends AbstractRow implements Row {
     /**
      * Method invoked by the Java serialization framework while deserializing
      * Row instances. Since previous versions of MetaModel did not use a
-     * DataSetHeader, but had a reference to a List<SelectItem>, this
+     * DataSetHeader, but had a reference to a List&lt;SelectItem&gt;, this
      * deserialization is particularly tricky. We check if the items variable is
      * there, and if it is, we convert it to a header instead.
      * 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/query/OperatorType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/OperatorType.java b/core/src/main/java/org/apache/metamodel/query/OperatorType.java
index 65f54b3..8c267d6 100644
--- a/core/src/main/java/org/apache/metamodel/query/OperatorType.java
+++ b/core/src/main/java/org/apache/metamodel/query/OperatorType.java
@@ -48,7 +48,7 @@ public interface OperatorType extends Serializable {
 
 /**
      * Determines if this operator requires a space delimitor. Operators that are written using letters usually require
-     * space delimitation whereas sign-based operators such as "=" and "<" can be applied even without any delimitaton.
+     * space delimitation whereas sign-based operators such as "=" and "&lt;" can be applied even without any delimitaton.
      * 
      * @return
      */

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java b/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
index a48b337..0eafe7d 100644
--- a/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
+++ b/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
@@ -65,8 +65,8 @@ public class OperatorTypeImpl implements OperatorType {
     }
 
 /**
-     * Converts from SQL string literals to an OperatorType. Valid SQL values are "=", "<>", "LIKE", ">", ">=", "<" and
-     * "<=".
+     * Converts from SQL string literals to an OperatorType. Valid SQL values are "=", "&lt;&gt;", "LIKE", "&gt;", "&gt;=", "&lt;" and
+     * "&lt;=".
      *
      * @param sqlType
      * @return a OperatorType object representing the specified SQL type

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/query/builder/SatisfiedQueryBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/SatisfiedQueryBuilder.java b/core/src/main/java/org/apache/metamodel/query/builder/SatisfiedQueryBuilder.java
index 1b62de9..e6b0670 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/SatisfiedQueryBuilder.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/SatisfiedQueryBuilder.java
@@ -65,7 +65,7 @@ public interface SatisfiedQueryBuilder<B extends SatisfiedQueryBuilder<?>> {
     /**
      * Sets the limit (aka. max rows) of the query that is being built.
      * 
-     * @param maxRows
+     * @param limit
      * @return
      */
     public SatisfiedQueryBuilder<B> limit(int limit);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/schema/Schema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/Schema.java b/core/src/main/java/org/apache/metamodel/schema/Schema.java
index 903b640..1184954 100644
--- a/core/src/main/java/org/apache/metamodel/schema/Schema.java
+++ b/core/src/main/java/org/apache/metamodel/schema/Schema.java
@@ -89,7 +89,7 @@ public interface Schema extends Comparable<Schema>, Serializable, NamedStructure
 	 * @return the column with the specified index
 	 * 
 	 * @throws IndexOutOfBoundsException
-	 *             if the index is out of bounds (index >= table count)
+	 *             if the index is out of bounds (index &gt;= table count)
 	 */
 	public Table getTable(int index) throws IndexOutOfBoundsException;
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/schema/Table.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/Table.java b/core/src/main/java/org/apache/metamodel/schema/Table.java
index a36b6e6..f5c6680 100644
--- a/core/src/main/java/org/apache/metamodel/schema/Table.java
+++ b/core/src/main/java/org/apache/metamodel/schema/Table.java
@@ -69,7 +69,7 @@ public interface Table extends Comparable<Table>, Serializable, NamedStructure {
      *            the index of the column
      * @return the column with the specified index
      * @throws IndexOutOfBoundsException
-     *             if the index is out of bounds (index >= column count)
+     *             if the index is out of bounds (index &gt;= column count)
      */
     public Column getColumn(int index) throws IndexOutOfBoundsException;
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/util/FormatHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/util/FormatHelper.java b/core/src/main/java/org/apache/metamodel/util/FormatHelper.java
index cd92949..6eff30f 100644
--- a/core/src/main/java/org/apache/metamodel/util/FormatHelper.java
+++ b/core/src/main/java/org/apache/metamodel/util/FormatHelper.java
@@ -150,7 +150,7 @@ public final class FormatHelper {
     /**
      * Parses a SQL string representation of a time based value
      * 
-     * @param type
+     * @param columnType
      * @param value
      * @return
      */

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/core/src/main/java/org/apache/metamodel/util/SimpleTableDefParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/util/SimpleTableDefParser.java b/core/src/main/java/org/apache/metamodel/util/SimpleTableDefParser.java
index 7239321..3df1489 100644
--- a/core/src/main/java/org/apache/metamodel/util/SimpleTableDefParser.java
+++ b/core/src/main/java/org/apache/metamodel/util/SimpleTableDefParser.java
@@ -29,8 +29,6 @@ public class SimpleTableDefParser {
     /**
      * Parses an array of table definitions.
      * 
-     * @see #setTableDefinitions(String)
-     * 
      * @param tableDefinitionsText
      * @return
      */
@@ -61,8 +59,6 @@ public class SimpleTableDefParser {
     /**
      * Parses a single table definition
      * 
-     * @see #setTableDefinitions(String)
-     * 
      * @param tableDefinitionText
      * @return
      */

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java
----------------------------------------------------------------------
diff --git a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java
index 8232394..acd0c36 100644
--- a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java
+++ b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java
@@ -125,7 +125,7 @@ public class ElasticSearchDataContext extends QueryPostprocessDataContext implem
     /**
      * Constructs a {@link ElasticSearchDataContext} and automatically detects
      * the schema structure/view on all indexes (see
-     * {@link this.detectSchema(Client, String)}).
+     * {@link #detectTable(ClusterState, String, String)}).
      *
      * @param client
      *            the ElasticSearch client
@@ -141,7 +141,7 @@ public class ElasticSearchDataContext extends QueryPostprocessDataContext implem
      * {@link Client} instance and detects the elasticsearch types structure
      * based on the metadata provided by the ElasticSearch java client.
      *
-     * @see #detectTable(ClusterState, String, String)
+     * @see {@link #detectTable(ClusterState, String, String)}
      * @return a mutable schema instance, useful for further fine tuning by the
      *         user.
      */

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
index 2219b89..6b8ac51 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
@@ -129,7 +129,7 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
     /**
      * Constructs a {@link ElasticSearchRestDataContext} and automatically detects
      * the schema structure/view on all indexes (see
-     * {@link this.detectSchema(JestClient, String)}).
+     * {@link #detectTable(JsonObject, String)}).
      *
      * @param client
      *            the ElasticSearch client
@@ -145,7 +145,7 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
      * {@link JestClient} instance and detects the elasticsearch types structure
      * based on the metadata provided by the ElasticSearch java client.
      *
-     * @see #detectTable(JsonObject, String)
+     * @see {@link #detectTable(JsonObject, String)}
      * @return a mutable schema instance, useful for further fine tuning by the
      *         user.
      */

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/AbstractQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/AbstractQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/AbstractQueryRewriter.java
index f4f50aa..087bf2f 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/AbstractQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/AbstractQueryRewriter.java
@@ -93,7 +93,6 @@ public abstract class AbstractQueryRewriter implements IQueryRewriter {
      * related. Cloning the query before modifying is recommended in order to
      * not violate referential integrity of clients (the query is mutable).
      * 
-     * @param strategy
      * @param query
      * @return the modified query
      */

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
----------------------------------------------------------------------
diff --git a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
index f7a5729..f1215ab 100644
--- a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
+++ b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDBUtils.java
@@ -57,7 +57,7 @@ public class MongoDBUtils {
     /**
      * Converts a map into MetaModel. This map stores data of a MongoDB document.
      * 
-     * @param dbObject
+     * @param map
      *            a map object storing data of a MongoDB document.
      * @param header
      *            a header describing the columns of the data stored.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
----------------------------------------------------------------------
diff --git a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
index 9bb6174..7805b53 100644
--- a/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
+++ b/mongodb/common/src/main/java/org/apache/metamodel/mongodb/common/MongoDbTableDef.java
@@ -24,8 +24,8 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.SimpleTableDef;
 
 /**
- * Defines a table layout for {@link MongoDbDataContext} tables. This class can
- * be used as an instruction set for the {@link MongoDbDataContext} to specify
+ * Defines a table layout for MongoDB tables. This class can
+ * be used as an instruction set for the MongoDB DataContext implementations to specify
  * which collections, which columns (and their types) should be included in the
  * schema structure of a Mongo DB database.
  * 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
index 1595a28..fbc9047 100644
--- a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
@@ -72,7 +72,7 @@ import com.mongodb.client.MongoIterable;
  * Since MongoDB has no schema, a virtual schema will be used in this
  * DataContext. This implementation supports either automatic discovery of a
  * schema or manual specification of a schema, through the
- * {@link MongoDbTableDef} class.
+ * {@link SimpleTableDef} class.
  */
 public class MongoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext {
 
@@ -85,15 +85,15 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
 
     /**
      * Constructs a {@link MongoDbDataContext}. This constructor accepts a
-     * custom array of {@link MongoDbTableDef}s which allows the user to define
+     * custom array of {@link SimpleTableDef}s which allows the user to define
      * his own view on the collections in the database.
      *
      * @param mongoDb
      *            the mongo db connection
      * @param tableDefs
-     *            an array of {@link MongoDbTableDef}s, which define the table
+     *            an array of {@link SimpleTableDef}s, which define the table
      *            and column model of the mongo db collections. (consider using
-     *            {@link #detectSchema(DB)} or {@link #detectTable(DB, String)}
+     *            {@link #detectSchema(MongoDatabase)} or {@link #detectTable(MongoDatabase, String)}
      *            ).
      */
     public MongoDbDataContext(MongoDatabase mongoDb, SimpleTableDef... tableDefs) {
@@ -104,7 +104,7 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
 
     /**
      * Constructs a {@link MongoDbDataContext} and automatically detects the
-     * schema structure/view on all collections (see {@link #detectSchema(DB)}).
+     * schema structure/view on all collections (see {@link #detectSchema(MongoDatabase)}).
      *
      * @param mongoDb
      *            the mongo db connection
@@ -122,7 +122,7 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
      *            the mongo db to inspect
      * @return a mutable schema instance, useful for further fine tuning by the
      *         user.
-     * @see #detectTable(DB, String)
+     * @see #detectTable(MongoDatabase, String)
      */
     public static SimpleTableDef[] detectSchema(MongoDatabase mongoDb) {
         MongoIterable<String> collectionNames = mongoDb.listCollectionNames();

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9f3ba1d..61a735c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@ under the License.
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<sshwagon.version>2.6</sshwagon.version>
-		<javadoc.version>2.9.1</javadoc.version>
+		<javadoc.version>2.10.3</javadoc.version>
 		<slf4j.version>1.7.7</slf4j.version>
 		<junit.version>4.11</junit.version>
 		<guava.version>16.0.1</guava.version>
@@ -246,9 +246,6 @@ under the License.
 							<goal>aggregate</goal>
 						</goals>
 						<phase>site</phase>
-						<configuration>
-							<excludePackageNames>org.apache.metamodel.jdbc.dialects:org.apache.metamodel.detect</excludePackageNames>
-						</configuration>
 					</execution>
 				</executions>
 			</plugin>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 9269ade..0754669 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -95,6 +95,13 @@ under the License.
 					</execution>
 				</executions>
 			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-javadoc-plugin</artifactId>
+				<configuration>
+					<excludePackageNames>com.sugarcrm.ws.soap</excludePackageNames>
+				</configuration>
+			</plugin>
 		</plugins>
 
 		<pluginManagement>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/60a4c56e/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java
----------------------------------------------------------------------
diff --git a/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java b/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java
index 4c1b5e4..c71d8ca 100644
--- a/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java
+++ b/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java
@@ -122,8 +122,8 @@ public class XmlDomDataContext extends QueryPostprocessDataContext {
     /**
      * Creates an XML DataContext strategy based on a file.
      * 
-     * @param file
-     *            the file to parse
+     * @param resource
+     *            the resource to parse
      * @param autoFlattenTables
      *            a parameter indicating whether or not tags with only text
      *            content or a single attribute should be flattened with it's


[37/42] metamodel git commit: Update CHANGES.md

Posted by ka...@apache.org.
Update CHANGES.md

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/161b6428
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/161b6428
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/161b6428

Branch: refs/heads/5.x
Commit: 161b64285dd4c62e62840a036cade510adf99008
Parents: 0af76cc
Author: Tomasz Guzialek <to...@guzialek.info>
Authored: Tue May 3 17:47:27 2016 +0200
Committer: Tomasz Guzialek <to...@guzialek.info>
Committed: Tue May 3 17:47:27 2016 +0200

----------------------------------------------------------------------
 CHANGES.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/161b6428/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index dd03195..2bb7572 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,6 +5,7 @@
  * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
  * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
  * [METAMODEL-247] - Added FixedWidthConfigurationReader for reading fixed width file metadata from external files.
+ * [METAMODEL-159] - DataContextFactory misses methods to create HBase and POJO data contexts
 
 ### Apache MetaModel 4.5.2
 


[32/42] metamodel git commit: Moved test to DelegatingIntrinsicSwitchColumnNamingStrategyTest

Posted by ka...@apache.org.
Moved test to DelegatingIntrinsicSwitchColumnNamingStrategyTest

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/41075909
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/41075909
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/41075909

Branch: refs/heads/5.x
Commit: 410759094569f6e12850eb7b24eee8eaf29e0da9
Parents: c1e1d52
Author: kaspersorensen <i....@gmail.com>
Authored: Tue Apr 26 12:39:03 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Apr 26 12:39:03 2016 -0700

----------------------------------------------------------------------
 .../naming/DefaultColumnNamingStrategyTest.java | 46 ------------------
 ...IntrinsicSwitchColumnNamingStrategyTest.java | 51 ++++++++++++++++++++
 2 files changed, 51 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/41075909/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
deleted file mode 100644
index eb618c2..0000000
--- a/core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema.naming;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class DefaultColumnNamingStrategyTest {
-
-    private final ColumnNamingStrategy namingStrategy = ColumnNamingStrategies.defaultStrategy();
-
-    @Test
-    public void testDuplicateColumnNames() throws Exception {
-        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
-            assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
-            assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
-            assertEquals("foo_2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
-        }
-    }
-
-    @Test
-    public void testNoIntrinsicColumnNames() throws Exception {
-        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
-            assertEquals("A", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 0)));
-            assertEquals("B", session.getNextColumnName(new ColumnNamingContextImpl(null, null, 1)));
-            assertEquals("C", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 2)));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/41075909/core/src/test/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategyTest.java
new file mode 100644
index 0000000..a10ec7c
--- /dev/null
+++ b/core/src/test/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategyTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class DelegatingIntrinsicSwitchColumnNamingStrategyTest {
+
+    private final ColumnNamingStrategy namingStrategy = ColumnNamingStrategies.defaultStrategy();
+    
+    @Test
+    public void testItIsTheDefaultStrategy() throws Exception {
+        assertTrue(namingStrategy instanceof DelegatingIntrinsicSwitchColumnNamingStrategy);
+    }
+
+    @Test
+    public void testDuplicateColumnNames() throws Exception {
+        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
+            assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
+            assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
+            assertEquals("foo_2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
+        }
+    }
+
+    @Test
+    public void testNoIntrinsicColumnNames() throws Exception {
+        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
+            assertEquals("A", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 0)));
+            assertEquals("B", session.getNextColumnName(new ColumnNamingContextImpl(null, null, 1)));
+            assertEquals("C", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 2)));
+        }
+    }
+}


[42/42] metamodel git commit: Merge branch 'master' into 5.x

Posted by ka...@apache.org.
Merge branch 'master' into 5.x

Conflicts:
	CHANGES.md
	cassandra/pom.xml
	core/pom.xml
	couchdb/pom.xml
	csv/pom.xml
	elasticsearch/common/pom.xml
	elasticsearch/native/pom.xml
	elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java
	elasticsearch/pom.xml
	elasticsearch/rest/pom.xml
	elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
	excel/pom.xml
	fixedwidth/pom.xml
	full/pom.xml
	hadoop/pom.xml
	hbase/pom.xml
	jdbc/pom.xml
	json/pom.xml
	mongodb/pom.xml
	mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataContext.java
	neo4j/pom.xml
	openoffice/pom.xml
	pojo/pom.xml
	pom.xml
	salesforce/pom.xml
	spring/pom.xml
	sugarcrm/pom.xml
	xml/pom.xml


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/6d50f0e3
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/6d50f0e3
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/6d50f0e3

Branch: refs/heads/5.x
Commit: 6d50f0e310f58a7278ef0f4c3b3e090f22707fb6
Parents: 9522663 2e39b50
Author: kaspersorensen <i....@gmail.com>
Authored: Sun May 15 20:40:06 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Sun May 15 20:51:27 2016 -0700

----------------------------------------------------------------------
 .gitignore                                      |   2 +-
 .travis.yml                                     |   2 +-
 CHANGES.md                                      |  22 +
 .../java/org/apache/metamodel/DataContext.java  |   2 +-
 .../apache/metamodel/convert/TypeConverter.java |   2 +-
 .../org/apache/metamodel/data/DefaultRow.java   |   2 +-
 .../query/AverageAggregateFunction.java         |   2 +
 .../metamodel/query/CountAggregateFunction.java |   2 +
 .../query/DefaultAggregateFunction.java         |   2 +
 .../metamodel/query/DefaultScalarFunction.java  |   2 +
 .../metamodel/query/FirstAggregateFunction.java |   2 +
 .../apache/metamodel/query/FunctionType.java    |   4 +-
 .../metamodel/query/LastAggregateFunction.java  |   2 +
 .../metamodel/query/MapValueFunction.java       |   2 +
 .../metamodel/query/MaxAggregateFunction.java   |   2 +
 .../metamodel/query/MinAggregateFunction.java   |   2 +
 .../apache/metamodel/query/OperatorType.java    |   6 +-
 .../metamodel/query/OperatorTypeImpl.java       |   6 +-
 .../query/RandomAggregateFunction.java          |   2 +
 .../metamodel/query/SumAggregateFunction.java   |   2 +
 .../metamodel/query/ToBooleanFunction.java      |   2 +
 .../apache/metamodel/query/ToDateFunction.java  |   2 +
 .../metamodel/query/ToNumberFunction.java       |   2 +
 .../metamodel/query/ToStringFunction.java       |   2 +
 .../query/builder/SatisfiedQueryBuilder.java    |   2 +-
 .../apache/metamodel/schema/ColumnTypeImpl.java |   4 +-
 .../org/apache/metamodel/schema/Schema.java     |   2 +-
 .../java/org/apache/metamodel/schema/Table.java |   2 +-
 .../naming/AlphabeticColumnNamingStrategy.java  |  43 ++
 .../schema/naming/ColumnNamingContext.java      |  52 ++
 .../schema/naming/ColumnNamingContextImpl.java  |  64 ++
 .../schema/naming/ColumnNamingSession.java      |  47 ++
 .../schema/naming/ColumnNamingStrategies.java   |  45 ++
 .../schema/naming/ColumnNamingStrategy.java     |  31 +
 .../naming/CustomColumnNamingStrategy.java      |  62 ++
 ...tingIntrinsicSwitchColumnNamingStrategy.java |  60 ++
 .../naming/UniqueColumnNamingStrategy.java      |  62 ++
 .../org/apache/metamodel/util/FormatHelper.java |   2 +-
 .../LegacyDeserializationObjectInputStream.java |   2 +-
 .../metamodel/util/SimpleTableDefParser.java    |   4 -
 .../metamodel/query/parser/QueryParserTest.java |   7 +
 .../metamodel/schema/ColumnTypeImplTest.java    |  95 +++
 .../apache/metamodel/schema/ColumnTypeTest.java |  92 ---
 ...IntrinsicSwitchColumnNamingStrategyTest.java |  51 ++
 .../couchdb/CouchDbDataContextTest.java         |  19 +-
 .../apache/metamodel/csv/CsvConfiguration.java  |  24 +-
 .../java/org/apache/metamodel/csv/CsvTable.java |  26 +-
 .../org/apache/metamodel/csv/CsvWriter.java     |  37 +-
 .../org/apache/metamodel/csv/CsvWriterTest.java |  43 ++
 .../common/ElasticSearchUtils.java              |  91 ++-
 .../ElasticSearchCreateTableBuilder.java        |  10 +-
 .../nativeclient/ElasticSearchDataContext.java  |   6 +-
 .../nativeclient/NativeElasticSearchUtils.java  |   3 +-
 elasticsearch/rest/pom.xml                      |   2 +-
 .../rest/ElasticSearchRestDataContext.java      |  12 +-
 .../JestElasticSearchCreateTableBuilder.java    |  20 +-
 .../rest/JestElasticSearchDataSet.java          |   2 +-
 .../rest/JestElasticSearchDeleteBuilder.java    |   2 +-
 .../rest/JestElasticSearchDropTableBuilder.java |   5 +-
 .../rest/JestElasticSearchInsertBuilder.java    |  33 +-
 .../rest/JestElasticSearchUpdateCallback.java   |  89 ++-
 .../rest/JestElasticSearchUtils.java            |  24 +-
 .../rest/JestElasticSearchUtilsTest.java        | 132 +++-
 .../excel/DefaultSpreadsheetReaderDelegate.java |  45 +-
 .../metamodel/excel/ExcelConfiguration.java     |  31 +-
 .../metamodel/excel/ExcelDataContext.java       |   4 +-
 .../excel/XlsxSpreadsheetReaderDelegate.java    |  60 +-
 .../metamodel/excel/ExcelDataContextTest.java   |   4 +-
 fixedwidth/pom.xml                              |   6 +
 .../fixedwidth/FixedWidthColumnSpec.java        |  45 ++
 .../fixedwidth/FixedWidthConfiguration.java     |  88 ++-
 .../FixedWidthConfigurationReader.java          | 180 ++++++
 .../fixedwidth/FixedWidthDataContext.java       |  26 +-
 .../FixedWidthConfigurationReaderTest.java      |  89 +++
 .../src/test/resources/metadata_spec1/data.txt  |   5 +
 .../metadata_spec1/sas-formatfile-metadata.txt  |   4 +
 .../metadata_spec1/sas-input-metadata.txt       |  19 +
 full/pom.xml                                    |   7 +-
 .../apache/metamodel/DataContextFactory.java    | 105 ++-
 .../metamodel/jdbc/JdbcMetadataLoader.java      |  19 +
 .../jdbc/dialects/AbstractQueryRewriter.java    |   1 -
 .../jdbc/dialects/DB2QueryRewriter.java         |   4 +-
 .../dialects/DB2QueryRewriterTest.java          |   6 +
 mongodb/common/pom.xml                          |  67 ++
 .../metamodel/mongodb/common/MongoDBUtils.java  |  93 +++
 .../mongodb/common/MongoDbTableDef.java         |  46 ++
 mongodb/mongo2/pom.xml                          |  70 ++
 .../mongo2/DefaultWriteConcernAdvisor.java      |  32 +
 .../mongodb/mongo2/MongoDbDataContext.java      | 530 ++++++++++++++++
 .../mongodb/mongo2/MongoDbDataSet.java          |  84 +++
 .../mongodb/mongo2/MongoDbDeleteBuilder.java    |  56 ++
 .../mongodb/mongo2/MongoDbDropTableBuilder.java |  43 ++
 .../mongodb/mongo2/MongoDbInsertionBuilder.java |  64 ++
 .../mongo2/MongoDbTableCreationBuilder.java     |  57 ++
 .../mongodb/mongo2/MongoDbUpdateCallback.java   | 115 ++++
 .../mongo2/SimpleWriteConcernAdvisor.java       |  50 ++
 .../mongodb/mongo2/WriteConcernAdvisor.java     |  35 +
 .../metamodel/mongodb/mongo2/package-info.java  |  23 +
 .../mongodb/mongo2/MongoDbDataContextTest.java  | 635 ++++++++++++++++++
 .../mongodb/mongo2/MongoDbDataCopyer.java       | 124 ++++
 .../mongodb/mongo2/MongoDbTestCase.java         | 111 ++++
 mongodb/mongo3/pom.xml                          |  70 ++
 .../mongo3/DefaultWriteConcernAdvisor.java      |  32 +
 .../mongodb/mongo3/MongoDbDataContext.java      | 547 ++++++++++++++++
 .../mongodb/mongo3/MongoDbDataSet.java          |  84 +++
 .../mongodb/mongo3/MongoDbDeleteBuilder.java    |  53 ++
 .../mongodb/mongo3/MongoDbDropTableBuilder.java |  43 ++
 .../mongodb/mongo3/MongoDbInsertionBuilder.java |  63 ++
 .../mongo3/MongoDbTableCreationBuilder.java     |  57 ++
 .../mongodb/mongo3/MongoDbUpdateCallback.java   | 119 ++++
 .../mongo3/SimpleWriteConcernAdvisor.java       |  51 ++
 .../mongodb/mongo3/WriteConcernAdvisor.java     |  36 ++
 .../metamodel/mongodb/mongo3/package-info.java  |  23 +
 .../mongodb/mongo3/MongoDbDataContextTest.java  | 613 ++++++++++++++++++
 .../mongodb/mongo3/MongoDbDataCopyer.java       | 127 ++++
 .../mongodb/mongo3/MongoDbTestCase.java         | 111 ++++
 mongodb/pom.xml                                 |  45 +-
 .../mongodb/DefaultWriteConcernAdvisor.java     |  32 -
 .../apache/metamodel/mongodb/MongoDBUtils.java  |  77 ---
 .../metamodel/mongodb/MongoDbDataContext.java   | 529 ---------------
 .../metamodel/mongodb/MongoDbDataSet.java       |  83 ---
 .../metamodel/mongodb/MongoDbDeleteBuilder.java |  56 --
 .../mongodb/MongoDbDropTableBuilder.java        |  43 --
 .../mongodb/MongoDbInsertionBuilder.java        |  64 --
 .../mongodb/MongoDbTableCreationBuilder.java    |  57 --
 .../metamodel/mongodb/MongoDbTableDef.java      |  46 --
 .../mongodb/MongoDbUpdateCallback.java          | 115 ----
 .../mongodb/SimpleWriteConcernAdvisor.java      |  50 --
 .../metamodel/mongodb/WriteConcernAdvisor.java  |  35 -
 .../apache/metamodel/mongodb/package-info.java  |  23 -
 .../mongodb/MongoDbDataContextTest.java         | 636 -------------------
 .../metamodel/mongodb/MongoDbDataCopyer.java    | 124 ----
 .../metamodel/mongodb/MongoDbTestCase.java      | 111 ----
 .../metamodel/neo4j/Neo4jDataContext.java       |   4 +-
 .../metamodel/neo4j/Neo4jDataContextTest.java   |  10 +
 .../pojo/ObjectTableDataProviderTest.java       |   2 +-
 pom.xml                                         |   8 +-
 .../MongoDbDataContextFactoryBeanDelegate.java  |   2 +-
 .../apache/metamodel/xml/XmlDomDataContext.java |   4 +-
 139 files changed, 6092 insertions(+), 2463 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/.travis.yml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/CHANGES.md
----------------------------------------------------------------------
diff --cc CHANGES.md
index 388bfb1,66d1917..a103d91
--- a/CHANGES.md
+++ b/CHANGES.md
@@@ -1,8 -1,25 +1,30 @@@
 +### Apache MetaModel 5.0
 +
 + * [METAMODEL-6] - Added update summary containing information about changes on returning UpdateableDataContext.executeUpdate(..)
 + * [METAMODEL-222] - Added support for Java 8 lambdas, removed support for Java 7.
 +
+ ### Apache MetaModel 4.5.3 (work in progress)
+ 
+  * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
+  * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
+  * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
+  * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
+  * [METAMODEL-247] - Added FixedWidthConfigurationReader for reading fixed width file metadata from external files.
+  * [METAMODEL-159] - DataContextFactory misses methods to create HBase and POJO data contexts.
+  * [METAMODEL-252] - Fixed a bug that caused JDBC updates to unnecessarily refresh schema objects.
+  * [METAMODEL-1082] - Improved performance of batch ElasticSearch operations by using bulk API.
+ 
+ ### Apache MetaModel 4.5.2
+ 
+  * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.
+ 
+ ### Apache MetaModel 4.5.1
+ 
+  * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
+  * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
+  * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
+  * [METAMODEL-228] - Fixed a bug causing Number.class to not be converted to ColumnType.NUMBER.
+ 
  ### Apache MetaModel 4.5.0
  
   * [METAMODEL-212] - New module for ElasticSearch via REST client.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
index 0000000,f6575c7..34498de
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
@@@ -1,0 -1,43 +1,43 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import org.apache.metamodel.util.AlphabeticSequence;
 -
 -public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
 -
 -    private static final long serialVersionUID = 1L;
 -
 -    @Override
 -    public ColumnNamingSession startColumnNamingSession() {
 -        return new ColumnNamingSession() {
 -            private final AlphabeticSequence seq = new AlphabeticSequence();
 -
 -            @Override
 -            public String getNextColumnName(ColumnNamingContext ctx) {
 -                return seq.next();
 -            }
 -
 -            @Override
 -            public void close() {
 -            }
 -        };
 -    }
 -
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import org.apache.metamodel.util.AlphabeticSequence;
++
++public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
++
++    private static final long serialVersionUID = 1L;
++
++    @Override
++    public ColumnNamingSession startColumnNamingSession() {
++        return new ColumnNamingSession() {
++            private final AlphabeticSequence seq = new AlphabeticSequence();
++
++            @Override
++            public String getNextColumnName(ColumnNamingContext ctx) {
++                return seq.next();
++            }
++
++            @Override
++            public void close() {
++            }
++        };
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
index 0000000,b613913..b43ad87
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
@@@ -1,0 -1,52 +1,52 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import org.apache.metamodel.schema.Table;
 -
 -/**
 - * Defines the context for naming a single column in a
 - * {@link ColumnNamingStrategy} session.
 - */
 -public interface ColumnNamingContext {
 -
 -    /**
 -     * Gets the index of the column being named.
 -     * 
 -     * @return
 -     */
 -    public int getColumnIndex();
 -
 -    /**
 -     * Gets the {@link Table} that the column is to pertain to. If the table is
 -     * not yet available then this may return null.
 -     * 
 -     * @return
 -     */
 -    public Table getTable();
 -
 -    /**
 -     * Gets the intrinsic column name, if this is defined in the datastore
 -     * itself. This may be in the form of a header or such. Sometimes intrinsic
 -     * column names exist only for some columns and sometimes there may be
 -     * duplicate names or other anomalies which are often discouraged.
 -     * 
 -     * @return
 -     */
 -    public String getIntrinsicColumnName();
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import org.apache.metamodel.schema.Table;
++
++/**
++ * Defines the context for naming a single column in a
++ * {@link ColumnNamingStrategy} session.
++ */
++public interface ColumnNamingContext {
++
++    /**
++     * Gets the index of the column being named.
++     * 
++     * @return
++     */
++    public int getColumnIndex();
++
++    /**
++     * Gets the {@link Table} that the column is to pertain to. If the table is
++     * not yet available then this may return null.
++     * 
++     * @return
++     */
++    public Table getTable();
++
++    /**
++     * Gets the intrinsic column name, if this is defined in the datastore
++     * itself. This may be in the form of a header or such. Sometimes intrinsic
++     * column names exist only for some columns and sometimes there may be
++     * duplicate names or other anomalies which are often discouraged.
++     * 
++     * @return
++     */
++    public String getIntrinsicColumnName();
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
index 0000000,cc7a24e..ec77440
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
@@@ -1,0 -1,64 +1,64 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import org.apache.metamodel.schema.Table;
 -
 -public class ColumnNamingContextImpl implements ColumnNamingContext {
 -
 -    private final int columnIndex;
 -    private final Table table;
 -    private final String intrinsicColumnName;
 -
 -    /**
 -     * 
 -     * @param table
 -     * @param intrinsicColumnName
 -     * @param columnIndex
 -     */
 -    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
 -        this.table = table;
 -        this.intrinsicColumnName = intrinsicColumnName;
 -        this.columnIndex = columnIndex;
 -    }
 -
 -    /**
 -     * 
 -     * @param columnIndex
 -     */
 -    public ColumnNamingContextImpl(int columnIndex) {
 -        this(null, null, columnIndex);
 -    }
 -
 -    @Override
 -    public int getColumnIndex() {
 -        return columnIndex;
 -    }
 -
 -    @Override
 -    public Table getTable() {
 -        return table;
 -    }
 -
 -    @Override
 -    public String getIntrinsicColumnName() {
 -        return intrinsicColumnName;
 -    }
 -
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import org.apache.metamodel.schema.Table;
++
++public class ColumnNamingContextImpl implements ColumnNamingContext {
++
++    private final int columnIndex;
++    private final Table table;
++    private final String intrinsicColumnName;
++
++    /**
++     * 
++     * @param table
++     * @param intrinsicColumnName
++     * @param columnIndex
++     */
++    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
++        this.table = table;
++        this.intrinsicColumnName = intrinsicColumnName;
++        this.columnIndex = columnIndex;
++    }
++
++    /**
++     * 
++     * @param columnIndex
++     */
++    public ColumnNamingContextImpl(int columnIndex) {
++        this(null, null, columnIndex);
++    }
++
++    @Override
++    public int getColumnIndex() {
++        return columnIndex;
++    }
++
++    @Override
++    public Table getTable() {
++        return table;
++    }
++
++    @Override
++    public String getIntrinsicColumnName() {
++        return intrinsicColumnName;
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
index 0000000,0696376..f0da83a
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
@@@ -1,0 -1,45 +1,45 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import java.util.List;
 -
 -/**
 - * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
 - */
 -public class ColumnNamingStrategies {
 -
 -    private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(
 -            new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
 -
 -    private ColumnNamingStrategies() {
 -    }
 -
 -    public static ColumnNamingStrategy defaultStrategy() {
 -        return DEFAULT_STRATEGY;
 -    }
 -
 -    public static ColumnNamingStrategy customNames(List<String> columnNames) {
 -        return new CustomColumnNamingStrategy(columnNames);
 -    }
 -
 -    public static ColumnNamingStrategy customNames(String ... columnNames) {
 -        return new CustomColumnNamingStrategy(columnNames);
 -    }
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import java.util.List;
++
++/**
++ * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
++ */
++public class ColumnNamingStrategies {
++
++    private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(
++            new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
++
++    private ColumnNamingStrategies() {
++    }
++
++    public static ColumnNamingStrategy defaultStrategy() {
++        return DEFAULT_STRATEGY;
++    }
++
++    public static ColumnNamingStrategy customNames(List<String> columnNames) {
++        return new CustomColumnNamingStrategy(columnNames);
++    }
++
++    public static ColumnNamingStrategy customNames(String ... columnNames) {
++        return new CustomColumnNamingStrategy(columnNames);
++    }
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
index 0000000,6ccccbf..27e85ea
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
@@@ -1,0 -1,31 +1,31 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import java.io.Serializable;
 -
 -/**
 - * A strategy that defines how columns are logically named. Such strategies are
 - * mostly used when a particular datastore is not itself intrinsically
 - * specifying the column name.
 - */
 -public interface ColumnNamingStrategy extends Serializable {
 -    
 -    public ColumnNamingSession startColumnNamingSession();
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import java.io.Serializable;
++
++/**
++ * A strategy that defines how columns are logically named. Such strategies are
++ * mostly used when a particular datastore is not itself intrinsically
++ * specifying the column name.
++ */
++public interface ColumnNamingStrategy extends Serializable {
++    
++    public ColumnNamingSession startColumnNamingSession();
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
index 0000000,e6cc706..39397d7
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
@@@ -1,0 -1,62 +1,62 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import java.util.Arrays;
 -import java.util.Iterator;
 -import java.util.List;
 -
 -/**
 - * A {@link ColumnNamingStrategy} that allows the user to supply his own list of
 - * custom column names.
 - */
 -public class CustomColumnNamingStrategy implements ColumnNamingStrategy {
 -
 -    private static final long serialVersionUID = 1L;
 -
 -    private final List<String> columnNames;
 -
 -    public CustomColumnNamingStrategy(List<String> columnNames) {
 -        this.columnNames = columnNames;
 -    }
 -
 -    public CustomColumnNamingStrategy(String... columnNames) {
 -        this(Arrays.asList(columnNames));
 -    }
 -
 -    @Override
 -    public ColumnNamingSession startColumnNamingSession() {
 -        final Iterator<String> iterator = columnNames.iterator();
 -        return new ColumnNamingSession() {
 -
 -            @Override
 -            public String getNextColumnName(ColumnNamingContext ctx) {
 -                if (iterator.hasNext()) {
 -                    return iterator.next();
 -                }
 -                return null;
 -            }
 -
 -            @Override
 -            public void close() {
 -            }
 -        };
 -    }
 -
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import java.util.Arrays;
++import java.util.Iterator;
++import java.util.List;
++
++/**
++ * A {@link ColumnNamingStrategy} that allows the user to supply his own list of
++ * custom column names.
++ */
++public class CustomColumnNamingStrategy implements ColumnNamingStrategy {
++
++    private static final long serialVersionUID = 1L;
++
++    private final List<String> columnNames;
++
++    public CustomColumnNamingStrategy(List<String> columnNames) {
++        this.columnNames = columnNames;
++    }
++
++    public CustomColumnNamingStrategy(String... columnNames) {
++        this(Arrays.asList(columnNames));
++    }
++
++    @Override
++    public ColumnNamingSession startColumnNamingSession() {
++        final Iterator<String> iterator = columnNames.iterator();
++        return new ColumnNamingSession() {
++
++            @Override
++            public String getNextColumnName(ColumnNamingContext ctx) {
++                if (iterator.hasNext()) {
++                    return iterator.next();
++                }
++                return null;
++            }
++
++            @Override
++            public void close() {
++            }
++        };
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
index 0000000,e18cb3a..35a0f39
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@@ -1,0 -1,60 +1,60 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -/**
 - * A {@link ColumnNamingStrategy} that switches between two other
 - * {@link ColumnNamingStrategy} delegates depending on the availability of a
 - * intrinsic column name.
 - */
 -public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
 -
 -    private static final long serialVersionUID = 1L;
 -    private final ColumnNamingStrategy intrinsicStrategy;
 -    private final ColumnNamingStrategy nonIntrinsicStrategy;
 -
 -    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
 -            ColumnNamingStrategy nonIntrinsicStrategy) {
 -        this.intrinsicStrategy = intrinsicStrategy;
 -        this.nonIntrinsicStrategy = nonIntrinsicStrategy;
 -    }
 -
 -    @Override
 -    public ColumnNamingSession startColumnNamingSession() {
 -        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
 -        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
 -        return new ColumnNamingSession() {
 -
 -            @Override
 -            public String getNextColumnName(ColumnNamingContext ctx) {
 -                final String intrinsicColumnName = ctx.getIntrinsicColumnName();
 -                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
 -                    return nonIntrinsicSession.getNextColumnName(ctx);
 -                }
 -                return intrinsicSession.getNextColumnName(ctx);
 -            }
 -
 -            @Override
 -            public void close() {
 -                intrinsicSession.close();
 -                nonIntrinsicSession.close();
 -            }
 -        };
 -    }
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++/**
++ * A {@link ColumnNamingStrategy} that switches between two other
++ * {@link ColumnNamingStrategy} delegates depending on the availability of a
++ * intrinsic column name.
++ */
++public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
++
++    private static final long serialVersionUID = 1L;
++    private final ColumnNamingStrategy intrinsicStrategy;
++    private final ColumnNamingStrategy nonIntrinsicStrategy;
++
++    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
++            ColumnNamingStrategy nonIntrinsicStrategy) {
++        this.intrinsicStrategy = intrinsicStrategy;
++        this.nonIntrinsicStrategy = nonIntrinsicStrategy;
++    }
++
++    @Override
++    public ColumnNamingSession startColumnNamingSession() {
++        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
++        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
++        return new ColumnNamingSession() {
++
++            @Override
++            public String getNextColumnName(ColumnNamingContext ctx) {
++                final String intrinsicColumnName = ctx.getIntrinsicColumnName();
++                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
++                    return nonIntrinsicSession.getNextColumnName(ctx);
++                }
++                return intrinsicSession.getNextColumnName(ctx);
++            }
++
++            @Override
++            public void close() {
++                intrinsicSession.close();
++                nonIntrinsicSession.close();
++            }
++        };
++    }
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
index 0000000,d4d21dd..9321998
mode 000000,100644..100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
@@@ -1,0 -1,62 +1,62 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.schema.naming;
 -
 -import java.util.HashSet;
 -import java.util.Set;
 -
 -/**
 - * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
 - * ensures that all column names are unique. When duplicate names are
 - * encountered a number will be appended yielding column names like "name",
 - * "name_2", "name_3" etc.
 - */
 -public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
 -
 -    private static final long serialVersionUID = 1L;
 -
 -    @Override
 -    public ColumnNamingSession startColumnNamingSession() {
 -        return new ColumnNamingSession() {
 -
 -            private final Set<String> names = new HashSet<>();
 -
 -            @Override
 -            public String getNextColumnName(ColumnNamingContext ctx) {
 -                final String intrinsicName = ctx.getIntrinsicColumnName();
 -                boolean unique = names.add(intrinsicName);
 -                if (unique) {
 -                    return intrinsicName;
 -                }
 -
 -                String newName = null;
 -                for (int i = 2; !unique; i++) {
 -                    newName = intrinsicName + '_' + i;
 -                    unique = names.add(newName);
 -                }
 -                return newName;
 -            }
 -
 -            @Override
 -            public void close() {
 -            }
 -        };
 -    }
 -
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.schema.naming;
++
++import java.util.HashSet;
++import java.util.Set;
++
++/**
++ * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
++ * ensures that all column names are unique. When duplicate names are
++ * encountered a number will be appended yielding column names like "name",
++ * "name_2", "name_3" etc.
++ */
++public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
++
++    private static final long serialVersionUID = 1L;
++
++    @Override
++    public ColumnNamingSession startColumnNamingSession() {
++        return new ColumnNamingSession() {
++
++            private final Set<String> names = new HashSet<>();
++
++            @Override
++            public String getNextColumnName(ColumnNamingContext ctx) {
++                final String intrinsicName = ctx.getIntrinsicColumnName();
++                boolean unique = names.add(intrinsicName);
++                if (unique) {
++                    return intrinsicName;
++                }
++
++                String newName = null;
++                for (int i = 2; !unique; i++) {
++                    newName = intrinsicName + '_' + i;
++                    unique = names.add(newName);
++                }
++                return newName;
++            }
++
++            @Override
++            public void close() {
++            }
++        };
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/elasticsearch/rest/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
----------------------------------------------------------------------
diff --cc elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
index e762050,c452d7b..e26646a
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
@@@ -358,11 -354,11 +359,12 @@@ public class ElasticSearchRestDataConte
      }
  
      @Override
 -    public void executeUpdate(UpdateScript update) {
 +    public UpdateSummary executeUpdate(UpdateScript update) {
-         final JestElasticSearchUpdateCallback callback = new JestElasticSearchUpdateCallback(this);
+         final boolean isBatch = update instanceof BatchUpdateScript;
+         final JestElasticSearchUpdateCallback callback = new JestElasticSearchUpdateCallback(this, isBatch);
          update.run(callback);
          callback.onExecuteUpdateFinished();
 +        return callback.getUpdateSummary();
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
----------------------------------------------------------------------
diff --cc elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
index ca2ed13,521955d..94e557c
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
@@@ -1,84 -1,165 +1,165 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.elasticsearch.rest;
 -
 -import java.util.List;
 -
 -import org.apache.metamodel.AbstractUpdateCallback;
 -import org.apache.metamodel.MetaModelException;
 -import org.apache.metamodel.UpdateCallback;
 -import org.apache.metamodel.create.TableCreationBuilder;
 -import org.apache.metamodel.delete.RowDeletionBuilder;
 -import org.apache.metamodel.drop.TableDropBuilder;
 -import org.apache.metamodel.insert.RowInsertionBuilder;
 -import org.apache.metamodel.schema.Schema;
 -import org.apache.metamodel.schema.Table;
 -import org.elasticsearch.action.bulk.BulkRequest;
 -import org.slf4j.Logger;
 -import org.slf4j.LoggerFactory;
 -
 -import io.searchbox.action.Action;
 -import io.searchbox.action.BulkableAction;
 -import io.searchbox.client.JestResult;
 -import io.searchbox.core.Bulk;
 -import io.searchbox.core.Bulk.Builder;
 -import io.searchbox.core.BulkResult;
 -import io.searchbox.core.BulkResult.BulkResultItem;
 -import io.searchbox.indices.Refresh;
 -
 -/**
 - * {@link UpdateCallback} implementation for
 - * {@link ElasticSearchRestDataContext}.
 - */
 -final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
 -
 -    private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);
 -
 -    private static final int BULK_BUFFER_SIZE = 1000;
 -
 -    private Bulk.Builder bulkBuilder;
 -    private int bulkActionCount = 0;
 -    private final boolean isBatch;
 -
 -    public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {
 -        super(dataContext);
 -        this.isBatch = isBatch;
 -    }
 -
 -    private boolean isBatch() {
 -        return isBatch;
 -    }
 -
 -    @Override
 -    public ElasticSearchRestDataContext getDataContext() {
 -        return (ElasticSearchRestDataContext) super.getDataContext();
 -    }
 -
 -    @Override
 -    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
 -            IllegalStateException {
 -        return new JestElasticSearchCreateTableBuilder(this, schema, name);
 -    }
 -
 -    @Override
 -    public boolean isDropTableSupported() {
 -        return true;
 -    }
 -
 -    @Override
 -    public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
 -            UnsupportedOperationException {
 -        return new JestElasticSearchDropTableBuilder(this, table);
 -    }
 -
 -    @Override
 -    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
 -            UnsupportedOperationException {
 -        return new JestElasticSearchInsertBuilder(this, table);
 -    }
 -
 -    @Override
 -    public boolean isDeleteSupported() {
 -        return true;
 -    }
 -
 -    @Override
 -    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
 -            UnsupportedOperationException {
 -        return new JestElasticSearchDeleteBuilder(this, table);
 -    }
 -
 -    public void onExecuteUpdateFinished() {
 -        if (isBatch()) {
 -            flushBulkActions();
 -        }
 -
 -        final String indexName = getDataContext().getIndexName();
 -        final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
 -
 -        JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
 -    }
 -
 -    private void flushBulkActions() {
 -        if (bulkBuilder == null || bulkActionCount == 0) {
 -            // nothing to flush
 -            return;
 -        }
 -        final Bulk bulk = getBulkBuilder().build();
 -        logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());
 -        executeBlocking(bulk);
 -
 -        bulkActionCount = 0;
 -        bulkBuilder = null;
 -    }
 -
 -    public void execute(Action<?> action) {
 -        if (isBatch() && action instanceof BulkableAction) {
 -            final Bulk.Builder bulkBuilder = getBulkBuilder();
 -            bulkBuilder.addAction((BulkableAction<?>) action);
 -            bulkActionCount++;
 -            if (bulkActionCount == BULK_BUFFER_SIZE) {
 -                flushBulkActions();
 -            }
 -        } else {
 -            executeBlocking(action);
 -        }
 -    }
 -
 -    private void executeBlocking(Action<?> action) {
 -        final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);
 -        if (!result.isSucceeded()) {
 -            if (result instanceof BulkResult) {
 -                final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();
 -                for (int i = 0; i < failedItems.size(); i++) {
 -                    final BulkResultItem failedItem = failedItems.get(i);
 -                    logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);
 -                }
 -            }
 -            throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());
 -        }
 -    }
 -
 -    private Builder getBulkBuilder() {
 -        if (bulkBuilder == null) {
 -            bulkBuilder = new Bulk.Builder();
 -            bulkBuilder.defaultIndex(getDataContext().getIndexName());
 -        }
 -        return bulkBuilder;
 -    }
 -}
 +/**
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you 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
 + *
 + * 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 org.apache.metamodel.elasticsearch.rest;
 +
- import io.searchbox.indices.Refresh;
++import java.util.List;
++
 +import org.apache.metamodel.AbstractUpdateCallback;
++import org.apache.metamodel.MetaModelException;
 +import org.apache.metamodel.UpdateCallback;
 +import org.apache.metamodel.create.TableCreationBuilder;
 +import org.apache.metamodel.delete.RowDeletionBuilder;
 +import org.apache.metamodel.drop.TableDropBuilder;
 +import org.apache.metamodel.insert.RowInsertionBuilder;
 +import org.apache.metamodel.schema.Schema;
 +import org.apache.metamodel.schema.Table;
++import org.elasticsearch.action.bulk.BulkRequest;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import io.searchbox.action.Action;
++import io.searchbox.action.BulkableAction;
++import io.searchbox.client.JestResult;
++import io.searchbox.core.Bulk;
++import io.searchbox.core.Bulk.Builder;
++import io.searchbox.core.BulkResult;
++import io.searchbox.core.BulkResult.BulkResultItem;
++import io.searchbox.indices.Refresh;
 +
 +/**
-  * {@link UpdateCallback} implementation for {@link ElasticSearchRestDataContext}.
++ * {@link UpdateCallback} implementation for
++ * {@link ElasticSearchRestDataContext}.
 + */
 +final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
-     public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext) {
++
++    private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);
++
++    private static final int BULK_BUFFER_SIZE = 1000;
++
++    private Bulk.Builder bulkBuilder;
++    private int bulkActionCount = 0;
++    private final boolean isBatch;
++
++    public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {
 +        super(dataContext);
++        this.isBatch = isBatch;
++    }
++
++    private boolean isBatch() {
++        return isBatch;
 +    }
 +
 +    @Override
 +    public ElasticSearchRestDataContext getDataContext() {
 +        return (ElasticSearchRestDataContext) super.getDataContext();
 +    }
 +
 +    @Override
 +    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
 +            IllegalStateException {
 +        return new JestElasticSearchCreateTableBuilder(this, schema, name);
 +    }
 +
 +    @Override
 +    public boolean isDropTableSupported() {
 +        return true;
 +    }
 +
 +    @Override
 +    public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
 +            UnsupportedOperationException {
 +        return new JestElasticSearchDropTableBuilder(this, table);
 +    }
 +
 +    @Override
 +    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
 +            UnsupportedOperationException {
 +        return new JestElasticSearchInsertBuilder(this, table);
 +    }
 +
 +    @Override
 +    public boolean isDeleteSupported() {
 +        return true;
 +    }
 +
 +    @Override
 +    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
 +            UnsupportedOperationException {
 +        return new JestElasticSearchDeleteBuilder(this, table);
 +    }
 +
 +    public void onExecuteUpdateFinished() {
++        if (isBatch()) {
++            flushBulkActions();
++        }
++
 +        final String indexName = getDataContext().getIndexName();
-         Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
++        final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
 +
 +        JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
 +    }
++
++    private void flushBulkActions() {
++        if (bulkBuilder == null || bulkActionCount == 0) {
++            // nothing to flush
++            return;
++        }
++        final Bulk bulk = getBulkBuilder().build();
++        logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());
++        executeBlocking(bulk);
++
++        bulkActionCount = 0;
++        bulkBuilder = null;
++    }
++
++    public void execute(Action<?> action) {
++        if (isBatch() && action instanceof BulkableAction) {
++            final Bulk.Builder bulkBuilder = getBulkBuilder();
++            bulkBuilder.addAction((BulkableAction<?>) action);
++            bulkActionCount++;
++            if (bulkActionCount == BULK_BUFFER_SIZE) {
++                flushBulkActions();
++            }
++        } else {
++            executeBlocking(action);
++        }
++    }
++
++    private void executeBlocking(Action<?> action) {
++        final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);
++        if (!result.isSucceeded()) {
++            if (result instanceof BulkResult) {
++                final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();
++                for (int i = 0; i < failedItems.size(); i++) {
++                    final BulkResultItem failedItem = failedItems.get(i);
++                    logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);
++                }
++            }
++            throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());
++        }
++    }
++
++    private Builder getBulkBuilder() {
++        if (bulkBuilder == null) {
++            bulkBuilder = new Bulk.Builder();
++            bulkBuilder.defaultIndex(getDataContext().getIndexName());
++        }
++        return bulkBuilder;
++    }
 +}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/excel/src/main/java/org/apache/metamodel/excel/ExcelDataContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --cc fixedwidth/pom.xml
index a304038,43e4021..7cae86b
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@@ -1,46 -1,52 +1,52 @@@
 -<?xml version="1.0" encoding="UTF-8" ?>
 -<!--
 -Licensed to the Apache Software Foundation (ASF) under one
 -or more contributor license agreements.  See the NOTICE file
 -distributed with this work for additional information
 -regarding copyright ownership.  The ASF licenses this file
 -to you 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
 -
 -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.
 --->
 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 -	<parent>
 -		<artifactId>MetaModel</artifactId>
 -		<groupId>org.apache.metamodel</groupId>
 -		<version>4.5.3-SNAPSHOT</version>
 -	</parent>
 -	<modelVersion>4.0.0</modelVersion>
 -	<artifactId>MetaModel-fixedwidth</artifactId>
 -	<name>MetaModel module for fixed width value files</name>
 -	<dependencies>
 -		<dependency>
 -			<groupId>org.apache.metamodel</groupId>
 -			<artifactId>MetaModel-core</artifactId>
 -			<version>${project.version}</version>
 -		</dependency>
 -		<dependency>
 -			<groupId>org.apache.metamodel</groupId>
 -			<artifactId>MetaModel-csv</artifactId>
 -			<version>${project.version}</version>
 -			<optional>true</optional>
 -		</dependency>
 -		<dependency>
 -			<groupId>org.slf4j</groupId>
 -			<artifactId>slf4j-nop</artifactId>
 -			<scope>test</scope>
 -		</dependency>
 -		<dependency>
 -			<groupId>junit</groupId>
 -			<artifactId>junit</artifactId>
 -			<scope>test</scope>
 -		</dependency>
 -	</dependencies>
 -</project>
 +<?xml version="1.0" encoding="UTF-8" ?>
 +<!--
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you 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
 +
 +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.
 +-->
 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 +	<parent>
 +		<artifactId>MetaModel</artifactId>
 +		<groupId>org.apache.metamodel</groupId>
 +		<version>5.0-SNAPSHOT</version>
 +	</parent>
 +	<modelVersion>4.0.0</modelVersion>
 +	<artifactId>MetaModel-fixedwidth</artifactId>
 +	<name>MetaModel module for fixed width value files</name>
 +	<dependencies>
 +		<dependency>
 +			<groupId>org.apache.metamodel</groupId>
 +			<artifactId>MetaModel-core</artifactId>
 +			<version>${project.version}</version>
 +		</dependency>
++	  <dependency>
++      <groupId>org.apache.metamodel</groupId>
++      <artifactId>MetaModel-csv</artifactId>
++      <version>${project.version}</version>
++      <optional>true</optional>
++    </dependency>
 +		<dependency>
 +			<groupId>org.slf4j</groupId>
 +			<artifactId>slf4j-nop</artifactId>
 +			<scope>test</scope>
 +		</dependency>
 +		<dependency>
 +			<groupId>junit</groupId>
 +			<artifactId>junit</artifactId>
 +			<scope>test</scope>
 +		</dependency>
 +	</dependencies>
 +</project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
----------------------------------------------------------------------
diff --cc fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
index 0000000,65ec219..f9d62df
mode 000000,100644..100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
@@@ -1,0 -1,45 +1,45 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.fixedwidth;
 -
 -import org.apache.metamodel.util.HasName;
 -
 -/**
 - * Represents the specification of a single column for a
 - * {@link FixedWidthDataContext}.
 - */
 -public final class FixedWidthColumnSpec implements HasName {
 -
 -    private final String name;
 -    private final int width;
 -
 -    public FixedWidthColumnSpec(String name, int width) {
 -        this.name = name;
 -        this.width = width;
 -    }
 -
 -    @Override
 -    public String getName() {
 -        return name;
 -    }
 -
 -    public int getWidth() {
 -        return width;
 -    }
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.fixedwidth;
++
++import org.apache.metamodel.util.HasName;
++
++/**
++ * Represents the specification of a single column for a
++ * {@link FixedWidthDataContext}.
++ */
++public final class FixedWidthColumnSpec implements HasName {
++
++    private final String name;
++    private final int width;
++
++    public FixedWidthColumnSpec(String name, int width) {
++        this.name = name;
++        this.width = width;
++    }
++
++    @Override
++    public String getName() {
++        return name;
++    }
++
++    public int getWidth() {
++        return width;
++    }
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --cc fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index 86a038a,2b2cae5..fe12177
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@@ -1,149 -1,189 +1,189 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.fixedwidth;
 -
 -import java.io.Serializable;
 -import java.util.Arrays;
 -import java.util.List;
 -
 -import org.apache.metamodel.data.DataSet;
 -import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
 -import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 -import org.apache.metamodel.util.BaseObject;
 -import org.apache.metamodel.util.CollectionUtils;
 -import org.apache.metamodel.util.FileHelper;
 -import org.apache.metamodel.util.HasNameMapper;
 -
 -/**
 - * Configuration of metadata about a fixed width values datacontext.
 - */
 -public final class FixedWidthConfiguration extends BaseObject implements
 -		Serializable {
 -
 -	private static final long serialVersionUID = 1L;
 -
 -	public static final int NO_COLUMN_NAME_LINE = 0;
 -	public static final int DEFAULT_COLUMN_NAME_LINE = 1;
 -
 -	private final String encoding;
 -	private final int fixedValueWidth;
 -	private final int[] valueWidths;
 -	private final int columnNameLineNumber;
 -	private final boolean failOnInconsistentLineWidth;
 -	private final ColumnNamingStrategy columnNamingStrategy;
 -
 -	public FixedWidthConfiguration(int fixedValueWidth) {
 -		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING,
 -				fixedValueWidth);
 -	}
 -
 -	public FixedWidthConfiguration(int[] valueWidth) {
 -		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth,
 -				false);
 -	}
 -
 -    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
 -        this(columnNameLineNumber, encoding, fixedValueWidth, false);
 -    }
 -
 -    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
 -            boolean failOnInconsistentLineWidth) {
 -        this.encoding = encoding;
 -        this.fixedValueWidth = fixedValueWidth;
 -        this.columnNameLineNumber = columnNameLineNumber;
 -        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
 -        this.columnNamingStrategy = null;
 -        this.valueWidths = new int[0];
 -    }
 -
 -    public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
 -            int[] valueWidths, boolean failOnInconsistentLineWidth) {
 -        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
 -    }
 -    
 -    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
 -            int[] valueWidths, boolean failOnInconsistentLineWidth) {
 -        this.encoding = encoding;
 -        this.fixedValueWidth = -1;
 -        this.columnNameLineNumber = columnNameLineNumber;
 -        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
 -        this.columnNamingStrategy = columnNamingStrategy;
 -        this.valueWidths = valueWidths;
 -    }
 -    
 -    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
 -        this(encoding, columnSpecs, false);
 -    }
 -
 -    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,
 -            boolean failOnInconsistentLineWidth) {
 -        this.encoding = encoding;
 -        this.fixedValueWidth = -1;
 -        this.columnNameLineNumber = NO_COLUMN_NAME_LINE;
 -        this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,
 -                new HasNameMapper()));
 -        this.valueWidths = new int[columnSpecs.size()];
 -        for (int i = 0; i < valueWidths.length; i++) {
 -            valueWidths[i] = columnSpecs.get(i).getWidth();
 -        }
 -        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
 -    }
 -
 -    /**
 -	 * The line number (1 based) from which to get the names of the columns.
 -	 * 
 -	 * @return an int representing the line number of the column headers/names.
 -	 */
 -	public int getColumnNameLineNumber() {
 -		return columnNameLineNumber;
 -	}
 -	
 -	/**
 -	 * Gets a {@link ColumnNamingStrategy} to use if needed.
 -	 * @return
 -	 */
 -	public ColumnNamingStrategy getColumnNamingStrategy() {
 -	    if (columnNamingStrategy == null) {
 -	        return ColumnNamingStrategies.defaultStrategy();
 -	    }
 -        return columnNamingStrategy;
 -    }
 -
 -	/**
 -	 * Gets the file encoding to use for reading the file.
 -	 * 
 -	 * @return the text encoding to use for reading the file.
 -	 */
 -	public String getEncoding() {
 -		return encoding;
 -	}
 -
 -	/**
 -	 * Gets the width of each value within the fixed width value file.
 -	 * 
 -	 * @return the fixed width to use when parsing the file.
 -	 */
 -	public int getFixedValueWidth() {
 -		return fixedValueWidth;
 -	}
 -
 -	public int[] getValueWidths() {
 -		return valueWidths;
 -	}
 -
 -	/**
 -	 * Determines if the {@link DataSet#next()} should throw an exception in
 -	 * case of inconsistent line width in the fixed width value file.
 -	 * 
 -	 * @return a boolean indicating whether or not to fail on inconsistent line
 -	 *         widths.
 -	 */
 -	public boolean isFailOnInconsistentLineWidth() {
 -		return failOnInconsistentLineWidth;
 -	}
 -
 -	@Override
 -	protected void decorateIdentity(List<Object> identifiers) {
 -		identifiers.add(columnNameLineNumber);
 -		identifiers.add(encoding);
 -		identifiers.add(fixedValueWidth);
 -		identifiers.add(valueWidths);
 -		identifiers.add(failOnInconsistentLineWidth);
 -	}
 -
 -	@Override
 -	public String toString() {
 -		return "FixedWidthConfiguration[encoding=" + encoding
 -				+ ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
 -				+ Arrays.toString(valueWidths) + ", columnNameLineNumber="
 -				+ columnNameLineNumber + ", failOnInconsistentLineWidth="
 -				+ failOnInconsistentLineWidth + "]";
 -	}
 -
 -	public boolean isConstantValueWidth() {
 -		return fixedValueWidth != -1;
 -	}
 -
 -	public int getValueWidth(int columnIndex) {
 -		if (isConstantValueWidth()) {
 -			return fixedValueWidth;
 -		}
 -		return valueWidths[columnIndex];
 -	}
 -}
 +/**
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you 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
 + *
 + * 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 org.apache.metamodel.fixedwidth;
 +
 +import java.io.Serializable;
 +import java.util.Arrays;
 +import java.util.List;
 +
 +import org.apache.metamodel.data.DataSet;
++import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
++import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 +import org.apache.metamodel.util.BaseObject;
++import org.apache.metamodel.util.CollectionUtils;
 +import org.apache.metamodel.util.FileHelper;
++import org.apache.metamodel.util.HasNameMapper;
 +
 +/**
 + * Configuration of metadata about a fixed width values datacontext.
 + */
 +public final class FixedWidthConfiguration extends BaseObject implements
 +		Serializable {
 +
 +	private static final long serialVersionUID = 1L;
 +
 +	public static final int NO_COLUMN_NAME_LINE = 0;
 +	public static final int DEFAULT_COLUMN_NAME_LINE = 1;
 +
 +	private final String encoding;
 +	private final int fixedValueWidth;
 +	private final int[] valueWidths;
 +	private final int columnNameLineNumber;
 +	private final boolean failOnInconsistentLineWidth;
++	private final ColumnNamingStrategy columnNamingStrategy;
 +
 +	public FixedWidthConfiguration(int fixedValueWidth) {
 +		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING,
 +				fixedValueWidth);
 +	}
 +
 +	public FixedWidthConfiguration(int[] valueWidth) {
 +		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth,
 +				false);
 +	}
 +
- 	public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
- 			int fixedValueWidth) {
- 		this(columnNameLineNumber, encoding, fixedValueWidth, false);
- 	}
- 
- 	public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
- 			int fixedValueWidth, boolean failOnInconsistentLineWidth) {
- 		this.encoding = encoding;
- 		this.fixedValueWidth = fixedValueWidth;
- 		this.columnNameLineNumber = columnNameLineNumber;
- 		this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- 		this.valueWidths = new int[0];
- 	}
- 
- 	public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
- 			int[] valueWidths, boolean failOnInconsistentLineWidth) {
- 		this.encoding = encoding;
- 		this.fixedValueWidth = -1;
- 		this.columnNameLineNumber = columnNameLineNumber;
- 		this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- 		this.valueWidths = valueWidths;
- 	}
- 
- 	/**
++    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
++        this(columnNameLineNumber, encoding, fixedValueWidth, false);
++    }
++
++    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
++            boolean failOnInconsistentLineWidth) {
++        this.encoding = encoding;
++        this.fixedValueWidth = fixedValueWidth;
++        this.columnNameLineNumber = columnNameLineNumber;
++        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
++        this.columnNamingStrategy = null;
++        this.valueWidths = new int[0];
++    }
++
++    public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
++            int[] valueWidths, boolean failOnInconsistentLineWidth) {
++        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
++    }
++    
++    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
++            int[] valueWidths, boolean failOnInconsistentLineWidth) {
++        this.encoding = encoding;
++        this.fixedValueWidth = -1;
++        this.columnNameLineNumber = columnNameLineNumber;
++        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
++        this.columnNamingStrategy = columnNamingStrategy;
++        this.valueWidths = valueWidths;
++    }
++    
++    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
++        this(encoding, columnSpecs, false);
++    }
++
++    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,
++            boolean failOnInconsistentLineWidth) {
++        this.encoding = encoding;
++        this.fixedValueWidth = -1;
++        this.columnNameLineNumber = NO_COLUMN_NAME_LINE;
++        this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,
++                new HasNameMapper()));
++        this.valueWidths = new int[columnSpecs.size()];
++        for (int i = 0; i < valueWidths.length; i++) {
++            valueWidths[i] = columnSpecs.get(i).getWidth();
++        }
++        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
++    }
++
++    /**
 +	 * The line number (1 based) from which to get the names of the columns.
 +	 * 
 +	 * @return an int representing the line number of the column headers/names.
 +	 */
 +	public int getColumnNameLineNumber() {
 +		return columnNameLineNumber;
 +	}
++	
++	/**
++	 * Gets a {@link ColumnNamingStrategy} to use if needed.
++	 * @return
++	 */
++	public ColumnNamingStrategy getColumnNamingStrategy() {
++	    if (columnNamingStrategy == null) {
++	        return ColumnNamingStrategies.defaultStrategy();
++	    }
++        return columnNamingStrategy;
++    }
 +
 +	/**
 +	 * Gets the file encoding to use for reading the file.
 +	 * 
 +	 * @return the text encoding to use for reading the file.
 +	 */
 +	public String getEncoding() {
 +		return encoding;
 +	}
 +
 +	/**
 +	 * Gets the width of each value within the fixed width value file.
 +	 * 
 +	 * @return the fixed width to use when parsing the file.
 +	 */
 +	public int getFixedValueWidth() {
 +		return fixedValueWidth;
 +	}
 +
 +	public int[] getValueWidths() {
 +		return valueWidths;
 +	}
 +
 +	/**
 +	 * Determines if the {@link DataSet#next()} should throw an exception in
 +	 * case of inconsistent line width in the fixed width value file.
 +	 * 
 +	 * @return a boolean indicating whether or not to fail on inconsistent line
 +	 *         widths.
 +	 */
 +	public boolean isFailOnInconsistentLineWidth() {
 +		return failOnInconsistentLineWidth;
 +	}
 +
 +	@Override
 +	protected void decorateIdentity(List<Object> identifiers) {
 +		identifiers.add(columnNameLineNumber);
 +		identifiers.add(encoding);
 +		identifiers.add(fixedValueWidth);
 +		identifiers.add(valueWidths);
 +		identifiers.add(failOnInconsistentLineWidth);
 +	}
 +
 +	@Override
 +	public String toString() {
 +		return "FixedWidthConfiguration[encoding=" + encoding
 +				+ ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
 +				+ Arrays.toString(valueWidths) + ", columnNameLineNumber="
 +				+ columnNameLineNumber + ", failOnInconsistentLineWidth="
 +				+ failOnInconsistentLineWidth + "]";
 +	}
 +
 +	public boolean isConstantValueWidth() {
 +		return fixedValueWidth != -1;
 +	}
 +
 +	public int getValueWidth(int columnIndex) {
 +		if (isConstantValueWidth()) {
 +			return fixedValueWidth;
 +		}
 +		return valueWidths[columnIndex];
 +	}
 +}


[02/42] metamodel git commit: Closes #68

Posted by ka...@apache.org.
Closes #68


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/de91a7d0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/de91a7d0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/de91a7d0

Branch: refs/heads/5.x
Commit: de91a7d03d6cffa50a28f2bd1f27799125cf7a32
Parents: f779f43
Author: Kasper S�rensen <i....@gmail.com>
Authored: Fri Jan 8 13:40:10 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Fri Jan 8 13:40:10 2016 +0100

----------------------------------------------------------------------

----------------------------------------------------------------------



[38/42] metamodel git commit: METAMODEL-244: Addition for Excel

Posted by ka...@apache.org.
METAMODEL-244: Addition for Excel

Closes #99

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/a6093c16
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/a6093c16
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/a6093c16

Branch: refs/heads/5.x
Commit: a6093c167f0fa7f9a6fc23aa8cb2ee0439c3d972
Parents: 161b642
Author: Kasper S�rensen <i....@gmail.com>
Authored: Thu May 12 20:15:33 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Thu May 12 20:15:33 2016 -0700

----------------------------------------------------------------------
 .../couchdb/CouchDbDataContextTest.java         |  3 +-
 .../excel/DefaultSpreadsheetReaderDelegate.java | 45 +++++++++------
 .../metamodel/excel/ExcelConfiguration.java     | 31 ++++++++--
 .../metamodel/excel/ExcelDataContext.java       |  4 +-
 .../excel/XlsxSpreadsheetReaderDelegate.java    | 60 +++++++++-----------
 .../metamodel/excel/ExcelDataContextTest.java   |  4 +-
 6 files changed, 85 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/a6093c16/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java b/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
index 9e1f5fe..c2ec998 100644
--- a/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
+++ b/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
@@ -53,7 +53,8 @@ public class CouchDbDataContextTest extends CouchDbTestCase {
         super.setUp();
 
         if (isConfigured()) {
-            httpClient = new StdHttpClient.Builder().host(getHostname()).build();
+            final int timeout = 8 * 1000; // 8 seconds should be more than enough
+            httpClient = new StdHttpClient.Builder().socketTimeout(timeout).host(getHostname()).build();
 
             // set up a simple database
             couchDbInstance = new StdCouchDbInstance(httpClient);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a6093c16/excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
----------------------------------------------------------------------
diff --git a/excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java b/excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
index 1b8b534..009fad4 100644
--- a/excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
+++ b/excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
@@ -30,7 +30,10 @@ import org.apache.metamodel.schema.MutableSchema;
 import org.apache.metamodel.schema.MutableTable;
 import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.Table;
-import org.apache.metamodel.util.AlphabeticSequence;
+import org.apache.metamodel.schema.naming.ColumnNamingContext;
+import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.naming.ColumnNamingSession;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 import org.apache.metamodel.util.Resource;
 import org.apache.poi.ss.usermodel.Cell;
@@ -131,19 +134,22 @@ final class DefaultSpreadsheetReaderDelegate implements SpreadsheetReaderDelegat
                 row = rowIterator.next();
             }
 
-            // build columns by using alphabetic sequences
-            // (A,B,C...)
-            AlphabeticSequence sequence = new AlphabeticSequence();
+            // build columns without any intrinsic column names
+            final ColumnNamingStrategy columnNamingStrategy = _configuration.getColumnNamingStrategy();
+            try (final ColumnNamingSession columnNamingSession = columnNamingStrategy.startColumnNamingSession()) {
+                final int offset = getColumnOffset(row);
+                for (int i = 0; i < offset; i++) {
+                    columnNamingSession.getNextColumnName(new ColumnNamingContextImpl(i));
+                }
 
-            final int offset = getColumnOffset(row);
-            for (int i = 0; i < offset; i++) {
-                sequence.next();
+                for (int j = offset; j < row.getLastCellNum(); j++) {
+                    final ColumnNamingContext namingContext = new ColumnNamingContextImpl(table, null, j);
+                    final Column column = new MutableColumn(columnNamingSession.getNextColumnName(namingContext),
+                            ColumnType.STRING, table, j, true);
+                    table.addColumn(column);
+                }
             }
 
-            for (int j = offset; j < row.getLastCellNum(); j++) {
-                Column column = new MutableColumn(sequence.next(), ColumnType.STRING, table, j, true);
-                table.addColumn(column);
-            }
         } else {
 
             boolean hasColumns = true;
@@ -183,14 +189,17 @@ final class DefaultSpreadsheetReaderDelegate implements SpreadsheetReaderDelegat
         final int offset = getColumnOffset(row);
 
         // build columns based on cell values.
-        for (int j = offset; j < rowLength; j++) {
-            Cell cell = row.getCell(j);
-            String columnName = ExcelUtils.getCellValue(wb, cell);
-            if (columnName == null || "".equals(columnName)) {
-                columnName = "[Column " + (j + 1) + "]";
+        try (final ColumnNamingSession columnNamingSession = _configuration.getColumnNamingStrategy()
+                .startColumnNamingSession()) {
+            for (int j = offset; j < rowLength; j++) {
+                final Cell cell = row.getCell(j);
+                final String intrinsicColumnName = ExcelUtils.getCellValue(wb, cell);
+                final ColumnNamingContext columnNamingContext = new ColumnNamingContextImpl(table, intrinsicColumnName,
+                        j);
+                final String columnName = columnNamingSession.getNextColumnName(columnNamingContext);
+                final Column column = new MutableColumn(columnName, ColumnType.VARCHAR, table, j, true);
+                table.addColumn(column);
             }
-            Column column = new MutableColumn(columnName, ColumnType.VARCHAR, table, j, true);
-            table.addColumn(column);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a6093c16/excel/src/main/java/org/apache/metamodel/excel/ExcelConfiguration.java
----------------------------------------------------------------------
diff --git a/excel/src/main/java/org/apache/metamodel/excel/ExcelConfiguration.java b/excel/src/main/java/org/apache/metamodel/excel/ExcelConfiguration.java
index 9220ea3..4779bb1 100644
--- a/excel/src/main/java/org/apache/metamodel/excel/ExcelConfiguration.java
+++ b/excel/src/main/java/org/apache/metamodel/excel/ExcelConfiguration.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.excel;
 import java.io.Serializable;
 import java.util.List;
 
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 
 /**
@@ -37,6 +39,7 @@ public final class ExcelConfiguration extends BaseObject implements
 	public static final int DEFAULT_COLUMN_NAME_LINE = 1;
 
 	private final int columnNameLineNumber;
+	private final ColumnNamingStrategy columnNamingStrategy;
 	private final boolean skipEmptyLines;
 	private final boolean skipEmptyColumns;
 
@@ -44,12 +47,28 @@ public final class ExcelConfiguration extends BaseObject implements
 		this(DEFAULT_COLUMN_NAME_LINE, true, false);
 	}
 
-	public ExcelConfiguration(int columnNameLineNumber, boolean skipEmptyLines,
-			boolean skipEmptyColumns) {
-		this.columnNameLineNumber = columnNameLineNumber;
-		this.skipEmptyLines = skipEmptyLines;
-		this.skipEmptyColumns = skipEmptyColumns;
-	}
+    public ExcelConfiguration(int columnNameLineNumber, boolean skipEmptyLines, boolean skipEmptyColumns) {
+        this(columnNameLineNumber, null, skipEmptyLines, skipEmptyColumns);
+    }
+
+    public ExcelConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy,
+            boolean skipEmptyLines, boolean skipEmptyColumns) {
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.skipEmptyLines = skipEmptyLines;
+        this.skipEmptyColumns = skipEmptyColumns;
+        this.columnNamingStrategy = columnNamingStrategy;
+    }
+    
+    /**
+     * Gets a {@link ColumnNamingStrategy} to use if needed.
+     * @return
+     */
+    public ColumnNamingStrategy getColumnNamingStrategy() {
+        if (columnNamingStrategy == null) {
+            return ColumnNamingStrategies.defaultStrategy();
+        }
+        return columnNamingStrategy;
+    }
 
 	/**
 	 * The line number (1 based) from which to get the names of the columns.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a6093c16/excel/src/main/java/org/apache/metamodel/excel/ExcelDataContext.java
----------------------------------------------------------------------
diff --git a/excel/src/main/java/org/apache/metamodel/excel/ExcelDataContext.java b/excel/src/main/java/org/apache/metamodel/excel/ExcelDataContext.java
index 28c1f8e..0ce1c64 100644
--- a/excel/src/main/java/org/apache/metamodel/excel/ExcelDataContext.java
+++ b/excel/src/main/java/org/apache/metamodel/excel/ExcelDataContext.java
@@ -165,8 +165,8 @@ public final class ExcelDataContext extends QueryPostprocessDataContext implemen
             return new MutableSchema(getMainSchemaName());
         }
         try {
-            SpreadsheetReaderDelegate delegate = getSpreadsheetReaderDelegate();
-            Schema schema = delegate.createSchema(getMainSchemaName());
+            final SpreadsheetReaderDelegate delegate = getSpreadsheetReaderDelegate();
+            final Schema schema = delegate.createSchema(getMainSchemaName());
             assert getMainSchemaName().equals(schema.getName());
             return schema;
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a6093c16/excel/src/main/java/org/apache/metamodel/excel/XlsxSpreadsheetReaderDelegate.java
----------------------------------------------------------------------
diff --git a/excel/src/main/java/org/apache/metamodel/excel/XlsxSpreadsheetReaderDelegate.java b/excel/src/main/java/org/apache/metamodel/excel/XlsxSpreadsheetReaderDelegate.java
index ab34ef6..94a9ff7 100644
--- a/excel/src/main/java/org/apache/metamodel/excel/XlsxSpreadsheetReaderDelegate.java
+++ b/excel/src/main/java/org/apache/metamodel/excel/XlsxSpreadsheetReaderDelegate.java
@@ -39,7 +39,9 @@ import org.apache.metamodel.schema.MutableSchema;
 import org.apache.metamodel.schema.MutableTable;
 import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.Table;
-import org.apache.metamodel.util.AlphabeticSequence;
+import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.naming.ColumnNamingSession;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 import org.apache.metamodel.util.FileResource;
 import org.apache.metamodel.util.Resource;
@@ -141,8 +143,8 @@ final class XlsxSpreadsheetReaderDelegate implements SpreadsheetReaderDelegate {
         for (Column column : columns) {
             selectItems.add(new SelectItem(column));
         }
-        final XlsxRowPublisherAction publishAction = new XlsxRowPublisherAction(_configuration, columns,
-                relationshipId, xssfReader);
+        final XlsxRowPublisherAction publishAction = new XlsxRowPublisherAction(_configuration, columns, relationshipId,
+                xssfReader);
 
         return new RowPublisherDataSet(selectItems.toArray(new SelectItem[selectItems.size()]), maxRows, publishAction,
                 new Closeable() {
@@ -161,26 +163,31 @@ final class XlsxSpreadsheetReaderDelegate implements SpreadsheetReaderDelegate {
             @Override
             public boolean row(int rowNumber, List<String> values, List<Style> styles) {
                 final int columnNameLineNumber = _configuration.getColumnNameLineNumber();
-                if (columnNameLineNumber == ExcelConfiguration.NO_COLUMN_NAME_LINE) {
-                    AlphabeticSequence alphabeticSequence = new AlphabeticSequence();
-                    List<String> generatedColumnNames = new ArrayList<String>(values.size());
-                    for (String originalColumnName : values) {
-                        String columnName = alphabeticSequence.next();
-                        if (originalColumnName == null) {
-                            columnName = null;
-                        }
-                        generatedColumnNames.add(columnName);
-                    }
-                    buildColumns(table, generatedColumnNames);
-                    return false;
-                } else {
+                final boolean hasColumnNameLine = columnNameLineNumber != ExcelConfiguration.NO_COLUMN_NAME_LINE;
+
+                if (hasColumnNameLine) {
                     final int zeroBasedLineNumber = columnNameLineNumber - 1;
-                    if (rowNumber >= zeroBasedLineNumber) {
-                        buildColumns(table, values);
-                        return false;
+                    if (rowNumber < zeroBasedLineNumber) {
+                        // jump to read the next line
+                        return true;
+                    }
+                }
+
+                final ColumnNamingStrategy columnNamingStrategy = _configuration.getColumnNamingStrategy();
+                try (ColumnNamingSession session = columnNamingStrategy.startColumnNamingSession()) {
+                    for (int i = 0; i < values.size(); i++) {
+                        final String intrinsicColumnName = hasColumnNameLine ? values.get(i) : null;
+                        final String columnName = session.getNextColumnName(new ColumnNamingContextImpl(table,
+                                intrinsicColumnName, i));
+
+                        if (!(_configuration.isSkipEmptyColumns() && values.get(i) == null)) {
+                            table.addColumn(new MutableColumn(columnName, ColumnType.STRING, table, i, true));
+                        }
                     }
                 }
-                return true;
+
+                // now we're done, no more reading
+                return false;
             }
         };
         final XlsxSheetToRowsHandler handler = new XlsxSheetToRowsHandler(rowCallback, xssfReader, _configuration);
@@ -196,19 +203,6 @@ final class XlsxSpreadsheetReaderDelegate implements SpreadsheetReaderDelegate {
         }
     }
 
-    protected void buildColumns(final MutableTable table, final List<String> columnNames) {
-        int columnNumber = 0;
-        for (String columnName : columnNames) {
-            if (columnName != null || !_configuration.isSkipEmptyColumns()) {
-                if (columnName == null) {
-                    columnName = "[Column " + (columnNumber + 1) + "]";
-                }
-                table.addColumn(new MutableColumn(columnName, ColumnType.STRING, table, columnNumber, true));
-            }
-            columnNumber++;
-        }
-    }
-
     private void buildTables(final XSSFReader xssfReader, final XlsxWorkbookToTablesHandler workbookToTables)
             throws Exception {
         final InputStream workbookData = xssfReader.getWorkbookData();

http://git-wip-us.apache.org/repos/asf/metamodel/blob/a6093c16/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
----------------------------------------------------------------------
diff --git a/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java b/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
index 81155c0..3b69290 100644
--- a/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
+++ b/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
@@ -276,7 +276,7 @@ public class ExcelDataContextTest extends TestCase {
 
         assertNotNull(table);
 
-        assertEquals("[[Column 1], hello]", Arrays.toString(table.getColumnNames()));
+        assertEquals("[A, hello]", Arrays.toString(table.getColumnNames()));
 
         Query q = dc.query().from(table).select(table.getColumns()).toQuery();
         DataSet ds = dc.executeQuery(q);
@@ -427,7 +427,7 @@ public class ExcelDataContextTest extends TestCase {
         Table table = schema.getTables()[0];
         assertEquals("[Column[name=a,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
                 + "Column[name=b,columnNumber=1,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
-                + "Column[name=[Column 3],columnNumber=2,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
+                + "Column[name=A,columnNumber=2,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
                 + "Column[name=d,columnNumber=3,type=VARCHAR,nullable=true,nativeType=null,columnSize=null]]",
                 Arrays.toString(table.getColumns()));
 


[18/42] metamodel git commit: [maven-release-plugin] prepare release MetaModel-4.5.2

Posted by ka...@apache.org.
[maven-release-plugin] prepare release MetaModel-4.5.2


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/cc35a258
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/cc35a258
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/cc35a258

Branch: refs/heads/5.x
Commit: cc35a258f06acff5fa235ae50e9412566d33242e
Parents: 60a4c56
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sat Mar 19 18:48:42 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Mar 19 18:48:42 2016 +0100

----------------------------------------------------------------------
 cassandra/pom.xml            | 2 +-
 core/pom.xml                 | 2 +-
 couchdb/pom.xml              | 2 +-
 csv/pom.xml                  | 2 +-
 elasticsearch/common/pom.xml | 2 +-
 elasticsearch/native/pom.xml | 2 +-
 elasticsearch/pom.xml        | 2 +-
 elasticsearch/rest/pom.xml   | 2 +-
 excel/pom.xml                | 2 +-
 fixedwidth/pom.xml           | 2 +-
 full/pom.xml                 | 2 +-
 hadoop/pom.xml               | 2 +-
 hbase/pom.xml                | 2 +-
 jdbc/pom.xml                 | 2 +-
 json/pom.xml                 | 2 +-
 mongodb/common/pom.xml       | 2 +-
 mongodb/mongo2/pom.xml       | 2 +-
 mongodb/mongo3/pom.xml       | 2 +-
 mongodb/pom.xml              | 2 +-
 neo4j/pom.xml                | 2 +-
 openoffice/pom.xml           | 2 +-
 pojo/pom.xml                 | 2 +-
 pom.xml                      | 4 ++--
 salesforce/pom.xml           | 2 +-
 spring/pom.xml               | 2 +-
 sugarcrm/pom.xml             | 2 +-
 xml/pom.xml                  | 2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index be61f5b..eba4472 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-cassandra</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index dc98591..8b82801 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-core</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index df359d8..1207729 100644
--- a/couchdb/pom.xml
+++ b/couchdb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-couchdb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index b456d27..d6945d6 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-csv</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index 8315863..a45f3d1 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 3929417..7dcb56d 100644
--- a/elasticsearch/native/pom.xml
+++ b/elasticsearch/native/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 8fa5ed9..487f886 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-elasticsearch</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 3ec49c3..0f87691 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 17d5202..fdc899a 100644
--- a/excel/pom.xml
+++ b/excel/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-excel</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 50bcf91..5ce729c 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-fixedwidth</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index e2528ba..c557c5a 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-full</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index a5fb978..51661e5 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hadoop</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index dc44c09..66f4d87 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hbase</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index d683641..fe6c423 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-jdbc</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 2582cde..872e513 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-json</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 5b98d2b..0d0af05 100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-common</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 5238cc2..05ba1e2 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index ab315d8..0ceebf1 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index be1df79..55edce5 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 7bec724..f50ec81 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-neo4j</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index dffa885..b395fb2 100644
--- a/openoffice/pom.xml
+++ b/openoffice/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-openoffice</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index b0b6cec..58e24d4 100644
--- a/pojo/pom.xml
+++ b/pojo/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-pojo</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 61a735c..f70f7dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
 		<url>https://git-wip-us.apache.org/repos/asf?p=metamodel.git</url>
 		<connection>scm:git:http://git-wip-us.apache.org/repos/asf/metamodel.git</connection>
 		<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/metamodel.git</developerConnection>
-		<tag>HEAD</tag>
+		<tag>MetaModel-4.5.2</tag>
 	</scm>
 	<groupId>org.apache.metamodel</groupId>
 	<artifactId>MetaModel</artifactId>
-	<version>4.5.2-SNAPSHOT</version>
+	<version>4.5.2</version>
 	<name>MetaModel</name>
 	<description>MetaModel is a library that encapsulates the differences and enhances 
 		the capabilities of different datastores. Rich querying abilities are

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 6b1f959..4d22452 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-salesforce</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index a6f6bb3..94d368b 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-spring</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 0754669..340d97b 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-sugarcrm</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cc35a258/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 0506e51..a3db178 100644
--- a/xml/pom.xml
+++ b/xml/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2-SNAPSHOT</version>
+		<version>4.5.2</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-xml</artifactId>


[05/42] metamodel git commit: METAMODEL-183: Fixed

Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
new file mode 100644
index 0000000..1952640
--- /dev/null
+++ b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
@@ -0,0 +1,613 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.mongodb.WriteConcern;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.UpdateScript;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.InMemoryDataSet;
+import org.apache.metamodel.query.FunctionType;
+import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.SimpleTableDef;
+import org.bson.Document;
+
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientURI;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+
+public class MongoDbDataContextTest extends MongoDbTestCase {
+
+    private MongoDatabase mongoDb;
+    private MongoClient client;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (isConfigured()) {
+            client = new MongoClient(new MongoClientURI("mongodb://"+getHostname()+":27017"));
+            mongoDb = client.getDatabase(getDatabaseName());
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (isConfigured()) {
+            mongoDb.drop();
+            client.close();
+        }
+    }
+
+    public void testNestedObjectFetching() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+        mongoDb.createCollection(getCollectionName());
+        MongoCollection<Document> col = mongoDb.getCollection(getCollectionName());
+
+        final List<Document> list = new ArrayList<Document>();
+        list.add(new Document().append("city", "Copenhagen").append("country", "Denmark"));
+        list.add(new Document().append("city", "Stockholm").append("country", "Sweden"));
+
+        final Document dbRow = new Document();
+        dbRow.append("name", new Document().append("first", "John").append("last", "Doe"));
+        dbRow.append("gender", "MALE");
+        dbRow.append("addresses", list);
+        col.insertOne(dbRow);
+
+        final MongoDbDataContext dc = new MongoDbDataContext(mongoDb, new SimpleTableDef(getCollectionName(), new String[] {
+                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
+                "addresses[5].foobar" }));
+
+        final DataSet ds = dc.query().from(getCollectionName()).selectAll().execute();
+        try {
+            assertTrue(ds.next());
+            final Object addresses = ds.getRow().getValue(3);
+            assertEquals("Row[values=[John, Doe, MALE, " + addresses + ", Copenhagen, Denmark, null]]", ds.getRow()
+                    .toString());
+            assertTrue(addresses instanceof List);
+            assertFalse(ds.next());
+        } finally {
+            ds.close();
+        }
+    }
+
+    public void testQueriesWithAutoGeneratedID() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+        
+        mongoDb.createCollection(getCollectionName());
+        MongoCollection<Document> col = mongoDb.getCollection(getCollectionName());
+        col.withWriteConcern(WriteConcern.ACKNOWLEDGED);
+        // create a couple of entries
+
+        Document dbRow1 = new Document();
+        dbRow1.put("name", "Mr. Black");
+        dbRow1.put("category", "gen_id");
+        dbRow1.put("age", 20);
+        col.insertOne(dbRow1);
+        final String autoGenID1 = dbRow1.get("_id").toString();
+
+        Document dbRow2 = new Document();
+        dbRow2.put("name", "Mr. Pink");
+        dbRow2.put("category", "gen_id");
+        dbRow2.put("age", 40);
+        col.insertOne(dbRow2);
+        String autoGenID2 = dbRow2.get("_id").toString();
+
+        Document dbRow3 = new Document();
+        dbRow3.put("_id", "123");
+        dbRow3.put("name", "Mr. White");
+        dbRow3.put("category", "gen_id");
+        dbRow3.put("age", 30);
+        col.insertOne(dbRow3);
+        String fixedID3 = dbRow3.get("_id").toString();
+
+        final MongoDbDataContext dc = new MongoDbDataContext(mongoDb);
+        DataSet ds;
+
+        // check all 3 entries inserted
+        ds = dc.query().from(getCollectionName()).selectAll()
+                .where("category").eq("gen_id").execute();
+        assertEquals(3, ds.toRows().size());
+        ds.close();
+
+        // select by autogenerated id
+        ds = dc.query().from(getCollectionName()).select("name").where("_id").eq(autoGenID1).execute();
+        assertTrue(ds.next());
+        assertEquals("Mr. Black", ds.getRow().getValue(0));
+        ds.close();
+
+        // select by multiple autogenerated ids
+        ds = dc.query().from(getCollectionName()).select("name")
+                .where("_id").eq(autoGenID1)
+                .or("_id").eq(autoGenID2)
+                .execute();
+        assertEquals(2, ds.toRows().size());
+        ds.close();
+
+        // select by both autogenerated id and fixed id
+        ds = dc.query().from(getCollectionName()).select("name")
+                .where("_id").eq(autoGenID1)
+                .or("_id").eq(fixedID3)
+                .execute();
+        assertEquals(2, ds.toRows().size());
+        ds.close();
+
+        // delete by id
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                callback.deleteFrom(getCollectionName())
+                        .where("_id").eq(autoGenID1)
+                        .execute();
+            }
+        });
+
+        // select by autogenerated id which was deleted
+        ds = dc.query().from(getCollectionName()).select("name").where("_id").eq(autoGenID1).execute();
+        assertEquals(0, ds.toRows().size());
+        ds.close();
+
+    }
+
+    public void testFirstRowAndMaxRows() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        mongoDb.createCollection(getCollectionName());
+        MongoCollection<Document> col = mongoDb.getCollection(getCollectionName());
+
+        // create 3 records
+        for (int i = 0; i < 3; i++) {
+            Document dbRow = new Document();
+            dbRow.put("id", i + 1);
+            col.insertOne(dbRow);
+        }
+
+        final MongoDbDataContext dc = new MongoDbDataContext(mongoDb);
+
+        DataSet ds;
+
+        ds = dc.query().from(getCollectionName()).select("id").firstRow(2).execute();
+        assertTrue(ds instanceof MongoDbDataSet);
+        assertTrue(ds.next());
+        assertEquals("Row[values=[2]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[3]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+
+        ds = dc.query().from(getCollectionName()).select("id").maxRows(1).execute();
+        assertTrue(ds instanceof MongoDbDataSet);
+        assertTrue(ds.next());
+        assertEquals("Row[values=[1]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+
+        ds = dc.query().from(getCollectionName()).select("id").maxRows(1).firstRow(2).execute();
+        assertTrue(ds instanceof MongoDbDataSet);
+        assertTrue(ds.next());
+        assertEquals("Row[values=[2]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+    }
+
+    public void testRead() throws Exception {
+        // Adding a comment to commit something and invoke a build in Travis...
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        mongoDb.createCollection(getCollectionName());
+        MongoCollection<Document> col = mongoDb.getCollection(getCollectionName());
+
+        // create 1000 records
+        for (int i = 0; i < 1000; i++) {
+            Document dbRow = new Document();
+            dbRow.put("id", i);
+            dbRow.put("name", "record no. " + i);
+            if (i % 5 == 0) {
+                dbRow.put("foo", "bar");
+            } else {
+                dbRow.put("foo", "baz");
+            }
+            Document nestedObj = new Document();
+            nestedObj.put("count", i);
+            nestedObj.put("constant", "foobarbaz");
+            dbRow.put("baz", nestedObj);
+
+            dbRow.put("list", Arrays.<Object> asList("l1", "l2", "l3", i));
+
+            col.insertOne(dbRow);
+        }
+
+        // Instantiate the actual data context
+        final DataContext dataContext = new MongoDbDataContext(mongoDb);
+
+        assertTrue(Arrays.asList(dataContext.getDefaultSchema().getTableNames()).contains(getCollectionName()));
+        
+        Table table = dataContext.getDefaultSchema().getTableByName(getCollectionName());
+        assertEquals("[_id, baz, foo, id, list, name]", Arrays.toString(table.getColumnNames()));
+
+        assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
+        assertEquals(ColumnType.VARCHAR, table.getColumnByName("foo").getType());
+        assertEquals(ColumnType.LIST, table.getColumnByName("list").getType());
+        assertEquals(ColumnType.INTEGER, table.getColumnByName("id").getType());
+        assertEquals(ColumnType.ROWID, table.getColumnByName("_id").getType());
+
+        DataSet ds = dataContext.query().from(getCollectionName()).select("name").and("foo").and("baz").and("list")
+                .where("id").greaterThan(800).or("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+        try {
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 0, bar, Document{{count=0, constant=foobarbaz}}, [l1, l2, l3, 0]]]",
+                    ds.getRow().toString());
+
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 5, bar, Document{{count=5, constant=foobarbaz}}, [l1, l2, l3, 5]]]",
+                    ds.getRow().toString());
+
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 10, bar, Document{{count=10, constant=foobarbaz}}, [l1, l2, l3, 10]]]",
+                    ds.getRow().toString());
+
+            for (int j = 15; j < 801; j++) {
+                if (j % 5 == 0) {
+                    assertTrue(ds.next());
+                    assertEquals("Row[values=[record no. " + j + ", bar, Document{{count=" + j
+                            + ", constant=foobarbaz}}, [l1, l2, l3, " + j + "]]]", ds.getRow()
+                            .toString());
+                }
+            }
+
+            assertTrue(ds.next());
+            assertTrue(ds.getRow().getValue(2) instanceof Map);
+            assertEquals(Document.class, ds.getRow().getValue(2).getClass());
+
+            assertTrue("unexpected type: " + ds.getRow().getValue(3).getClass(),
+                    ds.getRow().getValue(3) instanceof List);
+            assertEquals(ArrayList.class, ds.getRow().getValue(3).getClass());
+
+            assertEquals(
+                    "Row[values=[record no. 801, baz, Document{{count=801, constant=foobarbaz}}, [l1, l2, l3, 801]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 802, baz, Document{{count=802, constant=foobarbaz}}, [l1, l2, l3, 802]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 803, baz, Document{{count=803, constant=foobarbaz}}, [l1, l2, l3, 803]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 804, baz, Document{{count=804, constant=foobarbaz}}, [l1, l2, l3, 804]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 805, bar, Document{{count=805, constant=foobarbaz}}, [l1, l2, l3, 805]]]",
+                    ds.getRow().toString());
+
+            for (int i = 0; i < 194; i++) {
+                assertTrue(ds.next());
+            }
+            assertEquals(
+                    "Row[values=[record no. 999, baz, Document{{count=999, constant=foobarbaz}}, [l1, l2, l3, 999]]]",
+                    ds.getRow().toString());
+            assertFalse(ds.next());
+        } finally {
+            ds.close();
+        }
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").in(2, 6, 8, 9)
+                .execute();
+        assertTrue(ds.next());
+        assertEquals("Row[values=[2, record no. 2]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[6, record no. 6]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[8, record no. 8]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[9, record no. 9]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("foo").isEquals("bar")
+                .execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(200, objectArrays.size());
+            assertEquals("[0, record no. 0]", Arrays.toString(objectArrays.get(0)));
+        } finally {
+            ds.close();
+        }
+
+        // test GREATER_THAN_OR_EQUAL
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id")
+                .greaterThanOrEquals(500).and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(100, objectArrays.size());
+            assertEquals("[500, record no. 500]", Arrays.toString(objectArrays.get(0)));
+        } finally {
+            ds.close();
+        }
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id")
+                .greaterThanOrEquals(501).and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(99, objectArrays.size());
+            assertEquals("[505, record no. 505]", Arrays.toString(objectArrays.get(0)));
+        } finally {
+            ds.close();
+        }
+
+        // test LESS_THAN_OR_EQUAL
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").lessThanOrEquals(500)
+                .and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(101, objectArrays.size());
+            assertEquals("[500, record no. 500]", Arrays.toString(objectArrays.get(100)));
+        } finally {
+            ds.close();
+        }
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").lessThanOrEquals(499)
+                .and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(100, objectArrays.size());
+            assertEquals("[495, record no. 495]", Arrays.toString(objectArrays.get(99)));
+        } finally {
+            ds.close();
+        }
+
+        // test a primary key lookup query
+        Document dbRow = new Document();
+        dbRow.put("_id", 123456);
+        dbRow.put("id", 123456);
+        dbRow.put("name", "record no. " + 123456);
+        dbRow.put("foo", "bar123456");
+        Document nestedObj = new Document();
+        nestedObj.put("count", 123456);
+        nestedObj.put("constant", "foobarbaz");
+        dbRow.put("baz", nestedObj);
+
+        dbRow.put("list", Arrays.<Object> asList("l1", "l2", "l3", 123456));
+
+        col.insertOne(dbRow);
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("_id").eq(123456).execute();
+        assertTrue(ds.next());
+        assertEquals("Row[values=[123456, record no. 123456]]", ds.getRow().toString());
+        assertFalse(ds.next());
+
+        // do a query that we cannot push to mongo
+        // Replace column index 0 by 1
+        ds = dataContext.query().from(getCollectionName())
+                .select(FunctionType.SUM, dataContext.getDefaultSchema().getTables()[0].getColumnByName("id"))
+                .where("foo").isEquals("bar").execute();
+        assertEquals(InMemoryDataSet.class, ds.getClass());
+
+        ds.close();
+    }
+
+    public void testCreateAndWriteData() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+        final MongoDbDataContext dc = new MongoDbDataContext(mongoDb);
+        final Schema defaultSchema = dc.getDefaultSchema();
+
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                Table[] tables = defaultSchema.getTables();
+                for (Table table : tables) {
+                    callback.deleteFrom(table).execute();
+                }
+            }
+        });
+
+        assertEquals(0, defaultSchema.getTableCount());
+
+        dc.executeUpdate(new UpdateScript() {
+
+            @Override
+            public void run(UpdateCallback callback) {
+                Table table = callback.createTable(defaultSchema, "some_entries").withColumn("foo").withColumn("bar")
+                        .withColumn("baz").withColumn("list").execute();
+
+                callback.insertInto(table).value("foo", 1).value("bar", "hello").execute();
+                callback.insertInto(table).value("foo", 2).value("bar", "world").execute();
+                callback.insertInto(table).value("foo", 3).value("bar", "hi").execute();
+
+                Map<String, Object> nestedObj = new HashMap<String, Object>();
+                nestedObj.put("foo", "bar");
+                nestedObj.put("123", 456);
+
+                callback.insertInto(table).value("foo", 4).value("bar", "there").value("baz", nestedObj)
+                        .value("list", Arrays.asList(1, 2, 3)).execute();
+            }
+        });
+
+        DataSet dataSet;
+        assertEquals(1, defaultSchema.getTableCount());
+
+        // "Pure" SELECT COUNT(*) query
+        dataSet = dc.query().from("some_entries").selectCount().execute();
+        dataSet.close();
+        assertTrue(dataSet.next());
+        assertEquals(1, dataSet.getSelectItems().length);
+        assertEquals(SelectItem.getCountAllItem(), dataSet.getSelectItems()[0]);
+        assertEquals(4l, dataSet.getRow().getValue(SelectItem.getCountAllItem()));
+        assertFalse(dataSet.next());
+        assertEquals(InMemoryDataSet.class, dataSet.getClass());
+
+        // A conditional SELECT COUNT(*) query
+        dataSet = dc.query().from("some_entries").selectCount().where("foo").greaterThan(2).execute();
+        dataSet.close();
+        assertTrue(dataSet.next());
+        assertEquals(1, dataSet.getSelectItems().length);
+        assertEquals(SelectItem.getCountAllItem(), dataSet.getSelectItems()[0]);
+        assertEquals(2l, dataSet.getRow().getValue(SelectItem.getCountAllItem()));
+        assertFalse(dataSet.next());
+        assertEquals(InMemoryDataSet.class, dataSet.getClass());
+
+        // Select columns
+        dataSet = dc.query().from("some_entries").select("foo").and("bar").and("baz").and("list").execute();
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[1, hello, null, null]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[2, world, null, null]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[3, hi, null, null]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[4, there, Document{{123=456, foo=bar}}, [1, 2, 3]]]", dataSet.getRow().toString());
+        assertFalse(dataSet.next());
+        dataSet.close();
+        assertEquals(MongoDbDataSet.class, dataSet.getClass());
+
+        // delete some records
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                callback.deleteFrom("some_entries").where("foo").greaterThan(2).where("baz").isNotNull().execute();
+            }
+        });
+
+        dataSet = dc.query().from("some_entries").select("foo").execute();
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[1]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[2]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[3]]", dataSet.getRow().toString());
+        assertFalse(dataSet.next());
+        dataSet.close();
+        assertEquals(MongoDbDataSet.class, dataSet.getClass());
+
+        // drop the collection
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                callback.dropTable("some_entries").execute();
+            }
+        });
+
+        assertNull(dc.getTableByQualifiedLabel("some_entries"));
+
+        dc.refreshSchemas();
+        assertEquals(0, defaultSchema.getTableCount());
+    }
+
+    public void testSelectWithLikeOperator() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        mongoDb.createCollection(getCollectionName());
+        MongoCollection<Document> col = mongoDb.getCollection(getCollectionName());
+
+        final Document dbRow = new Document();
+        dbRow.append("name", new Document().append("first", "John").append("last", "Doe"));
+        dbRow.append("gender", "MALE");
+        col.insertOne(dbRow);
+
+        final Document dbRow2 = new Document();
+        dbRow2.append("name", new Document().append("first", "Mary").append("last", "Johnson"));
+        dbRow2.append("gender", "FEMALE");
+        col.insertOne(dbRow2);
+
+        final Document dbRow3 = new Document();
+        dbRow3.append("name", new Document().append("first", "X").append("last", "Unknown"));
+        dbRow3.append("gender", "UNKNOWN");
+        col.insertOne(dbRow3);
+
+        final MongoDbDataContext dc = new MongoDbDataContext(mongoDb, new SimpleTableDef(getCollectionName(), new String[] {
+                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
+                "addresses[5].foobar" }));
+
+        final DataSet ds1 = dc.executeQuery("select * from my_collection where gender LIKE '%MALE%'");
+        final DataSet ds2 = dc.executeQuery("select * from my_collection where gender LIKE 'MALE%'");
+        final DataSet ds3 = dc.executeQuery("select * from my_collection where gender LIKE '%NK%OW%'");
+        final DataSet ds4 = dc.executeQuery("select * from my_collection where gender LIKE '%MALE'");
+        try {
+            assertTrue(ds1.next());
+            assertTrue(ds1.next());
+            assertFalse(ds1.next());
+            assertTrue(ds2.next());
+            assertFalse(ds2.next());
+            assertTrue(ds3.next());
+            assertFalse(ds3.next());
+            assertTrue(ds4.next());
+            assertTrue(ds4.next());
+            assertFalse(ds4.next());
+        } finally {
+            ds1.close();
+            ds2.close();
+            ds3.close();
+            ds4.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
new file mode 100644
index 0000000..42ef536
--- /dev/null
+++ b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.UpdateScript;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.jdbc.JdbcDataContext;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.FileHelper;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+
+
+/**
+ * Simple example program that can copy data to a MongoDB collection
+ */
+public class MongoDbDataCopyer {
+
+    private final DataContext _sourceDataContext;
+    private final MongoDatabase _mongoDb;
+    private final String _collectionName;
+    private final String _sourceSchemaName;
+    private final String _sourceTableName;
+
+    // example copy job that will populate the mongodb with Derby data
+    public static void main(String[] args) throws Exception {
+        System.setProperty("derby.storage.tempDirector", FileHelper.getTempDir().getAbsolutePath());
+        System.setProperty("derby.stream.error.file", File.createTempFile("metamodel-derby", ".log").getAbsolutePath());
+
+        File dbFile = new File("../jdbc/src/test/resources/derby_testdb.jar");
+        dbFile = dbFile.getCanonicalFile();
+        if (!dbFile.exists()) {
+            throw new IllegalStateException("File does not exist: " + dbFile);
+        }
+
+        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+        Connection connection = DriverManager.getConnection("jdbc:derby:jar:(" + dbFile.getAbsolutePath()
+                + ")derby_testdb;territory=en");
+        connection.setReadOnly(true);
+
+        MongoClient client =  new MongoClient();
+        MongoDatabase mongoDb = client.getDatabase("orderdb_copy");
+
+        DataContext sourceDataContext = new JdbcDataContext(connection);
+
+        new MongoDbDataCopyer(mongoDb, "orders", sourceDataContext, "APP", "orders").copy();
+        new MongoDbDataCopyer(mongoDb, "offices", sourceDataContext, "APP", "offices").copy();
+        new MongoDbDataCopyer(mongoDb, "payments", sourceDataContext, "APP", "payments").copy();
+        new MongoDbDataCopyer(mongoDb, "orderfact", sourceDataContext, "APP", "orderfact").copy();
+        new MongoDbDataCopyer(mongoDb, "products", sourceDataContext, "APP", "products").copy();
+
+        connection.close();
+        client.close();
+    }
+
+    public MongoDbDataCopyer(MongoDatabase mongoDb, String collectionName, DataContext sourceDataContext, String sourceSchemaName,
+            String sourceTableName) {
+        _mongoDb = mongoDb;
+        _collectionName = collectionName;
+        _sourceDataContext = sourceDataContext;
+        _sourceSchemaName = sourceSchemaName;
+        _sourceTableName = sourceTableName;
+    }
+
+    public void copy() {
+        final MongoDbDataContext targetDataContext = new MongoDbDataContext(_mongoDb);
+        targetDataContext.executeUpdate(new UpdateScript() {
+
+            @Override
+            public void run(UpdateCallback callback) {
+                final Table sourceTable = getSourceTable();
+                final Table targetTable = callback.createTable(targetDataContext.getDefaultSchema(), _collectionName)
+                        .like(sourceTable).execute();
+                final Column[] sourceColumns = sourceTable.getColumns();
+                final DataSet dataSet = _sourceDataContext.query().from(sourceTable).select(sourceColumns).execute();
+                while (dataSet.next()) {
+                    final Row row = dataSet.getRow();
+
+                    RowInsertionBuilder insertBuilder = callback.insertInto(targetTable);
+                    for (Column column : sourceColumns) {
+                        insertBuilder = insertBuilder.value(column.getName(), row.getValue(column));
+                    }
+                    insertBuilder.execute();
+                }
+                dataSet.close();
+            }
+        });
+    }
+
+    private Table getSourceTable() {
+        final Schema schema;
+        if (_sourceSchemaName != null) {
+            schema = _sourceDataContext.getSchemaByName(_sourceSchemaName);
+        } else {
+            schema = _sourceDataContext.getDefaultSchema();
+        }
+
+        return schema.getTableByName(_sourceTableName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbTestCase.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbTestCase.java b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbTestCase.java
new file mode 100644
index 0000000..edc98c9
--- /dev/null
+++ b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbTestCase.java
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+public abstract class MongoDbTestCase extends TestCase {
+
+    private static final String DEFAULT_TEST_COLLECTION_NAME = "my_collection";
+    private static final String DEFAULT_TEST_DATABASE_NAME = "metamodel_test";
+
+    private String _hostname;
+    private String _collectionName;
+    private boolean _configured;
+
+    private String _databaseName;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        File file = new File(getPropertyFilePath());
+        if (file.exists()) {
+            loadPropertyFile(file);
+        } else {
+            // Continuous integration case
+            if (System.getenv("CONTINUOUS_INTEGRATION") != null) {
+                File travisFile = new File("../travis-metamodel-integrationtest-configuration.properties");
+                if (travisFile.exists()) {
+                    loadPropertyFile(travisFile);
+                } else {
+                    _configured = false;
+                }
+            } else {
+                _configured = false;
+            }
+        }
+    }
+
+    private void loadPropertyFile(File file) throws FileNotFoundException, IOException {
+        Properties properties = new Properties();
+        properties.load(new FileReader(file));
+        _hostname = properties.getProperty("mongodb.hostname");
+        
+        _databaseName = properties.getProperty("mongodb.databaseName");
+        if (_databaseName == null || _databaseName.isEmpty()) {
+            _databaseName = DEFAULT_TEST_DATABASE_NAME;
+        }
+        
+        _collectionName = properties.getProperty("mongodb.collectionName");
+        if (_collectionName == null || _collectionName.isEmpty()) {
+            _collectionName = DEFAULT_TEST_COLLECTION_NAME;
+        }
+
+        _configured = (_hostname != null && !_hostname.isEmpty());
+
+        if (_configured) {
+            System.out.println("Loaded MongoDB configuration. Hostname=" + _hostname + ", Collection="
+                    + _collectionName);
+        }
+        
+    }
+
+    private String getPropertyFilePath() {
+        String userHome = System.getProperty("user.home");
+        return userHome + "/metamodel-integrationtest-configuration.properties";
+    }
+
+    protected String getInvalidConfigurationMessage() {
+        return "!!! WARN !!! MongoDB module ignored\r\n" + "Please configure mongodb connection locally ("
+                + getPropertyFilePath() + "), to run integration tests";
+    }
+    
+    public String getDatabaseName() {
+        return _databaseName;
+    }
+
+    public String getCollectionName() {
+        return _collectionName;
+    }
+
+    public String getHostname() {
+        return _hostname;
+    }
+    
+    public boolean isConfigured() {
+        return _configured;
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 61a3784..c0a9448 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -25,41 +25,12 @@ under the License.
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>
+	<packaging>pom</packaging>
 	<name>MetaModel module for MongoDB databases</name>
-	<dependencies>
-		<dependency>
-			<groupId>org.apache.metamodel</groupId>
-			<artifactId>MetaModel-core</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>org.mongodb</groupId>
-			<artifactId>mongo-java-driver</artifactId>
-			<version>3.1.0</version>
-		</dependency>
-
-		<!-- Test dependencies -->
-		<dependency>
-			<groupId>org.apache.metamodel</groupId>
-			<artifactId>MetaModel-jdbc</artifactId>
-			<version>${project.version}</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.derby</groupId>
-			<artifactId>derby</artifactId>
-			<version>10.8.1.2</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-nop</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
+	
+	<modules>
+		<module>common</module>
+		<module>mongo2</module>
+		<module>mongo3</module>
+	</modules>
 </project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/DefaultWriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/DefaultWriteConcernAdvisor.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/DefaultWriteConcernAdvisor.java
deleted file mode 100644
index 6ea1903..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/DefaultWriteConcernAdvisor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import com.mongodb.WriteConcern;
-
-/**
- * Default {@link WriteConcernAdvisor}. Always returns
- * {@link WriteConcern#NORMAL}.
- */
-public class DefaultWriteConcernAdvisor extends SimpleWriteConcernAdvisor {
-
-    public DefaultWriteConcernAdvisor() {
-        super(WriteConcern.NORMAL);
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDBUtils.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDBUtils.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDBUtils.java
deleted file mode 100644
index cb69a04..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDBUtils.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.metamodel.data.DataSetHeader;
-import org.apache.metamodel.data.DefaultRow;
-import org.apache.metamodel.data.Row;
-import org.apache.metamodel.query.SelectItem;
-import org.apache.metamodel.schema.Column;
-import org.apache.metamodel.util.CollectionUtils;
-
-import com.mongodb.DBObject;
-
-/**
- * A utility class for MongoDB module.
- */
-public class MongoDBUtils {
-
-    /**
-     * Converts a MongoDB data object {@link DBObject} into MetaModel
-     * {@link Row}.
-     * 
-     * @param dbObject
-     *            a MongoDB object storing data.
-     * @param header
-     *            a header describing the columns of the data stored.
-     * @return the MetaModel {@link Row} result object.
-     */
-    public static Row toRow(DBObject dbObject, DataSetHeader header) {
-        if (dbObject == null) {
-            return null;
-        }
-
-        final Map<?,?> map = dbObject.toMap();
-
-        final int size = header.size();
-        final Object[] values = new Object[size];
-        for (int i = 0; i < values.length; i++) {
-            final SelectItem selectItem = header.getSelectItem(i);
-            final String key = selectItem.getColumn().getName();
-            final Object value = CollectionUtils.find(map, key);
-            values[i] = toValue(selectItem.getColumn(), value);
-        }
-        return new DefaultRow(header, values);
-    }
-
-    private static Object toValue(Column column, Object value) {
-        if (value instanceof List) {
-            return value;
-        }
-        if (value instanceof DBObject) {
-            DBObject basicDBObject = (DBObject) value;
-            return basicDBObject.toMap();
-        }
-        return value;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataContext.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataContext.java
deleted file mode 100644
index 26db6d4..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataContext.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.regex.Pattern;
-
-import org.apache.metamodel.DataContext;
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.QueryPostprocessDataContext;
-import org.apache.metamodel.UpdateScript;
-import org.apache.metamodel.UpdateableDataContext;
-import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.data.DataSetHeader;
-import org.apache.metamodel.data.InMemoryDataSet;
-import org.apache.metamodel.data.Row;
-import org.apache.metamodel.data.SimpleDataSetHeader;
-import org.apache.metamodel.query.FilterItem;
-import org.apache.metamodel.query.FromItem;
-import org.apache.metamodel.query.OperatorType;
-import org.apache.metamodel.query.Query;
-import org.apache.metamodel.query.SelectItem;
-import org.apache.metamodel.schema.Column;
-import org.apache.metamodel.schema.ColumnType;
-import org.apache.metamodel.schema.ColumnTypeImpl;
-import org.apache.metamodel.schema.MutableColumn;
-import org.apache.metamodel.schema.MutableSchema;
-import org.apache.metamodel.schema.MutableTable;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-import org.apache.metamodel.util.SimpleTableDef;
-import org.bson.types.ObjectId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.mongodb.BasicDBList;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-import com.mongodb.WriteConcern;
-
-/**
- * DataContext implementation for MongoDB.
- *
- * Since MongoDB has no schema, a virtual schema will be used in this
- * DataContext. This implementation supports either automatic discovery of a
- * schema or manual specification of a schema, through the
- * {@link MongoDbTableDef} class.
- */
-public class MongoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext {
-
-    private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
-
-    private final DB _mongoDb;
-    private final SimpleTableDef[] _tableDefs;
-    private WriteConcernAdvisor _writeConcernAdvisor;
-    private Schema _schema;
-
-    /**
-     * Constructor available for backwards compatibility
-     *
-     * @deprecated use {@link #MongoDbDataContext(DB, SimpleTableDef...)}
-     *             instead
-     */
-    @Deprecated
-    public MongoDbDataContext(DB mongoDb, MongoDbTableDef... tableDefs) {
-        this(mongoDb, (SimpleTableDef[]) tableDefs);
-    }
-
-    /**
-     * Constructs a {@link MongoDbDataContext}. This constructor accepts a
-     * custom array of {@link MongoDbTableDef}s which allows the user to define
-     * his own view on the collections in the database.
-     *
-     * @param mongoDb
-     *            the mongo db connection
-     * @param tableDefs
-     *            an array of {@link MongoDbTableDef}s, which define the table
-     *            and column model of the mongo db collections. (consider using
-     *            {@link #detectSchema(DB)} or {@link #detectTable(DB, String)}
-     *            ).
-     */
-    public MongoDbDataContext(DB mongoDb, SimpleTableDef... tableDefs) {
-        _mongoDb = mongoDb;
-        _tableDefs = tableDefs;
-        _schema = null;
-    }
-
-    /**
-     * Constructs a {@link MongoDbDataContext} and automatically detects the
-     * schema structure/view on all collections (see {@link #detectSchema(DB)}).
-     *
-     * @param mongoDb
-     *            the mongo db connection
-     */
-    public MongoDbDataContext(DB mongoDb) {
-        this(mongoDb, detectSchema(mongoDb));
-    }
-
-    /**
-     * Performs an analysis of the available collections in a Mongo {@link DB}
-     * instance and tries to detect the table's structure based on the first
-     * 1000 documents in each collection.
-     *
-     * @param db
-     *            the mongo db to inspect
-     * @return a mutable schema instance, useful for further fine tuning by the
-     *         user.
-     * @see #detectTable(DB, String)
-     */
-    public static SimpleTableDef[] detectSchema(DB db) {
-        Set<String> collectionNames = db.getCollectionNames();
-        SimpleTableDef[] result = new SimpleTableDef[collectionNames.size()];
-        int i = 0;
-        for (String collectionName : collectionNames) {
-            SimpleTableDef table = detectTable(db, collectionName);
-            result[i] = table;
-            i++;
-        }
-        return result;
-    }
-
-    /**
-     * Performs an analysis of an available collection in a Mongo {@link DB}
-     * instance and tries to detect the table structure based on the first 1000
-     * documents in the collection.
-     *
-     * @param db
-     *            the mongo DB
-     * @param collectionName
-     *            the name of the collection
-     * @return a table definition for mongo db.
-     */
-    public static SimpleTableDef detectTable(DB db, String collectionName) {
-        final DBCollection collection = db.getCollection(collectionName);
-        final DBCursor cursor = collection.find().limit(1000);
-
-        final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
-        while (cursor.hasNext()) {
-            DBObject object = cursor.next();
-            Set<String> keysInObject = object.keySet();
-            for (String key : keysInObject) {
-                Set<Class<?>> types = columnsAndTypes.get(key);
-                if (types == null) {
-                    types = new HashSet<Class<?>>();
-                    columnsAndTypes.put(key, types);
-                }
-                Object value = object.get(key);
-                if (value != null) {
-                    types.add(value.getClass());
-                }
-            }
-        }
-        cursor.close();
-
-        final String[] columnNames = new String[columnsAndTypes.size()];
-        final ColumnType[] columnTypes = new ColumnType[columnsAndTypes.size()];
-
-        int i = 0;
-        for (Entry<String, Set<Class<?>>> columnAndTypes : columnsAndTypes.entrySet()) {
-            final String columnName = columnAndTypes.getKey();
-            final Set<Class<?>> columnTypeSet = columnAndTypes.getValue();
-            final Class<?> columnType;
-            if (columnTypeSet.size() == 1) {
-                columnType = columnTypeSet.iterator().next();
-            } else {
-                columnType = Object.class;
-            }
-            columnNames[i] = columnName;
-            if (columnType == ObjectId.class) {
-                columnTypes[i] = ColumnType.ROWID;
-            } else {
-                columnTypes[i] = ColumnTypeImpl.convertColumnType(columnType);
-            }
-            i++;
-        }
-
-        return new SimpleTableDef(collectionName, columnNames, columnTypes);
-    }
-
-    @Override
-    protected Schema getMainSchema() throws MetaModelException {
-        if (_schema == null) {
-            MutableSchema schema = new MutableSchema(getMainSchemaName());
-            for (SimpleTableDef tableDef : _tableDefs) {
-
-                MutableTable table = tableDef.toTable().setSchema(schema);
-                Column[] rowIdColumns = table.getColumnsOfType(ColumnType.ROWID);
-                for (Column column : rowIdColumns) {
-                    if (column instanceof MutableColumn) {
-                        ((MutableColumn) column).setPrimaryKey(true);
-                    }
-                }
-
-                schema.addTable(table);
-            }
-
-            _schema = schema;
-        }
-        return _schema;
-    }
-
-    @Override
-    protected String getMainSchemaName() throws MetaModelException {
-        return _mongoDb.getName();
-    }
-
-    @Override
-    protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
-        final DBCollection collection = _mongoDb.getCollection(table.getName());
-
-        final DBObject query = createMongoDbQuery(table, whereItems);
-
-        logger.info("Executing MongoDB 'count' query: {}", query);
-        final long count = collection.count(query);
-
-        return count;
-    }
-
-    @Override
-    protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
-            Object keyValue) {
-        final DBCollection collection = _mongoDb.getCollection(table.getName());
-
-        List<FilterItem> whereItems = new ArrayList<FilterItem>();
-        SelectItem selectItem = new SelectItem(primaryKeyColumn);
-        FilterItem primaryKeyWhereItem = new FilterItem(selectItem, OperatorType.EQUALS_TO, keyValue);
-        whereItems.add(primaryKeyWhereItem);
-        final DBObject query = createMongoDbQuery(table, whereItems);
-        final DBObject resultDBObject = collection.findOne(query);
-
-        DataSetHeader header = new SimpleDataSetHeader(selectItems);
-
-        Row row = MongoDBUtils.toRow(resultDBObject, header);
-
-        return row;
-    }
-
-    @Override
-    public DataSet executeQuery(Query query) {
-        // Check for queries containing only simple selects and where clauses,
-        // or if it is a COUNT(*) query.
-
-        // if from clause only contains a main schema table
-        List<FromItem> fromItems = query.getFromClause().getItems();
-        if (fromItems.size() == 1 && fromItems.get(0).getTable() != null
-                && fromItems.get(0).getTable().getSchema() == _schema) {
-            final Table table = fromItems.get(0).getTable();
-
-            // if GROUP BY, HAVING and ORDER BY clauses are not specified
-            if (query.getGroupByClause().isEmpty() && query.getHavingClause().isEmpty()
-                    && query.getOrderByClause().isEmpty()) {
-
-                final List<FilterItem> whereItems = query.getWhereClause().getItems();
-
-                // if all of the select items are "pure" column selection
-                boolean allSelectItemsAreColumns = true;
-                List<SelectItem> selectItems = query.getSelectClause().getItems();
-
-                // if it is a
-                // "SELECT [columns] FROM [table] WHERE [conditions]"
-                // query.
-                for (SelectItem selectItem : selectItems) {
-                    if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
-                        allSelectItemsAreColumns = false;
-                        break;
-                    }
-                }
-
-                if (allSelectItemsAreColumns) {
-                    logger.debug("Query can be expressed in full MongoDB, no post processing needed.");
-
-                    // prepare for a non-post-processed query
-                    Column[] columns = new Column[selectItems.size()];
-                    for (int i = 0; i < columns.length; i++) {
-                        columns[i] = selectItems.get(i).getColumn();
-                    }
-
-                    // checking if the query is a primary key lookup query
-                    if (whereItems.size() == 1) {
-                        final FilterItem whereItem = whereItems.get(0);
-                        final SelectItem selectItem = whereItem.getSelectItem();
-                        if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
-                            final Column column = selectItem.getColumn();
-                            if (column.isPrimaryKey() && OperatorType.EQUALS_TO.equals(whereItem.getOperator())) {
-                                logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
-                                final Object operand = whereItem.getOperand();
-                                final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
-                                if (row == null) {
-                                    logger.debug("DataContext did not return any primary key lookup query results. Proceeding "
-                                            + "with manual lookup.");
-                                } else {
-                                    final DataSetHeader header = new SimpleDataSetHeader(selectItems);
-                                    return new InMemoryDataSet(header, row);
-                                }
-                            }
-                        }
-                    }
-
-                    int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
-                    int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
-
-                    final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
-                            maxRows, false);
-                    return dataSet;
-                }
-            }
-        }
-
-        logger.debug("Query will be simplified for MongoDB and post processed.");
-        return super.executeQuery(query);
-    }
-
-    private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
-            int firstRow, int maxRows, boolean queryPostProcessed) {
-        final DBCollection collection = _mongoDb.getCollection(table.getName());
-
-        final DBObject query = createMongoDbQuery(table, whereItems);
-
-        logger.info("Executing MongoDB 'find' query: {}", query);
-        DBCursor cursor = collection.find(query);
-
-        if (maxRows > 0) {
-            cursor = cursor.limit(maxRows);
-        }
-        if (firstRow > 1) {
-            final int skip = firstRow - 1;
-            cursor = cursor.skip(skip);
-        }
-
-        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
-    }
-
-    protected BasicDBObject createMongoDbQuery(Table table, List<FilterItem> whereItems) {
-        assert _schema == table.getSchema();
-
-        final BasicDBObject query = new BasicDBObject();
-        if (whereItems != null && !whereItems.isEmpty()) {
-            for (FilterItem item : whereItems) {
-                convertToCursorObject(query, item);
-            }
-        }
-
-        return query;
-    }
-
-    private void convertToCursorObject(BasicDBObject query, FilterItem item) {
-        if (item.isCompoundFilter()) {
-
-            BasicDBList orList = new BasicDBList();
-
-            final FilterItem[] childItems = item.getChildItems();
-            for (FilterItem childItem : childItems) {
-                BasicDBObject childObject = new BasicDBObject();
-                convertToCursorObject(childObject, childItem);
-                orList.add(childObject);
-            }
-
-            query.put("$or", orList);
-
-        } else {
-
-            final Column column = item.getSelectItem().getColumn();
-            final String columnName = column.getName();
-            final String operatorName = getOperatorName(item);
-
-            Object operand = item.getOperand();
-            if (ObjectId.isValid(String.valueOf(operand))) {
-                operand = new ObjectId(String.valueOf(operand));
-            }
-
-            final BasicDBObject existingFilterObject = (BasicDBObject) query.get(columnName);
-            if (existingFilterObject == null) {
-                if (operatorName == null) {
-                    if (OperatorType.LIKE.equals(item.getOperator())) {
-                        query.put(columnName, turnOperandIntoRegExp(operand));
-                    } else {
-                        query.put(columnName, operand);
-                    }
-                } else {
-                    query.put(columnName, new BasicDBObject(operatorName, operand));
-                }
-            } else {
-                if (operatorName == null) {
-                    throw new IllegalStateException("Cannot retrieve records for a column with two EQUALS_TO operators");
-                } else {
-                    existingFilterObject.append(operatorName, operand);
-                }
-            }
-        }
-    }
-
-    private String getOperatorName(FilterItem item) {
-        final OperatorType operator = item.getOperator();
-
-        if (OperatorType.EQUALS_TO.equals(operator)) {
-            return null;
-        }
-        if (OperatorType.LIKE.equals(operator)) {
-            return null;
-        }
-        if (OperatorType.LESS_THAN.equals(operator)) {
-            return "$lt";
-        }
-        if (OperatorType.LESS_THAN_OR_EQUAL.equals(operator)) {
-            return "$lte";
-        }
-        if (OperatorType.GREATER_THAN.equals(operator)) {
-            return "$gt";
-        }
-        if (OperatorType.GREATER_THAN_OR_EQUAL.equals(operator)) {
-            return "$gte";
-        }
-        if (OperatorType.DIFFERENT_FROM.equals(operator)) {
-            return "$ne";
-        }
-        if (OperatorType.IN.equals(operator)) {
-            return "$in";
-        }
-
-        throw new IllegalStateException("Unsupported operator type: " + operator);
-    }
-
-    private Pattern turnOperandIntoRegExp(Object operand) {
-        StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operand.toString()));
-        operandAsRegExp.insert(0, "^").append("$");
-        return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE);
-    }
-
-    private String replaceWildCardLikeChars(String operand) {
-        return operand.replaceAll("%", ".*");
-    }
-
-    @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
-        return materializeMainSchemaTableInternal(table, columns, null, 1, maxRows, true);
-    }
-
-    @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows) {
-        return materializeMainSchemaTableInternal(table, columns, null, firstRow, maxRows, true);
-    }
-
-    /**
-     * Executes an update with a specific {@link WriteConcernAdvisor}.
-     */
-    public void executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
-        MongoDbUpdateCallback callback = new MongoDbUpdateCallback(this, writeConcernAdvisor);
-        try {
-            update.run(callback);
-        } finally {
-            callback.close();
-        }
-    }
-
-    /**
-     * Executes an update with a specific {@link WriteConcern}.
-     */
-    public void executeUpdate(UpdateScript update, WriteConcern writeConcern) {
-        executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
-    }
-
-    @Override
-    public void executeUpdate(UpdateScript update) {
-        executeUpdate(update, getWriteConcernAdvisor());
-    }
-
-    /**
-     * Gets the {@link WriteConcernAdvisor} to use on
-     * {@link #executeUpdate(UpdateScript)} calls.
-     */
-    public WriteConcernAdvisor getWriteConcernAdvisor() {
-        if (_writeConcernAdvisor == null) {
-            return new DefaultWriteConcernAdvisor();
-        }
-        return _writeConcernAdvisor;
-    }
-
-    /**
-     * Sets a global {@link WriteConcern} advisor to use on
-     * {@link #executeUpdate(UpdateScript)}.
-     */
-    public void setWriteConcernAdvisor(WriteConcernAdvisor writeConcernAdvisor) {
-        _writeConcernAdvisor = writeConcernAdvisor;
-    }
-
-    /**
-     * Gets the {@link DB} instance that this {@link DataContext} is backed by.
-     */
-    public DB getMongoDb() {
-        return _mongoDb;
-    }
-
-    protected void addTable(MutableTable table) {
-        if (_schema instanceof MutableSchema) {
-            MutableSchema mutableSchema = (MutableSchema) _schema;
-            mutableSchema.addTable(table);
-        } else {
-            throw new UnsupportedOperationException("Schema is not mutable");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataSet.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataSet.java
deleted file mode 100644
index ee522b8..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDataSet.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import org.apache.metamodel.data.AbstractDataSet;
-import org.apache.metamodel.data.Row;
-import org.apache.metamodel.schema.Column;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-
-final class MongoDbDataSet extends AbstractDataSet {
-
-    private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
-
-    private final DBCursor _cursor;
-    private final boolean _queryPostProcessed;
-
-    private boolean _closed;
-    private volatile DBObject _dbObject;
-
-    public MongoDbDataSet(DBCursor cursor, Column[] columns, boolean queryPostProcessed) {
-        super(columns);
-        _cursor = cursor;
-        _queryPostProcessed = queryPostProcessed;
-        _closed = false;
-    }
-
-    public boolean isQueryPostProcessed() {
-        return _queryPostProcessed;
-    }
-
-    @Override
-    public void close() {
-        super.close();
-        _cursor.close();
-        _closed = true;
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        super.finalize();
-        if (!_closed) {
-            logger.warn("finalize() invoked, but DataSet is not closed. Invoking close() on {}", this);
-            close();
-        }
-    }
-
-    @Override
-    public boolean next() {
-        if (_cursor.hasNext()) {
-            _dbObject = _cursor.next();
-            return true;
-        } else {
-            _dbObject = null;
-            return false;
-        }
-    }
-
-    @Override
-    public Row getRow() {
-        return MongoDBUtils.toRow(_dbObject, getHeader());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDeleteBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDeleteBuilder.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDeleteBuilder.java
deleted file mode 100644
index f1b8591..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDeleteBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.delete.AbstractRowDeletionBuilder;
-import org.apache.metamodel.schema.Table;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-import com.mongodb.WriteConcern;
-import com.mongodb.WriteResult;
-
-final class MongoDbDeleteBuilder extends AbstractRowDeletionBuilder {
-
-    private static final Logger logger = LoggerFactory.getLogger(MongoDbDeleteBuilder.class);
-
-    private final MongoDbUpdateCallback _updateCallback;
-
-    public MongoDbDeleteBuilder(MongoDbUpdateCallback updateCallback, Table table) {
-        super(table);
-        _updateCallback = updateCallback;
-    }
-
-    @Override
-    public void execute() throws MetaModelException {
-        final DBCollection collection = _updateCallback.getCollection(getTable().getName());
-
-        final MongoDbDataContext dataContext = _updateCallback.getDataContext();
-        final BasicDBObject query = dataContext.createMongoDbQuery(getTable(), getWhereItems());
-        
-        WriteConcern writeConcern = _updateCallback.getWriteConcernAdvisor().adviceDeleteQuery(collection, query);
-        
-        final WriteResult writeResult = collection.remove(query, writeConcern);
-        logger.info("Remove returned result: {}", writeResult);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDropTableBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDropTableBuilder.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDropTableBuilder.java
deleted file mode 100644
index 4164346..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbDropTableBuilder.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.drop.AbstractTableDropBuilder;
-import org.apache.metamodel.schema.MutableSchema;
-import org.apache.metamodel.schema.Table;
-
-final class MongoDbDropTableBuilder extends AbstractTableDropBuilder {
-
-    private final MongoDbUpdateCallback _updateCallback;
-
-    public MongoDbDropTableBuilder(MongoDbUpdateCallback updateCallback, Table table) {
-        super(table);
-        _updateCallback = updateCallback;
-    }
-
-    @Override
-    public void execute() throws MetaModelException {
-        Table table = getTable();
-        _updateCallback.removeCollection(table.getName());
-        MutableSchema schema = (MutableSchema) table.getSchema();
-        schema.removeTable(table);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbInsertionBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbInsertionBuilder.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbInsertionBuilder.java
deleted file mode 100644
index 412612c..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbInsertionBuilder.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.insert.AbstractRowInsertionBuilder;
-import org.apache.metamodel.insert.RowInsertionBuilder;
-import org.apache.metamodel.schema.Column;
-import org.apache.metamodel.schema.Table;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-import com.mongodb.WriteConcern;
-import com.mongodb.WriteResult;
-
-final class MongoDbInsertionBuilder extends AbstractRowInsertionBuilder<MongoDbUpdateCallback> implements RowInsertionBuilder {
-
-    private static final Logger logger = LoggerFactory.getLogger(MongoDbInsertionBuilder.class);
-
-    public MongoDbInsertionBuilder(MongoDbUpdateCallback updateCallback, Table table) {
-        super(updateCallback, table);
-    }
-
-    @Override
-    public void execute() throws MetaModelException {
-        final Column[] columns = getColumns();
-        final Object[] values = getValues();
-
-        final BasicDBObject doc = new BasicDBObject();
-
-        for (int i = 0; i < values.length; i++) {
-            Object value = values[i];
-            if (value != null) {
-                doc.put(columns[i].getName(), value);
-            }
-        }
-
-        final MongoDbUpdateCallback updateCallback = getUpdateCallback();
-        final DBCollection collection = updateCallback.getCollection(getTable().getName());
-
-        final WriteConcern writeConcern = updateCallback.getWriteConcernAdvisor().adviceInsert(collection, doc);
-
-        final WriteResult writeResult = collection.insert(doc, writeConcern);
-        logger.info("Insert returned result: {}", writeResult);
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableCreationBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableCreationBuilder.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableCreationBuilder.java
deleted file mode 100644
index a57590d..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableCreationBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.create.AbstractTableCreationBuilder;
-import org.apache.metamodel.create.TableCreationBuilder;
-import org.apache.metamodel.schema.ColumnType;
-import org.apache.metamodel.schema.ImmutableColumn;
-import org.apache.metamodel.schema.MutableTable;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-
-final class MongoDbTableCreationBuilder extends
-		AbstractTableCreationBuilder<MongoDbUpdateCallback> implements
-		TableCreationBuilder {
-
-	public MongoDbTableCreationBuilder(MongoDbUpdateCallback updateCallback,
-			Schema schema, String name) {
-		super(updateCallback, schema, name);
-	}
-
-	@Override
-	public Table execute() throws MetaModelException {
-		final MongoDbDataContext dataContext = getUpdateCallback()
-				.getDataContext();
-		final Schema schema = dataContext.getDefaultSchema();
-		final MutableTable table = getTable();
-		if (table.getColumnByName("_id") == null) {
-			// all mongo db collections have an _id field as the first field.
-			ImmutableColumn idColumn = new ImmutableColumn("_id",
-					ColumnType.ROWID, table, table.getColumnCount(), null,
-					null, null, null, true, null, true);
-			table.addColumn(idColumn);
-		}
-		table.setSchema(schema);
-		getUpdateCallback().createCollection(table.getName());
-		dataContext.addTable(table);
-		return table;
-	}
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableDef.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableDef.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableDef.java
deleted file mode 100644
index 0a40fa1..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbTableDef.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.io.Serializable;
-
-import org.apache.metamodel.schema.ColumnType;
-import org.apache.metamodel.util.SimpleTableDef;
-
-/**
- * Defines a table layout for {@link MongoDbDataContext} tables. This class can
- * be used as an instruction set for the {@link MongoDbDataContext} to specify
- * which collections, which columns (and their types) should be included in the
- * schema structure of a Mongo DB database.
- * 
- * @deprecated use {@link SimpleTableDef} instead.
- */
-@Deprecated
-public final class MongoDbTableDef extends SimpleTableDef implements Serializable {
-
-	private static final long serialVersionUID = 1L;
-
-	public MongoDbTableDef(String name, String[] columnNames, ColumnType[] columnTypes) {
-		super(name, columnNames, columnTypes);
-	}
-
-	public MongoDbTableDef(String name, String[] columnNames) {
-		super(name, columnNames);
-	}
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbUpdateCallback.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbUpdateCallback.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbUpdateCallback.java
deleted file mode 100644
index 0558898..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/MongoDbUpdateCallback.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.io.Closeable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.metamodel.AbstractUpdateCallback;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.create.TableCreationBuilder;
-import org.apache.metamodel.delete.RowDeletionBuilder;
-import org.apache.metamodel.drop.TableDropBuilder;
-import org.apache.metamodel.insert.RowInsertionBuilder;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-
-final class MongoDbUpdateCallback extends AbstractUpdateCallback implements UpdateCallback, Closeable {
-
-    private final MongoDbDataContext _dataContext;
-    private final Map<String, DBCollection> _collections;
-    private final WriteConcernAdvisor _writeConcernAdvisor;
-
-    public MongoDbUpdateCallback(MongoDbDataContext dataContext, WriteConcernAdvisor writeConcernAdvisor) {
-        super(dataContext);
-        _dataContext = dataContext;
-        _writeConcernAdvisor = writeConcernAdvisor;
-        _collections = new HashMap<String, DBCollection>();
-    }
-
-    @Override
-    public MongoDbDataContext getDataContext() {
-        return _dataContext;
-    }
-    
-    public WriteConcernAdvisor getWriteConcernAdvisor() {
-        return _writeConcernAdvisor;
-    }
-
-    @Override
-    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
-            IllegalStateException {
-        return new MongoDbTableCreationBuilder(this, schema, name);
-    }
-
-    @Override
-    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException {
-        return new MongoDbInsertionBuilder(this, table);
-    }
-
-    protected void createCollection(String name) {
-        DBCollection collection = _dataContext.getMongoDb().createCollection(name, new BasicDBObject());
-        _collections.put(name, collection);
-    }
-
-    protected void removeCollection(String name) {
-        DBCollection collection = getCollection(name);
-        _collections.remove(name);
-        collection.drop();
-    }
-
-    protected DBCollection getCollection(String name) {
-        DBCollection collection = _collections.get(name);
-        if (collection == null) {
-            collection = _dataContext.getMongoDb().getCollection(name);
-            _collections.put(name, collection);
-        }
-        return collection;
-    }
-
-    @Override
-    public void close() {
-        _collections.clear();
-    }
-
-    @Override
-    public boolean isDropTableSupported() {
-        return true;
-    }
-
-    @Override
-    public TableDropBuilder dropTable(Table table) throws UnsupportedOperationException {
-        return new MongoDbDropTableBuilder(this, table);
-    }
-
-    @Override
-    public boolean isDeleteSupported() {
-        return true;
-    }
-
-    @Override
-    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
-            UnsupportedOperationException {
-        return new MongoDbDeleteBuilder(this, table);
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/SimpleWriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/SimpleWriteConcernAdvisor.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/SimpleWriteConcernAdvisor.java
deleted file mode 100644
index 2d6f76a..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/SimpleWriteConcernAdvisor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-import com.mongodb.WriteConcern;
-
-/**
- * A simple {@link WriteConcernAdvisor} that always returns the same write
- * concern.
- */
-public class SimpleWriteConcernAdvisor implements WriteConcernAdvisor {
-
-    private final WriteConcern _writeConcern;
-
-    public SimpleWriteConcernAdvisor(WriteConcern writeConcern) {
-        if (writeConcern == null) {
-            throw new IllegalArgumentException("WriteConcern cannot be null");
-        }
-        _writeConcern = writeConcern;
-    }
-
-    @Override
-    public WriteConcern adviceDeleteQuery(DBCollection collection, BasicDBObject query) {
-        return _writeConcern;
-    }
-
-    @Override
-    public WriteConcern adviceInsert(DBCollection collection, BasicDBObject document) {
-        return _writeConcern;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/WriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/WriteConcernAdvisor.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/WriteConcernAdvisor.java
deleted file mode 100644
index 006234b..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/WriteConcernAdvisor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-import com.mongodb.WriteConcern;
-
-/**
- * Interface for component that advices MetaModel on which {@link WriteConcern}
- * to apply to given operations
- */
-public interface WriteConcernAdvisor {
-
-    public WriteConcern adviceDeleteQuery(DBCollection collection, BasicDBObject query);
-
-    public WriteConcern adviceInsert(DBCollection collection, BasicDBObject document);
-
-}


[03/42] metamodel git commit: Closes #19

Posted by ka...@apache.org.
Closes #19


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/8e2df822
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/8e2df822
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/8e2df822

Branch: refs/heads/5.x
Commit: 8e2df8223d31e227570497b11ab5fc422bd0ceea
Parents: de91a7d
Author: Kasper S�rensen <i....@gmail.com>
Authored: Fri Jan 8 13:40:21 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Fri Jan 8 13:40:21 2016 +0100

----------------------------------------------------------------------

----------------------------------------------------------------------



[16/42] metamodel git commit: METAMODEL-239: Fixed

Posted by ka...@apache.org.
METAMODEL-239: Fixed

Fixes #90

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/8ea5ef52
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/8ea5ef52
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/8ea5ef52

Branch: refs/heads/5.x
Commit: 8ea5ef52659abee313957fa7164c1b3f55a31674
Parents: 496a839
Author: Ankit Kumar <ak...@gmail.com>
Authored: Wed Mar 9 18:55:06 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Wed Mar 9 18:55:06 2016 +0100

----------------------------------------------------------------------
 .../org/apache/metamodel/query/parser/QueryParserTest.java    | 7 +++++++
 .../org/apache/metamodel/jdbc/dialects/DB2QueryRewriter.java  | 4 ++--
 .../org/apache/metamodel/dialects/DB2QueryRewriterTest.java   | 6 ++++++
 3 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/8ea5ef52/core/src/test/java/org/apache/metamodel/query/parser/QueryParserTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/query/parser/QueryParserTest.java b/core/src/test/java/org/apache/metamodel/query/parser/QueryParserTest.java
index d081c39..fa9b66d 100644
--- a/core/src/test/java/org/apache/metamodel/query/parser/QueryParserTest.java
+++ b/core/src/test/java/org/apache/metamodel/query/parser/QueryParserTest.java
@@ -50,6 +50,13 @@ public class QueryParserTest extends TestCase {
         MutableColumn col = (MutableColumn) dc.getColumnByQualifiedLabel("tbl.baz");
         col.setType(ColumnType.INTEGER);
     };
+	
+    public void testQueryWithParenthesis() throws Exception {
+        Query q = MetaModelHelper.parseQuery(dc,
+                "select foo from sch.tbl where (foo= 1) and (foo=2)");
+        assertEquals("SELECT tbl.foo FROM sch.tbl WHERE tbl.foo = '1' AND tbl.foo = '2'",
+                q.toSql());
+    }
 
     public void testQueryWithParenthesisAnd() throws Exception {
         Query q = MetaModelHelper.parseQuery(dc, "select foo from sch.tbl where (foo= 1) and (foo=2)");

http://git-wip-us.apache.org/repos/asf/metamodel/blob/8ea5ef52/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DB2QueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DB2QueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DB2QueryRewriter.java
index fa8ebe0..d75bf54 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DB2QueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DB2QueryRewriter.java
@@ -69,11 +69,11 @@ public class DB2QueryRewriter extends DefaultQueryRewriter implements IQueryRewr
         final Integer firstRow = query.getFirstRow();
         final Integer maxRows = query.getMaxRows();
 
-        if (maxRows == null && firstRow == null) {
+        if (maxRows == null && (firstRow == null || firstRow.intValue() == 1)) {
             return super.rewriteQuery(query);
         }
 
-        if (firstRow == null || firstRow.intValue() == 1) {
+        if ((firstRow == null || firstRow.intValue() == 1) && maxRows != null && maxRows > 0) {
             // We prefer to use the "FETCH FIRST [n] ROWS ONLY" approach, if
             // firstRow is not specified.
             return super.rewriteQuery(query) + " FETCH FIRST " + maxRows + " ROWS ONLY";

http://git-wip-us.apache.org/repos/asf/metamodel/blob/8ea5ef52/jdbc/src/test/java/org/apache/metamodel/dialects/DB2QueryRewriterTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/dialects/DB2QueryRewriterTest.java b/jdbc/src/test/java/org/apache/metamodel/dialects/DB2QueryRewriterTest.java
index 06c667e..6d213d5 100644
--- a/jdbc/src/test/java/org/apache/metamodel/dialects/DB2QueryRewriterTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/dialects/DB2QueryRewriterTest.java
@@ -60,6 +60,12 @@ public class DB2QueryRewriterTest extends TestCase {
         assertEquals("SELECT sch.foo.bar FROM sch.foo FETCH FIRST 200 ROWS ONLY", str);
     }
 
+    public void testRewriteFirstRowIsOneAndMaxRowsIsNull() throws Exception {
+        Query q = new Query().from(table).select(col).setFirstRow(1);
+        String str = new DB2QueryRewriter(null).rewriteQuery(q);
+        assertEquals("SELECT sch.foo.bar FROM sch.foo", str);
+    }
+
     public void testRewriteFirstRow() throws Exception {
         Query q = new Query().from(table).select(col).setFirstRow(401);
         String str = new DB2QueryRewriter(null).rewriteQuery(q);


[21/42] metamodel git commit: METAMODEL-235: Fixed

Posted by ka...@apache.org.
METAMODEL-235: Fixed

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/6a669d7f
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/6a669d7f
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/6a669d7f

Branch: refs/heads/5.x
Commit: 6a669d7fb2190c6349f386f38c2bb515b7b80bfe
Parents: 324ea22
Author: kaspersorensen <i....@gmail.com>
Authored: Thu Apr 21 09:44:37 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Thu Apr 21 09:44:37 2016 -0700

----------------------------------------------------------------------
 .gitignore                                      |  4 +-
 .../rest/JestElasticSearchUtils.java            |  5 +-
 .../rest/JestElasticSearchUtilsTest.java        | 64 +++++++++++++++++---
 3 files changed, 63 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/6a669d7f/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e1af7b0..960f35f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
 .project
-.settings/
-.classpath/
+.settings
+.classpath
 .metadata/
 target/
 /.idea/

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6a669d7f/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
index c37ff80..7448aa6 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
@@ -55,12 +55,15 @@ final class JestElasticSearchUtils {
     }
 
     private static Object getDataFromColumnType(JsonElement field, ColumnType type) {
+        if (field == null || field.isJsonNull()) {
+            return null;
+        }
         if (type.isNumber()) {
             // Pretty terrible workaround to avoid LazilyParsedNumber
             // (which is happily output, but not recognized by Jest/GSON).
             return NumberComparator.toNumber(field.getAsString());
         } else if (type.isTimeBased()) {
-            Date valueToDate = ElasticSearchDateConverter.tryToConvert(field.getAsString());
+            final Date valueToDate = ElasticSearchDateConverter.tryToConvert(field.getAsString());
             if (valueToDate == null) {
                 return field.getAsString();
             } else {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6a669d7f/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java b/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
index 0d78d8e..9e2b42f 100644
--- a/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
+++ b/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
@@ -18,22 +18,28 @@
  */
 package org.apache.metamodel.elasticsearch.rest;
 
-import com.google.gson.JsonObject;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
 import org.apache.metamodel.data.DataSetHeader;
 import org.apache.metamodel.data.Row;
 import org.apache.metamodel.data.SimpleDataSetHeader;
 import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.schema.Column;
 import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.schema.MutableColumn;
+import org.junit.Test;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import com.google.gson.JsonObject;
 
-public class JestElasticSearchUtilsTest extends TestCase {
+public class JestElasticSearchUtilsTest {
 
+    @Test
     public void testAssignDocumentIdForPrimaryKeys() throws Exception {
         MutableColumn primaryKeyColumn = new MutableColumn("value1", ColumnType.STRING).setPrimaryKey(true);
         SelectItem primaryKeyItem = new SelectItem(primaryKeyColumn);
@@ -49,6 +55,50 @@ public class JestElasticSearchUtilsTest extends TestCase {
         assertEquals(primaryKeyValue, documentId);
     }
 
+    @Test
+    public void testCreateRowWithNullValues() throws Exception {
+        final Column col1 = new MutableColumn("col1", ColumnType.STRING);
+        final Column col2 = new MutableColumn("col2", ColumnType.STRING);
+        final DataSetHeader header = new SimpleDataSetHeader(new Column[] { col1, col2 });
+        final JsonObject source = new JsonObject();
+        source.addProperty("col1", "foo");
+        source.addProperty("col2", (String) null);
+        final String documentId = "row1";
+
+        final Row row = JestElasticSearchUtils.createRow(source, documentId, header);
+        assertEquals("Row[values=[foo, null]]", row.toString());
+    }
+
+    @Test
+    public void testCreateRowWithNumberValueAndStringType() throws Exception {
+        final Column col1 = new MutableColumn("col1", ColumnType.STRING);
+        final DataSetHeader header = new SimpleDataSetHeader(new Column[] { col1 });
+        final JsonObject source = new JsonObject();
+        source.addProperty("col1", 42);
+        final String documentId = "row1";
+
+        final Row row = JestElasticSearchUtils.createRow(source, documentId, header);
+        assertEquals("Row[values=[42]]", row.toString());
+    }
+
+    @Test
+    public void testCreateRowWithStringValueAndNumberType() throws Exception {
+        final Column col1 = new MutableColumn("col1", ColumnType.NUMBER);
+        final DataSetHeader header = new SimpleDataSetHeader(new Column[] { col1 });
+        final JsonObject source = new JsonObject();
+        source.addProperty("col1", "hello world");
+        final String documentId = "row1";
+
+        final Row row = JestElasticSearchUtils.createRow(source, documentId, header);
+
+        // whether or not 'null' should be returned (bad value, but preserves
+        // type) or 'hello world' should be returned (correct value, breaks
+        // type) can be debated. For now it is added here as an assertion to
+        // keep track of any regressions.
+        assertEquals("Row[values=[null]]", row.toString());
+    }
+
+    @Test
     public void testCreateRowWithParseableDates() throws Exception {
         SelectItem item1 = new SelectItem(new MutableColumn("value1", ColumnType.STRING));
         SelectItem item2 = new SelectItem(new MutableColumn("value2", ColumnType.DATE));


[24/42] metamodel git commit: METAMODEL-244: Made ColumnNamingStrategy available to fixedwidth module

Posted by ka...@apache.org.
METAMODEL-244: Made ColumnNamingStrategy available to fixedwidth module

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/3d0666ca
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/3d0666ca
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/3d0666ca

Branch: refs/heads/5.x
Commit: 3d0666cabce5e6df40ec341bb1d21b74343d1e3f
Parents: 820b1f2
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Apr 22 14:54:22 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Apr 22 14:54:22 2016 -0700

----------------------------------------------------------------------
 .../builder/AlphabeticColumnNamingStrategy.java | 36 +++++++++++
 .../schema/builder/ColumnNamingContext.java     | 52 ++++++++++++++++
 .../schema/builder/ColumnNamingContextImpl.java | 64 ++++++++++++++++++++
 .../schema/builder/ColumnNamingStrategy.java    | 37 +++++++++++
 .../fixedwidth/FixedWidthConfiguration.java     | 16 +++++
 .../fixedwidth/FixedWidthDataContext.java       | 16 ++---
 6 files changed, 214 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/3d0666ca/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
new file mode 100644
index 0000000..284e851
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+import org.apache.metamodel.util.AlphabeticSequence;
+
+public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
+
+    @Override
+    public String getColumnName(ColumnNamingContext ctx) {
+        final int columnIndex = ctx.getColumnIndex();
+        final AlphabeticSequence seq = new AlphabeticSequence("A");
+        // naive way to get to the right value is to iterate - to be optimized
+        for (int i = 0; i < columnIndex; i++) {
+            seq.next();
+        }
+        return seq.current();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/3d0666ca/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java
new file mode 100644
index 0000000..5bcfe56
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContext.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+import org.apache.metamodel.schema.Table;
+
+/**
+ * Defines the context for naming a single column in a
+ * {@link ColumnNamingStrategy} session.
+ */
+public interface ColumnNamingContext {
+
+    /**
+     * Gets the index of the column being named.
+     * 
+     * @return
+     */
+    public int getColumnIndex();
+
+    /**
+     * Gets the {@link Table} that the column is to pertain to. If the table is
+     * not yet available then this may return null.
+     * 
+     * @return
+     */
+    public Table getTable();
+
+    /**
+     * Gets the intrinsic column name, if this is defined in the datastore
+     * itself. This may be in the form of a header or such. Sometimes intrinsic
+     * column names exist only for some columns and sometimes there may be
+     * duplicate names or other anomalies which are often discouraged.
+     * 
+     * @return
+     */
+    public String getIntrinsicColumnName();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/3d0666ca/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java
new file mode 100644
index 0000000..cd04f98
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingContextImpl.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+import org.apache.metamodel.schema.Table;
+
+public class ColumnNamingContextImpl implements ColumnNamingContext {
+
+    private final int columnIndex;
+    private final Table table;
+    private final String intrinsicColumnName;
+
+    /**
+     * 
+     * @param table
+     * @param intrinsicColumnName
+     * @param columnIndex
+     */
+    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
+        this.table = table;
+        this.intrinsicColumnName = intrinsicColumnName;
+        this.columnIndex = columnIndex;
+    }
+
+    /**
+     * 
+     * @param columnIndex
+     */
+    public ColumnNamingContextImpl(int columnIndex) {
+        this(null, null, columnIndex);
+    }
+
+    @Override
+    public int getColumnIndex() {
+        return columnIndex;
+    }
+
+    @Override
+    public Table getTable() {
+        return table;
+    }
+
+    @Override
+    public String getIntrinsicColumnName() {
+        return intrinsicColumnName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/3d0666ca/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
new file mode 100644
index 0000000..626daaf
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+/**
+ * A strategy that defines how columns are logically named. Such strategies are
+ * mostly used when a particular datastore is not itself intrinsically
+ * specifying the column name.
+ */
+public interface ColumnNamingStrategy {
+
+    /**
+     * Provides the name to apply for a given column.
+     * 
+     * @param ctx
+     *            the context of the column naming taking place. This contains
+     *            column index, intrinsic name etc. if available.
+     * @return the name to provide to the column.
+     */
+    public String getColumnName(ColumnNamingContext ctx);
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/3d0666ca/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index 86a038a..3b90b32 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -23,6 +23,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.builder.AlphabeticColumnNamingStrategy;
+import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -42,6 +44,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
 	private final int[] valueWidths;
 	private final int columnNameLineNumber;
 	private final boolean failOnInconsistentLineWidth;
+	private final ColumnNamingStrategy columnNamingStrategy;
 
 	public FixedWidthConfiguration(int fixedValueWidth) {
 		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING,
@@ -64,6 +67,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
 		this.fixedValueWidth = fixedValueWidth;
 		this.columnNameLineNumber = columnNameLineNumber;
 		this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+		this.columnNamingStrategy = null;
 		this.valueWidths = new int[0];
 	}
 
@@ -73,6 +77,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
 		this.fixedValueWidth = -1;
 		this.columnNameLineNumber = columnNameLineNumber;
 		this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+		this.columnNamingStrategy = null;
 		this.valueWidths = valueWidths;
 	}
 
@@ -84,6 +89,17 @@ public final class FixedWidthConfiguration extends BaseObject implements
 	public int getColumnNameLineNumber() {
 		return columnNameLineNumber;
 	}
+	
+	/**
+	 * Gets a {@link ColumnNamingStrategy} to use if needed.
+	 * @return
+	 */
+	public ColumnNamingStrategy getColumnNamingStrategy() {
+	    if (columnNamingStrategy == null) {
+	        return new AlphabeticColumnNamingStrategy();
+	    }
+        return columnNamingStrategy;
+    }
 
 	/**
 	 * Gets the file encoding to use for reading the file.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/3d0666ca/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
index 4876847..fcc31ed 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
@@ -33,7 +33,8 @@ import org.apache.metamodel.schema.MutableTable;
 import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.Table;
 import org.apache.metamodel.schema.TableType;
-import org.apache.metamodel.util.AlphabeticSequence;
+import org.apache.metamodel.schema.builder.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 import org.apache.metamodel.util.FileResource;
 import org.apache.metamodel.util.Resource;
@@ -127,11 +128,12 @@ public class FixedWidthDataContext extends QueryPostprocessDataContext {
                 }
                 columnNames = reader.readLine();
             } else {
+                final ColumnNamingStrategy columnNamingStrategy = _configuration.getColumnNamingStrategy();
                 columnNames = reader.readLine();
                 if (columnNames != null) {
-                    AlphabeticSequence sequence = new AlphabeticSequence();
                     for (int i = 0; i < columnNames.length; i++) {
-                        columnNames[i] = sequence.next();
+                        columnNames[i] = columnNamingStrategy.getColumnName(new ColumnNamingContextImpl(table, null,
+                                i));
                     }
                 }
             }
@@ -179,11 +181,11 @@ public class FixedWidthDataContext extends QueryPostprocessDataContext {
         final Reader fileReader = FileHelper.getReader(inputStream, _configuration.getEncoding());
         final FixedWidthReader reader;
         if (_configuration.isConstantValueWidth()) {
-            reader = new FixedWidthReader(fileReader, _configuration.getFixedValueWidth(),
-                    _configuration.isFailOnInconsistentLineWidth());
+            reader = new FixedWidthReader(fileReader, _configuration.getFixedValueWidth(), _configuration
+                    .isFailOnInconsistentLineWidth());
         } else {
-            reader = new FixedWidthReader(fileReader, _configuration.getValueWidths(),
-                    _configuration.isFailOnInconsistentLineWidth());
+            reader = new FixedWidthReader(fileReader, _configuration.getValueWidths(), _configuration
+                    .isFailOnInconsistentLineWidth());
         }
         return reader;
     }


[06/42] metamodel git commit: METAMODEL-183: Fixed

Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
new file mode 100644
index 0000000..d777e5e
--- /dev/null
+++ b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
@@ -0,0 +1,635 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.mongodb.WriteConcern;
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.UpdateScript;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.InMemoryDataSet;
+import org.apache.metamodel.query.FunctionType;
+import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.SimpleTableDef;
+
+import com.mongodb.BasicDBList;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.Mongo;
+
+public class MongoDbDataContextTest extends MongoDbTestCase {
+
+    private DB db;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (isConfigured()) {
+            Mongo mongo = new Mongo(getHostname());
+            db = mongo.getDB(getDatabaseName());
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (isConfigured()) {
+            db.dropDatabase();
+        }
+    }
+
+    public void testNestedObjectFetching() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
+
+        // delete if already exists
+        {
+            col.drop();
+            col = db.createCollection(getCollectionName(), new BasicDBObject());
+        }
+
+        final BasicDBList list = new BasicDBList();
+        list.add(new BasicDBObject().append("city", "Copenhagen").append("country", "Denmark"));
+        list.add(new BasicDBObject().append("city", "Stockholm").append("country", "Sweden"));
+
+        final BasicDBObject dbRow = new BasicDBObject();
+        dbRow.append("name", new BasicDBObject().append("first", "John").append("last", "Doe"));
+        dbRow.append("gender", "MALE");
+        dbRow.append("addresses", list);
+        col.insert(dbRow);
+
+        final MongoDbDataContext dc = new MongoDbDataContext(db, new SimpleTableDef(getCollectionName(), new String[] {
+                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
+                "addresses[5].foobar" }));
+
+        final DataSet ds = dc.query().from(getCollectionName()).selectAll().execute();
+        try {
+            assertTrue(ds.next());
+            final Object addresses = ds.getRow().getValue(3);
+            assertEquals("Row[values=[John, Doe, MALE, " + addresses + ", Copenhagen, Denmark, null]]", ds.getRow()
+                    .toString());
+            assertTrue(addresses instanceof List);
+            assertFalse(ds.next());
+        } finally {
+            ds.close();
+        }
+    }
+
+    public void testQueriesWithAutoGeneratedID() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
+
+        // delete if already exists
+        {
+            col.drop();
+            col = db.createCollection(getCollectionName(), new BasicDBObject());
+        }
+
+        // create a couple of entries
+
+        BasicDBObject dbRow1 = new BasicDBObject();
+        dbRow1.put("name", "Mr. Black");
+        dbRow1.put("category", "gen_id");
+        dbRow1.put("age", 20);
+        col.insert(dbRow1, WriteConcern.ACKNOWLEDGED);
+        final String autoGenID1 = dbRow1.get("_id").toString();
+
+        BasicDBObject dbRow2 = new BasicDBObject();
+        dbRow2.put("name", "Mr. Pink");
+        dbRow2.put("category", "gen_id");
+        dbRow2.put("age", 40);
+        col.insert(dbRow2, WriteConcern.ACKNOWLEDGED);
+        String autoGenID2 = dbRow2.get("_id").toString();
+
+        BasicDBObject dbRow3 = new BasicDBObject();
+        dbRow3.put("_id", "123");
+        dbRow3.put("name", "Mr. White");
+        dbRow3.put("category", "gen_id");
+        dbRow3.put("age", 30);
+        col.insert(dbRow3, WriteConcern.ACKNOWLEDGED);
+        String fixedID3 = dbRow3.get("_id").toString();
+
+        final MongoDbDataContext dc = new MongoDbDataContext(db);
+        DataSet ds;
+
+        // check all 3 entries inserted
+        ds = dc.query().from(getCollectionName()).selectAll()
+                .where("category").eq("gen_id").execute();
+        assertEquals(3, ds.toRows().size());
+        ds.close();
+
+        // select by autogenerated id
+        ds = dc.query().from(getCollectionName()).select("name").where("_id").eq(autoGenID1).execute();
+        assertTrue(ds.next());
+        assertEquals("Mr. Black", ds.getRow().getValue(0));
+        ds.close();
+
+        // select by multiple autogenerated ids
+        ds = dc.query().from(getCollectionName()).select("name")
+                .where("_id").eq(autoGenID1)
+                .or("_id").eq(autoGenID2)
+                .execute();
+        assertEquals(2, ds.toRows().size());
+        ds.close();
+
+        // select by both autogenerated id and fixed id
+        ds = dc.query().from(getCollectionName()).select("name")
+                .where("_id").eq(autoGenID1)
+                .or("_id").eq(fixedID3)
+                .execute();
+        assertEquals(2, ds.toRows().size());
+        ds.close();
+
+        // delete by id
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                callback.deleteFrom(getCollectionName())
+                        .where("_id").eq(autoGenID1)
+                        .execute();
+            }
+        });
+
+        // select by autogenerated id which was deleted
+        ds = dc.query().from(getCollectionName()).select("name").where("_id").eq(autoGenID1).execute();
+        assertEquals(0, ds.toRows().size());
+        ds.close();
+
+    }
+
+    public void testFirstRowAndMaxRows() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
+
+        // delete if already exists
+        {
+            col.drop();
+            col = db.createCollection(getCollectionName(), new BasicDBObject());
+        }
+
+        // create 3 records
+        for (int i = 0; i < 3; i++) {
+            BasicDBObject dbRow = new BasicDBObject();
+            dbRow.put("id", i + 1);
+            col.insert(dbRow);
+        }
+
+        final MongoDbDataContext dc = new MongoDbDataContext(db);
+
+        DataSet ds;
+
+        ds = dc.query().from(getCollectionName()).select("id").firstRow(2).execute();
+        assertTrue(ds instanceof MongoDbDataSet);
+        assertTrue(ds.next());
+        assertEquals("Row[values=[2]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[3]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+
+        ds = dc.query().from(getCollectionName()).select("id").maxRows(1).execute();
+        assertTrue(ds instanceof MongoDbDataSet);
+        assertTrue(ds.next());
+        assertEquals("Row[values=[1]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+
+        ds = dc.query().from(getCollectionName()).select("id").maxRows(1).firstRow(2).execute();
+        assertTrue(ds instanceof MongoDbDataSet);
+        assertTrue(ds.next());
+        assertEquals("Row[values=[2]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+    }
+
+    public void testRead() throws Exception {
+        // Adding a comment to commit something and invoke a build in Travis...
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
+
+        // delete if already exists
+        {
+            col.drop();
+            col = db.createCollection(getCollectionName(), new BasicDBObject());
+        }
+
+        // create 1000 records
+        for (int i = 0; i < 1000; i++) {
+            BasicDBObject dbRow = new BasicDBObject();
+            dbRow.put("id", i);
+            dbRow.put("name", "record no. " + i);
+            if (i % 5 == 0) {
+                dbRow.put("foo", "bar");
+            } else {
+                dbRow.put("foo", "baz");
+            }
+            BasicDBObject nestedObj = new BasicDBObject();
+            nestedObj.put("count", i);
+            nestedObj.put("constant", "foobarbaz");
+            dbRow.put("baz", nestedObj);
+
+            dbRow.put("list", Arrays.<Object> asList("l1", "l2", "l3", i));
+
+            col.insert(dbRow);
+        }
+
+        // Instantiate the actual data context
+        final DataContext dataContext = new MongoDbDataContext(db);
+
+        assertTrue(Arrays.asList(dataContext.getDefaultSchema().getTableNames()).contains(getCollectionName()));
+        Table table = dataContext.getDefaultSchema().getTableByName(getCollectionName());
+        assertEquals("[_id, baz, foo, id, list, name]", Arrays.toString(table.getColumnNames()));
+
+        assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
+        assertEquals(ColumnType.VARCHAR, table.getColumnByName("foo").getType());
+        assertEquals(ColumnType.LIST, table.getColumnByName("list").getType());
+        assertEquals(ColumnType.INTEGER, table.getColumnByName("id").getType());
+        assertEquals(ColumnType.ROWID, table.getColumnByName("_id").getType());
+
+        DataSet ds = dataContext.query().from(getCollectionName()).select("name").and("foo").and("baz").and("list")
+                .where("id").greaterThan(800).or("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+        try {
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 0, bar, {count=0, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 0]]]",
+                    ds.getRow().toString());
+
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 5, bar, {count=5, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 5]]]",
+                    ds.getRow().toString());
+
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 10, bar, {count=10, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 10]]]",
+                    ds.getRow().toString());
+
+            for (int j = 15; j < 801; j++) {
+                if (j % 5 == 0) {
+                    assertTrue(ds.next());
+                    assertEquals("Row[values=[record no. " + j + ", bar, {count=" + j
+                            + ", constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , " + j + "]]]", ds.getRow()
+                            .toString());
+                }
+            }
+
+            assertTrue(ds.next());
+            assertTrue(ds.getRow().getValue(2) instanceof Map);
+            assertEquals(LinkedHashMap.class, ds.getRow().getValue(2).getClass());
+
+            assertTrue("unexpected type: " + ds.getRow().getValue(3).getClass(),
+                    ds.getRow().getValue(3) instanceof List);
+            assertEquals(BasicDBList.class, ds.getRow().getValue(3).getClass());
+
+            assertEquals(
+                    "Row[values=[record no. 801, baz, {count=801, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 801]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 802, baz, {count=802, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 802]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 803, baz, {count=803, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 803]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 804, baz, {count=804, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 804]]]",
+                    ds.getRow().toString());
+            assertTrue(ds.next());
+            assertEquals(
+                    "Row[values=[record no. 805, bar, {count=805, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 805]]]",
+                    ds.getRow().toString());
+
+            for (int i = 0; i < 194; i++) {
+                assertTrue(ds.next());
+            }
+            assertEquals(
+                    "Row[values=[record no. 999, baz, {count=999, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 999]]]",
+                    ds.getRow().toString());
+            assertFalse(ds.next());
+        } finally {
+            ds.close();
+        }
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").in(2, 6, 8, 9)
+                .execute();
+        assertTrue(ds.next());
+        assertEquals("Row[values=[2, record no. 2]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[6, record no. 6]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[8, record no. 8]]", ds.getRow().toString());
+        assertTrue(ds.next());
+        assertEquals("Row[values=[9, record no. 9]]", ds.getRow().toString());
+        assertFalse(ds.next());
+        ds.close();
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("foo").isEquals("bar")
+                .execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(200, objectArrays.size());
+            assertEquals("[0, record no. 0]", Arrays.toString(objectArrays.get(0)));
+        } finally {
+            ds.close();
+        }
+
+        // test GREATER_THAN_OR_EQUAL
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id")
+                .greaterThanOrEquals(500).and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(100, objectArrays.size());
+            assertEquals("[500, record no. 500]", Arrays.toString(objectArrays.get(0)));
+        } finally {
+            ds.close();
+        }
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id")
+                .greaterThanOrEquals(501).and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(99, objectArrays.size());
+            assertEquals("[505, record no. 505]", Arrays.toString(objectArrays.get(0)));
+        } finally {
+            ds.close();
+        }
+
+        // test LESS_THAN_OR_EQUAL
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").lessThanOrEquals(500)
+                .and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(101, objectArrays.size());
+            assertEquals("[500, record no. 500]", Arrays.toString(objectArrays.get(100)));
+        } finally {
+            ds.close();
+        }
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").lessThanOrEquals(499)
+                .and("foo").isEquals("bar").execute();
+        assertEquals(MongoDbDataSet.class, ds.getClass());
+        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
+
+        try {
+            List<Object[]> objectArrays = ds.toObjectArrays();
+            assertEquals(100, objectArrays.size());
+            assertEquals("[495, record no. 495]", Arrays.toString(objectArrays.get(99)));
+        } finally {
+            ds.close();
+        }
+
+        // test a primary key lookup query
+        BasicDBObject dbRow = new BasicDBObject();
+        dbRow.put("_id", 123456);
+        dbRow.put("id", 123456);
+        dbRow.put("name", "record no. " + 123456);
+        dbRow.put("foo", "bar123456");
+        BasicDBObject nestedObj = new BasicDBObject();
+        nestedObj.put("count", 123456);
+        nestedObj.put("constant", "foobarbaz");
+        dbRow.put("baz", nestedObj);
+
+        dbRow.put("list", Arrays.<Object> asList("l1", "l2", "l3", 123456));
+
+        col.insert(dbRow);
+
+        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("_id").eq(123456).execute();
+        assertTrue(ds.next());
+        assertEquals("Row[values=[123456, record no. 123456]]", ds.getRow().toString());
+        assertFalse(ds.next());
+
+        // do a query that we cannot push to mongo
+        // Replace column index 0 by 1
+        ds = dataContext.query().from(getCollectionName())
+                .select(FunctionType.SUM, dataContext.getDefaultSchema().getTables()[0].getColumnByName("id"))
+                .where("foo").isEquals("bar").execute();
+        assertEquals(InMemoryDataSet.class, ds.getClass());
+
+        ds.close();
+    }
+
+    public void testCreateAndWriteData() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+        final MongoDbDataContext dc = new MongoDbDataContext(db);
+        final Schema defaultSchema = dc.getDefaultSchema();
+
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                Table[] tables = defaultSchema.getTables();
+                for (Table table : tables) {
+                    callback.deleteFrom(table).execute();
+                }
+            }
+        });
+
+        assertEquals(0, defaultSchema.getTableCount());
+
+        dc.executeUpdate(new UpdateScript() {
+
+            @Override
+            public void run(UpdateCallback callback) {
+                Table table = callback.createTable(defaultSchema, "some_entries").withColumn("foo").withColumn("bar")
+                        .withColumn("baz").withColumn("list").execute();
+
+                callback.insertInto(table).value("foo", 1).value("bar", "hello").execute();
+                callback.insertInto(table).value("foo", 2).value("bar", "world").execute();
+                callback.insertInto(table).value("foo", 3).value("bar", "hi").execute();
+
+                Map<String, Object> nestedObj = new HashMap<String, Object>();
+                nestedObj.put("foo", "bar");
+                nestedObj.put("123", 456);
+
+                callback.insertInto(table).value("foo", 4).value("bar", "there").value("baz", nestedObj)
+                        .value("list", Arrays.asList(1, 2, 3)).execute();
+            }
+        });
+
+        DataSet dataSet;
+        assertEquals(1, defaultSchema.getTableCount());
+
+        // "Pure" SELECT COUNT(*) query
+        dataSet = dc.query().from("some_entries").selectCount().execute();
+        dataSet.close();
+        assertTrue(dataSet.next());
+        assertEquals(1, dataSet.getSelectItems().length);
+        assertEquals(SelectItem.getCountAllItem(), dataSet.getSelectItems()[0]);
+        assertEquals(4l, dataSet.getRow().getValue(SelectItem.getCountAllItem()));
+        assertFalse(dataSet.next());
+        assertEquals(InMemoryDataSet.class, dataSet.getClass());
+
+        // A conditional SELECT COUNT(*) query
+        dataSet = dc.query().from("some_entries").selectCount().where("foo").greaterThan(2).execute();
+        dataSet.close();
+        assertTrue(dataSet.next());
+        assertEquals(1, dataSet.getSelectItems().length);
+        assertEquals(SelectItem.getCountAllItem(), dataSet.getSelectItems()[0]);
+        assertEquals(2l, dataSet.getRow().getValue(SelectItem.getCountAllItem()));
+        assertFalse(dataSet.next());
+        assertEquals(InMemoryDataSet.class, dataSet.getClass());
+
+        // Select columns
+        dataSet = dc.query().from("some_entries").select("foo").and("bar").and("baz").and("list").execute();
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[1, hello, null, null]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[2, world, null, null]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[3, hi, null, null]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[4, there, {123=456, foo=bar}, [ 1 , 2 , 3]]]", dataSet.getRow().toString());
+        assertFalse(dataSet.next());
+        dataSet.close();
+        assertEquals(MongoDbDataSet.class, dataSet.getClass());
+
+        // delete some records
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                callback.deleteFrom("some_entries").where("foo").greaterThan(2).where("baz").isNotNull().execute();
+            }
+        });
+
+        dataSet = dc.query().from("some_entries").select("foo").execute();
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[1]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[2]]", dataSet.getRow().toString());
+        assertTrue(dataSet.next());
+        assertEquals("Row[values=[3]]", dataSet.getRow().toString());
+        assertFalse(dataSet.next());
+        dataSet.close();
+        assertEquals(MongoDbDataSet.class, dataSet.getClass());
+
+        // drop the collection
+        dc.executeUpdate(new UpdateScript() {
+            @Override
+            public void run(UpdateCallback callback) {
+                callback.dropTable("some_entries").execute();
+            }
+        });
+
+        assertNull(dc.getTableByQualifiedLabel("some_entries"));
+
+        dc.refreshSchemas();
+        assertEquals(0, defaultSchema.getTableCount());
+    }
+
+    public void testSelectWithLikeOperator() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
+
+        // delete if already exists
+        {
+            col.drop();
+            col = db.createCollection(getCollectionName(), new BasicDBObject());
+        }
+
+        final BasicDBObject dbRow = new BasicDBObject();
+        dbRow.append("name", new BasicDBObject().append("first", "John").append("last", "Doe"));
+        dbRow.append("gender", "MALE");
+        col.insert(dbRow);
+
+        final BasicDBObject dbRow2 = new BasicDBObject();
+        dbRow2.append("name", new BasicDBObject().append("first", "Mary").append("last", "Johnson"));
+        dbRow2.append("gender", "FEMALE");
+        col.insert(dbRow2);
+
+        final BasicDBObject dbRow3 = new BasicDBObject();
+        dbRow3.append("name", new BasicDBObject().append("first", "X").append("last", "Unknown"));
+        dbRow3.append("gender", "UNKNOWN");
+        col.insert(dbRow3);
+
+        final MongoDbDataContext dc = new MongoDbDataContext(db, new SimpleTableDef(getCollectionName(), new String[] {
+                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
+                "addresses[5].foobar" }));
+
+        final DataSet ds1 = dc.executeQuery("select * from my_collection where gender LIKE '%MALE%'");
+        final DataSet ds2 = dc.executeQuery("select * from my_collection where gender LIKE 'MALE%'");
+        final DataSet ds3 = dc.executeQuery("select * from my_collection where gender LIKE '%NK%OW%'");
+        final DataSet ds4 = dc.executeQuery("select * from my_collection where gender LIKE '%MALE'");
+        try {
+            assertTrue(ds1.next());
+            assertTrue(ds1.next());
+            assertFalse(ds1.next());
+            assertTrue(ds2.next());
+            assertFalse(ds2.next());
+            assertTrue(ds3.next());
+            assertFalse(ds3.next());
+            assertTrue(ds4.next());
+            assertTrue(ds4.next());
+            assertFalse(ds4.next());
+        } finally {
+            ds1.close();
+            ds2.close();
+            ds3.close();
+            ds4.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
new file mode 100644
index 0000000..b0aa9dc
--- /dev/null
+++ b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.UpdateScript;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.jdbc.JdbcDataContext;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.FileHelper;
+
+import com.mongodb.DB;
+import com.mongodb.Mongo;
+
+/**
+ * Simple example program that can copy data to a MongoDB collection
+ */
+public class MongoDbDataCopyer {
+
+    private final DataContext _sourceDataContext;
+    private final DB _mongoDb;
+    private final String _collectionName;
+    private final String _sourceSchemaName;
+    private final String _sourceTableName;
+
+    // example copy job that will populate the mongodb with Derby data
+    public static void main(String[] args) throws Exception {
+        System.setProperty("derby.storage.tempDirector", FileHelper.getTempDir().getAbsolutePath());
+        System.setProperty("derby.stream.error.file", File.createTempFile("metamodel-derby", ".log").getAbsolutePath());
+
+        File dbFile = new File("../jdbc/src/test/resources/derby_testdb.jar");
+        dbFile = dbFile.getCanonicalFile();
+        if (!dbFile.exists()) {
+            throw new IllegalStateException("File does not exist: " + dbFile);
+        }
+
+        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+        Connection connection = DriverManager.getConnection("jdbc:derby:jar:(" + dbFile.getAbsolutePath()
+                + ")derby_testdb;territory=en");
+        connection.setReadOnly(true);
+
+        DB db = new Mongo().getDB("orderdb_copy");
+
+        DataContext sourceDataContext = new JdbcDataContext(connection);
+
+        new MongoDbDataCopyer(db, "orders", sourceDataContext, "APP", "orders").copy();
+        new MongoDbDataCopyer(db, "offices", sourceDataContext, "APP", "offices").copy();
+        new MongoDbDataCopyer(db, "payments", sourceDataContext, "APP", "payments").copy();
+        new MongoDbDataCopyer(db, "orderfact", sourceDataContext, "APP", "orderfact").copy();
+        new MongoDbDataCopyer(db, "products", sourceDataContext, "APP", "products").copy();
+
+        connection.close();
+    }
+
+    public MongoDbDataCopyer(DB mongoDb, String collectionName, DataContext sourceDataContext, String sourceSchemaName,
+            String sourceTableName) {
+        _mongoDb = mongoDb;
+        _collectionName = collectionName;
+        _sourceDataContext = sourceDataContext;
+        _sourceSchemaName = sourceSchemaName;
+        _sourceTableName = sourceTableName;
+    }
+
+    public void copy() {
+        final MongoDbDataContext targetDataContext = new MongoDbDataContext(_mongoDb);
+        targetDataContext.executeUpdate(new UpdateScript() {
+
+            @Override
+            public void run(UpdateCallback callback) {
+                final Table sourceTable = getSourceTable();
+                final Table targetTable = callback.createTable(targetDataContext.getDefaultSchema(), _collectionName)
+                        .like(sourceTable).execute();
+                final Column[] sourceColumns = sourceTable.getColumns();
+                final DataSet dataSet = _sourceDataContext.query().from(sourceTable).select(sourceColumns).execute();
+                while (dataSet.next()) {
+                    final Row row = dataSet.getRow();
+
+                    RowInsertionBuilder insertBuilder = callback.insertInto(targetTable);
+                    for (Column column : sourceColumns) {
+                        insertBuilder = insertBuilder.value(column.getName(), row.getValue(column));
+                    }
+                    insertBuilder.execute();
+                }
+                dataSet.close();
+            }
+        });
+    }
+
+    private Table getSourceTable() {
+        final Schema schema;
+        if (_sourceSchemaName != null) {
+            schema = _sourceDataContext.getSchemaByName(_sourceSchemaName);
+        } else {
+            schema = _sourceDataContext.getDefaultSchema();
+        }
+
+        return schema.getTableByName(_sourceTableName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbTestCase.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbTestCase.java b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbTestCase.java
new file mode 100644
index 0000000..932f119
--- /dev/null
+++ b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbTestCase.java
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo2;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+public abstract class MongoDbTestCase extends TestCase {
+
+    private static final String DEFAULT_TEST_COLLECTION_NAME = "my_collection";
+    private static final String DEFAULT_TEST_DATABASE_NAME = "metamodel_test";
+
+    private String _hostname;
+    private String _collectionName;
+    private boolean _configured;
+
+    private String _databaseName;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        File file = new File(getPropertyFilePath());
+        if (file.exists()) {
+            loadPropertyFile(file);
+        } else {
+            // Continuous integration case
+            if (System.getenv("CONTINUOUS_INTEGRATION") != null) {
+                File travisFile = new File("../travis-metamodel-integrationtest-configuration.properties");
+                if (travisFile.exists()) {
+                    loadPropertyFile(travisFile);
+                } else {
+                    _configured = false;
+                }
+            } else {
+                _configured = false;
+            }
+        }
+    }
+
+    private void loadPropertyFile(File file) throws FileNotFoundException, IOException {
+        Properties properties = new Properties();
+        properties.load(new FileReader(file));
+        _hostname = properties.getProperty("mongodb.hostname");
+        
+        _databaseName = properties.getProperty("mongodb.databaseName");
+        if (_databaseName == null || _databaseName.isEmpty()) {
+            _databaseName = DEFAULT_TEST_DATABASE_NAME;
+        }
+        
+        _collectionName = properties.getProperty("mongodb.collectionName");
+        if (_collectionName == null || _collectionName.isEmpty()) {
+            _collectionName = DEFAULT_TEST_COLLECTION_NAME;
+        }
+
+        _configured = (_hostname != null && !_hostname.isEmpty());
+
+        if (_configured) {
+            System.out.println("Loaded MongoDB configuration. Hostname=" + _hostname + ", Collection="
+                    + _collectionName);
+        }
+        
+    }
+
+    private String getPropertyFilePath() {
+        String userHome = System.getProperty("user.home");
+        return userHome + "/metamodel-integrationtest-configuration.properties";
+    }
+
+    protected String getInvalidConfigurationMessage() {
+        return "!!! WARN !!! MongoDB module ignored\r\n" + "Please configure mongodb connection locally ("
+                + getPropertyFilePath() + "), to run integration tests";
+    }
+    
+    public String getDatabaseName() {
+        return _databaseName;
+    }
+
+    public String getCollectionName() {
+        return _collectionName;
+    }
+
+    public String getHostname() {
+        return _hostname;
+    }
+    
+    public boolean isConfigured() {
+        return _configured;
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
new file mode 100644
index 0000000..7bc97e4
--- /dev/null
+++ b/mongodb/mongo3/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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
+
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<artifactId>MetaModel-mongodb</artifactId>
+		<groupId>org.apache.metamodel</groupId>
+		<version>4.5.1-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>MetaModel-mongodb-mongo3</artifactId>
+	<name>MetaModel module for MongoDB databases</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-core</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+            <groupId>org.apache.metamodel</groupId>
+            <artifactId>MetaModel-mongodb-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>3.1.0</version>
+		</dependency>
+
+		<!-- Test dependencies -->
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-jdbc</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.derby</groupId>
+			<artifactId>derby</artifactId>
+			<version>10.8.1.2</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-nop</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/DefaultWriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/DefaultWriteConcernAdvisor.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/DefaultWriteConcernAdvisor.java
new file mode 100644
index 0000000..5414122
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/DefaultWriteConcernAdvisor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import com.mongodb.WriteConcern;
+
+/**
+ * Default {@link WriteConcernAdvisor}. Always returns
+ * {@link WriteConcern#NORMAL}.
+ */
+public class DefaultWriteConcernAdvisor extends SimpleWriteConcernAdvisor {
+
+    public DefaultWriteConcernAdvisor() {
+        super(WriteConcern.NORMAL);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
new file mode 100644
index 0000000..e13285b
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
@@ -0,0 +1,556 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.QueryPostprocessDataContext;
+import org.apache.metamodel.UpdateScript;
+import org.apache.metamodel.UpdateableDataContext;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.DataSetHeader;
+import org.apache.metamodel.data.InMemoryDataSet;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.data.SimpleDataSetHeader;
+import org.apache.metamodel.mongodb.common.MongoDBUtils;
+import org.apache.metamodel.mongodb.common.MongoDbTableDef;
+import org.apache.metamodel.query.FilterItem;
+import org.apache.metamodel.query.FromItem;
+import org.apache.metamodel.query.OperatorType;
+import org.apache.metamodel.query.Query;
+import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.ColumnTypeImpl;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.SimpleTableDef;
+import org.bson.Document;
+import org.bson.types.ObjectId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.WriteConcern;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.MongoIterable;
+
+/**
+ * DataContext implementation for MongoDB.
+ *
+ * Since MongoDB has no schema, a virtual schema will be used in this
+ * DataContext. This implementation supports either automatic discovery of a
+ * schema or manual specification of a schema, through the
+ * {@link MongoDbTableDef} class.
+ */
+public class MongoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
+
+    private final MongoDatabase _mongoDb;
+    private final SimpleTableDef[] _tableDefs;
+    private WriteConcernAdvisor _writeConcernAdvisor;
+    private Schema _schema;
+
+    /**
+     * Constructor available for backwards compatibility
+     *
+     * @deprecated use {@link #MongoDbDataContext(DB, SimpleTableDef...)}
+     *             instead
+     */
+    @Deprecated
+    public MongoDbDataContext(MongoDatabase mongoDb, MongoDbTableDef... tableDefs) {
+        this(mongoDb, (SimpleTableDef[]) tableDefs);
+    }
+
+    /**
+     * Constructs a {@link MongoDbDataContext}. This constructor accepts a
+     * custom array of {@link MongoDbTableDef}s which allows the user to define
+     * his own view on the collections in the database.
+     *
+     * @param mongoDb
+     *            the mongo db connection
+     * @param tableDefs
+     *            an array of {@link MongoDbTableDef}s, which define the table
+     *            and column model of the mongo db collections. (consider using
+     *            {@link #detectSchema(DB)} or {@link #detectTable(DB, String)}
+     *            ).
+     */
+    public MongoDbDataContext(MongoDatabase mongoDb, SimpleTableDef... tableDefs) {
+        _mongoDb = mongoDb;
+        _tableDefs = tableDefs;
+        _schema = null;
+    }
+
+    /**
+     * Constructs a {@link MongoDbDataContext} and automatically detects the
+     * schema structure/view on all collections (see {@link #detectSchema(DB)}).
+     *
+     * @param mongoDb
+     *            the mongo db connection
+     */
+    public MongoDbDataContext(MongoDatabase mongoDb) {
+        this(mongoDb, detectSchema(mongoDb));
+    }
+
+    /**
+     * Performs an analysis of the available collections in a Mongo {@link DB}
+     * instance and tries to detect the table's structure based on the first
+     * 1000 documents in each collection.
+     *
+     * @param mongoDb
+     *            the mongo db to inspect
+     * @return a mutable schema instance, useful for further fine tuning by the
+     *         user.
+     * @see #detectTable(DB, String)
+     */
+    public static SimpleTableDef[] detectSchema(MongoDatabase mongoDb) {
+        MongoIterable<String> collectionNames = mongoDb.listCollectionNames();
+        List<SimpleTableDef> result = new ArrayList<>();
+
+        for (String collectionName : collectionNames) {
+            SimpleTableDef table = detectTable(mongoDb, collectionName);
+            result.add(table);
+        }
+        return result.toArray(new SimpleTableDef[0]);
+    }
+
+    /**
+     * Performs an analysis of an available collection in a Mongo {@link DB}
+     * instance and tries to detect the table structure based on the first 1000
+     * documents in the collection.
+     *
+     * @param mongoDb
+     *            the mongo DB
+     * @param collectionName
+     *            the name of the collection
+     * @return a table definition for mongo db.
+     */
+    public static SimpleTableDef detectTable(MongoDatabase mongoDb, String collectionName) {
+        
+        final MongoCollection<Document> collection = mongoDb.getCollection(collectionName);
+        final FindIterable<Document> iterable = collection.find().limit(1000);
+
+        final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
+        for (Document document : iterable) {
+            Set<String> keysInObject = document.keySet();
+            for (String key : keysInObject) {
+                Set<Class<?>> types = columnsAndTypes.get(key);
+                if (types == null) {
+                    types = new HashSet<Class<?>>();
+                    columnsAndTypes.put(key, types);
+                }
+                Object value = document.get(key);
+                if (value != null) {
+                    types.add(value.getClass());
+                }
+            }
+        }
+           
+        final String[] columnNames = new String[columnsAndTypes.size()];
+        final ColumnType[] columnTypes = new ColumnType[columnsAndTypes.size()];
+
+        int i = 0;
+        for (Entry<String, Set<Class<?>>> columnAndTypes : columnsAndTypes.entrySet()) {
+            final String columnName = columnAndTypes.getKey();
+            final Set<Class<?>> columnTypeSet = columnAndTypes.getValue();
+            final Class<?> columnType;
+            if (columnTypeSet.size() == 1) {
+                columnType = columnTypeSet.iterator().next();
+            } else {
+                columnType = Object.class;
+            }
+            columnNames[i] = columnName;
+            if (columnType == ObjectId.class) {
+                columnTypes[i] = ColumnType.ROWID;
+            } else {
+                columnTypes[i] = ColumnTypeImpl.convertColumnType(columnType);
+            }
+            i++;
+        }
+
+        return new SimpleTableDef(collectionName, columnNames, columnTypes);
+    }
+
+    @Override
+    protected Schema getMainSchema() throws MetaModelException {
+        if (_schema == null) {
+            MutableSchema schema = new MutableSchema(getMainSchemaName());
+            for (SimpleTableDef tableDef : _tableDefs) {
+
+                MutableTable table = tableDef.toTable().setSchema(schema);
+                Column[] rowIdColumns = table.getColumnsOfType(ColumnType.ROWID);
+                for (Column column : rowIdColumns) {
+                    if (column instanceof MutableColumn) {
+                        ((MutableColumn) column).setPrimaryKey(true);
+                    }
+                }
+
+                schema.addTable(table);
+            }
+
+            _schema = schema;
+        }
+        return _schema;
+    }
+
+    @Override
+    protected String getMainSchemaName() throws MetaModelException {
+        return _mongoDb.getName();
+    }
+
+    @Override
+    protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
+        final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
+
+        final Document query = createMongoDbQuery(table, whereItems);
+
+        logger.info("Executing MongoDB 'count' query: {}", query);
+        final long count = collection.count(query);
+
+        return count;
+    }
+
+    @Override
+    protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
+            Object keyValue) {
+        final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
+
+        List<FilterItem> whereItems = new ArrayList<FilterItem>();
+        SelectItem selectItem = new SelectItem(primaryKeyColumn);
+        FilterItem primaryKeyWhereItem = new FilterItem(selectItem, OperatorType.EQUALS_TO, keyValue);
+        whereItems.add(primaryKeyWhereItem);
+        final Document query = createMongoDbQuery(table, whereItems);
+        final Document resultDoc = collection.find(query).first();
+
+        DataSetHeader header = new SimpleDataSetHeader(selectItems);
+
+        Row row = MongoDBUtils.toRow(resultDoc, header);
+
+        return row;
+    }
+
+    @Override
+    public DataSet executeQuery(Query query) {
+        // Check for queries containing only simple selects and where clauses,
+        // or if it is a COUNT(*) query.
+
+        // if from clause only contains a main schema table
+        List<FromItem> fromItems = query.getFromClause().getItems();
+        if (fromItems.size() == 1 && fromItems.get(0).getTable() != null
+                && fromItems.get(0).getTable().getSchema() == _schema) {
+            final Table table = fromItems.get(0).getTable();
+
+            // if GROUP BY, HAVING and ORDER BY clauses are not specified
+            if (query.getGroupByClause().isEmpty() && query.getHavingClause().isEmpty()
+                    && query.getOrderByClause().isEmpty()) {
+
+                final List<FilterItem> whereItems = query.getWhereClause().getItems();
+
+                // if all of the select items are "pure" column selection
+                boolean allSelectItemsAreColumns = true;
+                List<SelectItem> selectItems = query.getSelectClause().getItems();
+
+                // if it is a
+                // "SELECT [columns] FROM [table] WHERE [conditions]"
+                // query.
+                for (SelectItem selectItem : selectItems) {
+                    if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
+                        allSelectItemsAreColumns = false;
+                        break;
+                    }
+                }
+
+                if (allSelectItemsAreColumns) {
+                    logger.debug("Query can be expressed in full MongoDB, no post processing needed.");
+
+                    // prepare for a non-post-processed query
+                    Column[] columns = new Column[selectItems.size()];
+                    for (int i = 0; i < columns.length; i++) {
+                        columns[i] = selectItems.get(i).getColumn();
+                    }
+
+                    // checking if the query is a primary key lookup query
+                    if (whereItems.size() == 1) {
+                        final FilterItem whereItem = whereItems.get(0);
+                        final SelectItem selectItem = whereItem.getSelectItem();
+                        if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
+                            final Column column = selectItem.getColumn();
+                            if (column.isPrimaryKey() && OperatorType.EQUALS_TO.equals(whereItem.getOperator())) {
+                                logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
+                                final Object operand = whereItem.getOperand();
+                                final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
+                                if (row == null) {
+                                    logger.debug("DataContext did not return any primary key lookup query results. Proceeding "
+                                            + "with manual lookup.");
+                                } else {
+                                    final DataSetHeader header = new SimpleDataSetHeader(selectItems);
+                                    return new InMemoryDataSet(header, row);
+                                }
+                            }
+                        }
+                    }
+
+                    int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
+                    int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
+
+                    final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                            maxRows, false);
+                    return dataSet;
+                }
+            }
+        }
+
+        logger.debug("Query will be simplified for MongoDB and post processed.");
+        return super.executeQuery(query);
+    }
+
+    private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
+            int firstRow, int maxRows, boolean queryPostProcessed) {
+        final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
+
+        final Document query = createMongoDbQuery(table, whereItems);
+
+        logger.info("Executing MongoDB 'find' query: {}", query);
+        FindIterable<Document> iterable = collection.find(query);
+
+        if (maxRows > 0) {
+            iterable = iterable.limit(maxRows);
+        }
+        if (firstRow > 1) {
+            final int skip = firstRow - 1;
+            iterable = iterable.skip(skip);
+        }
+
+        MongoCursor<Document> cursor = iterable.iterator();
+
+        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+    }
+
+    protected Document createMongoDbQuery(Table table, List<FilterItem> whereItems) {
+        assert _schema == table.getSchema();
+
+        final Document query = new Document();
+        if (whereItems != null && !whereItems.isEmpty()) {
+            for (FilterItem item : whereItems) {
+                convertToCursorObject(query, item);
+            }
+        }
+
+        return query;
+    }
+
+    private static Object convertArrayToList(Object arr) {
+        if (arr instanceof boolean[]) {
+            return Arrays.asList((boolean[])arr);
+        } else if (arr instanceof byte[]) {
+            return Arrays.asList((byte[])arr);
+        } else if (arr instanceof short[]) {
+            return Arrays.asList((short[])arr);
+        } else if (arr instanceof char[]) {
+            return Arrays.asList((char[])arr);
+        } else if (arr instanceof int[]) {
+            return Arrays.asList((int[])arr);
+        } else if (arr instanceof long[]) {
+            return Arrays.asList((long[])arr);
+        } else if (arr instanceof float[]) {
+            return Arrays.asList((float[])arr);
+        } else if (arr instanceof double[]) {
+            return Arrays.asList((double[])arr);
+        } else if (arr instanceof Object[]) {
+            return Arrays.asList((Object[])arr);
+        }
+        // It's not an array.
+        return null;
+    }
+    
+    private void convertToCursorObject(Document query, FilterItem item) {
+        if (item.isCompoundFilter()) {
+
+            List<Document> orList = new ArrayList<Document>();
+
+            final FilterItem[] childItems = item.getChildItems();
+            for (FilterItem childItem : childItems) {
+                Document childDoc = new Document();
+                convertToCursorObject(childDoc, childItem);
+                orList.add(childDoc);
+            }
+
+            query.put("$or", orList);
+
+        } else {
+
+            final Column column = item.getSelectItem().getColumn();
+            final String columnName = column.getName();
+            final String operatorName = getOperatorName(item);
+
+            Object operand = item.getOperand();
+            if (ObjectId.isValid(String.valueOf(operand))) {
+                operand = new ObjectId(String.valueOf(operand));
+            } else if (operand != null && operand.getClass().isArray()){
+                operand = convertArrayToList(operand);
+            }
+
+            final Document existingFilterObject = (Document) query.get(columnName);
+            if (existingFilterObject == null) {
+                if (operatorName == null) {
+                    if (OperatorType.LIKE.equals(item.getOperator())) {
+                        query.put(columnName, turnOperandIntoRegExp(operand));
+                    } else {
+                        query.put(columnName, operand);
+                    }
+                } else {
+                    query.put(columnName, new Document(operatorName, operand));
+                }
+            } else {
+                if (operatorName == null) {
+                    throw new IllegalStateException("Cannot retrieve records for a column with two EQUALS_TO operators");
+                } else {
+                    existingFilterObject.append(operatorName, operand);
+                }
+            }
+        }
+    }
+
+    private String getOperatorName(FilterItem item) {
+        final OperatorType operator = item.getOperator();
+
+        if (OperatorType.EQUALS_TO.equals(operator)) {
+            return null;
+        }
+        if (OperatorType.LIKE.equals(operator)) {
+            return null;
+        }
+        if (OperatorType.LESS_THAN.equals(operator)) {
+            return "$lt";
+        }
+        if (OperatorType.LESS_THAN_OR_EQUAL.equals(operator)) {
+            return "$lte";
+        }
+        if (OperatorType.GREATER_THAN.equals(operator)) {
+            return "$gt";
+        }
+        if (OperatorType.GREATER_THAN_OR_EQUAL.equals(operator)) {
+            return "$gte";
+        }
+        if (OperatorType.DIFFERENT_FROM.equals(operator)) {
+            return "$ne";
+        }
+        if (OperatorType.IN.equals(operator)) {
+            return "$in";
+        }
+
+        throw new IllegalStateException("Unsupported operator type: " + operator);
+    }
+
+    private Pattern turnOperandIntoRegExp(Object operand) {
+        StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operand.toString()));
+        operandAsRegExp.insert(0, "^").append("$");
+        return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE);
+    }
+
+    private String replaceWildCardLikeChars(String operand) {
+        return operand.replaceAll("%", ".*");
+    }
+
+    @Override
+    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
+        return materializeMainSchemaTableInternal(table, columns, null, 1, maxRows, true);
+    }
+
+    @Override
+    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows) {
+        return materializeMainSchemaTableInternal(table, columns, null, firstRow, maxRows, true);
+    }
+
+    /**
+     * Executes an update with a specific {@link WriteConcernAdvisor}.
+     */
+    public void executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
+        MongoDbUpdateCallback callback = new MongoDbUpdateCallback(this, writeConcernAdvisor);
+        try {
+            update.run(callback);
+        } finally {
+            callback.close();
+        }
+    }
+
+    /**
+     * Executes an update with a specific {@link WriteConcern}.
+     */
+    public void executeUpdate(UpdateScript update, WriteConcern writeConcern) {
+        executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
+    }
+
+    @Override
+    public void executeUpdate(UpdateScript update) {
+        executeUpdate(update, getWriteConcernAdvisor());
+    }
+
+    /**
+     * Gets the {@link WriteConcernAdvisor} to use on
+     * {@link #executeUpdate(UpdateScript)} calls.
+     */
+    public WriteConcernAdvisor getWriteConcernAdvisor() {
+        if (_writeConcernAdvisor == null) {
+            return new DefaultWriteConcernAdvisor();
+        }
+        return _writeConcernAdvisor;
+    }
+
+    /**
+     * Sets a global {@link WriteConcern} advisor to use on
+     * {@link #executeUpdate(UpdateScript)}.
+     */
+    public void setWriteConcernAdvisor(WriteConcernAdvisor writeConcernAdvisor) {
+        _writeConcernAdvisor = writeConcernAdvisor;
+    }
+
+    /**
+     * Gets the {@link DB} instance that this {@link DataContext} is backed by.
+     * @return 
+     */
+    public MongoDatabase getMongoDb() {
+        return _mongoDb;
+    }
+
+    protected void addTable(MutableTable table) {
+        if (_schema instanceof MutableSchema) {
+            MutableSchema mutableSchema = (MutableSchema) _schema;
+            mutableSchema.addTable(table);
+        } else {
+            throw new UnsupportedOperationException("Schema is not mutable");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
new file mode 100644
index 0000000..7a480d1
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.apache.metamodel.data.AbstractDataSet;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.mongodb.common.MongoDBUtils;
+import org.apache.metamodel.schema.Column;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.client.MongoCursor;
+
+final class MongoDbDataSet extends AbstractDataSet {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
+
+    private final MongoCursor<Document> _cursor;
+    private final boolean _queryPostProcessed;
+
+    private boolean _closed;
+    private volatile Document _document;
+
+    public MongoDbDataSet(MongoCursor<Document> cursor, Column[] columns, boolean queryPostProcessed) {
+        super(columns);
+        _cursor = cursor;
+        _queryPostProcessed = queryPostProcessed;
+        _closed = false;
+    }
+
+    public boolean isQueryPostProcessed() {
+        return _queryPostProcessed;
+    }
+
+    @Override
+    public void close() {
+        super.close();
+        _cursor.close();
+        _closed = true;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+        if (!_closed) {
+            logger.warn("finalize() invoked, but DataSet is not closed. Invoking close() on {}", this);
+            close();
+        }
+    }
+
+    @Override
+    public boolean next() {
+        if (_cursor.hasNext()) {
+            _document = _cursor.next();
+            return true;
+        } else {
+            _document = null;
+            return false;
+        }
+    }
+
+    @Override
+    public Row getRow() {
+        return MongoDBUtils.toRow(_document, getHeader());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDeleteBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDeleteBuilder.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDeleteBuilder.java
new file mode 100644
index 0000000..714b8c2
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDeleteBuilder.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.delete.AbstractRowDeletionBuilder;
+import org.apache.metamodel.schema.Table;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.result.DeleteResult;
+
+final class MongoDbDeleteBuilder extends AbstractRowDeletionBuilder {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbDeleteBuilder.class);
+
+    private final MongoDbUpdateCallback _updateCallback;
+
+    public MongoDbDeleteBuilder(MongoDbUpdateCallback updateCallback, Table table) {
+        super(table);
+        _updateCallback = updateCallback;
+    }
+
+    @Override
+    public void execute() throws MetaModelException {
+        final MongoCollection<Document> collection = _updateCallback.getCollection(getTable().getName());
+
+        final MongoDbDataContext dataContext = _updateCallback.getDataContext();
+        final Document query = dataContext.createMongoDbQuery(getTable(), getWhereItems());
+        
+        DeleteResult result = collection.deleteMany(query);
+        logger.info("Remove returned result: {}", result);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDropTableBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDropTableBuilder.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDropTableBuilder.java
new file mode 100644
index 0000000..75a34d0
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDropTableBuilder.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.drop.AbstractTableDropBuilder;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.Table;
+
+final class MongoDbDropTableBuilder extends AbstractTableDropBuilder {
+
+    private final MongoDbUpdateCallback _updateCallback;
+
+    public MongoDbDropTableBuilder(MongoDbUpdateCallback updateCallback, Table table) {
+        super(table);
+        _updateCallback = updateCallback;
+    }
+
+    @Override
+    public void execute() throws MetaModelException {
+        Table table = getTable();
+        _updateCallback.removeCollection(table.getName());
+        MutableSchema schema = (MutableSchema) table.getSchema();
+        schema.removeTable(table);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbInsertionBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbInsertionBuilder.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbInsertionBuilder.java
new file mode 100644
index 0000000..f8b0070
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbInsertionBuilder.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.insert.AbstractRowInsertionBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Table;
+import org.bson.Document;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+
+import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoCollection;
+
+final class MongoDbInsertionBuilder extends AbstractRowInsertionBuilder<MongoDbUpdateCallback> implements RowInsertionBuilder {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoDbInsertionBuilder.class);
+
+    public MongoDbInsertionBuilder(MongoDbUpdateCallback updateCallback, Table table) {
+        super(updateCallback, table);
+    }
+
+    @Override
+    public void execute() throws MetaModelException {
+        final Column[] columns = getColumns();
+        final Object[] values = getValues();
+
+        final Document doc = new Document();
+
+        for (int i = 0; i < values.length; i++) {
+            Object value = values[i];
+            if (value != null) {
+                doc.put(columns[i].getName(), value);
+            }
+        }
+
+        final MongoDbUpdateCallback updateCallback = getUpdateCallback();
+        final MongoCollection<Document> collection = updateCallback.getCollection(getTable().getName());
+        final WriteConcern writeConcern = updateCallback.getWriteConcernAdvisor().adviceInsert(collection, doc);
+        collection.withWriteConcern(writeConcern);
+
+        collection.insertOne(doc);
+        logger.info("Document has been inserted");
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbTableCreationBuilder.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbTableCreationBuilder.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbTableCreationBuilder.java
new file mode 100644
index 0000000..aaec48e
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbTableCreationBuilder.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.create.AbstractTableCreationBuilder;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.ImmutableColumn;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+
+final class MongoDbTableCreationBuilder extends
+		AbstractTableCreationBuilder<MongoDbUpdateCallback> implements
+		TableCreationBuilder {
+
+	public MongoDbTableCreationBuilder(MongoDbUpdateCallback updateCallback,
+			Schema schema, String name) {
+		super(updateCallback, schema, name);
+	}
+
+	@Override
+	public Table execute() throws MetaModelException {
+		final MongoDbDataContext dataContext = getUpdateCallback()
+				.getDataContext();
+		final Schema schema = dataContext.getDefaultSchema();
+		final MutableTable table = getTable();
+		if (table.getColumnByName("_id") == null) {
+			// all mongo db collections have an _id field as the first field.
+			ImmutableColumn idColumn = new ImmutableColumn("_id",
+					ColumnType.ROWID, table, table.getColumnCount(), null,
+					null, null, null, true, null, true);
+			table.addColumn(idColumn);
+		}
+		table.setSchema(schema);
+		getUpdateCallback().createCollection(table.getName());
+		dataContext.addTable(table);
+		return table;
+	}
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbUpdateCallback.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbUpdateCallback.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbUpdateCallback.java
new file mode 100644
index 0000000..48db851
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbUpdateCallback.java
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import java.io.Closeable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.metamodel.AbstractUpdateCallback;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.delete.RowDeletionBuilder;
+import org.apache.metamodel.drop.TableDropBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.bson.Document;
+
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+
+
+final class MongoDbUpdateCallback extends AbstractUpdateCallback implements UpdateCallback, Closeable {
+
+    private final MongoDbDataContext _dataContext;
+    private final Map<String, MongoCollection<Document>> _collections;
+    private final WriteConcernAdvisor _writeConcernAdvisor;
+
+    public MongoDbUpdateCallback(MongoDbDataContext dataContext, WriteConcernAdvisor writeConcernAdvisor) {
+        super(dataContext);
+        _dataContext = dataContext;
+        _writeConcernAdvisor = writeConcernAdvisor;
+        _collections = new HashMap<String, MongoCollection<Document>>();
+    }
+
+    @Override
+    public MongoDbDataContext getDataContext() {
+        return _dataContext;
+    }
+    
+    public WriteConcernAdvisor getWriteConcernAdvisor() {
+        return _writeConcernAdvisor;
+    }
+
+    @Override
+    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
+            IllegalStateException {
+        return new MongoDbTableCreationBuilder(this, schema, name);
+    }
+
+    @Override
+    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException {
+        return new MongoDbInsertionBuilder(this, table);
+    }
+
+    protected void createCollection(String name) {
+        MongoDatabase mongoDb = _dataContext.getMongoDb();
+        mongoDb.createCollection(name);
+        MongoCollection<Document> collection = mongoDb.getCollection(name);
+        _collections.put(name, collection);
+    }
+
+    protected void removeCollection(String name) {
+        MongoCollection<Document> collection = getCollection(name);
+        _collections.remove(name);
+        collection.drop();
+    }
+
+    protected MongoCollection<Document> getCollection(String name) {
+        MongoCollection<Document> collection = _collections.get(name);
+        if (collection == null) {
+            collection = _dataContext.getMongoDb().getCollection(name);
+            _collections.put(name, collection);
+        }
+        return collection;
+    }
+
+    @Override
+    public void close() {
+        _collections.clear();
+    }
+
+    @Override
+    public boolean isDropTableSupported() {
+        return true;
+    }
+
+    @Override
+    public TableDropBuilder dropTable(Table table) throws UnsupportedOperationException {
+        return new MongoDbDropTableBuilder(this, table);
+    }
+
+    @Override
+    public boolean isDeleteSupported() {
+        return true;
+    }
+
+    @Override
+    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new MongoDbDeleteBuilder(this, table);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/SimpleWriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/SimpleWriteConcernAdvisor.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/SimpleWriteConcernAdvisor.java
new file mode 100644
index 0000000..f66e48d
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/SimpleWriteConcernAdvisor.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.bson.Document;
+
+import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoCollection;
+
+/**
+ * A simple {@link WriteConcernAdvisor} that always returns the same write
+ * concern.
+ */
+public class SimpleWriteConcernAdvisor implements WriteConcernAdvisor {
+
+    private final WriteConcern _writeConcern;
+
+    public SimpleWriteConcernAdvisor(WriteConcern writeConcern) {
+        if (writeConcern == null) {
+            throw new IllegalArgumentException("WriteConcern cannot be null");
+        }
+        _writeConcern = writeConcern;
+    }
+
+    @Override
+    public WriteConcern adviceDeleteQuery(MongoCollection<Document> collection, Document query) {
+        return _writeConcern;
+    }
+
+    @Override
+    public WriteConcern adviceInsert(MongoCollection<Document> collection, Document document) {
+        return _writeConcern;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/WriteConcernAdvisor.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/WriteConcernAdvisor.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/WriteConcernAdvisor.java
new file mode 100644
index 0000000..9492abe
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/WriteConcernAdvisor.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.mongodb.mongo3;
+
+import org.bson.Document;
+
+import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoCollection;
+
+/**
+ * Interface for component that advices MetaModel on which {@link WriteConcern}
+ * to apply to given operations
+ */
+public interface WriteConcernAdvisor {
+
+    public WriteConcern adviceDeleteQuery(MongoCollection<Document>  collection, Document query);
+
+    public WriteConcern adviceInsert(MongoCollection<Document>  collection, Document document);
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/package-info.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/package-info.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/package-info.java
new file mode 100644
index 0000000..866b7bc
--- /dev/null
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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.
+ */
+/**
+ * Module package for MongoDB support
+ */
+package org.apache.metamodel.mongodb.mongo3;
+


[25/42] metamodel git commit: METAMODEL-244: Refactored fixedwidth module a bit and added strategies

Posted by ka...@apache.org.
METAMODEL-244: Refactored fixedwidth module a bit and added strategies

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/0da8f1a1
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/0da8f1a1
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/0da8f1a1

Branch: refs/heads/5.x
Commit: 0da8f1a1cb9fa8bfe87eb73f38df047d111e196d
Parents: 3d0666c
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Apr 22 15:50:06 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Apr 22 15:50:06 2016 -0700

----------------------------------------------------------------------
 .../builder/AlphabeticColumnNamingStrategy.java | 12 ++---
 .../schema/builder/ColumnNamingStrategy.java    |  2 +-
 .../builder/DefaultColumnNamingStrategy.java    | 31 ++++++++++++
 ...tingIntrinsicSwitchColumnNamingStrategy.java | 46 ++++++++++++++++++
 .../builder/UniqueColumnNamingStrategy.java     | 50 ++++++++++++++++++++
 .../fixedwidth/FixedWidthConfiguration.java     |  4 +-
 .../fixedwidth/FixedWidthDataContext.java       | 17 ++++---
 7 files changed, 144 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
index 284e851..83679a3 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/AlphabeticColumnNamingStrategy.java
@@ -21,16 +21,12 @@ package org.apache.metamodel.schema.builder;
 import org.apache.metamodel.util.AlphabeticSequence;
 
 public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
+    
+    private final AlphabeticSequence seq = new AlphabeticSequence();
 
     @Override
-    public String getColumnName(ColumnNamingContext ctx) {
-        final int columnIndex = ctx.getColumnIndex();
-        final AlphabeticSequence seq = new AlphabeticSequence("A");
-        // naive way to get to the right value is to iterate - to be optimized
-        for (int i = 0; i < columnIndex; i++) {
-            seq.next();
-        }
-        return seq.current();
+    public String getNextColumnName(ColumnNamingContext ctx) {
+        return seq.next();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
index 626daaf..4923c58 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/ColumnNamingStrategy.java
@@ -33,5 +33,5 @@ public interface ColumnNamingStrategy {
      *            column index, intrinsic name etc. if available.
      * @return the name to provide to the column.
      */
-    public String getColumnName(ColumnNamingContext ctx);
+    public String getNextColumnName(ColumnNamingContext ctx);
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
new file mode 100644
index 0000000..9aef863
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+/**
+ * The default (in most cases) {@link ColumnNamingStrategy} to use when no other
+ * strategy is specified.
+ */
+public class DefaultColumnNamingStrategy extends DelegatingIntrinsicSwitchColumnNamingStrategy {
+
+    public DefaultColumnNamingStrategy() {
+        super(new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
new file mode 100644
index 0000000..99cdaf5
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+/**
+ * A {@link ColumnNamingStrategy} that switches between two other
+ * {@link ColumnNamingStrategy} delegates depending on the availability of a
+ * intrinsic column name.
+ */
+public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private final ColumnNamingStrategy intrinsicStrategy;
+    private final ColumnNamingStrategy nonIntrinsicStrategy;
+
+    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
+            ColumnNamingStrategy nonIntrinsicStrategy) {
+        this.intrinsicStrategy = intrinsicStrategy;
+        this.nonIntrinsicStrategy = nonIntrinsicStrategy;
+    }
+
+    @Override
+    public String getNextColumnName(ColumnNamingContext ctx) {
+        final String intrinsicColumnName = ctx.getIntrinsicColumnName();
+        if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
+            return nonIntrinsicStrategy.getNextColumnName(ctx);
+        }
+        return intrinsicStrategy.getNextColumnName(ctx);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
new file mode 100644
index 0000000..9371059
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/UniqueColumnNamingStrategy.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
+ * ensures that all column names are unique. When duplicate names are
+ * encountered a number will be appended yielding column names like "name",
+ * "name1", "name2" etc.
+ */
+public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private final Set<String> names = new HashSet<>();
+
+    @Override
+    public String getNextColumnName(ColumnNamingContext ctx) {
+        final String intrinsicName = ctx.getIntrinsicColumnName();
+        boolean unique = names.add(intrinsicName);
+        if (unique) {
+            return intrinsicName;
+        }
+
+        String newName = null;
+        for (int i = 2; !unique; i++) {
+            newName = intrinsicName + i;
+            unique = names.add(newName);
+        }
+        return newName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index 3b90b32..6538f5c 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -23,8 +23,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.schema.builder.AlphabeticColumnNamingStrategy;
 import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
+import org.apache.metamodel.schema.builder.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -96,7 +96,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
 	 */
 	public ColumnNamingStrategy getColumnNamingStrategy() {
 	    if (columnNamingStrategy == null) {
-	        return new AlphabeticColumnNamingStrategy();
+	        return new DefaultColumnNamingStrategy();
 	    }
         return columnNamingStrategy;
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0da8f1a1/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
index fcc31ed..0a326cc 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
@@ -122,19 +122,22 @@ public class FixedWidthDataContext extends QueryPostprocessDataContext {
         final FixedWidthReader reader = createReader();
         final String[] columnNames;
         try {
-            if (_configuration.getColumnNameLineNumber() != FixedWidthConfiguration.NO_COLUMN_NAME_LINE) {
+            final boolean hasColumnHeader = _configuration
+                    .getColumnNameLineNumber() != FixedWidthConfiguration.NO_COLUMN_NAME_LINE;
+            if (hasColumnHeader) {
                 for (int i = 1; i < _configuration.getColumnNameLineNumber(); i++) {
                     reader.readLine();
                 }
                 columnNames = reader.readLine();
             } else {
-                final ColumnNamingStrategy columnNamingStrategy = _configuration.getColumnNamingStrategy();
                 columnNames = reader.readLine();
-                if (columnNames != null) {
-                    for (int i = 0; i < columnNames.length; i++) {
-                        columnNames[i] = columnNamingStrategy.getColumnName(new ColumnNamingContextImpl(table, null,
-                                i));
-                    }
+            }
+            final ColumnNamingStrategy columnNamingStrategy = _configuration.getColumnNamingStrategy();
+            if (columnNames != null) {
+                for (int i = 0; i < columnNames.length; i++) {
+                    final String intrinsicColumnName = hasColumnHeader ? columnNames[i] : null;
+                    columnNames[i] = columnNamingStrategy.getNextColumnName(new ColumnNamingContextImpl(table,
+                            intrinsicColumnName, i));
                 }
             }
         } finally {


[10/42] metamodel git commit: METAMODEL-228: Fixed

Posted by ka...@apache.org.
METAMODEL-228: Fixed

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/67a0c96c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/67a0c96c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/67a0c96c

Branch: refs/heads/5.x
Commit: 67a0c96c8f849e112b57ce0cc3e99667e0145384
Parents: 4f4cefd
Author: Kasper S�rensen <i....@gmail.com>
Authored: Tue Feb 9 13:39:15 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Tue Feb 9 13:39:15 2016 +0100

----------------------------------------------------------------------
 CHANGES.md                                      |  1 +
 .../apache/metamodel/schema/ColumnTypeImpl.java |  4 +-
 .../metamodel/schema/ColumnTypeImplTest.java    | 95 ++++++++++++++++++++
 .../apache/metamodel/schema/ColumnTypeTest.java | 92 -------------------
 .../couchdb/CouchDbDataContextTest.java         | 16 ++--
 .../mongodb/mongo2/MongoDbDataContextTest.java  |  2 +-
 .../mongodb/mongo3/MongoDbDataContextTest.java  |  2 +-
 .../pojo/ObjectTableDataProviderTest.java       |  2 +-
 8 files changed, 110 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 13f1694..39aa75e 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,6 +3,7 @@
  * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
  * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
  * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
+ * [METAMODEL-228] - Fixed a bug causing Number.class to not be converted to ColumnType.NUMBER.
 
 ### Apache MetaModel 4.5.0
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/core/src/main/java/org/apache/metamodel/schema/ColumnTypeImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/ColumnTypeImpl.java b/core/src/main/java/org/apache/metamodel/schema/ColumnTypeImpl.java
index 856321e..dbca861 100644
--- a/core/src/main/java/org/apache/metamodel/schema/ColumnTypeImpl.java
+++ b/core/src/main/java/org/apache/metamodel/schema/ColumnTypeImpl.java
@@ -198,7 +198,7 @@ public class ColumnTypeImpl implements ColumnType {
 
         final ColumnType type;
         if (cls == String.class) {
-            type = ColumnType.VARCHAR;
+            type = ColumnType.STRING;
         } else if (cls == Boolean.class || cls == boolean.class) {
             type = ColumnType.BOOLEAN;
         } else if (cls == Character.class || cls == char.class || cls == Character[].class || cls == char[].class) {
@@ -217,6 +217,8 @@ public class ColumnTypeImpl implements ColumnType {
             type = ColumnType.DOUBLE;
         } else if (cls == BigDecimal.class) {
             type = ColumnType.DECIMAL;
+        } else if (Number.class.isAssignableFrom(cls)) {
+            type = ColumnType.NUMBER;
         } else if (Map.class.isAssignableFrom(cls)) {
             type = ColumnType.MAP;
         } else if (List.class.isAssignableFrom(cls)) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/core/src/test/java/org/apache/metamodel/schema/ColumnTypeImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/ColumnTypeImplTest.java b/core/src/test/java/org/apache/metamodel/schema/ColumnTypeImplTest.java
new file mode 100644
index 0000000..fbff3dc
--- /dev/null
+++ b/core/src/test/java/org/apache/metamodel/schema/ColumnTypeImplTest.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema;
+
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+public class ColumnTypeImplTest extends TestCase {
+
+	public void testConvertColumnTypeFromJdbcTypes() throws Exception {
+		ColumnType type = ColumnTypeImpl.convertColumnType(Types.VARCHAR);
+		assertEquals(ColumnType.VARCHAR, type);
+		
+		type = ColumnTypeImpl.convertColumnType(Types.DATE);
+        assertEquals(ColumnType.DATE, type);
+
+		type = ColumnTypeImpl.convertColumnType(Types.TIME);
+		assertEquals(ColumnType.TIME, type);
+
+		type = ColumnTypeImpl.convertColumnType(Types.TIMESTAMP);
+		assertEquals(ColumnType.TIMESTAMP, type);
+
+		type = ColumnTypeImpl.convertColumnType(42397443);
+		assertEquals(ColumnType.OTHER, type);
+		
+		type = ColumnTypeImpl.convertColumnType(-42397443);
+		assertEquals(ColumnType.OTHER, type);
+	}
+	
+	public void testConvertColumnTypeFromJavaClass() throws Exception {
+		ColumnType type = ColumnTypeImpl.convertColumnType(String.class);
+		assertEquals(ColumnType.STRING, type);
+
+        type = ColumnTypeImpl.convertColumnType(Number.class);
+        assertEquals(ColumnType.NUMBER, type);
+
+		type = ColumnTypeImpl.convertColumnType(Time.class);
+		assertEquals(ColumnType.TIME, type);
+
+		type = ColumnTypeImpl.convertColumnType(Timestamp.class);
+		assertEquals(ColumnType.TIMESTAMP, type);
+		
+		type = ColumnTypeImpl.convertColumnType(java.sql.Date.class);
+		assertEquals(ColumnType.DATE, type);
+
+		type = ColumnTypeImpl.convertColumnType(Date.class);
+		assertEquals(ColumnType.TIMESTAMP, type);
+		
+		type = ColumnTypeImpl.convertColumnType(Integer.class);
+		assertEquals(ColumnType.INTEGER, type);
+		
+		type = ColumnTypeImpl.convertColumnType(Object.class);
+		assertEquals(ColumnType.OTHER, type);
+		
+		type = ColumnTypeImpl.convertColumnType(Map.class);
+		assertEquals(ColumnType.MAP, type);
+		type = ColumnTypeImpl.convertColumnType(HashMap.class);
+		assertEquals(ColumnType.MAP, type);
+		type = ColumnTypeImpl.convertColumnType(TreeMap.class);
+		assertEquals(ColumnType.MAP, type);
+		
+		type = ColumnTypeImpl.convertColumnType(List.class);
+		assertEquals(ColumnType.LIST, type);
+		type = ColumnTypeImpl.convertColumnType(ArrayList.class);
+		assertEquals(ColumnType.LIST, type);
+		type = ColumnTypeImpl.convertColumnType(LinkedList.class);
+		assertEquals(ColumnType.LIST, type);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/core/src/test/java/org/apache/metamodel/schema/ColumnTypeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/ColumnTypeTest.java b/core/src/test/java/org/apache/metamodel/schema/ColumnTypeTest.java
deleted file mode 100644
index 58b843a..0000000
--- a/core/src/test/java/org/apache/metamodel/schema/ColumnTypeTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.schema;
-
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-public class ColumnTypeTest extends TestCase {
-
-	public void testConvertColumnTypeFromJdbcTypes() throws Exception {
-		ColumnType type = ColumnTypeImpl.convertColumnType(Types.VARCHAR);
-		assertEquals(ColumnType.VARCHAR, type);
-		
-		type = ColumnTypeImpl.convertColumnType(Types.DATE);
-        assertEquals(ColumnType.DATE, type);
-
-		type = ColumnTypeImpl.convertColumnType(Types.TIME);
-		assertEquals(ColumnType.TIME, type);
-
-		type = ColumnTypeImpl.convertColumnType(Types.TIMESTAMP);
-		assertEquals(ColumnType.TIMESTAMP, type);
-
-		type = ColumnTypeImpl.convertColumnType(42397443);
-		assertEquals(ColumnType.OTHER, type);
-		
-		type = ColumnTypeImpl.convertColumnType(-42397443);
-		assertEquals(ColumnType.OTHER, type);
-	}
-	
-	public void testConvertColumnTypeFromJavaClass() throws Exception {
-		ColumnType type = ColumnTypeImpl.convertColumnType(String.class);
-		assertEquals(ColumnType.VARCHAR, type);
-
-		type = ColumnTypeImpl.convertColumnType(Time.class);
-		assertEquals(ColumnType.TIME, type);
-
-		type = ColumnTypeImpl.convertColumnType(Timestamp.class);
-		assertEquals(ColumnType.TIMESTAMP, type);
-		
-		type = ColumnTypeImpl.convertColumnType(java.sql.Date.class);
-		assertEquals(ColumnType.DATE, type);
-
-		type = ColumnTypeImpl.convertColumnType(Date.class);
-		assertEquals(ColumnType.TIMESTAMP, type);
-		
-		type = ColumnTypeImpl.convertColumnType(Integer.class);
-		assertEquals(ColumnType.INTEGER, type);
-		
-		type = ColumnTypeImpl.convertColumnType(Object.class);
-		assertEquals(ColumnType.OTHER, type);
-		
-		type = ColumnTypeImpl.convertColumnType(Map.class);
-		assertEquals(ColumnType.MAP, type);
-		type = ColumnTypeImpl.convertColumnType(HashMap.class);
-		assertEquals(ColumnType.MAP, type);
-		type = ColumnTypeImpl.convertColumnType(TreeMap.class);
-		assertEquals(ColumnType.MAP, type);
-		
-		type = ColumnTypeImpl.convertColumnType(List.class);
-		assertEquals(ColumnType.LIST, type);
-		type = ColumnTypeImpl.convertColumnType(ArrayList.class);
-		assertEquals(ColumnType.LIST, type);
-		type = ColumnTypeImpl.convertColumnType(LinkedList.class);
-		assertEquals(ColumnType.LIST, type);
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java b/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
index dd637fd..9e1f5fe 100644
--- a/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
+++ b/couchdb/src/test/java/org/apache/metamodel/couchdb/CouchDbDataContextTest.java
@@ -65,7 +65,7 @@ public class CouchDbDataContextTest extends CouchDbTestCase {
             connector = couchDbInstance.createConnector(databaseName, true);
 
             final String[] columnNames = new String[] { "name", "gender", "age" };
-            final ColumnType[] columnTypes = new ColumnType[] { ColumnType.VARCHAR, ColumnType.CHAR, ColumnType.INTEGER };
+            final ColumnType[] columnTypes = new ColumnType[] { ColumnType.STRING, ColumnType.CHAR, ColumnType.INTEGER };
             predefinedTableDef = new SimpleTableDef(databaseName, columnNames, columnTypes);
         }
 
@@ -160,11 +160,11 @@ public class CouchDbDataContextTest extends CouchDbTestCase {
         final CouchDbDataContext dc = new CouchDbDataContext(couchDbInstance);
         Table table = dc.getDefaultSchema().getTableByName(databaseName);
         assertNotNull(table);
-        assertEquals("[Column[name=_id,columnNumber=0,type=VARCHAR,nullable=false,nativeType=null,columnSize=null], "
-                + "Column[name=_rev,columnNumber=1,type=VARCHAR,nullable=false,nativeType=null,columnSize=null], "
-                + "Column[name=bar,columnNumber=2,type=VARCHAR,nullable=null,nativeType=null,columnSize=null], "
+        assertEquals("[Column[name=_id,columnNumber=0,type=STRING,nullable=false,nativeType=null,columnSize=null], "
+                + "Column[name=_rev,columnNumber=1,type=STRING,nullable=false,nativeType=null,columnSize=null], "
+                + "Column[name=bar,columnNumber=2,type=STRING,nullable=null,nativeType=null,columnSize=null], "
                 + "Column[name=baz,columnNumber=3,type=INTEGER,nullable=null,nativeType=null,columnSize=null], "
-                + "Column[name=foo,columnNumber=4,type=VARCHAR,nullable=null,nativeType=null,columnSize=null]]",
+                + "Column[name=foo,columnNumber=4,type=STRING,nullable=null,nativeType=null,columnSize=null]]",
                 Arrays.toString(table.getColumns()));
 
         // first delete the manually created database!
@@ -182,7 +182,7 @@ public class CouchDbDataContextTest extends CouchDbTestCase {
             @Override
             public void run(UpdateCallback callback) {
                 Table table = callback.createTable(dc.getDefaultSchema(), databaseName).withColumn("foo")
-                        .ofType(ColumnType.VARCHAR).withColumn("greeting").ofType(ColumnType.VARCHAR).execute();
+                        .ofType(ColumnType.STRING).withColumn("greeting").ofType(ColumnType.STRING).execute();
                 assertEquals("[_id, _rev, foo, greeting]", Arrays.toString(table.getColumnNames()));
             }
         });
@@ -260,11 +260,11 @@ public class CouchDbDataContextTest extends CouchDbTestCase {
         assertEquals("[_id, _rev, age, gender, name]",
                 Arrays.toString(schema.getTableByName(getDatabaseName()).getColumnNames()));
         Column idColumn = schema.getTableByName(getDatabaseName()).getColumnByName("_id");
-        assertEquals("Column[name=_id,columnNumber=0,type=VARCHAR,nullable=false,nativeType=null,columnSize=null]",
+        assertEquals("Column[name=_id,columnNumber=0,type=STRING,nullable=false,nativeType=null,columnSize=null]",
                 idColumn.toString());
         assertTrue(idColumn.isPrimaryKey());
 
-        assertEquals("Column[name=_rev,columnNumber=1,type=VARCHAR,nullable=false,nativeType=null,columnSize=null]",
+        assertEquals("Column[name=_rev,columnNumber=1,type=STRING,nullable=false,nativeType=null,columnSize=null]",
                 schema.getTableByName(getDatabaseName()).getColumnByName("_rev").toString());
 
         DataSet ds;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
index d777e5e..a03585a 100644
--- a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
+++ b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
@@ -283,7 +283,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase {
         assertEquals("[_id, baz, foo, id, list, name]", Arrays.toString(table.getColumnNames()));
 
         assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
-        assertEquals(ColumnType.VARCHAR, table.getColumnByName("foo").getType());
+        assertEquals(ColumnType.STRING, table.getColumnByName("foo").getType());
         assertEquals(ColumnType.LIST, table.getColumnByName("list").getType());
         assertEquals(ColumnType.INTEGER, table.getColumnByName("id").getType());
         assertEquals(ColumnType.ROWID, table.getColumnByName("_id").getType());

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
index 1952640..d16e47c 100644
--- a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
+++ b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
@@ -266,7 +266,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase {
         assertEquals("[_id, baz, foo, id, list, name]", Arrays.toString(table.getColumnNames()));
 
         assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
-        assertEquals(ColumnType.VARCHAR, table.getColumnByName("foo").getType());
+        assertEquals(ColumnType.STRING, table.getColumnByName("foo").getType());
         assertEquals(ColumnType.LIST, table.getColumnByName("list").getType());
         assertEquals(ColumnType.INTEGER, table.getColumnByName("id").getType());
         assertEquals(ColumnType.ROWID, table.getColumnByName("_id").getType());

http://git-wip-us.apache.org/repos/asf/metamodel/blob/67a0c96c/pojo/src/test/java/org/apache/metamodel/pojo/ObjectTableDataProviderTest.java
----------------------------------------------------------------------
diff --git a/pojo/src/test/java/org/apache/metamodel/pojo/ObjectTableDataProviderTest.java b/pojo/src/test/java/org/apache/metamodel/pojo/ObjectTableDataProviderTest.java
index bdffc2a..ecf89fb 100644
--- a/pojo/src/test/java/org/apache/metamodel/pojo/ObjectTableDataProviderTest.java
+++ b/pojo/src/test/java/org/apache/metamodel/pojo/ObjectTableDataProviderTest.java
@@ -30,7 +30,7 @@ public class ObjectTableDataProviderTest extends TestCase {
 
         SimpleTableDef tableDef = tableDataProvider.getTableDef();
         assertEquals(
-                "SimpleTableDef[name=FoobarBean,columnNames=[col1, col2, col3],columnTypes=[VARCHAR, INTEGER, BOOLEAN]]",
+                "SimpleTableDef[name=FoobarBean,columnNames=[col1, col2, col3],columnTypes=[STRING, INTEGER, BOOLEAN]]",
                 tableDef.toString());
     }
 }


[20/42] metamodel git commit: Moved javadoc exclude to parent pom to fix 'mvn javadoc:aggregate'

Posted by ka...@apache.org.
Moved javadoc exclude to parent pom to fix 'mvn javadoc:aggregate'

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/324ea222
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/324ea222
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/324ea222

Branch: refs/heads/5.x
Commit: 324ea22259be3a19efb6bfcc017291d633488ed2
Parents: 05b5e41
Author: Kasper S�rensen <i....@gmail.com>
Authored: Tue Mar 22 22:58:43 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Tue Mar 22 22:58:43 2016 +0100

----------------------------------------------------------------------
 pom.xml          | 3 +++
 sugarcrm/pom.xml | 7 -------
 2 files changed, 3 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/324ea222/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 064af81..8311ca2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -248,6 +248,9 @@ under the License.
 						<phase>site</phase>
 					</execution>
 				</executions>
+				<configuration>
+					<excludePackageNames>com.sugarcrm.ws.soap</excludePackageNames>
+				</configuration>
 			</plugin>
 			<plugin>
 				<groupId>net.ju-n.maven.plugins</groupId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/324ea222/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 159eb88..34bb144 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -95,13 +95,6 @@ under the License.
 					</execution>
 				</executions>
 			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-javadoc-plugin</artifactId>
-				<configuration>
-					<excludePackageNames>com.sugarcrm.ws.soap</excludePackageNames>
-				</configuration>
-			</plugin>
 		</plugins>
 
 		<pluginManagement>


[27/42] metamodel git commit: METAMODEL-244: Implemented naming strategy support in csv module

Posted by ka...@apache.org.
METAMODEL-244: Implemented naming strategy support in csv module

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/0fcc4de3
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/0fcc4de3
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/0fcc4de3

Branch: refs/heads/5.x
Commit: 0fcc4de38faa180a321f01ba724f112a70cd86f9
Parents: d5b9e12
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Apr 24 13:48:28 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Apr 24 13:48:28 2016 -0700

----------------------------------------------------------------------
 .../builder/DefaultColumnNamingStrategy.java    |  2 +
 .../DefaultColumnNamingStrategyTest.java        | 46 +++++++++++++++++++
 .../apache/metamodel/csv/CsvConfiguration.java  | 24 +++++++++-
 .../java/org/apache/metamodel/csv/CsvTable.java | 26 ++++++-----
 .../fixedwidth/FixedWidthConfiguration.java     | 48 +++++++++++---------
 5 files changed, 111 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/0fcc4de3/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
index 9aef863..2cc9fb7 100644
--- a/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategy.java
@@ -24,6 +24,8 @@ package org.apache.metamodel.schema.builder;
  */
 public class DefaultColumnNamingStrategy extends DelegatingIntrinsicSwitchColumnNamingStrategy {
 
+    private static final long serialVersionUID = 1L;
+
     public DefaultColumnNamingStrategy() {
         super(new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0fcc4de3/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java b/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java
new file mode 100644
index 0000000..b903065
--- /dev/null
+++ b/core/src/test/java/org/apache/metamodel/schema/builder/DefaultColumnNamingStrategyTest.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.builder;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class DefaultColumnNamingStrategyTest {
+
+    private final DefaultColumnNamingStrategy namingStrategy = new DefaultColumnNamingStrategy();
+
+    @Test
+    public void testDuplicateColumnNames() throws Exception {
+        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
+            assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
+            assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
+            assertEquals("foo2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
+        }
+    }
+
+    @Test
+    public void testNoIntrinsicColumnNames() throws Exception {
+        try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
+            assertEquals("A", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 0)));
+            assertEquals("B", session.getNextColumnName(new ColumnNamingContextImpl(null, null, 1)));
+            assertEquals("C", session.getNextColumnName(new ColumnNamingContextImpl(null, "", 2)));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0fcc4de3/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
index d45709c..4d1874c 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.csv;
 import java.io.Serializable;
 import java.util.List;
 
+import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
+import org.apache.metamodel.schema.builder.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -50,6 +52,7 @@ public final class CsvConfiguration extends BaseObject implements Serializable {
     private final char escapeChar;
     private final boolean failOnInconsistentRowLength;
     private final boolean multilineValues;
+    private final ColumnNamingStrategy columnNamingStrategy;
 
     public CsvConfiguration() {
         this(DEFAULT_COLUMN_NAME_LINE);
@@ -74,9 +77,16 @@ public final class CsvConfiguration extends BaseObject implements Serializable {
             char escapeChar, boolean failOnInconsistentRowLength) {
         this(columnNameLineNumber, encoding, separatorChar, quoteChar, escapeChar, failOnInconsistentRowLength, true);
     }
-
+    
     public CsvConfiguration(int columnNameLineNumber, String encoding, char separatorChar, char quoteChar,
             char escapeChar, boolean failOnInconsistentRowLength, boolean multilineValues) {
+        this(columnNameLineNumber, null, encoding, separatorChar, quoteChar, escapeChar, failOnInconsistentRowLength,
+                multilineValues);
+    }
+
+    public CsvConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
+            char separatorChar, char quoteChar, char escapeChar, boolean failOnInconsistentRowLength,
+            boolean multilineValues) {
         this.columnNameLineNumber = columnNameLineNumber;
         this.encoding = encoding;
         this.separatorChar = separatorChar;
@@ -84,6 +94,18 @@ public final class CsvConfiguration extends BaseObject implements Serializable {
         this.escapeChar = escapeChar;
         this.failOnInconsistentRowLength = failOnInconsistentRowLength;
         this.multilineValues = multilineValues;
+        this.columnNamingStrategy = null;
+    }
+    
+    /**
+     * Gets a {@link ColumnNamingStrategy} to use if needed.
+     * @return
+     */
+    public ColumnNamingStrategy getColumnNamingStrategy() {
+        if (columnNamingStrategy == null) {
+            return new DefaultColumnNamingStrategy();
+        }
+        return columnNamingStrategy;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0fcc4de3/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java b/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
index b5ae485..e2a665d 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvTable.java
@@ -27,7 +27,9 @@ import org.apache.metamodel.schema.MutableColumn;
 import org.apache.metamodel.schema.Relationship;
 import org.apache.metamodel.schema.Schema;
 import org.apache.metamodel.schema.TableType;
-import org.apache.metamodel.util.AlphabeticSequence;
+import org.apache.metamodel.schema.builder.ColumnNamingContextImpl;
+import org.apache.metamodel.schema.builder.ColumnNamingSession;
+import org.apache.metamodel.schema.builder.ColumnNamingStrategy;
 import org.apache.metamodel.util.FileHelper;
 
 import au.com.bytecode.opencsv.CSVReader;
@@ -109,23 +111,23 @@ final class CsvTable extends AbstractTable {
         if (columnNames == null) {
             return new Column[0];
         }
-
+        
         final CsvConfiguration configuration = _schema.getDataContext().getConfiguration();
         final int columnNameLineNumber = configuration.getColumnNameLineNumber();
         final boolean nullable = !configuration.isFailOnInconsistentRowLength();
+        final ColumnNamingStrategy columnNamingStrategy = configuration.getColumnNamingStrategy();
 
         final Column[] columns = new Column[columnNames.length];
-        final AlphabeticSequence sequence = new AlphabeticSequence();
-        for (int i = 0; i < columnNames.length; i++) {
-            final String columnName;
-            if (columnNameLineNumber == CsvConfiguration.NO_COLUMN_NAME_LINE) {
-                columnName = sequence.next();
-            } else {
-                columnName = columnNames[i];
+        try (final ColumnNamingSession namingSession = columnNamingStrategy.startColumnNamingSession()) {
+            for (int i = 0; i < columnNames.length; i++) {
+                final String intrinsicColumnName = columnNameLineNumber == CsvConfiguration.NO_COLUMN_NAME_LINE ? null
+                        : columnNames[i];
+                final String columnName = namingSession.getNextColumnName(new ColumnNamingContextImpl(this,
+                        intrinsicColumnName, i));
+                final Column column = new MutableColumn(columnName, ColumnType.STRING, this, i, null, null, nullable,
+                        null, false, null);
+                columns[i] = column;
             }
-            Column column = new MutableColumn(columnName, ColumnType.STRING, this, i, null, null, nullable, null,
-                    false, null);
-            columns[i] = column;
         }
         return columns;
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/0fcc4de3/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index 6538f5c..9c0dd46 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -56,30 +56,34 @@ public final class FixedWidthConfiguration extends BaseObject implements
 				false);
 	}
 
-	public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
-			int fixedValueWidth) {
-		this(columnNameLineNumber, encoding, fixedValueWidth, false);
-	}
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
+        this(columnNameLineNumber, encoding, fixedValueWidth, false);
+    }
 
-	public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
-			int fixedValueWidth, boolean failOnInconsistentLineWidth) {
-		this.encoding = encoding;
-		this.fixedValueWidth = fixedValueWidth;
-		this.columnNameLineNumber = columnNameLineNumber;
-		this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
-		this.columnNamingStrategy = null;
-		this.valueWidths = new int[0];
-	}
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
+            boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = fixedValueWidth;
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+        this.columnNamingStrategy = null;
+        this.valueWidths = new int[0];
+    }
 
-	public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
-			int[] valueWidths, boolean failOnInconsistentLineWidth) {
-		this.encoding = encoding;
-		this.fixedValueWidth = -1;
-		this.columnNameLineNumber = columnNameLineNumber;
-		this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
-		this.columnNamingStrategy = null;
-		this.valueWidths = valueWidths;
-	}
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
+            int[] valueWidths, boolean failOnInconsistentLineWidth) {
+        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
+    }
+    
+    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
+            int[] valueWidths, boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = -1;
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+        this.columnNamingStrategy = columnNamingStrategy;
+        this.valueWidths = valueWidths;
+    }
 
 	/**
 	 * The line number (1 based) from which to get the names of the columns.


[41/42] metamodel git commit: Merge branch 'master' into 5.x

Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
----------------------------------------------------------------------
diff --cc fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
index 0000000,9154e5e..3c8d14c
mode 000000,100644..100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
@@@ -1,0 -1,180 +1,180 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.fixedwidth;
 -
 -import java.io.BufferedReader;
 -import java.io.InputStream;
 -import java.io.InputStreamReader;
 -import java.util.ArrayList;
 -import java.util.HashMap;
 -import java.util.LinkedHashMap;
 -import java.util.List;
 -import java.util.Map;
 -import java.util.Map.Entry;
 -import java.util.regex.Matcher;
 -import java.util.regex.Pattern;
 -
 -import org.apache.metamodel.csv.CsvConfiguration;
 -import org.apache.metamodel.csv.CsvDataContext;
 -import org.apache.metamodel.data.DataSet;
 -import org.apache.metamodel.schema.Table;
 -import org.apache.metamodel.util.Action;
 -import org.apache.metamodel.util.Resource;
 -import org.slf4j.Logger;
 -import org.slf4j.LoggerFactory;
 -
 -/**
 - * Object capable of reading fixed width metadata from external sources and
 - * thereby producing an appropriate {@link FixedWidthConfiguration} to use with
 - * a {@link FixedWidthDataContext}.
 - */
 -public class FixedWidthConfigurationReader {
 -
 -    private static final Logger logger = LoggerFactory.getLogger(FixedWidthConfigurationReader.class);
 -
 -    // example: @1 COL1 $char1.
 -    private final Pattern PATTERN_SAS_INPUT_LINE = Pattern.compile("\\@(\\d+) (.+) .*?(\\d+)\\.");
 -
 -    // example: COL1 "Record type"
 -    private final Pattern PATTERN_SAS_LABEL_LINE = Pattern.compile("(.+) \\\"(.+)\\\"");
 -
 -    /**
 -     * Reads a {@link FixedWidthConfiguration} based on a SAS 'format file',
 -     * <a href=
 -     * "http://support.sas.com/documentation/cdl/en/etlug/67323/HTML/default/viewer.htm#p0h03yig7fp1qan1arghp3lwjqi6.htm">
 -     * described here</a>.
 -     * 
 -     * @param encoding
 -     * @param resource
 -     *            the format file resource
 -     * @param failOnInconsistentLineWidth
 -     * @return a {@link FixedWidthConfiguration} object to use
 -     */
 -    public FixedWidthConfiguration readFromSasFormatFile(String encoding, Resource resource,
 -            boolean failOnInconsistentLineWidth) {
 -        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
 -
 -        final CsvDataContext dataContext = new CsvDataContext(resource, new CsvConfiguration());
 -        final Table table = dataContext.getDefaultSchema().getTable(0);
 -        try (final DataSet dataSet = dataContext.query().from(table).select("Name", "BeginPosition", "EndPosition")
 -                .execute()) {
 -            while (dataSet.next()) {
 -                final String name = (String) dataSet.getRow().getValue(0);
 -                final int beginPosition = Integer.parseInt((String) dataSet.getRow().getValue(1));
 -                final int endPosition = Integer.parseInt((String) dataSet.getRow().getValue(2));
 -                final int width = 1 + endPosition - beginPosition;
 -                columnSpecs.add(new FixedWidthColumnSpec(name, width));
 -            }
 -        }
 -
 -        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
 -    }
 -
 -    /**
 -     * Reads a {@link FixedWidthConfiguration} based on a SAS INPUT declaration.
 -     * The reader method also optionally will look for a LABEL defintion for
 -     * column naming.
 -     * 
 -     * @param encoding
 -     * @param resource
 -     *            the format file resource
 -     * @param failOnInconsistentLineWidth
 -     * @return a {@link FixedWidthConfiguration} object to use
 -     */
 -    public FixedWidthConfiguration readFromSasInputDefinition(String encoding, Resource resource,
 -            boolean failOnInconsistentLineWidth) {
 -
 -        final Map<String, Integer> inputWidthDeclarations = new LinkedHashMap<>();
 -        final Map<String, String> labelDeclarations = new HashMap<>();
 -
 -        resource.read(new Action<InputStream>() {
 -
 -            private boolean inInputSection = false;
 -            private boolean inLabelSection = false;
 -
 -            @Override
 -            public void run(InputStream in) throws Exception {
 -                try (final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
 -                    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
 -                        processLine(line);
 -                    }
 -                }
 -            }
 -
 -            private void processLine(String line) {
 -                line = line.trim();
 -                if (line.isEmpty()) {
 -                    return;
 -                }
 -                if (";".equals(line)) {
 -                    inInputSection = false;
 -                    inLabelSection = false;
 -                    return;
 -                } else if ("INPUT".equals(line)) {
 -                    inInputSection = true;
 -                    return;
 -                } else if ("LABEL".equals(line)) {
 -                    inLabelSection = true;
 -                    return;
 -                }
 -
 -                if (inInputSection) {
 -                    final Matcher matcher = PATTERN_SAS_INPUT_LINE.matcher(line);
 -                    if (matcher.matches()) {
 -                        final String positionSpec = matcher.group(1);
 -                        final String nameSpec = matcher.group(2);
 -                        final int width = Integer.parseInt(matcher.group(3));
 -                        logger.debug("Parsed INPUT line \"{}\": position={}, name={}, width={}", line, positionSpec,
 -                                nameSpec, width);
 -                        inputWidthDeclarations.put(nameSpec, width);
 -                    } else {
 -                        logger.debug("Failed to parse/recognize INPUT line \"{}\"", line);
 -                    }
 -                } else if (inLabelSection) {
 -                    final Matcher matcher = PATTERN_SAS_LABEL_LINE.matcher(line);
 -                    if (matcher.matches()) {
 -                        final String nameSpec = matcher.group(1);
 -                        final String labelSpec = matcher.group(2);
 -                        logger.debug("Parsed LABEL line \"{}\": name={}, label={}", line, nameSpec, labelSpec);
 -                        labelDeclarations.put(nameSpec, labelSpec);
 -                    } else {
 -                        logger.debug("Failed to parse/recognize LABEL line \"{}\"", line);
 -                    }
 -                }
 -
 -                if (line.endsWith(";")) {
 -                    inInputSection = false;
 -                    inLabelSection = false;
 -                }
 -            }
 -        });
 -
 -        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
 -        for (Entry<String, Integer> entry : inputWidthDeclarations.entrySet()) {
 -            final String columnKey = entry.getKey();
 -            final Integer columnWidth = entry.getValue();
 -            final String columnLabel = labelDeclarations.get(columnKey);
 -            final String columnName = columnLabel == null ? columnKey : columnLabel;
 -            columnSpecs.add(new FixedWidthColumnSpec(columnName, columnWidth));
 -        }
 -
 -        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
 -    }
 -
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.fixedwidth;
++
++import java.io.BufferedReader;
++import java.io.InputStream;
++import java.io.InputStreamReader;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.LinkedHashMap;
++import java.util.List;
++import java.util.Map;
++import java.util.Map.Entry;
++import java.util.regex.Matcher;
++import java.util.regex.Pattern;
++
++import org.apache.metamodel.csv.CsvConfiguration;
++import org.apache.metamodel.csv.CsvDataContext;
++import org.apache.metamodel.data.DataSet;
++import org.apache.metamodel.schema.Table;
++import org.apache.metamodel.util.Action;
++import org.apache.metamodel.util.Resource;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++/**
++ * Object capable of reading fixed width metadata from external sources and
++ * thereby producing an appropriate {@link FixedWidthConfiguration} to use with
++ * a {@link FixedWidthDataContext}.
++ */
++public class FixedWidthConfigurationReader {
++
++    private static final Logger logger = LoggerFactory.getLogger(FixedWidthConfigurationReader.class);
++
++    // example: @1 COL1 $char1.
++    private final Pattern PATTERN_SAS_INPUT_LINE = Pattern.compile("\\@(\\d+) (.+) .*?(\\d+)\\.");
++
++    // example: COL1 "Record type"
++    private final Pattern PATTERN_SAS_LABEL_LINE = Pattern.compile("(.+) \\\"(.+)\\\"");
++
++    /**
++     * Reads a {@link FixedWidthConfiguration} based on a SAS 'format file',
++     * <a href=
++     * "http://support.sas.com/documentation/cdl/en/etlug/67323/HTML/default/viewer.htm#p0h03yig7fp1qan1arghp3lwjqi6.htm">
++     * described here</a>.
++     * 
++     * @param encoding
++     * @param resource
++     *            the format file resource
++     * @param failOnInconsistentLineWidth
++     * @return a {@link FixedWidthConfiguration} object to use
++     */
++    public FixedWidthConfiguration readFromSasFormatFile(String encoding, Resource resource,
++            boolean failOnInconsistentLineWidth) {
++        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
++
++        final CsvDataContext dataContext = new CsvDataContext(resource, new CsvConfiguration());
++        final Table table = dataContext.getDefaultSchema().getTable(0);
++        try (final DataSet dataSet = dataContext.query().from(table).select("Name", "BeginPosition", "EndPosition")
++                .execute()) {
++            while (dataSet.next()) {
++                final String name = (String) dataSet.getRow().getValue(0);
++                final int beginPosition = Integer.parseInt((String) dataSet.getRow().getValue(1));
++                final int endPosition = Integer.parseInt((String) dataSet.getRow().getValue(2));
++                final int width = 1 + endPosition - beginPosition;
++                columnSpecs.add(new FixedWidthColumnSpec(name, width));
++            }
++        }
++
++        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
++    }
++
++    /**
++     * Reads a {@link FixedWidthConfiguration} based on a SAS INPUT declaration.
++     * The reader method also optionally will look for a LABEL defintion for
++     * column naming.
++     * 
++     * @param encoding
++     * @param resource
++     *            the format file resource
++     * @param failOnInconsistentLineWidth
++     * @return a {@link FixedWidthConfiguration} object to use
++     */
++    public FixedWidthConfiguration readFromSasInputDefinition(String encoding, Resource resource,
++            boolean failOnInconsistentLineWidth) {
++
++        final Map<String, Integer> inputWidthDeclarations = new LinkedHashMap<>();
++        final Map<String, String> labelDeclarations = new HashMap<>();
++
++        resource.read(new Action<InputStream>() {
++
++            private boolean inInputSection = false;
++            private boolean inLabelSection = false;
++
++            @Override
++            public void run(InputStream in) throws Exception {
++                try (final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
++                    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
++                        processLine(line);
++                    }
++                }
++            }
++
++            private void processLine(String line) {
++                line = line.trim();
++                if (line.isEmpty()) {
++                    return;
++                }
++                if (";".equals(line)) {
++                    inInputSection = false;
++                    inLabelSection = false;
++                    return;
++                } else if ("INPUT".equals(line)) {
++                    inInputSection = true;
++                    return;
++                } else if ("LABEL".equals(line)) {
++                    inLabelSection = true;
++                    return;
++                }
++
++                if (inInputSection) {
++                    final Matcher matcher = PATTERN_SAS_INPUT_LINE.matcher(line);
++                    if (matcher.matches()) {
++                        final String positionSpec = matcher.group(1);
++                        final String nameSpec = matcher.group(2);
++                        final int width = Integer.parseInt(matcher.group(3));
++                        logger.debug("Parsed INPUT line \"{}\": position={}, name={}, width={}", line, positionSpec,
++                                nameSpec, width);
++                        inputWidthDeclarations.put(nameSpec, width);
++                    } else {
++                        logger.debug("Failed to parse/recognize INPUT line \"{}\"", line);
++                    }
++                } else if (inLabelSection) {
++                    final Matcher matcher = PATTERN_SAS_LABEL_LINE.matcher(line);
++                    if (matcher.matches()) {
++                        final String nameSpec = matcher.group(1);
++                        final String labelSpec = matcher.group(2);
++                        logger.debug("Parsed LABEL line \"{}\": name={}, label={}", line, nameSpec, labelSpec);
++                        labelDeclarations.put(nameSpec, labelSpec);
++                    } else {
++                        logger.debug("Failed to parse/recognize LABEL line \"{}\"", line);
++                    }
++                }
++
++                if (line.endsWith(";")) {
++                    inInputSection = false;
++                    inLabelSection = false;
++                }
++            }
++        });
++
++        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
++        for (Entry<String, Integer> entry : inputWidthDeclarations.entrySet()) {
++            final String columnKey = entry.getKey();
++            final Integer columnWidth = entry.getValue();
++            final String columnLabel = labelDeclarations.get(columnKey);
++            final String columnName = columnLabel == null ? columnKey : columnLabel;
++            columnSpecs.add(new FixedWidthColumnSpec(columnName, columnWidth));
++        }
++
++        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
----------------------------------------------------------------------
diff --cc fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
index 0000000,eb57233..c34b294
mode 000000,100644..100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
@@@ -1,0 -1,89 +1,89 @@@
 -/**
 - * Licensed to the Apache Software Foundation (ASF) under one
 - * or more contributor license agreements.  See the NOTICE file
 - * distributed with this work for additional information
 - * regarding copyright ownership.  The ASF licenses this file
 - * to you 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
 - *
 - * 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 org.apache.metamodel.fixedwidth;
 -
 -import static org.junit.Assert.*;
 -
 -import java.util.Arrays;
 -
 -import org.apache.metamodel.DataContext;
 -import org.apache.metamodel.data.DataSet;
 -import org.apache.metamodel.schema.Table;
 -import org.apache.metamodel.util.FileResource;
 -import org.apache.metamodel.util.Resource;
 -import org.junit.Test;
 -
 -public class FixedWidthConfigurationReaderTest {
 -
 -    private final FileResource dataResource = new FileResource("src/test/resources/metadata_spec1/data.txt");
 -
 -    @Test
 -    public void testReadConfigurationFromSasFormatFile() throws Exception {
 -        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
 -        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-formatfile-metadata.txt");
 -        assertTrue(resource.isExists());
 -
 -        final FixedWidthConfiguration configuration = reader.readFromSasFormatFile("UTF8", resource, false);
 -        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
 -
 -        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
 -
 -        performAssertionsOnSpec1(dataContext);
 -    }
 -    
 -    @Test
 -    public void testReadConfigurationFromSasInputMetadata() throws Exception {
 -        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
 -        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-input-metadata.txt");
 -        assertTrue(resource.isExists());
 -
 -        final FixedWidthConfiguration configuration = reader.readFromSasInputDefinition("UTF8", resource, false);
 -        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
 -
 -        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
 -
 -        performAssertionsOnSpec1(dataContext);
 -    }
 -
 -    /**
 -     * Shared assertions section once the 'metadata_spec1' {@link DataContext}
 -     * has been loaded.
 -     * 
 -     * @param dataContext
 -     */
 -    private void performAssertionsOnSpec1(FixedWidthDataContext dataContext) {
 -        final Table table = dataContext.getDefaultSchema().getTable(0);
 -        final String[] columnNames = table.getColumnNames();
 -        assertEquals("[Record type, Description, Initials]", Arrays.toString(columnNames));
 -
 -        try (final DataSet dataSet = dataContext.query().from(table).selectAll().execute()) {
 -            assertTrue(dataSet.next());
 -            assertEquals("Row[values=[P, Kasper Sorensen, KS]]", dataSet.getRow().toString());
 -            assertTrue(dataSet.next());
 -            assertEquals("Row[values=[C, Human Inference, HI]]", dataSet.getRow().toString());
 -            assertTrue(dataSet.next());
 -            assertEquals("Row[values=[P, Ankit Kumar, AK]]", dataSet.getRow().toString());
 -            assertTrue(dataSet.next());
 -            assertEquals("Row[values=[C, Stratio, S]]", dataSet.getRow().toString());
 -            assertTrue(dataSet.next());
 -            assertEquals("Row[values=[U, Unknown, ]]", dataSet.getRow().toString());
 -            assertFalse(dataSet.next());
 -        }
 -    }
 -}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you 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
++ *
++ * 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 org.apache.metamodel.fixedwidth;
++
++import static org.junit.Assert.*;
++
++import java.util.Arrays;
++
++import org.apache.metamodel.DataContext;
++import org.apache.metamodel.data.DataSet;
++import org.apache.metamodel.schema.Table;
++import org.apache.metamodel.util.FileResource;
++import org.apache.metamodel.util.Resource;
++import org.junit.Test;
++
++public class FixedWidthConfigurationReaderTest {
++
++    private final FileResource dataResource = new FileResource("src/test/resources/metadata_spec1/data.txt");
++
++    @Test
++    public void testReadConfigurationFromSasFormatFile() throws Exception {
++        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
++        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-formatfile-metadata.txt");
++        assertTrue(resource.isExists());
++
++        final FixedWidthConfiguration configuration = reader.readFromSasFormatFile("UTF8", resource, false);
++        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
++
++        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
++
++        performAssertionsOnSpec1(dataContext);
++    }
++    
++    @Test
++    public void testReadConfigurationFromSasInputMetadata() throws Exception {
++        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
++        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-input-metadata.txt");
++        assertTrue(resource.isExists());
++
++        final FixedWidthConfiguration configuration = reader.readFromSasInputDefinition("UTF8", resource, false);
++        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
++
++        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
++
++        performAssertionsOnSpec1(dataContext);
++    }
++
++    /**
++     * Shared assertions section once the 'metadata_spec1' {@link DataContext}
++     * has been loaded.
++     * 
++     * @param dataContext
++     */
++    private void performAssertionsOnSpec1(FixedWidthDataContext dataContext) {
++        final Table table = dataContext.getDefaultSchema().getTable(0);
++        final String[] columnNames = table.getColumnNames();
++        assertEquals("[Record type, Description, Initials]", Arrays.toString(columnNames));
++
++        try (final DataSet dataSet = dataContext.query().from(table).selectAll().execute()) {
++            assertTrue(dataSet.next());
++            assertEquals("Row[values=[P, Kasper Sorensen, KS]]", dataSet.getRow().toString());
++            assertTrue(dataSet.next());
++            assertEquals("Row[values=[C, Human Inference, HI]]", dataSet.getRow().toString());
++            assertTrue(dataSet.next());
++            assertEquals("Row[values=[P, Ankit Kumar, AK]]", dataSet.getRow().toString());
++            assertTrue(dataSet.next());
++            assertEquals("Row[values=[C, Stratio, S]]", dataSet.getRow().toString());
++            assertTrue(dataSet.next());
++            assertEquals("Row[values=[U, Unknown, ]]", dataSet.getRow().toString());
++            assertFalse(dataSet.next());
++        }
++    }
++}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/test/resources/metadata_spec1/data.txt
----------------------------------------------------------------------
diff --cc fixedwidth/src/test/resources/metadata_spec1/data.txt
index 0000000,785a539..ac055c9
mode 000000,100644..100644
--- a/fixedwidth/src/test/resources/metadata_spec1/data.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/data.txt
@@@ -1,0 -1,5 +1,5 @@@
 -PKasper Sorensen     KS
 -CHuman Inference     HI
 -PAnkit Kumar         AK
 -CStratio             S 
 -UUnknown               
++PKasper Sorensen     KS
++CHuman Inference     HI
++PAnkit Kumar         AK
++CStratio             S 
++UUnknown               

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
----------------------------------------------------------------------
diff --cc fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
index 0000000,9bbe411..38b0e04
mode 000000,100644..100644
--- a/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
@@@ -1,0 -1,4 +1,4 @@@
 -Name,SASColumnType,BeginPosition,EndPosition,ReadFlag,Desc,SASFormat,SASInformat
 -Record type,C,1,1,y,Record Type,$char.,$char.
 -Description,C,2,21,y,Description of record,$char.,$char.
 -Initials,C,22,23,y,Initials of record,,
++Name,SASColumnType,BeginPosition,EndPosition,ReadFlag,Desc,SASFormat,SASInformat
++Record type,C,1,1,y,Record Type,$char.,$char.
++Description,C,2,21,y,Description of record,$char.,$char.
++Initials,C,22,23,y,Initials of record,,

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
----------------------------------------------------------------------
diff --cc fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
index 0000000,f12e418..6839a9b
mode 000000,100644..100644
--- a/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
@@@ -1,0 -1,19 +1,19 @@@
 -INPUT
 -
 -   @1 COL1 $char1.
 -
 -   @2 COL2 $char20.
 -
 -   @22 COL3 $char2.
 -   
 -;
 -
 -LABEL
 -
 -   COL1 "Record type"
 -
 -   COL2 "Description"
 -
 -   COL3 "Initials"
 -
 -;
++INPUT
++
++   @1 COL1 $char1.
++
++   @2 COL2 $char20.
++
++   @22 COL3 $char2.
++   
++;
++
++LABEL
++
++   COL1 "Record type"
++
++   COL2 "Description"
++
++   COL3 "Initials"
++
++;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/full/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --cc mongodb/common/pom.xml
index 0000000,850d2f7..9675d9e
mode 000000,100644..100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@@ -1,0 -1,67 +1,67 @@@
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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
+ 
+ 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.
+ -->
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 	<parent>
+ 		<artifactId>MetaModel-mongodb</artifactId>
+ 		<groupId>org.apache.metamodel</groupId>
 -		<version>4.5.3-SNAPSHOT</version>
++		<version>5.0-SNAPSHOT</version>
+ 	</parent>
+ 	<modelVersion>4.0.0</modelVersion>
+ 	<artifactId>MetaModel-mongodb-common</artifactId>
+ 	<name>MetaModel module for MongoDB commons</name>
+ 	
+ 	<dependencies>
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-core</artifactId>
+ 			<version>${project.version}</version>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.mongodb</groupId>
+ 			<artifactId>mongo-java-driver</artifactId>
+ 			<version>3.1.0</version>
+ 			<scope>provided</scope>
+ 		</dependency>
+ 
+ 		<!-- Test dependencies -->
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-jdbc</artifactId>
+ 			<version>${project.version}</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.apache.derby</groupId>
+ 			<artifactId>derby</artifactId>
+ 			<version>10.8.1.2</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.slf4j</groupId>
+ 			<artifactId>slf4j-nop</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>junit</groupId>
+ 			<artifactId>junit</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 	</dependencies>
+ </project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --cc mongodb/mongo2/pom.xml
index 0000000,4905102..8cd2540
mode 000000,100644..100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@@ -1,0 -1,70 +1,70 @@@
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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
+ 
+ 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.
+ -->
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 	<parent>
+ 		<artifactId>MetaModel-mongodb</artifactId>
+ 		<groupId>org.apache.metamodel</groupId>
 -		<version>4.5.3-SNAPSHOT</version>
++		<version>5.0-SNAPSHOT</version>
+ 	</parent>
+ 	<modelVersion>4.0.0</modelVersion>
+ 	<artifactId>MetaModel-mongodb-mongo2</artifactId>
+ 	<name>MetaModel module for MongoDB 2.x</name>
+ 	<dependencies>
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-core</artifactId>
+ 			<version>${project.version}</version>
+ 		</dependency>
+ 		<dependency>
+             <groupId>org.apache.metamodel</groupId>
+             <artifactId>MetaModel-mongodb-common</artifactId>
+             <version>${project.version}</version>
+         </dependency>
+ 		<dependency>
+ 			<groupId>org.mongodb</groupId>
+ 			<artifactId>mongo-java-driver</artifactId>
+ 			<version>2.14.0</version>
+ 		</dependency>
+ 
+ 		<!-- Test dependencies -->
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-jdbc</artifactId>
+ 			<version>${project.version}</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.apache.derby</groupId>
+ 			<artifactId>derby</artifactId>
+ 			<version>10.8.1.2</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.slf4j</groupId>
+ 			<artifactId>slf4j-nop</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>junit</groupId>
+ 			<artifactId>junit</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 	</dependencies>
+ </project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
----------------------------------------------------------------------
diff --cc mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
index 0000000,cfeb836..d2095e9
mode 000000,100644..100644
--- a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
@@@ -1,0 -1,528 +1,530 @@@
+ /**
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you 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
+  *
+  * 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 org.apache.metamodel.mongodb.mongo2;
+ 
+ import java.util.ArrayList;
+ import java.util.HashSet;
+ import java.util.List;
+ import java.util.Map.Entry;
+ import java.util.Set;
+ import java.util.SortedMap;
+ import java.util.TreeMap;
+ import java.util.regex.Pattern;
+ 
+ import org.apache.metamodel.DataContext;
+ import org.apache.metamodel.MetaModelException;
+ import org.apache.metamodel.QueryPostprocessDataContext;
+ import org.apache.metamodel.UpdateScript;
++import org.apache.metamodel.UpdateSummary;
+ import org.apache.metamodel.UpdateableDataContext;
+ import org.apache.metamodel.data.DataSet;
+ import org.apache.metamodel.data.DataSetHeader;
+ import org.apache.metamodel.data.InMemoryDataSet;
+ import org.apache.metamodel.data.Row;
+ import org.apache.metamodel.data.SimpleDataSetHeader;
+ import org.apache.metamodel.mongodb.common.MongoDBUtils;
+ import org.apache.metamodel.mongodb.common.MongoDbTableDef;
+ import org.apache.metamodel.query.FilterItem;
+ import org.apache.metamodel.query.FromItem;
+ import org.apache.metamodel.query.OperatorType;
+ import org.apache.metamodel.query.Query;
+ import org.apache.metamodel.query.SelectItem;
+ import org.apache.metamodel.schema.Column;
+ import org.apache.metamodel.schema.ColumnType;
+ import org.apache.metamodel.schema.ColumnTypeImpl;
+ import org.apache.metamodel.schema.MutableColumn;
+ import org.apache.metamodel.schema.MutableSchema;
+ import org.apache.metamodel.schema.MutableTable;
+ import org.apache.metamodel.schema.Schema;
+ import org.apache.metamodel.schema.Table;
+ import org.apache.metamodel.util.SimpleTableDef;
+ import org.bson.types.ObjectId;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ 
+ import com.mongodb.BasicDBList;
+ import com.mongodb.BasicDBObject;
+ import com.mongodb.DB;
+ import com.mongodb.DBCollection;
+ import com.mongodb.DBCursor;
+ import com.mongodb.DBObject;
+ import com.mongodb.WriteConcern;
+ 
+ /**
+  * DataContext implementation for MongoDB.
+  *
+  * Since MongoDB has no schema, a virtual schema will be used in this
+  * DataContext. This implementation supports either automatic discovery of a
+  * schema or manual specification of a schema, through the
+  * {@link MongoDbTableDef} class.
+  */
+ public class MongoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext {
+ 
+     private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
+ 
+     private final DB _mongoDb;
+     private final SimpleTableDef[] _tableDefs;
+     private WriteConcernAdvisor _writeConcernAdvisor;
+     private Schema _schema;
+ 
+     /**
+      * Constructor available for backwards compatibility
+      *
+      * @deprecated use {@link #MongoDbDataContext(DB, SimpleTableDef...)}
+      *             instead
+      */
+     @Deprecated
+     public MongoDbDataContext(DB mongoDb, MongoDbTableDef... tableDefs) {
+         this(mongoDb, (SimpleTableDef[]) tableDefs);
+     }
+ 
+     /**
+      * Constructs a {@link MongoDbDataContext}. This constructor accepts a
+      * custom array of {@link MongoDbTableDef}s which allows the user to define
+      * his own view on the collections in the database.
+      *
+      * @param mongoDb
+      *            the mongo db connection
+      * @param tableDefs
+      *            an array of {@link MongoDbTableDef}s, which define the table
+      *            and column model of the mongo db collections. (consider using
+      *            {@link #detectSchema(DB)} or {@link #detectTable(DB, String)}
+      *            ).
+      */
+     public MongoDbDataContext(DB mongoDb, SimpleTableDef... tableDefs) {
+         _mongoDb = mongoDb;
+         _tableDefs = tableDefs;
+         _schema = null;
+     }
+ 
+     /**
+      * Constructs a {@link MongoDbDataContext} and automatically detects the
+      * schema structure/view on all collections (see {@link #detectSchema(DB)}).
+      *
+      * @param mongoDb
+      *            the mongo db connection
+      */
+     public MongoDbDataContext(DB mongoDb) {
+         this(mongoDb, detectSchema(mongoDb));
+     }
+ 
+     /**
+      * Performs an analysis of the available collections in a Mongo {@link DB}
+      * instance and tries to detect the table's structure based on the first
+      * 1000 documents in each collection.
+      *
+      * @param db
+      *            the mongo db to inspect
+      * @return a mutable schema instance, useful for further fine tuning by the
+      *         user.
+      * @see #detectTable(DB, String)
+      */
+     public static SimpleTableDef[] detectSchema(DB db) {
+         Set<String> collectionNames = db.getCollectionNames();
+         SimpleTableDef[] result = new SimpleTableDef[collectionNames.size()];
+         int i = 0;
+         for (String collectionName : collectionNames) {
+             SimpleTableDef table = detectTable(db, collectionName);
+             result[i] = table;
+             i++;
+         }
+         return result;
+     }
+ 
+     /**
+      * Performs an analysis of an available collection in a Mongo {@link DB}
+      * instance and tries to detect the table structure based on the first 1000
+      * documents in the collection.
+      *
+      * @param db
+      *            the mongo DB
+      * @param collectionName
+      *            the name of the collection
+      * @return a table definition for mongo db.
+      */
+     public static SimpleTableDef detectTable(DB db, String collectionName) {
+         final DBCollection collection = db.getCollection(collectionName);
+         final DBCursor cursor = collection.find().limit(1000);
+ 
+         final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
+         while (cursor.hasNext()) {
+             DBObject object = cursor.next();
+             Set<String> keysInObject = object.keySet();
+             for (String key : keysInObject) {
+                 Set<Class<?>> types = columnsAndTypes.get(key);
+                 if (types == null) {
+                     types = new HashSet<Class<?>>();
+                     columnsAndTypes.put(key, types);
+                 }
+                 Object value = object.get(key);
+                 if (value != null) {
+                     types.add(value.getClass());
+                 }
+             }
+         }
+         cursor.close();
+ 
+         final String[] columnNames = new String[columnsAndTypes.size()];
+         final ColumnType[] columnTypes = new ColumnType[columnsAndTypes.size()];
+ 
+         int i = 0;
+         for (Entry<String, Set<Class<?>>> columnAndTypes : columnsAndTypes.entrySet()) {
+             final String columnName = columnAndTypes.getKey();
+             final Set<Class<?>> columnTypeSet = columnAndTypes.getValue();
+             final Class<?> columnType;
+             if (columnTypeSet.size() == 1) {
+                 columnType = columnTypeSet.iterator().next();
+             } else {
+                 columnType = Object.class;
+             }
+             columnNames[i] = columnName;
+             if (columnType == ObjectId.class) {
+                 columnTypes[i] = ColumnType.ROWID;
+             } else {
+                 columnTypes[i] = ColumnTypeImpl.convertColumnType(columnType);
+             }
+             i++;
+         }
+ 
+         return new SimpleTableDef(collectionName, columnNames, columnTypes);
+     }
+ 
+     @Override
+     protected Schema getMainSchema() throws MetaModelException {
+         if (_schema == null) {
+             MutableSchema schema = new MutableSchema(getMainSchemaName());
+             for (SimpleTableDef tableDef : _tableDefs) {
+ 
+                 MutableTable table = tableDef.toTable().setSchema(schema);
+                 Column[] rowIdColumns = table.getColumnsOfType(ColumnType.ROWID);
+                 for (Column column : rowIdColumns) {
+                     if (column instanceof MutableColumn) {
+                         ((MutableColumn) column).setPrimaryKey(true);
+                     }
+                 }
+ 
+                 schema.addTable(table);
+             }
+ 
+             _schema = schema;
+         }
+         return _schema;
+     }
+ 
+     @Override
+     protected String getMainSchemaName() throws MetaModelException {
+         return _mongoDb.getName();
+     }
+ 
+     @Override
+     protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
+         final DBCollection collection = _mongoDb.getCollection(table.getName());
+ 
+         final DBObject query = createMongoDbQuery(table, whereItems);
+ 
+         logger.info("Executing MongoDB 'count' query: {}", query);
+         final long count = collection.count(query);
+ 
+         return count;
+     }
+ 
+     @Override
+     protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
+             Object keyValue) {
+         final DBCollection collection = _mongoDb.getCollection(table.getName());
+ 
+         List<FilterItem> whereItems = new ArrayList<FilterItem>();
+         SelectItem selectItem = new SelectItem(primaryKeyColumn);
+         FilterItem primaryKeyWhereItem = new FilterItem(selectItem, OperatorType.EQUALS_TO, keyValue);
+         whereItems.add(primaryKeyWhereItem);
+         final DBObject query = createMongoDbQuery(table, whereItems);
+         final DBObject resultDBObject = collection.findOne(query);
+ 
+         DataSetHeader header = new SimpleDataSetHeader(selectItems);
+ 
+         Row row = MongoDBUtils.toRow(resultDBObject, header);
+ 
+         return row;
+     }
+ 
+     @Override
+     public DataSet executeQuery(Query query) {
+         // Check for queries containing only simple selects and where clauses,
+         // or if it is a COUNT(*) query.
+ 
+         // if from clause only contains a main schema table
+         List<FromItem> fromItems = query.getFromClause().getItems();
+         if (fromItems.size() == 1 && fromItems.get(0).getTable() != null
+                 && fromItems.get(0).getTable().getSchema() == _schema) {
+             final Table table = fromItems.get(0).getTable();
+ 
+             // if GROUP BY, HAVING and ORDER BY clauses are not specified
+             if (query.getGroupByClause().isEmpty() && query.getHavingClause().isEmpty()
+                     && query.getOrderByClause().isEmpty()) {
+ 
+                 final List<FilterItem> whereItems = query.getWhereClause().getItems();
+ 
+                 // if all of the select items are "pure" column selection
+                 boolean allSelectItemsAreColumns = true;
+                 List<SelectItem> selectItems = query.getSelectClause().getItems();
+ 
+                 // if it is a
+                 // "SELECT [columns] FROM [table] WHERE [conditions]"
+                 // query.
+                 for (SelectItem selectItem : selectItems) {
+                     if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
+                         allSelectItemsAreColumns = false;
+                         break;
+                     }
+                 }
+ 
+                 if (allSelectItemsAreColumns) {
+                     logger.debug("Query can be expressed in full MongoDB, no post processing needed.");
+ 
+                     // prepare for a non-post-processed query
+                     Column[] columns = new Column[selectItems.size()];
+                     for (int i = 0; i < columns.length; i++) {
+                         columns[i] = selectItems.get(i).getColumn();
+                     }
+ 
+                     // checking if the query is a primary key lookup query
+                     if (whereItems.size() == 1) {
+                         final FilterItem whereItem = whereItems.get(0);
+                         final SelectItem selectItem = whereItem.getSelectItem();
+                         if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
+                             final Column column = selectItem.getColumn();
+                             if (column.isPrimaryKey() && OperatorType.EQUALS_TO.equals(whereItem.getOperator())) {
+                                 logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
+                                 final Object operand = whereItem.getOperand();
+                                 final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
+                                 if (row == null) {
+                                     logger.debug("DataContext did not return any primary key lookup query results. Proceeding "
+                                             + "with manual lookup.");
+                                 } else {
+                                     final DataSetHeader header = new SimpleDataSetHeader(selectItems);
+                                     return new InMemoryDataSet(header, row);
+                                 }
+                             }
+                         }
+                     }
+ 
+                     int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
+                     int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
+ 
+                     final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                             maxRows, false);
+                     return dataSet;
+                 }
+             }
+         }
+ 
+         logger.debug("Query will be simplified for MongoDB and post processed.");
+         return super.executeQuery(query);
+     }
+ 
+     private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
+             int firstRow, int maxRows, boolean queryPostProcessed) {
+         final DBCollection collection = _mongoDb.getCollection(table.getName());
+ 
+         final DBObject query = createMongoDbQuery(table, whereItems);
+ 
+         logger.info("Executing MongoDB 'find' query: {}", query);
+         DBCursor cursor = collection.find(query);
+ 
+         if (maxRows > 0) {
+             cursor = cursor.limit(maxRows);
+         }
+         if (firstRow > 1) {
+             final int skip = firstRow - 1;
+             cursor = cursor.skip(skip);
+         }
+ 
+         return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+     }
+ 
+     protected BasicDBObject createMongoDbQuery(Table table, List<FilterItem> whereItems) {
+         assert _schema == table.getSchema();
+ 
+         final BasicDBObject query = new BasicDBObject();
+         if (whereItems != null && !whereItems.isEmpty()) {
+             for (FilterItem item : whereItems) {
+                 convertToCursorObject(query, item);
+             }
+         }
+ 
+         return query;
+     }
+ 
+     private void convertToCursorObject(BasicDBObject query, FilterItem item) {
+         if (item.isCompoundFilter()) {
+ 
+             BasicDBList orList = new BasicDBList();
+ 
+             final FilterItem[] childItems = item.getChildItems();
+             for (FilterItem childItem : childItems) {
+                 BasicDBObject childObject = new BasicDBObject();
+                 convertToCursorObject(childObject, childItem);
+                 orList.add(childObject);
+             }
+ 
+             query.put("$or", orList);
+ 
+         } else {
+ 
+             final Column column = item.getSelectItem().getColumn();
+             final String columnName = column.getName();
+             final String operatorName = getOperatorName(item);
+ 
+             Object operand = item.getOperand();
+             if (ObjectId.isValid(String.valueOf(operand))) {
+                 operand = new ObjectId(String.valueOf(operand));
+             }
+ 
+             final BasicDBObject existingFilterObject = (BasicDBObject) query.get(columnName);
+             if (existingFilterObject == null) {
+                 if (operatorName == null) {
+                     if (OperatorType.LIKE.equals(item.getOperator())) {
+                         query.put(columnName, turnOperandIntoRegExp(operand));
+                     } else {
+                         query.put(columnName, operand);
+                     }
+                 } else {
+                     query.put(columnName, new BasicDBObject(operatorName, operand));
+                 }
+             } else {
+                 if (operatorName == null) {
+                     throw new IllegalStateException("Cannot retrieve records for a column with two EQUALS_TO operators");
+                 } else {
+                     existingFilterObject.append(operatorName, operand);
+                 }
+             }
+         }
+     }
+ 
+     private String getOperatorName(FilterItem item) {
+         final OperatorType operator = item.getOperator();
+ 
+         if (OperatorType.EQUALS_TO.equals(operator)) {
+             return null;
+         }
+         if (OperatorType.LIKE.equals(operator)) {
+             return null;
+         }
+         if (OperatorType.LESS_THAN.equals(operator)) {
+             return "$lt";
+         }
+         if (OperatorType.LESS_THAN_OR_EQUAL.equals(operator)) {
+             return "$lte";
+         }
+         if (OperatorType.GREATER_THAN.equals(operator)) {
+             return "$gt";
+         }
+         if (OperatorType.GREATER_THAN_OR_EQUAL.equals(operator)) {
+             return "$gte";
+         }
+         if (OperatorType.DIFFERENT_FROM.equals(operator)) {
+             return "$ne";
+         }
+         if (OperatorType.IN.equals(operator)) {
+             return "$in";
+         }
+ 
+         throw new IllegalStateException("Unsupported operator type: " + operator);
+     }
+ 
+     private Pattern turnOperandIntoRegExp(Object operand) {
+         StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operand.toString()));
+         operandAsRegExp.insert(0, "^").append("$");
+         return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE);
+     }
+ 
+     private String replaceWildCardLikeChars(String operand) {
+         return operand.replaceAll("%", ".*");
+     }
+ 
+     @Override
+     protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
+         return materializeMainSchemaTableInternal(table, columns, null, 1, maxRows, true);
+     }
+ 
+     @Override
+     protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows) {
+         return materializeMainSchemaTableInternal(table, columns, null, firstRow, maxRows, true);
+     }
+ 
+     /**
+      * Executes an update with a specific {@link WriteConcernAdvisor}.
+      */
 -    public void executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
++    public UpdateSummary executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
+         MongoDbUpdateCallback callback = new MongoDbUpdateCallback(this, writeConcernAdvisor);
+         try {
+             update.run(callback);
+         } finally {
+             callback.close();
+         }
++        return callback.getUpdateSummary();
+     }
+ 
+     /**
+      * Executes an update with a specific {@link WriteConcern}.
+      */
 -    public void executeUpdate(UpdateScript update, WriteConcern writeConcern) {
 -        executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
++    public UpdateSummary executeUpdate(UpdateScript update, WriteConcern writeConcern) {
++        return executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
+     }
+ 
+     @Override
 -    public void executeUpdate(UpdateScript update) {
 -        executeUpdate(update, getWriteConcernAdvisor());
++    public UpdateSummary executeUpdate(UpdateScript update) {
++        return executeUpdate(update, getWriteConcernAdvisor());
+     }
+ 
+     /**
+      * Gets the {@link WriteConcernAdvisor} to use on
+      * {@link #executeUpdate(UpdateScript)} calls.
+      */
+     public WriteConcernAdvisor getWriteConcernAdvisor() {
+         if (_writeConcernAdvisor == null) {
+             return new DefaultWriteConcernAdvisor();
+         }
+         return _writeConcernAdvisor;
+     }
+ 
+     /**
+      * Sets a global {@link WriteConcern} advisor to use on
+      * {@link #executeUpdate(UpdateScript)}.
+      */
+     public void setWriteConcernAdvisor(WriteConcernAdvisor writeConcernAdvisor) {
+         _writeConcernAdvisor = writeConcernAdvisor;
+     }
+ 
+     /**
+      * Gets the {@link DB} instance that this {@link DataContext} is backed by.
+      */
+     public DB getMongoDb() {
+         return _mongoDb;
+     }
+ 
+     protected void addTable(MutableTable table) {
+         if (_schema instanceof MutableSchema) {
+             MutableSchema mutableSchema = (MutableSchema) _schema;
+             mutableSchema.addTable(table);
+         } else {
+             throw new UnsupportedOperationException("Schema is not mutable");
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --cc mongodb/mongo3/pom.xml
index 0000000,ae53158..4ff4fd7
mode 000000,100644..100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@@ -1,0 -1,70 +1,70 @@@
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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
+ 
+ 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.
+ -->
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 	<parent>
+ 		<artifactId>MetaModel-mongodb</artifactId>
+ 		<groupId>org.apache.metamodel</groupId>
 -		<version>4.5.3-SNAPSHOT</version>
++		<version>5.0-SNAPSHOT</version>
+ 	</parent>
+ 	<modelVersion>4.0.0</modelVersion>
+ 	<artifactId>MetaModel-mongodb-mongo3</artifactId>
+ 	<name>MetaModel module for MongoDB 3.x</name>
+ 	<dependencies>
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-core</artifactId>
+ 			<version>${project.version}</version>
+ 		</dependency>
+ 		<dependency>
+             <groupId>org.apache.metamodel</groupId>
+             <artifactId>MetaModel-mongodb-common</artifactId>
+             <version>${project.version}</version>
+         </dependency>
+ 		<dependency>
+ 			<groupId>org.mongodb</groupId>
+ 			<artifactId>mongo-java-driver</artifactId>
+ 			<version>3.1.0</version>
+ 		</dependency>
+ 
+ 		<!-- Test dependencies -->
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-jdbc</artifactId>
+ 			<version>${project.version}</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.apache.derby</groupId>
+ 			<artifactId>derby</artifactId>
+ 			<version>10.8.1.2</version>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.slf4j</groupId>
+ 			<artifactId>slf4j-nop</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>junit</groupId>
+ 			<artifactId>junit</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 	</dependencies>
+ </project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------
diff --cc mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
index 0000000,fbc9047..cf89f39
mode 000000,100644..100644
--- a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
@@@ -1,0 -1,545 +1,547 @@@
+ /**
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you 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
+  *
+  * 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 org.apache.metamodel.mongodb.mongo3;
+ 
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.HashSet;
+ import java.util.List;
+ import java.util.Map.Entry;
+ import java.util.Set;
+ import java.util.SortedMap;
+ import java.util.TreeMap;
+ import java.util.regex.Pattern;
+ 
+ import org.apache.metamodel.DataContext;
+ import org.apache.metamodel.MetaModelException;
+ import org.apache.metamodel.QueryPostprocessDataContext;
+ import org.apache.metamodel.UpdateScript;
++import org.apache.metamodel.UpdateSummary;
+ import org.apache.metamodel.UpdateableDataContext;
+ import org.apache.metamodel.data.DataSet;
+ import org.apache.metamodel.data.DataSetHeader;
+ import org.apache.metamodel.data.InMemoryDataSet;
+ import org.apache.metamodel.data.Row;
+ import org.apache.metamodel.data.SimpleDataSetHeader;
+ import org.apache.metamodel.mongodb.common.MongoDBUtils;
+ import org.apache.metamodel.query.FilterItem;
+ import org.apache.metamodel.query.FromItem;
+ import org.apache.metamodel.query.OperatorType;
+ import org.apache.metamodel.query.Query;
+ import org.apache.metamodel.query.SelectItem;
+ import org.apache.metamodel.schema.Column;
+ import org.apache.metamodel.schema.ColumnType;
+ import org.apache.metamodel.schema.ColumnTypeImpl;
+ import org.apache.metamodel.schema.MutableColumn;
+ import org.apache.metamodel.schema.MutableSchema;
+ import org.apache.metamodel.schema.MutableTable;
+ import org.apache.metamodel.schema.Schema;
+ import org.apache.metamodel.schema.Table;
+ import org.apache.metamodel.util.SimpleTableDef;
+ import org.bson.Document;
+ import org.bson.types.ObjectId;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ 
+ import com.mongodb.DB;
+ import com.mongodb.WriteConcern;
+ import com.mongodb.client.FindIterable;
+ import com.mongodb.client.MongoCollection;
+ import com.mongodb.client.MongoCursor;
+ import com.mongodb.client.MongoDatabase;
+ import com.mongodb.client.MongoIterable;
+ 
+ /**
+  * DataContext implementation for MongoDB.
+  *
+  * Since MongoDB has no schema, a virtual schema will be used in this
+  * DataContext. This implementation supports either automatic discovery of a
+  * schema or manual specification of a schema, through the
+  * {@link SimpleTableDef} class.
+  */
+ public class MongoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext {
+ 
+     private static final Logger logger = LoggerFactory.getLogger(MongoDbDataSet.class);
+ 
+     private final MongoDatabase _mongoDb;
+     private final SimpleTableDef[] _tableDefs;
+     private WriteConcernAdvisor _writeConcernAdvisor;
+     private Schema _schema;
+ 
+     /**
+      * Constructs a {@link MongoDbDataContext}. This constructor accepts a
+      * custom array of {@link SimpleTableDef}s which allows the user to define
+      * his own view on the collections in the database.
+      *
+      * @param mongoDb
+      *            the mongo db connection
+      * @param tableDefs
+      *            an array of {@link SimpleTableDef}s, which define the table
+      *            and column model of the mongo db collections. (consider using
+      *            {@link #detectSchema(MongoDatabase)} or {@link #detectTable(MongoDatabase, String)}
+      *            ).
+      */
+     public MongoDbDataContext(MongoDatabase mongoDb, SimpleTableDef... tableDefs) {
+         _mongoDb = mongoDb;
+         _tableDefs = tableDefs;
+         _schema = null;
+     }
+ 
+     /**
+      * Constructs a {@link MongoDbDataContext} and automatically detects the
+      * schema structure/view on all collections (see {@link #detectSchema(MongoDatabase)}).
+      *
+      * @param mongoDb
+      *            the mongo db connection
+      */
+     public MongoDbDataContext(MongoDatabase mongoDb) {
+         this(mongoDb, detectSchema(mongoDb));
+     }
+ 
+     /**
+      * Performs an analysis of the available collections in a Mongo {@link DB}
+      * instance and tries to detect the table's structure based on the first
+      * 1000 documents in each collection.
+      *
+      * @param mongoDb
+      *            the mongo db to inspect
+      * @return a mutable schema instance, useful for further fine tuning by the
+      *         user.
+      * @see #detectTable(MongoDatabase, String)
+      */
+     public static SimpleTableDef[] detectSchema(MongoDatabase mongoDb) {
+         MongoIterable<String> collectionNames = mongoDb.listCollectionNames();
+         List<SimpleTableDef> result = new ArrayList<>();
+ 
+         for (String collectionName : collectionNames) {
+             SimpleTableDef table = detectTable(mongoDb, collectionName);
+             result.add(table);
+         }
+         return result.toArray(new SimpleTableDef[0]);
+     }
+ 
+     /**
+      * Performs an analysis of an available collection in a Mongo {@link DB}
+      * instance and tries to detect the table structure based on the first 1000
+      * documents in the collection.
+      *
+      * @param mongoDb
+      *            the mongo DB
+      * @param collectionName
+      *            the name of the collection
+      * @return a table definition for mongo db.
+      */
+     public static SimpleTableDef detectTable(MongoDatabase mongoDb, String collectionName) {
+         
+         final MongoCollection<Document> collection = mongoDb.getCollection(collectionName);
+         final FindIterable<Document> iterable = collection.find().limit(1000);
+ 
+         final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
+         for (Document document : iterable) {
+             Set<String> keysInObject = document.keySet();
+             for (String key : keysInObject) {
+                 Set<Class<?>> types = columnsAndTypes.get(key);
+                 if (types == null) {
+                     types = new HashSet<Class<?>>();
+                     columnsAndTypes.put(key, types);
+                 }
+                 Object value = document.get(key);
+                 if (value != null) {
+                     types.add(value.getClass());
+                 }
+             }
+         }
+            
+         final String[] columnNames = new String[columnsAndTypes.size()];
+         final ColumnType[] columnTypes = new ColumnType[columnsAndTypes.size()];
+ 
+         int i = 0;
+         for (Entry<String, Set<Class<?>>> columnAndTypes : columnsAndTypes.entrySet()) {
+             final String columnName = columnAndTypes.getKey();
+             final Set<Class<?>> columnTypeSet = columnAndTypes.getValue();
+             final Class<?> columnType;
+             if (columnTypeSet.size() == 1) {
+                 columnType = columnTypeSet.iterator().next();
+             } else {
+                 columnType = Object.class;
+             }
+             columnNames[i] = columnName;
+             if (columnType == ObjectId.class) {
+                 columnTypes[i] = ColumnType.ROWID;
+             } else {
+                 columnTypes[i] = ColumnTypeImpl.convertColumnType(columnType);
+             }
+             i++;
+         }
+ 
+         return new SimpleTableDef(collectionName, columnNames, columnTypes);
+     }
+ 
+     @Override
+     protected Schema getMainSchema() throws MetaModelException {
+         if (_schema == null) {
+             MutableSchema schema = new MutableSchema(getMainSchemaName());
+             for (SimpleTableDef tableDef : _tableDefs) {
+ 
+                 MutableTable table = tableDef.toTable().setSchema(schema);
+                 Column[] rowIdColumns = table.getColumnsOfType(ColumnType.ROWID);
+                 for (Column column : rowIdColumns) {
+                     if (column instanceof MutableColumn) {
+                         ((MutableColumn) column).setPrimaryKey(true);
+                     }
+                 }
+ 
+                 schema.addTable(table);
+             }
+ 
+             _schema = schema;
+         }
+         return _schema;
+     }
+ 
+     @Override
+     protected String getMainSchemaName() throws MetaModelException {
+         return _mongoDb.getName();
+     }
+ 
+     @Override
+     protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
+         final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
+ 
+         final Document query = createMongoDbQuery(table, whereItems);
+ 
+         logger.info("Executing MongoDB 'count' query: {}", query);
+         final long count = collection.count(query);
+ 
+         return count;
+     }
+ 
+     @Override
+     protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
+             Object keyValue) {
+         final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
+ 
+         List<FilterItem> whereItems = new ArrayList<FilterItem>();
+         SelectItem selectItem = new SelectItem(primaryKeyColumn);
+         FilterItem primaryKeyWhereItem = new FilterItem(selectItem, OperatorType.EQUALS_TO, keyValue);
+         whereItems.add(primaryKeyWhereItem);
+         final Document query = createMongoDbQuery(table, whereItems);
+         final Document resultDoc = collection.find(query).first();
+ 
+         DataSetHeader header = new SimpleDataSetHeader(selectItems);
+ 
+         Row row = MongoDBUtils.toRow(resultDoc, header);
+ 
+         return row;
+     }
+ 
+     @Override
+     public DataSet executeQuery(Query query) {
+         // Check for queries containing only simple selects and where clauses,
+         // or if it is a COUNT(*) query.
+ 
+         // if from clause only contains a main schema table
+         List<FromItem> fromItems = query.getFromClause().getItems();
+         if (fromItems.size() == 1 && fromItems.get(0).getTable() != null
+                 && fromItems.get(0).getTable().getSchema() == _schema) {
+             final Table table = fromItems.get(0).getTable();
+ 
+             // if GROUP BY, HAVING and ORDER BY clauses are not specified
+             if (query.getGroupByClause().isEmpty() && query.getHavingClause().isEmpty()
+                     && query.getOrderByClause().isEmpty()) {
+ 
+                 final List<FilterItem> whereItems = query.getWhereClause().getItems();
+ 
+                 // if all of the select items are "pure" column selection
+                 boolean allSelectItemsAreColumns = true;
+                 List<SelectItem> selectItems = query.getSelectClause().getItems();
+ 
+                 // if it is a
+                 // "SELECT [columns] FROM [table] WHERE [conditions]"
+                 // query.
+                 for (SelectItem selectItem : selectItems) {
+                     if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
+                         allSelectItemsAreColumns = false;
+                         break;
+                     }
+                 }
+ 
+                 if (allSelectItemsAreColumns) {
+                     logger.debug("Query can be expressed in full MongoDB, no post processing needed.");
+ 
+                     // prepare for a non-post-processed query
+                     Column[] columns = new Column[selectItems.size()];
+                     for (int i = 0; i < columns.length; i++) {
+                         columns[i] = selectItems.get(i).getColumn();
+                     }
+ 
+                     // checking if the query is a primary key lookup query
+                     if (whereItems.size() == 1) {
+                         final FilterItem whereItem = whereItems.get(0);
+                         final SelectItem selectItem = whereItem.getSelectItem();
+                         if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
+                             final Column column = selectItem.getColumn();
+                             if (column.isPrimaryKey() && OperatorType.EQUALS_TO.equals(whereItem.getOperator())) {
+                                 logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
+                                 final Object operand = whereItem.getOperand();
+                                 final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
+                                 if (row == null) {
+                                     logger.debug("DataContext did not return any primary key lookup query results. Proceeding "
+                                             + "with manual lookup.");
+                                 } else {
+                                     final DataSetHeader header = new SimpleDataSetHeader(selectItems);
+                                     return new InMemoryDataSet(header, row);
+                                 }
+                             }
+                         }
+                     }
+ 
+                     int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
+                     int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
+ 
+                     final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                             maxRows, false);
+                     return dataSet;
+                 }
+             }
+         }
+ 
+         logger.debug("Query will be simplified for MongoDB and post processed.");
+         return super.executeQuery(query);
+     }
+ 
+     private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
+             int firstRow, int maxRows, boolean queryPostProcessed) {
+         final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
+ 
+         final Document query = createMongoDbQuery(table, whereItems);
+ 
+         logger.info("Executing MongoDB 'find' query: {}", query);
+         FindIterable<Document> iterable = collection.find(query);
+ 
+         if (maxRows > 0) {
+             iterable = iterable.limit(maxRows);
+         }
+         if (firstRow > 1) {
+             final int skip = firstRow - 1;
+             iterable = iterable.skip(skip);
+         }
+ 
+         MongoCursor<Document> cursor = iterable.iterator();
+ 
+         return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+     }
+ 
+     protected Document createMongoDbQuery(Table table, List<FilterItem> whereItems) {
+         assert _schema == table.getSchema();
+ 
+         final Document query = new Document();
+         if (whereItems != null && !whereItems.isEmpty()) {
+             for (FilterItem item : whereItems) {
+                 convertToCursorObject(query, item);
+             }
+         }
+ 
+         return query;
+     }
+ 
+     private static Object convertArrayToList(Object arr) {
+         if (arr instanceof boolean[]) {
+             return Arrays.asList((boolean[])arr);
+         } else if (arr instanceof byte[]) {
+             return Arrays.asList((byte[])arr);
+         } else if (arr instanceof short[]) {
+             return Arrays.asList((short[])arr);
+         } else if (arr instanceof char[]) {
+             return Arrays.asList((char[])arr);
+         } else if (arr instanceof int[]) {
+             return Arrays.asList((int[])arr);
+         } else if (arr instanceof long[]) {
+             return Arrays.asList((long[])arr);
+         } else if (arr instanceof float[]) {
+             return Arrays.asList((float[])arr);
+         } else if (arr instanceof double[]) {
+             return Arrays.asList((double[])arr);
+         } else if (arr instanceof Object[]) {
+             return Arrays.asList((Object[])arr);
+         }
+         // It's not an array.
+         return null;
+     }
+     
+     private void convertToCursorObject(Document query, FilterItem item) {
+         if (item.isCompoundFilter()) {
+ 
+             List<Document> orList = new ArrayList<Document>();
+ 
+             final FilterItem[] childItems = item.getChildItems();
+             for (FilterItem childItem : childItems) {
+                 Document childDoc = new Document();
+                 convertToCursorObject(childDoc, childItem);
+                 orList.add(childDoc);
+             }
+ 
+             query.put("$or", orList);
+ 
+         } else {
+ 
+             final Column column = item.getSelectItem().getColumn();
+             final String columnName = column.getName();
+             final String operatorName = getOperatorName(item);
+ 
+             Object operand = item.getOperand();
+             if (ObjectId.isValid(String.valueOf(operand))) {
+                 operand = new ObjectId(String.valueOf(operand));
+             } else if (operand != null && operand.getClass().isArray()){
+                 operand = convertArrayToList(operand);
+             }
+ 
+             final Document existingFilterObject = (Document) query.get(columnName);
+             if (existingFilterObject == null) {
+                 if (operatorName == null) {
+                     if (OperatorType.LIKE.equals(item.getOperator())) {
+                         query.put(columnName, turnOperandIntoRegExp(operand));
+                     } else {
+                         query.put(columnName, operand);
+                     }
+                 } else {
+                     query.put(columnName, new Document(operatorName, operand));
+                 }
+             } else {
+                 if (operatorName == null) {
+                     throw new IllegalStateException("Cannot retrieve records for a column with two EQUALS_TO operators");
+                 } else {
+                     existingFilterObject.append(operatorName, operand);
+                 }
+             }
+         }
+     }
+ 
+     private String getOperatorName(FilterItem item) {
+         final OperatorType operator = item.getOperator();
+ 
+         if (OperatorType.EQUALS_TO.equals(operator)) {
+             return null;
+         }
+         if (OperatorType.LIKE.equals(operator)) {
+             return null;
+         }
+         if (OperatorType.LESS_THAN.equals(operator)) {
+             return "$lt";
+         }
+         if (OperatorType.LESS_THAN_OR_EQUAL.equals(operator)) {
+             return "$lte";
+         }
+         if (OperatorType.GREATER_THAN.equals(operator)) {
+             return "$gt";
+         }
+         if (OperatorType.GREATER_THAN_OR_EQUAL.equals(operator)) {
+             return "$gte";
+         }
+         if (OperatorType.DIFFERENT_FROM.equals(operator)) {
+             return "$ne";
+         }
+         if (OperatorType.IN.equals(operator)) {
+             return "$in";
+         }
+ 
+         throw new IllegalStateException("Unsupported operator type: " + operator);
+     }
+ 
+     private Pattern turnOperandIntoRegExp(Object operand) {
+         StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operand.toString()));
+         operandAsRegExp.insert(0, "^").append("$");
+         return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE);
+     }
+ 
+     private String replaceWildCardLikeChars(String operand) {
+         return operand.replaceAll("%", ".*");
+     }
+ 
+     @Override
+     protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
+         return materializeMainSchemaTableInternal(table, columns, null, 1, maxRows, true);
+     }
+ 
+     @Override
+     protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows) {
+         return materializeMainSchemaTableInternal(table, columns, null, firstRow, maxRows, true);
+     }
+ 
+     /**
+      * Executes an update with a specific {@link WriteConcernAdvisor}.
+      */
 -    public void executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
++    public UpdateSummary executeUpdate(UpdateScript update, WriteConcernAdvisor writeConcernAdvisor) {
+         MongoDbUpdateCallback callback = new MongoDbUpdateCallback(this, writeConcernAdvisor);
+         try {
+             update.run(callback);
+         } finally {
+             callback.close();
+         }
++        return callback.getUpdateSummary();
+     }
+ 
+     /**
+      * Executes an update with a specific {@link WriteConcern}.
+      */
 -    public void executeUpdate(UpdateScript update, WriteConcern writeConcern) {
 -        executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
++    public UpdateSummary executeUpdate(UpdateScript update, WriteConcern writeConcern) {
++        return executeUpdate(update, new SimpleWriteConcernAdvisor(writeConcern));
+     }
+ 
+     @Override
 -    public void executeUpdate(UpdateScript update) {
 -        executeUpdate(update, getWriteConcernAdvisor());
++    public UpdateSummary executeUpdate(UpdateScript update) {
++        return executeUpdate(update, getWriteConcernAdvisor());
+     }
+ 
+     /**
+      * Gets the {@link WriteConcernAdvisor} to use on
+      * {@link #executeUpdate(UpdateScript)} calls.
+      */
+     public WriteConcernAdvisor getWriteConcernAdvisor() {
+         if (_writeConcernAdvisor == null) {
+             return new DefaultWriteConcernAdvisor();
+         }
+         return _writeConcernAdvisor;
+     }
+ 
+     /**
+      * Sets a global {@link WriteConcern} advisor to use on
+      * {@link #executeUpdate(UpdateScript)}.
+      */
+     public void setWriteConcernAdvisor(WriteConcernAdvisor writeConcernAdvisor) {
+         _writeConcernAdvisor = writeConcernAdvisor;
+     }
+ 
+     /**
+      * Gets the {@link DB} instance that this {@link DataContext} is backed by.
+      * @return 
+      */
+     public MongoDatabase getMongoDb() {
+         return _mongoDb;
+     }
+ 
+     protected void addTable(MutableTable table) {
+         if (_schema instanceof MutableSchema) {
+             MutableSchema mutableSchema = (MutableSchema) _schema;
+             mutableSchema.addTable(table);
+         } else {
+             throw new UnsupportedOperationException("Schema is not mutable");
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/mongodb/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/6d50f0e3/pom.xml
----------------------------------------------------------------------


[12/42] metamodel git commit: [maven-release-plugin] prepare release MetaModel-4.5.1

Posted by ka...@apache.org.
[maven-release-plugin] prepare release MetaModel-4.5.1


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/d6c80526
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/d6c80526
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/d6c80526

Branch: refs/heads/5.x
Commit: d6c80526597e38308c92cb7de19d23b7c1b3af3e
Parents: c4f386b
Author: Kasper S�rensen <i....@gmail.com>
Authored: Tue Feb 9 13:45:23 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Tue Feb 9 13:45:23 2016 +0100

----------------------------------------------------------------------
 cassandra/pom.xml            | 2 +-
 core/pom.xml                 | 2 +-
 couchdb/pom.xml              | 2 +-
 csv/pom.xml                  | 2 +-
 elasticsearch/common/pom.xml | 2 +-
 elasticsearch/native/pom.xml | 2 +-
 elasticsearch/pom.xml        | 2 +-
 elasticsearch/rest/pom.xml   | 2 +-
 excel/pom.xml                | 2 +-
 fixedwidth/pom.xml           | 2 +-
 full/pom.xml                 | 2 +-
 hadoop/pom.xml               | 2 +-
 hbase/pom.xml                | 2 +-
 jdbc/pom.xml                 | 2 +-
 json/pom.xml                 | 2 +-
 mongodb/common/pom.xml       | 2 +-
 mongodb/mongo2/pom.xml       | 2 +-
 mongodb/mongo3/pom.xml       | 2 +-
 mongodb/pom.xml              | 2 +-
 neo4j/pom.xml                | 2 +-
 openoffice/pom.xml           | 2 +-
 pojo/pom.xml                 | 2 +-
 pom.xml                      | 4 ++--
 salesforce/pom.xml           | 2 +-
 spring/pom.xml               | 2 +-
 sugarcrm/pom.xml             | 2 +-
 xml/pom.xml                  | 2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 29af9e7..1f9a461 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-cassandra</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index e540b3c..c91c638 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-core</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index bfd8fc3..06dca33 100644
--- a/couchdb/pom.xml
+++ b/couchdb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-couchdb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index 191c55c..e50fd1e 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-csv</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index bc798e6..b95a5a8 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 1f5a372..6aeb6c1 100644
--- a/elasticsearch/native/pom.xml
+++ b/elasticsearch/native/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 2e2a037..efd0771 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-elasticsearch</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 3c292ac..a2b6420 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 4d81bc2..e50cf54 100644
--- a/excel/pom.xml
+++ b/excel/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-excel</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 05c33b6..56ebbc5 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-fixedwidth</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 3602e45..adf3a98 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-full</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index bd67d97..7ce7307 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hadoop</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 44c275d..a8ad0b1 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hbase</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 6b59cd4..6a1fefe 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-jdbc</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index b884bf4..09e228a 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-json</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 2ef9d14..a3bd7b5 100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-common</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index b5e374e..39370d4 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index bf2e340..c293890 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 4b81223..22665c1 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 5181ff6..4786787 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-neo4j</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index 2f04c84..59e2fd2 100644
--- a/openoffice/pom.xml
+++ b/openoffice/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-openoffice</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index d48940e..647d951 100644
--- a/pojo/pom.xml
+++ b/pojo/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-pojo</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a45cc4b..668b44a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
 		<url>https://git-wip-us.apache.org/repos/asf?p=metamodel.git</url>
 		<connection>scm:git:http://git-wip-us.apache.org/repos/asf/metamodel.git</connection>
 		<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/metamodel.git</developerConnection>
-		<tag>HEAD</tag>
+		<tag>MetaModel-4.5.1</tag>
 	</scm>
 	<groupId>org.apache.metamodel</groupId>
 	<artifactId>MetaModel</artifactId>
-	<version>4.5.1-SNAPSHOT</version>
+	<version>4.5.1</version>
 	<name>MetaModel</name>
 	<description>MetaModel is a library that encapsulates the differences and enhances 
 		the capabilities of different datastores. Rich querying abilities are

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index a05cd5f..9ace7ed 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-salesforce</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index b77e818..266d26c 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-spring</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 9b16684..083a1b2 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-sugarcrm</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/d6c80526/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 9baeb31..317a313 100644
--- a/xml/pom.xml
+++ b/xml/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.1-SNAPSHOT</version>
+		<version>4.5.1</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-xml</artifactId>


[22/42] metamodel git commit: METAMODEL-225: Fixed

Posted by ka...@apache.org.
METAMODEL-225: Fixed

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/c5a233a6
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/c5a233a6
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/c5a233a6

Branch: refs/heads/5.x
Commit: c5a233a65ce67d782d281e7c7e57dc425c184a19
Parents: 6a669d7
Author: kaspersorensen <i....@gmail.com>
Authored: Thu Apr 21 10:00:37 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Thu Apr 21 10:00:37 2016 -0700

----------------------------------------------------------------------
 .../rest/JestElasticSearchUtils.java            | 19 ++++--
 .../rest/JestElasticSearchUtilsTest.java        | 68 ++++++++++++++++++++
 2 files changed, 83 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/c5a233a6/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
index 7448aa6..11a79b7 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtils.java
@@ -18,8 +18,10 @@
  */
 package org.apache.metamodel.elasticsearch.rest;
 
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.metamodel.data.DataSetHeader;
 import org.apache.metamodel.data.DefaultRow;
 import org.apache.metamodel.data.Row;
@@ -29,7 +31,9 @@ import org.apache.metamodel.schema.Column;
 import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.NumberComparator;
 
-import java.util.Date;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 
 /**
  * Shared/common util functions for the ElasticSearch MetaModel module.
@@ -58,6 +62,14 @@ final class JestElasticSearchUtils {
         if (field == null || field.isJsonNull()) {
             return null;
         }
+
+        if (field.isJsonObject()) {
+            return new Gson().fromJson(field, Map.class);
+        }
+        if (field.isJsonArray()) {
+            return new Gson().fromJson(field, List.class);
+        }
+
         if (type.isNumber()) {
             // Pretty terrible workaround to avoid LazilyParsedNumber
             // (which is happily output, but not recognized by Jest/GSON).
@@ -75,5 +87,4 @@ final class JestElasticSearchUtils {
             return field.getAsString();
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/c5a233a6/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java b/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
index 9e2b42f..f114826 100644
--- a/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
+++ b/elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUtilsTest.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.metamodel.data.DataSetHeader;
 import org.apache.metamodel.data.Row;
@@ -35,7 +36,9 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.schema.MutableColumn;
 import org.junit.Test;
 
+import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
 
 public class JestElasticSearchUtilsTest {
 
@@ -99,6 +102,71 @@ public class JestElasticSearchUtilsTest {
     }
 
     @Test
+    public void testCreateRowWithJsonObject() throws Exception {
+        final Column col1 = new MutableColumn("col1", ColumnType.MAP);
+        final DataSetHeader header = new SimpleDataSetHeader(new Column[] { col1 });
+        final JsonObject source = new JsonObject();
+        final JsonObject value = new JsonObject();
+        value.addProperty("foo1", "bar");
+        value.addProperty("foo2", 42);
+        source.add("col1", value);
+        final String documentId = "row1";
+
+        final Row row = JestElasticSearchUtils.createRow(source, documentId, header);
+        assertEquals("Row[values=[{foo1=bar, foo2=42.0}]]", row.toString());
+
+        final Map<?, ?> rowValue = (Map<?, ?>) row.getValue(col1);
+        assertEquals("bar", rowValue.get("foo1"));
+    }
+
+    @Test
+    public void testCreateRowWithJsonArray() throws Exception {
+        final Column col1 = new MutableColumn("col1", ColumnType.LIST);
+        final DataSetHeader header = new SimpleDataSetHeader(new Column[] { col1 });
+        final JsonObject source = new JsonObject();
+        final JsonArray value = new JsonArray();
+        value.add(new JsonPrimitive("foo"));
+        value.add(new JsonPrimitive("bar"));
+        source.add("col1", value);
+        final String documentId = "row1";
+
+        final Row row = JestElasticSearchUtils.createRow(source, documentId, header);
+        assertEquals("Row[values=[[foo, bar]]]", row.toString());
+
+        final List<?> rowValue = (List<?>) row.getValue(col1);
+        assertEquals("foo", rowValue.get(0));
+    }
+
+    @Test
+    public void testCreateRowWithDeepNesting() throws Exception {
+        final Column col1 = new MutableColumn("col1", ColumnType.LIST);
+        final DataSetHeader header = new SimpleDataSetHeader(new Column[] { col1 });
+        final JsonObject source = new JsonObject();
+
+        final JsonObject obj2 = new JsonObject();
+        obj2.addProperty("foo", 43);
+
+        final JsonArray arr1 = new JsonArray();
+        arr1.add(new JsonPrimitive("foo"));
+        arr1.add(new JsonPrimitive("bar"));
+        arr1.add(obj2);
+
+        final JsonObject obj1 = new JsonObject();
+        obj1.addProperty("mybool", true);
+        obj1.add("arr1", arr1);
+        source.add("col1", obj1);
+        final String documentId = "row1";
+
+        final Row row = JestElasticSearchUtils.createRow(source, documentId, header);
+        assertEquals("Row[values=[{mybool=true, arr1=[foo, bar, {foo=43.0}]}]]", row.toString());
+
+        final Map<?, ?> rowObj1 = (Map<?, ?>) row.getValue(col1);
+        final List<?> rowList = (List<?>) rowObj1.get("arr1");
+        final Map<?, ?> rowObj2 = (Map<?, ?>) rowList.get(2);
+        assertEquals(43.0, rowObj2.get("foo"));
+    }
+
+    @Test
     public void testCreateRowWithParseableDates() throws Exception {
         SelectItem item1 = new SelectItem(new MutableColumn("value1", ColumnType.STRING));
         SelectItem item2 = new SelectItem(new MutableColumn("value2", ColumnType.DATE));


[19/42] metamodel git commit: [maven-release-plugin] prepare for next development iteration

Posted by ka...@apache.org.
[maven-release-plugin] prepare for next development iteration


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/05b5e410
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/05b5e410
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/05b5e410

Branch: refs/heads/5.x
Commit: 05b5e4103c05f4b4455498e6e199fb4ffb50597d
Parents: cc35a25
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sat Mar 19 18:49:02 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Mar 19 18:49:02 2016 +0100

----------------------------------------------------------------------
 cassandra/pom.xml            | 2 +-
 core/pom.xml                 | 2 +-
 couchdb/pom.xml              | 2 +-
 csv/pom.xml                  | 2 +-
 elasticsearch/common/pom.xml | 2 +-
 elasticsearch/native/pom.xml | 2 +-
 elasticsearch/pom.xml        | 2 +-
 elasticsearch/rest/pom.xml   | 2 +-
 excel/pom.xml                | 2 +-
 fixedwidth/pom.xml           | 2 +-
 full/pom.xml                 | 2 +-
 hadoop/pom.xml               | 2 +-
 hbase/pom.xml                | 2 +-
 jdbc/pom.xml                 | 2 +-
 json/pom.xml                 | 2 +-
 mongodb/common/pom.xml       | 2 +-
 mongodb/mongo2/pom.xml       | 2 +-
 mongodb/mongo3/pom.xml       | 2 +-
 mongodb/pom.xml              | 2 +-
 neo4j/pom.xml                | 2 +-
 openoffice/pom.xml           | 2 +-
 pojo/pom.xml                 | 2 +-
 pom.xml                      | 4 ++--
 salesforce/pom.xml           | 2 +-
 spring/pom.xml               | 2 +-
 sugarcrm/pom.xml             | 2 +-
 xml/pom.xml                  | 2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index eba4472..c622e75 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-cassandra</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 8b82801..a73276e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-core</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index 1207729..ed65212 100644
--- a/couchdb/pom.xml
+++ b/couchdb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-couchdb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index d6945d6..4aa9b4c 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-csv</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index a45f3d1..615ef42 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 7dcb56d..c917bb0 100644
--- a/elasticsearch/native/pom.xml
+++ b/elasticsearch/native/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 487f886..7e049be 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-elasticsearch</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 0f87691..16c0555 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index fdc899a..6e7f126 100644
--- a/excel/pom.xml
+++ b/excel/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-excel</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 5ce729c..e667a10 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-fixedwidth</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index c557c5a..83c1855 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-full</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 51661e5..8a88e6f 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hadoop</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 66f4d87..30cd01d 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hbase</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index fe6c423..7034e5c 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-jdbc</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 872e513..f3e30ac 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-json</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 0d0af05..850d2f7 100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-common</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 05ba1e2..4905102 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 0ceebf1..ae53158 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 55edce5..d8d6706 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index f50ec81..037c9b6 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-neo4j</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index b395fb2..8b5fbfd 100644
--- a/openoffice/pom.xml
+++ b/openoffice/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-openoffice</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 58e24d4..915ed09 100644
--- a/pojo/pom.xml
+++ b/pojo/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-pojo</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f70f7dd..064af81 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
 		<url>https://git-wip-us.apache.org/repos/asf?p=metamodel.git</url>
 		<connection>scm:git:http://git-wip-us.apache.org/repos/asf/metamodel.git</connection>
 		<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/metamodel.git</developerConnection>
-		<tag>MetaModel-4.5.2</tag>
+		<tag>HEAD</tag>
 	</scm>
 	<groupId>org.apache.metamodel</groupId>
 	<artifactId>MetaModel</artifactId>
-	<version>4.5.2</version>
+	<version>4.5.3-SNAPSHOT</version>
 	<name>MetaModel</name>
 	<description>MetaModel is a library that encapsulates the differences and enhances 
 		the capabilities of different datastores. Rich querying abilities are

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 4d22452..b9b4fd5 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-salesforce</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index 94d368b..0c01d2b 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-spring</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 340d97b..159eb88 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-sugarcrm</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/05b5e410/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index a3db178..1341185 100644
--- a/xml/pom.xml
+++ b/xml/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.2</version>
+		<version>4.5.3-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-xml</artifactId>


[35/42] metamodel git commit: METAMODEL-247: Fixed

Posted by ka...@apache.org.
METAMODEL-247: Fixed

Closes #97

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/47c6d56c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/47c6d56c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/47c6d56c

Branch: refs/heads/5.x
Commit: 47c6d56cc7dbc3e6772b94d3816b94252622cbef
Parents: 025d07f
Author: kaspersorensen <i....@gmail.com>
Authored: Thu Apr 28 16:39:41 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Thu Apr 28 16:39:41 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      | 335 ++++++++---------
 .../schema/naming/ColumnNamingStrategies.java   |  10 +
 .../naming/CustomColumnNamingStrategy.java      |  62 ++++
 fixedwidth/pom.xml                              |  98 ++---
 .../fixedwidth/FixedWidthColumnSpec.java        |  45 +++
 .../fixedwidth/FixedWidthConfiguration.java     | 358 ++++++++++---------
 .../FixedWidthConfigurationReader.java          | 180 ++++++++++
 .../FixedWidthConfigurationReaderTest.java      |  89 +++++
 .../src/test/resources/metadata_spec1/data.txt  |   5 +
 .../metadata_spec1/sas-formatfile-metadata.txt  |   4 +
 .../metadata_spec1/sas-input-metadata.txt       |  19 +
 11 files changed, 823 insertions(+), 382 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 4356071..dd03195 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,167 +1,168 @@
-### Apache MetaModel 4.5.3 (work in progress)
-
- * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
- * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
- * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
- * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
-
-### Apache MetaModel 4.5.2
-
- * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.
-
-### Apache MetaModel 4.5.1
-
- * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
- * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
- * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
- * [METAMODEL-228] - Fixed a bug causing Number.class to not be converted to ColumnType.NUMBER.
-
-### Apache MetaModel 4.5.0
-
- * [METAMODEL-212] - New module for ElasticSearch via REST client.
- * [METAMODEL-99] - New module for Neo4j connectivity with MetaModel.
- * [METAMODEL-207] - Ensured the serializability of the SingleLineCsvRow class.
- * [METAMODEL-211] - Fixed a bug related to lookup by primary key (_id) on MongoDB.
- * [METAMODEL-216] - Added new aggregate functions: FIRST, LAST and RANDOM.
- * [METAMODEL-195] - Added new function MAP_VALUE which allows extracting a nested value from within a key/value map field.
- * [METAMODEL-15] - Query parser support for table names with space. Delimitters can be double quote or square brackets. 
- * [METAMODEL-215] - Improved the capability of NumberComparator to support Integer, Long, Double, BigInteger and other built-in Number classes.
- * [METAMODEL-218] - Fixed conversion of STRING and NUMBER types to database-specific types in JDBC module.
- * [METAMODEL-205] - Added validation of Excel sheet name before attempting to create table (sheet).
- * [METAMODEL-219] - Made HdfsResource capable of incorporating Hadoop configuration files core-site.xml and hdfs-site.xml
- * [METAMODEL-220] - Made HdfsResource capable of working with other URI schemes than 'hdfs'.
-
-### Apache MetaModel 4.4.1
-
- * [METAMODEL-198] - Fixed support for JDBC TIMESTAMP precision to match the underlying database's precision.
- * [METAMODEL-200] - Added optional "APPROXIMATE" keyword to query syntax for aggregate functions.
- * [METAMODEL-144] - Automated binary packaging of the MetaModel project.
- * [METAMODEL-197] - ElasticSearch schema update/change after CREATE TABLE statements.
- * [METAMODEL-199] - Fixed a bug in query parser when parsing two consecutive WHERE items with parentheses around them.
- * [METAMODEL-203] - Upgraded MongoDB dependency version and API to the 3.x line.
-
-### Apache MetaModel 4.4.0
-
- * [METAMODEL-192] - Added support for Scalar functions. We have a basic set of datatype conversion functions as well as support for UDF via implementing the ScalarFunction interface.
- * [METAMODEL-194] - Added support for setting the "Max rows" flag of a query to 0. This will always return an empty dataset.
- * [METAMODEL-173] - Improved CSV writing to non-file destinations. Added .write() and .append() methods to Resource interface.
- * [METAMODEL-170] - Dropped support for Java 6.
- * [METAMODEL-176] - Trimmed the transient dependencies of the JDBC module.
- * [METAMODEL-178] - Added AggregateFunction and ScalarFunction interfaces. Changed FunctionType enum to be super-interface of those. Compatibility is retained but a recompile of code using FunctionType is needed.
- * [METAMODEL-188] - Changed OperatorType enum to be an interface. Compatibility is retained but a recompile of code is needed.
- * [METAMODEL-179] - Ensured that HdfsResource is not closing a shared HDFS file system reference.
- * [METAMODEL-171] - Made integration tests for Cassandra module function properly in all environments.
- * [METAMODEL-177] - Fixed a bug pertaining to the serializability of HdfsResource.
- * [METAMODEL-172] - ElasticSearch Date types should be converted properly.
- * [METAMODEL-184] - ElasticSearch querying with "IS NULL" and "IS NOT NULL" now uses MissingFilter and ExistsFilter.
- * [METAMODEL-190] - Improved decimal number support in Excel module.
- * [METAMODEL-187] - Improved memory consumption of Excel module by passing random-access-file handles to POI when possible.
- * [METAMODEL-191] - Resolved a number of dependency conflicts/overlaps when combining multiple MetaModel modules.
- * [METAMODEL-157] - Fixed an issue in DELETE FROM statements with WHERE clauses requiring client-side data type conversion on JDBC databases.
- * [METAMODEL-182] - Improved HdfsResource and FileResource directory-based implementations by adding also getSize() and getLastModified() directory-based implementations.
-
-### Apache MetaModel 4.3.6
-
- * [METAMODEL-161] - Upgraded HBase client API to version 1.1.1
- * [METAMODEL-160] - Added support for Apache Hive via the JDBC module of MetaModel.
- * [METAMODEL-162] - Made HdfsResource Serializable and added property getters
- * [METAMODEL-163] - Made FileResource and HdfsResource work with folders containing file chunks instead of only single files
- * [METAMODEL-104] - Added 'hadoop' and 'hbase' modules to dependencies of 'MetaModel-full'.
- * [METAMODEL-164] - Fixed a bug in data type parsing of ElasticSearch mapping document.
-
-### Apache MetaModel 4.3.5
-
- * [METAMODEL-148] - Added a 'hadoop' module with a HdfsResource class to allow CSV, Excel and Fixed-width file access on HDFS.
- * [METAMODEL-152] - Fixed an issue of not clearing schema cache when refreshSchemas() is invoked.
- * [METAMODEL-149] - Added support for COUNTER data type in Cassandra.
- * [METAMODEL-151] - Added support for DOUBLE data type mapping in PostgreSQL
- * [METAMODEL-154] - Use embedded Cassandra server for integration tests.
-
-### Apache MetaModel 4.3.4
-
- * [METAMODEL-136] - Added LIKE operator native support (using conversion to regex) for MongoDB.
- * [METAMODEL-138] - Allow empty characters before AS keyword in query parsing.
- * [METAMODEL-141] - Improved mapping of ColumnType to SQL data types for Oracle, SQL Server, MySQL, DB2 and PostgreSQL
- * [METAMODEL-142] - Ensured that JDBC schema refreshes in an UpdateScript is using same Connection/Transaction as rest of operations
- * [METAMODEL-133] - Improved query parser support for multiple JOINs in same query.
- * [METAMODEL-140] - Fixed support for ElasticSearch mappings with additional property attributes.
-
-### Apache MetaModel 4.3.3
-
- * [METAMODEL-123] - Added compatibility with ElasticSearch version 1.4.x
- * [METAMODEL-93] - Added compatibility with Apache HBase version 1.0.0
- * [METAMODEL-124] - Invoked ElasticSearch cross-version incompatible methods via reflection
- * [METAMODEL-125] - Added support for comma-separated select items in Query.select(String) method argument.
- * [METAMODEL-128] - Fixed bug in DataSet ordering when aggregation functions are applied to non-JDBC modules.
- * [METAMODEL-131] - Added support for composite primary keys in JDBC CREATE TABLE statements.
-
-### Apache MetaModel 4.3.2
-
- * [METAMODEL-78] - Fixed a bug that caused SELECT DISTINCT to sometimes return duplicates records on certain DataContext implementations.
- * [METAMODEL-106] - Improved handling of invalid or non-existing index names passed to ElasticSearchDataContext
- * [METAMODEL-79] - Added update execution support on ElasticSearch module. Increased capability of pushing down WHERE items to ElasticSearch searches.
- * [METAMODEL-115] - Improved query parsing to allow lower-case function names, operators etc.
-
-### Apache MetaModel 4.3.1
-
- * [METAMODEL-100] - Fixed bug when having multiple columns of same name. Added column no. comparison when calling Column.equals(...).
-
-### Apache MetaModel 4.3.0-incubating
-
- * [METAMODEL-77] - New module 'elasticsearch' for connecting and modeling ElasticSearch indexes through MetaModel.
- * [METAMODEL-18] - New module 'cassandra' for connecting and modelling Apache Cassandra databases through MetaModel.
- * [METAMODEL-83] - Added new operator types: GREATER_THAN_OR_EQUAL ('>=') and LESS_THAN_OR_EQUAL ('<=').
- * [METAMODEL-92] - For JSON, MongoDB and CouchDB: Made it possible to specify column names referring nested fields such as "name.first" or "addresses[0].city".
- * [METAMODEL-76] - Query parser improved to handle filters without spaces inbetween operator and operands.
- * [METAMODEL-95] - Fixed a critical bug in the Salesforce.com module which caused all number values to be interpreted as '1'.
- * [METAMODEL-74] - Fixed a bug related to skipping blank values when applying an aggregate function (SUM, AVG etc.)
- * [METAMODEL-85] - Fixed a bug that caused NULL values to be evaluated with equal-sign in JDBC update and delete statements instead of 'IS NULL'.
- 
-### Apache MetaModel 4.2.0-incubating
-
- * [METAMODEL-38] - New module 'json' for handling json files (containing JSON arrays of documents or line-delimited JSON documents)
- * [METAMODEL-54] - ColumnType converted from enum to interface to allow for further specialization in modules.
- * [METAMODEL-57] - Changed the column type VARCHAR into STRING for the modules: CSV, Fixedwidth, Excel and XML.
- * [METAMODEL-56] - Made separate column types for converted JDBC LOBs - "CLOB as String" and "BLOB as bytes".
- * [METAMODEL-46] - Improved row-lookup by primary key (ID) in CouchDB
- * [METAMODEL-58] - Fixed a bug related to using CreateTable class and primary keys not getting created.
- * [METAMODEL-3]  - Improved writing of Byte-Order-Mark (BOM) for various encoding spelling variants.
- * [METAMODEL-70] - Made the build compatible with both JDK versions 6 and 7.
- * [METAMODEL-59] - Fixed a bug related to handling of date/time literals in MS SQL Server queries.
- * [METAMODEL-60] - Fixed a bug related to DISTINCT and TOP keywords in MS SQL Server queries.
- * [METAMODEL-45] - Improved and standardized way of handling integration test connection information towards external databases.
- * [METAMODEL-62] - Fixed a bug related to fault-tolerant handling of malformed CSV lines when reading CSVs in single-line mode
- * [METAMODEL-68] - Made it possible to create a CSV table without a header line in the file, if the user configures it.
- * [METAMODEL-67] - Upgraded Jackson (JSON library) dependency from org.codehaus namespace to the newer com.fasterxml namespace.
- * [METAMODEL-69] - Fixed issue with deserialization of ColumnType into the new interface instead of the old enum.
-
-### Apache MetaModel 4.1.0-incubating
-
- * [METAMODEL-13] - Added support for Apache HBase via the new module "MetaModel-hbase"
- * [METAMODEL-41] - Added a parser for SimpleTableDef objects (SimpleTableDefParser). It parses statements similar to CREATE TABLE statements, although without the "CREATE TABLE" prefix. For example: foo (bar INTEGER, baz VARCHAR)
- * [METAMODEL-11] - New module "MetaModel-spring" which adds a convenient FactoryBean to produce various types of DataContext objects based on externalizable parameters, for Spring framework users.
- * [METAMODEL-32] - Fixed thread-safety issue in Excel module when tables (sheets) metadata is updated.
- * [METAMODEL-47] - Fixed issue in Excel of loading schema if query is fired based on metadata from a previous DataContext instance.
- * [METAMODEL-35] - Improved query rewriting for DB2 when paged queries contain ORDER BY clause.
- * [METAMODEL-44] - Added an optional method for QueryPostprocessDataContext implementations to do a row-lookup by primary key value.
- * [METAMODEL-43] - Made CSV datastores skip empty lines in file instead of treating them of rows with null values.
- * [METAMODEL-39] - Added pooling of active/used Connections and PreparedStatements in JDBC compiled queries.
- * [METAMODEL-34] - Updated LICENSE file to not include bundled dependencies' licenses.
- * [METAMODEL-33] - Ensured that Apache Rat plugin for Maven is properly activated.
- * [METAMODEL-37] - Removed old site sources from project.
-
-### Apache MetaModel 4.0.0-incubating
-
- * [METAMODEL-9] - SalesforceDataSet is throwing exception for insert sql of record having date/time.
- * [METAMODEL-4] - Use folder name as schema name for file based DataContexts
- * [METAMODEL-5] - Faster CsvDataContext implementation for single-line values
- * [METAMODEL-26] - Provide endpoint URL with SalesforceDataContext
- * Upgraded Apache POI dependency to v. 3.9
- * Improved fluent Query builder API by adding string parameter based methods for joining tables
- * Added a utility ObjectInputStream for deserializing legacy MetaModel objects
- * Performance improvement to CSV reading when values are only single line based
- * Setting up the project on apache infrastructure
- * [METAMODEL-10] - Exclude Jackcess dependency (Access module) from MetaModel
- * Renaming the package hierarchy from org.eobjects.metamodel to org.apache.metamodel
- * [METAMODEL-29] - Fixed issue in CreateTable builder class, causing it to only support a single column definition
- * [METAMODEL-30] - Fixed issue with count(*) queries on CSV resources that does not provide a byte stream length 
+### Apache MetaModel 4.5.3 (work in progress)
+
+ * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
+ * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.
+ * [METAMODEL-244] - Added ColumnNamingStrategies concept which allows custom column naming and column name overriding.
+ * [METAMODEL-242] - Fixed issue when de-serializing old enum-instances of FunctionType.
+ * [METAMODEL-247] - Added FixedWidthConfigurationReader for reading fixed width file metadata from external files.
+
+### Apache MetaModel 4.5.2
+
+ * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.
+
+### Apache MetaModel 4.5.1
+
+ * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
+ * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
+ * [METAMODEL-231] - Fixed a bug causing the Neo4j to represent the same table multiple times within a schema.
+ * [METAMODEL-228] - Fixed a bug causing Number.class to not be converted to ColumnType.NUMBER.
+
+### Apache MetaModel 4.5.0
+
+ * [METAMODEL-212] - New module for ElasticSearch via REST client.
+ * [METAMODEL-99] - New module for Neo4j connectivity with MetaModel.
+ * [METAMODEL-207] - Ensured the serializability of the SingleLineCsvRow class.
+ * [METAMODEL-211] - Fixed a bug related to lookup by primary key (_id) on MongoDB.
+ * [METAMODEL-216] - Added new aggregate functions: FIRST, LAST and RANDOM.
+ * [METAMODEL-195] - Added new function MAP_VALUE which allows extracting a nested value from within a key/value map field.
+ * [METAMODEL-15] - Query parser support for table names with space. Delimitters can be double quote or square brackets. 
+ * [METAMODEL-215] - Improved the capability of NumberComparator to support Integer, Long, Double, BigInteger and other built-in Number classes.
+ * [METAMODEL-218] - Fixed conversion of STRING and NUMBER types to database-specific types in JDBC module.
+ * [METAMODEL-205] - Added validation of Excel sheet name before attempting to create table (sheet).
+ * [METAMODEL-219] - Made HdfsResource capable of incorporating Hadoop configuration files core-site.xml and hdfs-site.xml
+ * [METAMODEL-220] - Made HdfsResource capable of working with other URI schemes than 'hdfs'.
+
+### Apache MetaModel 4.4.1
+
+ * [METAMODEL-198] - Fixed support for JDBC TIMESTAMP precision to match the underlying database's precision.
+ * [METAMODEL-200] - Added optional "APPROXIMATE" keyword to query syntax for aggregate functions.
+ * [METAMODEL-144] - Automated binary packaging of the MetaModel project.
+ * [METAMODEL-197] - ElasticSearch schema update/change after CREATE TABLE statements.
+ * [METAMODEL-199] - Fixed a bug in query parser when parsing two consecutive WHERE items with parentheses around them.
+ * [METAMODEL-203] - Upgraded MongoDB dependency version and API to the 3.x line.
+
+### Apache MetaModel 4.4.0
+
+ * [METAMODEL-192] - Added support for Scalar functions. We have a basic set of datatype conversion functions as well as support for UDF via implementing the ScalarFunction interface.
+ * [METAMODEL-194] - Added support for setting the "Max rows" flag of a query to 0. This will always return an empty dataset.
+ * [METAMODEL-173] - Improved CSV writing to non-file destinations. Added .write() and .append() methods to Resource interface.
+ * [METAMODEL-170] - Dropped support for Java 6.
+ * [METAMODEL-176] - Trimmed the transient dependencies of the JDBC module.
+ * [METAMODEL-178] - Added AggregateFunction and ScalarFunction interfaces. Changed FunctionType enum to be super-interface of those. Compatibility is retained but a recompile of code using FunctionType is needed.
+ * [METAMODEL-188] - Changed OperatorType enum to be an interface. Compatibility is retained but a recompile of code is needed.
+ * [METAMODEL-179] - Ensured that HdfsResource is not closing a shared HDFS file system reference.
+ * [METAMODEL-171] - Made integration tests for Cassandra module function properly in all environments.
+ * [METAMODEL-177] - Fixed a bug pertaining to the serializability of HdfsResource.
+ * [METAMODEL-172] - ElasticSearch Date types should be converted properly.
+ * [METAMODEL-184] - ElasticSearch querying with "IS NULL" and "IS NOT NULL" now uses MissingFilter and ExistsFilter.
+ * [METAMODEL-190] - Improved decimal number support in Excel module.
+ * [METAMODEL-187] - Improved memory consumption of Excel module by passing random-access-file handles to POI when possible.
+ * [METAMODEL-191] - Resolved a number of dependency conflicts/overlaps when combining multiple MetaModel modules.
+ * [METAMODEL-157] - Fixed an issue in DELETE FROM statements with WHERE clauses requiring client-side data type conversion on JDBC databases.
+ * [METAMODEL-182] - Improved HdfsResource and FileResource directory-based implementations by adding also getSize() and getLastModified() directory-based implementations.
+
+### Apache MetaModel 4.3.6
+
+ * [METAMODEL-161] - Upgraded HBase client API to version 1.1.1
+ * [METAMODEL-160] - Added support for Apache Hive via the JDBC module of MetaModel.
+ * [METAMODEL-162] - Made HdfsResource Serializable and added property getters
+ * [METAMODEL-163] - Made FileResource and HdfsResource work with folders containing file chunks instead of only single files
+ * [METAMODEL-104] - Added 'hadoop' and 'hbase' modules to dependencies of 'MetaModel-full'.
+ * [METAMODEL-164] - Fixed a bug in data type parsing of ElasticSearch mapping document.
+
+### Apache MetaModel 4.3.5
+
+ * [METAMODEL-148] - Added a 'hadoop' module with a HdfsResource class to allow CSV, Excel and Fixed-width file access on HDFS.
+ * [METAMODEL-152] - Fixed an issue of not clearing schema cache when refreshSchemas() is invoked.
+ * [METAMODEL-149] - Added support for COUNTER data type in Cassandra.
+ * [METAMODEL-151] - Added support for DOUBLE data type mapping in PostgreSQL
+ * [METAMODEL-154] - Use embedded Cassandra server for integration tests.
+
+### Apache MetaModel 4.3.4
+
+ * [METAMODEL-136] - Added LIKE operator native support (using conversion to regex) for MongoDB.
+ * [METAMODEL-138] - Allow empty characters before AS keyword in query parsing.
+ * [METAMODEL-141] - Improved mapping of ColumnType to SQL data types for Oracle, SQL Server, MySQL, DB2 and PostgreSQL
+ * [METAMODEL-142] - Ensured that JDBC schema refreshes in an UpdateScript is using same Connection/Transaction as rest of operations
+ * [METAMODEL-133] - Improved query parser support for multiple JOINs in same query.
+ * [METAMODEL-140] - Fixed support for ElasticSearch mappings with additional property attributes.
+
+### Apache MetaModel 4.3.3
+
+ * [METAMODEL-123] - Added compatibility with ElasticSearch version 1.4.x
+ * [METAMODEL-93] - Added compatibility with Apache HBase version 1.0.0
+ * [METAMODEL-124] - Invoked ElasticSearch cross-version incompatible methods via reflection
+ * [METAMODEL-125] - Added support for comma-separated select items in Query.select(String) method argument.
+ * [METAMODEL-128] - Fixed bug in DataSet ordering when aggregation functions are applied to non-JDBC modules.
+ * [METAMODEL-131] - Added support for composite primary keys in JDBC CREATE TABLE statements.
+
+### Apache MetaModel 4.3.2
+
+ * [METAMODEL-78] - Fixed a bug that caused SELECT DISTINCT to sometimes return duplicates records on certain DataContext implementations.
+ * [METAMODEL-106] - Improved handling of invalid or non-existing index names passed to ElasticSearchDataContext
+ * [METAMODEL-79] - Added update execution support on ElasticSearch module. Increased capability of pushing down WHERE items to ElasticSearch searches.
+ * [METAMODEL-115] - Improved query parsing to allow lower-case function names, operators etc.
+
+### Apache MetaModel 4.3.1
+
+ * [METAMODEL-100] - Fixed bug when having multiple columns of same name. Added column no. comparison when calling Column.equals(...).
+
+### Apache MetaModel 4.3.0-incubating
+
+ * [METAMODEL-77] - New module 'elasticsearch' for connecting and modeling ElasticSearch indexes through MetaModel.
+ * [METAMODEL-18] - New module 'cassandra' for connecting and modelling Apache Cassandra databases through MetaModel.
+ * [METAMODEL-83] - Added new operator types: GREATER_THAN_OR_EQUAL ('>=') and LESS_THAN_OR_EQUAL ('<=').
+ * [METAMODEL-92] - For JSON, MongoDB and CouchDB: Made it possible to specify column names referring nested fields such as "name.first" or "addresses[0].city".
+ * [METAMODEL-76] - Query parser improved to handle filters without spaces inbetween operator and operands.
+ * [METAMODEL-95] - Fixed a critical bug in the Salesforce.com module which caused all number values to be interpreted as '1'.
+ * [METAMODEL-74] - Fixed a bug related to skipping blank values when applying an aggregate function (SUM, AVG etc.)
+ * [METAMODEL-85] - Fixed a bug that caused NULL values to be evaluated with equal-sign in JDBC update and delete statements instead of 'IS NULL'.
+ 
+### Apache MetaModel 4.2.0-incubating
+
+ * [METAMODEL-38] - New module 'json' for handling json files (containing JSON arrays of documents or line-delimited JSON documents)
+ * [METAMODEL-54] - ColumnType converted from enum to interface to allow for further specialization in modules.
+ * [METAMODEL-57] - Changed the column type VARCHAR into STRING for the modules: CSV, Fixedwidth, Excel and XML.
+ * [METAMODEL-56] - Made separate column types for converted JDBC LOBs - "CLOB as String" and "BLOB as bytes".
+ * [METAMODEL-46] - Improved row-lookup by primary key (ID) in CouchDB
+ * [METAMODEL-58] - Fixed a bug related to using CreateTable class and primary keys not getting created.
+ * [METAMODEL-3]  - Improved writing of Byte-Order-Mark (BOM) for various encoding spelling variants.
+ * [METAMODEL-70] - Made the build compatible with both JDK versions 6 and 7.
+ * [METAMODEL-59] - Fixed a bug related to handling of date/time literals in MS SQL Server queries.
+ * [METAMODEL-60] - Fixed a bug related to DISTINCT and TOP keywords in MS SQL Server queries.
+ * [METAMODEL-45] - Improved and standardized way of handling integration test connection information towards external databases.
+ * [METAMODEL-62] - Fixed a bug related to fault-tolerant handling of malformed CSV lines when reading CSVs in single-line mode
+ * [METAMODEL-68] - Made it possible to create a CSV table without a header line in the file, if the user configures it.
+ * [METAMODEL-67] - Upgraded Jackson (JSON library) dependency from org.codehaus namespace to the newer com.fasterxml namespace.
+ * [METAMODEL-69] - Fixed issue with deserialization of ColumnType into the new interface instead of the old enum.
+
+### Apache MetaModel 4.1.0-incubating
+
+ * [METAMODEL-13] - Added support for Apache HBase via the new module "MetaModel-hbase"
+ * [METAMODEL-41] - Added a parser for SimpleTableDef objects (SimpleTableDefParser). It parses statements similar to CREATE TABLE statements, although without the "CREATE TABLE" prefix. For example: foo (bar INTEGER, baz VARCHAR)
+ * [METAMODEL-11] - New module "MetaModel-spring" which adds a convenient FactoryBean to produce various types of DataContext objects based on externalizable parameters, for Spring framework users.
+ * [METAMODEL-32] - Fixed thread-safety issue in Excel module when tables (sheets) metadata is updated.
+ * [METAMODEL-47] - Fixed issue in Excel of loading schema if query is fired based on metadata from a previous DataContext instance.
+ * [METAMODEL-35] - Improved query rewriting for DB2 when paged queries contain ORDER BY clause.
+ * [METAMODEL-44] - Added an optional method for QueryPostprocessDataContext implementations to do a row-lookup by primary key value.
+ * [METAMODEL-43] - Made CSV datastores skip empty lines in file instead of treating them of rows with null values.
+ * [METAMODEL-39] - Added pooling of active/used Connections and PreparedStatements in JDBC compiled queries.
+ * [METAMODEL-34] - Updated LICENSE file to not include bundled dependencies' licenses.
+ * [METAMODEL-33] - Ensured that Apache Rat plugin for Maven is properly activated.
+ * [METAMODEL-37] - Removed old site sources from project.
+
+### Apache MetaModel 4.0.0-incubating
+
+ * [METAMODEL-9] - SalesforceDataSet is throwing exception for insert sql of record having date/time.
+ * [METAMODEL-4] - Use folder name as schema name for file based DataContexts
+ * [METAMODEL-5] - Faster CsvDataContext implementation for single-line values
+ * [METAMODEL-26] - Provide endpoint URL with SalesforceDataContext
+ * Upgraded Apache POI dependency to v. 3.9
+ * Improved fluent Query builder API by adding string parameter based methods for joining tables
+ * Added a utility ObjectInputStream for deserializing legacy MetaModel objects
+ * Performance improvement to CSV reading when values are only single line based
+ * Setting up the project on apache infrastructure
+ * [METAMODEL-10] - Exclude Jackcess dependency (Access module) from MetaModel
+ * Renaming the package hierarchy from org.eobjects.metamodel to org.apache.metamodel
+ * [METAMODEL-29] - Fixed issue in CreateTable builder class, causing it to only support a single column definition
+ * [METAMODEL-30] - Fixed issue with count(*) queries on CSV resources that does not provide a byte stream length 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
index de78338..0696376 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
@@ -18,6 +18,8 @@
  */
 package org.apache.metamodel.schema.naming;
 
+import java.util.List;
+
 /**
  * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
  */
@@ -32,4 +34,12 @@ public class ColumnNamingStrategies {
     public static ColumnNamingStrategy defaultStrategy() {
         return DEFAULT_STRATEGY;
     }
+
+    public static ColumnNamingStrategy customNames(List<String> columnNames) {
+        return new CustomColumnNamingStrategy(columnNames);
+    }
+
+    public static ColumnNamingStrategy customNames(String ... columnNames) {
+        return new CustomColumnNamingStrategy(columnNames);
+    }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
new file mode 100644
index 0000000..e6cc706
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.schema.naming;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A {@link ColumnNamingStrategy} that allows the user to supply his own list of
+ * custom column names.
+ */
+public class CustomColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    private final List<String> columnNames;
+
+    public CustomColumnNamingStrategy(List<String> columnNames) {
+        this.columnNames = columnNames;
+    }
+
+    public CustomColumnNamingStrategy(String... columnNames) {
+        this(Arrays.asList(columnNames));
+    }
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        final Iterator<String> iterator = columnNames.iterator();
+        return new ColumnNamingSession() {
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                if (iterator.hasNext()) {
+                    return iterator.next();
+                }
+                return null;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index e667a10..43e4021 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -1,46 +1,52 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you 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
-
-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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-	<parent>
-		<artifactId>MetaModel</artifactId>
-		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
-	</parent>
-	<modelVersion>4.0.0</modelVersion>
-	<artifactId>MetaModel-fixedwidth</artifactId>
-	<name>MetaModel module for fixed width value files</name>
-	<dependencies>
-		<dependency>
-			<groupId>org.apache.metamodel</groupId>
-			<artifactId>MetaModel-core</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-nop</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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
+
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<artifactId>MetaModel</artifactId>
+		<groupId>org.apache.metamodel</groupId>
+		<version>4.5.3-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>MetaModel-fixedwidth</artifactId>
+	<name>MetaModel module for fixed width value files</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-core</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.metamodel</groupId>
+			<artifactId>MetaModel-csv</artifactId>
+			<version>${project.version}</version>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-nop</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
new file mode 100644
index 0000000..65ec219
--- /dev/null
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.fixedwidth;
+
+import org.apache.metamodel.util.HasName;
+
+/**
+ * Represents the specification of a single column for a
+ * {@link FixedWidthDataContext}.
+ */
+public final class FixedWidthColumnSpec implements HasName {
+
+    private final String name;
+    private final int width;
+
+    public FixedWidthColumnSpec(String name, int width) {
+        this.name = name;
+        this.width = width;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index 6e9f0f1..2b2cae5 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -1,169 +1,189 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.fixedwidth;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
-import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-import org.apache.metamodel.util.BaseObject;
-import org.apache.metamodel.util.FileHelper;
-
-/**
- * Configuration of metadata about a fixed width values datacontext.
- */
-public final class FixedWidthConfiguration extends BaseObject implements
-		Serializable {
-
-	private static final long serialVersionUID = 1L;
-
-	public static final int NO_COLUMN_NAME_LINE = 0;
-	public static final int DEFAULT_COLUMN_NAME_LINE = 1;
-
-	private final String encoding;
-	private final int fixedValueWidth;
-	private final int[] valueWidths;
-	private final int columnNameLineNumber;
-	private final boolean failOnInconsistentLineWidth;
-	private final ColumnNamingStrategy columnNamingStrategy;
-
-	public FixedWidthConfiguration(int fixedValueWidth) {
-		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING,
-				fixedValueWidth);
-	}
-
-	public FixedWidthConfiguration(int[] valueWidth) {
-		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth,
-				false);
-	}
-
-    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
-        this(columnNameLineNumber, encoding, fixedValueWidth, false);
-    }
-
-    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
-            boolean failOnInconsistentLineWidth) {
-        this.encoding = encoding;
-        this.fixedValueWidth = fixedValueWidth;
-        this.columnNameLineNumber = columnNameLineNumber;
-        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
-        this.columnNamingStrategy = null;
-        this.valueWidths = new int[0];
-    }
-
-    public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
-            int[] valueWidths, boolean failOnInconsistentLineWidth) {
-        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
-    }
-    
-    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
-            int[] valueWidths, boolean failOnInconsistentLineWidth) {
-        this.encoding = encoding;
-        this.fixedValueWidth = -1;
-        this.columnNameLineNumber = columnNameLineNumber;
-        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
-        this.columnNamingStrategy = columnNamingStrategy;
-        this.valueWidths = valueWidths;
-    }
-
-	/**
-	 * The line number (1 based) from which to get the names of the columns.
-	 * 
-	 * @return an int representing the line number of the column headers/names.
-	 */
-	public int getColumnNameLineNumber() {
-		return columnNameLineNumber;
-	}
-	
-	/**
-	 * Gets a {@link ColumnNamingStrategy} to use if needed.
-	 * @return
-	 */
-	public ColumnNamingStrategy getColumnNamingStrategy() {
-	    if (columnNamingStrategy == null) {
-	        return ColumnNamingStrategies.defaultStrategy();
-	    }
-        return columnNamingStrategy;
-    }
-
-	/**
-	 * Gets the file encoding to use for reading the file.
-	 * 
-	 * @return the text encoding to use for reading the file.
-	 */
-	public String getEncoding() {
-		return encoding;
-	}
-
-	/**
-	 * Gets the width of each value within the fixed width value file.
-	 * 
-	 * @return the fixed width to use when parsing the file.
-	 */
-	public int getFixedValueWidth() {
-		return fixedValueWidth;
-	}
-
-	public int[] getValueWidths() {
-		return valueWidths;
-	}
-
-	/**
-	 * Determines if the {@link DataSet#next()} should throw an exception in
-	 * case of inconsistent line width in the fixed width value file.
-	 * 
-	 * @return a boolean indicating whether or not to fail on inconsistent line
-	 *         widths.
-	 */
-	public boolean isFailOnInconsistentLineWidth() {
-		return failOnInconsistentLineWidth;
-	}
-
-	@Override
-	protected void decorateIdentity(List<Object> identifiers) {
-		identifiers.add(columnNameLineNumber);
-		identifiers.add(encoding);
-		identifiers.add(fixedValueWidth);
-		identifiers.add(valueWidths);
-		identifiers.add(failOnInconsistentLineWidth);
-	}
-
-	@Override
-	public String toString() {
-		return "FixedWidthConfiguration[encoding=" + encoding
-				+ ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
-				+ Arrays.toString(valueWidths) + ", columnNameLineNumber="
-				+ columnNameLineNumber + ", failOnInconsistentLineWidth="
-				+ failOnInconsistentLineWidth + "]";
-	}
-
-	public boolean isConstantValueWidth() {
-		return fixedValueWidth != -1;
-	}
-
-	public int getValueWidth(int columnIndex) {
-		if (isConstantValueWidth()) {
-			return fixedValueWidth;
-		}
-		return valueWidths[columnIndex];
-	}
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.fixedwidth;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+import org.apache.metamodel.util.BaseObject;
+import org.apache.metamodel.util.CollectionUtils;
+import org.apache.metamodel.util.FileHelper;
+import org.apache.metamodel.util.HasNameMapper;
+
+/**
+ * Configuration of metadata about a fixed width values datacontext.
+ */
+public final class FixedWidthConfiguration extends BaseObject implements
+		Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final int NO_COLUMN_NAME_LINE = 0;
+	public static final int DEFAULT_COLUMN_NAME_LINE = 1;
+
+	private final String encoding;
+	private final int fixedValueWidth;
+	private final int[] valueWidths;
+	private final int columnNameLineNumber;
+	private final boolean failOnInconsistentLineWidth;
+	private final ColumnNamingStrategy columnNamingStrategy;
+
+	public FixedWidthConfiguration(int fixedValueWidth) {
+		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING,
+				fixedValueWidth);
+	}
+
+	public FixedWidthConfiguration(int[] valueWidth) {
+		this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth,
+				false);
+	}
+
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
+        this(columnNameLineNumber, encoding, fixedValueWidth, false);
+    }
+
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
+            boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = fixedValueWidth;
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+        this.columnNamingStrategy = null;
+        this.valueWidths = new int[0];
+    }
+
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
+            int[] valueWidths, boolean failOnInconsistentLineWidth) {
+        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
+    }
+    
+    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
+            int[] valueWidths, boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = -1;
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+        this.columnNamingStrategy = columnNamingStrategy;
+        this.valueWidths = valueWidths;
+    }
+    
+    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
+        this(encoding, columnSpecs, false);
+    }
+
+    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,
+            boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = -1;
+        this.columnNameLineNumber = NO_COLUMN_NAME_LINE;
+        this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,
+                new HasNameMapper()));
+        this.valueWidths = new int[columnSpecs.size()];
+        for (int i = 0; i < valueWidths.length; i++) {
+            valueWidths[i] = columnSpecs.get(i).getWidth();
+        }
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+    }
+
+    /**
+	 * The line number (1 based) from which to get the names of the columns.
+	 * 
+	 * @return an int representing the line number of the column headers/names.
+	 */
+	public int getColumnNameLineNumber() {
+		return columnNameLineNumber;
+	}
+	
+	/**
+	 * Gets a {@link ColumnNamingStrategy} to use if needed.
+	 * @return
+	 */
+	public ColumnNamingStrategy getColumnNamingStrategy() {
+	    if (columnNamingStrategy == null) {
+	        return ColumnNamingStrategies.defaultStrategy();
+	    }
+        return columnNamingStrategy;
+    }
+
+	/**
+	 * Gets the file encoding to use for reading the file.
+	 * 
+	 * @return the text encoding to use for reading the file.
+	 */
+	public String getEncoding() {
+		return encoding;
+	}
+
+	/**
+	 * Gets the width of each value within the fixed width value file.
+	 * 
+	 * @return the fixed width to use when parsing the file.
+	 */
+	public int getFixedValueWidth() {
+		return fixedValueWidth;
+	}
+
+	public int[] getValueWidths() {
+		return valueWidths;
+	}
+
+	/**
+	 * Determines if the {@link DataSet#next()} should throw an exception in
+	 * case of inconsistent line width in the fixed width value file.
+	 * 
+	 * @return a boolean indicating whether or not to fail on inconsistent line
+	 *         widths.
+	 */
+	public boolean isFailOnInconsistentLineWidth() {
+		return failOnInconsistentLineWidth;
+	}
+
+	@Override
+	protected void decorateIdentity(List<Object> identifiers) {
+		identifiers.add(columnNameLineNumber);
+		identifiers.add(encoding);
+		identifiers.add(fixedValueWidth);
+		identifiers.add(valueWidths);
+		identifiers.add(failOnInconsistentLineWidth);
+	}
+
+	@Override
+	public String toString() {
+		return "FixedWidthConfiguration[encoding=" + encoding
+				+ ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
+				+ Arrays.toString(valueWidths) + ", columnNameLineNumber="
+				+ columnNameLineNumber + ", failOnInconsistentLineWidth="
+				+ failOnInconsistentLineWidth + "]";
+	}
+
+	public boolean isConstantValueWidth() {
+		return fixedValueWidth != -1;
+	}
+
+	public int getValueWidth(int columnIndex) {
+		if (isConstantValueWidth()) {
+			return fixedValueWidth;
+		}
+		return valueWidths[columnIndex];
+	}
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
new file mode 100644
index 0000000..9154e5e
--- /dev/null
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
@@ -0,0 +1,180 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.fixedwidth;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.metamodel.csv.CsvConfiguration;
+import org.apache.metamodel.csv.CsvDataContext;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.Action;
+import org.apache.metamodel.util.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Object capable of reading fixed width metadata from external sources and
+ * thereby producing an appropriate {@link FixedWidthConfiguration} to use with
+ * a {@link FixedWidthDataContext}.
+ */
+public class FixedWidthConfigurationReader {
+
+    private static final Logger logger = LoggerFactory.getLogger(FixedWidthConfigurationReader.class);
+
+    // example: @1 COL1 $char1.
+    private final Pattern PATTERN_SAS_INPUT_LINE = Pattern.compile("\\@(\\d+) (.+) .*?(\\d+)\\.");
+
+    // example: COL1 "Record type"
+    private final Pattern PATTERN_SAS_LABEL_LINE = Pattern.compile("(.+) \\\"(.+)\\\"");
+
+    /**
+     * Reads a {@link FixedWidthConfiguration} based on a SAS 'format file',
+     * <a href=
+     * "http://support.sas.com/documentation/cdl/en/etlug/67323/HTML/default/viewer.htm#p0h03yig7fp1qan1arghp3lwjqi6.htm">
+     * described here</a>.
+     * 
+     * @param encoding
+     * @param resource
+     *            the format file resource
+     * @param failOnInconsistentLineWidth
+     * @return a {@link FixedWidthConfiguration} object to use
+     */
+    public FixedWidthConfiguration readFromSasFormatFile(String encoding, Resource resource,
+            boolean failOnInconsistentLineWidth) {
+        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
+
+        final CsvDataContext dataContext = new CsvDataContext(resource, new CsvConfiguration());
+        final Table table = dataContext.getDefaultSchema().getTable(0);
+        try (final DataSet dataSet = dataContext.query().from(table).select("Name", "BeginPosition", "EndPosition")
+                .execute()) {
+            while (dataSet.next()) {
+                final String name = (String) dataSet.getRow().getValue(0);
+                final int beginPosition = Integer.parseInt((String) dataSet.getRow().getValue(1));
+                final int endPosition = Integer.parseInt((String) dataSet.getRow().getValue(2));
+                final int width = 1 + endPosition - beginPosition;
+                columnSpecs.add(new FixedWidthColumnSpec(name, width));
+            }
+        }
+
+        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
+    }
+
+    /**
+     * Reads a {@link FixedWidthConfiguration} based on a SAS INPUT declaration.
+     * The reader method also optionally will look for a LABEL defintion for
+     * column naming.
+     * 
+     * @param encoding
+     * @param resource
+     *            the format file resource
+     * @param failOnInconsistentLineWidth
+     * @return a {@link FixedWidthConfiguration} object to use
+     */
+    public FixedWidthConfiguration readFromSasInputDefinition(String encoding, Resource resource,
+            boolean failOnInconsistentLineWidth) {
+
+        final Map<String, Integer> inputWidthDeclarations = new LinkedHashMap<>();
+        final Map<String, String> labelDeclarations = new HashMap<>();
+
+        resource.read(new Action<InputStream>() {
+
+            private boolean inInputSection = false;
+            private boolean inLabelSection = false;
+
+            @Override
+            public void run(InputStream in) throws Exception {
+                try (final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
+                    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+                        processLine(line);
+                    }
+                }
+            }
+
+            private void processLine(String line) {
+                line = line.trim();
+                if (line.isEmpty()) {
+                    return;
+                }
+                if (";".equals(line)) {
+                    inInputSection = false;
+                    inLabelSection = false;
+                    return;
+                } else if ("INPUT".equals(line)) {
+                    inInputSection = true;
+                    return;
+                } else if ("LABEL".equals(line)) {
+                    inLabelSection = true;
+                    return;
+                }
+
+                if (inInputSection) {
+                    final Matcher matcher = PATTERN_SAS_INPUT_LINE.matcher(line);
+                    if (matcher.matches()) {
+                        final String positionSpec = matcher.group(1);
+                        final String nameSpec = matcher.group(2);
+                        final int width = Integer.parseInt(matcher.group(3));
+                        logger.debug("Parsed INPUT line \"{}\": position={}, name={}, width={}", line, positionSpec,
+                                nameSpec, width);
+                        inputWidthDeclarations.put(nameSpec, width);
+                    } else {
+                        logger.debug("Failed to parse/recognize INPUT line \"{}\"", line);
+                    }
+                } else if (inLabelSection) {
+                    final Matcher matcher = PATTERN_SAS_LABEL_LINE.matcher(line);
+                    if (matcher.matches()) {
+                        final String nameSpec = matcher.group(1);
+                        final String labelSpec = matcher.group(2);
+                        logger.debug("Parsed LABEL line \"{}\": name={}, label={}", line, nameSpec, labelSpec);
+                        labelDeclarations.put(nameSpec, labelSpec);
+                    } else {
+                        logger.debug("Failed to parse/recognize LABEL line \"{}\"", line);
+                    }
+                }
+
+                if (line.endsWith(";")) {
+                    inInputSection = false;
+                    inLabelSection = false;
+                }
+            }
+        });
+
+        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
+        for (Entry<String, Integer> entry : inputWidthDeclarations.entrySet()) {
+            final String columnKey = entry.getKey();
+            final Integer columnWidth = entry.getValue();
+            final String columnLabel = labelDeclarations.get(columnKey);
+            final String columnName = columnLabel == null ? columnKey : columnLabel;
+            columnSpecs.add(new FixedWidthColumnSpec(columnName, columnWidth));
+        }
+
+        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
new file mode 100644
index 0000000..eb57233
--- /dev/null
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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 org.apache.metamodel.fixedwidth;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.FileResource;
+import org.apache.metamodel.util.Resource;
+import org.junit.Test;
+
+public class FixedWidthConfigurationReaderTest {
+
+    private final FileResource dataResource = new FileResource("src/test/resources/metadata_spec1/data.txt");
+
+    @Test
+    public void testReadConfigurationFromSasFormatFile() throws Exception {
+        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
+        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-formatfile-metadata.txt");
+        assertTrue(resource.isExists());
+
+        final FixedWidthConfiguration configuration = reader.readFromSasFormatFile("UTF8", resource, false);
+        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
+
+        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
+
+        performAssertionsOnSpec1(dataContext);
+    }
+    
+    @Test
+    public void testReadConfigurationFromSasInputMetadata() throws Exception {
+        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
+        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-input-metadata.txt");
+        assertTrue(resource.isExists());
+
+        final FixedWidthConfiguration configuration = reader.readFromSasInputDefinition("UTF8", resource, false);
+        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
+
+        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
+
+        performAssertionsOnSpec1(dataContext);
+    }
+
+    /**
+     * Shared assertions section once the 'metadata_spec1' {@link DataContext}
+     * has been loaded.
+     * 
+     * @param dataContext
+     */
+    private void performAssertionsOnSpec1(FixedWidthDataContext dataContext) {
+        final Table table = dataContext.getDefaultSchema().getTable(0);
+        final String[] columnNames = table.getColumnNames();
+        assertEquals("[Record type, Description, Initials]", Arrays.toString(columnNames));
+
+        try (final DataSet dataSet = dataContext.query().from(table).selectAll().execute()) {
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[P, Kasper Sorensen, KS]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[C, Human Inference, HI]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[P, Ankit Kumar, AK]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[C, Stratio, S]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[U, Unknown, ]]", dataSet.getRow().toString());
+            assertFalse(dataSet.next());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/test/resources/metadata_spec1/data.txt
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/resources/metadata_spec1/data.txt b/fixedwidth/src/test/resources/metadata_spec1/data.txt
new file mode 100644
index 0000000..785a539
--- /dev/null
+++ b/fixedwidth/src/test/resources/metadata_spec1/data.txt
@@ -0,0 +1,5 @@
+PKasper Sorensen     KS
+CHuman Inference     HI
+PAnkit Kumar         AK
+CStratio             S 
+UUnknown               

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt b/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
new file mode 100644
index 0000000..9bbe411
--- /dev/null
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
@@ -0,0 +1,4 @@
+Name,SASColumnType,BeginPosition,EndPosition,ReadFlag,Desc,SASFormat,SASInformat
+Record type,C,1,1,y,Record Type,$char.,$char.
+Description,C,2,21,y,Description of record,$char.,$char.
+Initials,C,22,23,y,Initials of record,,

http://git-wip-us.apache.org/repos/asf/metamodel/blob/47c6d56c/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt b/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
new file mode 100644
index 0000000..f12e418
--- /dev/null
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
@@ -0,0 +1,19 @@
+INPUT
+
+   @1 COL1 $char1.
+
+   @2 COL2 $char20.
+
+   @22 COL3 $char2.
+   
+;
+
+LABEL
+
+   COL1 "Record type"
+
+   COL2 "Description"
+
+   COL3 "Initials"
+
+;


[14/42] metamodel git commit: METAMODEL-236: Fixed

Posted by ka...@apache.org.
METAMODEL-236: Fixed

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/aeddd80c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/aeddd80c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/aeddd80c

Branch: refs/heads/5.x
Commit: aeddd80c384d409469b804af7725c6524f933ed9
Parents: 426396a
Author: Kasper S�rensen <i....@gmail.com>
Authored: Mon Mar 7 09:10:47 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Mon Mar 7 09:10:47 2016 +0100

----------------------------------------------------------------------
 CHANGES.md                                                       | 4 ++++
 .../org/apache/metamodel/query/AverageAggregateFunction.java     | 2 ++
 .../java/org/apache/metamodel/query/CountAggregateFunction.java  | 2 ++
 .../org/apache/metamodel/query/DefaultAggregateFunction.java     | 2 ++
 .../java/org/apache/metamodel/query/DefaultScalarFunction.java   | 2 ++
 .../java/org/apache/metamodel/query/FirstAggregateFunction.java  | 2 ++
 core/src/main/java/org/apache/metamodel/query/FunctionType.java  | 4 +++-
 .../java/org/apache/metamodel/query/LastAggregateFunction.java   | 2 ++
 .../main/java/org/apache/metamodel/query/MapValueFunction.java   | 2 ++
 .../java/org/apache/metamodel/query/MaxAggregateFunction.java    | 2 ++
 .../java/org/apache/metamodel/query/MinAggregateFunction.java    | 2 ++
 core/src/main/java/org/apache/metamodel/query/OperatorType.java  | 4 +++-
 .../main/java/org/apache/metamodel/query/OperatorTypeImpl.java   | 2 ++
 .../java/org/apache/metamodel/query/RandomAggregateFunction.java | 2 ++
 .../java/org/apache/metamodel/query/SumAggregateFunction.java    | 2 ++
 .../main/java/org/apache/metamodel/query/ToBooleanFunction.java  | 2 ++
 .../src/main/java/org/apache/metamodel/query/ToDateFunction.java | 2 ++
 .../main/java/org/apache/metamodel/query/ToNumberFunction.java   | 2 ++
 .../main/java/org/apache/metamodel/query/ToStringFunction.java   | 2 ++
 19 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 368e0a2..9ed7dc4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,7 @@
+### Apache MetaModel 4.5.2
+
+ * [METAMODEL-236] - Made OperatorType and FunctionType Serializable to ensure that serialization of Query is possible.
+
 ### Apache MetaModel 4.5.1
 
  * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/AverageAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/AverageAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/AverageAggregateFunction.java
index d80de09..338b088 100644
--- a/core/src/main/java/org/apache/metamodel/query/AverageAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/AverageAggregateFunction.java
@@ -22,6 +22,8 @@ import org.apache.metamodel.util.AggregateBuilder;
 
 public class AverageAggregateFunction extends DefaultAggregateFunction<Double> {
 
+    private static final long serialVersionUID = 1L;
+
     @Override
     public String getFunctionName() {
         return "AVG";

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/CountAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/CountAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/CountAggregateFunction.java
index c88b47e..4e2985a 100644
--- a/core/src/main/java/org/apache/metamodel/query/CountAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/CountAggregateFunction.java
@@ -22,6 +22,8 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class CountAggregateFunction extends DefaultAggregateFunction<Long> {
+    
+    private static final long serialVersionUID = 1L;
 
     public String getFunctionName() {
         return "COUNT";

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/DefaultAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/DefaultAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/DefaultAggregateFunction.java
index d904bb0..ef8ea57 100644
--- a/core/src/main/java/org/apache/metamodel/query/DefaultAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/DefaultAggregateFunction.java
@@ -26,6 +26,8 @@ import org.apache.metamodel.util.AggregateBuilder;
  */
 public abstract class DefaultAggregateFunction<T> implements AggregateFunction {
 
+    private static final long serialVersionUID = 1L;
+
     @Override
     public ColumnType getExpectedColumnType(ColumnType type) {
         return type;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/DefaultScalarFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/DefaultScalarFunction.java b/core/src/main/java/org/apache/metamodel/query/DefaultScalarFunction.java
index e647b02..8926f60 100644
--- a/core/src/main/java/org/apache/metamodel/query/DefaultScalarFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/DefaultScalarFunction.java
@@ -19,6 +19,8 @@
 package org.apache.metamodel.query;
 
 public abstract class DefaultScalarFunction implements ScalarFunction {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public String toString() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/FirstAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/FirstAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/FirstAggregateFunction.java
index b83f2e1..925b7d5 100644
--- a/core/src/main/java/org/apache/metamodel/query/FirstAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/FirstAggregateFunction.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.query;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class FirstAggregateFunction extends DefaultAggregateFunction<Object> {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public AggregateBuilder<?> createAggregateBuilder() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/FunctionType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/FunctionType.java b/core/src/main/java/org/apache/metamodel/query/FunctionType.java
index 8d06dcc..ecedc97 100644
--- a/core/src/main/java/org/apache/metamodel/query/FunctionType.java
+++ b/core/src/main/java/org/apache/metamodel/query/FunctionType.java
@@ -18,6 +18,8 @@
  */
 package org.apache.metamodel.query;
 
+import java.io.Serializable;
+
 import org.apache.metamodel.schema.ColumnType;
 
 /**
@@ -25,7 +27,7 @@ import org.apache.metamodel.schema.ColumnType;
  *
  * @see SelectItem
  */
-public interface FunctionType {
+public interface FunctionType extends Serializable {
 
     public static final AggregateFunction COUNT = new CountAggregateFunction();
     public static final AggregateFunction AVG = new AverageAggregateFunction();

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/LastAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/LastAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/LastAggregateFunction.java
index 4fa532e..909a19d 100644
--- a/core/src/main/java/org/apache/metamodel/query/LastAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/LastAggregateFunction.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.query;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class LastAggregateFunction extends DefaultAggregateFunction<Object> {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public AggregateBuilder<?> createAggregateBuilder() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/MapValueFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/MapValueFunction.java b/core/src/main/java/org/apache/metamodel/query/MapValueFunction.java
index 5cb743a..099bcab 100644
--- a/core/src/main/java/org/apache/metamodel/query/MapValueFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/MapValueFunction.java
@@ -29,6 +29,8 @@ import org.apache.metamodel.util.CollectionUtils;
  * {@link ColumnType#MAP} or similar.
  */
 public final class MapValueFunction extends DefaultScalarFunction {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public Object evaluate(Row row, Object[] parameters, SelectItem operandItem) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/MaxAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/MaxAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/MaxAggregateFunction.java
index 32ecc2a..805e506 100644
--- a/core/src/main/java/org/apache/metamodel/query/MaxAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/MaxAggregateFunction.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.query;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class MaxAggregateFunction extends DefaultAggregateFunction<Object> {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public String getFunctionName() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/MinAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/MinAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/MinAggregateFunction.java
index 0181376..3962088 100644
--- a/core/src/main/java/org/apache/metamodel/query/MinAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/MinAggregateFunction.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.query;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class MinAggregateFunction extends DefaultAggregateFunction<Object> {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public String getFunctionName() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/OperatorType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/OperatorType.java b/core/src/main/java/org/apache/metamodel/query/OperatorType.java
index d20f492..65f54b3 100644
--- a/core/src/main/java/org/apache/metamodel/query/OperatorType.java
+++ b/core/src/main/java/org/apache/metamodel/query/OperatorType.java
@@ -18,12 +18,14 @@
  */
 package org.apache.metamodel.query;
 
+import java.io.Serializable;
+
 /**
  * Defines the types of operators that can be used in filters.
  *
  * @see FilterItem
  */
-public interface OperatorType {
+public interface OperatorType extends Serializable {
 
     public static final OperatorType EQUALS_TO = new OperatorTypeImpl("=", false);
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java b/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
index 9869c88..a48b337 100644
--- a/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
+++ b/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
@@ -24,6 +24,8 @@ import java.util.Objects;
  * Simple implementation of {@link OperatorType}
  */
 public class OperatorTypeImpl implements OperatorType {
+    
+    private static final long serialVersionUID = 1L;
 
     private final String _sql;
     private final boolean _spaceDelimited;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/RandomAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/RandomAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/RandomAggregateFunction.java
index 1a53816..764a2e6 100644
--- a/core/src/main/java/org/apache/metamodel/query/RandomAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/RandomAggregateFunction.java
@@ -21,6 +21,8 @@ package org.apache.metamodel.query;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class RandomAggregateFunction extends DefaultAggregateFunction<Object> {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public AggregateBuilder<?> createAggregateBuilder() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/SumAggregateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/SumAggregateFunction.java b/core/src/main/java/org/apache/metamodel/query/SumAggregateFunction.java
index 655f130..23e4c4c 100644
--- a/core/src/main/java/org/apache/metamodel/query/SumAggregateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/SumAggregateFunction.java
@@ -22,6 +22,8 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.AggregateBuilder;
 
 public class SumAggregateFunction extends DefaultAggregateFunction<Double> {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public String getFunctionName() {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/ToBooleanFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/ToBooleanFunction.java b/core/src/main/java/org/apache/metamodel/query/ToBooleanFunction.java
index c8684cf..3a7f8ee 100644
--- a/core/src/main/java/org/apache/metamodel/query/ToBooleanFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/ToBooleanFunction.java
@@ -23,6 +23,8 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.BooleanComparator;
 
 public class ToBooleanFunction extends DefaultScalarFunction {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public ColumnType getExpectedColumnType(ColumnType type) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/ToDateFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/ToDateFunction.java b/core/src/main/java/org/apache/metamodel/query/ToDateFunction.java
index e6f932b..a55d513 100644
--- a/core/src/main/java/org/apache/metamodel/query/ToDateFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/ToDateFunction.java
@@ -25,6 +25,8 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.TimeComparator;
 
 public class ToDateFunction extends DefaultScalarFunction {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public ColumnType getExpectedColumnType(ColumnType type) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/ToNumberFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/ToNumberFunction.java b/core/src/main/java/org/apache/metamodel/query/ToNumberFunction.java
index a97a84a..5a8bac7 100644
--- a/core/src/main/java/org/apache/metamodel/query/ToNumberFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/ToNumberFunction.java
@@ -23,6 +23,8 @@ import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.util.NumberComparator;
 
 public class ToNumberFunction extends DefaultScalarFunction {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public ColumnType getExpectedColumnType(ColumnType type) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/aeddd80c/core/src/main/java/org/apache/metamodel/query/ToStringFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/ToStringFunction.java b/core/src/main/java/org/apache/metamodel/query/ToStringFunction.java
index ce85f0e..97d3fa9 100644
--- a/core/src/main/java/org/apache/metamodel/query/ToStringFunction.java
+++ b/core/src/main/java/org/apache/metamodel/query/ToStringFunction.java
@@ -22,6 +22,8 @@ import org.apache.metamodel.data.Row;
 import org.apache.metamodel.schema.ColumnType;
 
 public class ToStringFunction extends DefaultScalarFunction {
+    
+    private static final long serialVersionUID = 1L;
 
     @Override
     public ColumnType getExpectedColumnType(ColumnType type) {


[08/42] metamodel git commit: METAMODEL-183: Updated CHANGES.md and removed deprecated new code

Posted by ka...@apache.org.
METAMODEL-183: Updated CHANGES.md and removed deprecated new code

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/63262e9a
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/63262e9a
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/63262e9a

Branch: refs/heads/5.x
Commit: 63262e9aac449a166482744dae703f829fc71fa5
Parents: 365fae3
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sat Jan 23 17:44:24 2016 +0100
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Jan 23 17:44:24 2016 +0100

----------------------------------------------------------------------
 CHANGES.md                                             |  1 +
 mongodb/mongo2/pom.xml                                 |  2 +-
 mongodb/mongo3/pom.xml                                 |  2 +-
 .../metamodel/mongodb/mongo3/MongoDbDataContext.java   | 13 +------------
 mongodb/pom.xml                                        |  2 +-
 5 files changed, 5 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/63262e9a/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 0a0d387..773a57d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,7 @@
 ### Apache MetaModel 4.5.1 (work-in-progress)
 
  * [METAMODEL-227] - Fix for respecting CSV escape character also when no quote character is set.
+ * [METAMODEL-183] - MongoDB module split into three: common, Mongo2 and Mongo3 to allow use of either old or new MongoDB API.
 
 ### Apache MetaModel 4.5.0
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/63262e9a/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 24b1bca..b5e374e 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -25,7 +25,7 @@ under the License.
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>
-	<name>MetaModel module for MongoDB databases under version 3</name>
+	<name>MetaModel module for MongoDB 2.x</name>
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.metamodel</groupId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/63262e9a/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 7bc97e4..bf2e340 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -25,7 +25,7 @@ under the License.
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>
-	<name>MetaModel module for MongoDB databases</name>
+	<name>MetaModel module for MongoDB 3.x</name>
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.metamodel</groupId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/63262e9a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
index e13285b..1595a28 100644
--- a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
@@ -39,7 +39,6 @@ import org.apache.metamodel.data.InMemoryDataSet;
 import org.apache.metamodel.data.Row;
 import org.apache.metamodel.data.SimpleDataSetHeader;
 import org.apache.metamodel.mongodb.common.MongoDBUtils;
-import org.apache.metamodel.mongodb.common.MongoDbTableDef;
 import org.apache.metamodel.query.FilterItem;
 import org.apache.metamodel.query.FromItem;
 import org.apache.metamodel.query.OperatorType;
@@ -59,6 +58,7 @@ import org.bson.types.ObjectId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.mongodb.DB;
 import com.mongodb.WriteConcern;
 import com.mongodb.client.FindIterable;
 import com.mongodb.client.MongoCollection;
@@ -84,17 +84,6 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
     private Schema _schema;
 
     /**
-     * Constructor available for backwards compatibility
-     *
-     * @deprecated use {@link #MongoDbDataContext(DB, SimpleTableDef...)}
-     *             instead
-     */
-    @Deprecated
-    public MongoDbDataContext(MongoDatabase mongoDb, MongoDbTableDef... tableDefs) {
-        this(mongoDb, (SimpleTableDef[]) tableDefs);
-    }
-
-    /**
      * Constructs a {@link MongoDbDataContext}. This constructor accepts a
      * custom array of {@link MongoDbTableDef}s which allows the user to define
      * his own view on the collections in the database.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/63262e9a/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index c0a9448..4b81223 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -26,7 +26,7 @@ under the License.
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>
 	<packaging>pom</packaging>
-	<name>MetaModel module for MongoDB databases</name>
+	<name>MetaModel module for MongoDB</name>
 	
 	<modules>
 		<module>common</module>


[04/42] metamodel git commit: METAMODEL-183: Fixed

Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/main/java/org/apache/metamodel/mongodb/package-info.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/metamodel/mongodb/package-info.java b/mongodb/src/main/java/org/apache/metamodel/mongodb/package-info.java
deleted file mode 100644
index 99bf0fc..0000000
--- a/mongodb/src/main/java/org/apache/metamodel/mongodb/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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.
- */
-/**
- * Module package for MongoDB support
- */
-package org.apache.metamodel.mongodb;
-

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataContextTest.java b/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataContextTest.java
deleted file mode 100644
index c495754..0000000
--- a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataContextTest.java
+++ /dev/null
@@ -1,636 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.mongodb.WriteConcern;
-import org.apache.metamodel.DataContext;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.UpdateScript;
-import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.data.InMemoryDataSet;
-import org.apache.metamodel.query.FunctionType;
-import org.apache.metamodel.query.SelectItem;
-import org.apache.metamodel.schema.ColumnType;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-import org.apache.metamodel.util.SimpleTableDef;
-
-import com.mongodb.BasicDBList;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.Mongo;
-
-public class MongoDbDataContextTest extends MongoDbTestCase {
-
-    private DB db;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        if (isConfigured()) {
-            Mongo mongo = new Mongo(getHostname());
-            db = mongo.getDB(getDatabaseName());
-        }
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        if (isConfigured()) {
-            db.dropDatabase();
-        }
-    }
-
-    public void testNestedObjectFetching() throws Exception {
-        if (!isConfigured()) {
-            System.err.println(getInvalidConfigurationMessage());
-            return;
-        }
-
-        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
-
-        // delete if already exists
-        {
-            col.drop();
-            col = db.createCollection(getCollectionName(), new BasicDBObject());
-        }
-
-        final BasicDBList list = new BasicDBList();
-        list.add(new BasicDBObject().append("city", "Copenhagen").append("country", "Denmark"));
-        list.add(new BasicDBObject().append("city", "Stockholm").append("country", "Sweden"));
-
-        final BasicDBObject dbRow = new BasicDBObject();
-        dbRow.append("name", new BasicDBObject().append("first", "John").append("last", "Doe"));
-        dbRow.append("gender", "MALE");
-        dbRow.append("addresses", list);
-        col.insert(dbRow);
-
-        final MongoDbDataContext dc = new MongoDbDataContext(db, new SimpleTableDef(getCollectionName(), new String[] {
-                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
-                "addresses[5].foobar" }));
-
-        final DataSet ds = dc.query().from(getCollectionName()).selectAll().execute();
-        try {
-            assertTrue(ds.next());
-            final Object addresses = ds.getRow().getValue(3);
-            assertEquals("Row[values=[John, Doe, MALE, " + addresses + ", Copenhagen, Denmark, null]]", ds.getRow()
-                    .toString());
-            assertTrue(addresses instanceof List);
-            assertFalse(ds.next());
-        } finally {
-            ds.close();
-        }
-    }
-
-    public void testQueriesWithAutoGeneratedID() throws Exception {
-        if (!isConfigured()) {
-            System.err.println(getInvalidConfigurationMessage());
-            return;
-        }
-
-        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
-
-        // delete if already exists
-        {
-            col.drop();
-            col = db.createCollection(getCollectionName(), new BasicDBObject());
-        }
-
-        // create a couple of entries
-
-        BasicDBObject dbRow1 = new BasicDBObject();
-        dbRow1.put("name", "Mr. Black");
-        dbRow1.put("category", "gen_id");
-        dbRow1.put("age", 20);
-        col.insert(dbRow1, WriteConcern.ACKNOWLEDGED);
-        final String autoGenID1 = dbRow1.get("_id").toString();
-
-        BasicDBObject dbRow2 = new BasicDBObject();
-        dbRow2.put("name", "Mr. Pink");
-        dbRow2.put("category", "gen_id");
-        dbRow2.put("age", 40);
-        col.insert(dbRow2, WriteConcern.ACKNOWLEDGED);
-        String autoGenID2 = dbRow2.get("_id").toString();
-
-        BasicDBObject dbRow3 = new BasicDBObject();
-        dbRow3.put("_id", "123");
-        dbRow3.put("name", "Mr. White");
-        dbRow3.put("category", "gen_id");
-        dbRow3.put("age", 30);
-        col.insert(dbRow3, WriteConcern.ACKNOWLEDGED);
-        String fixedID3 = dbRow3.get("_id").toString();
-
-        final MongoDbDataContext dc = new MongoDbDataContext(db);
-        DataSet ds;
-
-        // check all 3 entries inserted
-        ds = dc.query().from(getCollectionName()).selectAll()
-                .where("category").eq("gen_id").execute();
-        assertEquals(3, ds.toRows().size());
-        ds.close();
-
-        // select by autogenerated id
-        ds = dc.query().from(getCollectionName()).select("name").where("_id").eq(autoGenID1).execute();
-        assertTrue(ds.next());
-        assertEquals("Mr. Black", ds.getRow().getValue(0));
-        ds.close();
-
-        // select by multiple autogenerated ids
-        ds = dc.query().from(getCollectionName()).select("name")
-                .where("_id").eq(autoGenID1)
-                .or("_id").eq(autoGenID2)
-                .execute();
-        assertEquals(2, ds.toRows().size());
-        ds.close();
-
-        // select by both autogenerated id and fixed id
-        ds = dc.query().from(getCollectionName()).select("name")
-                .where("_id").eq(autoGenID1)
-                .or("_id").eq(fixedID3)
-                .execute();
-        assertEquals(2, ds.toRows().size());
-        ds.close();
-
-        // delete by id
-        dc.executeUpdate(new UpdateScript() {
-            @Override
-            public void run(UpdateCallback callback) {
-                callback.deleteFrom(getCollectionName())
-                        .where("_id").eq(autoGenID1)
-                        .execute();
-            }
-        });
-
-        // select by autogenerated id which was deleted
-        ds = dc.query().from(getCollectionName()).select("name").where("_id").eq(autoGenID1).execute();
-        assertEquals(0, ds.toRows().size());
-        ds.close();
-
-    }
-
-    public void testFirstRowAndMaxRows() throws Exception {
-        if (!isConfigured()) {
-            System.err.println(getInvalidConfigurationMessage());
-            return;
-        }
-
-        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
-
-        // delete if already exists
-        {
-            col.drop();
-            col = db.createCollection(getCollectionName(), new BasicDBObject());
-        }
-
-        // create 3 records
-        for (int i = 0; i < 3; i++) {
-            BasicDBObject dbRow = new BasicDBObject();
-            dbRow.put("id", i + 1);
-            col.insert(dbRow);
-        }
-
-        final MongoDbDataContext dc = new MongoDbDataContext(db);
-
-        DataSet ds;
-
-        ds = dc.query().from(getCollectionName()).select("id").firstRow(2).execute();
-        assertTrue(ds instanceof MongoDbDataSet);
-        assertTrue(ds.next());
-        assertEquals("Row[values=[2]]", ds.getRow().toString());
-        assertTrue(ds.next());
-        assertEquals("Row[values=[3]]", ds.getRow().toString());
-        assertFalse(ds.next());
-        ds.close();
-
-        ds = dc.query().from(getCollectionName()).select("id").maxRows(1).execute();
-        assertTrue(ds instanceof MongoDbDataSet);
-        assertTrue(ds.next());
-        assertEquals("Row[values=[1]]", ds.getRow().toString());
-        assertFalse(ds.next());
-        ds.close();
-
-        ds = dc.query().from(getCollectionName()).select("id").maxRows(1).firstRow(2).execute();
-        assertTrue(ds instanceof MongoDbDataSet);
-        assertTrue(ds.next());
-        assertEquals("Row[values=[2]]", ds.getRow().toString());
-        assertFalse(ds.next());
-        ds.close();
-    }
-
-    public void testRead() throws Exception {
-        // Adding a comment to commit something and invoke a build in Travis...
-        if (!isConfigured()) {
-            System.err.println(getInvalidConfigurationMessage());
-            return;
-        }
-
-        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
-
-        // delete if already exists
-        {
-            col.drop();
-            col = db.createCollection(getCollectionName(), new BasicDBObject());
-        }
-
-        // create 1000 records
-        for (int i = 0; i < 1000; i++) {
-            BasicDBObject dbRow = new BasicDBObject();
-            dbRow.put("id", i);
-            dbRow.put("name", "record no. " + i);
-            if (i % 5 == 0) {
-                dbRow.put("foo", "bar");
-            } else {
-                dbRow.put("foo", "baz");
-            }
-            BasicDBObject nestedObj = new BasicDBObject();
-            nestedObj.put("count", i);
-            nestedObj.put("constant", "foobarbaz");
-            dbRow.put("baz", nestedObj);
-
-            dbRow.put("list", Arrays.<Object> asList("l1", "l2", "l3", i));
-
-            col.insert(dbRow);
-        }
-
-        // Instantiate the actual data context
-        final DataContext dataContext = new MongoDbDataContext(db);
-
-        assertEquals("[" + getCollectionName() + ", system.indexes]",
-                Arrays.toString(dataContext.getDefaultSchema().getTableNames()));
-        Table table = dataContext.getDefaultSchema().getTableByName(getCollectionName());
-        assertEquals("[_id, baz, foo, id, list, name]", Arrays.toString(table.getColumnNames()));
-
-        assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
-        assertEquals(ColumnType.VARCHAR, table.getColumnByName("foo").getType());
-        assertEquals(ColumnType.LIST, table.getColumnByName("list").getType());
-        assertEquals(ColumnType.INTEGER, table.getColumnByName("id").getType());
-        assertEquals(ColumnType.ROWID, table.getColumnByName("_id").getType());
-
-        DataSet ds = dataContext.query().from(getCollectionName()).select("name").and("foo").and("baz").and("list")
-                .where("id").greaterThan(800).or("foo").isEquals("bar").execute();
-        assertEquals(MongoDbDataSet.class, ds.getClass());
-        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
-        try {
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 0, bar, {count=0, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 0]]]",
-                    ds.getRow().toString());
-
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 5, bar, {count=5, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 5]]]",
-                    ds.getRow().toString());
-
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 10, bar, {count=10, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 10]]]",
-                    ds.getRow().toString());
-
-            for (int j = 15; j < 801; j++) {
-                if (j % 5 == 0) {
-                    assertTrue(ds.next());
-                    assertEquals("Row[values=[record no. " + j + ", bar, {count=" + j
-                            + ", constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , " + j + "]]]", ds.getRow()
-                            .toString());
-                }
-            }
-
-            assertTrue(ds.next());
-            assertTrue(ds.getRow().getValue(2) instanceof Map);
-            assertEquals(LinkedHashMap.class, ds.getRow().getValue(2).getClass());
-
-            assertTrue("unexpected type: " + ds.getRow().getValue(3).getClass(),
-                    ds.getRow().getValue(3) instanceof List);
-            assertEquals(BasicDBList.class, ds.getRow().getValue(3).getClass());
-
-            assertEquals(
-                    "Row[values=[record no. 801, baz, {count=801, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 801]]]",
-                    ds.getRow().toString());
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 802, baz, {count=802, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 802]]]",
-                    ds.getRow().toString());
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 803, baz, {count=803, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 803]]]",
-                    ds.getRow().toString());
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 804, baz, {count=804, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 804]]]",
-                    ds.getRow().toString());
-            assertTrue(ds.next());
-            assertEquals(
-                    "Row[values=[record no. 805, bar, {count=805, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 805]]]",
-                    ds.getRow().toString());
-
-            for (int i = 0; i < 194; i++) {
-                assertTrue(ds.next());
-            }
-            assertEquals(
-                    "Row[values=[record no. 999, baz, {count=999, constant=foobarbaz}, [ \"l1\" , \"l2\" , \"l3\" , 999]]]",
-                    ds.getRow().toString());
-            assertFalse(ds.next());
-        } finally {
-            ds.close();
-        }
-
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").in(2, 6, 8, 9)
-                .execute();
-        assertTrue(ds.next());
-        assertEquals("Row[values=[2, record no. 2]]", ds.getRow().toString());
-        assertTrue(ds.next());
-        assertEquals("Row[values=[6, record no. 6]]", ds.getRow().toString());
-        assertTrue(ds.next());
-        assertEquals("Row[values=[8, record no. 8]]", ds.getRow().toString());
-        assertTrue(ds.next());
-        assertEquals("Row[values=[9, record no. 9]]", ds.getRow().toString());
-        assertFalse(ds.next());
-        ds.close();
-
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("foo").isEquals("bar")
-                .execute();
-        assertEquals(MongoDbDataSet.class, ds.getClass());
-        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
-
-        try {
-            List<Object[]> objectArrays = ds.toObjectArrays();
-            assertEquals(200, objectArrays.size());
-            assertEquals("[0, record no. 0]", Arrays.toString(objectArrays.get(0)));
-        } finally {
-            ds.close();
-        }
-
-        // test GREATER_THAN_OR_EQUAL
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id")
-                .greaterThanOrEquals(500).and("foo").isEquals("bar").execute();
-        assertEquals(MongoDbDataSet.class, ds.getClass());
-        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
-
-        try {
-            List<Object[]> objectArrays = ds.toObjectArrays();
-            assertEquals(100, objectArrays.size());
-            assertEquals("[500, record no. 500]", Arrays.toString(objectArrays.get(0)));
-        } finally {
-            ds.close();
-        }
-
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id")
-                .greaterThanOrEquals(501).and("foo").isEquals("bar").execute();
-        assertEquals(MongoDbDataSet.class, ds.getClass());
-        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
-
-        try {
-            List<Object[]> objectArrays = ds.toObjectArrays();
-            assertEquals(99, objectArrays.size());
-            assertEquals("[505, record no. 505]", Arrays.toString(objectArrays.get(0)));
-        } finally {
-            ds.close();
-        }
-
-        // test LESS_THAN_OR_EQUAL
-
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").lessThanOrEquals(500)
-                .and("foo").isEquals("bar").execute();
-        assertEquals(MongoDbDataSet.class, ds.getClass());
-        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
-
-        try {
-            List<Object[]> objectArrays = ds.toObjectArrays();
-            assertEquals(101, objectArrays.size());
-            assertEquals("[500, record no. 500]", Arrays.toString(objectArrays.get(100)));
-        } finally {
-            ds.close();
-        }
-
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("id").lessThanOrEquals(499)
-                .and("foo").isEquals("bar").execute();
-        assertEquals(MongoDbDataSet.class, ds.getClass());
-        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());
-
-        try {
-            List<Object[]> objectArrays = ds.toObjectArrays();
-            assertEquals(100, objectArrays.size());
-            assertEquals("[495, record no. 495]", Arrays.toString(objectArrays.get(99)));
-        } finally {
-            ds.close();
-        }
-
-        // test a primary key lookup query
-        BasicDBObject dbRow = new BasicDBObject();
-        dbRow.put("_id", 123456);
-        dbRow.put("id", 123456);
-        dbRow.put("name", "record no. " + 123456);
-        dbRow.put("foo", "bar123456");
-        BasicDBObject nestedObj = new BasicDBObject();
-        nestedObj.put("count", 123456);
-        nestedObj.put("constant", "foobarbaz");
-        dbRow.put("baz", nestedObj);
-
-        dbRow.put("list", Arrays.<Object> asList("l1", "l2", "l3", 123456));
-
-        col.insert(dbRow);
-
-        ds = dataContext.query().from(getCollectionName()).select("id").and("name").where("_id").eq(123456).execute();
-        assertTrue(ds.next());
-        assertEquals("Row[values=[123456, record no. 123456]]", ds.getRow().toString());
-        assertFalse(ds.next());
-
-        // do a query that we cannot push to mongo
-        // Replace column index 0 by 1
-        ds = dataContext.query().from(getCollectionName())
-                .select(FunctionType.SUM, dataContext.getDefaultSchema().getTables()[0].getColumnByName("id"))
-                .where("foo").isEquals("bar").execute();
-        assertEquals(InMemoryDataSet.class, ds.getClass());
-
-        ds.close();
-    }
-
-    public void testCreateAndWriteData() throws Exception {
-        if (!isConfigured()) {
-            System.err.println(getInvalidConfigurationMessage());
-            return;
-        }
-        final MongoDbDataContext dc = new MongoDbDataContext(db);
-        final Schema defaultSchema = dc.getDefaultSchema();
-
-        dc.executeUpdate(new UpdateScript() {
-            @Override
-            public void run(UpdateCallback callback) {
-                Table[] tables = defaultSchema.getTables();
-                for (Table table : tables) {
-                    callback.deleteFrom(table).execute();
-                }
-            }
-        });
-
-        assertEquals(0, defaultSchema.getTableCount());
-
-        dc.executeUpdate(new UpdateScript() {
-
-            @Override
-            public void run(UpdateCallback callback) {
-                Table table = callback.createTable(defaultSchema, "some_entries").withColumn("foo").withColumn("bar")
-                        .withColumn("baz").withColumn("list").execute();
-
-                callback.insertInto(table).value("foo", 1).value("bar", "hello").execute();
-                callback.insertInto(table).value("foo", 2).value("bar", "world").execute();
-                callback.insertInto(table).value("foo", 3).value("bar", "hi").execute();
-
-                Map<String, Object> nestedObj = new HashMap<String, Object>();
-                nestedObj.put("foo", "bar");
-                nestedObj.put("123", 456);
-
-                callback.insertInto(table).value("foo", 4).value("bar", "there").value("baz", nestedObj)
-                        .value("list", Arrays.asList(1, 2, 3)).execute();
-            }
-        });
-
-        DataSet dataSet;
-        assertEquals(1, defaultSchema.getTableCount());
-
-        // "Pure" SELECT COUNT(*) query
-        dataSet = dc.query().from("some_entries").selectCount().execute();
-        dataSet.close();
-        assertTrue(dataSet.next());
-        assertEquals(1, dataSet.getSelectItems().length);
-        assertEquals(SelectItem.getCountAllItem(), dataSet.getSelectItems()[0]);
-        assertEquals(4l, dataSet.getRow().getValue(SelectItem.getCountAllItem()));
-        assertFalse(dataSet.next());
-        assertEquals(InMemoryDataSet.class, dataSet.getClass());
-
-        // A conditional SELECT COUNT(*) query
-        dataSet = dc.query().from("some_entries").selectCount().where("foo").greaterThan(2).execute();
-        dataSet.close();
-        assertTrue(dataSet.next());
-        assertEquals(1, dataSet.getSelectItems().length);
-        assertEquals(SelectItem.getCountAllItem(), dataSet.getSelectItems()[0]);
-        assertEquals(2l, dataSet.getRow().getValue(SelectItem.getCountAllItem()));
-        assertFalse(dataSet.next());
-        assertEquals(InMemoryDataSet.class, dataSet.getClass());
-
-        // Select columns
-        dataSet = dc.query().from("some_entries").select("foo").and("bar").and("baz").and("list").execute();
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[1, hello, null, null]]", dataSet.getRow().toString());
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[2, world, null, null]]", dataSet.getRow().toString());
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[3, hi, null, null]]", dataSet.getRow().toString());
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[4, there, {123=456, foo=bar}, [ 1 , 2 , 3]]]", dataSet.getRow().toString());
-        assertFalse(dataSet.next());
-        dataSet.close();
-        assertEquals(MongoDbDataSet.class, dataSet.getClass());
-
-        // delete some records
-        dc.executeUpdate(new UpdateScript() {
-            @Override
-            public void run(UpdateCallback callback) {
-                callback.deleteFrom("some_entries").where("foo").greaterThan(2).where("baz").isNotNull().execute();
-            }
-        });
-
-        dataSet = dc.query().from("some_entries").select("foo").execute();
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[1]]", dataSet.getRow().toString());
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[2]]", dataSet.getRow().toString());
-        assertTrue(dataSet.next());
-        assertEquals("Row[values=[3]]", dataSet.getRow().toString());
-        assertFalse(dataSet.next());
-        dataSet.close();
-        assertEquals(MongoDbDataSet.class, dataSet.getClass());
-
-        // drop the collection
-        dc.executeUpdate(new UpdateScript() {
-            @Override
-            public void run(UpdateCallback callback) {
-                callback.dropTable("some_entries").execute();
-            }
-        });
-
-        assertNull(dc.getTableByQualifiedLabel("some_entries"));
-
-        dc.refreshSchemas();
-        assertEquals(0, defaultSchema.getTableCount());
-    }
-
-    public void testSelectWithLikeOperator() throws Exception {
-        if (!isConfigured()) {
-            System.err.println(getInvalidConfigurationMessage());
-            return;
-        }
-
-        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
-
-        // delete if already exists
-        {
-            col.drop();
-            col = db.createCollection(getCollectionName(), new BasicDBObject());
-        }
-
-        final BasicDBObject dbRow = new BasicDBObject();
-        dbRow.append("name", new BasicDBObject().append("first", "John").append("last", "Doe"));
-        dbRow.append("gender", "MALE");
-        col.insert(dbRow);
-
-        final BasicDBObject dbRow2 = new BasicDBObject();
-        dbRow2.append("name", new BasicDBObject().append("first", "Mary").append("last", "Johnson"));
-        dbRow2.append("gender", "FEMALE");
-        col.insert(dbRow2);
-
-        final BasicDBObject dbRow3 = new BasicDBObject();
-        dbRow3.append("name", new BasicDBObject().append("first", "X").append("last", "Unknown"));
-        dbRow3.append("gender", "UNKNOWN");
-        col.insert(dbRow3);
-
-        final MongoDbDataContext dc = new MongoDbDataContext(db, new SimpleTableDef(getCollectionName(), new String[] {
-                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
-                "addresses[5].foobar" }));
-
-        final DataSet ds1 = dc.executeQuery("select * from my_collection where gender LIKE '%MALE%'");
-        final DataSet ds2 = dc.executeQuery("select * from my_collection where gender LIKE 'MALE%'");
-        final DataSet ds3 = dc.executeQuery("select * from my_collection where gender LIKE '%NK%OW%'");
-        final DataSet ds4 = dc.executeQuery("select * from my_collection where gender LIKE '%MALE'");
-        try {
-            assertTrue(ds1.next());
-            assertTrue(ds1.next());
-            assertFalse(ds1.next());
-            assertTrue(ds2.next());
-            assertFalse(ds2.next());
-            assertTrue(ds3.next());
-            assertFalse(ds3.next());
-            assertTrue(ds4.next());
-            assertTrue(ds4.next());
-            assertFalse(ds4.next());
-        } finally {
-            ds1.close();
-            ds2.close();
-            ds3.close();
-            ds4.close();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataCopyer.java
----------------------------------------------------------------------
diff --git a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataCopyer.java b/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataCopyer.java
deleted file mode 100644
index 5ecbcc5..0000000
--- a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataCopyer.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.apache.metamodel.DataContext;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.UpdateScript;
-import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.data.Row;
-import org.apache.metamodel.insert.RowInsertionBuilder;
-import org.apache.metamodel.jdbc.JdbcDataContext;
-import org.apache.metamodel.schema.Column;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-import org.apache.metamodel.util.FileHelper;
-
-import com.mongodb.DB;
-import com.mongodb.Mongo;
-
-/**
- * Simple example program that can copy data to a MongoDB collection
- */
-public class MongoDbDataCopyer {
-
-    private final DataContext _sourceDataContext;
-    private final DB _mongoDb;
-    private final String _collectionName;
-    private final String _sourceSchemaName;
-    private final String _sourceTableName;
-
-    // example copy job that will populate the mongodb with Derby data
-    public static void main(String[] args) throws Exception {
-        System.setProperty("derby.storage.tempDirector", FileHelper.getTempDir().getAbsolutePath());
-        System.setProperty("derby.stream.error.file", File.createTempFile("metamodel-derby", ".log").getAbsolutePath());
-
-        File dbFile = new File("../jdbc/src/test/resources/derby_testdb.jar");
-        dbFile = dbFile.getCanonicalFile();
-        if (!dbFile.exists()) {
-            throw new IllegalStateException("File does not exist: " + dbFile);
-        }
-
-        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
-        Connection connection = DriverManager.getConnection("jdbc:derby:jar:(" + dbFile.getAbsolutePath()
-                + ")derby_testdb;territory=en");
-        connection.setReadOnly(true);
-
-        DB db = new Mongo().getDB("orderdb_copy");
-
-        DataContext sourceDataContext = new JdbcDataContext(connection);
-
-        new MongoDbDataCopyer(db, "orders", sourceDataContext, "APP", "orders").copy();
-        new MongoDbDataCopyer(db, "offices", sourceDataContext, "APP", "offices").copy();
-        new MongoDbDataCopyer(db, "payments", sourceDataContext, "APP", "payments").copy();
-        new MongoDbDataCopyer(db, "orderfact", sourceDataContext, "APP", "orderfact").copy();
-        new MongoDbDataCopyer(db, "products", sourceDataContext, "APP", "products").copy();
-
-        connection.close();
-    }
-
-    public MongoDbDataCopyer(DB mongoDb, String collectionName, DataContext sourceDataContext, String sourceSchemaName,
-            String sourceTableName) {
-        _mongoDb = mongoDb;
-        _collectionName = collectionName;
-        _sourceDataContext = sourceDataContext;
-        _sourceSchemaName = sourceSchemaName;
-        _sourceTableName = sourceTableName;
-    }
-
-    public void copy() {
-        final MongoDbDataContext targetDataContext = new MongoDbDataContext(_mongoDb);
-        targetDataContext.executeUpdate(new UpdateScript() {
-
-            @Override
-            public void run(UpdateCallback callback) {
-                final Table sourceTable = getSourceTable();
-                final Table targetTable = callback.createTable(targetDataContext.getDefaultSchema(), _collectionName)
-                        .like(sourceTable).execute();
-                final Column[] sourceColumns = sourceTable.getColumns();
-                final DataSet dataSet = _sourceDataContext.query().from(sourceTable).select(sourceColumns).execute();
-                while (dataSet.next()) {
-                    final Row row = dataSet.getRow();
-
-                    RowInsertionBuilder insertBuilder = callback.insertInto(targetTable);
-                    for (Column column : sourceColumns) {
-                        insertBuilder = insertBuilder.value(column.getName(), row.getValue(column));
-                    }
-                    insertBuilder.execute();
-                }
-                dataSet.close();
-            }
-        });
-    }
-
-    private Table getSourceTable() {
-        final Schema schema;
-        if (_sourceSchemaName != null) {
-            schema = _sourceDataContext.getSchemaByName(_sourceSchemaName);
-        } else {
-            schema = _sourceDataContext.getDefaultSchema();
-        }
-
-        return schema.getTableByName(_sourceTableName);
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
----------------------------------------------------------------------
diff --git a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java b/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
deleted file mode 100644
index 4b83398..0000000
--- a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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
- *
- * 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 org.apache.metamodel.mongodb;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-public abstract class MongoDbTestCase extends TestCase {
-
-    private static final String DEFAULT_TEST_COLLECTION_NAME = "my_collection";
-    private static final String DEFAULT_TEST_DATABASE_NAME = "metamodel_test";
-
-    private String _hostname;
-    private String _collectionName;
-    private boolean _configured;
-
-    private String _databaseName;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        File file = new File(getPropertyFilePath());
-        if (file.exists()) {
-            loadPropertyFile(file);
-        } else {
-            // Continuous integration case
-            if (System.getenv("CONTINUOUS_INTEGRATION") != null) {
-                File travisFile = new File("../travis-metamodel-integrationtest-configuration.properties");
-                if (travisFile.exists()) {
-                    loadPropertyFile(travisFile);
-                } else {
-                    _configured = false;
-                }
-            } else {
-                _configured = false;
-            }
-        }
-    }
-
-    private void loadPropertyFile(File file) throws FileNotFoundException, IOException {
-        Properties properties = new Properties();
-        properties.load(new FileReader(file));
-        _hostname = properties.getProperty("mongodb.hostname");
-        
-        _databaseName = properties.getProperty("mongodb.databaseName");
-        if (_databaseName == null || _databaseName.isEmpty()) {
-            _databaseName = DEFAULT_TEST_DATABASE_NAME;
-        }
-        
-        _collectionName = properties.getProperty("mongodb.collectionName");
-        if (_collectionName == null || _collectionName.isEmpty()) {
-            _collectionName = DEFAULT_TEST_COLLECTION_NAME;
-        }
-
-        _configured = (_hostname != null && !_hostname.isEmpty());
-
-        if (_configured) {
-            System.out.println("Loaded MongoDB configuration. Hostname=" + _hostname + ", Collection="
-                    + _collectionName);
-        }
-        
-    }
-
-    private String getPropertyFilePath() {
-        String userHome = System.getProperty("user.home");
-        return userHome + "/metamodel-integrationtest-configuration.properties";
-    }
-
-    protected String getInvalidConfigurationMessage() {
-        return "!!! WARN !!! MongoDB module ignored\r\n" + "Please configure mongodb connection locally ("
-                + getPropertyFilePath() + "), to run integration tests";
-    }
-    
-    public String getDatabaseName() {
-        return _databaseName;
-    }
-
-    public String getCollectionName() {
-        return _collectionName;
-    }
-
-    public String getHostname() {
-        return _hostname;
-    }
-    
-    public boolean isConfigured() {
-        return _configured;
-    }
-}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/365fae3a/spring/src/main/java/org/apache/metamodel/spring/MongoDbDataContextFactoryBeanDelegate.java
----------------------------------------------------------------------
diff --git a/spring/src/main/java/org/apache/metamodel/spring/MongoDbDataContextFactoryBeanDelegate.java b/spring/src/main/java/org/apache/metamodel/spring/MongoDbDataContextFactoryBeanDelegate.java
index 9bc8279..84378f1 100644
--- a/spring/src/main/java/org/apache/metamodel/spring/MongoDbDataContextFactoryBeanDelegate.java
+++ b/spring/src/main/java/org/apache/metamodel/spring/MongoDbDataContextFactoryBeanDelegate.java
@@ -20,7 +20,7 @@ package org.apache.metamodel.spring;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.DataContextFactory;
-import org.apache.metamodel.mongodb.MongoDbDataContext;
+import org.apache.metamodel.mongodb.mongo3.MongoDbDataContext;
 import org.apache.metamodel.util.SimpleTableDef;
 
 /**