Skip to content

Commit d930903

Browse files
committed
TEIID-2334, TEIID-1854
1 parent f7f0ff2 commit d930903

File tree

36 files changed

+767
-352
lines changed

36 files changed

+767
-352
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ target
55
bin
66
build.xml
77
.DS_Store
8+
m2e-wtp

api/src/main/java/org/teiid/logging/LogConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public interface LogConstants {
3737
public static final String CTX_ADMIN_API = "org.teiid.ADMIN_API"; //$NON-NLS-1$
3838
public static final String CTX_RUNTIME = "org.teiid.RUNTIME"; //$NON-NLS-1$
3939
public static final String CTX_ODBC = "org.teiid.ODBC"; //$NON-NLS-1$
40+
public static final String CTX_ODATA = "org.teiid.ODATA"; //$NON-NLS-1$
4041

4142
// Query contexts
4243
public static final String CTX_FUNCTION_TREE = CTX_QUERY_PLANNER + ".FUNCTION_TREE"; //$NON-NLS-1$

api/src/main/java/org/teiid/translator/SourceSystemFunctions.java

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class SourceSystemFunctions {
6363
public static final String SUBSTRING = "substring"; //$NON-NLS-1$
6464
public static final String TO_BYTES = "to_bytes"; //$NON-NLS-1$
6565
public static final String TO_CHARS = "to_chars"; //$NON-NLS-1$
66+
public static final String ENDSWITH = "endswith"; //$NON-NLS-1$
6667
/**
6768
* The trim function is only used for a non-space trim character
6869
*/

build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml

-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@
312312
<translator name="intersystems-cache" module="org.jboss.teiid.translator.jdbc"/>
313313
<translator name="netezza" module="org.jboss.teiid.translator.jdbc"/>
314314
<translator name="file" module="org.jboss.teiid.translator.file"/>
315-
<translator name="google-spreadsheet" module="org.jboss.teiid.translator.google"/>
316315
<translator name="ldap" module="org.jboss.teiid.translator.ldap"/>
317316
<translator name="loopback" module="org.jboss.teiid.translator.loopback"/>
318317
<translator name="olap" module="org.jboss.teiid.translator.olap"/>

engine/src/main/java/org/teiid/query/function/FunctionMethods.java

+9
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,15 @@ public static Object upperCase(String str) {
714714
public static Object locate(String sub, String str) {
715715
return locate(sub, str, 1);
716716
}
717+
718+
// ================== Function = endsWith =====================
719+
720+
public static Object endsWith(String sub, String str) {
721+
if(str == null || sub == null) {
722+
return Boolean.FALSE;
723+
}
724+
return str.endsWith(sub);
725+
}
717726

718727
/**
719728
* TODO: The treatment of negative start indexes is inconsistent here.

engine/src/main/java/org/teiid/query/function/source/SystemSource.java

+9
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,15 @@ private void addReplaceFunction() {
604604
new FunctionParameter("replacement", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Replace_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
605605
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Replace_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
606606
}
607+
608+
private void addEndsWithFunction() {
609+
functions.add(
610+
new FunctionMethod(SourceSystemFunctions.ENDSWITH, QueryPlugin.Util.getString("SystemSource.endswith_desc"), STRING, FUNCTION_CLASS, "endsWith", //$NON-NLS-1$ //$NON-NLS-2$
611+
new FunctionParameter[] {
612+
new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.endswith_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
613+
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.endswith_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
614+
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.endswith_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
615+
}
607616

608617
private void addRepeatFunction() {
609618
functions.add(

engine/src/main/resources/org/teiid/metadata/SYS.sql

+36-10
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ CREATE FOREIGN TABLE Columns (
2929
Radix integer NOT NULL,
3030
UID string(50) NOT NULL,
3131
Description string(255),
32-
OID integer
32+
OID integer,
33+
PRIMARY KEY (VDBName, SchemaName, TableName, Name),
34+
FOREIGN KEY (VDBName, SchemaName, TableName) REFERENCES Tables (VDBName, SchemaName, Name),
35+
FOREIGN KEY (DataType) REFERENCES DataTypes(Name),
36+
UNIQUE (UID)
3337
);
3438

3539
CREATE FOREIGN TABLE DataTypes (
@@ -51,7 +55,9 @@ CREATE FOREIGN TABLE DataTypes (
5155
RuntimeType string(64),
5256
BaseType string(64),
5357
Description string(255),
54-
OID integer
58+
OID integer,
59+
PRIMARY KEY (Name),
60+
UNIQUE (UID)
5561
);
5662

5763
CREATE FOREIGN TABLE KeyColumns (
@@ -64,7 +70,10 @@ CREATE FOREIGN TABLE KeyColumns (
6470
RefKeyUID string(50),
6571
UID string(50) NOT NULL,
6672
Position integer,
67-
OID integer
73+
OID integer,
74+
PRIMARY KEY (VDBName, SchemaName, TableName, Name),
75+
FOREIGN KEY (VDBName, SchemaName, TableName) REFERENCES Tables (VDBName, SchemaName, Name),
76+
UNIQUE (UID)
6877
);
6978

7079
CREATE FOREIGN TABLE Keys (
@@ -78,7 +87,10 @@ CREATE FOREIGN TABLE Keys (
7887
IsIndexed boolean NOT NULL,
7988
RefKeyUID string(50),
8089
UID string(50) NOT NULL,
81-
OID integer
90+
OID integer,
91+
PRIMARY KEY (VDBName, SchemaName, TableName, Name),
92+
FOREIGN KEY (VDBName, SchemaName, TableName) REFERENCES Tables (VDBName, SchemaName, Name),
93+
UNIQUE (UID)
8294
);
8395

8496
CREATE FOREIGN TABLE ProcedureParams (
@@ -97,7 +109,11 @@ CREATE FOREIGN TABLE ProcedureParams (
97109
NullType string(10) NOT NULL,
98110
UID string(50),
99111
Description string(255),
100-
OID integer
112+
OID integer,
113+
PRIMARY KEY (VDBName, SchemaName, ProcedureName, Name),
114+
FOREIGN KEY (VDBName, SchemaName, ProcedureName) REFERENCES Procedures (VDBName, SchemaName, Name),
115+
FOREIGN KEY (DataType) REFERENCES DataTypes(Name),
116+
UNIQUE (UID)
101117
);
102118

103119
CREATE FOREIGN TABLE Procedures (
@@ -108,15 +124,19 @@ CREATE FOREIGN TABLE Procedures (
108124
ReturnsResults boolean NOT NULL,
109125
UID string(50) NOT NULL,
110126
Description string(255),
111-
OID integer
127+
OID integer,
128+
PRIMARY KEY (VDBName, SchemaName, Name),
129+
FOREIGN KEY (VDBName, SchemaName) REFERENCES Schemas (VDBName, Name),
130+
UNIQUE (UID)
112131
);
113132

114133
CREATE FOREIGN TABLE Properties (
115134
Name string(255) NOT NULL,
116135
"Value" string(255) NOT NULL,
117136
UID string(50) NOT NULL,
118137
OID integer,
119-
ClobValue clob(2097152)
138+
ClobValue clob(2097152),
139+
UNIQUE(UID)
120140
);
121141

122142
CREATE FOREIGN TABLE ReferenceKeyColumns (
@@ -143,7 +163,9 @@ CREATE FOREIGN TABLE Schemas (
143163
UID string(50) NOT NULL,
144164
Description string(255),
145165
PrimaryMetamodelURI string(255) NOT NULL,
146-
OID integer
166+
OID integer,
167+
PRIMARY KEY (VDBName, Name),
168+
UNIQUE (UID)
147169
);
148170

149171
CREATE FOREIGN TABLE Tables (
@@ -159,12 +181,16 @@ CREATE FOREIGN TABLE Tables (
159181
Description string(255),
160182
IsSystem boolean,
161183
IsMaterialized boolean NOT NULL,
162-
OID integer
184+
OID integer,
185+
PRIMARY KEY (VDBName, SchemaName, Name),
186+
FOREIGN KEY (VDBName, SchemaName) REFERENCES Schemas (VDBName, Name),
187+
UNIQUE (UID)
163188
);
164189

165190
CREATE FOREIGN TABLE VirtualDatabases (
166191
Name string(255) NOT NULL,
167-
Version string(50) NOT NULL
192+
Version string(50) NOT NULL,
193+
PRIMARY KEY (Name, Version)
168194
);
169195

170196
CREATE FOREIGN PROCEDURE getXMLSchemas(IN document string NOT NULL) RETURNS TABLE (schema xml)

engine/src/main/resources/org/teiid/metadata/SYSADMIN.sql

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ CREATE FOREIGN TABLE MatViews (
77
Valid boolean,
88
LoadState string(255),
99
Updated timestamp,
10-
Cardinality integer
10+
Cardinality integer,
11+
PRIMARY KEY (VDBName, SchemaName, Name)
1112
);
1213

1314
CREATE FOREIGN TABLE VDBResources (
1415
resourcePath string(255),
15-
contents blob
16+
contents blob,
17+
PRIMARY KEY (resourcePath)
1618
);
1719

1820
CREATE FOREIGN PROCEDURE isLoggable(OUT loggable boolean NOT NULL RESULT, IN level string NOT NULL DEFAULT 'DEBUG', IN context string NOT NULL DEFAULT 'org.teiid.PROCESSOR')

engine/src/main/resources/org/teiid/query/i18n.properties

+4
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ SystemSource.decode_arg2=The encoding
640640
SystemSource.decode_result=byte representation Blob
641641
SystemSource.session_id_desc=Returns the session id of the currently logged in user
642642
SystemSource.session_id_result=Returns the session id of the currently logged in user
643+
SystemSource.endswith_desc=Find if string has ending character sequence as defined in substring
644+
SystemSource.endswith_arg1=substring
645+
SystemSource.endswith_arg2=string
646+
SystemSource.endswith_result=true if string ends with character sequence of substring; false otherwise.
643647
TEIID30350=Element ''{0}'' not found.
644648
TEIID30351=Group ''{0}'' not found.
645649
TEIID30341=Function {0} is marked in the function metadata as a function that must be evaluated at the source.

engine/src/test/java/org/teiid/query/function/TestFunction.java

+17
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public static void helpTestLocate(String locateString, String input, int expecte
130130
int actualLocation = location.intValue();
131131
assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
132132
}
133+
134+
public static void helpTestEndssWith(String locateString, String input, Boolean expected) {
135+
Boolean actual = (Boolean) FunctionMethods.endsWith(locateString, input);
136+
assertEquals("Didn't get expected result from startsWith", expected, actual); //$NON-NLS-1$
137+
}
133138

134139
public static void helpTestLocate(String locateString, String input, Integer start, int expectedLocation) {
135140
Integer location = (Integer) FunctionMethods.locate(locateString, input, start);
@@ -626,7 +631,19 @@ public static void helpTestParseTimestamp(String tsStr, String format, String ex
626631
@Test public void testLocate8() throws Exception {
627632
helpTestLocate("z", "abab", -1, 0); //$NON-NLS-1$ //$NON-NLS-2$
628633
}
634+
635+
@Test public void testEndsWith1() throws Exception {
636+
helpTestEndssWith("z", "abab", false); //$NON-NLS-1$ //$NON-NLS-2$
637+
}
638+
639+
@Test public void testEndsWith2() throws Exception {
640+
helpTestEndssWith("b", "abab", true); //$NON-NLS-1$ //$NON-NLS-2$
641+
}
629642

643+
@Test public void testEndsWith3() throws Exception {
644+
helpTestEndssWith("a", null, false); //$NON-NLS-1$ //$NON-NLS-2$
645+
}
646+
630647
@Test public void testBitand() throws Exception {
631648
// Both values are integers
632649
Integer result = (Integer) FunctionMethods.bitand(new Integer(0xFFF), new Integer(0x0F0));

engine/src/test/java/org/teiid/query/processor/TestTextTable.java

+12
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ public class TestTextTable {
205205
process(sql, expected);
206206
}
207207

208+
@Test public void testCarraigeReturn() throws Exception {
209+
String sql = "select * from texttable('a,b\r\nc,d\r\ne,f' COLUMNS c1 string, c2 string) x"; //$NON-NLS-1$
210+
211+
List[] expected = new List[] {
212+
Arrays.asList("a", "b"),
213+
Arrays.asList("c", "d"),
214+
Arrays.asList("e", "f"),
215+
};
216+
217+
process(sql, expected);
218+
}
219+
208220
@Test public void testQuote() throws Exception {
209221
String sql = "select * from texttable(' \" a\", \" \"\" \"' COLUMNS c1 string, c2 string) x"; //$NON-NLS-1$
210222

jboss-integration/pom.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@
147147
<version>${project.version}</version>
148148
<scope>test</scope>
149149
</dependency>
150-
150+
<dependency>
151+
<groupId>org.jboss.as</groupId>
152+
<artifactId>jboss-as-jaxrs</artifactId>
153+
<version>7.1.1.Final</version>
154+
</dependency>
151155
</dependencies>
152156

153157
</project>

jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,10 @@ protected void executeOperation(OperationContext context, DQPCore engine, ModelN
14681468

14691469
ServiceName svcName = ServiceName.JBOSS.append("deployment", "unit").append(rarName); //$NON-NLS-1$ //$NON-NLS-2$
14701470
ServiceController<?> sc = context.getServiceRegistry(false).getService(svcName);
1471-
DeploymentUnit du = DeploymentUnit.class.cast(sc.getValue());
1471+
if (sc == null) {
1472+
throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString("RAR_notfound"))); //$NON-NLS-1$
1473+
}
1474+
DeploymentUnit du = DeploymentUnit.class.cast(sc.getValue());
14721475
ConnectorXmlDescriptor cd = du.getAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY);
14731476
ResourceAdapter ra = cd.getConnector().getResourceadapter();
14741477
if (ra instanceof ResourceAdapter1516) {

jboss-integration/src/main/java/org/teiid/jboss/TransportService.java

+2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ protected ClientServiceRegistry getClientServiceRegistry() {
208208
DQP dqpProxy = proxyService(DQP.class, getDQP(), LogConstants.CTX_DQP);
209209
this.csr.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
210210
this.csr.registerClientService(DQP.class, dqpProxy, LogConstants.CTX_DQP);
211+
//used by odata for metadata
212+
this.csr.registerClientService(VDBRepository.class, getVdbRepository(), LogConstants.CTX_DQP);
211213
}
212214

213215
@Override

jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ event_distributor_bound=org.teiid.events.EventDistributorFactory is bound to {0}
3232
TEIID50019=Re-deploying VDB {0}
3333
TEIID50054=Model {0} not found in VDB {1}.{2}
3434
TEIID50055=Source name {0} not found in Model {1} in VDB {1}.{2}
35+
RAR_notfound=RAR file name supplied on operation is wrong or no such RAR file is currently deployed.
3536

3637
distributed_cache_not_enabled= Distributed caching NOT enabled. Missing "distributed-cache" property in the configuration or running in standalone mode.
3738
TEIID50003=Distributed caching enabled.

pom.xml

+51-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<version.sun.jaxb>2.2.4</version.sun.jaxb>
4141
<version.javax.wsdl4j>1.6.2</version.javax.wsdl4j>
4242
<version.junit>4.10</version.junit>
43+
<version.javax.ws.rs>1.1</version.javax.ws.rs>
44+
<version.org.odata4j>0.8.0-SNAPSHOT</version.org.odata4j>
45+
<version.core4j>0.5</version.core4j>
46+
<version.resteasy-jaxrs>2.3.2.Final</version.resteasy-jaxrs>
4347
</properties>
4448
<scm>
4549
<connection>scm:git:git://github.com/teiid/teiid.git</connection>
@@ -675,7 +679,52 @@
675679
<groupId>wsdl4j</groupId>
676680
<artifactId>wsdl4j</artifactId>
677681
<version>${version.javax.wsdl4j}</version>
678-
</dependency>
682+
</dependency>
683+
<dependency>
684+
<groupId>javax.ws.rs</groupId>
685+
<artifactId>jsr311-api</artifactId>
686+
<version>${version.javax.ws.rs}</version>
687+
</dependency>
688+
<dependency>
689+
<groupId>org.odata4j</groupId>
690+
<artifactId>odata4j-core</artifactId>
691+
<version>${version.org.odata4j}</version>
692+
<exclusions>
693+
<exclusion>
694+
<groupId>org.eclipse.persistence</groupId>
695+
<artifactId>javax.persistence</artifactId>
696+
</exclusion>
697+
<exclusion>
698+
<groupId>javax.ws.rs</groupId>
699+
<artifactId>jsr311-api</artifactId>
700+
</exclusion>
701+
<exclusion>
702+
<groupId>org.eclipse.persistence</groupId>
703+
<artifactId>eclipselink</artifactId>
704+
</exclusion>
705+
<!--
706+
<exclusion>
707+
<groupId>joda-time</groupId>
708+
<artifactId>joda-time</artifactId>
709+
</exclusion>
710+
-->
711+
</exclusions>
712+
</dependency>
713+
<dependency>
714+
<artifactId>core4j</artifactId>
715+
<groupId>org.core4j</groupId>
716+
<version>${version.core4j}</version>
717+
</dependency>
718+
<dependency>
719+
<groupId>org.jboss.resteasy</groupId>
720+
<artifactId>resteasy-jaxrs</artifactId>
721+
<version>${version.resteasy-jaxrs}</version>
722+
</dependency>
723+
<dependency>
724+
<groupId>org.jboss.spec.javax.servlet</groupId>
725+
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
726+
<version>1.0.0.Final</version>
727+
</dependency>
679728
</dependencies>
680729
</dependencyManagement>
681730
<modules>
@@ -695,5 +744,6 @@
695744
<module>test-integration</module>
696745
<module>client-jdk15</module>
697746
<module>admin</module>
747+
<module>odata</module>
698748
</modules>
699749
</project>

0 commit comments

Comments
 (0)