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 2017/05/10 03:54:03 UTC
[01/43] metamodel git commit: METAMODEL-1102 Separated
FixedWidthLineParser
Repository: metamodel
Updated Branches:
refs/heads/5.x 02397db0a -> c4788a272
METAMODEL-1102 Separated FixedWidthLineParser
Closes apache/metamodel#114
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/250b12db
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/250b12db
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/250b12db
Branch: refs/heads/5.x
Commit: 250b12dbf5ed5f3620cdd693c67ffedc1e82ac1b
Parents: 52c3daf
Author: Claudia Pesu <Cl...@HumanInference.com>
Authored: Wed Jul 13 10:20:36 2016 +0200
Committer: Dennis Du Krøger <d...@hp23c.dk>
Committed: Wed Jul 13 10:20:36 2016 +0200
----------------------------------------------------------------------
CHANGES.md | 3 +-
.../fixedwidth/FixedWidthLineParser.java | 121 ++++++++++++++++++
.../metamodel/fixedwidth/FixedWidthReader.java | 123 ++-----------------
.../fixedwidth/FixedWidthLineParserTest.java | 66 ++++++++++
.../fixedwidth/FixedWidthReaderTest.java | 64 ++++++++--
.../src/test/resources/example_simple3.txt | 4 +
6 files changed, 260 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/250b12db/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 3ff4ca0..65223ac 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,7 +5,8 @@
* [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
* [METAMODEL-1094] - Added support for Apache Cassandra version 3.x.
* [METAMODEL-1093] - Close compiled ResultSets.
-
+ * [METAMODEL-1102] - Separated FixedWidthLineParser.
+
### Apache MetaModel 4.5.3
* [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/250b12db/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthLineParser.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthLineParser.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthLineParser.java
new file mode 100644
index 0000000..3746333
--- /dev/null
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthLineParser.java
@@ -0,0 +1,121 @@
+/**
+ * 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.IOException;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FixedWidthLineParser {
+
+ private final int _expectedLineLength;
+ private volatile int _rowNumber;
+ private final FixedWidthConfiguration _configuration;
+
+ public FixedWidthLineParser(FixedWidthConfiguration configuration, int expectedLineLength, int rowNumber) {
+ _configuration = configuration;
+ _expectedLineLength = expectedLineLength;
_rowNumber = rowNumber;
+ }
+
+
+ public String[] parseLine(String line) throws IOException {
+ final List<String> values = new ArrayList<String>();
+ int[] valueWidths = _configuration.getValueWidths();
+
+ if (line == null) {
+ return null;
+ }
+
+ StringBuilder nextValue = new StringBuilder();
+
+ int valueIndex = 0;
+
+ final CharacterIterator it = new StringCharacterIterator(line);
+ for (char c = it.first(); c != CharacterIterator.DONE; c = it
+ .next()) {
+ nextValue.append(c);
+
+ final int valueWidth;
+ if (_configuration.isConstantValueWidth()) {
+ valueWidth = _configuration.getFixedValueWidth();
+ } else {
+ if (valueIndex >= valueWidths.length) {
+ if (_configuration.isFailOnInconsistentLineWidth()) {
+ String[] result = values.toArray(new String[values
+ .size()]);
+ throw new InconsistentValueWidthException(result,
+ line, _rowNumber + 1);
+ } else {
+ // silently ignore the inconsistency
+ break;
+ }
+ }
+ valueWidth = _configuration.getValueWidth(valueIndex);
+ }
+
+ if (nextValue.length() == valueWidth) {
+ // write the value
+ values.add(nextValue.toString().trim());
+ nextValue = new StringBuilder();
+ valueIndex++;
+ }
+ }
+
+ if (nextValue.length() > 0) {
+ values.add(nextValue.toString().trim());
+ }
+
+ String[] result = values.toArray(new String[values.size()]);
+
+ if (!_configuration.isFailOnInconsistentLineWidth() && ! _configuration.isConstantValueWidth()) {
+ if (result.length != valueWidths.length) {
+ String[] correctedResult = new String[valueWidths.length];
+ for (int i = 0; i < result.length
+ && i < valueWidths.length; i++) {
+ correctedResult[i] = result[i];
+ }
+ result = correctedResult;
+ }
+ }
+
+ if (_configuration.isFailOnInconsistentLineWidth()) {
+ _rowNumber++;
+ if (_configuration.isConstantValueWidth()) {
+ if (line.length() % _configuration.getFixedValueWidth() != 0) {
+ throw new InconsistentValueWidthException(result, line,
+ _rowNumber);
+ }
+ } else {
+ if (result.length != values.size()) {
+ throw new InconsistentValueWidthException(result, line,
+ _rowNumber);
+ }
+
+ if (line.length() != _expectedLineLength) {
+ throw new InconsistentValueWidthException(result, line,
+ _rowNumber);
+ }
+ }
+ }
+
+ return result;
+}
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/250b12db/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
index 40dc145..d7a18cf 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
@@ -22,10 +22,6 @@ import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
-import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
-import java.util.ArrayList;
-import java.util.List;
/**
* Reader capable of separating values based on a fixed width setting.
@@ -33,12 +29,7 @@ import java.util.List;
final public class FixedWidthReader implements Closeable {
private final BufferedReader _reader;
- private final int _fixedValueWidth;
- private final int[] _valueWidths;
- private final boolean _failOnInconsistentLineWidth;
- private final int expectedLineLength;
- private final boolean constantWidth;
- private volatile int _rowNumber;
+ private final FixedWidthLineParser _parser;
public FixedWidthReader(Reader reader, int fixedValueWidth,
boolean failOnInconsistentLineWidth) {
@@ -49,13 +40,9 @@ final public class FixedWidthReader implements Closeable {
public FixedWidthReader(BufferedReader reader, int fixedValueWidth,
boolean failOnInconsistentLineWidth) {
_reader = reader;
- _fixedValueWidth = fixedValueWidth;
- _failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- _rowNumber = 0;
- _valueWidths = null;
-
- constantWidth = true;
- expectedLineLength = -1;
+ final FixedWidthConfiguration fixedWidthConfiguration = new FixedWidthConfiguration(
+ FixedWidthConfiguration.NO_COLUMN_NAME_LINE, null, fixedValueWidth, failOnInconsistentLineWidth);
+ _parser = new FixedWidthLineParser(fixedWidthConfiguration, -1, 0);
}
public FixedWidthReader(Reader reader, int[] valueWidths,
@@ -67,19 +54,16 @@ final public class FixedWidthReader implements Closeable {
public FixedWidthReader(BufferedReader reader, int[] valueWidths,
boolean failOnInconsistentLineWidth) {
_reader = reader;
- _fixedValueWidth = -1;
- _valueWidths = valueWidths;
- _failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- _rowNumber = 0;
-
- constantWidth = false;
+ int fixedValueWidth = -1;
int expectedLineLength = 0;
- if (_fixedValueWidth == -1) {
- for (int i = 0; i < _valueWidths.length; i++) {
- expectedLineLength += _valueWidths[i];
+ if (fixedValueWidth == -1) {
+ for (int i = 0; i < valueWidths.length; i++) {
+ expectedLineLength += valueWidths[i];
}
}
- this.expectedLineLength = expectedLineLength;
+ final FixedWidthConfiguration fixedWidthConfiguration = new FixedWidthConfiguration(
+ FixedWidthConfiguration.NO_COLUMN_NAME_LINE, null, valueWidths, failOnInconsistentLineWidth);
+ _parser = new FixedWidthLineParser(fixedWidthConfiguration, expectedLineLength, 0);
}
@@ -96,95 +80,12 @@ final public class FixedWidthReader implements Closeable {
String line;
try {
line = _reader.readLine();
- return readLine(line);
+ return _parser.parseLine(line);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
- public String[] readLine(String line) throws IOException {
-
-
- final List<String> values = new ArrayList<String>();
-
- if (line == null) {
- return null;
- }
-
- StringBuilder nextValue = new StringBuilder();
-
- int valueIndex = 0;
-
- final CharacterIterator it = new StringCharacterIterator(line);
- for (char c = it.first(); c != CharacterIterator.DONE; c = it
- .next()) {
- nextValue.append(c);
-
- final int valueWidth;
- if (constantWidth) {
- valueWidth = _fixedValueWidth;
- } else {
- if (valueIndex >= _valueWidths.length) {
- if (_failOnInconsistentLineWidth) {
- String[] result = values.toArray(new String[values
- .size()]);
- throw new InconsistentValueWidthException(result,
- line, _rowNumber + 1);
- } else {
- // silently ignore the inconsistency
- break;
- }
- }
- valueWidth = _valueWidths[valueIndex];
- }
-
- if (nextValue.length() == valueWidth) {
- // write the value
- values.add(nextValue.toString().trim());
- nextValue = new StringBuilder();
- valueIndex++;
- }
- }
-
- if (nextValue.length() > 0) {
- values.add(nextValue.toString().trim());
- }
-
- String[] result = values.toArray(new String[values.size()]);
-
- if (!_failOnInconsistentLineWidth && !constantWidth) {
- if (result.length != _valueWidths.length) {
- String[] correctedResult = new String[_valueWidths.length];
- for (int i = 0; i < result.length
- && i < _valueWidths.length; i++) {
- correctedResult[i] = result[i];
- }
- result = correctedResult;
- }
- }
-
- if (_failOnInconsistentLineWidth) {
- _rowNumber++;
- if (constantWidth) {
- if (line.length() % _fixedValueWidth != 0) {
- throw new InconsistentValueWidthException(result, line,
- _rowNumber);
- }
- } else {
- if (result.length != values.size()) {
- throw new InconsistentValueWidthException(result, line,
- _rowNumber);
- }
-
- if (line.length() != expectedLineLength) {
- throw new InconsistentValueWidthException(result, line,
- _rowNumber);
- }
- }
- }
-
- return result;
- }
@Override
public void close() throws IOException {
http://git-wip-us.apache.org/repos/asf/metamodel/blob/250b12db/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthLineParserTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthLineParserTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthLineParserTest.java
new file mode 100644
index 0000000..50d5097
--- /dev/null
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthLineParserTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.assertEquals;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class FixedWidthLineParserTest {
+
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
+ @Test
+ public void testParser() throws IOException {
+ int[] widths = new int[] { 8, 9 };
+ FixedWidthConfiguration fixedWidthConfiguration = new FixedWidthConfiguration(FixedWidthConfiguration.NO_COLUMN_NAME_LINE, null, widths, false);
+ final FixedWidthLineParser parser = new FixedWidthLineParser(fixedWidthConfiguration, 17, 0);
+
+ final String lineToParse1 = "greeting greeter ";
+ final String[] line = parser.parseLine(lineToParse1);
+ assertEquals("[greeting, greeter]", Arrays.asList(line).toString());
+
+ final String lineToParse2="howdy partner";
+ String[] line2 = parser.parseLine(lineToParse2);
+ assertEquals("[howdy, partner]", Arrays.asList(line2).toString());
+
+ final String lineToParse3 ="hi there ";
+ String[] line3 = parser.parseLine(lineToParse3);
+ assertEquals("[hi, there]", Arrays.asList(line3).toString());
+
+ }
+
+ @Test
+ public void testParserFailInconsistentRowException() throws IOException {
+ int[] widths = new int[] { 8, 5 };
+ FixedWidthConfiguration fixedWidthConfiguration = new FixedWidthConfiguration(FixedWidthConfiguration.NO_COLUMN_NAME_LINE, null, widths, true);
+ final FixedWidthLineParser parser = new FixedWidthLineParser(fixedWidthConfiguration, 17, 0);
+
+ final String lineToParse1 = "greeting greeter ";
+ exception.expect(InconsistentValueWidthException.class);
+ @SuppressWarnings("unused")
+ final String[] line = parser.parseLine(lineToParse1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/250b12db/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
index dd45900..4d11f0e 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
@@ -26,12 +26,17 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class FixedWidthReaderTest {
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
@Test
- public void testBufferedReader() throws IOException {
+ public void testBufferedReader1() throws IOException {
final File file = new File("src/test/resources/example_simple1.txt");
final BufferedReader reader = new BufferedReader(new FileReader(file));
int[] widths = new int[] { 8, 9 };
@@ -44,14 +49,55 @@ public class FixedWidthReaderTest {
assertEquals("[hi, there]", Arrays.asList(line3).toString());
}
}
-
+
@Test
- public void testNoBufferReader() throws IOException {
- int[] widths = new int[] { 8, 9 };
- final String lineToBeRead = "greeting greeter ";
- @SuppressWarnings("resource")
- final FixedWidthReader fixedWidthReader = new FixedWidthReader(null, widths, false);
- final String[] line = fixedWidthReader.readLine(lineToBeRead);
- assertEquals("[greeting, greeter]", Arrays.asList(line).toString());
+ public void testBufferedReader2() throws IOException {
+ final File file = new File("src/test/resources/example_simple2.txt");
+ final BufferedReader reader = new BufferedReader(new FileReader(file));
+ int[] widths = new int[] {1, 8, 9 };
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, widths, false)) {
+ final String[] line1 = fixedWidthReader.readLine();
+ assertEquals("[i, greeting, greeter]", Arrays.asList(line1).toString());
+ final String[] line2 = fixedWidthReader.readLine();
+ assertEquals("[1, hello, world]", Arrays.asList(line2).toString());
+ final String[] line3 = fixedWidthReader.readLine();
+ assertEquals("[2, hi, there]", Arrays.asList(line3).toString());
+ }
}
+
+ @Test
+ public void testBufferedReader3() throws IOException {
+ final File file = new File("src/test/resources/example_simple3.txt");
+ final BufferedReader reader = new BufferedReader(new FileReader(file));
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, 5, false)) {
+ final String[] line1 = fixedWidthReader.readLine();
+ assertEquals("[hello]", Arrays.asList(line1).toString());
+ final String[] line2 = fixedWidthReader.readLine();
+ assertEquals("[world]", Arrays.asList(line2).toString());
+ final String[] line3 = fixedWidthReader.readLine();
+ assertEquals("[howdy]", Arrays.asList(line3).toString());
+ final String[] line4 = fixedWidthReader.readLine();
+ assertEquals("[ther]", Arrays.asList(line4).toString());
+ }
+ }
+
+ @Test
+ public void testBufferedReaderFailOnInconsistentRows() throws IOException {
+ final File file = new File("src/test/resources/example_simple3.txt");
+ final BufferedReader reader = new BufferedReader(new FileReader(file));
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, 5, true)) {
+ final String[] line1 = fixedWidthReader.readLine();
+ assertEquals("[hello]", Arrays.asList(line1).toString());
+ final String[] line2 = fixedWidthReader.readLine();
+ assertEquals("[world]", Arrays.asList(line2).toString());
+ final String[] line3 = fixedWidthReader.readLine();
+ assertEquals("[howdy]", Arrays.asList(line3).toString());
+
+ exception.expect(InconsistentValueWidthException.class);
+ @SuppressWarnings("unused")
+ final String[] line4 = fixedWidthReader.readLine();
+ }
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/250b12db/fixedwidth/src/test/resources/example_simple3.txt
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/resources/example_simple3.txt b/fixedwidth/src/test/resources/example_simple3.txt
new file mode 100644
index 0000000..a9e1cf3
--- /dev/null
+++ b/fixedwidth/src/test/resources/example_simple3.txt
@@ -0,0 +1,4 @@
+hello
+world
+howdy
+ther
\ No newline at end of file
[27/43] metamodel git commit: Fixed toString() method of
insert-builder. Fixes #134
Posted by ka...@apache.org.
Fixed toString() method of insert-builder. Fixes #134
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/c32a2bb4
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/c32a2bb4
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/c32a2bb4
Branch: refs/heads/5.x
Commit: c32a2bb447863bda17fc75a5c7681c2d60af8590
Parents: a3ecbab
Author: Kasper Sørensen <i....@gmail.com>
Authored: Wed Oct 26 21:07:13 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Wed Oct 26 21:07:13 2016 -0700
----------------------------------------------------------------------
.gitattributes | 2 +
.../insert/AbstractRowInsertionBuilder.java | 5 +-
.../insert/AbstractRowInsertionBuilderTest.java | 49 ++++++++++++++++++++
pom.xml | 2 +
4 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c32a2bb4/.gitattributes
----------------------------------------------------------------------
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..4cab1f4
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Set the default behavior, in case people don't have core.autocrlf set.
+* text=auto
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c32a2bb4/core/src/main/java/org/apache/metamodel/insert/AbstractRowInsertionBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/insert/AbstractRowInsertionBuilder.java b/core/src/main/java/org/apache/metamodel/insert/AbstractRowInsertionBuilder.java
index d688059..bc09f98 100644
--- a/core/src/main/java/org/apache/metamodel/insert/AbstractRowInsertionBuilder.java
+++ b/core/src/main/java/org/apache/metamodel/insert/AbstractRowInsertionBuilder.java
@@ -84,7 +84,10 @@ public abstract class AbstractRowInsertionBuilder<U extends UpdateCallback> exte
sb.append(") VALUES (");
Object[] values = getValues();
for (int i = 0; i < values.length; i++) {
- Object value = values[i];
+ if (i != 0) {
+ sb.append(',');
+ }
+ final Object value = values[i];
final String stringValue;
if (value == null) {
stringValue = "NULL";
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c32a2bb4/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
new file mode 100644
index 0000000..fc9f6bd
--- /dev/null
+++ b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.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.insert;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableTable;
+import org.junit.Test;
+
+public class AbstractRowInsertionBuilderTest {
+
+ @Test
+ public void testToString() {
+ final MutableTable table = new MutableTable("tbl");
+ final MutableColumn col1 = new MutableColumn("col1").setTable(table);
+ final MutableColumn col2 = new MutableColumn("col2").setTable(table);
+ table.addColumn(col1).addColumn(col2);
+
+ final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(
+ null, table) {
+ @Override
+ public void execute() throws MetaModelException {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ builder.value(col1, "value1").value(col2, "value2");
+ assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c32a2bb4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 25209d8..b7b71c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -376,6 +376,8 @@ under the License.
<exclude>**/src/assembly/metamodel-packaged-assembly-descriptor.xml</exclude>
<exclude>**/.gitignore/**</exclude>
<exclude>.git/**</exclude>
+ <exclude>.gitattributes</exclude>
+ <exclude>**/.toDelete</exclude>
<exclude>**/src/main/resources/META-INF/services/**</exclude>
<exclude>**/src/test/resources/**</exclude>
<exclude>**/src/site/**</exclude>
[02/43] metamodel git commit: METAMODEL-1103: Fixed
Posted by ka...@apache.org.
METAMODEL-1103: Fixed
Closes #115
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/1910d56f
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/1910d56f
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/1910d56f
Branch: refs/heads/5.x
Commit: 1910d56f40bd5b4cd6a10b1b312d763059dfc8bd
Parents: 250b12d
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Jul 15 16:04:50 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Jul 15 16:04:50 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../org/apache/metamodel/util/WildcardPattern.java | 13 ++++++++++---
.../org/apache/metamodel/util/WildcardPatternTest.java | 11 +++++++++++
3 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/1910d56f/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 65223ac..0b2b49d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,7 @@
### Apache MetaModel 4.5.4 (work in progress)
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
+ * [METAMODEL-1103] - Fixed a bug pertaining to anchoring of wildcards in LIKE operands.
* [METAMODEL-1088] - Add support for aliases in MongoDB.
* [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
* [METAMODEL-1094] - Added support for Apache Cassandra version 3.x.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/1910d56f/core/src/main/java/org/apache/metamodel/util/WildcardPattern.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/util/WildcardPattern.java b/core/src/main/java/org/apache/metamodel/util/WildcardPattern.java
index 648c2ca..715e0d2 100644
--- a/core/src/main/java/org/apache/metamodel/util/WildcardPattern.java
+++ b/core/src/main/java/org/apache/metamodel/util/WildcardPattern.java
@@ -32,14 +32,20 @@ import org.apache.metamodel.query.FilterItem;
public final class WildcardPattern implements Serializable {
private static final long serialVersionUID = 857462137797209624L;
+ private final boolean _startsWithDelim;
+ private final boolean _endsWithDelim;
private String _pattern;
private char _wildcard;
- private boolean _endsWithDelim;
public WildcardPattern(String pattern, char wildcard) {
_pattern = pattern;
_wildcard = wildcard;
- _endsWithDelim = (_pattern.charAt(pattern.length() - 1) == _wildcard);
+ if(_pattern.isEmpty()){
+ _startsWithDelim = _endsWithDelim = false;
+ } else {
+ _startsWithDelim = _pattern.charAt(0) == _wildcard;
+ _endsWithDelim = _pattern.charAt(pattern.length() - 1) == _wildcard;
+ }
}
public boolean matches(String value) {
@@ -50,9 +56,10 @@ public final class WildcardPattern implements Serializable {
Character.toString(_wildcard));
int charIndex = 0;
while (st.hasMoreTokens()) {
+ int oldIndex = charIndex;
String token = st.nextToken();
charIndex = value.indexOf(token, charIndex);
- if (charIndex == -1) {
+ if (charIndex == -1 || !_startsWithDelim && oldIndex == 0 && charIndex != 0) {
return false;
}
charIndex = charIndex + token.length();
http://git-wip-us.apache.org/repos/asf/metamodel/blob/1910d56f/core/src/test/java/org/apache/metamodel/util/WildcardPatternTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/util/WildcardPatternTest.java b/core/src/test/java/org/apache/metamodel/util/WildcardPatternTest.java
index 1e075dd..4bc45f7 100644
--- a/core/src/test/java/org/apache/metamodel/util/WildcardPatternTest.java
+++ b/core/src/test/java/org/apache/metamodel/util/WildcardPatternTest.java
@@ -41,5 +41,16 @@ public class WildcardPatternTest extends TestCase {
assertTrue(pattern.matches("foobarbar"));
assertFalse(pattern.matches("w00p"));
+ pattern = new WildcardPattern("oba%", '%');
+ assertTrue(pattern.matches("obar"));
+ assertFalse(pattern.matches("foobar"));
+
+ pattern = new WildcardPattern("bar", '%');
+ assertTrue(pattern.matches("bar"));
+ assertFalse(pattern.matches("foobar"));
+
+ pattern = new WildcardPattern("", '%');
+ assertTrue(pattern.matches(""));
+ assertFalse(pattern.matches("foo"));
}
}
\ No newline at end of file
[20/43] metamodel git commit: METAMODEL-1114: Fixed
Posted by ka...@apache.org.
METAMODEL-1114: Fixed
Fixes #126
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/060884c1
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/060884c1
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/060884c1
Branch: refs/heads/5.x
Commit: 060884c17d1c5c35348d2cb675bed1c404013579
Parents: 9c8f0b9
Author: Arjan Seijkens <Ar...@humaninference.com>
Authored: Mon Sep 5 21:16:01 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Sep 5 21:16:01 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../metamodel/fixedwidth/EbcdicConfiguration.java | 9 ++++++++-
.../apache/metamodel/fixedwidth/EBCDICTest.java | 18 ++++++++++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/060884c1/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index c8f288f..f44077e 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,7 @@
* [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
* [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
* [METAMODEL-1113] - Fixed support for ColumnNamingStrategy in CSV connector.
+ * [METAMODEL-1114] - Added support for ColumnNamingStrategy in EBCDIC connector.
### Apache MetaModel 4.5.4
http://git-wip-us.apache.org/repos/asf/metamodel/blob/060884c1/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java
index 389a4f8..e4bff94 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java
@@ -18,6 +18,8 @@
*/
package org.apache.metamodel.fixedwidth;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+
/**
* Special fixed-width configuration for EBCDIC files.
*/
@@ -35,7 +37,12 @@ public final class EbcdicConfiguration extends FixedWidthConfiguration {
public EbcdicConfiguration(int columnNameLineNumber, String encoding, int[] valueWidths,
boolean failOnInconsistentLineWidth, boolean skipEbcdicHeader, boolean eolPresent) {
- super(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
+ this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth, skipEbcdicHeader, eolPresent);
+ }
+
+ public EbcdicConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
+ int[] valueWidths, boolean failOnInconsistentLineWidth, boolean skipEbcdicHeader, boolean eolPresent) {
+ super(columnNameLineNumber, columnNamingStrategy, encoding, valueWidths, failOnInconsistentLineWidth);
_skipEbcdicHeader = skipEbcdicHeader;
_eolPresent = eolPresent;
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/060884c1/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
index ea19960..2b5c8be 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
@@ -20,12 +20,15 @@ package org.apache.metamodel.fixedwidth;
import java.io.File;
+import org.apache.metamodel.DataContext;
import org.apache.metamodel.data.DataSet;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.schema.naming.CustomColumnNamingStrategy;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
public class EBCDICTest {
private static final int[] COLUMN_WIDTHS = new int[] { 2, 7, 10, 10 };
@@ -74,4 +77,19 @@ public class EBCDICTest {
}
}
}
+
+ @Test
+ public void testCustomColumnNames() throws Exception {
+ final String[] columnNames = {"first", "second", "third", "fourth"};
+ final FixedWidthConfiguration configuration = new EbcdicConfiguration(
+ FixedWidthConfiguration.NO_COLUMN_NAME_LINE, new CustomColumnNamingStrategy(columnNames), ENCODING,
+ COLUMN_WIDTHS, false, true, false);
+ final DataContext dataContext = new FixedWidthDataContext(new File(
+ "src/test/resources/fixed-width-2-7-10-10.ebc"), configuration);
+ final Table table = dataContext.getDefaultSchema().getTable(0);
+
+ for (int i = 0; i < columnNames.length; i++) {
+ assertNotNull(table.getColumnByName(columnNames[i]));
+ }
+ }
}
[38/43] metamodel git commit: Updated CHANGES.md for METAMODEL-1133
Posted by ka...@apache.org.
Updated CHANGES.md for METAMODEL-1133
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/d99034b1
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/d99034b1
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/d99034b1
Branch: refs/heads/5.x
Commit: d99034b17e1619763612e36bd9aad090904cf780
Parents: 5b98a63
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sat Jan 28 11:26:36 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sat Jan 28 11:26:36 2017 -0800
----------------------------------------------------------------------
CHANGES.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/d99034b1/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 6ffda44..105aced 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
* [METAMODEL-1136] - New connector for Amazon DynamoDB.
* [METAMODEL-1134] - Added NOT IN and NOT LIKE operators to WHERE filters.
+ * [METAMODEL-1133] - Made PojoDataContext thread-safe.
### Apache MetaModel 4.5.5
[24/43] metamodel git commit: METAMODEL-1119: Fixed
Posted by ka...@apache.org.
METAMODEL-1119: Fixed
Fixes #133
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/3949af85
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/3949af85
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/3949af85
Branch: refs/heads/5.x
Commit: 3949af857282f7c17a9be279e333348c5d3a0196
Parents: 4236768
Author: Dennis Du Krøger <lo...@apache.org>
Authored: Thu Oct 13 12:37:48 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Thu Oct 13 12:37:48 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../apache/metamodel/jdbc/JdbcDataContext.java | 48 +++++++++-----
.../jdbc/dialects/HiveQueryRewriter.java | 10 +++
.../integrationtests/HiveIntegrationTest.java | 69 +++++++++++++++++---
4 files changed, 101 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3949af85/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 5c0b893..bef1902 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@
* [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
* [METAMODEL-1113] - Fixed support for ColumnNamingStrategy in CSV connector.
* [METAMODEL-1114] - Added support for ColumnNamingStrategy in EBCDIC connector.
+ * [METAMODEL-1119] - Worked around Hive JDBC driver issues, avoiding non-compliant metadata calls.
### Apache MetaModel 4.5.4
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3949af85/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
index 63e42e5..8cd027b 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
@@ -654,7 +654,14 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
// Second strategy: Find default schema name by examining the
// URL
if (!found) {
- String url = metaData.getURL();
+ String url = null;
+ try {
+ url = metaData.getURL();
+ } catch (SQLException e) {
+ if (!DATABASE_PRODUCT_HIVE.equals(_databaseProductName)) {
+ throw e;
+ }
+ }
if (url != null && url.length() > 0) {
if (schemaNames.length > 0) {
StringTokenizer st = new StringTokenizer(url, "/\\:");
@@ -679,7 +686,14 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
// Third strategy: Check for schema equal to username
if (!found) {
- String username = metaData.getUserName();
+ String username = null;
+ try {
+ username = metaData.getUserName();
+ } catch (SQLException e) {
+ if (!DATABASE_PRODUCT_HIVE.equals(_databaseProductName)) {
+ throw e;
+ }
+ }
if (username != null) {
for (int i = 0; i < schemaNames.length && !found; i++) {
if (username.equalsIgnoreCase(schemaNames[i])) {
@@ -708,30 +722,28 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
found = true;
}
if (DATABASE_PRODUCT_HSQLDB.equalsIgnoreCase(_databaseProductName)) {
- for (int i = 0; i < schemaNames.length && !found; i++) {
- String schemaName = schemaNames[i];
- if ("PUBLIC".equals(schemaName)) {
- result = schemaName;
- found = true;
- break;
- }
- }
+ result = findDefaultSchema("PUBLIC", schemaNames);
}
if (DATABASE_PRODUCT_SQLSERVER.equals(_databaseProductName)) {
- for (int i = 0; i < schemaNames.length && !found; i++) {
- String schemaName = schemaNames[i];
- if ("dbo".equals(schemaName)) {
- result = schemaName;
- found = true;
- break;
- }
- }
+ result = findDefaultSchema("dbo", schemaNames);
+ }
+ if (DATABASE_PRODUCT_HIVE.equals(_databaseProductName)) {
+ result = findDefaultSchema("default", schemaNames);
}
}
}
return result;
}
+ private String findDefaultSchema(final String defaultName, final String[] schemaNames) {
+ for (String schemaName : schemaNames) {
+ if (defaultName.equals(schemaName)) {
+ return schemaName;
+ }
+ }
+ return null;
+ }
+
/**
* Microsoft SQL Server returns users instead of schemas when calling
* metadata.getSchemas() This is a simple workaround.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3949af85/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
index b18b9aa..59608d9 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
@@ -35,6 +35,16 @@ public class HiveQueryRewriter extends DefaultQueryRewriter {
if (columnType == ColumnType.INTEGER) {
return "INT";
}
+
+ if(columnType == ColumnType.STRING) {
+ return "STRING";
+ }
+
+ // Hive does not support VARCHAR without a width, nor VARCHAR(MAX).
+ // Returning max allowable column size instead.
+ if (columnType == ColumnType.VARCHAR && columnSize == null) {
+ return super.rewriteColumnType(columnType, 65535);
+ }
return super.rewriteColumnType(columnType, columnSize);
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3949af85/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/HiveIntegrationTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/HiveIntegrationTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/HiveIntegrationTest.java
index 6f6b9ec..b26bfe8 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/HiveIntegrationTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/HiveIntegrationTest.java
@@ -18,6 +18,10 @@
*/
package org.apache.metamodel.jdbc.integrationtests;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
import org.apache.metamodel.UpdateCallback;
import org.apache.metamodel.UpdateScript;
import org.apache.metamodel.create.CreateTable;
@@ -28,14 +32,61 @@ import org.apache.metamodel.jdbc.dialects.HiveQueryRewriter;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HiveIntegrationTest extends AbstractJdbIntegrationTest {
+ private static final Logger logger = LoggerFactory.getLogger(HiveIntegrationTest.class);
@Override
protected String getPropertyPrefix() {
return "hive";
}
+ private void createSchemas() throws SQLException {
+ Connection connection = getConnection();
+ final Statement st = connection.createStatement();
+ final String createFirstSql = "CREATE SCHEMA IF NOT EXISTS a_metamodel_test";
+ logger.info("SQL updated fired (return {}): {}", st.executeUpdate(createFirstSql), createFirstSql);
+ final String createLastSql = "CREATE SCHEMA IF NOT EXISTS z_metamodel_test";
+ logger.info("SQL updated fired (return {}): {}", st.executeUpdate(createLastSql), createLastSql);
+ }
+
+ private void deleteSchemas() throws SQLException {
+ Connection connection = getConnection();
+ final Statement st = connection.createStatement();
+ final String deleteFirstSql = "DROP SCHEMA IF EXISTS a_metamodel_test";
+ logger.info("SQL updated fired (return {}): {}", st.executeUpdate(deleteFirstSql), deleteFirstSql);
+ final String deleteLastSql = "DROP SCHEMA IF EXISTS z_metamodel_test";
+ logger.info("SQL updated fired (return {}): {}", st.executeUpdate(deleteLastSql), deleteLastSql);
+ }
+
+ public void testDefaultGetSchema() throws Exception {
+ if (!isConfigured()) {
+ return;
+ }
+
+ try {
+ try {
+ createSchemas();
+ } catch (SQLException e) {
+ fail("Schema creation failed");
+ }
+
+ final JdbcDataContext dataContext = getDataContext();
+ final Schema schema = dataContext.getDefaultSchema();
+
+ assertEquals("Schema[name=default]", schema.toString());
+
+ } finally {
+ try {
+ deleteSchemas();
+ } catch (SQLException e) {
+ logger.warn("Weird, couldn't delete test schemas");
+ }
+ }
+ }
+
public void testGetSchema() throws Exception {
if (!isConfigured()) {
return;
@@ -45,7 +96,7 @@ public class HiveIntegrationTest extends AbstractJdbIntegrationTest {
final Schema schema = dataContext.getSchemaByName("default");
assertEquals("Schema[name=default]", schema.toString());
}
-
+
public void testUseCorrectRewriter() throws Exception {
if (!isConfigured()) {
return;
@@ -65,19 +116,19 @@ public class HiveIntegrationTest extends AbstractJdbIntegrationTest {
final Schema schema = dataContext.getDefaultSchema();
dataContext.executeUpdate(new CreateTable(schema, tableName).withColumn("foo").ofType(ColumnType.STRING)
- .withColumn("bar").ofType(ColumnType.INTEGER));
+ .withColumn("bar").ofType(ColumnType.INTEGER).withColumn("baz").ofType(ColumnType.VARCHAR));
try {
final Table table = dataContext.getTableByQualifiedLabel(tableName);
assertNotNull(table);
dataContext.executeUpdate(new UpdateScript() {
-
+
@Override
public void run(UpdateCallback callback) {
- callback.insertInto(table).value("foo", "Hello world").value("bar", 42).execute();
- callback.insertInto(table).value("foo", "Lorem ipsum").value("bar", 42).execute();
- callback.insertInto(table).value("foo", "Apache").value("bar", 43).execute();
- callback.insertInto(table).value("foo", "MetaModel").value("bar", 44).execute();
+ callback.insertInto(table).value("foo", "Hello world").value("bar", 42).value("baz", "Hive").execute();
+ callback.insertInto(table).value("foo", "Lorem ipsum").value("bar", 42).value("baz", "Five").execute();
+ callback.insertInto(table).value("foo", "Apache").value("bar", 43).value("baz", "Live").execute();
+ callback.insertInto(table).value("foo", "MetaModel").value("bar", 44).value("baz", "Jive").execute();
}
});
@@ -89,9 +140,9 @@ public class HiveIntegrationTest extends AbstractJdbIntegrationTest {
final DataSet ds2 = dataContext.query().from(table).selectAll().where("bar").eq(42).execute();
assertTrue(ds2.next());
- assertEquals("Row[values=[Hello world, 42]]", ds2.getRow().toString());
+ assertEquals("Row[values=[Hello world, 42, Hive]]", ds2.getRow().toString());
assertTrue(ds2.next());
- assertEquals("Row[values=[Lorem ipsum, 42]]", ds2.getRow().toString());
+ assertEquals("Row[values=[Lorem ipsum, 42, Five]]", ds2.getRow().toString());
assertFalse(ds2.next());
ds2.close();
} finally {
[31/43] metamodel git commit: Updated line-endings
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/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
index 264287f..71a2640 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
@@ -1,176 +1,176 @@
-/**
- * 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 the format file encoding
- * @param resource the format file resource
- * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
- * @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 definition for column naming.
- *
- * @param encoding the format file encoding
- * @param resource the format file resource
- * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
- * @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 the format file encoding
+ * @param resource the format file resource
+ * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
+ * @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 definition for column naming.
+ *
+ * @param encoding the format file encoding
+ * @param resource the format file resource
+ * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
+ * @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/3f4c6d38/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
index eb57233..c34b294 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
@@ -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/3f4c6d38/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
index 785a539..ac055c9 100644
--- a/fixedwidth/src/test/resources/metadata_spec1/data.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/data.txt
@@ -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/3f4c6d38/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
index 9bbe411..38b0e04 100644
--- a/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
@@ -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/3f4c6d38/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
index f12e418..6839a9b 100644
--- a/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
@@ -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"
+
+;
[41/43] metamodel git commit: [maven-release-plugin] prepare release
MetaModel-4.6.0
Posted by ka...@apache.org.
[maven-release-plugin] prepare release MetaModel-4.6.0
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/5a5f7505
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/5a5f7505
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/5a5f7505
Branch: refs/heads/5.x
Commit: 5a5f7505c9ea3e1d38607aeafbc9e8f264cb5538
Parents: 32e0f97
Author: Kasper Sørensen <i....@gmail.com>
Authored: Tue Jan 31 13:09:49 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Tue Jan 31 13:09:49 2017 -0800
----------------------------------------------------------------------
cassandra/pom.xml | 2 +-
core/pom.xml | 2 +-
couchdb/pom.xml | 2 +-
csv/pom.xml | 2 +-
dynamodb/pom.xml | 5 ++---
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 +-
28 files changed, 30 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 8faaa38..a85b0d4 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-cassandra</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index e5fd523..de4726d 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index 8d03fe8..a481373 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-couchdb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index e3cdd09..1eef467 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-csv</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/dynamodb/pom.xml
----------------------------------------------------------------------
diff --git a/dynamodb/pom.xml b/dynamodb/pom.xml
index 546a13b..c1536b8 100644
--- a/dynamodb/pom.xml
+++ b/dynamodb/pom.xml
@@ -17,12 +17,11 @@ 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">
+<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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-dynamodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index eaff016..fe4ff29 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 358d8f0..d793f85 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 6a4efeb..17cbf8a 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-elasticsearch</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 5153932..178a299 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 6e617be..48e851b 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-excel</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 7ca3f7a..40eb3fa 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-fixedwidth</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 7dd5152..d4e7ac3 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-full</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 26f6afb..92bd38a 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hadoop</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 18ddb23..781f6ad 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hbase</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index ddb8bce..700a8e2 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-jdbc</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 79d1d9f..625a445 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-json</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index e9b52c4..945da3b 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-common</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 4bfa5d0..30c4209 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo2</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 744b3b7..2307064 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo3</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index a5f14d5..27e5fa3 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 21dc5b6..9e450ea 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-neo4j</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index 6a32548..e5eaca1 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-openoffice</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index cdedeb1..6a370d7 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-pojo</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 72d3672..2ea59fd 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.6.0</tag>
</scm>
<groupId>org.apache.metamodel</groupId>
<artifactId>MetaModel</artifactId>
- <version>4.5.6-SNAPSHOT</version>
+ <version>4.6.0</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/5a5f7505/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 4ae1b02..d03e188 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-salesforce</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index 60c1fe2..2eeb3e3 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-spring</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index bf8c557..32dbbd9 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-sugarcrm</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5a5f7505/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 0e1f000..bdb5aa3 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.6-SNAPSHOT</version>
+ <version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-xml</artifactId>
[22/43] metamodel git commit: Fixes #131: Improved query builder
support for "group by" and "having"
Posted by ka...@apache.org.
Fixes #131: Improved query builder support for "group by" and "having"
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/fe3aebe8
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/fe3aebe8
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/fe3aebe8
Branch: refs/heads/5.x
Commit: fe3aebe865d0fa825c304e2f94f28a7c80ed467a
Parents: b23085b
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sat Oct 8 23:54:24 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sat Oct 8 23:54:24 2016 -0700
----------------------------------------------------------------------
.../query/builder/GroupedQueryBuilder.java | 5 +
.../builder/GroupedQueryBuilderCallback.java | 16 +++
.../query/builder/GroupedQueryBuilderImpl.java | 30 +++++-
.../query/builder/HavingBuilderImpl.java | 100 +++++++++----------
.../query/builder/SatisfiedQueryBuilder.java | 4 +-
.../query/builder/SyntaxExamplesTest.java | 5 +
6 files changed, 104 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fe3aebe8/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilder.java b/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilder.java
index 18b65d6..75a0c38 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilder.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilder.java
@@ -19,6 +19,7 @@
package org.apache.metamodel.query.builder;
import org.apache.metamodel.query.FunctionType;
+import org.apache.metamodel.query.SelectItem;
import org.apache.metamodel.schema.Column;
/**
@@ -28,6 +29,10 @@ public interface GroupedQueryBuilder extends
SatisfiedQueryBuilder<GroupedQueryBuilder> {
public HavingBuilder having(FunctionType functionType, Column column);
+
+ public HavingBuilder having(SelectItem selectItem);
+
+ public HavingBuilder having(String columnExpression);
public SatisfiedOrderByBuilder<GroupedQueryBuilder> orderBy(
FunctionType function, Column column);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fe3aebe8/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderCallback.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderCallback.java b/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderCallback.java
index b5367ca..7a11ce2 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderCallback.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderCallback.java
@@ -26,6 +26,7 @@ import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.query.FunctionType;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.ScalarFunction;
+import org.apache.metamodel.query.SelectItem;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.util.BaseObject;
@@ -142,6 +143,21 @@ abstract class GroupedQueryBuilderCallback extends BaseObject implements Grouped
}
@Override
+ public HavingBuilder having(String columnExpression) {
+ return getQueryBuilder().having(columnExpression);
+ }
+
+ @Override
+ public HavingBuilder having(SelectItem selectItem) {
+ return getQueryBuilder().having(selectItem);
+ }
+
+ @Override
+ public GroupedQueryBuilder groupBy(String... columnNames) {
+ return getQueryBuilder().groupBy(columnNames);
+ }
+
+ @Override
public GroupedQueryBuilder groupBy(Column... columns) {
getQueryBuilder().groupBy(columns);
return this;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fe3aebe8/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderImpl.java b/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderImpl.java
index 0ea0098..d73ae8f 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderImpl.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/GroupedQueryBuilderImpl.java
@@ -30,6 +30,7 @@ import org.apache.metamodel.query.FunctionType;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.ScalarFunction;
import org.apache.metamodel.query.SelectItem;
+import org.apache.metamodel.query.parser.SelectItemParser;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.Table;
import org.apache.metamodel.util.BaseObject;
@@ -96,7 +97,7 @@ final class GroupedQueryBuilderImpl extends BaseObject implements GroupedQueryBu
@Override
public ColumnSelectBuilder<GroupedQueryBuilder> select(String columnName) {
- Column column = findColumn(columnName);
+ final Column column = findColumn(columnName);
return select(column);
}
@@ -196,8 +197,8 @@ final class GroupedQueryBuilderImpl extends BaseObject implements GroupedQueryBu
for (FromItem fromItem : fromItems) {
final Table table = fromItem.getTable();
if (table != null) {
- logger.debug("Table available in FROM item: {}. Column names: {}", table,
- Arrays.toString(table.getColumnNames()));
+ logger.debug("Table available in FROM item: {}. Column names: {}", table, Arrays.toString(table
+ .getColumnNames()));
}
}
}
@@ -271,11 +272,17 @@ final class GroupedQueryBuilderImpl extends BaseObject implements GroupedQueryBu
@Override
public GroupedQueryBuilder groupBy(String columnName) {
- Column column = findColumn(columnName);
+ final Column column = findColumn(columnName);
return groupBy(column);
}
@Override
+ public GroupedQueryBuilder groupBy(String... columnNames) {
+ _query.groupBy(columnNames);
+ return this;
+ }
+
+ @Override
public GroupedQueryBuilder groupBy(Column... columns) {
if (columns == null) {
throw new IllegalArgumentException("columns cannot be null");
@@ -285,6 +292,21 @@ final class GroupedQueryBuilderImpl extends BaseObject implements GroupedQueryBu
}
@Override
+ public HavingBuilder having(String columnExpression) {
+ final SelectItemParser parser = new SelectItemParser(_query, false);
+ final SelectItem selectItem = parser.findSelectItem(columnExpression);
+ return having(selectItem);
+ }
+
+ @Override
+ public HavingBuilder having(SelectItem selectItem) {
+ if (selectItem == null) {
+ throw new IllegalArgumentException("selectItem cannot be null");
+ }
+ return new HavingBuilderImpl(selectItem, _query, this);
+ }
+
+ @Override
public HavingBuilder having(FunctionType function, Column column) {
if (function == null) {
throw new IllegalArgumentException("function cannot be null");
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fe3aebe8/core/src/main/java/org/apache/metamodel/query/builder/HavingBuilderImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/HavingBuilderImpl.java b/core/src/main/java/org/apache/metamodel/query/builder/HavingBuilderImpl.java
index 4406e65..41a2b11 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/HavingBuilderImpl.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/HavingBuilderImpl.java
@@ -27,61 +27,59 @@ import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.SelectItem;
import org.apache.metamodel.schema.Column;
-final class HavingBuilderImpl extends
- AbstractQueryFilterBuilder<SatisfiedHavingBuilder> implements
- HavingBuilder, SatisfiedHavingBuilder {
+final class HavingBuilderImpl extends AbstractQueryFilterBuilder<SatisfiedHavingBuilder> implements
+ HavingBuilder,
+ SatisfiedHavingBuilder {
- private final Query _query;
- private final List<FilterItem> _orFilters;
- private FilterItem _parentOrFilter;
+ private final Query _query;
+ private final List<FilterItem> _orFilters;
+ private FilterItem _parentOrFilter;
- public HavingBuilderImpl(FunctionType function, Column column, Query query,
- GroupedQueryBuilder queryBuilder) {
- super(new SelectItem(function, column), queryBuilder);
- _query = query;
- _orFilters = new ArrayList<FilterItem>();
- }
+ public HavingBuilderImpl(SelectItem selectItem, Query query, GroupedQueryBuilder queryBuilder) {
+ super(selectItem, queryBuilder);
+ _query = query;
+ _orFilters = new ArrayList<FilterItem>();
+ }
- public HavingBuilderImpl(FunctionType function, Column column, Query query,
- FilterItem parentOrFilter, List<FilterItem> orFilters,
- GroupedQueryBuilder queryBuilder) {
- super(new SelectItem(function, column), queryBuilder);
- _query = query;
- _orFilters = orFilters;
- _parentOrFilter = parentOrFilter;
- }
+ public HavingBuilderImpl(FunctionType function, Column column, Query query, GroupedQueryBuilder queryBuilder) {
+ this(new SelectItem(function, column), query, queryBuilder);
+ }
- @Override
- protected SatisfiedHavingBuilder applyFilter(FilterItem filter) {
- if (_parentOrFilter == null) {
- _query.having(filter);
- } else {
- if (_parentOrFilter.getChildItemCount() == 1) {
- _query.getHavingClause().removeItem(_orFilters.get(0));
- _query.getHavingClause().addItem(_parentOrFilter);
- }
- }
- _orFilters.add(filter);
- return this;
- }
+ public HavingBuilderImpl(FunctionType function, Column column, Query query, FilterItem parentOrFilter,
+ List<FilterItem> orFilters, GroupedQueryBuilder queryBuilder) {
+ this(function, column, query, queryBuilder);
+ }
- @Override
- public HavingBuilder or(FunctionType function, Column column) {
- if (function == null) {
- throw new IllegalArgumentException("function cannot be null");
- }
- if (column == null) {
- throw new IllegalArgumentException("column cannot be null");
- }
- if (_parentOrFilter == null) {
- _parentOrFilter = new FilterItem(_orFilters);
- }
- return new HavingBuilderImpl(function, column, _query, _parentOrFilter,
- _orFilters, getQueryBuilder());
- }
+ @Override
+ protected SatisfiedHavingBuilder applyFilter(FilterItem filter) {
+ if (_parentOrFilter == null) {
+ _query.having(filter);
+ } else {
+ if (_parentOrFilter.getChildItemCount() == 1) {
+ _query.getHavingClause().removeItem(_orFilters.get(0));
+ _query.getHavingClause().addItem(_parentOrFilter);
+ }
+ }
+ _orFilters.add(filter);
+ return this;
+ }
- @Override
- public HavingBuilder and(FunctionType function, Column column) {
- return getQueryBuilder().having(function, column);
- }
+ @Override
+ public HavingBuilder or(FunctionType function, Column column) {
+ if (function == null) {
+ throw new IllegalArgumentException("function cannot be null");
+ }
+ if (column == null) {
+ throw new IllegalArgumentException("column cannot be null");
+ }
+ if (_parentOrFilter == null) {
+ _parentOrFilter = new FilterItem(_orFilters);
+ }
+ return new HavingBuilderImpl(function, column, _query, _parentOrFilter, _orFilters, getQueryBuilder());
+ }
+
+ @Override
+ public HavingBuilder and(FunctionType function, Column column) {
+ return getQueryBuilder().having(function, column);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fe3aebe8/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 e6b0670..f94ebdb 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
@@ -103,10 +103,12 @@ public interface SatisfiedQueryBuilder<B extends SatisfiedQueryBuilder<?>> {
public SatisfiedOrderByBuilder<B> orderBy(Column column);
public GroupedQueryBuilder groupBy(String columnName);
+
+ public GroupedQueryBuilder groupBy(String ... columnNames);
public GroupedQueryBuilder groupBy(Column column);
- public B groupBy(Column... columns);
+ public GroupedQueryBuilder groupBy(Column... columns);
/**
* Gets the built query as a {@link Query} object. Typically the returned
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fe3aebe8/core/src/test/java/org/apache/metamodel/query/builder/SyntaxExamplesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/query/builder/SyntaxExamplesTest.java b/core/src/test/java/org/apache/metamodel/query/builder/SyntaxExamplesTest.java
index 8876df9..af81801 100644
--- a/core/src/test/java/org/apache/metamodel/query/builder/SyntaxExamplesTest.java
+++ b/core/src/test/java/org/apache/metamodel/query/builder/SyntaxExamplesTest.java
@@ -70,6 +70,11 @@ public class SyntaxExamplesTest extends TestCase {
dc.query().from(table1).selectCount().select(col1).groupBy(col1).having(FunctionType.SUM, col1).greaterThan(3)
.orderBy(col1).asc();
}
+
+ public void testMultiGroupByAndHaving() throws Exception {
+ dc.query().from(table1).select("foo", "bar", "COUNT(*)").groupBy("foo","bar").having("COUNT(*)").greaterThan(3)
+ .orderBy(col1).asc();
+ }
public void testMultipleTables() throws Exception {
Query q = dc.query().from(table1).as("t1").and(table2).as("t2").select(col1).where(col1).greaterThan(col2)
[25/43] metamodel git commit: METAMODEL-1123: Fixed. METAMODEL-1124:
Fixed.
Posted by ka...@apache.org.
METAMODEL-1123: Fixed. METAMODEL-1124: Fixed.
Fixes #132
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/5f09375f
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/5f09375f
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/5f09375f
Branch: refs/heads/5.x
Commit: 5f09375ff7197545f67e9f64982921bfdb8354d7
Parents: 3949af8
Author: Juslwk <i....@gmail.com>
Authored: Thu Oct 13 12:45:25 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Thu Oct 13 12:45:25 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 2 ++
.../org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java | 2 +-
.../org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java | 2 +-
.../main/java/org/apache/metamodel/salesforce/SalesforceTable.java | 2 +-
4 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5f09375f/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index bef1902..236602e 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,6 +8,8 @@
* [METAMODEL-1113] - Fixed support for ColumnNamingStrategy in CSV connector.
* [METAMODEL-1114] - Added support for ColumnNamingStrategy in EBCDIC connector.
* [METAMODEL-1119] - Worked around Hive JDBC driver issues, avoiding non-compliant metadata calls.
+ * [METAMODEL-1123] - Fixed the treatment of a Salesforce.com 'currency' value as a number, not a string.
+ * [METAMODEL-1124] - Fixed the date formatting of date values in MS SQL server.
### Apache MetaModel 4.5.4
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5f09375f/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
index f261d40..88bed85 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
@@ -112,7 +112,7 @@ public class SQLServerQueryRewriter extends DefaultQueryRewriter {
final Date date = (Date) operand;
- final DateFormat format = DateUtils.createDateFormat("yyyy-MM-dd HH:mm:ss");
+ final DateFormat format = DateUtils.createDateFormat("yyyyMMdd HH:mm:ss");
final String dateTimeValue = "CAST('" + format.format(date) + "' AS DATETIME)";
sb.append(dateTimeValue);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5f09375f/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java b/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
index 9b588ab..7d75dc1 100644
--- a/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
@@ -87,7 +87,7 @@ public class SQLServerQueryRewriterTest extends TestCase {
.toDate("2014-06-28 14:06:00")));
assertEquals(
- "SELECT MY_SCHEMA.\"foo\".\"bar\", timestamp FROM MY_SCHEMA.\"foo\" WHERE timestamp < CAST('2014-06-28 14:06:00' AS DATETIME)",
+ "SELECT MY_SCHEMA.\"foo\".\"bar\", timestamp FROM MY_SCHEMA.\"foo\" WHERE timestamp < CAST('20140628 14:06:00' AS DATETIME)",
qr.rewriteQuery(q));
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5f09375f/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java
----------------------------------------------------------------------
diff --git a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java
index 2df17cc..0c1c113 100644
--- a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java
+++ b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java
@@ -105,6 +105,7 @@ final class SalesforceTable extends AbstractTable {
case _int:
return ColumnType.INTEGER;
case _double:
+ case currency:
return ColumnType.DOUBLE;
case date:
return ColumnType.DATE;
@@ -120,7 +121,6 @@ final class SalesforceTable extends AbstractTable {
case textarea:
case encryptedstring:
case base64:
- case currency:
case id:
case picklist:
return ColumnType.VARCHAR;
[35/43] metamodel git commit: METAMODEL-1132: Fixed
Posted by ka...@apache.org.
METAMODEL-1132: Fixed
Fixes #137
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/95fa617d
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/95fa617d
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/95fa617d
Branch: refs/heads/5.x
Commit: 95fa617db5c9c5afe3c63155c64c2cc99f0c832b
Parents: 05bbaf7
Author: rposkocil <r....@gmc.net>
Authored: Wed Dec 21 08:47:47 2016 +0100
Committer: Dennis Du Krøger <lo...@apache.org>
Committed: Wed Dec 21 08:49:47 2016 +0100
----------------------------------------------------------------------
CHANGES.md | 1 +
.../apache/metamodel/jdbc/JdbcDataContext.java | 20 +++-
.../jdbc/dialects/AbstractQueryRewriter.java | 22 +++++
.../jdbc/dialects/OffsetFetchQueryRewriter.java | 69 ++++++++++++++
.../jdbc/dialects/OracleQueryRewriter.java | 8 +-
.../jdbc/dialects/SQLServerQueryRewriter.java | 11 +--
.../dialects/SQLServerQueryRewriterTest.java | 17 +++-
.../jdbc/dialects/OracleQueryRewriterTest.java | 99 +++++++++++++++++++-
8 files changed, 230 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 5d8f394..427ac21 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,6 @@
### Apache MetaModel 4.5.5
+ * [METAMODEL-1132] - Support native paging on SQL Server and Oracle database.
* [METAMODEL-1128] - Fixed bug pertaining to ElasticSearch REST data set scrolling.
* [METAMODEL-1118] - Fixed bug pertaining to cloning of FilterItem.LogicalOperator in compiled queries.
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
index 8cd027b..ef0b549 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
@@ -112,6 +112,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
*/
private IQueryRewriter _queryRewriter;
private final String _databaseProductName;
+ private final String _databaseVersion;
/**
* There are some confusion as to the definition of catalogs and schemas.
@@ -183,6 +184,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
boolean supportsBatchUpdates = false;
String identifierQuoteString = null;
String databaseProductName = null;
+ String databaseVersion = null;
boolean usesCatalogsAsSchemas = false;
final Connection con = getConnection();
@@ -210,8 +212,9 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
usesCatalogsAsSchemas = usesCatalogsAsSchemas(metaData);
try {
databaseProductName = metaData.getDatabaseProductName();
+ databaseVersion = metaData.getDatabaseProductVersion();
} catch (SQLException e) {
- logger.warn("Could not retrieve database product name: " + e.getMessage());
+ logger.warn("Could not retrieve metadata: " + e.getMessage());
}
} catch (SQLException e) {
logger.debug("Unexpected exception during JdbcDataContext initialization", e);
@@ -219,6 +222,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
closeIfNecessary(con);
}
_databaseProductName = databaseProductName;
+ _databaseVersion = databaseVersion;
logger.debug("Database product name: {}", _databaseProductName);
if (DATABASE_PRODUCT_MYSQL.equals(_databaseProductName)) {
setQueryRewriter(new MysqlQueryRewriter(this));
@@ -571,7 +575,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
// Retrieve catalogs
logger.debug("Retrieving catalogs");
- List<String> catalogs = new ArrayList<String>();
+ List<String> catalogs = new ArrayList<>();
try {
rs = metaData.getCatalogs();
while (rs.next()) {
@@ -754,7 +758,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
private Set<String> getSchemaSQLServerNames(DatabaseMetaData metaData) throws SQLException {
// Distinct schema names. metaData.getTables() is a denormalized
// resultset
- Set<String> schemas = new HashSet<String>();
+ Set<String> schemas = new HashSet<>();
ResultSet rs = metaData.getTables(_catalogName, null, null, JdbcUtils.getTableTypesAsStrings(_tableTypes));
while (rs.next()) {
schemas.add(rs.getString("TABLE_SCHEM"));
@@ -783,7 +787,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
Connection connection = getConnection();
try {
DatabaseMetaData metaData = connection.getMetaData();
- Collection<String> result = new ArrayList<String>();
+ Collection<String> result = new ArrayList<>();
if (DATABASE_PRODUCT_SQLSERVER.equals(_databaseProductName)) {
result = getSchemaSQLServerNames(metaData);
@@ -887,4 +891,12 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
public String getCatalogName() {
return _catalogName;
}
+
+ public String getDatabaseProductName() {
+ return _databaseProductName;
+ }
+
+ public String getDatabaseVersion() {
+ return _databaseVersion;
+ }
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/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 98c8369..7092052 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
@@ -460,4 +460,26 @@ public abstract class AbstractQueryRewriter implements IQueryRewriter {
}
return resultSet.getObject(columnIndex);
}
+
+ protected boolean isSupportedVersion(String databaseProductName, int databaseVersion) {
+
+ if(databaseProductName.equals(_dataContext.getDatabaseProductName())
+ && databaseVersion <= getDatabaseMajorVersion(_dataContext.getDatabaseVersion())) {
+ return true;
+ }
+ return false;
+ }
+
+ private int getDatabaseMajorVersion(String version) {
+ int firstDot = -1;
+ if(version != null) {
+ version = version.replaceAll("[^0-9.]+", "");
+ firstDot = version.indexOf('.');
+ }
+ if(firstDot >= 0) {
+ return Integer.valueOf(version.substring(0, firstDot));
+ } else {
+ return 0;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OffsetFetchQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OffsetFetchQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OffsetFetchQueryRewriter.java
new file mode 100644
index 0000000..9e14243
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OffsetFetchQueryRewriter.java
@@ -0,0 +1,69 @@
+/**
+ * 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.jdbc.dialects;
+
+import org.apache.metamodel.jdbc.JdbcDataContext;
+import org.apache.metamodel.query.Query;
+
+/**
+ * Query rewriter for databases that support OFFSET and FETCH keywords for max
+ * rows and first row properties.
+ */
+public abstract class OffsetFetchQueryRewriter extends DefaultQueryRewriter {
+
+ private final String databaseProductName;
+ private final int databaseSupportedVersion;
+
+ public OffsetFetchQueryRewriter(JdbcDataContext dataContext, int minSupportedVersion) {
+ super(dataContext);
+ databaseProductName = dataContext.getDatabaseProductName();
+ databaseSupportedVersion = minSupportedVersion;
+ }
+
+ @Override
+ public final boolean isFirstRowSupported() {
+ return true;
+ }
+
+ @Override
+ public final boolean isMaxRowsSupported() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * If the Max rows and First row property of the query is set, then we
+ * will use the database's "OFFSET i ROWS FETCH NEXT j ROWS ONLY" construct.
+ */
+ @Override
+ public String rewriteQuery(Query query) {
+ String queryString = super.rewriteQuery(query);
+ if(isSupportedVersion(databaseProductName, databaseSupportedVersion)) {
+ Integer maxRows = query.getMaxRows();
+ Integer firstRow = query.getFirstRow();
+ if (maxRows != null && firstRow != null && queryString.indexOf("ORDER BY") >= 0 ) {
+ queryString = queryString.replaceAll("TOP [0-9]+", "");
+ queryString = queryString + " OFFSET " + (firstRow-1) + " ROWS FETCH NEXT " + maxRows + " ROWS ONLY";
+ }
+ }
+ return queryString;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
index 305dbb8..647035e 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
@@ -18,6 +18,8 @@
*/
package org.apache.metamodel.jdbc.dialects;
+import static org.apache.metamodel.jdbc.JdbcDataContext.DATABASE_PRODUCT_ORACLE;
+
import org.apache.metamodel.jdbc.JdbcDataContext;
import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.schema.ColumnType;
@@ -25,10 +27,12 @@ import org.apache.metamodel.schema.ColumnType;
/**
* Query rewriter for Oracle
*/
-public class OracleQueryRewriter extends DefaultQueryRewriter {
+public class OracleQueryRewriter extends OffsetFetchQueryRewriter {
+
+ public static final int FIRST_FETCH_SUPPORTING_VERSION = 12;
public OracleQueryRewriter(JdbcDataContext dataContext) {
- super(dataContext);
+ super(dataContext, FIRST_FETCH_SUPPORTING_VERSION);
}
@Override
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
index 88bed85..8e17236 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/SQLServerQueryRewriter.java
@@ -31,15 +31,12 @@ import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.util.DateUtils;
-public class SQLServerQueryRewriter extends DefaultQueryRewriter {
+public class SQLServerQueryRewriter extends OffsetFetchQueryRewriter {
- public SQLServerQueryRewriter(JdbcDataContext dataContext) {
- super(dataContext);
- }
+ public static final int FIRST_FETCH_SUPPORTING_VERSION = 11;
- @Override
- public boolean isMaxRowsSupported() {
- return true;
+ public SQLServerQueryRewriter(JdbcDataContext dataContext) {
+ super(dataContext, FIRST_FETCH_SUPPORTING_VERSION);
}
/**
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java b/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
index 7d75dc1..86f9828 100644
--- a/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/dialects/SQLServerQueryRewriterTest.java
@@ -18,8 +18,14 @@
*/
package org.apache.metamodel.dialects;
+import static org.apache.metamodel.jdbc.JdbcDataContext.DATABASE_PRODUCT_SQLSERVER;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+
import junit.framework.TestCase;
+import org.apache.metamodel.jdbc.JdbcDataContext;
import org.apache.metamodel.jdbc.dialects.SQLServerQueryRewriter;
import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.query.FromItem;
@@ -31,12 +37,13 @@ import org.apache.metamodel.schema.MutableColumn;
import org.apache.metamodel.schema.MutableSchema;
import org.apache.metamodel.schema.MutableTable;
import org.apache.metamodel.util.TimeComparator;
+import org.easymock.EasyMock;
public class SQLServerQueryRewriterTest extends TestCase {
private MutableTable table;
private MutableColumn column;
- private SQLServerQueryRewriter qr = new SQLServerQueryRewriter(null);
+ private SQLServerQueryRewriter qr;
@Override
protected void setUp() throws Exception {
@@ -47,6 +54,14 @@ public class SQLServerQueryRewriterTest extends TestCase {
column = new MutableColumn("bar");
column.setQuote("\"");
column.setTable(table);
+
+ final JdbcDataContext mockContext = EasyMock.createMock(JdbcDataContext.class);
+ EasyMock.expect(mockContext.getDatabaseProductName()).andReturn(DATABASE_PRODUCT_SQLSERVER).anyTimes();
+ EasyMock.expect(mockContext.getDatabaseVersion()).andReturn("12.1.1.1").anyTimes();
+ EasyMock.expect(mockContext.getIdentifierQuoteString()).andReturn("quoteString").anyTimes();
+
+ EasyMock.replay(mockContext);
+ qr = new SQLServerQueryRewriter(mockContext);
}
public void testRewriteColumnTypeDouble() throws Exception {
http://git-wip-us.apache.org/repos/asf/metamodel/blob/95fa617d/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
index 88f0a50..a36a4ba 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
@@ -18,18 +18,35 @@
*/
package org.apache.metamodel.jdbc.dialects;
+import static org.apache.metamodel.jdbc.JdbcDataContext.DATABASE_PRODUCT_ORACLE;
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+
+import org.apache.metamodel.jdbc.JdbcDataContext;
import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.query.OperatorType;
+import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.SelectItem;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
public class OracleQueryRewriterTest {
+ private static final JdbcDataContext mockContext = EasyMock.createMock(JdbcDataContext.class);
+
+ @BeforeClass
+ public static void initMocks() throws SQLException {
+ setMetaData(DATABASE_PRODUCT_ORACLE, "R12.1.1.1");
+ }
+
@Test
public void testReplaceEmptyStringWithNull() throws Exception {
- final OracleQueryRewriter rewriter = new OracleQueryRewriter(null);
+ final OracleQueryRewriter rewriter = new OracleQueryRewriter(mockContext);
final String alias = "alias";
SelectItem selectItem = new SelectItem("expression", alias);
final FilterItem filterItem = new FilterItem(selectItem, OperatorType.DIFFERENT_FROM, "");
@@ -38,4 +55,80 @@ public class OracleQueryRewriterTest {
assertEquals(expectedValue, rewrittenValue);
}
+
+ @Test
+ public void testOffsetFetchConstruct() {
+ final OracleQueryRewriter rewriter = new OracleQueryRewriter(mockContext);
+ final int offset = 1000;
+ final int rows = 100;
+ final String table = "table";
+ final String where = "x > 1";
+
+ Query query = new Query();
+ query.from(table).orderBy("id");
+ final String queryWithoutBoth = query.toSql();
+ Assert.assertEquals("Original SQL is not correctly generated.", " FROM table ORDER BY id ASC", queryWithoutBoth);
+ final String queryWithoutBothRewritten = rewriter.rewriteQuery(query);
+ Assert.assertEquals("There shouldn't be OFFSET-FETCH clause.", queryWithoutBoth, queryWithoutBothRewritten);
+
+ query.setFirstRow(offset);
+ final String queryWithoutMax = query.toSql();
+ Assert.assertEquals("Original SQL is not correctly generated.", " FROM table ORDER BY id ASC", queryWithoutMax);
+ final String queryWithoutMaxRewritten = rewriter.rewriteQuery(query);
+ Assert.assertEquals("There shouldn't be OFFSET-FETCH clause.", queryWithoutMax, queryWithoutMaxRewritten);
+
+ query.setMaxRows(rows).where(where);
+ final String originalQuery = query.toSql();
+ Assert.assertEquals("Original SQL is not correctly generated.", " FROM table WHERE x > 1 ORDER BY id ASC", originalQuery);
+
+ String rewrittenQuery = rewriter.rewriteQuery(query);
+ final String offsetFetchClause = " OFFSET " + (offset-1) + " ROWS FETCH NEXT " + rows + " ROWS ONLY";
+ Assert.assertEquals("Not correctly generated Offset Fetch clouse.", originalQuery + offsetFetchClause, rewrittenQuery);
+ }
+
+ @Test
+ public void testOffsetFetchVersionCheck() throws SQLException {
+ setMetaData(DATABASE_PRODUCT_ORACLE, "10.1.1.1");
+
+ final int offset = 1000;
+ final int rows = 100;
+ final String table = "table";
+
+ Query query = new Query();
+ query.from(table).setFirstRow(offset).setMaxRows(rows);
+ final String originalQuery = query.toSql();
+ Assert.assertEquals("Original SQL is not correctly generated.", " FROM table", originalQuery);
+
+ final OracleQueryRewriter rewriter = new OracleQueryRewriter(mockContext);
+ String rewrittenQuery = rewriter.rewriteQuery(query);
+ Assert.assertEquals("The query shouldn't be rewritten.", originalQuery, rewrittenQuery);
+ }
+
+ @Test
+ public void testOffsetFetchVersionIsNull() throws SQLException {
+ setMetaData(DATABASE_PRODUCT_ORACLE, null);
+
+ final int offset = 1000;
+ final int rows = 100;
+ final String table = "table";
+
+ Query query = new Query();
+ query.from(table).setFirstRow(offset).setMaxRows(rows);
+ final String originalQuery = query.toSql();
+ Assert.assertEquals("Original SQL is not correctly generated.", " FROM table", originalQuery);
+
+ final OracleQueryRewriter rewriter = new OracleQueryRewriter(mockContext);
+ String rewrittenQuery = rewriter.rewriteQuery(query);
+ Assert.assertEquals("The query shouldn't be rewritten.", originalQuery, rewrittenQuery);
+ }
+
+ private static void setMetaData(String productName, String version) throws SQLException {
+ EasyMock.reset(mockContext);
+
+ EasyMock.expect(mockContext.getDatabaseProductName()).andReturn(productName).anyTimes();
+ EasyMock.expect(mockContext.getDatabaseVersion()).andReturn(version).anyTimes();
+ EasyMock.expect(mockContext.getIdentifierQuoteString()).andReturn("quoteString").anyTimes();
+
+ EasyMock.replay(mockContext);
+ }
}
\ No newline at end of file
[29/43] metamodel git commit: METAMODEL-1128: Fixed
Posted by ka...@apache.org.
METAMODEL-1128: Fixed
Fixes #136
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/f18ae8b7
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/f18ae8b7
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/f18ae8b7
Branch: refs/heads/5.x
Commit: f18ae8b75f5baf4832a3c1942a9fd82373fa7355
Parents: 11710af
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Nov 11 13:38:28 2016 -0800
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Nov 11 13:38:28 2016 -0800
----------------------------------------------------------------------
.../rest/ElasticSearchRestDataContext.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f18ae8b7/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 b55db13..920217f 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
@@ -95,6 +95,9 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
// 1 minute timeout
public static final String TIMEOUT_SCROLL = "1m";
+ // we scroll when more than 400 rows are expected
+ private static final int SCROLL_THRESHOLD = 400;
+
private final JestClient elasticSearchClient;
private final String indexName;
@@ -265,13 +268,18 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
if (queryBuilder != null) {
// where clause can be pushed down to an ElasticSearch query
SearchSourceBuilder searchSourceBuilder = createSearchRequest(firstRow, maxRows, queryBuilder);
- SearchResult result = executeSearch(table, searchSourceBuilder, false);
+ SearchResult result = executeSearch(table, searchSourceBuilder, scrollNeeded(maxRows));
return new JestElasticSearchDataSet(elasticSearchClient, result, selectItems);
}
return super.materializeMainSchemaTable(table, selectItems, whereItems, firstRow, maxRows);
}
+ private boolean scrollNeeded(int maxRows) {
+ // if either we don't know about max rows or max rows is set higher than threshold
+ return !limitMaxRowsIsSet(maxRows) || maxRows > SCROLL_THRESHOLD;
+ }
+
private SearchResult executeSearch(Table table, SearchSourceBuilder searchSourceBuilder, boolean scroll) {
Search.Builder builder = new Search.Builder(searchSourceBuilder.toString()).addIndex(getIndexName()).addType(
table.getName());
@@ -292,7 +300,7 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
@Override
protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
- SearchResult searchResult = executeSearch(table, createSearchRequest(1, maxRows, null), limitMaxRowsIsSet(
+ SearchResult searchResult = executeSearch(table, createSearchRequest(1, maxRows, null), scrollNeeded(
maxRows));
return new JestElasticSearchDataSet(elasticSearchClient, searchResult, columns);
@@ -306,6 +314,8 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
}
if (limitMaxRowsIsSet(maxRows)) {
searchRequest.size(maxRows);
+ } else {
+ searchRequest.size(Integer.MAX_VALUE);
}
if (queryBuilder != null) {
[33/43] metamodel git commit: [maven-release-plugin] prepare release
MetaModel-4.5.5
Posted by ka...@apache.org.
[maven-release-plugin] prepare release MetaModel-4.5.5
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/7587b6ac
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/7587b6ac
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/7587b6ac
Branch: refs/heads/5.x
Commit: 7587b6aca46c1e5351c79cc60a83503548efd14b
Parents: 3f4c6d3
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sun Nov 13 11:09:38 2016 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sun Nov 13 11:09:38 2016 -0800
----------------------------------------------------------------------
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/7587b6ac/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 27e2753..0649d06 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-cassandra</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 2c1a57d..7a36028 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index 720c521..fb3c8fd 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-couchdb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index b234fb7..ba5b874 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-csv</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index e978223..0778224 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 568d53b..937f08e 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index f375e33..506a669 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-elasticsearch</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index a9db222..1f86308 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 089b1dc..3d4562d 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-excel</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index b859010..27e5d77 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-fixedwidth</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index d11d945..14bb1fc 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-full</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index c5879e4..2cf2530 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hadoop</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 08fdfe2..24368c1 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hbase</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index e9164fc..581f9b8 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-jdbc</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 251867b..f175891 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-json</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index fd02cdf..a21b75f 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-common</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 23fae1d..aefa65a 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo2</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 2237efd..728e4fd 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo3</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index a39b47e..1049d86 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index d60d270..c67bc58 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-neo4j</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index b9cab19..ad5b2b8 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-openoffice</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 76e236d..71c0b37 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-pojo</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b7b71c9..49aaf0e 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.5</tag>
</scm>
<groupId>org.apache.metamodel</groupId>
<artifactId>MetaModel</artifactId>
- <version>4.5.5-SNAPSHOT</version>
+ <version>4.5.5</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/7587b6ac/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 307833e..891e22d 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-salesforce</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index 7060d3a..f7aaf42 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-spring</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 103703b..d7a89ff 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-sugarcrm</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7587b6ac/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index f3efc83..2a41c6c 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.5-SNAPSHOT</version>
+ <version>4.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-xml</artifactId>
[12/43] metamodel git commit: METAMODEL-1111: Fixed
Posted by ka...@apache.org.
METAMODEL-1111: Fixed
Fixes #123
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/d2eee32d
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/d2eee32d
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/d2eee32d
Branch: refs/heads/5.x
Commit: d2eee32dea67ae5e373ce8a3ca37ec4e794f2cd0
Parents: 7e355a1
Author: Jakub Horcicka <ja...@humaninference.com>
Authored: Tue Aug 9 08:29:53 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Aug 9 08:29:53 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 4 ++
.../jdbc/dialects/OracleQueryRewriter.java | 11 ++++++
.../jdbc/dialects/OracleQueryRewriterTest.java | 41 ++++++++++++++++++++
3 files changed, 56 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/d2eee32d/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index d3d7506..a27fa50 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,7 @@
+### Apache MetaModel 4.5.5
+
+ * [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
+
### Apache MetaModel 4.5.4
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/d2eee32d/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
index cad357b..305dbb8 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriter.java
@@ -19,6 +19,7 @@
package org.apache.metamodel.jdbc.dialects;
import org.apache.metamodel.jdbc.JdbcDataContext;
+import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.schema.ColumnType;
/**
@@ -77,4 +78,14 @@ public class OracleQueryRewriter extends DefaultQueryRewriter {
}
return super.rewriteColumnType(columnType, columnSize);
}
+
+ @Override
+ public String rewriteFilterItem(final FilterItem item) {
+ if (item.getOperand() instanceof String && item.getOperand().equals("")) {
+ // In Oracle empty strings are treated as null. Typical SQL constructs with an empty string do not work.
+ return super.rewriteFilterItem(new FilterItem(item.getSelectItem(), item.getOperator(), null));
+ } else {
+ return super.rewriteFilterItem(item);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/d2eee32d/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
new file mode 100644
index 0000000..88f0a50
--- /dev/null
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/OracleQueryRewriterTest.java
@@ -0,0 +1,41 @@
+/**
+ * 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.jdbc.dialects;
+
+import org.apache.metamodel.query.FilterItem;
+import org.apache.metamodel.query.OperatorType;
+import org.apache.metamodel.query.SelectItem;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class OracleQueryRewriterTest {
+
+ @Test
+ public void testReplaceEmptyStringWithNull() throws Exception {
+ final OracleQueryRewriter rewriter = new OracleQueryRewriter(null);
+ final String alias = "alias";
+ SelectItem selectItem = new SelectItem("expression", alias);
+ final FilterItem filterItem = new FilterItem(selectItem, OperatorType.DIFFERENT_FROM, "");
+ final String rewrittenValue = rewriter.rewriteFilterItem(filterItem);
+ final String expectedValue = alias + " IS NOT NULL";
+
+ assertEquals(expectedValue, rewrittenValue);
+ }
+}
\ No newline at end of file
[16/43] metamodel git commit: METAMODEL-1115: Fixed by exposing new
SalesforceDataContext constructor
Posted by ka...@apache.org.
METAMODEL-1115: Fixed by exposing new SalesforceDataContext constructor
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/e5fb93a0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/e5fb93a0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/e5fb93a0
Branch: refs/heads/5.x
Commit: e5fb93a0cba347faf3d42337bae1e844f82305b1
Parents: 73b70b9
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sun Aug 21 21:15:21 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sun Aug 21 21:26:06 2016 -0700
----------------------------------------------------------------------
salesforce/pom.xml | 12 +---------
.../salesforce/SalesforceDataContext.java | 24 ++++++++++++++++++++
2 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/e5fb93a0/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index c6d5ed7..307833e 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -36,17 +36,7 @@ under the License.
<dependency>
<groupId>com.force.api</groupId>
<artifactId>force-partner-api</artifactId>
- <version>24.0.0</version>
- <exclusions>
- <exclusion>
- <artifactId>gson</artifactId>
- <groupId>com.google.code.gson</groupId>
- </exclusion>
- <exclusion>
- <artifactId>js</artifactId>
- <groupId>rhino</groupId>
- </exclusion>
- </exclusions>
+ <version>35.0.1</version>
</dependency>
<!-- provided -->
http://git-wip-us.apache.org/repos/asf/metamodel/blob/e5fb93a0/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java
----------------------------------------------------------------------
diff --git a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java
index c8add52..e1f95aa 100644
--- a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java
+++ b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java
@@ -94,6 +94,30 @@ public class SalesforceDataContext extends QueryPostprocessDataContext implement
}
}
+ /**
+ * Creates a {@code SalesforceDataContext} instance , configured with given
+ * salesforce connection.
+ *
+ * @param connection
+ * salesforce connection (cannot be {@code null}).
+ *
+ */
+ public SalesforceDataContext(PartnerConnection connection) {
+ if (connection == null) {
+ throw new IllegalArgumentException("connection cannot be null");
+ }
+ _connection = connection;
+ }
+
+ /**
+ * Returns the Salesforce connection being used by this datacontext.
+ *
+ * @return the Salesforce connection
+ */
+ public PartnerConnection getConnection() {
+ return _connection;
+ }
+
@Override
protected Schema getMainSchema() throws MetaModelException {
final SalesforceSchema schema = new SalesforceSchema(getMainSchemaName(), _connection);
[42/43] 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/b0cfe3ae
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/b0cfe3ae
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/b0cfe3ae
Branch: refs/heads/5.x
Commit: b0cfe3aed447769f752743ac1753ebed90adaad2
Parents: 5a5f750
Author: Kasper Sørensen <i....@gmail.com>
Authored: Tue Jan 31 13:10:34 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Tue Jan 31 13:10:34 2017 -0800
----------------------------------------------------------------------
cassandra/pom.xml | 2 +-
core/pom.xml | 2 +-
couchdb/pom.xml | 2 +-
csv/pom.xml | 2 +-
dynamodb/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 +-
28 files changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index a85b0d4..af8c914 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-cassandra</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index de4726d..a4e0f8e 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index a481373..e9569a8 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-couchdb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index 1eef467..99945b1 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-csv</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/dynamodb/pom.xml
----------------------------------------------------------------------
diff --git a/dynamodb/pom.xml b/dynamodb/pom.xml
index c1536b8..ec95902 100644
--- a/dynamodb/pom.xml
+++ b/dynamodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-dynamodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index fe4ff29..70625ec 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index d793f85..dfae6ed 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 17cbf8a..e5ee1d8 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-elasticsearch</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 178a299..c0f802a 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 48e851b..83746ce 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-excel</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 40eb3fa..4cf4760 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-fixedwidth</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index d4e7ac3..14fbc92 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-full</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 92bd38a..badc52e 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hadoop</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 781f6ad..963e0b4 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hbase</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 700a8e2..e5f8deb 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-jdbc</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 625a445..943dc03 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
<parent>
<artifactId>MetaModel</artifactId>
<groupId>org.apache.metamodel</groupId>
- <version>4.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-json</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 945da3b..9916ceb 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-common</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 30c4209..a81060b 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo2</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 2307064..8f8380f 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo3</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 27e5fa3..0d0c2da 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 9e450ea..3d38fa8 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-neo4j</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index e5eaca1..28e8ed8 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-openoffice</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 6a370d7..ed9472a 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-pojo</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2ea59fd..65fa153 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.6.0</tag>
+ <tag>HEAD</tag>
</scm>
<groupId>org.apache.metamodel</groupId>
<artifactId>MetaModel</artifactId>
- <version>4.6.0</version>
+ <version>4.6.1-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/b0cfe3ae/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index d03e188..32dee0c 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-salesforce</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index 2eeb3e3..aa97520 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-spring</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 32dbbd9..db4c9bf 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-sugarcrm</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b0cfe3ae/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index bdb5aa3..df80435 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.6.0</version>
+ <version>4.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-xml</artifactId>
[43/43] 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/pom.xml
# elasticsearch/rest/pom.xml
# elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
# excel/pom.xml
# fixedwidth/pom.xml
# fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
# fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
# fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
# full/pom.xml
# hadoop/pom.xml
# hbase/pom.xml
# jdbc/pom.xml
# jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
# json/pom.xml
# mongodb/common/pom.xml
# mongodb/mongo2/pom.xml
# mongodb/mongo3/pom.xml
# mongodb/pom.xml
# 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/c4788a27
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/c4788a27
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/c4788a27
Branch: refs/heads/5.x
Commit: c4788a27270110ee630e0337402f4f48b6147ac1
Parents: 02397db b0cfe3a
Author: Kasper Sørensen <i....@gmail.com>
Authored: Tue May 9 20:40:08 2017 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Tue May 9 20:53:48 2017 -0700
----------------------------------------------------------------------
.gitattributes | 2 +
CHANGES.md | 36 +-
README.md | 77 ++--
cassandra/.gitignore | 1 +
.../cassandra/CassandraDataContext.java | 74 +++-
.../cassandra/CassandraDataContextTest.java | 18 +-
.../metamodel/factory/DataContextFactory.java | 16 +
.../insert/AbstractRowInsertionBuilder.java | 5 +-
.../metamodel/query/DefaultCompiledQuery.java | 2 +-
.../org/apache/metamodel/query/FilterItem.java | 12 +-
.../apache/metamodel/query/OperatorType.java | 6 +-
.../metamodel/query/OperatorTypeImpl.java | 74 ++--
.../query/builder/AbstractFilterBuilder.java | 24 ++
.../builder/AbstractQueryFilterBuilder.java | 21 +
.../metamodel/query/builder/FilterBuilder.java | 22 ++
.../query/builder/GroupedQueryBuilder.java | 5 +
.../builder/GroupedQueryBuilderCallback.java | 16 +
.../query/builder/GroupedQueryBuilderImpl.java | 30 +-
.../query/builder/HavingBuilderImpl.java | 100 +++--
.../query/builder/SatisfiedQueryBuilder.java | 4 +-
.../apache/metamodel/util/WildcardPattern.java | 13 +-
.../ResourceFactoryRegistryImplTest.java | 3 +-
.../insert/AbstractRowInsertionBuilderTest.java | 49 +++
.../apache/metamodel/query/FilterItemTest.java | 28 ++
.../query/builder/SyntaxExamplesTest.java | 5 +
.../query/builder/WhereBuilderImplTest.java | 28 ++
.../metamodel/util/WildcardPatternTest.java | 11 +
.../apache/metamodel/csv/CsvConfiguration.java | 2 +-
.../metamodel/csv/CsvDataContextTest.java | 23 ++
dynamodb/.gitignore | 4 +
dynamodb/pom.xml | 61 +++
.../metamodel/dynamodb/DynamoDbDataContext.java | 306 +++++++++++++++
.../metamodel/dynamodb/DynamoDbDataSet.java | 68 ++++
.../dynamodb/DynamoDbRowInsertionBuilder.java | 57 +++
.../dynamodb/DynamoDbTableCreationBuilder.java | 112 ++++++
.../dynamodb/DynamoDbTableDropBuilder.java | 46 +++
.../dynamodb/DynamoDbUpdateCallback.java | 85 +++++
.../metamodel/dynamodb/DynamoDbUtils.java | 105 +++++
.../DynamoDbDataContextIntegrationTest.java | 211 +++++++++++
.../ElasticSearchDataContextFactory.java | 165 ++++++++
....apache.metamodel.factory.DataContextFactory | 1 +
.../rest/ElasticSearchRestDataContext.java | 24 +-
.../ElasticSearchRestDataContextFactory.java | 106 ++++++
....apache.metamodel.factory.DataContextFactory | 1 +
...del-integrationtest-configuration.properties | 7 +
.../metamodel/excel/ExcelDataContextTest.java | 17 +
fixedwidth/pom.xml | 46 +--
.../fixedwidth/EbcdicConfiguration.java | 67 ++++
.../metamodel/fixedwidth/EbcdicReader.java | 79 ++++
.../fixedwidth/FixedWidthConfiguration.java | 199 +++++-----
.../FixedWidthConfigurationReader.java | 18 +-
.../fixedwidth/FixedWidthDataContext.java | 25 +-
.../metamodel/fixedwidth/FixedWidthDataSet.java | 3 +-
.../fixedwidth/FixedWidthLineParser.java | 121 ++++++
.../metamodel/fixedwidth/FixedWidthReader.java | 379 +++++++++++--------
.../apache/metamodel/fixedwidth/EBCDICTest.java | 95 +++++
.../fixedwidth/FixedWidthConfigurationTest.java | 11 +-
.../fixedwidth/FixedWidthDataContextTest.java | 20 +-
.../fixedwidth/FixedWidthLineParserTest.java | 66 ++++
.../fixedwidth/FixedWidthReaderTest.java | 103 ++++-
.../test/resources/example_diacritics_utf8.txt | 4 +
.../src/test/resources/example_simple3.txt | 4 +
.../test/resources/fixed-width-2-7-10-10.ebc | 1 +
.../apache/metamodel/DataContextFactory.java | 22 +-
jdbc/pom.xml | 13 +-
.../apache/metamodel/jdbc/JdbcDataContext.java | 68 ++--
.../org/apache/metamodel/jdbc/JdbcDataSet.java | 53 +--
.../metamodel/jdbc/JdbcDeleteBuilder.java | 2 +-
.../metamodel/jdbc/JdbcInsertBuilder.java | 2 +-
.../metamodel/jdbc/JdbcUpdateBuilder.java | 4 +-
.../org/apache/metamodel/jdbc/JdbcUtils.java | 140 +------
.../org/apache/metamodel/jdbc/SqlKeywords.java | 69 ++--
.../jdbc/dialects/AbstractQueryRewriter.java | 197 +++++++++-
.../jdbc/dialects/DB2QueryRewriter.java | 2 +-
.../jdbc/dialects/DefaultQueryRewriter.java | 9 +-
.../jdbc/dialects/HiveQueryRewriter.java | 12 +-
.../metamodel/jdbc/dialects/IQueryRewriter.java | 30 ++
.../jdbc/dialects/MysqlQueryRewriter.java | 2 +-
.../jdbc/dialects/OffsetFetchQueryRewriter.java | 69 ++++
.../jdbc/dialects/OracleQueryRewriter.java | 19 +-
.../jdbc/dialects/PostgresqlQueryRewriter.java | 69 +++-
.../jdbc/dialects/SQLServerQueryRewriter.java | 13 +-
.../dialects/SQLServerQueryRewriterTest.java | 19 +-
.../metamodel/jdbc/JdbcTestTemplates.java | 22 ++
.../jdbc/dialects/OracleQueryRewriterTest.java | 134 +++++++
.../dialects/PostgresqlQueryRewriterTest.java | 49 +++
.../integrationtests/HiveIntegrationTest.java | 69 +++-
.../jdbc/integrationtests/PostgresqlTest.java | 102 +++--
pom.xml | 3 +
salesforce/pom.xml | 12 +-
.../salesforce/SalesforceDataContext.java | 24 ++
.../metamodel/salesforce/SalesforceTable.java | 2 +-
92 files changed, 3763 insertions(+), 792 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/CHANGES.md
----------------------------------------------------------------------
diff --cc CHANGES.md
index bb64682,ebc7e66..3356b5d
--- a/CHANGES.md
+++ b/CHANGES.md
@@@ -1,12 -1,31 +1,37 @@@
+### 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.
+ * [METAMODEL-1087] - Removed deprecated APIs from MetaModel's codebase.
+
- ### Apache MetaModel 4.5.4 (work in progress)
+ ### Apache MetaModel 4.6.0
+
+ * [METAMODEL-1136] - New connector for Amazon DynamoDB.
+ * [METAMODEL-1134] - Added NOT IN and NOT LIKE operators to WHERE filters.
+ * [METAMODEL-1133] - Made PojoDataContext thread-safe.
+
+ ### Apache MetaModel 4.5.5
+
+ * [METAMODEL-1132] - Support native paging on SQL Server and Oracle database.
+ * [METAMODEL-1128] - Fixed bug pertaining to ElasticSearch REST data set scrolling.
+ * [METAMODEL-1118] - Fixed bug pertaining to cloning of FilterItem.LogicalOperator in compiled queries.
+ * [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
+ * [METAMODEL-1122] - Optimized the way the Cassandra module executes primary key lookup queries.
+ * [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
+ * [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
+ * [METAMODEL-1113] - Fixed support for ColumnNamingStrategy in CSV connector.
+ * [METAMODEL-1114] - Added support for ColumnNamingStrategy in EBCDIC connector.
+ * [METAMODEL-1119] - Worked around Hive JDBC driver issues, avoiding non-compliant metadata calls.
+ * [METAMODEL-1123] - Fixed the treatment of a Salesforce.com 'currency' value as a number, not a string.
+ * [METAMODEL-1124] - Fixed the date formatting of date values in MS SQL server.
+ * [METAMODEL-1127] - Fixed setting of null Map on postgres
+
+ ### Apache MetaModel 4.5.4
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
+ * [METAMODEL-1099] - Implemented DataContextFactory SPI for connectors: JDBC, CSV, ElasticSearch
+ * [METAMODEL-250] - Added support for EBCDIC files (part of 'fixedwidth' module).
+ * [METAMODEL-1103] - Fixed a bug pertaining to anchoring of wildcards in LIKE operands.
* [METAMODEL-1088] - Add support for aliases in MongoDB.
* [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
* [METAMODEL-1094] - Added support for Apache Cassandra version 3.x.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/core/src/main/java/org/apache/metamodel/query/FilterItem.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/core/src/main/java/org/apache/metamodel/query/builder/AbstractFilterBuilder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/core/src/main/java/org/apache/metamodel/query/builder/AbstractQueryFilterBuilder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/core/src/main/java/org/apache/metamodel/query/builder/FilterBuilder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/dynamodb/pom.xml
----------------------------------------------------------------------
diff --cc dynamodb/pom.xml
index 0000000,ec95902..1de0cb3
mode 000000,100644..100644
--- a/dynamodb/pom.xml
+++ b/dynamodb/pom.xml
@@@ -1,0 -1,61 +1,61 @@@
+ <?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.6.1-SNAPSHOT</version>
++ <version>5.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>MetaModel-dynamodb</artifactId>
+ <name>MetaModel module for Amazon AWS DynamoDB.</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.metamodel</groupId>
+ <artifactId>MetaModel-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk-dynamodb</artifactId>
+ <version>1.11.81</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </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/c4788a27/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
----------------------------------------------------------------------
diff --cc excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
index eef29ae,f8406c3..ecd6691
--- a/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
+++ b/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
@@@ -34,13 -36,11 +34,14 @@@ import org.apache.metamodel.query.Query
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+ import org.apache.metamodel.schema.naming.CustomColumnNamingStrategy;
import org.apache.metamodel.util.DateUtils;
import org.apache.metamodel.util.FileHelper;
+import org.apache.metamodel.util.FileResource;
import org.apache.metamodel.util.Month;
+import junit.framework.TestCase;
+
public class ExcelDataContextTest extends TestCase {
/**
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/fixedwidth/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
----------------------------------------------------------------------
diff --cc fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
index 28ee300,027cdab..952c4b5
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
@@@ -69,9 -89,24 +69,9 @@@ public class FixedWidthDataContext exte
}
/**
- * Gets the file being read.
- *
- * @return a file
- *
- * @deprecated use {@link #getResource()} instead.
- */
- @Deprecated
- public File getFile() {
- if (_resource instanceof FileResource) {
- return ((FileResource) _resource).getFile();
- }
- return null;
- }
-
- /**
* Gets the resource being read
*
- * @return
+ * @return a {@link Resource} object
*/
public Resource getResource() {
return _resource;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDeleteBuilder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcInsertBuilder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateBuilder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
----------------------------------------------------------------------
diff --cc jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
index ef3ae28,2668df9..6f8fb09
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
@@@ -22,8 -22,9 +22,10 @@@ import java.lang.reflect.Method
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.util.Arrays;
+ import java.util.HashMap;
import java.util.List;
+import java.util.Optional;
+ import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.swing.table.TableModel;
@@@ -434,42 -478,6 +481,42 @@@ public class PostgresqlTest extends Abs
}
}
+ public void testGetGeneratedKeys() throws Exception {
+ if (!isConfigured()) {
+ return;
+ }
+
+ final JdbcDataContext dc = new JdbcDataContext(getConnection());
+ final Schema schema = dc.getDefaultSchema();
+ final String tableName = "my_table_with_generated_keys";
+
+ if (schema.getTableByName(tableName) != null) {
+ dc.executeUpdate(new DropTable(schema, tableName));
+ }
+
+ final UpdateSummary updateSummary = dc.executeUpdate(new UpdateScript() {
+ @Override
+ public void run(UpdateCallback cb) {
+ Table table = cb.createTable(schema, tableName).withColumn("id").ofType(ColumnType.INTEGER)
+ .ofNativeType("SERIAL").nullable(false).asPrimaryKey().withColumn("foo").ofType(
+ ColumnType.STRING).execute();
+ assertEquals(tableName, table.getName());
+
+ cb.insertInto(table).value("foo", "hello").execute();
+ cb.insertInto(table).value("foo", "world").execute();
+ }
+ });
+
+ final Optional<Integer> insertedRows = updateSummary.getInsertedRows();
+ assertTrue(insertedRows.isPresent());
+ assertEquals(2, insertedRows.get().intValue());
+
+ final Optional<Iterable<Object>> generatedKeys = updateSummary.getGeneratedKeys();
+ assertTrue(generatedKeys.isPresent());
+ assertEquals("[1, 2]", generatedKeys.get().toString());
+
+ }
-
++
public void testBlob() throws Exception {
if (!isConfigured()) {
return;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/salesforce/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/c4788a27/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java
----------------------------------------------------------------------
[05/43] metamodel git commit: METAMODEL-1099: Implemented
DataContextFactory SPI for ElasticSearch
Posted by ka...@apache.org.
METAMODEL-1099: Implemented DataContextFactory SPI for ElasticSearch
Closes #118
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/f35bfed0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/f35bfed0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/f35bfed0
Branch: refs/heads/5.x
Commit: f35bfed081f4c54226e8b0d60a8c161e0c35dd6a
Parents: ae5ec80
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Jul 29 08:38:49 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Jul 29 08:38:49 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../metamodel/factory/DataContextFactory.java | 16 ++
.../ElasticSearchDataContextFactory.java | 165 +++++++++++++++++++
....apache.metamodel.factory.DataContextFactory | 1 +
.../rest/ElasticSearchRestDataContext.java | 61 ++++---
.../ElasticSearchRestDataContextFactory.java | 106 ++++++++++++
....apache.metamodel.factory.DataContextFactory | 1 +
7 files changed, 324 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 4f61177..bd2cec8 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,7 @@
### Apache MetaModel 4.5.4 (work in progress)
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
+ * [METAMODEL-1099] - Implemented DataContextFactory SPI for connectors: JDBC, CSV, ElasticSearch
* [METAMODEL-1103] - Fixed a bug pertaining to anchoring of wildcards in LIKE operands.
* [METAMODEL-1088] - Add support for aliases in MongoDB.
* [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java b/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
index b9f8e3e..1a00fa8 100644
--- a/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
@@ -18,9 +18,25 @@
*/
package org.apache.metamodel.factory;
+import java.util.ServiceLoader;
+
import org.apache.metamodel.ConnectionException;
import org.apache.metamodel.DataContext;
+/**
+ * Represents a factory of {@link DataContext} objects. Factories take
+ * {@link DataContextProperties} and turn them into active {@link DataContext}
+ * instances.
+ *
+ * Multiple factories can exist in order to serve different kinds of properties,
+ * thereby offering a dynamic factory mechanism. The collection of factories is
+ * accessible via {@link DataContextFactoryRegistry}.
+ *
+ * These factories are registered via the Java {@link ServiceLoader} SPI API. So
+ * add a file with path
+ * "/META-INF/services/org.apache.metamodel.factory.DataContextFactory" in any
+ * JAR file in order to register another factory.
+ */
public interface DataContextFactory {
public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContextFactory.java
----------------------------------------------------------------------
diff --git a/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContextFactory.java b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContextFactory.java
new file mode 100644
index 0000000..94359c4
--- /dev/null
+++ b/elasticsearch/native/src/main/java/org/apache/metamodel/elasticsearch/nativeclient/ElasticSearchDataContextFactory.java
@@ -0,0 +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.nativeclient;
+
+import org.apache.metamodel.ConnectionException;
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextFactory;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.factory.ResourceFactoryRegistry;
+import org.apache.metamodel.factory.UnsupportedDataContextPropertiesException;
+import org.apache.metamodel.util.SimpleTableDef;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.settings.ImmutableSettings;
+import org.elasticsearch.common.settings.ImmutableSettings.Builder;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeBuilder;
+
+/**
+ * Factory for ElasticSearch data context of native type.
+ *
+ * The factory will activate when DataContext type is specified as
+ * "elasticsearch", "es-node", "elasticsearch-node", "es-transport",
+ * "elasticsearch-transport".
+ *
+ * This factory is configured with the following properties:
+ *
+ * <ul>
+ * <li>clientType (needed if datacontext type is just "elasticsearch" - must be
+ * either "transport" or "node")</li>
+ * <li>hostname (if clientType is "transport")</li>
+ * <li>port (if clientType is "transport")</li>
+ * <li>database (index name)</li>
+ * <li>cluster</li>
+ * <li>username (optional, only available if clientType is "transport")</li>
+ * <li>password (optional, only available if clientType is "transport")</li>
+ * <li>ssl (optional, only available if clientType is "transport")</li>
+ * <li>keystorePath (optional, only available if clientType is "transport")</li>
+ * <li>keystorePassword (optional, only available if clientType is "transport")
+ * </li>
+ * </ul>
+ */
+public class ElasticSearchDataContextFactory implements DataContextFactory {
+
+ @Override
+ public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) {
+ switch (properties.getDataContextType()) {
+ case "elasticsearch":
+ case "es-node":
+ case "elasticsearch-node":
+ case "es-transport":
+ case "elasticsearch-transport":
+ return acceptsInternal(properties);
+ }
+ return false;
+ }
+
+ private boolean acceptsInternal(DataContextProperties properties) {
+ final String clientType = getClientType(properties);
+ if (clientType == null) {
+ return false;
+ }
+ if (!"node".equals(clientType)) {
+ if (properties.getHostname() == null || properties.getPort() == null) {
+ return false;
+ }
+ }
+ if (getIndex(properties) == null) {
+ return false;
+ }
+ if (getCluster(properties) == null) {
+ return false;
+ }
+ return true;
+ }
+
+ private String getClientType(DataContextProperties properties) {
+ switch (properties.getDataContextType()) {
+ case "elasticsearch-node":
+ case "es-node":
+ return "node";
+ case "elasticsearch-transport":
+ case "es-transport":
+ return "transport";
+ }
+ final String clientType = (String) properties.toMap().get("clientType");
+ return clientType;
+ }
+
+ private String getIndex(DataContextProperties properties) {
+ final String databaseName = properties.getDatabaseName();
+ if (databaseName == null) {
+ return (String) properties.toMap().get("index");
+ }
+ return databaseName;
+ }
+
+ private String getCluster(DataContextProperties properties) {
+ return (String) properties.toMap().get("cluster");
+ }
+
+ @Override
+ public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry)
+ throws UnsupportedDataContextPropertiesException, ConnectionException {
+ final String clientType = getClientType(properties);
+ final Client client;
+ if ("node".equals(clientType)) {
+ client = createNodeClient(properties);
+ } else {
+ client = createTransportClient(properties);
+ }
+ final String indexName = getIndex(properties);
+ final SimpleTableDef[] tableDefinitions = properties.getTableDefs();
+ return new ElasticSearchDataContext(client, indexName, tableDefinitions);
+ }
+
+ private Client createTransportClient(DataContextProperties properties) {
+ final Builder settingsBuilder = ImmutableSettings.builder();
+ settingsBuilder.put("name", "MetaModel");
+ settingsBuilder.put("cluster.name", getCluster(properties));
+ if (properties.getUsername() != null && properties.getPassword() != null) {
+ settingsBuilder.put("shield.user", properties.getUsername() + ":" + properties.getPassword());
+ if ("true".equals(properties.toMap().get("ssl"))) {
+ if (properties.toMap().get("keystorePath") != null) {
+ settingsBuilder.put("shield.ssl.keystore.path", properties.toMap().get("keystorePath"));
+ settingsBuilder.put("shield.ssl.keystore.password", properties.toMap().get("keystorePassword"));
+ }
+ settingsBuilder.put("shield.transport.ssl", "true");
+ }
+ }
+ final Settings settings = settingsBuilder.build();
+
+ final TransportClient client = new TransportClient(settings);
+ client.addTransportAddress(new InetSocketTransportAddress(properties.getHostname(), properties.getPort()));
+ return client;
+ }
+
+ private Client createNodeClient(DataContextProperties properties) {
+ final Builder settingsBuilder = ImmutableSettings.builder();
+ settingsBuilder.put("name", "MetaModel");
+ settingsBuilder.put("shield.enabled", false);
+ final Settings settings = settingsBuilder.build();
+ final Node node = NodeBuilder.nodeBuilder().clusterName(getCluster(properties)).client(true).settings(settings)
+ .node();
+ return node.client();
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/elasticsearch/native/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
----------------------------------------------------------------------
diff --git a/elasticsearch/native/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory b/elasticsearch/native/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
new file mode 100644
index 0000000..b33339b
--- /dev/null
+++ b/elasticsearch/native/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
@@ -0,0 +1 @@
+org.apache.metamodel.elasticsearch.nativeclient.ElasticSearchDataContextFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/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 c452d7b..b55db13 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
@@ -20,6 +20,7 @@ package org.apache.metamodel.elasticsearch.rest;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -83,7 +84,9 @@ import io.searchbox.params.Parameters;
* This implementation supports either automatic discovery of a schema or manual
* specification of a schema, through the {@link SimpleTableDef} class.
*/
-public class ElasticSearchRestDataContext extends QueryPostprocessDataContext implements DataContext, UpdateableDataContext {
+public class ElasticSearchRestDataContext extends QueryPostprocessDataContext implements
+ DataContext,
+ UpdateableDataContext {
private static final Logger logger = LoggerFactory.getLogger(ElasticSearchRestDataContext.class);
@@ -95,16 +98,17 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
private final JestClient elasticSearchClient;
private final String indexName;
- // Table definitions that are set from the beginning, not supposed to be changed.
+ // Table definitions that are set from the beginning, not supposed to be
+ // changed.
private final List<SimpleTableDef> staticTableDefinitions;
// Table definitions that are discovered, these can change
private final List<SimpleTableDef> dynamicTableDefinitions = new ArrayList<>();
/**
- * Constructs a {@link ElasticSearchRestDataContext}. This constructor accepts a
- * custom array of {@link SimpleTableDef}s which allows the user to define
- * his own view on the indexes in the engine.
+ * Constructs a {@link ElasticSearchRestDataContext}. This constructor
+ * accepts a custom array of {@link SimpleTableDef}s which allows the user
+ * to define his own view on the indexes in the engine.
*
* @param client
* the ElasticSearch client
@@ -123,13 +127,14 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
}
this.elasticSearchClient = client;
this.indexName = indexName;
- this.staticTableDefinitions = Arrays.asList(tableDefinitions);
+ this.staticTableDefinitions = (tableDefinitions == null || tableDefinitions.length == 0 ? Collections
+ .<SimpleTableDef> emptyList() : Arrays.asList(tableDefinitions));
this.dynamicTableDefinitions.addAll(Arrays.asList(detectSchema()));
}
/**
- * Constructs a {@link ElasticSearchRestDataContext} and automatically detects
- * the schema structure/view on all indexes (see
+ * Constructs a {@link ElasticSearchRestDataContext} and automatically
+ * detects the schema structure/view on all indexes (see
* {@link #detectTable(JsonObject, String)}).
*
* @param client
@@ -158,20 +163,20 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
final GetMapping getMapping = new GetMapping.Builder().addIndex(indexName).build();
jestResult = elasticSearchClient.execute(getMapping);
} catch (Exception e) {
- logger.error("Failed to retrieve mappings" , e);
+ logger.error("Failed to retrieve mappings", e);
throw new MetaModelException("Failed to execute request for index information needed to detect schema", e);
}
- if(!jestResult.isSucceeded()){
+ if (!jestResult.isSucceeded()) {
logger.error("Failed to retrieve mappings; {}", jestResult.getErrorMessage());
throw new MetaModelException("Failed to retrieve mappings; " + jestResult.getErrorMessage());
}
final List<SimpleTableDef> result = new ArrayList<>();
- final Set<Map.Entry<String, JsonElement>> mappings =
- jestResult.getJsonObject().getAsJsonObject(indexName).getAsJsonObject("mappings").entrySet();
- if(mappings.size() == 0){
+ final Set<Map.Entry<String, JsonElement>> mappings = jestResult.getJsonObject().getAsJsonObject(indexName)
+ .getAsJsonObject("mappings").entrySet();
+ if (mappings.size() == 0) {
logger.warn("No metadata returned for index name '{}' - no tables will be detected.");
} else {
@@ -179,7 +184,8 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
final String documentType = entry.getKey();
try {
- final SimpleTableDef table = detectTable(entry.getValue().getAsJsonObject().get("properties").getAsJsonObject(), documentType);
+ final SimpleTableDef table = detectTable(entry.getValue().getAsJsonObject().get("properties")
+ .getAsJsonObject(), documentType);
result.add(table);
} catch (Exception e) {
logger.error("Unexpected error during detectTable for document type '{}'", documentType, e);
@@ -199,8 +205,8 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
/**
* Performs an analysis of an available index type in an ElasticSearch
- * {@link JestClient} client and tries to detect the index structure based on
- * the metadata provided by the java client.
+ * {@link JestClient} client and tries to detect the index structure based
+ * on the metadata provided by the java client.
*
* @param metadataProperties
* the ElasticSearch mapping
@@ -210,8 +216,7 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
*/
private static SimpleTableDef detectTable(JsonObject metadataProperties, String documentType) {
final ElasticSearchMetaData metaData = JestElasticSearchMetaDataParser.parse(metadataProperties);
- return new SimpleTableDef(documentType, metaData.getColumnNames(),
- metaData.getColumnTypes());
+ return new SimpleTableDef(documentType, metaData.getColumnNames(), metaData.getColumnTypes());
}
@Override
@@ -253,10 +258,10 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
}
@Override
- protected DataSet materializeMainSchemaTable(Table table, List<SelectItem> selectItems,
- List<FilterItem> whereItems, int firstRow, int maxRows) {
- final QueryBuilder queryBuilder = ElasticSearchUtils
- .createQueryBuilderForSimpleWhere(whereItems, LogicalOperator.AND);
+ protected DataSet materializeMainSchemaTable(Table table, List<SelectItem> selectItems, List<FilterItem> whereItems,
+ int firstRow, int maxRows) {
+ final QueryBuilder queryBuilder = ElasticSearchUtils.createQueryBuilderForSimpleWhere(whereItems,
+ LogicalOperator.AND);
if (queryBuilder != null) {
// where clause can be pushed down to an ElasticSearch query
SearchSourceBuilder searchSourceBuilder = createSearchRequest(firstRow, maxRows, queryBuilder);
@@ -268,8 +273,9 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
}
private SearchResult executeSearch(Table table, SearchSourceBuilder searchSourceBuilder, boolean scroll) {
- Search.Builder builder = new Search.Builder(searchSourceBuilder.toString()).addIndex(getIndexName()).addType(table.getName());
- if(scroll){
+ Search.Builder builder = new Search.Builder(searchSourceBuilder.toString()).addIndex(getIndexName()).addType(
+ table.getName());
+ if (scroll) {
builder.setParameter(Parameters.SCROLL, TIMEOUT_SCROLL);
}
@@ -277,7 +283,7 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
SearchResult result;
try {
result = elasticSearchClient.execute(search);
- } catch (Exception e){
+ } catch (Exception e) {
logger.warn("Could not execute ElasticSearch query", e);
throw new MetaModelException("Could not execute ElasticSearch query", e);
}
@@ -286,7 +292,8 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
@Override
protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
- SearchResult searchResult = executeSearch(table, createSearchRequest(1, maxRows, null), limitMaxRowsIsSet(maxRows));
+ SearchResult searchResult = executeSearch(table, createSearchRequest(1, maxRows, null), limitMaxRowsIsSet(
+ maxRows));
return new JestElasticSearchDataSet(elasticSearchClient, searchResult, columns);
}
@@ -341,7 +348,7 @@ public class ElasticSearchRestDataContext extends QueryPostprocessDataContext im
CountResult countResult;
try {
countResult = elasticSearchClient.execute(count);
- } catch (Exception e){
+ } catch (Exception e) {
logger.warn("Could not execute ElasticSearch get query", e);
throw new MetaModelException("Could not execute ElasticSearch get query", e);
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContextFactory.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContextFactory.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContextFactory.java
new file mode 100644
index 0000000..b2dc4c3
--- /dev/null
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContextFactory.java
@@ -0,0 +1,106 @@
+/**
+ * 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 org.apache.metamodel.ConnectionException;
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextFactory;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.factory.ResourceFactoryRegistry;
+import org.apache.metamodel.factory.UnsupportedDataContextPropertiesException;
+import org.apache.metamodel.util.SimpleTableDef;
+
+import io.searchbox.client.JestClient;
+import io.searchbox.client.JestClientFactory;
+import io.searchbox.client.config.HttpClientConfig;
+
+/**
+ * Factory for ElasticSearch data context of REST type.
+ *
+ * The factory will activate when DataContext type is specified as
+ * "elasticsearch", "es-rest" or "elasticsearch-rest".
+ *
+ * This factory is configured with the following properties:
+ *
+ * <ul>
+ * <li>url (http or https based base URL of elasticsearch)</li>
+ * <li>database (index name)</li>
+ * <li>username (optional)</li>
+ * <li>password (optional)</li>
+ * </ul>
+ */
+public class ElasticSearchRestDataContextFactory implements DataContextFactory {
+
+ @Override
+ public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) {
+ switch (properties.getDataContextType()) {
+ case "elasticsearch":
+ // ensure that the url is http or https based to infer that this is
+ // a REST based connection
+ final String url = properties.getUrl();
+ return url != null && url.startsWith("http") && acceptsInternal(properties);
+ case "es-rest":
+ case "elasticsearch-rest":
+ return acceptsInternal(properties);
+ }
+ return false;
+ }
+
+ private boolean acceptsInternal(DataContextProperties properties) {
+ if (properties.getUrl() == null) {
+ return false;
+ }
+ if (getIndex(properties) == null) {
+ return false;
+ }
+ return true;
+ }
+
+ private JestClient createClient(DataContextProperties properties) {
+ final String serverUri = properties.getUrl();
+ final HttpClientConfig.Builder builder = new HttpClientConfig.Builder(serverUri);
+ if (properties.getUsername() != null) {
+ builder.defaultCredentials(properties.getUsername(), properties.getPassword());
+ }
+
+ final JestClientFactory clientFactory = new JestClientFactory();
+ final HttpClientConfig httpClientConfig = new HttpClientConfig(builder);
+ clientFactory.setHttpClientConfig(httpClientConfig);
+ final JestClient client = clientFactory.getObject();
+ return client;
+ }
+
+ private String getIndex(DataContextProperties properties) {
+ final String databaseName = properties.getDatabaseName();
+ if (databaseName == null) {
+ properties.toMap().get("index");
+ }
+ return databaseName;
+ }
+
+ @Override
+ public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry)
+ throws UnsupportedDataContextPropertiesException, ConnectionException {
+ final JestClient client = createClient(properties);
+ final String indexName = getIndex(properties);
+ final SimpleTableDef[] tableDefinitions = properties.getTableDefs();
+ return new ElasticSearchRestDataContext(client, indexName, tableDefinitions);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/f35bfed0/elasticsearch/rest/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory b/elasticsearch/rest/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
new file mode 100644
index 0000000..a8924c4
--- /dev/null
+++ b/elasticsearch/rest/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
@@ -0,0 +1 @@
+org.apache.metamodel.elasticsearch.rest.ElasticSearchRestDataContextFactory
\ No newline at end of file
[34/43] 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/05bbaf78
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/05bbaf78
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/05bbaf78
Branch: refs/heads/5.x
Commit: 05bbaf780e8609abc96f998c2957117446f0b9d6
Parents: 7587b6a
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sun Nov 13 11:09:53 2016 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sun Nov 13 11:09:53 2016 -0800
----------------------------------------------------------------------
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/05bbaf78/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 0649d06..8faaa38 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-cassandra</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 7a36028..e5fd523 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index fb3c8fd..8d03fe8 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-couchdb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index ba5b874..e3cdd09 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-csv</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index 0778224..eaff016 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 937f08e..358d8f0 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 506a669..6a4efeb 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-elasticsearch</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 1f86308..5153932 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 3d4562d..6e617be 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-excel</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 27e5d77..7ca3f7a 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-fixedwidth</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 14bb1fc..7dd5152 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-full</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 2cf2530..26f6afb 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hadoop</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 24368c1..18ddb23 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hbase</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 581f9b8..ddb8bce 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-jdbc</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index f175891..79d1d9f 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-json</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index a21b75f..e9b52c4 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-common</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index aefa65a..4bfa5d0 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo2</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 728e4fd..744b3b7 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo3</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 1049d86..a5f14d5 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index c67bc58..21dc5b6 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-neo4j</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index ad5b2b8..6a32548 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-openoffice</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 71c0b37..cdedeb1 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-pojo</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 49aaf0e..5170658 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.5</tag>
+ <tag>HEAD</tag>
</scm>
<groupId>org.apache.metamodel</groupId>
<artifactId>MetaModel</artifactId>
- <version>4.5.5</version>
+ <version>4.5.6-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/05bbaf78/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 891e22d..4ae1b02 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-salesforce</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index f7aaf42..60c1fe2 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-spring</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index d7a89ff..bf8c557 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-sugarcrm</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/05bbaf78/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 2a41c6c..0e1f000 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.5</version>
+ <version>4.5.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-xml</artifactId>
[26/43] metamodel git commit: Updated README with the new Confluence
wiki URL
Posted by ka...@apache.org.
Updated README with the new Confluence wiki URL
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/a3ecbab0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/a3ecbab0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/a3ecbab0
Branch: refs/heads/5.x
Commit: a3ecbab02e7834dd9af73b230ba0af60edd7544a
Parents: 5f09375
Author: kasper <ka...@LAPTOP-67ITMT2V>
Authored: Wed Oct 19 22:01:27 2016 -0700
Committer: kasper <ka...@LAPTOP-67ITMT2V>
Committed: Wed Oct 19 22:01:27 2016 -0700
----------------------------------------------------------------------
README.md | 77 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 39 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a3ecbab0/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 1bb2504..e5cf17a 100644
--- a/README.md
+++ b/README.md
@@ -1,39 +1,40 @@
-## Apache MetaModel
-
-MetaModel is a data access framework, providing a common interface for exploration and querying of different types of datastores.
-
-<div>
-<img src="http://metamodel.apache.org/img/logo.png" style="float: right; margin-left: 20px;" alt="MetaModel logo" />
-</div>
-
-### Mailing lists
-
- * Developer list: dev@metamodel.apache.org
- * Commits list: commits@metamodel.apache.org
-
-### Website
-
-http://metamodel.apache.org/
-
-### Documentation
-
-Please check out our [wiki for user documentation](http://wiki.apache.org/metamodel/).
-
-### Building the code
-
-MetaModel uses maven as it's build tool. Code can be built with:
-
-```
-mvn clean install
-```
-
-### Running the integration tests
-
- 1. Copy the file 'example-metamodel-integrationtest-configuration.properties' to your user home.
- 2. Remove the 'example-' prefix from its filename
- 3. Modify the file to enable properties of the integration tests that you're interested in.
- 4. Re-run "mvn clean install".
-
-### Contributing
-
+## Apache MetaModel
+
+MetaModel is a data access framework, providing a common interface for exploration and querying of different types of datastores.
+
+<div>
+<img src="http://metamodel.apache.org/img/logo.png" style="float: right; margin-left: 20px;" alt="MetaModel logo" />
+</div>
+
+### Mailing lists
+
+ * Developer list: dev@metamodel.apache.org
+ * User list: user@metamodel.apache.org
+ * Commits list: commits@metamodel.apache.org
+
+### Website
+
+http://metamodel.apache.org/
+
+### Documentation
+
+Please check out our [wiki for user documentation](https://cwiki.apache.org/confluence/display/METAMODEL).
+
+### Building the code
+
+MetaModel uses maven as it's build tool. Code can be built with:
+
+```
+mvn clean install
+```
+
+### Running the integration tests
+
+ 1. Copy the file 'example-metamodel-integrationtest-configuration.properties' to your user home.
+ 2. Remove the 'example-' prefix from its filename
+ 3. Modify the file to enable properties of the integration tests that you're interested in.
+ 4. Re-run "mvn clean install".
+
+### Contributing
+
Please see [CONTRIBUTE.md](CONTRIBUTE.md)
\ No newline at end of file
[17/43] 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/288fcca4
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/288fcca4
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/288fcca4
Branch: refs/heads/5.x
Commit: 288fcca423be8fb6a3d59cc6645743f7a844615b
Parents: e5fb93a
Author: kaspersorensen <i....@gmail.com>
Authored: Mon Aug 22 13:19:30 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Mon Aug 22 13:19:30 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/288fcca4/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index d7cd4d3..0c06db2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
* [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
+ * [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
### Apache MetaModel 4.5.4
[11/43] 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/7e355a1b
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/7e355a1b
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/7e355a1b
Branch: refs/heads/5.x
Commit: 7e355a1b9b5333e6e3d32458b9a5ddc61bb3d57e
Parents: fd65c4e
Author: Kasper Sørensen <i....@gmail.com>
Authored: Mon Aug 1 21:34:40 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Aug 1 21:34:40 2016 -0700
----------------------------------------------------------------------
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/7e355a1b/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 5797021..27e2753 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-cassandra</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 0fa14b9..2c1a57d 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index aa5742e..720c521 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-couchdb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index dfdf5a6..b234fb7 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-csv</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index 3c08a5b..e978223 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index 1e98795..568d53b 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 8baca5e..f375e33 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-elasticsearch</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index e5983d0..a9db222 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 49663fb..089b1dc 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-excel</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index d24c2e7..b859010 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-fixedwidth</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 6444bcc..d11d945 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-full</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index e4851d4..c5879e4 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hadoop</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 24bb19e..08fdfe2 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hbase</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index bcb7203..e9164fc 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-jdbc</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 20440ee..251867b 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-json</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 770adf7..fd02cdf 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-common</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 39e1663..23fae1d 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo2</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 57028c3..2237efd 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo3</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 9d9fb6f..a39b47e 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index a0e4341..d60d270 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-neo4j</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index a7bd368..b9cab19 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-openoffice</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 80eeac0..76e236d 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-pojo</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e25cc7e..25209d8 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.4</tag>
+ <tag>HEAD</tag>
</scm>
<groupId>org.apache.metamodel</groupId>
<artifactId>MetaModel</artifactId>
- <version>4.5.4</version>
+ <version>4.5.5-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/7e355a1b/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 857bfb6..c6d5ed7 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-salesforce</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index c5e6b9c..7060d3a 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-spring</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index f1167cb..103703b 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-sugarcrm</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e355a1b/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index a340316..f3efc83 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.4</version>
+ <version>4.5.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-xml</artifactId>
[13/43] metamodel git commit: METAMODEL-1109: Fixed
Posted by ka...@apache.org.
METAMODEL-1109: Fixed
Fixes #122
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/7e29fb89
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/7e29fb89
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/7e29fb89
Branch: refs/heads/5.x
Commit: 7e29fb895703508fd793ba9604f3e893f55adf82
Parents: 7e355a1
Author: Jakub Horcicka <ja...@humaninference.com>
Authored: Wed Aug 10 20:38:25 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Wed Aug 10 20:39:54 2016 -0700
----------------------------------------------------------------------
.../metamodel/fixedwidth/EbcdicReader.java | 4 +++
.../metamodel/fixedwidth/FixedWidthReader.java | 37 ++++++++++++--------
.../fixedwidth/FixedWidthReaderTest.java | 28 +++++++++++++++
.../test/resources/example_diacritics_utf8.txt | 4 +++
4 files changed, 59 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e29fb89/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
index a7639fc..9e22dac 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
@@ -26,6 +26,8 @@ import java.io.IOException;
*/
class EbcdicReader extends FixedWidthReader {
+ private final BufferedInputStream _stream;
+ private final String _charsetName;
private final boolean _skipEbcdicHeader;
private final boolean _eolPresent;
private boolean _headerSkipped;
@@ -33,6 +35,8 @@ class EbcdicReader extends FixedWidthReader {
public EbcdicReader(BufferedInputStream stream, String charsetName, int[] valueWidths,
boolean failOnInconsistentLineWidth, boolean skipEbcdicHeader, boolean eolPresent) {
super(stream, charsetName, valueWidths, failOnInconsistentLineWidth);
+ _stream = stream;
+ _charsetName = charsetName;
_skipEbcdicHeader = skipEbcdicHeader;
_eolPresent = eolPresent;
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e29fb89/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
index da17ff1..9f65ac7 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
@@ -19,9 +19,13 @@
package org.apache.metamodel.fixedwidth;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.ArrayList;
@@ -35,14 +39,13 @@ class FixedWidthReader implements Closeable {
private static final int LINE_FEED = '\n';
private static final int CARRIAGE_RETURN = '\r';
- protected final String _charsetName;
private final int _fixedValueWidth;
private final int[] _valueWidths;
private int _valueIndex = 0;
private final boolean _failOnInconsistentLineWidth;
private final boolean _constantWidth;
private volatile int _rowNumber;
- protected final BufferedInputStream _stream;
+ protected final Reader _reader;
protected final int _expectedLineLength;
public FixedWidthReader(InputStream stream, String charsetName, int fixedValueWidth,
@@ -52,8 +55,7 @@ class FixedWidthReader implements Closeable {
private FixedWidthReader(BufferedInputStream stream, String charsetName, int fixedValueWidth,
boolean failOnInconsistentLineWidth) {
- _stream = stream;
- _charsetName = charsetName;
+ _reader = initReader(stream, charsetName);
_fixedValueWidth = fixedValueWidth;
_failOnInconsistentLineWidth = failOnInconsistentLineWidth;
_rowNumber = 0;
@@ -69,8 +71,7 @@ class FixedWidthReader implements Closeable {
FixedWidthReader(BufferedInputStream stream, String charsetName, int[] valueWidths,
boolean failOnInconsistentLineWidth) {
- _stream = stream;
- _charsetName = charsetName;
+ _reader = initReader(stream, charsetName);
_fixedValueWidth = -1;
_valueWidths = valueWidths;
_failOnInconsistentLineWidth = failOnInconsistentLineWidth;
@@ -85,6 +86,15 @@ class FixedWidthReader implements Closeable {
_expectedLineLength = expectedLineLength;
}
+ private Reader initReader(BufferedInputStream stream, String charsetName) {
+ try {
+ InputStreamReader inputStreamReader = new InputStreamReader(stream, charsetName);
+ return new BufferedReader(inputStreamReader);
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(String.format("Encoding '%s' was not recognized. ", charsetName));
+ }
+ }
+
/**
* This reads and returns the next record from the file. Usually, it is a line but in case the new line characters
* are not present, the length of the content depends on the column-widths setting.
@@ -106,7 +116,6 @@ class FixedWidthReader implements Closeable {
* Empty hook that enables special behavior in sub-classed readers (by overriding this method).
*/
protected void beforeReadLine() {
- return;
}
private String[] getValues() throws IOException {
@@ -167,8 +176,8 @@ class FixedWidthReader implements Closeable {
StringBuilder line = new StringBuilder();
int ch;
- for (ch = _stream.read(); !isEndingCharacter(ch); ch = _stream.read()) {
- line.append((char) ch);
+ for (ch = _reader.read(); !isEndingCharacter(ch); ch = _reader.read()) {
+ line.append((char)ch);
}
if (ch == CARRIAGE_RETURN) {
@@ -179,10 +188,10 @@ class FixedWidthReader implements Closeable {
}
private void readLineFeedIfFollows() throws IOException {
- _stream.mark(1);
-
- if (_stream.read() != LINE_FEED) {
- _stream.reset();
+ _reader.mark(1);
+
+ if (_reader.read() != LINE_FEED) {
+ _reader.reset();
}
}
@@ -247,6 +256,6 @@ class FixedWidthReader implements Closeable {
@Override
public void close() throws IOException {
- _stream.close();
+ _reader.close();
}
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e29fb89/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
index 8f40c1d..29b4b06 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
@@ -37,6 +37,34 @@ public class FixedWidthReaderTest {
public final ExpectedException exception = ExpectedException.none();
@Test
+ public void testDiacritics() throws IOException {
+ assertExpectedDiacritics(CHARSET);
+ }
+
+ @Test(expected=AssertionError.class)
+ public void testDiacriticsFails() throws IOException {
+ assertExpectedDiacritics("Windows-1250");
+ }
+
+ private void assertExpectedDiacritics(String charset) throws IOException {
+ final File file = new File("src/test/resources/example_diacritics_utf8.txt");
+ final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
+ int[] widths = new int[] { 10, 10 };
+ final String[] expectedValues = {
+ "[name, surname]",
+ "[Štěpán, Knížek]",
+ "[Lukáš, Žáček]",
+ "[Přemysl, Hývl]",
+ };
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(stream, charset, widths, false)) {
+ for (String expectedLine : expectedValues) {
+ final String[] line = fixedWidthReader.readLine();
+ assertEquals(expectedLine, Arrays.asList(line).toString());
+ }
+ }
+ }
+
+ @Test
public void testBufferedReader1() throws IOException {
final File file = new File("src/test/resources/example_simple1.txt");
final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
http://git-wip-us.apache.org/repos/asf/metamodel/blob/7e29fb89/fixedwidth/src/test/resources/example_diacritics_utf8.txt
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/resources/example_diacritics_utf8.txt b/fixedwidth/src/test/resources/example_diacritics_utf8.txt
new file mode 100644
index 0000000..65b6a63
--- /dev/null
+++ b/fixedwidth/src/test/resources/example_diacritics_utf8.txt
@@ -0,0 +1,4 @@
+name surname
+Štěpán Knížek
+Lukáš Žáček
+Přemysl Hývl
\ No newline at end of file
[21/43] metamodel git commit: METAMODEL-1118: Fixed
Posted by ka...@apache.org.
METAMODEL-1118: Fixed
Fixes #129
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/b23085b6
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/b23085b6
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/b23085b6
Branch: refs/heads/5.x
Commit: b23085b6e3cc74e6ae7a2976ee6854d56fed74ee
Parents: 060884c
Author: kaspersorensen <i....@gmail.com>
Authored: Wed Sep 21 15:57:46 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Wed Sep 21 15:57:46 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../main/java/org/apache/metamodel/query/DefaultCompiledQuery.java | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b23085b6/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index f44077e..bda2372 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,6 @@
### Apache MetaModel 4.5.5
+ * [METAMODEL-1118] - Fixed bug pertaining to cloning of FilterItem.LogicalOperator in compiled queries.
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
* [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
* [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b23085b6/core/src/main/java/org/apache/metamodel/query/DefaultCompiledQuery.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/DefaultCompiledQuery.java b/core/src/main/java/org/apache/metamodel/query/DefaultCompiledQuery.java
index 4cd497a..12a2529 100644
--- a/core/src/main/java/org/apache/metamodel/query/DefaultCompiledQuery.java
+++ b/core/src/main/java/org/apache/metamodel/query/DefaultCompiledQuery.java
@@ -101,7 +101,7 @@ public class DefaultCompiledQuery implements CompiledQuery {
final FilterItem newChildItem = copyFilterItem(childItem, values, parameterIndex);
newChildItems[i] = newChildItem;
}
- final FilterItem newFilter = new FilterItem(newChildItems);
+ final FilterItem newFilter = new FilterItem(item.getLogicalOperator(), newChildItems);
return newFilter;
} else {
if (item.getOperand() instanceof QueryParameter) {
[06/43] metamodel git commit: METAMODEL-1106: Fixed bug when JDBC
column is named like 'index'.
Posted by ka...@apache.org.
METAMODEL-1106: Fixed bug when JDBC column is named like 'index'.
Closes #117
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/23925579
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/23925579
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/23925579
Branch: refs/heads/5.x
Commit: 2392557953c0b2473d702852efc14a20a50f195d
Parents: f35bfed
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Jul 29 08:40:49 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Jul 29 08:40:49 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../org/apache/metamodel/jdbc/SqlKeywords.java | 62 ++++++++++++--------
2 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/23925579/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index bd2cec8..f0264c6 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@
* [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
* [METAMODEL-1094] - Added support for Apache Cassandra version 3.x.
* [METAMODEL-1093] - Close compiled ResultSets.
+ * [METAMODEL-1106] - Fixed bug in JDBC adaptor caused by not quoting columns named as a keyword, e.g. 'index'.
* [METAMODEL-1102] - Separated FixedWidthLineParser.
* [METAMODEL-1107] - Added support for PostgreSQL's "json" and "jsonb" data types.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/23925579/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
index b2207df..7ffb6c9 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
@@ -23,29 +23,45 @@ import java.util.Set;
class SqlKeywords {
- private static final Set<String> KEYWORDS;
+ private static final Set<String> KEYWORDS;
- static {
- KEYWORDS = new HashSet<String>();
- KEYWORDS.add("SELECT");
- KEYWORDS.add("DISTINCT");
- KEYWORDS.add("AS");
- KEYWORDS.add("COUNT");
- KEYWORDS.add("SUM");
- KEYWORDS.add("MIN");
- KEYWORDS.add("MAX");
- KEYWORDS.add("FROM");
- KEYWORDS.add("WHERE");
- KEYWORDS.add("LIKE");
- KEYWORDS.add("IN");
- KEYWORDS.add("GROUP");
- KEYWORDS.add("BY");
- KEYWORDS.add("HAVING");
- KEYWORDS.add("ORDER");
- }
+ static {
+ KEYWORDS = new HashSet<String>();
+ KEYWORDS.add("SELECT");
+ KEYWORDS.add("DISTINCT");
+ KEYWORDS.add("AS");
+ KEYWORDS.add("COUNT");
+ KEYWORDS.add("SUM");
+ KEYWORDS.add("MIN");
+ KEYWORDS.add("MAX");
+ KEYWORDS.add("FROM");
+ KEYWORDS.add("WHERE");
+ KEYWORDS.add("LIKE");
+ KEYWORDS.add("IN");
+ KEYWORDS.add("GROUP");
+ KEYWORDS.add("BY");
+ KEYWORDS.add("HAVING");
+ KEYWORDS.add("ORDER");
+ KEYWORDS.add("INDEX");
+ KEYWORDS.add("PRIMARY");
+ KEYWORDS.add("KEY");
+ KEYWORDS.add("CONSTRAINT");
+ KEYWORDS.add("UNIQUE");
+ KEYWORDS.add("IS");
+ KEYWORDS.add("NOT");
+ KEYWORDS.add("NULL");
+ KEYWORDS.add("CREATE");
+ KEYWORDS.add("INSERT");
+ KEYWORDS.add("INTO");
+ KEYWORDS.add("UPDATE");
+ KEYWORDS.add("VALUES");
+ KEYWORDS.add("DELETE");
+ KEYWORDS.add("AND");
+ KEYWORDS.add("OR");
+ }
- public static boolean isKeyword(String str) {
- str = str.toUpperCase();
- return KEYWORDS.contains(str);
- }
+ public static boolean isKeyword(String str) {
+ str = str.toUpperCase();
+ return KEYWORDS.contains(str);
+ }
}
[28/43] metamodel git commit: METAMODEL-1127: Fixed setting of null
Map on postgres Fixes apache/metamodel#135
Posted by ka...@apache.org.
METAMODEL-1127: Fixed setting of null Map on postgres
Fixes apache/metamodel#135
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/11710afe
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/11710afe
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/11710afe
Branch: refs/heads/5.x
Commit: 11710afe2d92d816a5cf850eb87a19e6e3af4ee1
Parents: c32a2bb
Author: Kasper Sørensen <i....@gmail.com>
Authored: Tue Nov 1 09:04:33 2016 +0100
Committer: Dennis Du Krøger <de...@humaninference.com>
Committed: Tue Nov 1 09:04:33 2016 +0100
----------------------------------------------------------------------
CHANGES.md | 3 +-
.../jdbc/dialects/AbstractQueryRewriter.java | 2 +-
.../jdbc/dialects/DefaultQueryRewriter.java | 4 ++
.../jdbc/dialects/PostgresqlQueryRewriter.java | 6 ++-
.../dialects/PostgresqlQueryRewriterTest.java | 49 ++++++++++++++++++++
5 files changed, 60 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/11710afe/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 236602e..0ee551c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -10,7 +10,8 @@
* [METAMODEL-1119] - Worked around Hive JDBC driver issues, avoiding non-compliant metadata calls.
* [METAMODEL-1123] - Fixed the treatment of a Salesforce.com 'currency' value as a number, not a string.
* [METAMODEL-1124] - Fixed the date formatting of date values in MS SQL server.
-
+ * [METAMODEL-1127] - Fixed setting of null Map on postgres
+
### Apache MetaModel 4.5.4
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/11710afe/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 5ce4445..98c8369 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
@@ -63,7 +63,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class AbstractQueryRewriter implements IQueryRewriter {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ private static final Logger logger = LoggerFactory.getLogger(AbstractQueryRewriter.class);
private final JdbcDataContext _dataContext;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/11710afe/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
index fcefb9f..0dec7c1 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
@@ -41,12 +41,16 @@ import org.apache.metamodel.query.SelectItem;
import org.apache.metamodel.query.SumAggregateFunction;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.util.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Generic query rewriter that adds syntax enhancements that are only possible
* to resolve just before execution time.
*/
public class DefaultQueryRewriter extends AbstractQueryRewriter {
+
+ private static final Logger logger = LoggerFactory.getLogger(DefaultQueryRewriter.class);
private static final String SPECIAL_ALIAS_CHARACTERS = "- ,.|*%()!#¤/\\=?;:~";
private static final Set<Class<? extends FunctionType>> SUPPORTED_FUNCTION_CLASSES = new HashSet<>(
http://git-wip-us.apache.org/repos/asf/metamodel/blob/11710afe/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
index 531306f..7fe03cb 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
@@ -83,7 +83,9 @@ public class PostgresqlQueryRewriter extends LimitOffsetQueryRewriter {
case "json":
case "jsonb":
assert column.getType() == ColumnType.MAP;
- if (value != null) {
+ if (value == null) {
+ st.setObject(valueIndex, null);
+ } else {
final PGobject pgo = new PGobject();
pgo.setType(column.getNativeType());
if (value instanceof Map) {
@@ -96,8 +98,8 @@ public class PostgresqlQueryRewriter extends LimitOffsetQueryRewriter {
pgo.setValue(value.toString());
}
st.setObject(valueIndex, pgo);
- return;
}
+ return;
}
super.setStatementParameter(st, valueIndex, column, value);
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/11710afe/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriterTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriterTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriterTest.java
new file mode 100644
index 0000000..d7ecb3a
--- /dev/null
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriterTest.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.jdbc.dialects;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.MutableColumn;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class PostgresqlQueryRewriterTest {
+
+ @Test
+ public void testInsertNullMap() throws SQLException {
+ final PreparedStatement statementMock = EasyMock.createMock(PreparedStatement.class);
+
+ final PostgresqlQueryRewriter queryRewriter = new PostgresqlQueryRewriter(null);
+ final Column column = new MutableColumn("col").setType(ColumnType.MAP).setNativeType("jsonb");
+ final Object value = null;
+
+ // mock behaviour recording
+ statementMock.setObject(0, null);
+
+ EasyMock.replay(statementMock);
+
+ queryRewriter.setStatementParameter(statementMock, 0, column, value);
+
+ EasyMock.verify(statementMock);
+ }
+}
[03/43] metamodel git commit: METAMODEL-1107: Fixed
Posted by ka...@apache.org.
METAMODEL-1107: Fixed
Closes #112
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/a5235c11
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/a5235c11
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/a5235c11
Branch: refs/heads/5.x
Commit: a5235c11ff2f409798d143023fba1c10b7e1a6fd
Parents: 1910d56
Author: kaspersorensen <i....@gmail.com>
Authored: Mon Jul 25 09:16:59 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Mon Jul 25 09:16:59 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 5 +-
jdbc/pom.xml | 13 +-
.../org/apache/metamodel/jdbc/JdbcDataSet.java | 53 ++----
.../metamodel/jdbc/JdbcDeleteBuilder.java | 2 +-
.../metamodel/jdbc/JdbcInsertBuilder.java | 2 +-
.../metamodel/jdbc/JdbcUpdateBuilder.java | 4 +-
.../org/apache/metamodel/jdbc/JdbcUtils.java | 140 +--------------
.../jdbc/dialects/AbstractQueryRewriter.java | 173 +++++++++++++++++++
.../jdbc/dialects/DB2QueryRewriter.java | 2 +-
.../jdbc/dialects/HiveQueryRewriter.java | 2 +-
.../metamodel/jdbc/dialects/IQueryRewriter.java | 30 ++++
.../jdbc/dialects/MysqlQueryRewriter.java | 2 +-
.../jdbc/dialects/PostgresqlQueryRewriter.java | 67 ++++++-
.../jdbc/integrationtests/PostgresqlTest.java | 102 ++++++++---
14 files changed, 382 insertions(+), 215 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 0b2b49d..4f61177 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@
* [METAMODEL-1094] - Added support for Apache Cassandra version 3.x.
* [METAMODEL-1093] - Close compiled ResultSets.
* [METAMODEL-1102] - Separated FixedWidthLineParser.
+ * [METAMODEL-1107] - Added support for PostgreSQL's "json" and "jsonb" data types.
### Apache MetaModel 4.5.3
@@ -57,8 +58,8 @@
### 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-192] - Added support for Scalar functions. We have a basic set of data type 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 data set.
* [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.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index fb332f7..3969b1c 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -75,7 +75,18 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1104-jdbc4</version>
- <scope>test</scope>
+ <!-- optional instead of test-scoped because we code against it in the rewriter class -->
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
index 4142ab7..cbcdb7a 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
@@ -18,10 +18,6 @@
*/
package org.apache.metamodel.jdbc;
-import java.io.InputStream;
-import java.io.Reader;
-import java.sql.Blob;
-import java.sql.Clob;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -31,10 +27,11 @@ import org.apache.metamodel.MetaModelException;
import org.apache.metamodel.data.AbstractDataSet;
import org.apache.metamodel.data.DefaultRow;
import org.apache.metamodel.data.Row;
+import org.apache.metamodel.jdbc.dialects.DefaultQueryRewriter;
+import org.apache.metamodel.jdbc.dialects.IQueryRewriter;
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.util.FileHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -131,8 +128,8 @@ final class JdbcDataSet extends AbstractDataSet {
values[i] = null;
}
} catch (Exception e) {
- logger.debug("Could not invoke wasNull() method on resultset, error message: {}",
- e.getMessage());
+ logger.debug("Could not invoke wasNull() method on resultset, error message: {}", e
+ .getMessage());
}
}
_row = new DefaultRow(getHeader(), values);
@@ -149,44 +146,18 @@ final class JdbcDataSet extends AbstractDataSet {
final SelectItem selectItem = getHeader().getSelectItem(i);
final int columnIndex = i + 1;
if (selectItem.getAggregateFunction() == null) {
- Column column = selectItem.getColumn();
+ final Column column = selectItem.getColumn();
if (column != null) {
- ColumnType type = column.getType();
- try {
- if (type == ColumnType.TIME) {
- return _resultSet.getTime(columnIndex);
- } else if (type == ColumnType.DATE) {
- return _resultSet.getDate(columnIndex);
- } else if (type == ColumnType.TIMESTAMP) {
- return _resultSet.getTimestamp(columnIndex);
- } else if (type == ColumnType.BLOB) {
- final Blob blob = _resultSet.getBlob(columnIndex);
- return blob;
- } else if (type == JdbcDataContext.COLUMN_TYPE_BLOB_AS_BYTES) {
- final Blob blob = _resultSet.getBlob(columnIndex);
- final InputStream inputStream = blob.getBinaryStream();
- final byte[] bytes = FileHelper.readAsBytes(inputStream);
- return bytes;
- } else if (type.isBinary()) {
- return _resultSet.getBytes(columnIndex);
- } else if (type == ColumnType.CLOB || type == ColumnType.NCLOB) {
- final Clob clob = _resultSet.getClob(columnIndex);
- return clob;
- } else if (type == JdbcDataContext.COLUMN_TYPE_CLOB_AS_STRING) {
- final Clob clob = _resultSet.getClob(columnIndex);
- final Reader reader = clob.getCharacterStream();
- final String result = FileHelper.readAsString(reader);
- return result;
- } else if (type.isBoolean()) {
- return _resultSet.getBoolean(columnIndex);
- }
- } catch (Exception e) {
- logger.warn("Failed to retrieve " + type
- + " value using type-specific getter, retrying with generic getObject(...) method", e);
+ final IQueryRewriter queryRewriter;
+ if (_jdbcDataContext == null) {
+ queryRewriter = new DefaultQueryRewriter(null);
+ } else {
+ queryRewriter = _jdbcDataContext.getQueryRewriter();
}
+ return queryRewriter.getResultSetValue(resultSet, columnIndex, column);
}
}
- return _resultSet.getObject(columnIndex);
+ return resultSet.getObject(columnIndex);
}
/**
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDeleteBuilder.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDeleteBuilder.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDeleteBuilder.java
index bf6aaf2..e46cd19 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDeleteBuilder.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDeleteBuilder.java
@@ -70,7 +70,7 @@ final class JdbcDeleteBuilder extends AbstractRowDeletionBuilder {
for (FilterItem whereItem : whereItems) {
if (JdbcUtils.isPreparedParameterCandidate(whereItem)) {
Object operand = whereItem.getOperand();
- JdbcUtils.setStatementValue(st, valueCounter, whereItem.getSelectItem().getColumn(), operand);
+ _queryRewriter.setStatementParameter(st, valueCounter, whereItem.getSelectItem().getColumn(), operand);
valueCounter++;
}
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcInsertBuilder.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcInsertBuilder.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcInsertBuilder.java
index 66cdbe7..d9c7a5e 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcInsertBuilder.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcInsertBuilder.java
@@ -76,7 +76,7 @@ final class JdbcInsertBuilder extends AbstractRowInsertionBuilder<JdbcUpdateCall
for (int i = 0; i < columns.length; i++) {
boolean explicitNull = explicitNulls[i];
if (values[i] != null || explicitNull) {
- JdbcUtils.setStatementValue(st, valueCounter, columns[i], values[i]);
+ _queryRewriter.setStatementParameter(st, valueCounter, columns[i], values[i]);
valueCounter++;
}
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateBuilder.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateBuilder.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateBuilder.java
index 6610a7e..590a23d 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateBuilder.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateBuilder.java
@@ -72,7 +72,7 @@ final class JdbcUpdateBuilder extends AbstractRowUpdationBuilder {
for (int i = 0; i < columns.length; i++) {
boolean explicitNull = explicitNulls[i];
if (values[i] != null || explicitNull) {
- JdbcUtils.setStatementValue(st, valueCounter, columns[i], values[i]);
+ _queryRewriter.setStatementParameter(st, valueCounter, columns[i], values[i]);
valueCounter++;
}
@@ -84,7 +84,7 @@ final class JdbcUpdateBuilder extends AbstractRowUpdationBuilder {
final Object operand = whereItem.getOperand();
final Column column = whereItem.getSelectItem().getColumn();
- JdbcUtils.setStatementValue(st, valueCounter, column, operand);
+ _queryRewriter.setStatementParameter(st, valueCounter, column, operand);
valueCounter++;
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUtils.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUtils.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUtils.java
index 1073d6f..2d66790 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUtils.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUtils.java
@@ -18,20 +18,12 @@
*/
package org.apache.metamodel.jdbc;
-import java.io.InputStream;
-import java.io.Reader;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Date;
import java.util.List;
import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.jdbc.dialects.DefaultQueryRewriter;
import org.apache.metamodel.jdbc.dialects.IQueryRewriter;
import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.query.OperatorType;
@@ -39,7 +31,6 @@ import org.apache.metamodel.query.QueryParameter;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.schema.TableType;
-import org.apache.metamodel.util.FileHelper;
import org.apache.metamodel.util.FormatHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,133 +62,12 @@ public final class JdbcUtils {
}
/**
- * Method which handles the action of setting a parameterized value on a
- * statement. Traditionally this is done using the
- * {@link PreparedStatement#setObject(int, Object)} method but for some
- * types we use more specific setter methods.
- *
- * @param st
- * @param valueIndex
- * @param column
- * @param value
- * @throws SQLException
+ * @deprecated use {@link IQueryRewriter#setStatementParameter(PreparedStatement, int, Column, Object)}
*/
+ @Deprecated
public static void setStatementValue(final PreparedStatement st, final int valueIndex, final Column column,
Object value) throws SQLException {
- final ColumnType type = (column == null ? null : column.getType());
-
- if (type == null || type == ColumnType.OTHER) {
- // type is not known - nothing more we can do to narrow the type
- st.setObject(valueIndex, value);
- return;
- }
-
- if (value == null && type != null) {
- try {
- final int jdbcType = type.getJdbcType();
- st.setNull(valueIndex, jdbcType);
- return;
- } catch (Exception e) {
- logger.warn("Exception occurred while calling setNull(...) for value index " + valueIndex
- + ". Attempting value-based setter method instead.", e);
- }
- }
-
- if (type == ColumnType.VARCHAR && value instanceof Date) {
- // some drivers (SQLite and JTDS for MS SQL server) treat dates as
- // VARCHARS. In that case we need to convert the dates to the
- // correct format
- String nativeType = column.getNativeType();
- Date date = (Date) value;
- if ("DATE".equalsIgnoreCase(nativeType)) {
- value = FormatHelper.formatSqlTime(ColumnType.DATE, date, false);
- } else if ("TIME".equalsIgnoreCase(nativeType)) {
- value = FormatHelper.formatSqlTime(ColumnType.TIME, date, false);
- } else if ("TIMESTAMP".equalsIgnoreCase(nativeType) || "DATETIME".equalsIgnoreCase(nativeType)) {
- value = FormatHelper.formatSqlTime(ColumnType.TIMESTAMP, date, false);
- }
- }
-
- if (type != null && type.isTimeBased() && value instanceof String) {
- value = FormatHelper.parseSqlTime(type, (String) value);
- }
-
- try {
- if (type == ColumnType.DATE && value instanceof Date) {
- Calendar cal = Calendar.getInstance();
- cal.setTime((Date) value);
- st.setDate(valueIndex, new java.sql.Date(cal.getTimeInMillis()), cal);
- } else if (type == ColumnType.TIME && value instanceof Date) {
- final Time time = toTime((Date) value);
- st.setTime(valueIndex, time);
- } else if (type == ColumnType.TIMESTAMP && value instanceof Date) {
- final Timestamp ts = toTimestamp((Date) value);
- st.setTimestamp(valueIndex, ts);
- } else if (type == ColumnType.CLOB || type == ColumnType.NCLOB) {
- if (value instanceof InputStream) {
- InputStream inputStream = (InputStream) value;
- st.setAsciiStream(valueIndex, inputStream);
- } else if (value instanceof Reader) {
- Reader reader = (Reader) value;
- st.setCharacterStream(valueIndex, reader);
- } else if (value instanceof NClob) {
- NClob nclob = (NClob) value;
- st.setNClob(valueIndex, nclob);
- } else if (value instanceof Clob) {
- Clob clob = (Clob) value;
- st.setClob(valueIndex, clob);
- } else if (value instanceof String) {
- st.setString(valueIndex, (String) value);
- } else {
- st.setObject(valueIndex, value);
- }
- } else if (type == ColumnType.BLOB || type == ColumnType.BINARY) {
- if (value instanceof byte[]) {
- byte[] bytes = (byte[]) value;
- st.setBytes(valueIndex, bytes);
- } else if (value instanceof InputStream) {
- InputStream inputStream = (InputStream) value;
- st.setBinaryStream(valueIndex, inputStream);
- } else if (value instanceof Blob) {
- Blob blob = (Blob) value;
- st.setBlob(valueIndex, blob);
- } else {
- st.setObject(valueIndex, value);
- }
- } else if (type.isLiteral()) {
- final String str;
- if (value instanceof Reader) {
- Reader reader = (Reader) value;
- str = FileHelper.readAsString(reader);
- } else {
- str = value.toString();
- }
- st.setString(valueIndex, str);
- } else {
- st.setObject(valueIndex, value);
- }
- } catch (SQLException e) {
- logger.error("Failed to set parameter {} to value: {}", valueIndex, value);
- throw e;
- }
- }
-
- private static Time toTime(Date value) {
- if (value instanceof Time) {
- return (Time) value;
- }
- final Calendar cal = Calendar.getInstance();
- cal.setTime((Date) value);
- return new java.sql.Time(cal.getTimeInMillis());
- }
-
- private static Timestamp toTimestamp(Date value) {
- if (value instanceof Timestamp) {
- return (Timestamp) value;
- }
- final Calendar cal = Calendar.getInstance();
- cal.setTime((Date) value);
- return new Timestamp(cal.getTimeInMillis());
+ new DefaultQueryRewriter(null).setStatementParameter(st, valueIndex, column, value);
}
public static String getValueAsSql(Column column, Object value, IQueryRewriter queryRewriter) {
@@ -208,7 +78,7 @@ public final class JdbcUtils {
if (columnType.isLiteral() && value instanceof String) {
value = queryRewriter.escapeQuotes((String) value);
}
- String formatSqlValue = FormatHelper.formatSqlValue(columnType, value);
+ final String formatSqlValue = FormatHelper.formatSqlValue(columnType, value);
return formatSqlValue;
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/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 087bf2f..5ce4445 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
@@ -18,6 +18,18 @@
*/
package org.apache.metamodel.jdbc.dialects;
+import java.io.InputStream;
+import java.io.Reader;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import org.apache.metamodel.jdbc.JdbcDataContext;
@@ -35,8 +47,11 @@ import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.ScalarFunction;
import org.apache.metamodel.query.SelectClause;
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.util.FileHelper;
+import org.apache.metamodel.util.FormatHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -287,4 +302,162 @@ public abstract class AbstractQueryRewriter implements IQueryRewriter {
}
return item.toSql(isSchemaIncludedInColumnPaths());
}
+
+ @Override
+ public void setStatementParameter(PreparedStatement st, int valueIndex, Column column, Object value)
+ throws SQLException {
+
+ final ColumnType type = (column == null ? null : column.getType());
+
+ if (type == null || type == ColumnType.OTHER) {
+ // type is not known - nothing more we can do to narrow the type
+ st.setObject(valueIndex, value);
+ return;
+ }
+
+ if (value == null && type != null) {
+ try {
+ final int jdbcType = type.getJdbcType();
+ st.setNull(valueIndex, jdbcType);
+ return;
+ } catch (Exception e) {
+ logger.warn("Exception occurred while calling setNull(...) for value index " + valueIndex
+ + ". Attempting value-based setter method instead.", e);
+ }
+ }
+
+ if (type == ColumnType.VARCHAR && value instanceof Date) {
+ // some drivers (SQLite and JTDS for MS SQL server) treat dates as
+ // VARCHARS. In that case we need to convert the dates to the
+ // correct format
+ String nativeType = column.getNativeType();
+ Date date = (Date) value;
+ if ("DATE".equalsIgnoreCase(nativeType)) {
+ value = FormatHelper.formatSqlTime(ColumnType.DATE, date, false);
+ } else if ("TIME".equalsIgnoreCase(nativeType)) {
+ value = FormatHelper.formatSqlTime(ColumnType.TIME, date, false);
+ } else if ("TIMESTAMP".equalsIgnoreCase(nativeType) || "DATETIME".equalsIgnoreCase(nativeType)) {
+ value = FormatHelper.formatSqlTime(ColumnType.TIMESTAMP, date, false);
+ }
+ }
+
+ if (type != null && type.isTimeBased() && value instanceof String) {
+ value = FormatHelper.parseSqlTime(type, (String) value);
+ }
+
+ try {
+ if (type == ColumnType.DATE && value instanceof Date) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime((Date) value);
+ st.setDate(valueIndex, new java.sql.Date(cal.getTimeInMillis()), cal);
+ } else if (type == ColumnType.TIME && value instanceof Date) {
+ final Time time = toTime((Date) value);
+ st.setTime(valueIndex, time);
+ } else if (type == ColumnType.TIMESTAMP && value instanceof Date) {
+ final Timestamp ts = toTimestamp((Date) value);
+ st.setTimestamp(valueIndex, ts);
+ } else if (type == ColumnType.CLOB || type == ColumnType.NCLOB) {
+ if (value instanceof InputStream) {
+ InputStream inputStream = (InputStream) value;
+ st.setAsciiStream(valueIndex, inputStream);
+ } else if (value instanceof Reader) {
+ Reader reader = (Reader) value;
+ st.setCharacterStream(valueIndex, reader);
+ } else if (value instanceof NClob) {
+ NClob nclob = (NClob) value;
+ st.setNClob(valueIndex, nclob);
+ } else if (value instanceof Clob) {
+ Clob clob = (Clob) value;
+ st.setClob(valueIndex, clob);
+ } else if (value instanceof String) {
+ st.setString(valueIndex, (String) value);
+ } else {
+ st.setObject(valueIndex, value);
+ }
+ } else if (type == ColumnType.BLOB || type == ColumnType.BINARY) {
+ if (value instanceof byte[]) {
+ byte[] bytes = (byte[]) value;
+ st.setBytes(valueIndex, bytes);
+ } else if (value instanceof InputStream) {
+ InputStream inputStream = (InputStream) value;
+ st.setBinaryStream(valueIndex, inputStream);
+ } else if (value instanceof Blob) {
+ Blob blob = (Blob) value;
+ st.setBlob(valueIndex, blob);
+ } else {
+ st.setObject(valueIndex, value);
+ }
+ } else if (type.isLiteral()) {
+ final String str;
+ if (value instanceof Reader) {
+ Reader reader = (Reader) value;
+ str = FileHelper.readAsString(reader);
+ } else {
+ str = value.toString();
+ }
+ st.setString(valueIndex, str);
+ } else {
+ st.setObject(valueIndex, value);
+ }
+ } catch (SQLException e) {
+ logger.error("Failed to set parameter {} to value: {}", valueIndex, value);
+ throw e;
+ }
+ }
+
+ protected Time toTime(Date value) {
+ if (value instanceof Time) {
+ return (Time) value;
+ }
+ final Calendar cal = Calendar.getInstance();
+ cal.setTime((Date) value);
+ return new java.sql.Time(cal.getTimeInMillis());
+ }
+
+ protected Timestamp toTimestamp(Date value) {
+ if (value instanceof Timestamp) {
+ return (Timestamp) value;
+ }
+ final Calendar cal = Calendar.getInstance();
+ cal.setTime((Date) value);
+ return new Timestamp(cal.getTimeInMillis());
+ }
+
+ @Override
+ public Object getResultSetValue(ResultSet resultSet, int columnIndex, Column column) throws SQLException {
+ final ColumnType type = column.getType();
+ try {
+ if (type == ColumnType.TIME) {
+ return resultSet.getTime(columnIndex);
+ } else if (type == ColumnType.DATE) {
+ return resultSet.getDate(columnIndex);
+ } else if (type == ColumnType.TIMESTAMP) {
+ return resultSet.getTimestamp(columnIndex);
+ } else if (type == ColumnType.BLOB) {
+ final Blob blob = resultSet.getBlob(columnIndex);
+ return blob;
+ } else if (type == JdbcDataContext.COLUMN_TYPE_BLOB_AS_BYTES) {
+ final Blob blob = resultSet.getBlob(columnIndex);
+ final InputStream inputStream = blob.getBinaryStream();
+ final byte[] bytes = FileHelper.readAsBytes(inputStream);
+ return bytes;
+ } else if (type.isBinary()) {
+ return resultSet.getBytes(columnIndex);
+ } else if (type == ColumnType.CLOB || type == ColumnType.NCLOB) {
+ final Clob clob = resultSet.getClob(columnIndex);
+ return clob;
+ } else if (type == JdbcDataContext.COLUMN_TYPE_CLOB_AS_STRING) {
+ final Clob clob = resultSet.getClob(columnIndex);
+ final Reader reader = clob.getCharacterStream();
+ final String result = FileHelper.readAsString(reader);
+ return result;
+ } else if (type.isBoolean()) {
+ return resultSet.getBoolean(columnIndex);
+ }
+ } catch (Exception e) {
+ logger.warn("Failed to retrieve " + type
+ + " value using type-specific getter, retrying with generic getObject(...) method", e);
+ }
+ return resultSet.getObject(columnIndex);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/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 d75bf54..3b0d144 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
@@ -34,7 +34,7 @@ import org.apache.metamodel.util.TimeComparator;
/**
* Query rewriter for IBM DB2
*/
-public class DB2QueryRewriter extends DefaultQueryRewriter implements IQueryRewriter {
+public class DB2QueryRewriter extends DefaultQueryRewriter {
public DB2QueryRewriter(JdbcDataContext dataContext) {
super(dataContext);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
index ec63f7b..b18b9aa 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/HiveQueryRewriter.java
@@ -24,7 +24,7 @@ import org.apache.metamodel.schema.ColumnType;
/**
* Query rewriter for Apache Hive
*/
-public class HiveQueryRewriter extends DefaultQueryRewriter implements IQueryRewriter {
+public class HiveQueryRewriter extends DefaultQueryRewriter {
public HiveQueryRewriter(JdbcDataContext dataContext) {
super(dataContext);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/IQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/IQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/IQueryRewriter.java
index f867cb1..3ab24a7 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/IQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/IQueryRewriter.java
@@ -18,6 +18,9 @@
*/
package org.apache.metamodel.jdbc.dialects;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.sql.Types;
import org.apache.metamodel.jdbc.JdbcDataContext;
@@ -26,6 +29,7 @@ import org.apache.metamodel.query.FilterItem;
import org.apache.metamodel.query.FromItem;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.ScalarFunction;
+import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.ColumnType;
/**
@@ -46,6 +50,32 @@ public interface IQueryRewriter {
public String rewriteFilterItem(FilterItem whereItem);
/**
+ * Method which handles the action of setting a parameterized value on a
+ * statement. Traditionally this is done using the
+ * {@link PreparedStatement#setObject(int, Object)} method but for some
+ * types we use more specific setter methods.
+ *
+ * @param st
+ * @param valueIndex
+ * @param column
+ * @param value
+ * @throws SQLException
+ */
+ public void setStatementParameter(final PreparedStatement st, final int valueIndex, final Column column,
+ final Object value) throws SQLException;
+
+ /**
+ * Retrieves a value from a JDBC {@link ResultSet} when the anticipated value is mapped to a particular column.
+ *
+ * @param resultSet
+ * @param columnIndex
+ * @param column
+ * @throws SQLException
+ * @return
+ */
+ public Object getResultSetValue(ResultSet resultSet, int columnIndex, Column column) throws SQLException;
+
+ /**
* Gets whether this query rewriter is able to write the "Max rows" query
* property to the query string.
*
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/MysqlQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/MysqlQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/MysqlQueryRewriter.java
index 4ea8f78..68647cc 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/MysqlQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/MysqlQueryRewriter.java
@@ -24,7 +24,7 @@ import org.apache.metamodel.schema.ColumnType;
/**
* Query rewriter for MySQL
*/
-public class MysqlQueryRewriter extends LimitOffsetQueryRewriter implements IQueryRewriter {
+public class MysqlQueryRewriter extends LimitOffsetQueryRewriter {
public MysqlQueryRewriter(JdbcDataContext dataContext) {
super(dataContext);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
index eebb116..531306f 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/PostgresqlQueryRewriter.java
@@ -18,17 +18,28 @@
*/
package org.apache.metamodel.jdbc.dialects;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
import org.apache.metamodel.jdbc.JdbcDataContext;
import org.apache.metamodel.query.FromItem;
import org.apache.metamodel.query.Query;
+import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+import org.postgresql.util.PGobject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Query rewriter for PostgreSQL
*/
-public class PostgresqlQueryRewriter extends LimitOffsetQueryRewriter implements IQueryRewriter {
+public class PostgresqlQueryRewriter extends LimitOffsetQueryRewriter {
+
+ private final ObjectMapper jsonObjectMapper = new ObjectMapper();
public PostgresqlQueryRewriter(JdbcDataContext dataContext) {
super(dataContext);
@@ -36,10 +47,14 @@ public class PostgresqlQueryRewriter extends LimitOffsetQueryRewriter implements
@Override
public ColumnType getColumnType(int jdbcType, String nativeType, Integer columnSize) {
- if ("bool".equals(nativeType)) {
+ switch (nativeType) {
+ case "bool":
// override the normal behaviour of postgresql which maps "bool" to
// a BIT.
return ColumnType.BOOLEAN;
+ case "json":
+ case "jsonb":
+ return ColumnType.MAP;
}
return super.getColumnType(jdbcType, nativeType, columnSize);
}
@@ -55,10 +70,58 @@ public class PostgresqlQueryRewriter extends LimitOffsetQueryRewriter implements
if (columnType == ColumnType.DOUBLE) {
return "double precision";
}
+ if (columnType == ColumnType.MAP) {
+ return "jsonb";
+ }
return super.rewriteColumnType(columnType, columnSize);
}
@Override
+ public void setStatementParameter(PreparedStatement st, int valueIndex, Column column, Object value)
+ throws SQLException {
+ switch (column.getNativeType()) {
+ case "json":
+ case "jsonb":
+ assert column.getType() == ColumnType.MAP;
+ if (value != null) {
+ final PGobject pgo = new PGobject();
+ pgo.setType(column.getNativeType());
+ if (value instanceof Map) {
+ try {
+ pgo.setValue(jsonObjectMapper.writeValueAsString(value));
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Unable to write value as JSON string: " + value);
+ }
+ } else {
+ pgo.setValue(value.toString());
+ }
+ st.setObject(valueIndex, pgo);
+ return;
+ }
+ }
+ super.setStatementParameter(st, valueIndex, column, value);
+ }
+
+ @Override
+ public Object getResultSetValue(ResultSet resultSet, int columnIndex, Column column) throws SQLException {
+ switch (column.getNativeType()) {
+ case "json":
+ case "jsonb":
+ assert column.getType() == ColumnType.MAP;
+ final String stringValue = resultSet.getString(columnIndex);
+ if (stringValue == null) {
+ return null;
+ }
+ try {
+ return jsonObjectMapper.readValue(stringValue, Map.class);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Unable to read string as JSON: " + stringValue);
+ }
+ }
+ return super.getResultSetValue(resultSet, columnIndex, column);
+ }
+
+ @Override
protected String rewriteFromItem(Query query, FromItem item) {
String result = super.rewriteFromItem(query, item);
Table table = item.getTable();
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a5235c11/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
index 5cf6822..2668df9 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
@@ -22,7 +22,9 @@ import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.swing.table.TableModel;
@@ -65,12 +67,12 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
protected String getPropertyPrefix() {
return "postgresql";
}
-
+
public void testTimestampValueInsertSelect() throws Exception {
if (!isConfigured()) {
return;
}
-
+
final Connection connection = getConnection();
JdbcTestTemplates.timestampValueInsertSelect(connection, TimeUnit.MICROSECONDS);
}
@@ -113,8 +115,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
- Table table = callback.createTable(dc.getDefaultSchema(), "test_table").withColumn("foo")
- .ofType(ColumnType.INTEGER).withColumn("bar").ofType(ColumnType.VARCHAR).execute();
+ Table table = callback.createTable(dc.getDefaultSchema(), "test_table").withColumn("foo").ofType(
+ ColumnType.INTEGER).withColumn("bar").ofType(ColumnType.VARCHAR).execute();
callback.insertInto(table).value("foo", 1).value("bar", "hello").execute();
callback.insertInto(table).value("foo", 2).value("bar", "there").execute();
callback.insertInto(table).value("foo", 3).value("bar", "world").execute();
@@ -197,10 +199,10 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
- Table table = cb.createTable(schema, "my_table").withColumn("id").asPrimaryKey()
- .ofType(ColumnType.INTEGER).ofNativeType("SERIAL").nullable(false).withColumn("name")
- .ofType(ColumnType.VARCHAR).ofSize(10).withColumn("foo").ofType(ColumnType.BOOLEAN)
- .nullable(true).withColumn("bar").ofType(ColumnType.BOOLEAN).nullable(true).execute();
+ Table table = cb.createTable(schema, "my_table").withColumn("id").asPrimaryKey().ofType(
+ ColumnType.INTEGER).ofNativeType("SERIAL").nullable(false).withColumn("name").ofType(
+ ColumnType.VARCHAR).ofSize(10).withColumn("foo").ofType(ColumnType.BOOLEAN).nullable(
+ true).withColumn("bar").ofType(ColumnType.BOOLEAN).nullable(true).execute();
assertEquals("my_table", table.getName());
}
@@ -267,9 +269,9 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, "my_table").withColumn("id").ofType(ColumnType.INTEGER)
- .ofNativeType("SERIAL").nullable(false).withColumn("name").ofType(ColumnType.VARCHAR)
- .ofSize(10).withColumn("foo").ofType(ColumnType.BOOLEAN).nullable(true).withColumn("bar")
- .ofType(ColumnType.BOOLEAN).nullable(true).execute();
+ .ofNativeType("SERIAL").nullable(false).withColumn("name").ofType(ColumnType.VARCHAR).ofSize(10)
+ .withColumn("foo").ofType(ColumnType.BOOLEAN).nullable(true).withColumn("bar").ofType(
+ ColumnType.BOOLEAN).nullable(true).execute();
assertEquals("my_table", table.getName());
}
@@ -329,6 +331,51 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
}
}
+ public void testJsonAndJsonbDatatypes() throws Exception {
+ if (!isConfigured()) {
+ return;
+ }
+
+ final JdbcDataContext dc = new JdbcDataContext(getConnection());
+
+ final Schema schema = dc.getDefaultSchema();
+
+ dc.executeUpdate(new UpdateScript() {
+ @Override
+ public void run(UpdateCallback cb) {
+ final Table table = cb.createTable(schema, "json_datatypes_table").withColumn("id").ofType(ColumnType.INTEGER)
+ .ofNativeType("SERIAL").asPrimaryKey().nullable(false).withColumn("col_json").ofNativeType(
+ "json").withColumn("col_jsonb").ofNativeType("jsonb").execute();
+ assertEquals("json_datatypes_table", table.getName());
+
+ final Map<String, Object> map = new HashMap<>();
+ map.put("foo", "bar");
+ cb.insertInto(table).value("id", 1).value("col_json", map).execute();
+ cb.insertInto(table).value("id", 2).value("col_jsonb", "{'foo':'baz'}".replace('\'', '"')).execute();
+ }
+ });
+
+ try {
+ final DataSet ds = dc.query().from("json_datatypes_table").select("col_json", "col_jsonb").execute();
+
+ assertTrue(ds.next());
+ assertEquals("Row[values=[{foo=bar}, null]]", ds.getRow().toString());
+ assertTrue(ds.getRow().getValue(0) instanceof Map);
+ assertTrue(ds.next());
+ assertEquals("Row[values=[null, {foo=baz}]]", ds.getRow().toString());
+ assertTrue(ds.getRow().getValue(1) instanceof Map);
+ assertFalse(ds.next());
+ } finally {
+ dc.executeUpdate(new UpdateScript() {
+ @Override
+ public void run(UpdateCallback cb) {
+ cb.dropTable("json_datatypes_table").execute();
+ }
+ });
+ }
+
+ }
+
/**
* Tests some inconsistencies dealing with booleans.
*
@@ -415,7 +462,7 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
assertTrue(ds.next());
Double nAn = (Double) ds.getRow().getValue(ds.getSelectItems()[0]);
assertFalse(ds.next());
-
+
assertEquals(Double.MIN_VALUE, minVal, DELTA);
assertEquals(Double.MAX_VALUE, maxVal, DELTA);
assertTrue(Double.isInfinite(negInf));
@@ -430,7 +477,7 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
});
}
}
-
+
public void testBlob() throws Exception {
if (!isConfigured()) {
return;
@@ -516,8 +563,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, "my_table").withColumn("id").ofType(ColumnType.INTEGER)
- .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255)
- .withColumn("age").ofType(ColumnType.INTEGER).execute();
+ .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255).withColumn(
+ "age").ofType(ColumnType.INTEGER).execute();
assertEquals("[id, person name, age]", Arrays.toString(table.getColumnNames()));
assertEquals(
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
@@ -582,8 +629,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, "my_table").withColumn("id").ofType(ColumnType.INTEGER)
- .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255)
- .withColumn("age").ofType(ColumnType.INTEGER).execute();
+ .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255).withColumn(
+ "age").ofType(ColumnType.INTEGER).execute();
assertEquals("[id, person name, age]", Arrays.toString(table.getColumnNames()));
assertEquals(
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
@@ -635,8 +682,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, "my_table").withColumn("id").ofType(ColumnType.INTEGER)
- .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255)
- .withColumn("age").ofType(ColumnType.INTEGER).execute();
+ .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255).withColumn(
+ "age").ofType(ColumnType.INTEGER).execute();
assertEquals("[id, person name, age]", Arrays.toString(table.getColumnNames()));
assertEquals(
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
@@ -706,10 +753,9 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
assertEquals("[Table[name=categories,type=TABLE,remarks=null], "
+ "Table[name=cust_hist,type=TABLE,remarks=null], " + "Table[name=customers,type=TABLE,remarks=null], "
- + "Table[name=inventory,type=TABLE,remarks=null], "
- + "Table[name=orderlines,type=TABLE,remarks=null], " + "Table[name=orders,type=TABLE,remarks=null], "
- + "Table[name=products,type=TABLE,remarks=null], " + "Table[name=reorder,type=TABLE,remarks=null]]",
- Arrays.toString(schema.getTables()));
+ + "Table[name=inventory,type=TABLE,remarks=null], " + "Table[name=orderlines,type=TABLE,remarks=null], "
+ + "Table[name=orders,type=TABLE,remarks=null], " + "Table[name=products,type=TABLE,remarks=null], "
+ + "Table[name=reorder,type=TABLE,remarks=null]]", Arrays.toString(schema.getTables()));
Table productsTable = schema.getTableByName("products");
assertEquals(
@@ -804,7 +850,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
Column quantityColumn = orderlinesTable.getColumnByName("quantity");
q.from(orderlinesTable);
- q.where(new FilterItem(new SelectItem(prodIdColumn), OperatorType.EQUALS_TO, new SelectItem(commonProdIdColumn)));
+ q.where(new FilterItem(new SelectItem(prodIdColumn), OperatorType.EQUALS_TO, new SelectItem(
+ commonProdIdColumn)));
q.groupBy(titleColumn);
q.getSelectClause().removeItem(q.getSelectClause().getSelectItem(productPriceColumn));
SelectItem quantitySum = new SelectItem(FunctionType.SUM, quantityColumn).setAlias("orderAmount");
@@ -815,7 +862,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
assertEquals("SELECT \"products\".\"title\" AS product-title, SUM(\"orderlines\".\"quantity\") AS orderAmount "
+ "FROM public.\"products\", public.\"orderlines\" "
+ "WHERE \"products\".\"prod_id\" = \"orderlines\".\"prod_id\" " + "GROUP BY \"products\".\"title\" "
- + "HAVING SUM(\"orderlines\".\"quantity\") > 25 " + "ORDER BY \"products\".\"title\" ASC", q.toString());
+ + "HAVING SUM(\"orderlines\".\"quantity\") > 25 " + "ORDER BY \"products\".\"title\" ASC", q
+ .toString());
data = dc.executeQuery(q);
tableModel = new DataSetTableModel(data);
assertEquals(2, tableModel.getColumnCount());
@@ -856,8 +904,8 @@ public class PostgresqlTest extends AbstractJdbIntegrationTest {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, "my_table").withColumn("id").ofType(ColumnType.INTEGER)
- .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255)
- .withColumn("age").ofType(ColumnType.INTEGER).execute();
+ .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255).withColumn(
+ "age").ofType(ColumnType.INTEGER).execute();
assertEquals("[id, person name, age]", Arrays.toString(table.getColumnNames()));
assertEquals(
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
[32/43] metamodel git commit: Updated line-endings
Posted by ka...@apache.org.
Updated line-endings
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/3f4c6d38
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/3f4c6d38
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/3f4c6d38
Branch: refs/heads/5.x
Commit: 3f4c6d38724efc4213cc055ad21e8841d9a3aa64
Parents: e68ef42
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sun Nov 13 11:00:44 2016 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sun Nov 13 11:00:44 2016 -0800
----------------------------------------------------------------------
.../naming/AlphabeticColumnNamingStrategy.java | 86 ++---
.../schema/naming/ColumnNamingContext.java | 104 +++---
.../schema/naming/ColumnNamingContextImpl.java | 128 +++----
.../schema/naming/ColumnNamingStrategies.java | 90 ++---
.../schema/naming/ColumnNamingStrategy.java | 62 ++--
.../naming/CustomColumnNamingStrategy.java | 124 +++----
...tingIntrinsicSwitchColumnNamingStrategy.java | 120 +++---
.../naming/UniqueColumnNamingStrategy.java | 124 +++----
.../insert/AbstractRowInsertionBuilderTest.java | 98 ++---
.../rest/JestElasticSearchUpdateCallback.java | 330 ++++++++--------
.../fixedwidth/FixedWidthColumnSpec.java | 90 ++---
.../fixedwidth/FixedWidthConfiguration.java | 372 +++++++++----------
.../FixedWidthConfigurationReader.java | 352 +++++++++---------
.../FixedWidthConfigurationReaderTest.java | 178 ++++-----
.../src/test/resources/metadata_spec1/data.txt | 10 +-
.../metadata_spec1/sas-formatfile-metadata.txt | 8 +-
.../metadata_spec1/sas-input-metadata.txt | 38 +-
17 files changed, 1157 insertions(+), 1157 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/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
index f6575c7..34498de 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,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/3f4c6d38/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
index b613913..b43ad87 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,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/3f4c6d38/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
index cc7a24e..ec77440 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,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/3f4c6d38/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 0696376..f0da83a 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,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/3f4c6d38/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
index 6ccccbf..27e85ea 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,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/3f4c6d38/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
index e6cc706..39397d7 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,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/3f4c6d38/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
index e18cb3a..35a0f39 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,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/3f4c6d38/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 d4d21dd..9321998 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,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/3f4c6d38/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
index fc9f6bd..1b8ea7c 100644
--- a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
+++ b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
@@ -1,49 +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.insert;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.schema.MutableColumn;
-import org.apache.metamodel.schema.MutableTable;
-import org.junit.Test;
-
-public class AbstractRowInsertionBuilderTest {
-
- @Test
- public void testToString() {
- final MutableTable table = new MutableTable("tbl");
- final MutableColumn col1 = new MutableColumn("col1").setTable(table);
- final MutableColumn col2 = new MutableColumn("col2").setTable(table);
- table.addColumn(col1).addColumn(col2);
-
- final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(
- null, table) {
- @Override
- public void execute() throws MetaModelException {
- throw new UnsupportedOperationException();
- }
- };
-
- builder.value(col1, "value1").value(col2, "value2");
- assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());
- }
-}
+/**
+ * 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.insert;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableTable;
+import org.junit.Test;
+
+public class AbstractRowInsertionBuilderTest {
+
+ @Test
+ public void testToString() {
+ final MutableTable table = new MutableTable("tbl");
+ final MutableColumn col1 = new MutableColumn("col1").setTable(table);
+ final MutableColumn col2 = new MutableColumn("col2").setTable(table);
+ table.addColumn(col1).addColumn(col2);
+
+ final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(
+ null, table) {
+ @Override
+ public void execute() throws MetaModelException {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ builder.value(col1, "value1").value(col2, "value2");
+ assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/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 521955d..94e557c 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,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 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/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
index dedfbcd..5f53ff5 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
@@ -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}.
- */
-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}.
+ */
+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/3f4c6d38/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 c53ff16..79aac36 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -1,186 +1,186 @@
-/**
- * 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 data context.
- */
-public 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 column naming strategy
- */
- 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 data context.
+ */
+public 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 column naming strategy
+ */
+ 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];
+ }
+}
[39/43] metamodel git commit: Updated CHANGES.md before release
Posted by ka...@apache.org.
Updated CHANGES.md before release
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/9dc6700e
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/9dc6700e
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/9dc6700e
Branch: refs/heads/5.x
Commit: 9dc6700e48942beb3b27ca474fc3797bac07851c
Parents: d99034b
Author: Kasper Sørensen <i....@gmail.com>
Authored: Tue Jan 31 12:59:59 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Tue Jan 31 12:59:59 2017 -0800
----------------------------------------------------------------------
CHANGES.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/9dc6700e/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 105aced..c70ac22 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-### Apache MetaModel [wip]
+### Apache MetaModel 4.5.6
* [METAMODEL-1136] - New connector for Amazon DynamoDB.
* [METAMODEL-1134] - Added NOT IN and NOT LIKE operators to WHERE filters.
[36/43] metamodel git commit: METAMODEL-1134: Fixed
Posted by ka...@apache.org.
METAMODEL-1134: Fixed
Closes #139
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/41a708f0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/41a708f0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/41a708f0
Branch: refs/heads/5.x
Commit: 41a708f04a1189ff23c60fee396f0e2b21e50d35
Parents: 95fa617
Author: Kasper Sørensen <i....@gmail.com>
Authored: Fri Jan 27 20:16:09 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Fri Jan 27 20:16:09 2017 -0800
----------------------------------------------------------------------
CHANGES.md | 4 ++
.../org/apache/metamodel/query/FilterItem.java | 12 +++-
.../apache/metamodel/query/OperatorType.java | 6 +-
.../metamodel/query/OperatorTypeImpl.java | 74 +++++++++++---------
.../query/builder/AbstractFilterBuilder.java | 24 +++++++
.../builder/AbstractQueryFilterBuilder.java | 21 ++++++
.../metamodel/query/builder/FilterBuilder.java | 22 ++++++
.../apache/metamodel/query/FilterItemTest.java | 28 ++++++++
.../query/builder/WhereBuilderImplTest.java | 28 ++++++++
.../jdbc/dialects/DefaultQueryRewriter.java | 5 +-
.../metamodel/jdbc/JdbcTestTemplates.java | 22 ++++++
11 files changed, 206 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 427ac21..475de9f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,7 @@
+### Apache MetaModel [wip]
+
+ * [METAMODEL-1134] - Added NOT IN and NOT LIKE operators to WHERE filters.
+
### Apache MetaModel 4.5.5
* [METAMODEL-1132] - Support native paging on SQL Server and Oracle database.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/core/src/main/java/org/apache/metamodel/query/FilterItem.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/FilterItem.java b/core/src/main/java/org/apache/metamodel/query/FilterItem.java
index 6fb7578..18e44cf 100644
--- a/core/src/main/java/org/apache/metamodel/query/FilterItem.java
+++ b/core/src/main/java/org/apache/metamodel/query/FilterItem.java
@@ -60,7 +60,7 @@ public class FilterItem extends BaseObject implements QueryItem, Cloneable, IRow
* Private constructor, used for cloning
*/
private FilterItem(SelectItem selectItem, OperatorType operator, Object operand, List<FilterItem> orItems,
- String expression, LogicalOperator logicalOperator) {
+ String expression, LogicalOperator logicalOperator) {
_selectItem = selectItem;
_operator = operator;
_operand = validateOperand(operand);
@@ -103,7 +103,7 @@ public class FilterItem extends BaseObject implements QueryItem, Cloneable, IRow
require("Can only use EQUALS or DIFFERENT_FROM operator with null-operand",
_operator == OperatorType.DIFFERENT_FROM || _operator == OperatorType.EQUALS_TO);
}
- if (_operator == OperatorType.LIKE) {
+ if (_operator == OperatorType.LIKE || _operator == OperatorType.NOT_LIKE) {
ColumnType type = _selectItem.getColumn().getType();
if (type != null) {
require("Can only use LIKE operator with strings", type.isLiteral()
@@ -295,7 +295,7 @@ public class FilterItem extends BaseObject implements QueryItem, Cloneable, IRow
sb.append(operator.toSql());
sb.append(' ');
- if (operator == OperatorType.IN) {
+ if (operator == OperatorType.IN || operator == OperatorType.NOT_IN) {
operand = CollectionUtils.toList(operand);
}
return operand;
@@ -375,9 +375,15 @@ public class FilterItem extends BaseObject implements QueryItem, Cloneable, IRow
} else if (_operator == OperatorType.LIKE) {
WildcardPattern matcher = new WildcardPattern((String) operandValue, '%');
return matcher.matches((String) selectItemValue);
+ } else if (_operator == OperatorType.NOT_LIKE) {
+ WildcardPattern matcher = new WildcardPattern((String) operandValue, '%');
+ return !matcher.matches((String) selectItemValue);
} else if (_operator == OperatorType.IN) {
Set<?> inValues = getInValues();
return inValues.contains(selectItemValue);
+ } else if (_operator == OperatorType.NOT_IN) {
+ Set<?> inValues = getInValues();
+ return !inValues.contains(selectItemValue);
} else {
throw new IllegalStateException("Operator could not be determined");
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/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 8c267d6..a0daccc 100644
--- a/core/src/main/java/org/apache/metamodel/query/OperatorType.java
+++ b/core/src/main/java/org/apache/metamodel/query/OperatorType.java
@@ -33,6 +33,8 @@ public interface OperatorType extends Serializable {
public static final OperatorType LIKE = new OperatorTypeImpl("LIKE", true);
+ public static final OperatorType NOT_LIKE = new OperatorTypeImpl("NOT LIKE", true);
+
public static final OperatorType GREATER_THAN = new OperatorTypeImpl(">", false);
public static final OperatorType GREATER_THAN_OR_EQUAL = new OperatorTypeImpl(">=", false);
@@ -43,8 +45,10 @@ public interface OperatorType extends Serializable {
public static final OperatorType IN = new OperatorTypeImpl("IN", true);
+ public static final OperatorType NOT_IN = new OperatorTypeImpl("NOT IN", true);
+
public static final OperatorType[] BUILT_IN_OPERATORS = new OperatorType[] { EQUALS_TO, DIFFERENT_FROM, LIKE,
- GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, IN };
+ NOT_LIKE, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, IN, NOT_IN };
/**
* Determines if this operator requires a space delimitor. Operators that are written using letters usually require
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/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 0eafe7d..753dc37 100644
--- a/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
+++ b/core/src/main/java/org/apache/metamodel/query/OperatorTypeImpl.java
@@ -75,40 +75,46 @@ public class OperatorTypeImpl implements OperatorType {
if (sqlType != null) {
sqlType = sqlType.trim().toUpperCase();
switch (sqlType) {
- case "=":
- case "==":
- case "EQ":
- case "EQUALS_TO":
- return OperatorType.EQUALS_TO;
- case "<>":
- case "!=":
- case "NE":
- case "NOT_EQUAL":
- case "NOT_EQUAL_TO":
- case "NOT_EQUALS":
- case "NOT_EQUALS_TO":
- case "DIFFERENT_FROM":
- return OperatorType.DIFFERENT_FROM;
- case ">":
- case "GT":
- case "GREATER_THAN":
- return OperatorType.GREATER_THAN;
- case ">=":
- case "=>":
- case "GREATER_THAN_OR_EQUAL":
- return OperatorType.GREATER_THAN_OR_EQUAL;
- case "IN":
- return OperatorType.IN;
- case "<":
- case "LT":
- case "LESS_THAN":
- return OperatorType.LESS_THAN;
- case "<=":
- case "=<":
- case "LESS_THAN_OR_EQUAL":
- return OperatorType.LESS_THAN_OR_EQUAL;
- case "LIKE":
- return OperatorType.LIKE;
+ case "=":
+ case "==":
+ case "EQ":
+ case "EQUALS_TO":
+ return OperatorType.EQUALS_TO;
+ case "<>":
+ case "!=":
+ case "NE":
+ case "NOT_EQUAL":
+ case "NOT_EQUAL_TO":
+ case "NOT_EQUALS":
+ case "NOT_EQUALS_TO":
+ case "DIFFERENT_FROM":
+ return OperatorType.DIFFERENT_FROM;
+ case ">":
+ case "GT":
+ case "GREATER_THAN":
+ return OperatorType.GREATER_THAN;
+ case ">=":
+ case "=>":
+ case "GREATER_THAN_OR_EQUAL":
+ return OperatorType.GREATER_THAN_OR_EQUAL;
+ case "NOT_IN":
+ case "NOT IN":
+ return OperatorType.NOT_IN;
+ case "IN":
+ return OperatorType.IN;
+ case "<":
+ case "LT":
+ case "LESS_THAN":
+ return OperatorType.LESS_THAN;
+ case "<=":
+ case "=<":
+ case "LESS_THAN_OR_EQUAL":
+ return OperatorType.LESS_THAN_OR_EQUAL;
+ case "LIKE":
+ return OperatorType.LIKE;
+ case "NOT_LIKE":
+ case "NOT LIKE":
+ return OperatorType.NOT_LIKE;
}
}
return null;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/core/src/main/java/org/apache/metamodel/query/builder/AbstractFilterBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/AbstractFilterBuilder.java b/core/src/main/java/org/apache/metamodel/query/builder/AbstractFilterBuilder.java
index f14b4af..2cf91ef 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/AbstractFilterBuilder.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/AbstractFilterBuilder.java
@@ -64,6 +64,21 @@ public abstract class AbstractFilterBuilder<B> implements FilterBuilder<B> {
}
@Override
+ public B notIn(Collection<?> values) {
+ return applyFilter(new FilterItem(_selectItem, OperatorType.NOT_IN, values));
+ }
+
+ @Override
+ public B notIn(Number... numbers) {
+ return applyFilter(new FilterItem(_selectItem, OperatorType.NOT_IN, numbers));
+ }
+
+ @Override
+ public B notIn(String... strings) {
+ return applyFilter(new FilterItem(_selectItem, OperatorType.NOT_IN, strings));
+ }
+
+ @Override
public B isNull() {
return applyFilter(new FilterItem(_selectItem, OperatorType.EQUALS_TO, null));
}
@@ -460,6 +475,15 @@ public abstract class AbstractFilterBuilder<B> implements FilterBuilder<B> {
}
@Override
+ public B notLike(String string) {
+ if (string == null) {
+ throw new IllegalArgumentException("string cannot be null");
+ }
+ return applyFilter(new FilterItem(_selectItem, OperatorType.NOT_LIKE, string));
+ }
+
+
+ @Override
public B gt(Column column) {
return greaterThan(column);
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/core/src/main/java/org/apache/metamodel/query/builder/AbstractQueryFilterBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/AbstractQueryFilterBuilder.java b/core/src/main/java/org/apache/metamodel/query/builder/AbstractQueryFilterBuilder.java
index 133bce0..6a0c900 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/AbstractQueryFilterBuilder.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/AbstractQueryFilterBuilder.java
@@ -57,6 +57,22 @@ abstract class AbstractQueryFilterBuilder<B> extends GroupedQueryBuilderCallback
}
@Override
+ public B notIn(Collection<?> values) {
+ return _filterBuilder.notIn(values);
+ }
+
+ @Override
+ public B notIn(Number... numbers) {
+ return _filterBuilder.notIn(numbers);
+ }
+
+ @Override
+ public B notIn(String... strings) {
+ return _filterBuilder.notIn(strings);
+ }
+
+
+ @Override
public B isNull() {
return _filterBuilder.isNull();
}
@@ -305,6 +321,11 @@ abstract class AbstractQueryFilterBuilder<B> extends GroupedQueryBuilderCallback
}
@Override
+ public B notLike(String string) {
+ return _filterBuilder.notLike(string);
+ }
+
+ @Override
public B gt(Column column) {
return greaterThan(column);
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/core/src/main/java/org/apache/metamodel/query/builder/FilterBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/query/builder/FilterBuilder.java b/core/src/main/java/org/apache/metamodel/query/builder/FilterBuilder.java
index 8ba1f62..a6cf57b 100644
--- a/core/src/main/java/org/apache/metamodel/query/builder/FilterBuilder.java
+++ b/core/src/main/java/org/apache/metamodel/query/builder/FilterBuilder.java
@@ -57,6 +57,21 @@ public interface FilterBuilder<B> {
public B in(String... strings);
/**
+ * Not in ...
+ */
+ public B notIn(Collection<?> values);
+
+ /**
+ * Not in ...
+ */
+ public B notIn(Number... numbers);
+
+ /**
+ * Not in ...
+ */
+ public B notIn(String... strings);
+
+ /**
* Like ...
*
* (use '%' as wildcard).
@@ -64,6 +79,13 @@ public interface FilterBuilder<B> {
public B like(String string);
/**
+ * Not like ...
+ *
+ * (use '%' as wildcard).
+ */
+ public B notLike(String string);
+
+ /**
* Equal to ...
*/
public B eq(Column column);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/core/src/test/java/org/apache/metamodel/query/FilterItemTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/query/FilterItemTest.java b/core/src/test/java/org/apache/metamodel/query/FilterItemTest.java
index 5024797..3b89d9d 100644
--- a/core/src/test/java/org/apache/metamodel/query/FilterItemTest.java
+++ b/core/src/test/java/org/apache/metamodel/query/FilterItemTest.java
@@ -428,6 +428,34 @@ public class FilterItemTest extends TestCase {
assertEquals("foo IN ()", new FilterItem(selectItem, OperatorType.IN, operand).toSql());
}
+ public void testNotInOperandSql() throws Exception {
+ SelectItem selectItem = new SelectItem("foo", "foo");
+ Object operand = new String[] { "foo", "bar" };
+ assertEquals("foo NOT IN ('foo' , 'bar')", new FilterItem(selectItem, OperatorType.NOT_IN, operand).toSql());
+
+ operand = Arrays.asList("foo", "bar", "baz");
+ assertEquals("foo NOT IN ('foo' , 'bar' , 'baz')", new FilterItem(selectItem, OperatorType.NOT_IN, operand).toSql());
+
+ operand = "foo";
+ assertEquals("foo NOT IN ('foo')", new FilterItem(selectItem, OperatorType.NOT_IN, operand).toSql());
+
+ operand = new ArrayList<Object>();
+ assertEquals("foo NOT IN ()", new FilterItem(selectItem, OperatorType.NOT_IN, operand).toSql());
+ }
+
+ public void testNotLikeOperandSql() throws Exception {
+ Column column = new MutableColumn("foo");
+ SelectItem selectItem = new SelectItem(column);
+ String operand = "%foo";
+ assertEquals("foo NOT LIKE '%foo'", new FilterItem(selectItem, OperatorType.NOT_LIKE, operand).toSql());
+
+ operand = "foo%";
+ assertEquals("foo NOT LIKE 'foo%'", new FilterItem(selectItem, OperatorType.NOT_LIKE, operand).toSql());
+
+ operand = "%foo%foo%";
+ assertEquals("foo NOT LIKE '%foo%foo%'", new FilterItem(selectItem, OperatorType.NOT_LIKE, operand).toSql());
+ }
+
public void testInOperandEvaluate() throws Exception {
SelectItem selectItem = new SelectItem(new MutableColumn("foo", ColumnType.VARCHAR, null, 1, null, null, true,
null, false, null));
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/core/src/test/java/org/apache/metamodel/query/builder/WhereBuilderImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/query/builder/WhereBuilderImplTest.java b/core/src/test/java/org/apache/metamodel/query/builder/WhereBuilderImplTest.java
index 68c7f72..f873d7d 100644
--- a/core/src/test/java/org/apache/metamodel/query/builder/WhereBuilderImplTest.java
+++ b/core/src/test/java/org/apache/metamodel/query/builder/WhereBuilderImplTest.java
@@ -49,6 +49,13 @@ public class WhereBuilderImplTest extends TestCase {
query.toSql());
}
+ public void testNotLike() throws Exception {
+ whereBuilder.eq(true).or(col2).notLike("%test%case%");
+
+ assertEquals(" WHERE (col1 = TRUE OR col2 NOT LIKE '%test%case%')",
+ query.toSql());
+ }
+
public void testAnd() throws Exception {
whereBuilder.differentFrom(true).and(col2).eq(1).or(col2).eq(2)
.or(col2).eq(3).and(new MutableColumn("col3")).eq(4);
@@ -65,12 +72,25 @@ public class WhereBuilderImplTest extends TestCase {
query.toSql());
}
+ public void testNotInStringArray() throws Exception {
+ whereBuilder.eq(true).or(col2).notIn("foo", "bar");
+
+ assertEquals(" WHERE (col1 = TRUE OR col2 NOT IN ('foo' , 'bar'))",
+ query.toSql());
+ }
+
public void testInNumberArray() throws Exception {
whereBuilder.eq(true).or(col2).in(3, 1);
assertEquals(" WHERE (col1 = TRUE OR col2 IN (3 , 1))", query.toSql());
}
+ public void testNotInNumberArray() throws Exception {
+ whereBuilder.eq(true).or(col2).notIn(3, 1);
+
+ assertEquals(" WHERE (col1 = TRUE OR col2 NOT IN (3 , 1))", query.toSql());
+ }
+
public void testInCollection() throws Exception {
Collection<?> col = Arrays.asList("foo", "bar");
whereBuilder.eq(true).or(col2).in(col);
@@ -78,4 +98,12 @@ public class WhereBuilderImplTest extends TestCase {
assertEquals(" WHERE (col1 = TRUE OR col2 IN ('foo' , 'bar'))",
query.toSql());
}
+
+ public void testNotInCollection() throws Exception {
+ Collection<?> col = Arrays.asList("foo", "bar");
+ whereBuilder.eq(true).or(col2).notIn(col);
+
+ assertEquals(" WHERE (col1 = TRUE OR col2 NOT IN ('foo' , 'bar'))",
+ query.toSql());
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
index 0dec7c1..90a2411 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
@@ -137,9 +137,10 @@ public class DefaultQueryRewriter extends AbstractQueryRewriter {
return rewriteFilterItemWithOperandLiteral(item, timestampLiteral);
} else if (operand instanceof Iterable || operand.getClass().isArray()) {
// operand is a set of values (typically in combination with an
- // IN operator). Each individual element must be escaped.
+ // IN or NOT IN operator). Each individual element must be escaped.
- assert OperatorType.IN.equals(item.getOperator());
+ assert OperatorType.IN.equals(item.getOperator()) ||
+ OperatorType.NOT_IN.equals(item.getOperator());
@SuppressWarnings("unchecked")
final List<Object> elements = (List<Object>) CollectionUtils.toList(operand);
http://git-wip-us.apache.org/repos/asf/metamodel/blob/41a708f0/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java
index f7d0cf2..f216a75 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java
@@ -205,6 +205,13 @@ public class JdbcTestTemplates {
assertFalse(ds.next());
ds.close();
+ // NOT LIKE
+ ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").notLike("%1").execute();
+ assertTrue(ds.next());
+ assertEquals("2", ds.getRow().getValue(0).toString());
+ assertFalse(ds.next());
+ ds.close();
+
// regular IN (with string)
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").in("C01", "C02")
.execute();
@@ -220,6 +227,21 @@ public class JdbcTestTemplates {
assertFalse(ds.next());
ds.close();
+ // regular NOT IN (with string)
+ ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").notIn("C01", "C02")
+ .execute();
+ assertTrue(ds.next());
+ assertEquals("1", ds.getRow().getValue(0).toString());
+ assertFalse(ds.next());
+ ds.close();
+
+ // regular NOT IN (with decimals)
+ ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("id").notIn(1.0, 2.0, 4.0).execute();
+ assertTrue(ds.next());
+ assertEquals("1", ds.getRow().getValue(0).toString());
+ assertFalse(ds.next());
+ ds.close();
+
// irregular IN (with null value) - (currently uses SQL's standard way
// of understanding NULL - see ticket #1058)
Query query = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code")
[09/43] metamodel git commit: Fixed javadoc issue and other minor
code issues prior to release
Posted by ka...@apache.org.
Fixed javadoc issue and other minor code issues prior to release
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/b8ce5ede
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/b8ce5ede
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/b8ce5ede
Branch: refs/heads/5.x
Commit: b8ce5ede8a7c3e6576b2e0da49ab634418e0b8d8
Parents: 6a7a151
Author: Kasper Sørensen <i....@gmail.com>
Authored: Mon Aug 1 21:32:17 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Aug 1 21:32:17 2016 -0700
----------------------------------------------------------------------
.../apache/metamodel/DataContextFactory.java | 22 ++++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/b8ce5ede/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 b4bf3f6..af12604 100644
--- a/full/src/main/java/org/apache/metamodel/DataContextFactory.java
+++ b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
@@ -193,9 +193,9 @@ public class DataContextFactory {
*/
public static UpdateableDataContext createCsvDataContext(File file, char separatorChar, char quoteChar,
String encoding) {
- CsvConfiguration configuration = new CsvConfiguration(CsvConfiguration.DEFAULT_COLUMN_NAME_LINE, encoding,
+ final CsvConfiguration configuration = new CsvConfiguration(CsvConfiguration.DEFAULT_COLUMN_NAME_LINE, encoding,
separatorChar, quoteChar, CsvConfiguration.DEFAULT_ESCAPE_CHAR);
- CsvDataContext dc = new CsvDataContext(file, configuration);
+ final CsvDataContext dc = new CsvDataContext(file, configuration);
return dc;
}
@@ -209,7 +209,7 @@ public class DataContextFactory {
* @return a DataContext object that matches the request
*/
public static UpdateableDataContext createCsvDataContext(File file, CsvConfiguration configuration) {
- CsvDataContext dc = new CsvDataContext(file, configuration);
+ final CsvDataContext dc = new CsvDataContext(file, configuration);
return dc;
}
@@ -243,9 +243,9 @@ public class DataContextFactory {
*/
public static DataContext createCsvDataContext(InputStream inputStream, char separatorChar, char quoteChar,
String encoding) {
- CsvConfiguration configuration = new CsvConfiguration(CsvConfiguration.DEFAULT_COLUMN_NAME_LINE, encoding,
+ final CsvConfiguration configuration = new CsvConfiguration(CsvConfiguration.DEFAULT_COLUMN_NAME_LINE, encoding,
separatorChar, quoteChar, CsvConfiguration.DEFAULT_ESCAPE_CHAR);
- CsvDataContext dc = new CsvDataContext(inputStream, configuration);
+ final CsvDataContext dc = new CsvDataContext(inputStream, configuration);
return dc;
}
@@ -259,7 +259,7 @@ public class DataContextFactory {
* @return a DataContext object that matches the request
*/
public static DataContext createCsvDataContext(InputStream inputStream, CsvConfiguration configuration) {
- CsvDataContext dc = new CsvDataContext(inputStream, configuration);
+ final CsvDataContext dc = new CsvDataContext(inputStream, configuration);
return dc;
}
@@ -289,14 +289,14 @@ public class DataContextFactory {
* @return a DataContext object that matches the request
*/
public static DataContext createFixedWidthDataContext(File file, FixedWidthConfiguration configuration) {
- FixedWidthDataContext dc = new FixedWidthDataContext(file, configuration);
+ final FixedWidthDataContext dc = new FixedWidthDataContext(file, configuration);
return dc;
}
/**
* Creates a DataContext based on a fixed width file.
*
- * @param file
- * the file to read from.
+ * @param resource
+ * the resource to read from.
* @param configuration
* the fixed width configuration to use
* @return a DataContext object that matches the request
@@ -567,7 +567,7 @@ public class DataContextFactory {
} else {
serverAddress = new ServerAddress(hostname, port);
}
- MongoClient mongoClient = null;
+ final MongoClient mongoClient;
final MongoDatabase mongoDb;
if (Strings.isNullOrEmpty(username)) {
mongoClient = new MongoClient(serverAddress);
@@ -649,7 +649,7 @@ public class DataContextFactory {
public static UpdateableDataContext createCouchDbDataContext(String hostname, Integer port, String username,
String password, SimpleTableDef[] tableDefs) {
- Builder httpClientBuilder = new Builder();
+ final Builder httpClientBuilder = new Builder();
httpClientBuilder.host(hostname);
if (port != null) {
httpClientBuilder.port(port);
[37/43] metamodel git commit: METAMODEL-1136: New Amazon DynamoDB
connector
Posted by ka...@apache.org.
METAMODEL-1136: New Amazon DynamoDB connector
Closes #140
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/5b98a633
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/5b98a633
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/5b98a633
Branch: refs/heads/5.x
Commit: 5b98a633a788a7a7c94c4a671eccf68609abc249
Parents: 41a708f
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sat Jan 28 10:54:35 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sat Jan 28 10:54:35 2017 -0800
----------------------------------------------------------------------
CHANGES.md | 1 +
dynamodb/.gitignore | 4 +
dynamodb/pom.xml | 62 ++++
.../metamodel/dynamodb/DynamoDbDataContext.java | 306 +++++++++++++++++++
.../metamodel/dynamodb/DynamoDbDataSet.java | 68 +++++
.../dynamodb/DynamoDbRowInsertionBuilder.java | 57 ++++
.../dynamodb/DynamoDbTableCreationBuilder.java | 112 +++++++
.../dynamodb/DynamoDbTableDropBuilder.java | 46 +++
.../dynamodb/DynamoDbUpdateCallback.java | 85 ++++++
.../metamodel/dynamodb/DynamoDbUtils.java | 105 +++++++
.../DynamoDbDataContextIntegrationTest.java | 211 +++++++++++++
...del-integrationtest-configuration.properties | 7 +
pom.xml | 1 +
13 files changed, 1065 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 475de9f..6ffda44 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,6 @@
### Apache MetaModel [wip]
+ * [METAMODEL-1136] - New connector for Amazon DynamoDB.
* [METAMODEL-1134] - Added NOT IN and NOT LIKE operators to WHERE filters.
### Apache MetaModel 4.5.5
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/.gitignore
----------------------------------------------------------------------
diff --git a/dynamodb/.gitignore b/dynamodb/.gitignore
new file mode 100644
index 0000000..4e247ee
--- /dev/null
+++ b/dynamodb/.gitignore
@@ -0,0 +1,4 @@
+/.settings
+/target
+/.classpath
+/.project
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/pom.xml
----------------------------------------------------------------------
diff --git a/dynamodb/pom.xml b/dynamodb/pom.xml
new file mode 100644
index 0000000..546a13b
--- /dev/null
+++ b/dynamodb/pom.xml
@@ -0,0 +1,62 @@
+<?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.6-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>MetaModel-dynamodb</artifactId>
+ <name>MetaModel module for Amazon AWS DynamoDB.</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.metamodel</groupId>
+ <artifactId>MetaModel-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk-dynamodb</artifactId>
+ <version>1.11.81</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </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/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataContext.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataContext.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataContext.java
new file mode 100644
index 0000000..5f95219
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataContext.java
@@ -0,0 +1,306 @@
+/**
+ * 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.dynamodb;
+
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.DefaultRow;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.data.SimpleDataSetHeader;
+import org.apache.metamodel.query.FilterItem;
+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.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 com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
+import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
+import com.amazonaws.services.dynamodbv2.model.AttributeValue;
+import com.amazonaws.services.dynamodbv2.model.DescribeTableResult;
+import com.amazonaws.services.dynamodbv2.model.GetItemRequest;
+import com.amazonaws.services.dynamodbv2.model.GetItemResult;
+import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndexDescription;
+import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
+import com.amazonaws.services.dynamodbv2.model.ListTablesResult;
+import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndexDescription;
+import com.amazonaws.services.dynamodbv2.model.ScanRequest;
+import com.amazonaws.services.dynamodbv2.model.ScanResult;
+import com.amazonaws.services.dynamodbv2.model.TableDescription;
+
+/**
+ * DataContext implementation for Amazon DynamoDB.
+ */
+public class DynamoDbDataContext extends QueryPostprocessDataContext implements UpdateableDataContext, Closeable {
+
+ /**
+ * System property key used for getting the read throughput capacity when
+ * creating new tables. Defaults to 5.
+ */
+ public static final String SYSTEM_PROPERTY_THROUGHPUT_READ_CAPACITY = "metamodel.dynamodb.throughput.capacity.read";
+
+ /**
+ * System property key used for getting the write throughput capacity when
+ * creating new tables. Defaults to 5.
+ */
+ public static final String SYSTEM_PROPERTY_THROUGHPUT_WRITE_CAPACITY = "metamodel.dynamodb.throughput.capacity.write";
+
+ /**
+ * The artificial schema name used by this DataContext.
+ */
+ public static final String SCHEMA_NAME = "public";
+
+ private final AmazonDynamoDB _dynamoDb;
+ private final boolean _shutdownOnClose;
+ private final SimpleTableDef[] _tableDefs;
+
+ public DynamoDbDataContext() {
+ this(AmazonDynamoDBClientBuilder.defaultClient(), null, true);
+ }
+
+ public DynamoDbDataContext(SimpleTableDef[] tableDefs) {
+ this(AmazonDynamoDBClientBuilder.defaultClient(), tableDefs, true);
+ }
+
+ public DynamoDbDataContext(AmazonDynamoDB client) {
+ this(client, null, false);
+ }
+
+ public DynamoDbDataContext(AmazonDynamoDB client, SimpleTableDef[] tableDefs) {
+ this(client, tableDefs, false);
+ }
+
+ private DynamoDbDataContext(AmazonDynamoDB client, SimpleTableDef[] tableDefs, boolean shutdownOnClose) {
+ _dynamoDb = client;
+ _tableDefs = (tableDefs == null ? new SimpleTableDef[0] : tableDefs);
+ _shutdownOnClose = shutdownOnClose;
+ }
+
+ public AmazonDynamoDB getDynamoDb() {
+ return _dynamoDb;
+ }
+
+ @Override
+ public void close() {
+ if (_shutdownOnClose) {
+ _dynamoDb.shutdown();
+ }
+ }
+
+ @Override
+ protected Schema getMainSchema() throws MetaModelException {
+ final Map<String, SimpleTableDef> tableDefs = new HashMap<>();
+ for (final SimpleTableDef tableDef : _tableDefs) {
+ tableDefs.put(tableDef.getName(), tableDef);
+ }
+
+ final MutableSchema schema = new MutableSchema(getMainSchemaName());
+ final ListTablesResult tables = _dynamoDb.listTables();
+ final List<String> tableNames = tables.getTableNames();
+ for (final String tableName : tableNames) {
+ final MutableTable table = new MutableTable(tableName, schema);
+ schema.addTable(table);
+
+ final DescribeTableResult descripeTableResult = _dynamoDb.describeTable(tableName);
+ final TableDescription tableDescription = descripeTableResult.getTable();
+
+ // add primary keys
+ addColumnFromKeySchema("Primary index", tableDescription.getKeySchema(), table, true);
+
+ // add attributes from global and local indices
+ final List<GlobalSecondaryIndexDescription> globalSecondaryIndexes = tableDescription
+ .getGlobalSecondaryIndexes();
+ if (globalSecondaryIndexes != null) {
+ for (final GlobalSecondaryIndexDescription globalSecondaryIndex : globalSecondaryIndexes) {
+ addColumnFromKeySchema(globalSecondaryIndex.getIndexName(), globalSecondaryIndex.getKeySchema(),
+ table, false);
+ }
+ }
+ final List<LocalSecondaryIndexDescription> localSecondaryIndexes = tableDescription
+ .getLocalSecondaryIndexes();
+ if (localSecondaryIndexes != null) {
+ for (final LocalSecondaryIndexDescription localSecondaryIndex : localSecondaryIndexes) {
+ addColumnFromKeySchema(localSecondaryIndex.getIndexName(), localSecondaryIndex.getKeySchema(),
+ table, false);
+ }
+ }
+
+ // add top-level attribute definitions
+ final List<AttributeDefinition> attributeDefinitions = tableDescription.getAttributeDefinitions();
+ for (final AttributeDefinition attributeDefinition : attributeDefinitions) {
+ final String attributeName = attributeDefinition.getAttributeName();
+ MutableColumn column = (MutableColumn) table.getColumnByName(attributeName);
+ if (column == null) {
+ column = new MutableColumn(attributeName, table);
+ table.addColumn(column);
+ }
+ final String attributeType = attributeDefinition.getAttributeType();
+ column.setType(DynamoDbUtils.toColumnType(attributeName, attributeType));
+ column.setIndexed(true);
+ column.setNativeType(attributeType);
+ }
+
+ // add additional metadata from SimpleTableDefs if available
+ final SimpleTableDef tableDef = tableDefs.get(tableName);
+ if (tableDef != null) {
+ final String[] columnNames = tableDef.getColumnNames();
+ final ColumnType[] columnTypes = tableDef.getColumnTypes();
+ for (int i = 0; i < columnNames.length; i++) {
+ final String columnName = columnNames[i];
+ final ColumnType columnType = columnTypes[i];
+ MutableColumn column = (MutableColumn) table.getColumnByName(columnName);
+ if (column == null) {
+ column = new MutableColumn(columnName, table);
+ table.addColumn(column);
+ }
+ if (column.getType() == null && columnType != null) {
+ column.setType(columnType);
+ }
+ }
+ }
+
+ // add additional attributes based on global and local indices
+ if (globalSecondaryIndexes != null) {
+ for (final GlobalSecondaryIndexDescription globalSecondaryIndex : globalSecondaryIndexes) {
+ final List<String> nonKeyAttributes = globalSecondaryIndex.getProjection().getNonKeyAttributes();
+ for (final String attributeName : nonKeyAttributes) {
+ addColumnFromNonKeyAttribute(globalSecondaryIndex.getIndexName(), table, attributeName);
+ }
+ }
+ }
+ if (localSecondaryIndexes != null) {
+ for (final LocalSecondaryIndexDescription localSecondaryIndex : localSecondaryIndexes) {
+ final List<String> nonKeyAttributes = localSecondaryIndex.getProjection().getNonKeyAttributes();
+ for (final String attributeName : nonKeyAttributes) {
+ addColumnFromNonKeyAttribute(localSecondaryIndex.getIndexName(), table, attributeName);
+ }
+ }
+ }
+ }
+ return schema;
+ }
+
+ private void addColumnFromNonKeyAttribute(String indexName, MutableTable table, String attributeName) {
+ MutableColumn column = (MutableColumn) table.getColumnByName(attributeName);
+ if (column == null) {
+ column = new MutableColumn(attributeName, table);
+ table.addColumn(column);
+ }
+ appendRemarks(column, indexName + " non-key attribute");
+ }
+
+ private void addColumnFromKeySchema(String indexName, List<KeySchemaElement> keySchema, MutableTable table,
+ boolean primaryKey) {
+ for (final KeySchemaElement keySchemaElement : keySchema) {
+ final String attributeName = keySchemaElement.getAttributeName();
+ if (table.getColumnByName(attributeName) == null) {
+ final String keyType = keySchemaElement.getKeyType();
+ final MutableColumn column = new MutableColumn(attributeName, table).setPrimaryKey(primaryKey);
+ appendRemarks(column, indexName + " member ('" + keyType + "' type)");
+ table.addColumn(column);
+ }
+ }
+ }
+
+ private static void appendRemarks(MutableColumn column, String remarks) {
+ final String existingRemarks = column.getRemarks();
+ if (existingRemarks == null) {
+ column.setRemarks(remarks);
+ } else {
+ column.setRemarks(existingRemarks + ", " + remarks);
+ }
+ }
+
+ @Override
+ protected String getMainSchemaName() throws MetaModelException {
+ return SCHEMA_NAME;
+ }
+
+ @Override
+ protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
+ if (!whereItems.isEmpty()) {
+ return null;
+ }
+ return _dynamoDb.describeTable(table.getName()).getTable().getItemCount();
+ }
+
+ @Override
+ protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
+ final List<String> attributeNames = new ArrayList<>(columns.length);
+ for (final Column column : columns) {
+ attributeNames.add(column.getName());
+ }
+ final ScanRequest scanRequest = new ScanRequest(table.getName());
+ scanRequest.setAttributesToGet(attributeNames);
+ if (maxRows > 0) {
+ scanRequest.setLimit(maxRows);
+ }
+ final ScanResult result = _dynamoDb.scan(scanRequest);
+ return new DynamoDbDataSet(columns, result);
+ }
+
+ @Override
+ protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
+ Object keyValue) {
+ final List<String> attributeNames = new ArrayList<>();
+ for (SelectItem selectItem : selectItems) {
+ attributeNames.add(selectItem.getColumn().getName());
+ }
+
+ final GetItemRequest getItemRequest = new GetItemRequest(table.getName(), Collections.singletonMap(
+ primaryKeyColumn.getName(), DynamoDbUtils.toAttributeValue(keyValue))).withAttributesToGet(
+ attributeNames);
+ final GetItemResult item = _dynamoDb.getItem(getItemRequest);
+
+ final Object[] values = new Object[selectItems.size()];
+ for (int i = 0; i < values.length; i++) {
+ final AttributeValue attributeValue = item.getItem().get(attributeNames.get(i));
+ values[i] = DynamoDbUtils.toValue(attributeValue);
+ }
+
+ return new DefaultRow(new SimpleDataSetHeader(selectItems), values);
+ }
+
+ @Override
+ public void executeUpdate(UpdateScript update) {
+ final DynamoDbUpdateCallback callback = new DynamoDbUpdateCallback(this);
+ try {
+ update.run(callback);
+ } finally {
+ if (callback.isInterrupted()) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataSet.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataSet.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataSet.java
new file mode 100644
index 0000000..17b781b
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbDataSet.java
@@ -0,0 +1,68 @@
+/**
+ * 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.dynamodb;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.metamodel.data.AbstractDataSet;
+import org.apache.metamodel.data.DataSetHeader;
+import org.apache.metamodel.data.DefaultRow;
+import org.apache.metamodel.data.Row;
+import org.apache.metamodel.schema.Column;
+
+import com.amazonaws.services.dynamodbv2.model.AttributeValue;
+import com.amazonaws.services.dynamodbv2.model.ScanResult;
+
+final class DynamoDbDataSet extends AbstractDataSet {
+
+ private final Iterator<Map<String, AttributeValue>> _iterator;
+ private Map<String, AttributeValue> _currentItem;
+
+ public DynamoDbDataSet(Column[] columns, ScanResult result) {
+ super(columns);
+ _iterator = result.getItems().iterator();
+ }
+
+ @Override
+ public boolean next() {
+ final boolean hasNext = _iterator.hasNext();
+ if (hasNext) {
+ _currentItem = _iterator.next();
+ return true;
+ }
+ _currentItem = null;
+ return false;
+ }
+
+ @Override
+ public Row getRow() {
+ if (_currentItem == null) {
+ return null;
+ }
+ final DataSetHeader header = getHeader();
+ final Object[] values = new Object[header.size()];
+ for (int i = 0; i < values.length; i++) {
+ final AttributeValue attributeValue = _currentItem.get(header.getSelectItem(i).getColumn().getName());
+ values[i] = DynamoDbUtils.toValue(attributeValue);
+ }
+ final Row row = new DefaultRow(header, values);
+ return row;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbRowInsertionBuilder.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbRowInsertionBuilder.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbRowInsertionBuilder.java
new file mode 100644
index 0000000..c97f815
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbRowInsertionBuilder.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.dynamodb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.insert.AbstractRowInsertionBuilder;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.Table;
+
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
+import com.amazonaws.services.dynamodbv2.model.AttributeValue;
+
+final class DynamoDbRowInsertionBuilder extends AbstractRowInsertionBuilder<DynamoDbUpdateCallback> {
+
+ public DynamoDbRowInsertionBuilder(DynamoDbUpdateCallback updateCallback, Table table) {
+ super(updateCallback, table);
+ }
+
+ @Override
+ public void execute() throws MetaModelException {
+ final Map<String, AttributeValue> itemValues = new HashMap<>();
+ final Column[] columns = getColumns();
+ final Object[] values = getValues();
+ for (int i = 0; i < columns.length; i++) {
+ final Column column = columns[i];
+ final Object value = values[i];
+ if (column.isPrimaryKey() && value == null) {
+ throw new IllegalArgumentException("Value for '" + column.getName() + "' cannot be null");
+ }
+
+ final AttributeValue attributeValue = DynamoDbUtils.toAttributeValue(value);
+ itemValues.put(column.getName(), attributeValue);
+ }
+
+ final AmazonDynamoDB dynamoDb = getUpdateCallback().getDataContext().getDynamoDb();
+ dynamoDb.putItem(getTable().getName(), itemValues);
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableCreationBuilder.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableCreationBuilder.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableCreationBuilder.java
new file mode 100644
index 0000000..c9779df
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableCreationBuilder.java
@@ -0,0 +1,112 @@
+/**
+ * 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.dynamodb;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.create.AbstractTableCreationBuilder;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
+import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
+import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
+import com.amazonaws.services.dynamodbv2.model.CreateTableResult;
+import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex;
+import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
+import com.amazonaws.services.dynamodbv2.model.KeyType;
+import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
+import com.amazonaws.services.dynamodbv2.model.TableStatus;
+
+class DynamoDbTableCreationBuilder extends AbstractTableCreationBuilder<DynamoDbUpdateCallback> {
+
+ private static final Logger logger = LoggerFactory.getLogger(DynamoDbTableCreationBuilder.class);
+
+ public DynamoDbTableCreationBuilder(DynamoDbUpdateCallback updateCallback, Schema schema, String name) {
+ super(updateCallback, schema, name);
+ }
+
+ @Override
+ public Table execute() throws MetaModelException {
+ final MutableTable table = getTable();
+ final String tableName = table.getName();
+
+ final Collection<AttributeDefinition> attributes = new ArrayList<>();
+ final Collection<KeySchemaElement> keySchema = new ArrayList<>();
+ final Collection<GlobalSecondaryIndex> globalSecondaryIndices = new ArrayList<>();
+
+ final long readCapacity = Long.parseLong(System.getProperty(
+ DynamoDbDataContext.SYSTEM_PROPERTY_THROUGHPUT_READ_CAPACITY, "5"));
+ final long writeCapacity = Long.parseLong(System.getProperty(
+ DynamoDbDataContext.SYSTEM_PROPERTY_THROUGHPUT_WRITE_CAPACITY, "5"));
+ final ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput(readCapacity, writeCapacity);
+
+ final Column[] columns = table.getColumns();
+ for (Column column : columns) {
+ if (column.isPrimaryKey()) {
+ final KeyType keyType = getKeyType(column.getRemarks());
+ keySchema.add(new KeySchemaElement(column.getName(), keyType));
+ attributes.add(new AttributeDefinition(column.getName(), DynamoDbUtils.toAttributeType(column
+ .getType())));
+ }
+ }
+
+ final CreateTableRequest createTableRequest = new CreateTableRequest();
+ createTableRequest.setTableName(tableName);
+ createTableRequest.setAttributeDefinitions(attributes);
+ createTableRequest.setGlobalSecondaryIndexes(globalSecondaryIndices);
+ createTableRequest.setKeySchema(keySchema);
+ createTableRequest.setProvisionedThroughput(provisionedThroughput);
+
+ final AmazonDynamoDB client = getUpdateCallback().getDataContext().getDynamoDb();
+
+ final CreateTableResult createTableResult = client.createTable(createTableRequest);
+
+ // await the table creation to be "done".
+ {
+ String tableStatus = createTableResult.getTableDescription().getTableStatus();
+ while (TableStatus.CREATING.name().equals(tableStatus)) {
+ logger.debug("Waiting for table status to be ACTIVE. Currently: {}", tableStatus);
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ getUpdateCallback().setInterrupted(true);
+ }
+ tableStatus = client.describeTable(tableName).getTable().getTableStatus();
+ }
+ }
+
+ return table;
+ }
+
+ private KeyType getKeyType(String remarks) {
+ if ("RANGE".equals(remarks)) {
+ // default
+ return KeyType.RANGE;
+ }
+ return KeyType.HASH;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableDropBuilder.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableDropBuilder.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableDropBuilder.java
new file mode 100644
index 0000000..a83682f
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbTableDropBuilder.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.dynamodb;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.drop.AbstractTableDropBuilder;
+import org.apache.metamodel.schema.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.amazonaws.services.dynamodbv2.model.DeleteTableResult;
+
+final class DynamoDbTableDropBuilder extends AbstractTableDropBuilder {
+
+ private static final Logger logger = LoggerFactory.getLogger(DynamoDbTableDropBuilder.class);
+ private final DynamoDbDataContext _dataContext;
+
+ public DynamoDbTableDropBuilder(Table table, DynamoDbDataContext dataContext) {
+ super(table);
+ _dataContext = dataContext;
+ }
+
+ @Override
+ public void execute() throws MetaModelException {
+ final String tableName = getTable().getName();
+ final DeleteTableResult result = _dataContext.getDynamoDb().deleteTable(tableName);
+ logger.debug("Dropped table {} in request ID: {}", tableName, result.getSdkResponseMetadata().getRequestId());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUpdateCallback.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUpdateCallback.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUpdateCallback.java
new file mode 100644
index 0000000..8efd01b
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUpdateCallback.java
@@ -0,0 +1,85 @@
+/**
+ * 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.dynamodb;
+
+import org.apache.metamodel.AbstractUpdateCallback;
+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;
+
+final class DynamoDbUpdateCallback extends AbstractUpdateCallback {
+
+ private boolean interrupted = false;
+
+ public DynamoDbUpdateCallback(DynamoDbDataContext dataContext) {
+ super(dataContext);
+ }
+
+ public boolean isInterrupted() {
+ return interrupted;
+ }
+
+ public void setInterrupted(boolean interrupted) {
+ this.interrupted = interrupted;
+ }
+
+ @Override
+ public DynamoDbDataContext getDataContext() {
+ return (DynamoDbDataContext) super.getDataContext();
+ }
+
+ @Override
+ public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
+ IllegalStateException {
+ return new DynamoDbTableCreationBuilder(this, schema, name);
+ }
+
+ @Override
+ public boolean isDropTableSupported() {
+ return true;
+ }
+
+ @Override
+ public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
+ UnsupportedOperationException {
+ return new DynamoDbTableDropBuilder(table, getDataContext());
+ }
+
+ @Override
+ public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
+ UnsupportedOperationException {
+ return new DynamoDbRowInsertionBuilder(this, table);
+ }
+
+ @Override
+ public boolean isDeleteSupported() {
+ return false;
+ }
+
+ @Override
+ public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
+ UnsupportedOperationException {
+ // This could be implemented ...
+ throw new UnsupportedOperationException();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUtils.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUtils.java b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUtils.java
new file mode 100644
index 0000000..e49636b
--- /dev/null
+++ b/dynamodb/src/main/java/org/apache/metamodel/dynamodb/DynamoDbUtils.java
@@ -0,0 +1,105 @@
+/**
+ * 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.dynamodb;
+
+import org.apache.metamodel.schema.ColumnType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.amazonaws.services.dynamodbv2.model.AttributeValue;
+import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
+
+final class DynamoDbUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(DynamoDbUtils.class);
+
+ // prevent instantiation
+ private DynamoDbUtils() {
+ }
+
+ public static AttributeValue toAttributeValue(Object value) {
+ if (value instanceof AttributeValue) {
+ return (AttributeValue) value;
+ }
+ final AttributeValue attributeValue = new AttributeValue();
+ if (value == null) {
+ attributeValue.setNULL(true);
+ } else if (value instanceof Number) {
+ attributeValue.setN(value.toString());
+ } else if (value instanceof Boolean) {
+ attributeValue.setBOOL((Boolean) value);
+ } else if (value instanceof String) {
+ attributeValue.setS(value.toString());
+ } else {
+ // TODO: Actually there's a few more value types we should support,
+ // see AttributeValue.setXxxx
+ throw new UnsupportedOperationException("Unsupported value type: " + value);
+ }
+ return attributeValue;
+ }
+
+ public static ScalarAttributeType toAttributeType(ColumnType type) {
+ if (type == null) {
+ return ScalarAttributeType.S;
+ }
+ if (type.isBinary()) {
+ return ScalarAttributeType.B;
+ }
+ if (type.isNumber()) {
+ return ScalarAttributeType.S;
+ }
+ // default to string
+ return ScalarAttributeType.S;
+ }
+
+ public static ColumnType toColumnType(String attributeName, String attributeType) {
+ if (attributeType == null) {
+ return null;
+ }
+ switch (attributeType) {
+ case "S":
+ return ColumnType.STRING;
+ case "N":
+ return ColumnType.NUMBER;
+ case "B":
+ return ColumnType.BINARY;
+ }
+ logger.warn("Unexpected attribute type '{}' for attribute: {}", attributeType, attributeName);
+ return null;
+ }
+
+ public static Object toValue(AttributeValue a) {
+ if (a == null || Boolean.TRUE == a.isNULL()) {
+ return null;
+ }
+ // dynamo is a bit funky this way ... it has a getter for each possible
+ // data type.
+ return firstNonNull(a.getB(), a.getBOOL(), a.getBS(), a.getL(), a.getM(), a.getN(), a.getNS(), a.getS(), a
+ .getSS());
+ }
+
+ private static Object firstNonNull(Object... objects) {
+ for (Object object : objects) {
+ if (object != null) {
+ return object;
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/dynamodb/src/test/java/org/apache/metamodel/dynamodb/DynamoDbDataContextIntegrationTest.java
----------------------------------------------------------------------
diff --git a/dynamodb/src/test/java/org/apache/metamodel/dynamodb/DynamoDbDataContextIntegrationTest.java b/dynamodb/src/test/java/org/apache/metamodel/dynamodb/DynamoDbDataContextIntegrationTest.java
new file mode 100644
index 0000000..967655d
--- /dev/null
+++ b/dynamodb/src/test/java/org/apache/metamodel/dynamodb/DynamoDbDataContextIntegrationTest.java
@@ -0,0 +1,211 @@
+/**
+ * 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.dynamodb;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.InMemoryDataSet;
+import org.apache.metamodel.schema.Column;
+import org.apache.metamodel.schema.ColumnType;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.SimpleTableDef;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.AWSCredentialsProvider;
+import com.amazonaws.auth.AWSStaticCredentialsProvider;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.regions.Regions;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
+import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
+import com.amazonaws.services.dynamodbv2.model.AttributeValue;
+import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
+import com.amazonaws.services.dynamodbv2.model.CreateTableResult;
+import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex;
+import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
+import com.amazonaws.services.dynamodbv2.model.KeyType;
+import com.amazonaws.services.dynamodbv2.model.Projection;
+import com.amazonaws.services.dynamodbv2.model.ProjectionType;
+import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
+import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
+
+public class DynamoDbDataContextIntegrationTest {
+
+ private AmazonDynamoDB client;
+
+ @Before
+ public void before() throws Exception {
+ final String userHome = System.getProperty("user.home");
+ final String propertiesFilename = userHome + "/metamodel-integrationtest-configuration.properties";
+ final File file = new File(propertiesFilename);
+
+ Assume.assumeTrue(file.exists());
+
+ final Properties props = new Properties();
+ props.load(new FileReader(file));
+
+ final String accessKey = props.getProperty("dynamodb.accessKey");
+ final String secretKey = props.getProperty("dynamodb.secretKey");
+
+ Assume.assumeNotNull(accessKey, secretKey);
+
+ final Regions region = Regions.fromName(props.getProperty("dynamodb.region", Regions.DEFAULT_REGION.getName()));
+
+ final AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
+ final AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
+ client = AmazonDynamoDBClientBuilder.standard().withRegion(region).withCredentials(credentialsProvider).build();
+ }
+
+ @After
+ public void after() {
+ if (client != null) {
+ client.shutdown();
+ }
+ }
+
+ @Test
+ public void testScenario1() throws Exception {
+ final String tableName = "MetaModel-" + UUID.randomUUID().toString();
+
+ final ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput(5l, 5l);
+
+ final Collection<AttributeDefinition> attributes = new ArrayList<>();
+ attributes.add(new AttributeDefinition("id", ScalarAttributeType.S));
+ attributes.add(new AttributeDefinition("counter", ScalarAttributeType.N));
+
+ final Collection<KeySchemaElement> keySchema = new ArrayList<>();
+ keySchema.add(new KeySchemaElement("id", KeyType.HASH));
+
+ // CreateDateIndex
+ final GlobalSecondaryIndex globalSecondaryIndex = new GlobalSecondaryIndex().withIndexName("counter_index")
+ .withProvisionedThroughput(provisionedThroughput).withKeySchema(new KeySchemaElement()
+ .withAttributeName("counter").withKeyType(KeyType.HASH)).withProjection(new Projection()
+ .withProjectionType(ProjectionType.INCLUDE).withNonKeyAttributes("foundation"));
+
+ final CreateTableRequest createTableRequest = new CreateTableRequest();
+ createTableRequest.setTableName(tableName);
+ createTableRequest.setAttributeDefinitions(attributes);
+ createTableRequest.setGlobalSecondaryIndexes(Arrays.asList(globalSecondaryIndex));
+ createTableRequest.setKeySchema(keySchema);
+ createTableRequest.setProvisionedThroughput(provisionedThroughput);
+ final CreateTableResult createTableResult = client.createTable(createTableRequest);
+
+ // await the table creation to be "done".
+ {
+ String tableStatus = createTableResult.getTableDescription().getTableStatus();
+ while (!"ACTIVE".equals(tableStatus)) {
+ System.out.println("Waiting for table status to be ACTIVE. Currently: " + tableStatus);
+ Thread.sleep(300);
+ tableStatus = client.describeTable(tableName).getTable().getTableStatus();
+ }
+ }
+
+ client.putItem(tableName, createItem("id", "foo", "counter", 1, "foundation", "Apache"));
+ client.putItem(tableName, createItem("id", "bar", "counter", 2, "project", "MetaModel"));
+ client.putItem(tableName, createItem("id", "baz", "counter", 3, "url", "http://metamodel.apache.org"));
+
+ final SimpleTableDef[] tableDefs = new SimpleTableDef[] { new SimpleTableDef(tableName, new String[] {
+ "counter", "project" }, new ColumnType[] { ColumnType.INTEGER, ColumnType.STRING }) };
+
+ try {
+ try (final DynamoDbDataContext dc = new DynamoDbDataContext(client, tableDefs)) {
+
+ final Table table = dc.getTableByQualifiedLabel(tableName);
+ assertEquals(tableName, table.getName());
+
+ // Right now we can only discover indexed columns
+ assertEquals("[id, counter, project, foundation]", Arrays.toString(table.getColumnNames()));
+
+ final Column idColumn = table.getColumnByName("id");
+ assertEquals(true, idColumn.isPrimaryKey());
+ assertEquals(true, idColumn.isIndexed());
+ assertEquals(ColumnType.STRING, idColumn.getType());
+ assertEquals("Primary index member ('HASH' type)", idColumn.getRemarks());
+
+ final Column counterColumn = table.getColumnByName("counter");
+ assertEquals(ColumnType.NUMBER, counterColumn.getType());
+ assertEquals(true, counterColumn.isIndexed());
+ assertEquals(false, counterColumn.isPrimaryKey());
+ assertEquals("counter_index member ('HASH' type)", counterColumn.getRemarks());
+
+ final Column projectColumn = table.getColumnByName("project");
+ assertEquals(ColumnType.STRING, projectColumn.getType());
+ assertEquals(false, projectColumn.isIndexed());
+ assertEquals(false, projectColumn.isPrimaryKey());
+ assertEquals(null, projectColumn.getRemarks());
+
+ final Column foundationColumn = table.getColumnByName("foundation");
+ assertEquals(null, foundationColumn.getType());
+ assertEquals(false, foundationColumn.isIndexed());
+ assertEquals(false, foundationColumn.isPrimaryKey());
+ assertEquals("counter_index non-key attribute", foundationColumn.getRemarks());
+
+ try (final DataSet dataSet = dc.query().from(table).select("id", "counter", "project").orderBy("id")
+ .execute()) {
+ assertTrue(dataSet.next());
+ assertEquals("Row[values=[bar, 2, MetaModel]]", dataSet.getRow().toString());
+ assertTrue(dataSet.next());
+ assertEquals("Row[values=[baz, 3, null]]", dataSet.getRow().toString());
+ assertTrue(dataSet.next());
+ assertEquals("Row[values=[foo, 1, null]]", dataSet.getRow().toString());
+ assertFalse(dataSet.next());
+ }
+
+ try (final DataSet dataSet = dc.query().from(tableName).select("counter", "project").where("id").eq(
+ "baz").execute()) {
+ assertTrue(dataSet instanceof InMemoryDataSet);
+
+ assertTrue(dataSet.next());
+ assertEquals("Row[values=[3, null]]", dataSet.getRow().toString());
+ assertFalse(dataSet.next());
+ }
+ }
+ } finally {
+ client.deleteTable(tableName);
+ }
+ }
+
+ // convenience method
+ private Map<String, AttributeValue> createItem(Object... keyAndValues) {
+ final Map<String, AttributeValue> map = new HashMap<>();
+ for (int i = 0; i < keyAndValues.length; i = i + 2) {
+ final String key = (String) keyAndValues[i];
+ final Object value = keyAndValues[i + 1];
+ map.put(key, DynamoDbUtils.toAttributeValue(value));
+ }
+ return map;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/example-metamodel-integrationtest-configuration.properties
----------------------------------------------------------------------
diff --git a/example-metamodel-integrationtest-configuration.properties b/example-metamodel-integrationtest-configuration.properties
index 83c5f4e..4f3cbfe 100644
--- a/example-metamodel-integrationtest-configuration.properties
+++ b/example-metamodel-integrationtest-configuration.properties
@@ -30,6 +30,13 @@
#hadoop.hdfs.port=9000
#hadoop.hdfs.file.path=/apache_metamodel_testfile.txt
+# ----------------------------
+# Dynamo DB module properties:
+# ----------------------------
+
+#dynamodb.accessKey=
+#dynamodb.secretKey=
+#dynamodb.region=us-west-2
# ------------------------
# HBase module properties:
http://git-wip-us.apache.org/repos/asf/metamodel/blob/5b98a633/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5170658..72d3672 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@ under the License.
<module>core</module>
<module>pojo</module>
<module>fixedwidth</module>
+ <module>dynamodb</module>
<module>excel</module>
<module>csv</module>
<module>json</module>
[10/43] metamodel git commit: [maven-release-plugin] prepare release
MetaModel-4.5.4
Posted by ka...@apache.org.
[maven-release-plugin] prepare release MetaModel-4.5.4
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/fd65c4e9
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/fd65c4e9
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/fd65c4e9
Branch: refs/heads/5.x
Commit: fd65c4e9bd408af60fe45b28f7416ac643583248
Parents: b8ce5ed
Author: Kasper Sørensen <i....@gmail.com>
Authored: Mon Aug 1 21:34:26 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Aug 1 21:34:26 2016 -0700
----------------------------------------------------------------------
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 | 104 +++++++++++++++++++-------------------
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, 79 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 7a84f6e..5797021 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-cassandra</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 4f34660..0fa14b9 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index 3563e1d..aa5742e 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-couchdb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index f2c7c43..dfdf5a6 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-csv</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index a11ff50..3c08a5b 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index dc3ed9c..1e98795 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 31b05a9..8baca5e 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-elasticsearch</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 0af3ec5..e5983d0 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 4d10b16..49663fb 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-excel</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 7461e86..d24c2e7 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -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.4-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>4.5.4</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/fd65c4e9/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index df1572e..6444bcc 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-full</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 618bf47..e4851d4 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hadoop</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index fa74f1b..24bb19e 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-hbase</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 3969b1c..bcb7203 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-jdbc</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index 44bd2a0..20440ee 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-json</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 19fbb1a..770adf7 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-common</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 4bab569..39e1663 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo2</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index da46b43..57028c3 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb-mongo3</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 59a61a5..9d9fb6f 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-mongodb</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 15852d1..a0e4341 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-neo4j</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index e311520..a7bd368 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-openoffice</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index d3fcc93..80eeac0 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-pojo</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 95ed697..e25cc7e 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.4</tag>
</scm>
<groupId>org.apache.metamodel</groupId>
<artifactId>MetaModel</artifactId>
- <version>4.5.4-SNAPSHOT</version>
+ <version>4.5.4</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/fd65c4e9/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index a43577b..857bfb6 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-salesforce</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index aef691d..c5e6b9c 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-spring</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index a13c33e..f1167cb 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-sugarcrm</artifactId>
http://git-wip-us.apache.org/repos/asf/metamodel/blob/fd65c4e9/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 70a2223..a340316 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.4-SNAPSHOT</version>
+ <version>4.5.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MetaModel-xml</artifactId>
[30/43] metamodel git commit: Updated CHANGES file with METAMODEL-1128
Posted by ka...@apache.org.
Updated CHANGES file with METAMODEL-1128
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/e68ef424
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/e68ef424
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/e68ef424
Branch: refs/heads/5.x
Commit: e68ef424b2435d6a95be38e19c145809520f633d
Parents: f18ae8b
Author: kaspersorensen <i....@gmail.com>
Authored: Fri Nov 11 13:40:56 2016 -0800
Committer: kaspersorensen <i....@gmail.com>
Committed: Fri Nov 11 13:40:56 2016 -0800
----------------------------------------------------------------------
CHANGES.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/e68ef424/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 0ee551c..5d8f394 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,6 @@
### Apache MetaModel 4.5.5
+ * [METAMODEL-1128] - Fixed bug pertaining to ElasticSearch REST data set scrolling.
* [METAMODEL-1118] - Fixed bug pertaining to cloning of FilterItem.LogicalOperator in compiled queries.
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
* [METAMODEL-1122] - Optimized the way the Cassandra module executes primary key lookup queries.
[18/43] metamodel git commit: Added missing SQL keywords
Posted by ka...@apache.org.
Added missing SQL keywords
Closes #127
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/8a17fbfb
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/8a17fbfb
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/8a17fbfb
Branch: refs/heads/5.x
Commit: 8a17fbfbb4c37c702fd362a25bc401268a08e3f1
Parents: 288fcca
Author: Laxmi Lal Menaria <me...@gmail.com>
Authored: Tue Aug 30 13:43:59 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Tue Aug 30 13:43:59 2016 -0700
----------------------------------------------------------------------
jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/8a17fbfb/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
index 7ffb6c9..4e50679 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/SqlKeywords.java
@@ -58,6 +58,13 @@ class SqlKeywords {
KEYWORDS.add("DELETE");
KEYWORDS.add("AND");
KEYWORDS.add("OR");
+ KEYWORDS.add("BEGIN");
+ KEYWORDS.add("END");
+ KEYWORDS.add("COLUMN");
+ KEYWORDS.add("TABLE");
+ KEYWORDS.add("SCHEMA");
+ KEYWORDS.add("DATABASE");
+ KEYWORDS.add("CAST");
}
public static boolean isKeyword(String str) {
[19/43] metamodel git commit: METAMODEL-1113: Fixed
Posted by ka...@apache.org.
METAMODEL-1113: Fixed
Fixes #125
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/9c8f0b9d
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/9c8f0b9d
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/9c8f0b9d
Branch: refs/heads/5.x
Commit: 9c8f0b9d100853431f20b5761b4364c04276452b
Parents: 8a17fbf
Author: Arjan Seijkens <Ar...@humaninference.com>
Authored: Mon Sep 5 21:11:40 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Sep 5 21:12:35 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../apache/metamodel/csv/CsvConfiguration.java | 2 +-
.../metamodel/csv/CsvDataContextTest.java | 23 ++++++++++++++++++++
.../metamodel/excel/ExcelDataContextTest.java | 17 +++++++++++++++
.../fixedwidth/FixedWidthDataContextTest.java | 17 +++++++++++++++
5 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/9c8f0b9d/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 0c06db2..c8f288f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,6 +3,7 @@
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
* [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
* [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
+ * [METAMODEL-1113] - Fixed support for ColumnNamingStrategy in CSV connector.
### Apache MetaModel 4.5.4
http://git-wip-us.apache.org/repos/asf/metamodel/blob/9c8f0b9d/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 abcf2d4..332ef4b 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
@@ -94,7 +94,7 @@ public final class CsvConfiguration extends BaseObject implements Serializable {
this.escapeChar = escapeChar;
this.failOnInconsistentRowLength = failOnInconsistentRowLength;
this.multilineValues = multilineValues;
- this.columnNamingStrategy = null;
+ this.columnNamingStrategy = columnNamingStrategy;
}
/**
http://git-wip-us.apache.org/repos/asf/metamodel/blob/9c8f0b9d/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextTest.java
----------------------------------------------------------------------
diff --git a/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextTest.java b/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextTest.java
index e417cf6..39f9d43 100644
--- a/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextTest.java
+++ b/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextTest.java
@@ -48,6 +48,7 @@ import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.MutableColumn;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.schema.naming.CustomColumnNamingStrategy;
import org.apache.metamodel.util.FileHelper;
import org.apache.metamodel.util.MutableRef;
@@ -828,4 +829,26 @@ public class CsvDataContextTest extends TestCase {
// e.getMessage());
// }
// }
+
+ public void testCustomColumnNames() throws Exception {
+ final String firstColumnName = "first";
+ final String secondColumnName = "second";
+ final String thirdColumnName = "third";
+ final String fourthColumnName = "fourth";
+
+ final CsvConfiguration configuration = new CsvConfiguration(CsvConfiguration.DEFAULT_COLUMN_NAME_LINE,
+ new CustomColumnNamingStrategy(firstColumnName, secondColumnName, thirdColumnName, fourthColumnName),
+ FileHelper.DEFAULT_ENCODING, CsvConfiguration.DEFAULT_SEPARATOR_CHAR,
+ CsvConfiguration.DEFAULT_QUOTE_CHAR, CsvConfiguration.DEFAULT_ESCAPE_CHAR, false, true);
+
+ final DataContext dataContext = new CsvDataContext(new File("src/test/resources/csv_people.csv"),
+ configuration);
+
+ final Table table = dataContext.getDefaultSchema().getTable(0);
+
+ assertNotNull(table.getColumnByName(firstColumnName));
+ assertNotNull(table.getColumnByName(secondColumnName));
+ assertNotNull(table.getColumnByName(thirdColumnName));
+ assertNotNull(table.getColumnByName(fourthColumnName));
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/9c8f0b9d/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 3b69290..f8406c3 100644
--- a/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
+++ b/excel/src/test/java/org/apache/metamodel/excel/ExcelDataContextTest.java
@@ -36,6 +36,7 @@ import org.apache.metamodel.query.Query;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.schema.naming.CustomColumnNamingStrategy;
import org.apache.metamodel.util.DateUtils;
import org.apache.metamodel.util.FileHelper;
import org.apache.metamodel.util.Month;
@@ -775,4 +776,20 @@ public class ExcelDataContextTest extends TestCase {
assertNotNull(ds);
ds.close();
}
+
+ public void testCustomColumnNames() throws Exception {
+ final String firstColumnName = "first";
+ final String secondColumnName = "second";
+ final String thirdColumnName = "third";
+
+ final ExcelConfiguration configuration = new ExcelConfiguration(ExcelConfiguration.DEFAULT_COLUMN_NAME_LINE,
+ new CustomColumnNamingStrategy(firstColumnName, secondColumnName, thirdColumnName), true, false);
+ final DataContext dataContext = new ExcelDataContext(copyOf("src/test/resources/Spreadsheet2007.xlsx"),
+ configuration);
+ final Table table = dataContext.getDefaultSchema().getTable(0);
+
+ assertNotNull(table.getColumnByName(firstColumnName));
+ assertNotNull(table.getColumnByName(secondColumnName));
+ assertNotNull(table.getColumnByName(thirdColumnName));
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/metamodel/blob/9c8f0b9d/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
index 7962cf6..7a4b75f 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
@@ -28,6 +28,7 @@ import org.apache.metamodel.data.DataSet;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.schema.naming.CustomColumnNamingStrategy;
public class FixedWidthDataContextTest extends TestCase {
@@ -221,4 +222,20 @@ public class FixedWidthDataContextTest extends TestCase {
assertEquals("[3, howdy, partner]", Arrays.toString(ds.getRow().getValues()));
assertFalse(ds.next());
}
+
+ public void testCustomColumnNames() throws Exception {
+ final String firstColumnName = "first";
+ final String secondColumnName = "second";
+
+ final FixedWidthConfiguration configuration = new FixedWidthConfiguration(
+ FixedWidthConfiguration.DEFAULT_COLUMN_NAME_LINE, new CustomColumnNamingStrategy(firstColumnName,
+ secondColumnName), "UTF8", new int[] { 10, 10 }, true);
+
+ final DataContext dataContext = new FixedWidthDataContext(new File("src/test/resources/example_simple1.txt"),
+ configuration);
+ final Table table = dataContext.getDefaultSchema().getTable(0);
+
+ assertNotNull(table.getColumnByName(firstColumnName));
+ assertNotNull(table.getColumnByName(secondColumnName));
+ }
}
[23/43] metamodel git commit: METAMODEL-1122: Fixed
Posted by ka...@apache.org.
METAMODEL-1122: Fixed
Fixes #130
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/42367685
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/42367685
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/42367685
Branch: refs/heads/5.x
Commit: 423676852d8f147905b12ba0203d15771aff87ae
Parents: fe3aebe
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sat Oct 8 23:57:36 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sat Oct 8 23:57:36 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
cassandra/.gitignore | 1 +
.../cassandra/CassandraDataContext.java | 74 +++++++++++++++++---
.../cassandra/CassandraDataContextTest.java | 18 ++++-
4 files changed, 84 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/42367685/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index bda2372..5c0b893 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
* [METAMODEL-1118] - Fixed bug pertaining to cloning of FilterItem.LogicalOperator in compiled queries.
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
+ * [METAMODEL-1122] - Optimized the way the Cassandra module executes primary key lookup queries.
* [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
* [METAMODEL-1115] - Added support for passing your own PartnerConnection object to the Salesforce.com connector.
* [METAMODEL-1113] - Fixed support for ColumnNamingStrategy in CSV connector.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/42367685/cassandra/.gitignore
----------------------------------------------------------------------
diff --git a/cassandra/.gitignore b/cassandra/.gitignore
index 4e247ee..212512c 100644
--- a/cassandra/.gitignore
+++ b/cassandra/.gitignore
@@ -2,3 +2,4 @@
/target
/.classpath
/.project
+/.toDelete
http://git-wip-us.apache.org/repos/asf/metamodel/blob/42367685/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraDataContext.java
----------------------------------------------------------------------
diff --git a/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraDataContext.java b/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraDataContext.java
index e99570b..3a1684e 100644
--- a/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraDataContext.java
+++ b/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraDataContext.java
@@ -18,23 +18,41 @@
*/
package org.apache.metamodel.cassandra;
-import com.datastax.driver.core.*;
-import com.datastax.driver.core.querybuilder.QueryBuilder;
-import com.datastax.driver.core.querybuilder.Select;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
import org.apache.metamodel.DataContext;
import org.apache.metamodel.MetaModelException;
import org.apache.metamodel.QueryPostprocessDataContext;
import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.data.SimpleDataSetHeader;
import org.apache.metamodel.query.FilterItem;
-import org.apache.metamodel.schema.*;
+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.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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ColumnMetadata;
+import com.datastax.driver.core.DataType;
+import com.datastax.driver.core.KeyspaceMetadata;
+import com.datastax.driver.core.Metadata;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Statement;
+import com.datastax.driver.core.TableMetadata;
+import com.datastax.driver.core.querybuilder.QueryBuilder;
+import com.datastax.driver.core.querybuilder.Select;
+import com.datastax.driver.core.querybuilder.Select.Selection;
/**
* DataContext implementation for Apache Cassandra database.
@@ -145,6 +163,20 @@ public class CassandraDataContext extends QueryPostprocessDataContext implements
final MutableSchema theSchema = new MutableSchema(getMainSchemaName());
for (final SimpleTableDef tableDef : tableDefs) {
final MutableTable table = tableDef.toTable().setSchema(theSchema);
+
+ final TableMetadata cassandraTable = cassandraCluster.getMetadata().getKeyspace(keySpaceName).getTable(table
+ .getName());
+ if (cassandraTable != null) {
+ final List<ColumnMetadata> primaryKeys = cassandraTable.getPrimaryKey();
+ for (ColumnMetadata primaryKey : primaryKeys) {
+ final MutableColumn column = (MutableColumn) table.getColumnByName(primaryKey.getName());
+ if (column != null) {
+ column.setPrimaryKey(true);
+ }
+ column.setNativeType(primaryKey.getType().getName().name());
+ }
+ }
+
theSchema.addTable(table);
}
return theSchema;
@@ -162,7 +194,7 @@ public class CassandraDataContext extends QueryPostprocessDataContext implements
query.limit(maxRows);
}
final ResultSet resultSet = cassandraCluster.connect().execute(query);
-
+
final Iterator<Row> response = resultSet.iterator();
return new CassandraDataSet(response, columns);
}
@@ -172,10 +204,34 @@ public class CassandraDataContext extends QueryPostprocessDataContext implements
}
@Override
+ protected org.apache.metamodel.data.Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems,
+ Column primaryKeyColumn, Object keyValue) {
+
+ if (primaryKeyColumn.getType() == ColumnType.UUID && keyValue instanceof String) {
+ keyValue = UUID.fromString(keyValue.toString());
+ }
+
+ Selection select = QueryBuilder.select();
+ for (SelectItem selectItem : selectItems) {
+ final Column column = selectItem.getColumn();
+ assert column != null;
+ select = select.column(column.getName());
+ }
+
+ final Statement statement = select.from(keySpaceName, table.getName()).where(QueryBuilder.eq(primaryKeyColumn
+ .getName(), keyValue));
+
+ final Row row = cassandraCluster.connect().execute(statement).one();
+
+ return CassandraUtils.toRow(row, new SimpleDataSetHeader(selectItems));
+ }
+
+ @Override
protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
if (!whereItems.isEmpty()) {
// not supported - will have to be done by counting client-side
- logger.debug("Not able to execute count query natively - resorting to query post-processing, which may be expensive");
+ logger.debug(
+ "Not able to execute count query natively - resorting to query post-processing, which may be expensive");
return null;
}
final Statement statement = QueryBuilder.select().countAll().from(keySpaceName, table.getName());
http://git-wip-us.apache.org/repos/asf/metamodel/blob/42367685/cassandra/src/test/java/org/apache/metamodel/cassandra/CassandraDataContextTest.java
----------------------------------------------------------------------
diff --git a/cassandra/src/test/java/org/apache/metamodel/cassandra/CassandraDataContextTest.java b/cassandra/src/test/java/org/apache/metamodel/cassandra/CassandraDataContextTest.java
index 4921639..a9d9605 100644
--- a/cassandra/src/test/java/org/apache/metamodel/cassandra/CassandraDataContextTest.java
+++ b/cassandra/src/test/java/org/apache/metamodel/cassandra/CassandraDataContextTest.java
@@ -32,6 +32,7 @@ import javax.swing.table.TableModel;
import org.apache.metamodel.data.DataSet;
import org.apache.metamodel.data.DataSetTableModel;
import org.apache.metamodel.data.FilteredDataSet;
+import org.apache.metamodel.data.InMemoryDataSet;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.query.parser.QueryParserException;
import org.apache.metamodel.schema.ColumnType;
@@ -113,7 +114,7 @@ public class CassandraDataContextTest {
@Test
public void testWhereColumnEqualsValues() throws Exception {
- DataSet ds = dc.query().from(testTableName).select("id").and("title").where("id").isEquals(firstRowId)
+ DataSet ds = dc.query().from(testTableName).select("id").and("title").where("title").isEquals(firstRowTitle)
.execute();
assertEquals(FilteredDataSet.class, ds.getClass());
@@ -125,6 +126,21 @@ public class CassandraDataContextTest {
ds.close();
}
}
+
+ @Test
+ public void testPrimaryKeyLookup() throws Exception {
+ DataSet ds = dc.query().from(testTableName).select("id").and("title").where("id").isEquals(firstRowId)
+ .execute();
+
+ assertEquals(InMemoryDataSet.class, ds.getClass());
+ try {
+ assertTrue(ds.next());
+ assertEquals("Row[values=[" + firstRowId + ", " + firstRowTitle + "]]", ds.getRow().toString());
+ assertFalse(ds.next());
+ } finally {
+ ds.close();
+ }
+ }
@Test
public void testWhereColumnInValues() throws Exception {
[07/43] metamodel git commit: METAMODEL-250: Added support for EBCDIC
files
Posted by ka...@apache.org.
METAMODEL-250: Added support for EBCDIC files
Closes #103
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/a1b9ff7f
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/a1b9ff7f
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/a1b9ff7f
Branch: refs/heads/5.x
Commit: a1b9ff7fbc22cbebd8abda60dc8954fbf58981ce
Parents: 2392557
Author: Kasper Sørensen <i....@gmail.com>
Authored: Mon Aug 1 21:19:22 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Aug 1 21:20:11 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
.../fixedwidth/EbcdicConfiguration.java | 60 ++++
.../metamodel/fixedwidth/EbcdicReader.java | 75 +++++
.../fixedwidth/FixedWidthColumnSpec.java | 2 +-
.../fixedwidth/FixedWidthConfiguration.java | 199 +++++++------
.../FixedWidthConfigurationReader.java | 18 +-
.../fixedwidth/FixedWidthDataContext.java | 25 +-
.../metamodel/fixedwidth/FixedWidthDataSet.java | 3 +-
.../metamodel/fixedwidth/FixedWidthReader.java | 281 +++++++++++++++----
.../apache/metamodel/fixedwidth/EBCDICTest.java | 77 +++++
.../fixedwidth/FixedWidthConfigurationTest.java | 11 +-
.../fixedwidth/FixedWidthDataContextTest.java | 3 -
.../fixedwidth/FixedWidthReaderTest.java | 27 +-
.../test/resources/fixed-width-2-7-10-10.ebc | 1 +
14 files changed, 572 insertions(+), 211 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index f0264c6..c0b90cc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
* [METAMODEL-1099] - Implemented DataContextFactory SPI for connectors: JDBC, CSV, ElasticSearch
+ * [METAMODEL-250] - Added support for EBCDIC files (part of 'fixedwidth' module).
* [METAMODEL-1103] - Fixed a bug pertaining to anchoring of wildcards in LIKE operands.
* [METAMODEL-1088] - Add support for aliases in MongoDB.
* [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.java
new file mode 100644
index 0000000..389a4f8
--- /dev/null
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicConfiguration.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.fixedwidth;
+
+/**
+ * Special fixed-width configuration for EBCDIC files.
+ */
+public final class EbcdicConfiguration extends FixedWidthConfiguration {
+
+ private final boolean _skipEbcdicHeader;
+ private final boolean _eolPresent;
+
+ public EbcdicConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
+ boolean failOnInconsistentLineWidth, boolean skipEbcdicHeader, boolean eolPresent) {
+ super(columnNameLineNumber, encoding, fixedValueWidth, failOnInconsistentLineWidth);
+ _skipEbcdicHeader = skipEbcdicHeader;
+ _eolPresent = eolPresent;
+ }
+
+ public EbcdicConfiguration(int columnNameLineNumber, String encoding, int[] valueWidths,
+ boolean failOnInconsistentLineWidth, boolean skipEbcdicHeader, boolean eolPresent) {
+ super(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
+ _skipEbcdicHeader = skipEbcdicHeader;
+ _eolPresent = eolPresent;
+ }
+
+ /**
+ * Determines if the input file contains a header that should be skipped before reading records data.
+ *
+ * @return a boolean indicating whether or not to skip EBCDIC header.
+ */
+ public boolean isSkipEbcdicHeader() {
+ return _skipEbcdicHeader;
+ }
+
+ /**
+ * Determines if the input file contains new line characters.
+ *
+ * @return a boolean indicating whether or not the input contains new line characters.
+ */
+ public boolean isEolPresent() {
+ return _eolPresent;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
new file mode 100644
index 0000000..a7639fc
--- /dev/null
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/EbcdicReader.java
@@ -0,0 +1,75 @@
+/**
+ * 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.BufferedInputStream;
+import java.io.IOException;
+
+/**
+ * Reader capable of separating values based on a fixed width setting.
+ */
+class EbcdicReader extends FixedWidthReader {
+
+ private final boolean _skipEbcdicHeader;
+ private final boolean _eolPresent;
+ private boolean _headerSkipped;
+
+ public EbcdicReader(BufferedInputStream stream, String charsetName, int[] valueWidths,
+ boolean failOnInconsistentLineWidth, boolean skipEbcdicHeader, boolean eolPresent) {
+ super(stream, charsetName, valueWidths, failOnInconsistentLineWidth);
+ _skipEbcdicHeader = skipEbcdicHeader;
+ _eolPresent = eolPresent;
+ }
+
+ @Override
+ protected void beforeReadLine() {
+ if (shouldSkipHeader()) {
+ try {
+ skipHeader();
+ } catch (IOException e) {
+ throw new IllegalStateException("A problem occurred while skipping the input stream. ", e);
+ }
+ }
+ }
+
+ private boolean shouldSkipHeader() {
+ return (_skipEbcdicHeader && !_headerSkipped);
+ }
+
+ private void skipHeader() throws IOException {
+ _headerSkipped = true;
+ _stream.skip(_expectedLineLength);
+ }
+
+ @Override
+ protected String readSingleRecordData() throws IOException {
+ if (_eolPresent) {
+ return super.readSingleRecordData();
+ } else {
+ byte[] buffer = new byte[_expectedLineLength];
+ int bytesRead = _stream.read(buffer, 0, _expectedLineLength);
+
+ if (bytesRead < 0) {
+ return null;
+ }
+
+ return new String(buffer, _charsetName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/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
index 65ec219..dedfbcd 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
@@ -24,7 +24,7 @@ import org.apache.metamodel.util.HasName;
* Represents the specification of a single column for a
* {@link FixedWidthDataContext}.
*/
-public final class FixedWidthColumnSpec implements HasName {
+final class FixedWidthColumnSpec implements HasName {
private final String name;
private final int width;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/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 2b2cae5..c53ff16 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -31,32 +31,29 @@ import org.apache.metamodel.util.FileHelper;
import org.apache.metamodel.util.HasNameMapper;
/**
- * Configuration of metadata about a fixed width values datacontext.
+ * Configuration of metadata about a fixed width values data context.
*/
-public final class FixedWidthConfiguration extends BaseObject implements
- Serializable {
+public class FixedWidthConfiguration extends BaseObject implements Serializable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public static final int NO_COLUMN_NAME_LINE = 0;
- public static final int DEFAULT_COLUMN_NAME_LINE = 1;
+ 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;
+ 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 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[] valueWidth) {
+ this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth, false);
+ }
public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
this(columnNameLineNumber, encoding, fixedValueWidth, false);
@@ -72,11 +69,11 @@ public final class FixedWidthConfiguration extends BaseObject implements
this.valueWidths = new int[0];
}
- public FixedWidthConfiguration(int columnNameLineNumber, String encoding,
- int[] valueWidths, boolean failOnInconsistentLineWidth) {
+ 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;
@@ -86,7 +83,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
this.columnNamingStrategy = columnNamingStrategy;
this.valueWidths = valueWidths;
}
-
+
public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
this(encoding, columnSpecs, false);
}
@@ -106,84 +103,84 @@ public final class FixedWidthConfiguration extends BaseObject implements
}
/**
- * 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();
- }
+ * 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 column naming strategy
+ */
+ 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];
- }
+ /**
+ * 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/a1b9ff7f/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
index 9154e5e..264287f 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
@@ -60,10 +60,9 @@ public class FixedWidthConfigurationReader {
* "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
+ * @param encoding the format file encoding
+ * @param resource the format file resource
+ * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
* @return a {@link FixedWidthConfiguration} object to use
*/
public FixedWidthConfiguration readFromSasFormatFile(String encoding, Resource resource,
@@ -88,13 +87,11 @@ public class FixedWidthConfigurationReader {
/**
* Reads a {@link FixedWidthConfiguration} based on a SAS INPUT declaration.
- * The reader method also optionally will look for a LABEL defintion for
- * column naming.
+ * The reader method also optionally will look for a LABEL definition for column naming.
*
- * @param encoding
- * @param resource
- * the format file resource
- * @param failOnInconsistentLineWidth
+ * @param encoding the format file encoding
+ * @param resource the format file resource
+ * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
* @return a {@link FixedWidthConfiguration} object to use
*/
public FixedWidthConfiguration readFromSasInputDefinition(String encoding, Resource resource,
@@ -176,5 +173,4 @@ public class FixedWidthConfigurationReader {
return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
}
-
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/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 d28a0b2..027cdab 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataContext.java
@@ -18,9 +18,9 @@
*/
package org.apache.metamodel.fixedwidth;
+import java.io.BufferedInputStream;
import java.io.File;
import java.io.InputStream;
-import java.io.Reader;
import org.apache.metamodel.MetaModelException;
import org.apache.metamodel.QueryPostprocessDataContext;
@@ -106,7 +106,7 @@ public class FixedWidthDataContext extends QueryPostprocessDataContext {
/**
* Gets the resource being read
*
- * @return
+ * @return a {@link Resource} object
*/
public Resource getResource() {
return _resource;
@@ -184,16 +184,23 @@ public class FixedWidthDataContext extends QueryPostprocessDataContext {
private FixedWidthReader createReader() {
final InputStream inputStream = _resource.read();
- final Reader fileReader = FileHelper.getReader(inputStream, _configuration.getEncoding());
final FixedWidthReader reader;
- if (_configuration.isConstantValueWidth()) {
- reader = new FixedWidthReader(fileReader, _configuration.getFixedValueWidth(), _configuration
- .isFailOnInconsistentLineWidth());
+
+ if (_configuration instanceof EbcdicConfiguration) {
+ reader = new EbcdicReader((BufferedInputStream) inputStream, _configuration.getEncoding(),
+ _configuration.getValueWidths(), _configuration.isFailOnInconsistentLineWidth(),
+ ((EbcdicConfiguration) _configuration).isSkipEbcdicHeader(),
+ ((EbcdicConfiguration) _configuration).isEolPresent());
} else {
- reader = new FixedWidthReader(fileReader, _configuration.getValueWidths(), _configuration
- .isFailOnInconsistentLineWidth());
+ if (_configuration.isConstantValueWidth()) {
+ reader = new FixedWidthReader(inputStream, _configuration.getEncoding(),
+ _configuration.getFixedValueWidth(), _configuration.isFailOnInconsistentLineWidth());
+ } else {
+ reader = new FixedWidthReader(inputStream, _configuration.getEncoding(),
+ _configuration.getValueWidths(), _configuration.isFailOnInconsistentLineWidth());
+ }
}
+
return reader;
}
-
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataSet.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataSet.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataSet.java
index 44ce808..4f78bab 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataSet.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthDataSet.java
@@ -98,8 +98,7 @@ class FixedWidthDataSet extends AbstractDataSet {
if (columnNumber < stringValues.length) {
rowValues[i] = stringValues[columnNumber];
} else {
- // Ticket #125: Missing values should be enterpreted as
- // null.
+ // Ticket #125: Missing values should be interpreted as null.
rowValues[i] = null;
}
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
index d7a18cf..da17ff1 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
@@ -18,78 +18,235 @@
*/
package org.apache.metamodel.fixedwidth;
-import java.io.BufferedReader;
+import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.IOException;
-import java.io.Reader;
+import java.io.InputStream;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
/**
* Reader capable of separating values based on a fixed width setting.
*/
-final public class FixedWidthReader implements Closeable {
-
- private final BufferedReader _reader;
- private final FixedWidthLineParser _parser;
-
- public FixedWidthReader(Reader reader, int fixedValueWidth,
- boolean failOnInconsistentLineWidth) {
- this(new BufferedReader(reader), fixedValueWidth,
- failOnInconsistentLineWidth);
- }
-
- public FixedWidthReader(BufferedReader reader, int fixedValueWidth,
- boolean failOnInconsistentLineWidth) {
- _reader = reader;
- final FixedWidthConfiguration fixedWidthConfiguration = new FixedWidthConfiguration(
- FixedWidthConfiguration.NO_COLUMN_NAME_LINE, null, fixedValueWidth, failOnInconsistentLineWidth);
- _parser = new FixedWidthLineParser(fixedWidthConfiguration, -1, 0);
- }
-
- public FixedWidthReader(Reader reader, int[] valueWidths,
- boolean failOnInconsistentLineWidth) {
- this(new BufferedReader(reader), valueWidths,
- failOnInconsistentLineWidth);
- }
-
- public FixedWidthReader(BufferedReader reader, int[] valueWidths,
- boolean failOnInconsistentLineWidth) {
- _reader = reader;
- int fixedValueWidth = -1;
- int expectedLineLength = 0;
- if (fixedValueWidth == -1) {
- for (int i = 0; i < valueWidths.length; i++) {
- expectedLineLength += valueWidths[i];
- }
- }
- final FixedWidthConfiguration fixedWidthConfiguration = new FixedWidthConfiguration(
- FixedWidthConfiguration.NO_COLUMN_NAME_LINE, null, valueWidths, failOnInconsistentLineWidth);
- _parser = new FixedWidthLineParser(fixedWidthConfiguration, expectedLineLength, 0);
- }
-
-
- /***
- * Reads the next line in the file.
- *
- * @return an array of values in the next line, or null if the end of the
- * file has been reached.
- *
- * @throws IllegalStateException
- * if an exception occurs while reading the file.
- */
- public String[] readLine() throws IllegalStateException {
- String line;
+class FixedWidthReader implements Closeable {
+ private static final int END_OF_STREAM = -1;
+ private static final int LINE_FEED = '\n';
+ private static final int CARRIAGE_RETURN = '\r';
+
+ protected final String _charsetName;
+ private final int _fixedValueWidth;
+ private final int[] _valueWidths;
+ private int _valueIndex = 0;
+ private final boolean _failOnInconsistentLineWidth;
+ private final boolean _constantWidth;
+ private volatile int _rowNumber;
+ protected final BufferedInputStream _stream;
+ protected final int _expectedLineLength;
+
+ public FixedWidthReader(InputStream stream, String charsetName, int fixedValueWidth,
+ boolean failOnInconsistentLineWidth) {
+ this(new BufferedInputStream(stream), charsetName, fixedValueWidth, failOnInconsistentLineWidth);
+ }
+
+ private FixedWidthReader(BufferedInputStream stream, String charsetName, int fixedValueWidth,
+ boolean failOnInconsistentLineWidth) {
+ _stream = stream;
+ _charsetName = charsetName;
+ _fixedValueWidth = fixedValueWidth;
+ _failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+ _rowNumber = 0;
+ _valueWidths = null;
+ _constantWidth = true;
+ _expectedLineLength = -1;
+ }
+
+ public FixedWidthReader(InputStream stream, String charsetName, int[] valueWidths,
+ boolean failOnInconsistentLineWidth) {
+ this(new BufferedInputStream(stream), charsetName, valueWidths, failOnInconsistentLineWidth);
+ }
+
+ FixedWidthReader(BufferedInputStream stream, String charsetName, int[] valueWidths,
+ boolean failOnInconsistentLineWidth) {
+ _stream = stream;
+ _charsetName = charsetName;
+ _fixedValueWidth = -1;
+ _valueWidths = valueWidths;
+ _failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+ _rowNumber = 0;
+ _constantWidth = false;
+ int expectedLineLength = 0;
+
+ for (final int _valueWidth : _valueWidths) {
+ expectedLineLength += _valueWidth;
+ }
+
+ _expectedLineLength = expectedLineLength;
+ }
+
+ /**
+ * This reads and returns the next record from the file. Usually, it is a line but in case the new line characters
+ * are not present, the length of the content depends on the column-widths setting.
+ *
+ * @return an array of values in the next line, or null if the end of the file has been reached.
+ * @throws IllegalStateException if an exception occurs while reading the file.
+ */
+ public String[] readLine() throws IllegalStateException {
try {
- line = _reader.readLine();
- return _parser.parseLine(line);
+ beforeReadLine();
+ _rowNumber++;
+ return getValues();
} catch (IOException e) {
throw new IllegalStateException(e);
}
- }
-
+ }
+
+ /**
+ * Empty hook that enables special behavior in sub-classed readers (by overriding this method).
+ */
+ protected void beforeReadLine() {
+ return;
+ }
+
+ private String[] getValues() throws IOException {
+ final List<String> values = new ArrayList<>();
+ final String singleRecordData = readSingleRecordData();
+
+ if (singleRecordData == null) {
+ return null;
+ }
+
+ processSingleRecordData(singleRecordData, values);
+ String[] result = values.toArray(new String[values.size()]);
+
+ if (!_failOnInconsistentLineWidth && !_constantWidth) {
+ result = correctResult(result);
+ }
+
+ validateConsistentValue(singleRecordData, result, values.size());
+
+ return result;
+ }
+
+ private void validateConsistentValue(String recordData, String[] result, int valuesSize) {
+ if (!_failOnInconsistentLineWidth) {
+ return;
+ }
+
+ InconsistentValueWidthException inconsistentValueException = null;
+
+ if (_constantWidth) {
+ if (recordData.length() % _fixedValueWidth != 0) {
+ inconsistentValueException = new InconsistentValueWidthException(result, recordData, _rowNumber);
+ }
+ } else if (result.length != valuesSize || recordData.length() != _expectedLineLength) {
+ inconsistentValueException = new InconsistentValueWidthException(result, recordData, _rowNumber);
+ }
+
+ if (inconsistentValueException != null) {
+ throw inconsistentValueException;
+ }
+ }
+
+ private void processSingleRecordData(final String singleRecordData, final List<String> values) {
+ StringBuilder nextValue = new StringBuilder();
+ final CharacterIterator it = new StringCharacterIterator(singleRecordData);
+ _valueIndex = 0;
+
+ for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
+ processCharacter(c, nextValue, values, singleRecordData);
+ }
+
+ if (nextValue.length() > 0) {
+ addNewValueIfAppropriate(values, nextValue);
+ }
+ }
+
+ String readSingleRecordData() throws IOException {
+ StringBuilder line = new StringBuilder();
+ int ch;
+
+ for (ch = _stream.read(); !isEndingCharacter(ch); ch = _stream.read()) {
+ line.append((char) ch);
+ }
+
+ if (ch == CARRIAGE_RETURN) {
+ readLineFeedIfFollows();
+ }
+
+ return (line.length()) > 0 ? line.toString() : null;
+ }
+
+ private void readLineFeedIfFollows() throws IOException {
+ _stream.mark(1);
+
+ if (_stream.read() != LINE_FEED) {
+ _stream.reset();
+ }
+ }
+
+ private boolean isEndingCharacter(int ch) {
+ return (ch == CARRIAGE_RETURN || ch == LINE_FEED || ch == END_OF_STREAM);
+ }
+
+ private void processCharacter(char c, StringBuilder nextValue, List<String> values, String recordData) {
+ nextValue.append(c);
+ final int valueWidth = getValueWidth(values, recordData);
+
+ if (nextValue.length() == valueWidth) {
+ addNewValueIfAppropriate(values, nextValue);
+ nextValue.setLength(0); // clear the buffer
+
+ if (_valueWidths != null) {
+ _valueIndex = (_valueIndex + 1) % _valueWidths.length;
+ }
+ }
+ }
+
+ private int getValueWidth(List<String> values, String recordData) {
+ if (_constantWidth) {
+ return _fixedValueWidth;
+ } else {
+ if (_valueIndex >= _valueWidths.length) {
+ if (_failOnInconsistentLineWidth) {
+ String[] result = values.toArray(new String[values.size()]);
+ throw new InconsistentValueWidthException(result, recordData, _rowNumber + 1);
+ } else {
+ return -1; // silently ignore the inconsistency
+ }
+ }
+
+ return _valueWidths[_valueIndex];
+ }
+ }
+
+ private void addNewValueIfAppropriate(List<String> values, StringBuilder nextValue) {
+ if (_valueWidths != null) {
+ if (values.size() < _valueWidths.length) {
+ values.add(nextValue.toString().trim());
+ }
+ } else {
+ values.add(nextValue.toString().trim());
+ }
+ }
+
+ private String[] correctResult(String[] result) {
+ if (result.length != _valueWidths.length) {
+ String[] correctedResult = new String[_valueWidths.length];
+
+ for (int i = 0; i < result.length && i < _valueWidths.length; i++) {
+ correctedResult[i] = result[i];
+ }
+
+ result = correctedResult;
+ }
- @Override
- public void close() throws IOException {
- _reader.close();
- }
+ return result;
+ }
+ @Override
+ public void close() throws IOException {
+ _stream.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
new file mode 100644
index 0000000..ea19960
--- /dev/null
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/EBCDICTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.File;
+
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class EBCDICTest {
+ private static final int[] COLUMN_WIDTHS = new int[] { 2, 7, 10, 10 };
+ private static final long EXPECTED_ROWS_COUNT = 49; // 50 lines, 1. is a header
+ private static final String ENCODING = "IBM500";
+ private static final String[] EXPECTED_ROWS = new String[] {
+ "Row[values=[01, name-01, surname-01, address-01]]",
+ "Row[values=[02, name-02, surname-02, address-02]]",
+ "Row[values=[03, name-03, surname-03, address-03]]",
+ };
+ private final FixedWidthDataContext _context;
+ private final Table _table;
+
+ public EBCDICTest() {
+ String fileName = "fixed-width-2-7-10-10.ebc";
+ FixedWidthConfiguration configuration = new EbcdicConfiguration(FixedWidthConfiguration.NO_COLUMN_NAME_LINE,
+ ENCODING, COLUMN_WIDTHS, false, true, false);
+ _context = new FixedWidthDataContext(new File("src/test/resources/" + fileName), configuration);
+ Schema schema = _context.getDefaultSchema();
+ _table = schema.getTableByName(fileName);
+ }
+
+ @Test
+ public void testRowsCount() throws Exception {
+ long rows = 0;
+
+ try (final DataSet dataSet = _context.query().from(_table).selectCount().execute()) {
+ if (dataSet.next()) {
+ Object[] values = dataSet.getRow().getValues();
+ rows = (long) values[0];
+ }
+ }
+
+ assertEquals(EXPECTED_ROWS_COUNT, rows);
+ }
+
+ @Test
+ public void testFirstRows() throws Exception {
+ int limit = EXPECTED_ROWS.length;
+ int i = 0;
+
+ try (final DataSet dataSet = _context.query().from(_table).selectAll().limit(limit).execute()) {
+ while (dataSet.next()) {
+ assertEquals(EXPECTED_ROWS[i], dataSet.getRow().toString());
+ i++;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationTest.java
index 8225be0..f03d633 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.metamodel.fixedwidth;
-import org.apache.metamodel.fixedwidth.FixedWidthConfiguration;
-
import junit.framework.TestCase;
public class FixedWidthConfigurationTest extends TestCase {
@@ -31,14 +29,11 @@ public class FixedWidthConfigurationTest extends TestCase {
}
public void testEquals() throws Exception {
- FixedWidthConfiguration conf1 = new FixedWidthConfiguration(1, "UTF8",
- 10, true);
- FixedWidthConfiguration conf2 = new FixedWidthConfiguration(1, "UTF8",
- 10, true);
+ FixedWidthConfiguration conf1 = new FixedWidthConfiguration(1, "UTF8", 10, true);
+ FixedWidthConfiguration conf2 = new FixedWidthConfiguration(1, "UTF8", 10, true);
assertEquals(conf1, conf2);
- FixedWidthConfiguration conf3 = new FixedWidthConfiguration(1, "UTF8",
- 10, false);
+ FixedWidthConfiguration conf3 = new FixedWidthConfiguration(1, "UTF8", 10, false);
assertFalse(conf1.equals(conf3));
}
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
index 2ac3680..7962cf6 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthDataContextTest.java
@@ -25,9 +25,6 @@ import junit.framework.TestCase;
import org.apache.metamodel.DataContext;
import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.fixedwidth.FixedWidthConfiguration;
-import org.apache.metamodel.fixedwidth.FixedWidthDataContext;
-import org.apache.metamodel.fixedwidth.InconsistentValueWidthException;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
index 4d11f0e..8f40c1d 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
@@ -18,11 +18,9 @@
*/
package org.apache.metamodel.fixedwidth;
-import static org.junit.Assert.assertEquals;
-
-import java.io.BufferedReader;
+import java.io.BufferedInputStream;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
@@ -30,7 +28,10 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import static org.junit.Assert.assertEquals;
+
public class FixedWidthReaderTest {
+ private static final String CHARSET = "UTF-8";
@Rule
public final ExpectedException exception = ExpectedException.none();
@@ -38,9 +39,9 @@ public class FixedWidthReaderTest {
@Test
public void testBufferedReader1() throws IOException {
final File file = new File("src/test/resources/example_simple1.txt");
- final BufferedReader reader = new BufferedReader(new FileReader(file));
+ final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
int[] widths = new int[] { 8, 9 };
- try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, widths, false)) {
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(stream, CHARSET, widths, false)) {
final String[] line1 = fixedWidthReader.readLine();
assertEquals("[greeting, greeter]", Arrays.asList(line1).toString());
final String[] line2 = fixedWidthReader.readLine();
@@ -53,9 +54,9 @@ public class FixedWidthReaderTest {
@Test
public void testBufferedReader2() throws IOException {
final File file = new File("src/test/resources/example_simple2.txt");
- final BufferedReader reader = new BufferedReader(new FileReader(file));
+ final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
int[] widths = new int[] {1, 8, 9 };
- try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, widths, false)) {
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(stream, CHARSET, widths, false)) {
final String[] line1 = fixedWidthReader.readLine();
assertEquals("[i, greeting, greeter]", Arrays.asList(line1).toString());
final String[] line2 = fixedWidthReader.readLine();
@@ -68,8 +69,8 @@ public class FixedWidthReaderTest {
@Test
public void testBufferedReader3() throws IOException {
final File file = new File("src/test/resources/example_simple3.txt");
- final BufferedReader reader = new BufferedReader(new FileReader(file));
- try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, 5, false)) {
+ final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(stream, CHARSET, 5, false)) {
final String[] line1 = fixedWidthReader.readLine();
assertEquals("[hello]", Arrays.asList(line1).toString());
final String[] line2 = fixedWidthReader.readLine();
@@ -84,8 +85,8 @@ public class FixedWidthReaderTest {
@Test
public void testBufferedReaderFailOnInconsistentRows() throws IOException {
final File file = new File("src/test/resources/example_simple3.txt");
- final BufferedReader reader = new BufferedReader(new FileReader(file));
- try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, 5, true)) {
+ final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
+ try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(stream, CHARSET, 5, true)) {
final String[] line1 = fixedWidthReader.readLine();
assertEquals("[hello]", Arrays.asList(line1).toString());
final String[] line2 = fixedWidthReader.readLine();
@@ -98,6 +99,4 @@ public class FixedWidthReaderTest {
final String[] line4 = fixedWidthReader.readLine();
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/a1b9ff7f/fixedwidth/src/test/resources/fixed-width-2-7-10-10.ebc
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/resources/fixed-width-2-7-10-10.ebc b/fixedwidth/src/test/resources/fixed-width-2-7-10-10.ebc
new file mode 100644
index 0000000..09fcc70
--- /dev/null
+++ b/fixedwidth/src/test/resources/fixed-width-2-7-10-10.ebc
@@ -0,0 +1 @@
+������`���������`���������`����`�����`�����`����`�����`�����`����`�����`�����`������`�������`�����`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`����`�𢤙����`�������`����`�����`�����`����`�����`�����`����`�����`�����`������`�������`����
���`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`����`�𢤙����`�������`����`�����`�����`����`�����`�����`����`�����`�����`������`�������`�����`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������
`���������`��������`���������`���������`����`�𢤙����`�������`����`�����`�����`����`�����`�����`����`�����`�����`������`�������`�����`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`����`�𢤙����`�������`����`�����`�����`����`�����`�����`����`�
������`�����`������`�������`�����`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`��������`���������`���������`��
\ No newline at end of file
[14/43] metamodel git commit: Merge remote-tracking branch
'origin/master'
Posted by ka...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/64c0e77c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/64c0e77c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/64c0e77c
Branch: refs/heads/5.x
Commit: 64c0e77c4ef634287f73f119047fada4bb7c339c
Parents: 7e29fb8 d2eee32
Author: Kasper Sørensen <i....@gmail.com>
Authored: Wed Aug 10 20:41:47 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Wed Aug 10 20:41:47 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 4 ++
.../jdbc/dialects/OracleQueryRewriter.java | 11 ++++++
.../jdbc/dialects/OracleQueryRewriterTest.java | 41 ++++++++++++++++++++
3 files changed, 56 insertions(+)
----------------------------------------------------------------------
[04/43] metamodel git commit: METAMODEL-1104: Fixed broken unittest
Posted by ka...@apache.org.
METAMODEL-1104: Fixed broken unittest
Closes #116
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/ae5ec80e
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/ae5ec80e
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/ae5ec80e
Branch: refs/heads/5.x
Commit: ae5ec80e146ace4d1e3b66b2e8181e2e255b1e20
Parents: a5235c1
Author: kaspersorensen <i....@gmail.com>
Authored: Thu Jul 28 08:12:36 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Thu Jul 28 08:12:36 2016 -0700
----------------------------------------------------------------------
.../apache/metamodel/factory/ResourceFactoryRegistryImplTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/ae5ec80e/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java b/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
index 0122253..816fc32 100644
--- a/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
+++ b/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
@@ -36,7 +36,8 @@ public class ResourceFactoryRegistryImplTest {
@Test
public void testGetQualifiedFileResource() throws Exception {
final File file = new File("src/test/resources/unicode-text-utf8.txt");
- final Resource res = registry.createResource(new SimpleResourceProperties("file:///" + file.getAbsolutePath()));
+ final Resource res = registry.createResource(new SimpleResourceProperties("file:///" + file.getAbsolutePath()
+ .replace('\\', '/')));
assertTrue(res.isExists());
assertEquals("unicode-text-utf8.txt", res.getName());
}
[08/43] metamodel git commit: Preparing CHANGES.md prior to release
Posted by ka...@apache.org.
Preparing CHANGES.md prior to release
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/6a7a1513
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/6a7a1513
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/6a7a1513
Branch: refs/heads/5.x
Commit: 6a7a15138f374c97eb7a8e1171b699eb424a4d3b
Parents: a1b9ff7
Author: Kasper Sørensen <i....@gmail.com>
Authored: Mon Aug 1 21:21:31 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Mon Aug 1 21:21:31 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/6a7a1513/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index c0b90cc..d3d7506 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-### Apache MetaModel 4.5.4 (work in progress)
+### Apache MetaModel 4.5.4
* [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
* [METAMODEL-1099] - Implemented DataContextFactory SPI for connectors: JDBC, CSV, ElasticSearch
[40/43] metamodel git commit: Using version 4.6.0 since new features
(DynamoDB) was added.
Posted by ka...@apache.org.
Using version 4.6.0 since new features (DynamoDB) was added.
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/32e0f970
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/32e0f970
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/32e0f970
Branch: refs/heads/5.x
Commit: 32e0f970c99f6eee3ad790f90b9554286d80b1e2
Parents: 9dc6700
Author: Kasper Sørensen <i....@gmail.com>
Authored: Tue Jan 31 13:02:42 2017 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Tue Jan 31 13:02:42 2017 -0800
----------------------------------------------------------------------
CHANGES.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/32e0f970/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index c70ac22..ebc7e66 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-### Apache MetaModel 4.5.6
+### Apache MetaModel 4.6.0
* [METAMODEL-1136] - New connector for Amazon DynamoDB.
* [METAMODEL-1134] - Added NOT IN and NOT LIKE operators to WHERE filters.
[15/43] 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/73b70b93
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/73b70b93
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/73b70b93
Branch: refs/heads/5.x
Commit: 73b70b937f1935111a684126089e5b74e361e56b
Parents: 64c0e77
Author: Kasper Sørensen <i....@gmail.com>
Authored: Wed Aug 10 20:42:40 2016 -0700
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Wed Aug 10 20:42:40 2016 -0700
----------------------------------------------------------------------
CHANGES.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/73b70b93/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index a27fa50..d7cd4d3 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,7 @@
### Apache MetaModel 4.5.5
* [METAMODEL-1111] - Added WHERE rewrite for Oracle when empty strings are considered as NULL.
+ * [METAMODEL-1109] - Fixed diacritics/encoding issue with Fixed Width reader.
### Apache MetaModel 4.5.4