Skip to content

Commit

Permalink
Merge pull request #37 from rareddy/TEIID-1757
Browse files Browse the repository at this point in the history
Teiid 1757 - Initial checkin for odata translator
  • Loading branch information
rareddy committed Jan 22, 2013
2 parents 7cee2f7 + 2f03982 commit 4db0334
Show file tree
Hide file tree
Showing 31 changed files with 3,612 additions and 12 deletions.
26 changes: 23 additions & 3 deletions api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java
Expand Up @@ -39,20 +39,28 @@
*/
public class CollectorVisitor<T> extends HierarchyVisitor {

private Class<T> type;
private Collection<T> objects = new ArrayList<T>();
protected Class<T> type;
protected Collection<T> objects = new ArrayList<T>();
private boolean shallow = false;

public CollectorVisitor(Class<T> type) {
this.type = type;
}

public CollectorVisitor(Class<T> type, boolean shallow) {
this.type = type;
this.shallow = shallow;
}

@SuppressWarnings("unchecked")
@Override
public void visitNode(LanguageObject obj) {
if(type.isInstance(obj)) {
this.objects.add((T)obj);
}
super.visitNode(obj);
if (this.shallow) {
super.visitNode(obj);
}
}

public Collection<T> getCollectedObjects() {
Expand All @@ -73,6 +81,18 @@ public static <T> Collection<T> collectObjects(Class<T> type, LanguageObject obj
return visitor.getCollectedObjects();
}

/**
* Similar to collectObjects but this method does deep walk language objects that have already collected
* @param type
* @param object
* @return
*/
public static <T> Collection<T> shallowCollectObjects(Class<T> type, LanguageObject object) {
CollectorVisitor<T> visitor = new CollectorVisitor<T>(type);
visitor.visitNode(object);
return visitor.getCollectedObjects();
}

/**
* This is a utility method for a common use of this visitor, which is to collect
* all elements in an object tree.
Expand Down
24 changes: 23 additions & 1 deletion build/assembly/jboss-as7/dist.xml
Expand Up @@ -499,7 +499,29 @@
<outputDirectory>modules/org/jboss/teiid/translator/object/main</outputDirectory>
<fileMode>0644</fileMode>
</binaries>
</moduleSet>
</moduleSet>

<moduleSet>
<includeSubModules>true</includeSubModules>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>org.jboss.teiid.connectors:translator-odata</include>
</includes>
<binaries>
<includeDependencies>true</includeDependencies>
<unpack>false</unpack>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<unpack>false</unpack>
<useTransitiveDependencies>false</useTransitiveDependencies>
<useDefaultExcludes>true</useDefaultExcludes>
</dependencySet>
</dependencySets>
<outputDirectory>modules/org/jboss/teiid/translator/odata/main</outputDirectory>
<fileMode>0644</fileMode>
</binaries>
</moduleSet>
<!-- Include the JOPR plugin
<moduleSet>
<includeSubModules>true</includeSubModules>
Expand Down
Expand Up @@ -65,6 +65,7 @@ connect
/profile=ha/subsystem=teiid/translator=infinispan-cache:add(module=org.jboss.teiid.translator.object)
/profile=ha/subsystem=teiid/translator=map-cache:add(module=org.jboss.teiid.translator.object)
/profile=ha/subsystem=teiid/translator=google-spreadsheet:add(module=org.jboss.teiid.translator.google)
/profile=ha/subsystem=teiid/translator=odata:add(module=org.jboss.teiid.translator.odata)


/profile=ha/subsystem=datasources/jdbc-driver=teiid:add(driver-name=teiid, driver-module-name=org.jboss.teiid.client, driver-class-name=org.teiid.jdbc.TeiidDriver, driver-xa-datasource-class-name=org.teiid.jdbc.TeiidDataSource)
Expand Down
Expand Up @@ -62,6 +62,7 @@ connect
/subsystem=teiid/translator=infinispan-cache:add(module=org.jboss.teiid.translator.object)
/subsystem=teiid/translator=map-cache:add(module=org.jboss.teiid.translator.object)
/subsystem=teiid/translator=google-spreadsheet:add(module=org.jboss.teiid.translator.google)
/subsystem=teiid/translator=odata:add(module=org.jboss.teiid.translator.odata)


/subsystem=datasources/jdbc-driver=teiid:add(driver-name=teiid, driver-module-name=org.jboss.teiid.client, driver-class-name=org.teiid.jdbc.TeiidDriver, driver-xa-datasource-class-name=org.teiid.jdbc.TeiidDataSource)
Expand Down
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.jboss.teiid.translator.odata">
<resources>
<resource-root path="translator-odata-${project.version}.jar" />
<!-- Insert resources here -->
</resources>

<dependencies>
<module name="org.odata4j.core"/>
<module name="org.jboss.resteasy.resteasy-jaxrs"/>
<module name="javax.xml.ws.api"/>
<module name="javax.api"/>
<module name="javax.ws.rs.api"/>
<module name="javax.resource.api"/>
<module name="org.jboss.teiid.common-core" />
<module name="org.jboss.teiid.api" />
<module name="org.jboss.teiid.translator.ws"/>
<module name="org.jboss.teiid.translator.jdbc"/>
<module name="javax.wsdl4j.api"/>
<module name="org.springframework.spring" optional="true"/>
<module name="org.joda.time" />
</dependencies>
</module>
Expand Up @@ -321,6 +321,7 @@
<translator name="jpa2" module="org.jboss.teiid.translator.jpa"/>
<translator name="infinispan-cache" module="org.jboss.teiid.translator.object"/>
<translator name="map-cache" module="org.jboss.teiid.translator.object"/>
<translator name="odata" module="org.jboss.teiid.translator.odata"/>


</subsystem>
Expand Down
Expand Up @@ -105,6 +105,7 @@ public String getContentType() {
private static final class BinaryDispatch implements Dispatch<DataSource> {

HashMap<String, Object> requestContext = new HashMap<String, Object>();
HashMap<String, Object> responseContext = new HashMap<String, Object>();

private String endpoint;

Expand Down Expand Up @@ -136,7 +137,7 @@ public DataSource invoke(DataSource msg) {
InputStream is = msg.getInputStream();
ObjectConverterUtil.write(os, is, -1);
}

readResponseHeaders(httpConn);
return new HttpDataSource(url, httpConn);
} catch (IOException e) {
throw new WebServiceException(e);
Expand Down Expand Up @@ -181,7 +182,20 @@ public Map<String, Object> getRequestContext() {

@Override
public Map<String, Object> getResponseContext() {
throw new UnsupportedOperationException();
return responseContext;
}

private void readResponseHeaders(HttpURLConnection httpConn) {
for (int i = 0;; i++) {
String headerName = httpConn.getHeaderFieldKey(i);
String headerValue = httpConn.getHeaderField(i);

if (headerName == null && headerValue == null) {
break;
}

this.responseContext.put(headerName, headerValue);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions connectors/pom.xml
Expand Up @@ -111,5 +111,6 @@
<module>translator-jpa</module>
<module>translator-object</module>
<module>connector-infinispan</module>
<module>translator-odata</module>
</modules>
</project>
81 changes: 81 additions & 0 deletions connectors/translator-odata/pom.xml
@@ -0,0 +1,81 @@
<?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">
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
<version>8.3.0.Alpha3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-odata</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
<name>Odata Translator</name>
<description>This translator provides access to Odata based data sources</description>
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid.connectors</groupId>
<artifactId>translator-ws</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid.connectors</groupId>
<artifactId>translator-jdbc</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.odata4j</groupId>
<artifactId>odata4j-core</artifactId>
<classifier>redhat</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>core4j</artifactId>
<groupId>org.core4j</groupId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<outputDirectory>target/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
</build>

</project>
@@ -0,0 +1,70 @@
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
package org.teiid.translator.odata;

import java.util.List;

import org.teiid.language.Argument;
import org.teiid.language.Command;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.*;

public class ODataDirectQueryExecution implements ProcedureExecution {

public ODataDirectQueryExecution(List<Argument> arguments, Command command,
ExecutionContext executionContext, RuntimeMetadata metadata,
WSConnection connection, String nativeQuery) {

// rameshTODO Auto-generated constructor stub
}

@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
// rameshTODO Auto-generated method stub
return null;
}

@Override
public void close() {
// rameshTODO Auto-generated method stub

}

@Override
public void cancel() throws TranslatorException {
// rameshTODO Auto-generated method stub

}

@Override
public void execute() throws TranslatorException {
// rameshTODO Auto-generated method stub

}

@Override
public List<?> getOutputParameterValues() throws TranslatorException {
// rameshTODO Auto-generated method stub
return null;
}

}

0 comments on commit 4db0334

Please sign in to comment.