Skip to content

Commit

Permalink
TEIIDDES-1518: Implement a Query Service
Browse files Browse the repository at this point in the history
* Implements a service that offers up the syntax and other query-related
  elements associated with the teiid client of the default server.
  • Loading branch information
Paul Richardson committed Dec 7, 2012
1 parent d112c5a commit 6907c1f
Show file tree
Hide file tree
Showing 48 changed files with 460 additions and 5,261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import org.teiid.designer.runtime.registry.TeiidRuntimeRegistry;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;
import org.teiid.designer.sql.IQueryService;
import org.teiid.designer.type.IDataTypeManagerService;

/**
Expand Down Expand Up @@ -2093,7 +2094,7 @@ public static void setTeiidServerVersion(ITeiidServerVersion serverVersion) {

/**
* Get the teiid data type manager service for the
* targetted teiid server. The targeted teiid server
* targeted teiid server. The targeted teiid server
* can be changed using {@link #setTeiidServerVersion(ITeiidServerVersion)}
*
* @return
Expand All @@ -2105,4 +2106,19 @@ public static IDataTypeManagerService getTeiidDataTypeManagerService() {
throw new RuntimeException(ex);
}
}

/**
* Get the teiid query service for the
* targeted teiid server. The targeted teiid server
* can be changed using {@link #setTeiidServerVersion(ITeiidServerVersion)}
*
* @return
*/
public static IQueryService getTeiidQueryService() {
try {
return TeiidRuntimeRegistry.getInstance().getQueryService(getTeiidServerVersion());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}
1 change: 1 addition & 0 deletions plugins/org.teiid.designer.mapping.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.8.0,4.0.0)",
org.teiid.designer.metamodels.transformation;bundle-version="[8.0.0,9.0.0)",
org.teiid.designer.metamodels.core;bundle-version="[8.0.0,9.0.0)",
org.teiid.designer.legacy;bundle-version="[8.0.0,9.0.0)",
org.teiid.designer.spi;bundle-version="[8.0.0,9.0.0)",
org.teiid8;bundle-version="[8.0.0,9.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ private void createStandardRules() {
// Add word rule for keywords, datatypes, and function names.
WordRule wordRule = new WordRule(new SqlWordDetector(), other);

// for (int i = 0; i < SqlSyntax.DATATYPE_NAMES.size(); i++)
// wordRule.addWord((String)SqlSyntax.DATATYPE_NAMES.get(i), datatype);
// for (int i = 0; i < SqlSyntax.FUNCTION_NAMES.size(); i++)
// wordRule.addWord((String)SqlSyntax.FUNCTION_NAMES.get(i), function);

rules.add(wordRule);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.8.0,3.0.0)",
org.teiid.designer.legacy;bundle-version="[8.0.0,9.0.0)",
org.teiid8;bundle-version="[8.0.0,9.0.0)",
org.teiid.designer.extension;bundle-version="[8.0.0,9.0.0)",
org.eclipse.core.resources;bundle-version="[3.8.0,4.0.0)"
org.eclipse.core.resources;bundle-version="[3.8.0,4.0.0)",
org.teiid.designer.spi;bundle-version="[8.0.0,9.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.teiid.designer.metadata.runtime.api.DataType;
import org.teiid.designer.metamodels.relational.RelationalPlugin;
import org.teiid.designer.metamodels.relational.SearchabilityType;
import org.teiid.designer.sql.IQueryService;


/**
Expand Down Expand Up @@ -121,7 +122,7 @@ protected String getIdentifier( final EObject datatype ) {
*
* @param jdbcTypeName the name of the JDBC type
* @return the {@link DataType} that best corresponds to the JDBC type name
* @throws ModelerCoreException if there is a problem with the {@link DataTypeManager}
* @throws ModelerCoreException if there is a problem with the {@link DatatypeManager}
*/
@Override
public EObject getDatatype( final String jdbcTypeName ) throws ModelerCoreException {
Expand All @@ -144,14 +145,16 @@ public EObject getDatatype( final String jdbcTypeName ) throws ModelerCoreExcept
* @param jdbcType the JDBC type
* @return the {@link DataType} that best corresponds to the JDBC type, or null if no {@link DataType} could be found or if the type is
* ambiguous (such as {@link Types#OTHER}).
* @throws ModelerCoreException if there is a problem with the {@link DataTypeManager}
* @throws ModelerCoreException if there is a problem with the {@link DatatypeManager}
*/
@Override
public EObject getDatatype( final int jdbcType ) throws ModelerCoreException {
if (jdbcType == Types.JAVA_OBJECT) {
return findDatatype(DatatypeConstants.BuiltInNames.OBJECT);
}
String typeName = JDBCSQLTypeInfo.getTypeName(jdbcType);

IQueryService service = ModelerCore.getTeiidQueryService();
String typeName = service.getJDBCSQLTypeName(jdbcType);
String builtinName = DatatypeConstants.getDatatypeNamefromRuntimeType(typeName);
if (builtinName == null || DatatypeConstants.BuiltInNames.OBJECT.equals(builtinName)) {
return null; //not a known sql type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0.0)",
org.apache.commons.discovery;bundle-version="[0.2.0,1.0.0)",
javax.xml.rpc;bundle-version="[1.1.0,2.0.0)",
org.wsdl4j;bundle-version="[1.4.0,2.0.0)",
org.teiid.designer.extension;bundle-version="[8.0.0,9.0.0)"
org.teiid.designer.extension;bundle-version="[8.0.0,9.0.0)",
org.teiid.designer.spi;bundle-version="[8.0.0,9.0.0)"
Bundle-ActivationPolicy: lazy
Export-Package: com.sforce.soap.partner;x-friends:="org.teiid.designer.modelgenerator.salesforce.test",
org.teiid.designer.modelgenerator.salesforce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
package org.teiid.designer.modelgenerator.salesforce.util;

import org.teiid.language.SQLConstants;
import org.teiid.query.sql.ProcedureReservedWords;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.sql.IQueryService;

/**
* @since 8.0
Expand All @@ -32,7 +32,9 @@ public static String normalizeName( String nameIn ) {
* @return
*/
private static String checkReservedWords( String normal ) {
if (SQLConstants.isReservedWord(normal) || ProcedureReservedWords.isProcedureReservedWord(normal)) {
IQueryService sqlSyntaxService = ModelerCore.getTeiidQueryService();

if( sqlSyntaxService.isReservedWord(normal) || sqlSyntaxService.isProcedureReservedWord(normal)) {
normal = normal + "_"; //$NON-NLS-1$
}
return normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import org.teiid.designer.schema.tools.model.schema.impl.BaseSchemaObject;
import org.teiid.designer.schema.tools.processing.SchemaProcessingException;
import org.teiid.designer.schema.tools.processing.SchemaProcessor;
import org.teiid.designer.transformation.util.SqlConstants;
import org.teiid.designer.sql.ISQLConstants;
import org.teiid.designer.ui.viewsupport.DatatypeUtilities;
import org.teiid.designer.ui.viewsupport.ModelUtilities;

Expand Down Expand Up @@ -502,8 +502,8 @@ public String createResponseColumn(int type,
String prefix = null;
StringBuilder parentXpath = new StringBuilder();
if (importManager.isMessageServiceMode()) {
responseInfo.addNamespace(SqlConstants.ENVELOPE_NS_ALIAS,
SqlConstants.ENVELOPE_NS);
responseInfo.addNamespace(ISQLConstants.ENVELOPE_NS_ALIAS,
ISQLConstants.ENVELOPE_NS);
}
//Add the default namespace.
responseInfo.addNamespace(ResponseInfo.DEFAULT_NS, this.responseSchemaTreeModel.getDefaultNamespace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.validation.rules.StringNameValidator;
import org.teiid.designer.metamodels.relational.aspects.validation.RelationalStringNameValidator;
import org.teiid.designer.modelgenerator.wsdl.model.Operation;
import org.teiid.designer.modelgenerator.wsdl.ui.Messages;
import org.teiid.designer.modelgenerator.wsdl.ui.ModelGeneratorWsdlUiConstants;
import org.teiid.designer.modelgenerator.wsdl.ui.util.ModelGeneratorWsdlUiUtil;
import org.teiid.designer.modelgenerator.wsdl.ui.wizards.WSDLImportWizardManager;
import org.teiid.designer.transformation.util.SqlConstants;
import org.teiid.language.SQLConstants;
import org.teiid.designer.sql.IQueryService;
import org.teiid.designer.sql.ISQLConstants;


/** This class provides state information for the create and extract procedures that will be generated during
Expand All @@ -32,7 +33,7 @@
*
* @since 8.0
*/
public class ProcedureGenerator implements SqlConstants {
public class ProcedureGenerator implements ISQLConstants {
public static final String PLUGIN_ID = ModelGeneratorWsdlUiConstants.PLUGIN_ID;

private static final StringNameValidator nameValidator = new RelationalStringNameValidator(false, true);
Expand Down Expand Up @@ -420,7 +421,9 @@ public IStatus validate() {
* @return
*/
public String convertSqlNameSegment(String name) {
if( SQLConstants.isReservedWord(name) ) {
IQueryService sqlSyntaxService = ModelerCore.getTeiidQueryService();

if( sqlSyntaxService.isReservedWord(name) ) {
return '\"' + name + '\"';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import org.teiid.designer.core.util.StringUtilities;
import org.teiid.designer.core.validation.rules.StringNameValidator;
import org.teiid.designer.modelgenerator.wsdl.model.Operation;
import org.teiid.designer.transformation.util.SqlConstants;
import org.teiid.designer.sql.ISQLConstants;



/**
* @since 8.0
*/
public abstract class ProcedureInfo implements SqlConstants {
public abstract class ProcedureInfo implements ISQLConstants {

public static final String SQL_BEGIN = "CREATE VIRTUAL PROCEDURE\nBEGIN\n"; //$NON-NLS-1$
public static final String SQL_END = "\nEND"; //$NON-NLS-1$
Expand Down
14 changes: 7 additions & 7 deletions plugins/org.teiid.designer.query.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ Bundle-Version: 8.0.0.qualifier
Bundle-Activator: org.teiid.query.ui.UiPlugin
Bundle-Vendor: %pluginProvider
Bundle-Localization: plugin
Export-Package: org.teiid.query.ui,
org.teiid.query.ui.actions,
org.teiid.query.ui.builder.model,
org.teiid.query.ui.builder.util,
org.teiid.query.ui.sqleditor.component,
org.teiid.query.ui.sqleditor.sql,
org.teiid.query.ui.tree
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.8.0,4.0.0)",
org.eclipse.ui.views;bundle-version="[3.6.100,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.8.0,4.0.0)",
Expand All @@ -32,3 +25,10 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.8.0,4.0.0)",
org.teiid.designer.spi;bundle-version="8.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.teiid.query.ui,
org.teiid.query.ui.actions,
org.teiid.query.ui.builder.model,
org.teiid.query.ui.builder.util,
org.teiid.query.ui.sqleditor.component,
org.teiid.query.ui.sqleditor.sql,
org.teiid.query.ui.tree
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,17 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import javax.management.Query;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.designer.core.index.Block;
import org.teiid.designer.core.query.QueryValidationResult;
import org.teiid.designer.core.query.QueryValidator;
import org.teiid.designer.core.query.QueryValidator.ElementSymbolOptimization;
import org.teiid.language.SQLConstants;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.From;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.MultipleElementSymbol;
import org.teiid.query.sql.symbol.Symbol;
import org.teiid.designer.sql.ISQLConstants;
import org.teiid.query.ui.UiConstants;


Expand Down Expand Up @@ -219,7 +208,7 @@ private void validateSql(String inputSqlString, boolean doResolveAndValidate, Qu
//nValidations++;
// Replace sqlString with the combined toSting() values of sqlDisplayNode's display node list, replacing the visible
// nodes' text with the current value of sqlString.
if (!sqlString.trim().toUpperCase().startsWith(SQLConstants.Reserved.CREATE) && this.sqlDisplayNode != null) {
if (!sqlString.trim().toUpperCase().startsWith(ISQLConstants.SQL_TYPE_CREATE_STRING) && this.sqlDisplayNode != null) {
StringBuffer text = new StringBuffer();
boolean replaced = false;
for (Iterator iter = this.sqlDisplayNode.getDisplayNodeList().iterator(); iter.hasNext();) {
Expand All @@ -230,7 +219,7 @@ private void validateSql(String inputSqlString, boolean doResolveAndValidate, Qu
replaced = true;
}
} else {
if (!replaced && node.getParent().languageObject instanceof Block && SQLConstants.Reserved.END.equals(node.toString())) {
if (!replaced && node.getParent().languageObject instanceof Block && ISQLConstants.END.equals(node.toString())) {
text.append(sqlString);
}
text.append(node.toString());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,18 @@ public SqlCodeScanner(ColorManager colorManager) {

// Add word rule for keywords, datatypes, and function names.
WordRule wordRule = new CaseInsensitiveWordRule(new SqlWordDetector(), other);
for (int i = 0; i < SqlSyntax.RESERVED_WORDS.size(); i++)
wordRule.addWord(SqlSyntax.RESERVED_WORDS.get(i), keyword);
for (int i = 0; i < SqlSyntax.DATATYPE_NAMES.size(); i++)
wordRule.addWord(SqlSyntax.DATATYPE_NAMES.get(i), datatype);
for (int i = 0; i < SqlSyntax.FUNCTION_NAMES.size(); i++)
wordRule.addWord(SqlSyntax.FUNCTION_NAMES.get(i), function);
rules.add(wordRule);
SqlSyntax sqlSyntax = new SqlSyntax();

for (String word : sqlSyntax.getReservedWords())
wordRule.addWord(word, keyword);

for (String dataTypeName : sqlSyntax.getDataTypeNames())
wordRule.addWord(dataTypeName, datatype);

for (String functionName : sqlSyntax.getFunctionNames())
wordRule.addWord(functionName, function);

rules.add(wordRule);

IRule[] result = new IRule[rules.size()];
rules.toArray(result);
Expand Down

0 comments on commit 6907c1f

Please sign in to comment.