Skip to content

Commit

Permalink
TEIIDDES-1565: Changes to code by removal of runtime wrapping classes
Browse files Browse the repository at this point in the history
* Removal of ILanguageObject isFunction() and isExpression() methods
  as no longer necessary (hopefully!)

* org.teiid.designer.spi
 * Use of generics to allow minimum changes to the teiid runtime
   codebases
 * Addition of interfaces to complete the teiid syntax language and
   properly represent the language visitors
 * Changes to enums and statics to synchronise with teiid runtime code
 * Replacement with lists of arrays and varargs since the compiler
   simply casts them which causes a class cast exception
  • Loading branch information
Paul Richardson committed Jan 25, 2013
1 parent a3f731d commit 987a38a
Show file tree
Hide file tree
Showing 186 changed files with 2,396 additions and 632 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ public void launchCriteriaBuilder() {

IQueryService queryService = ModelerCore.getTeiidQueryService();
ISQLStringVisitor visitor = queryService.getSQLStringVisitor();
final String sqlCriteria = visitor.getSQLString(newCriteria);
final String sqlCriteria = visitor.returnSQLString(newCriteria);
// Recreate the query object so that the references within the new criteria (that the user entered in the criteria
// builder dialog) get resolved. Can't just persist the command since the command is created as a result of the
// validation process, not the other way around.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void launchCriteriaBuilder() {
ILanguageObject newCriteria = builder.getLanguageObject();
IQueryService queryService = ModelerCore.getTeiidQueryService();
ISQLStringVisitor visitor = queryService.getSQLStringVisitor();
String sCriteriaString = visitor.getSQLString(newCriteria);
String sCriteriaString = visitor.returnSQLString(newCriteria);
// this: updateCriteriaForSelectedRow( criteriaString );
docRecursionConditionCriteria.set(sCriteriaString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public ILanguageObject getLanguageObject() {
}

int numArgs = argValues.size();
IExpression[] args = new IExpression[numArgs];
List<IExpression> args = new ArrayList<IExpression>();

for (int i = 0; i < numArgs; i++) {
args[i] = (IExpression)argValues.get(i);
args.add((IExpression)argValues.get(i));
}

IQueryService service = ModelerCore.getTeiidQueryService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static ILanguageObject getBuilderLanguageObject( ILanguageObject theLangO

ILanguageObject result = theLangObj;

if (theLangObj != null && theLangObj.isFunction() && ((IFunction)theLangObj).isImplicit()) {
if (theLangObj != null && theLangObj instanceof IFunction && ((IFunction)theLangObj).isImplicit()) {
// according to Alex, all implicit functions are conversions and
// the first argument is what is being converted
result = getBuilderLanguageObject(((IFunction)theLangObj).getArgs()[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.teiid.designer.query.sql.lang.INotCriteria;
import org.teiid.designer.query.sql.lang.IPredicateCriteria;
import org.teiid.designer.query.sql.symbol.IConstant;
import org.teiid.designer.query.sql.symbol.IFunction;
import org.teiid.designer.query.sql.symbol.IReference;
import org.teiid.query.ui.UiConstants;
import org.teiid.query.ui.UiPlugin;
Expand Down Expand Up @@ -79,7 +80,7 @@ public Image getImage( Object theElement ) {

if (theElement instanceof IConstant) {
result = CONSTANT_IMAGE;
} else if (theElement instanceof ILanguageObject && ((ILanguageObject) theElement).isFunction()) {
} else if (theElement instanceof ILanguageObject && theElement instanceof IFunction) {
result = FUNCTION_IMAGE;
} else if (theElement instanceof IPredicateCriteria) {
result = PREDICATE_IMAGE;
Expand Down Expand Up @@ -131,7 +132,7 @@ public String getText( Object theElement ) {
} else if (theElement instanceof ILanguageObject) {
IQueryService queryService = ModelerCore.getTeiidQueryService();
ISQLStringVisitor visitor = queryService.getSQLStringVisitor();
result = visitor.getSQLString((ILanguageObject)theElement);
result = visitor.returnSQLString((ILanguageObject)theElement);
} else {
result = super.getText(theElement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Iterator;
import java.util.List;
import org.teiid.designer.query.sql.lang.ICriteria;
import org.teiid.designer.query.sql.lang.IExpression;
import org.teiid.designer.query.sql.lang.ILanguageObject;

/**
Expand Down Expand Up @@ -174,7 +175,7 @@ public boolean isInExpression() {
public DisplayNode getExpression() {
DisplayNode parentNode = this;
while (parentNode != null) {
if (parentNode.languageObject != null && parentNode.languageObject.isExpression()) {
if (parentNode.languageObject != null && parentNode.languageObject instanceof IExpression) {
return parentNode;
}
parentNode = parentNode.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static DisplayNode constructDisplayNode( DisplayNode parentNode,
} else if (obj instanceof ICompoundCriteria) {
CompoundCriteriaDisplayNode node = new CompoundCriteriaDisplayNode(parentNode, (ICompoundCriteria)obj);
return node;
} else if (obj instanceof ILanguageObject && ((ILanguageObject) obj).isFunction()) {
} else if (obj instanceof IFunction) {
// ---------------------------------------------------------------------
// Constant, Function, Expression Nodes
// ---------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.teiid.designer.query.sql.lang.ICompareCriteria;
import org.teiid.designer.query.sql.lang.ICompoundCriteria;
import org.teiid.designer.query.sql.lang.ICriteria;
import org.teiid.designer.query.sql.lang.IExpression;
import org.teiid.designer.query.sql.lang.IFrom;
import org.teiid.designer.query.sql.lang.IGroupBy;
import org.teiid.designer.query.sql.lang.IIsNullCriteria;
Expand Down Expand Up @@ -204,7 +205,7 @@ public static boolean hasSymbol( DisplayNode node ) {
* @return true if the node has at least one expression, false if not.
*/
public static boolean hasExpression( DisplayNode node ) {
if (node.languageObject != null && node.languageObject.isExpression()) {
if (node.languageObject != null && node.languageObject instanceof IExpression) {
return true;
}
List nodes = node.getDisplayNodeList();
Expand Down Expand Up @@ -288,7 +289,7 @@ public static int getEndIndexOfPreviousSymbol( DisplayNode node,
*/
public static int getStartIndexOfNextExpression( DisplayNode node,
int index ) {
if (node.languageObject != null && node.languageObject.isExpression()) {
if (node.languageObject != null && node.languageObject instanceof IExpression) {
if (node.isAnywhereWithin(index)) {
return node.getStartIndex();
}
Expand Down Expand Up @@ -318,7 +319,7 @@ public static int getStartIndexOfNextExpression( DisplayNode node,
public static int getEndIndexOfPreviousExpression( DisplayNode node,
int index ) {
int prevEnd = -1;
if (node.languageObject != null && node.languageObject.isExpression()) {
if (node.languageObject != null && node.languageObject instanceof IExpression) {
if (node.isAnywhereWithin(index)) {
return node.getEndIndex() + 1;
}
Expand Down Expand Up @@ -888,7 +889,7 @@ public static DisplayNode getExpressionForNode( DisplayNode node ) {
return node.getExpression();
}
return null;
} else if (node.languageObject != null && node.languageObject.isExpression() && !(node.languageObject instanceof IScalarSubquery)) {
} else if (node.languageObject != null && node.languageObject instanceof IExpression && !(node.languageObject instanceof IScalarSubquery)) {
return node;
} else if (node.isInExpression()) {
return node.getExpression();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public GroupSymbolFinder(SqlIndexLocator locator, Collection exGroups) {
this.externalGroups = new ArrayList(exGroups);

IQueryService queryService = ModelerCore.getTeiidQueryService();
visitor = queryService.getGroupCollectorVisitor();
visitor = queryService.getGroupCollectorVisitor(true);
}

/**
Expand Down Expand Up @@ -84,12 +84,12 @@ public List find() {
private List getGroupsForCriteria() {
Set groups = new HashSet();
if( locator.isSelectScopeSelected() || locator.isWhereSelected() ) {
groups.addAll(visitor.getGroups(locator.getPrimaryLanguageObject(), true));
groups.addAll(visitor.findGroups(locator.getPrimaryLanguageObject()));
List groupsInScope = locator.collectCriteriaParentQueries(locator.isSelectScopeSelected());
DisplayNode dNode = null;
for( Iterator iter = groupsInScope.iterator(); iter.hasNext(); ) {
dNode = (DisplayNode)iter.next();
groups.addAll(visitor.getGroups(dNode.getLanguageObject(), true));
groups.addAll(visitor.findGroups(dNode.getLanguageObject()));
}
}

Expand All @@ -99,7 +99,7 @@ private List getGroupsForCriteria() {
private List getGroupsForSubQuery() {
Set allGroups = new HashSet();
// Get this commands groupSymbols
allGroups.addAll(visitor.getGroups(locator.getPrimaryLanguageObject(), true));
allGroups.addAll(visitor.findGroups(locator.getPrimaryLanguageObject()));
// Get parent node, keep going up until parent is null
if( !locator.isUnionSegmentSelected() ) {
DisplayNode parentNode = locator.getCommandDisplayNode().getParent();
Expand All @@ -111,14 +111,14 @@ private List getGroupsForSubQuery() {
parentNode = null;

if(parentNode != null && parentLangObj instanceof ICommand) {
allGroups.addAll(visitor.getGroups(parentLangObj,true));
allGroups.addAll(visitor.findGroups(parentLangObj));
}
}
// Now let's add for the real selected Select query
if( locator.isSelectScopeSelected() ) {
DisplayNode selectedSelectQueryNode = locator.getSelectedSelectQuery();
if( selectedSelectQueryNode != null )
allGroups.addAll(visitor.getGroups(selectedSelectQueryNode.getLanguageObject(), true));
allGroups.addAll(visitor.findGroups(selectedSelectQueryNode.getLanguageObject()));
}
if( locator.isCriteriaQuerySelected() ) {
allGroups.addAll(getGroupsForCriteria());
Expand All @@ -131,7 +131,7 @@ private List getGroupsForSubQuery() {

private List getGroupsForUnionSegment() {
Set allGroups = new HashSet();
allGroups.addAll(visitor.getGroups(locator.getPrimaryLanguageObject(), true));
allGroups.addAll(visitor.findGroups(locator.getPrimaryLanguageObject()));
return new ArrayList(allGroups);
}

Expand All @@ -144,7 +144,7 @@ private List getGroups() {

// make sure no duplicates before adding in external groups

Collection groups = visitor.getGroupsIgnoreInlineViews(langObj, true);
Collection groups = visitor.findGroupsIgnoreInlineViews(langObj);

Collection clonedGrps = new ArrayList(groups.size());
Iterator grpIter = groups.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public boolean hasSubQueries() {
if (primaryLanguageObject != null && primaryLanguageObject instanceof IQuery) {
IQueryService queryService = ModelerCore.getTeiidQueryService();
ICommandCollectorVisitor commandCollectorVisitor = queryService.getCommandCollectorVisitor();
List subCommands = commandCollectorVisitor.getCommands((IQuery)primaryLanguageObject);
List subCommands = commandCollectorVisitor.findCommands((IQuery)primaryLanguageObject);
return !subCommands.isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.teiid.designer.runtime.spi.ExecutionConfigurationEvent;
import org.teiid.designer.runtime.spi.IExecutionConfigurationListener;
import org.teiid.designer.type.IDataTypeManagerService;
import org.teiid.designer.udf.IFunctionDescriptor;
import org.teiid.designer.udf.IFunctionForm;
import org.teiid.designer.udf.IFunctionLibrary;
import org.teiid.designer.udf.UdfManager;
Expand Down Expand Up @@ -89,7 +90,7 @@ private void init() {
Iterator iter;
try {
// FUNCTION NAMES List
IFunctionLibrary functionLib = UdfManager.getInstance().getSystemFunctionLibrary();
IFunctionLibrary<IFunctionForm, IFunctionDescriptor> functionLib = UdfManager.getInstance().getSystemFunctionLibrary();
List<String> allCategories = functionLib.getFunctionCategories();
for (String category : allCategories) {
for (IFunctionForm fForm : functionLib.getFunctionForms(category)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Object[] getChildren(Object obj) {
} else if ( obj instanceof ICriteria ) {
IQueryService queryService = ModelerCore.getTeiidQueryService();
IValueIteratorProviderCollectorVisitor visitor = queryService.getValueIteratorProviderCollectorVisitor();
List<ISubqueryContainer<?>> containers = visitor.getValueIteratorProviders((ICriteria)obj);
List<ISubqueryContainer<?>> containers = visitor.findValueIteratorProviders((ICriteria)obj);
List<ICommand> commands = new ArrayList<ICommand>();

for (ISubqueryContainer container : containers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import org.teiid.designer.query.sql.lang.ICriteria;
import org.teiid.designer.query.sql.lang.IExpression;
import org.teiid.designer.query.sql.lang.IFrom;
import org.teiid.designer.query.sql.lang.IJoinPredicate;
import org.teiid.designer.query.sql.lang.ILanguageObject;
Expand Down Expand Up @@ -103,7 +104,7 @@ public Image getImage(Object element) {
return FROM_ICON;
} else if ( element instanceof IJoinPredicate ) {
return JOIN_ICON;
} else if ( ((ILanguageObject) element).isExpression() ) {
} else if ( element instanceof IExpression ) {
if ( element instanceof IExpressionSymbol) {
return EXPRESSION_ICON;
}
Expand Down

0 comments on commit 987a38a

Please sign in to comment.