/** * Determine whether a command is a query without a criteria * @param command * @return */ static boolean hasNoCriteria(Command command) { if(command instanceof Query) { Query query = (Query) command; return query.getCriteria() == null; } if (command instanceof Delete) { Delete query = (Delete) command; return query.getCriteria() == null; } if (command instanceof Update) { Update query = (Update) command; return query.getCriteria() == null; } if (command instanceof SetQuery) { SetQuery query = (SetQuery)command; return hasNoCriteria(query.getLeftQuery()) || hasNoCriteria(query.getRightQuery()); } return false; }
/** * Determine whether a command is a query without a criteria * @param command * @return */ static boolean hasNoCriteria(Command command) { if(command instanceof Query) { Query query = (Query) command; return query.getCriteria() == null; } if (command instanceof Delete) { Delete query = (Delete) command; return query.getCriteria() == null; } if (command instanceof Update) { Update query = (Update) command; return query.getCriteria() == null; } if (command instanceof SetQuery) { SetQuery query = (SetQuery)command; return hasNoCriteria(query.getLeftQuery()) || hasNoCriteria(query.getRightQuery()); } return false; }
/** * Determine whether a command is a query without a criteria * @param command * @return */ static boolean hasNoCriteria(Command command) { if(command instanceof Query) { Query query = (Query) command; return query.getCriteria() == null; } if (command instanceof Delete) { Delete query = (Delete) command; return query.getCriteria() == null; } if (command instanceof Update) { Update query = (Update) command; return query.getCriteria() == null; } if (command instanceof SetQuery) { SetQuery query = (SetQuery)command; return hasNoCriteria(query.getLeftQuery()) || hasNoCriteria(query.getRightQuery()); } return false; }
public void testHasNoCriteria1() { assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(new Insert())); //$NON-NLS-1$ }
public void testHasNoCriteria3() { assertEquals("Got incorrect answer checking for no criteria", true, RuleValidateWhereAll.hasNoCriteria(new Query())); //$NON-NLS-1$ }
/** * Verifies that a model with "supports where all" is being passed an atomic * query with a criteria. * @throws QueryPlannerException if property is not satisfied */ public PlanNode execute( PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryPlannerException, QueryMetadataException, TeiidComponentException { for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.ACCESS)) { Object modelID = RuleRaiseAccess.getModelIDFromAccess(node, metadata); if(CapabilitiesUtil.requiresCriteria(modelID, metadata, capFinder) && hasNoCriteria((Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST))) { String modelName = metadata.getFullName(modelID); throw new QueryPlannerException(QueryPlugin.Event.TEIID30268, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30268, modelName)); } } return plan; }
/** * Verifies that a model with "supports where all" is being passed an atomic * query with a criteria. * @throws QueryPlannerException if property is not satisfied */ public PlanNode execute( PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryPlannerException, QueryMetadataException, TeiidComponentException { for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.ACCESS)) { Object modelID = RuleRaiseAccess.getModelIDFromAccess(node, metadata); if(CapabilitiesUtil.requiresCriteria(modelID, metadata, capFinder) && hasNoCriteria((Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST))) { String modelName = metadata.getFullName(modelID); throw new QueryPlannerException(QueryPlugin.Event.TEIID30268, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30268, modelName)); } } return plan; }
/** * Verifies that a model with "supports where all" is being passed an atomic * query with a criteria. * @throws QueryPlannerException if property is not satisfied */ public PlanNode execute( PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryPlannerException, QueryMetadataException, TeiidComponentException { for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.ACCESS)) { Object modelID = RuleRaiseAccess.getModelIDFromAccess(node, metadata); if(CapabilitiesUtil.requiresCriteria(modelID, metadata, capFinder) && hasNoCriteria((Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST))) { String modelName = metadata.getFullName(modelID); throw new QueryPlannerException(QueryPlugin.Event.TEIID30268, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30268, modelName)); } } return plan; }
public void testHasNoCriteria2() { Query query = new Query(); CompareCriteria crit = new CompareCriteria(new Constant("a"), CompareCriteria.EQ, new Constant("b")); //$NON-NLS-1$ //$NON-NLS-2$ query.setCriteria(crit); assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(query)); //$NON-NLS-1$ }