@Override public void visit(NamedTable obj) { try { this.odataQuery.addRootDocument(obj.getMetadataObject()); } catch (TranslatorException e) { this.exceptions.add(e); } } }
public NamedTable createNamedTable(String name, String correlationName, Table metadataReference) { return new NamedTable(name, correlationName, metadataReference); }
private boolean isDual(NamedTable table) { String groupName = null; AbstractMetadataRecord groupID = table.getMetadataObject(); if(groupID != null) { groupName = SQLStringVisitor.getRecordName(groupID); } else { groupName = table.getName(); } return DUAL.equalsIgnoreCase(groupName); }
private void stripDualAlias(NamedTable table) { if (table.getCorrelationName() != null) { if (isDual(table)) { table.setCorrelationName(null); } } }
@Override public void visit(NamedTable obj) { if (obj.getMetadataObject() != null) { return; } String name = obj.getName(); String val = nameMap.get(name); if (val != null) { obj.setName(val); } if (obj.getCorrelationName() == null) { obj.setCorrelationName(name); } } }
private boolean alreadyInJoin(NamedTable table) { String[] splits = table.getName().split("\\."); String correlationName = splits[0]; String attrName = splits[1]; for(JoinTable joinTable:this.joins) { if (joinTable.parent != null && joinTable.parent.getCorrelationName().equals(correlationName) && attrName.equals(joinTable.childAttributeName)) { return true; } } return false; }
private boolean isParentOf(NamedTable parent, NamedTable child) { String[] splits = child.getName().split("\\."); String correlation = splits[0]; String attrName = splits[1]; if (!parent.getCorrelationName().equals(correlation)) { return false; } for (ForeignKey fk:parent.getMetadataObject().getForeignKeys()){ if (fk.getReferenceKey().getParent().equals(child.getMetadataObject())) { return true; } } return false; }
@Override public void visit(NamedTable obj) { if (obj.getCorrelationName() == null) { String aliasName = "ql_"+this.aliasCounter.getAndIncrement(); //$NON-NLS-1$ this.correlatedName.put(obj.getMetadataObject().getName(), aliasName); obj.setCorrelationName(aliasName); } else { this.correlatedName.put(obj.getMetadataObject().getName(), obj.getCorrelationName()); } }
@Override public void visit(Join obj) { try { handleJoin(obj); for (NamedTable table:this.implicitGroups.values()) { NamedTable parent = findParent(table); if (parent != null) { if (!alreadyInJoin(table)) { this.joins.add(new JoinTable(parent, table, JoinType.LEFT_OUTER_JOIN)); } } else { exceptions.add(new TranslatorException(JPAPlugin.Util.gs(JPAPlugin.Event.TEIID14004, table.getName()))); } } } catch (TranslatorException e) { exceptions.add(e); } }
groupName = rightTable.getCorrelationName() + Tokens.DOT + leftTable.getName(); NamedTable table = this.implicitGroups.get(groupName); if (table != null) { table.setCorrelationName(leftTable.getCorrelationName()); groupName = leftTable.getCorrelationName() + Tokens.DOT + rightTable.getName(); table = this.implicitGroups.get(groupName); if (table != null) { table.setCorrelationName(rightTable.getCorrelationName());
public NamedTable translate(GroupSymbol symbol) { String alias = null; String fullGroup = symbol.getOutputName(); if(symbol.getOutputDefinition() != null) { alias = symbol.getOutputName(); fullGroup = symbol.getOutputDefinition(); if (remappedGroups != null) { GroupSymbol remappedGroup = remappedGroups.get(symbol.getMetadataID()); if (remappedGroup != null && remappedGroup != symbol) { fullGroup = remappedGroup.getName(); } } } fullGroup = removeSchemaName(fullGroup); NamedTable group = new NamedTable(fullGroup, alias, null); try { group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID())); } catch (QueryMetadataException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30487, e); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30488, e); } return group; }
nameMap = new HashMap<String, String>(); nameMap.put(item.getTable().getName(), tableName); NamedTable table = new NamedTable(tableName, null, null); if (tempTables == null) { tempTables = new ArrayList<NamedTable>();
@Override public void visit(ColumnReference obj) { AbstractMetadataRecord record = obj.getMetadataObject(); if (record != null) { String name = record.getProperty(JPAMetadataProcessor.KEY_ASSOSIATED_WITH_FOREIGN_TABLE, false); if (name != null) { try { Table t = this.metadata.getTable(name); String correlationName = obj.getTable().getCorrelationName(); String attrName = record.getProperty(JPAMetadataProcessor.RELATION_PROPERTY, false); String groupName = correlationName + Tokens.DOT + attrName; NamedTable nt = this.implicitGroups.get(groupName); if (nt == null) { nt = new NamedTable(groupName, "J_"+this.aliasCounter.getAndIncrement(), t); this.implicitGroups.put(groupName, nt); //$NON-NLS-1$ } } catch (TranslatorException e) { exceptions.add(e); } } } }
public void visit(NamedTable obj) { appendBaseName(obj); if (obj.getCorrelationName() != null) { buffer.append(Tokens.SPACE); if (useAsInGroupAlias()){ buffer.append(AS) .append(Tokens.SPACE); } buffer.append(obj.getCorrelationName()); } }
@Override protected void appendBaseName(NamedTable obj) { if (obj.getMetadataObject() != null) { String nativeQuery = obj.getMetadataObject().getProperty(TEIID_NATIVE_QUERY, false); if (nativeQuery != null) { if (obj.getCorrelationName() == null) { throw new IllegalArgumentException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11020, obj.getName())); } buffer.append(Tokens.LPAREN).append(nativeQuery).append(Tokens.RPAREN); if (obj.getCorrelationName() == null) { buffer.append(Tokens.SPACE); if (useAsInGroupAlias()){ buffer.append(AS).append(Tokens.SPACE); } } return; } } super.appendBaseName(obj); }
private boolean isInReference(NamedTable table, ColumnReference reference) { return table.getCorrelationName().equals(reference.getTable().getCorrelationName()) && table.getName().equals(reference.getTable().getName()); }
for (NamedTable temp : tempTables) { try { LogManager.logDetail(LogConstants.CTX_CONNECTOR, "dropping temporary table", temp.getName()); //$NON-NLS-1$ s.execute(this.executionFactory.getDialect().getDefaultMultiTableBulkIdStrategy().getIdTableSupport().getDropIdTableCommand() + " " + temp.getName()); //$NON-NLS-1$ } catch (SQLException e) {
public NamedTable translate(GroupSymbol symbol) { String alias = null; String fullGroup = symbol.getOutputName(); if(symbol.getOutputDefinition() != null) { alias = symbol.getOutputName(); fullGroup = symbol.getOutputDefinition(); if (remappedGroups != null) { GroupSymbol remappedGroup = remappedGroups.get(symbol.getMetadataID()); if (remappedGroup != null && remappedGroup != symbol) { fullGroup = remappedGroup.getName(); } } } fullGroup = removeSchemaName(fullGroup); NamedTable group = new NamedTable(fullGroup, alias, null); try { group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID())); } catch (QueryMetadataException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30487, e); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30488, e); } return group; }
@Override public void visit(ColumnReference column) { Column record = column.getMetadataObject(); if (record != null) { String name = record.getProperty(JPAMetadataProcessor.KEY_ASSOSIATED_WITH_FOREIGN_TABLE, false); if (name == null) { buffer.append(column.getTable().getCorrelationName()).append(Tokens.DOT) .append(record.getSourceName()); } else { String attrName = record.getProperty(JPAMetadataProcessor.RELATION_PROPERTY, false); String attrColumnName = record.getProperty(JPAMetadataProcessor.RELATION_KEY, false); String groupName = column.getTable().getCorrelationName() + Tokens.DOT + attrName; String correlationName = this.visitor.implicitGroups.get(groupName).getCorrelationName(); buffer.append(correlationName).append(Tokens.DOT).append(attrColumnName); } } else { buffer.append(column.getName()); } }
@Override public void visit(NamedTable obj) { super.visit(obj); this.table = obj.getMetadataObject(); }