public boolean elementSupports(Object elementID, int elementConstant) throws TeiidComponentException, QueryMetadataException { return actualMetadata.elementSupports(elementID, elementConstant); }
public boolean elementSupports(Object elementID, int elementConstant) throws TeiidComponentException, QueryMetadataException { return actualMetadata.elementSupports(elementID, elementConstant); }
public boolean elementSupports(Object elementID, int elementConstant) throws TeiidComponentException, QueryMetadataException { return actualMetadata.elementSupports(elementID, elementConstant); }
public static boolean hasDefault(Object mid, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Object defaultValue = metadata.getDefaultValue(mid); return defaultValue != null || metadata.elementSupports(mid, SupportConstants.Element.NULL); }
public static boolean hasDefault(Object mid, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Object defaultValue = metadata.getDefaultValue(mid); return defaultValue != null || metadata.elementSupports(mid, SupportConstants.Element.NULL); }
public static boolean hasDefault(Object mid, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Object defaultValue = metadata.getDefaultValue(mid); return defaultValue != null || metadata.elementSupports(mid, SupportConstants.Element.NULL); }
public static List<ElementSymbol> getAutoIncrementKey(Object metadataId, List<ElementSymbol> columns, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Object pk = metadata.getPrimaryKey(metadataId); if (pk == null) { return null; } List<?> cols = metadata.getElementIDsInKey(pk); List<ElementSymbol> key = null; for (ElementSymbol es : columns) { if (cols.contains(es.getMetadataID())) { if (!metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT) && !metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { return null; } if (key == null) { key = new ArrayList<ElementSymbol>(); } key.add(es); } } return key; }
/** * <p> This method validates an elements present in the group specified in the * FROM clause of the query but not specified in its SELECT clause</p> * @param element The <code>ElementSymbol</code> being validated * @throws TeiidComponentException * @throws QueryMetadataException */ private boolean validateInsertElement(ElementSymbol element) throws QueryMetadataException, TeiidComponentException { // checking if the elements not specified in the query are required. if(metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.NULL) || metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.DEFAULT_VALUE) || metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { return true; } if (this.updateInfo.insertType == UpdateType.INHERENT) { insertReport.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0010", element, element.getGroupSymbol())); //$NON-NLS-1$ } return false; } }
/** * <p> This method validates an elements present in the group specified in the * FROM clause of the query but not specified in its SELECT clause</p> * @param element The <code>ElementSymbol</code> being validated * @throws TeiidComponentException * @throws QueryMetadataException */ private boolean validateInsertElement(ElementSymbol element) throws QueryMetadataException, TeiidComponentException { // checking if the elements not specified in the query are required. if(metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.NULL) || metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.DEFAULT_VALUE) || metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { return true; } if (this.updateInfo.insertType == UpdateType.INHERENT) { insertReport.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0010", element, element.getGroupSymbol())); //$NON-NLS-1$ } return false; } }
/** * <p> This method validates an elements present in the group specified in the * FROM clause of the query but not specified in its SELECT clause</p> * @param element The <code>ElementSymbol</code> being validated * @throws TeiidComponentException * @throws QueryMetadataException */ private boolean validateInsertElement(ElementSymbol element) throws QueryMetadataException, TeiidComponentException { // checking if the elements not specified in the query are required. if(metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.NULL) || metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.DEFAULT_VALUE) || metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { return true; } if (this.updateInfo.insertType == UpdateType.INHERENT) { insertReport.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0010", element, element.getGroupSymbol())); //$NON-NLS-1$ } return false; } }
public static List<ElementSymbol> getAutoIncrementKey(Object metadataId, List<ElementSymbol> columns, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Object pk = metadata.getPrimaryKey(metadataId); if (pk == null) { return null; } List<?> cols = metadata.getElementIDsInKey(pk); List<ElementSymbol> key = null; for (ElementSymbol es : columns) { if (cols.contains(es.getMetadataID())) { if (!metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT) && !metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { return null; } if (key == null) { key = new ArrayList<ElementSymbol>(); } key.add(es); } } return key; }
protected Collection<ElementSymbol> validateElementsSupport(Collection<ElementSymbol> elements, int supportsFlag) { // Collect any identifiers not supporting flag List<ElementSymbol> dontSupport = null; ElementSymbol symbol = null; try { Iterator<ElementSymbol> elemIter = elements.iterator(); while(elemIter.hasNext()) { symbol = elemIter.next(); if(! getMetadata().elementSupports(symbol.getMetadataID(), supportsFlag)) { if(dontSupport == null) { dontSupport = new ArrayList<ElementSymbol>(); } dontSupport.add(symbol); } } } catch(QueryMetadataException e) { handleException(e, symbol); } catch(TeiidComponentException e) { handleException(e, symbol); } return dontSupport; }
/** * Find a selectable element in the specified groups. This is a helper for fixing * the "no elements" case. * * @param groups Bunch of groups * @param metadata Metadata implementation * @throws QueryPlannerException */ static ElementSymbol selectOutputElement(Collection<GroupSymbol> groups, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { // Find a group with selectable elements and pick the first one for (GroupSymbol group : groups) { List<ElementSymbol> elements = (List<ElementSymbol>)ResolverUtil.resolveElementsInGroup(group, metadata); for (ElementSymbol element : elements) { if(metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.SELECT)) { element = element.clone(); element.setGroupSymbol(group); return element; } } } return null; }
public static Create getCreateCommand(GroupSymbol group, boolean matview, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Create create = new Create(); create.setTable(group); List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata); create.setElementSymbolsAsColumns(allColumns); if (!matview) { for (int i = 0; i < allColumns.size(); i++) { ElementSymbol es = allColumns.get(i); if (!metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { create.getColumns().get(i).setNullType(NullType.No_Nulls); if (es.getType() == DataTypeManager.DefaultDataClasses.INTEGER && metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { create.getColumns().get(i).setAutoIncremented(true); //serial } } } } Object pk = metadata.getPrimaryKey(group.getMetadataID()); if (pk != null) { List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk); create.getPrimaryKey().addAll(pkColumns); } return create; }
private boolean isNonNull(Query query, Expression rightExpr) throws TeiidComponentException, QueryMetadataException { if (rightExpr instanceof ElementSymbol) { ElementSymbol es = (ElementSymbol)rightExpr; if (metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { return false; } if (!isSimpleJoin(query)) { return false; } } else if (rightExpr instanceof Constant) { if (((Constant)rightExpr).isNull()) { return false; } } else if (rightExpr instanceof AggregateSymbol) { AggregateSymbol as = (AggregateSymbol)rightExpr; if (!as.isCount()) { return false; } } else { return false; } return true; }
/** * Find a selectable element in the specified groups. This is a helper for fixing * the "no elements" case. * * @param groups Bunch of groups * @param metadata Metadata implementation * @throws QueryPlannerException */ static ElementSymbol selectOutputElement(Collection<GroupSymbol> groups, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { // Find a group with selectable elements and pick the first one for (GroupSymbol group : groups) { List<ElementSymbol> elements = (List<ElementSymbol>)ResolverUtil.resolveElementsInGroup(group, metadata); for (ElementSymbol element : elements) { if(metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.SELECT)) { element = element.clone(); element.setGroupSymbol(group); return element; } } } return null; }
private boolean isNonNull(Query query, Expression rightExpr) throws TeiidComponentException, QueryMetadataException { if (rightExpr instanceof ElementSymbol) { ElementSymbol es = (ElementSymbol)rightExpr; if (metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { return false; } if (!isSimpleJoin(query)) { return false; } } else if (rightExpr instanceof Constant) { if (((Constant)rightExpr).isNull()) { return false; } } else if (rightExpr instanceof AggregateSymbol) { AggregateSymbol as = (AggregateSymbol)rightExpr; if (as.getAggregateFunction() != Type.COUNT) { return false; } } else { return false; } return true; }
private void checkNotNull(ElementSymbol param, Object value) throws TeiidComponentException, QueryMetadataException, QueryValidatorException { if (metadata.elementSupports(param.getMetadataID(), SupportConstants.Element.NULL)) { return; } if (metadata.isVariadic(param.getMetadataID())) { if (value instanceof ArrayImpl) { ArrayImpl av = (ArrayImpl)value; for (Object o : av.getValues()) { if (o == null) { throw new QueryValidatorException(QueryPlugin.Event.TEIID30164, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30164, param)); } } } } else if (value == null) { throw new QueryValidatorException(QueryPlugin.Event.TEIID30164, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30164, param)); } }
public static void checkNotNull(ElementSymbol param, Object value, QueryMetadataInterface metadata) throws TeiidComponentException, QueryMetadataException, QueryValidatorException { if (metadata.elementSupports(param.getMetadataID(), SupportConstants.Element.NULL)) { return; } if (metadata.isVariadic(param.getMetadataID())) { if (value instanceof ArrayImpl) { ArrayImpl av = (ArrayImpl)value; for (Object o : av.getValues()) { if (o == null) { throw new QueryValidatorException(QueryPlugin.Event.TEIID30164, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30164, param)); } } } } else if (value == null) { throw new QueryValidatorException(QueryPlugin.Event.TEIID30164, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30164, param)); } }
public static void checkNotNull(ElementSymbol param, Object value, QueryMetadataInterface metadata) throws TeiidComponentException, QueryMetadataException, QueryValidatorException { if (metadata.elementSupports(param.getMetadataID(), SupportConstants.Element.NULL)) { return; } if (metadata.isVariadic(param.getMetadataID())) { if (value instanceof ArrayImpl) { ArrayImpl av = (ArrayImpl)value; for (Object o : av.getValues()) { if (o == null) { throw new QueryValidatorException(QueryPlugin.Event.TEIID30164, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30164, param)); } } } } else if (value == null) { throw new QueryValidatorException(QueryPlugin.Event.TEIID30164, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30164, param)); } }