Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Adding the sql-stored-connector #58

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ target
.project
.settings
.classpath
.factorypath

# Mobile Tools for Java (J2ME)
.mtj.tmp/
Expand Down
1 change: 1 addition & 0 deletions connectors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<module>twitter-mention-connector</module>
<module>twitter-search-connector</module>
<module>salesforce-upsert-contact-connector</module>
<module>sql-stored-connector</module>
<module>day-trade-get-connector</module>
<module>day-trade-place-connector</module>
<module>trade-insight-buy-connector</module>
Expand Down
1 change: 1 addition & 0 deletions connectors/sql-stored-connector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
derby.log
221 changes: 221 additions & 0 deletions connectors/sql-stored-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.syndesis</groupId>
<artifactId>connectors</artifactId>
<version>0.4-SNAPSHOT</version>
</parent>

<artifactId>sql-stored-connector</artifactId>
<packaging>jar</packaging>
<name>Syndesis Connectors :: Sql Stored Connector</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<camel.version>2.20.0.fuse-000091</camel.version>
</properties>

<dependencyManagement>
<dependencies>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-parent</artifactId>
<version>${camel.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<!-- base component to use for this connector -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql-starter</artifactId>
</dependency>

<!-- camel-connector -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-connector</artifactId>
</dependency>

<!-- camel and spring boot compiler plugins -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>apt</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want apt to be in compile scope (perhaps provided or optional) or have them explicitly configured in the maven-compiler-plugin configuration see https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessorPaths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zregvart We seem to be doing this on all connectors, so we should probably address that across all connectors. Shall I open a Jira just for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it would benefit to have this in the parent POM also

</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same about annotation processing as above

<version>${spring-boot.version}</version>
</dependency>

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>

<!-- supported drivers -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- The Oracle Driver needs to be added manually by user, for licensing compliance
it can not be shipped. We need to provide some mechnism so the integrator can upload
this jar. (http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html)
<dependency>
<groupId>oracle</groupId>
<artifactId>jdbc</artifactId>
<version>12.0</version>
<scope>system</scope>
<systemPath>ojdbc8.jar</systemPath>
</dependency>
-->

<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>

<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jsonSchema</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>install</defaultGoal>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<encoding>UTF-8</encoding>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should also use https://github.com/basepom/basepom for connectors, or perhaps have a connectors-parent POM (no need to change in this PR), so some of these encodings (and others that we forget) are set beforehand

</configuration>
</plugin>

<!-- generate components meta-data and validate component includes documentation etc
Disabled until the plugin supports adding parameters at the connector level. At the moment
they are added manually.
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-package-maven-plugin</artifactId>
<version>${camel.version}</version>
<executions>
<execution>
<id>prepare</id>
<goals>
<goal>prepare-components</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution>
<id>validate</id>
<goals>
<goal>validate-components</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>
-->

<!-- generate connector
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-connector-maven-plugin</artifactId>
<version>${camel.version}</version>
<executions>
<execution>
<id>boot</id>
<goals>
<goal>prepare-spring-boot-auto-configuration</goal>
</goals>
<configuration>

<includeLicenseHeader>false</includeLicenseHeader>

<configurationPrefix>false</configurationPrefix>
</configuration>
</execution>
<execution>
<id>connector</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
-->

</plugins>
</build>

<repositories>
<repository>
<id>jboss-ea</id>
<name>JBoss Early-access repository</name>
<url>https://repository.jboss.org/nexus/content/groups/ea/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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 io.syndesis.connector;

/**
* Complete Enumeration of Column modes in use by
* Stored Procedures.
*
* @since 09/11/17
* @author kstam
*
*/
public enum ColumnMode {
UNKNOWN, IN, INOUT, RESULT, OUT, RETURN;

public static ColumnMode valueOf(int columnType) {
return ColumnMode.values()[columnType];
}
}
Original file line number Diff line number Diff line change
@@ -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 io.syndesis.connector;

/**
* Enumeration of Database products we have tested, and
* for which we ship drivers for. One caviat is the
* Oracle Driver which cannot be shipped due to
* restrictions on its license.
*
* @since 09/11/17
* @author kstam
*
*/
public enum DatabaseProduct {
APACHE_DERBY, ORACLE, POSTGRESQL;

/**
* Can be used to convert '_' to ' ' in the enum
* name.
*
* @return name of the enum.
*/
public String nameWithSpaces() {
return name().replaceAll("_", " ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* 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 io.syndesis.connector;

import java.util.ArrayList;
import java.util.List;

/**
* JSON Schema builder for the simple schema's the SQL Stored Connector uses.
*
* The schema is created so it can be passed on to the dataMapper. An example
* schema looks like
*
* <pre>
* {@code
* "$schema": "http://json-schema.org/schema#",
* "type" : "object",
* "properties" : {
* "a" : {"type" : "integer"},
* "b" : {"type" : "integer"}
* }
* }
* </pre>
*
* @author kstam
* @since 09/11/2017
*
*/
public class JSONBeanSchemaBuilder {

final static String SCHEMA = "{\n" +
" \"$schema\": \"http://json-schema.org/schema#\",\n" +
" \"type\" : \"object\",\n" +
" \"properties\" : {\n%s\n } \n}";
List<String> fields = new ArrayList<String>();

public JSONBeanSchemaBuilder addField(String name, String type) {
fields.add(String.format(" \"%s\" : {\"type\" : \"%s\"}", name, type));
return this;
}

public String build() {
String fieldString = "";
int count = 0;
for (String field : fields) {
fieldString += field;
if ( fields.size()!=++count ) fieldString += ",\n";
}
return String.format(SCHEMA, fieldString);
}
}
Loading