Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.GroupContext


    static void prepareQuery(MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv, QueryCommand rsQuery)
        throws TeiidComponentException, QueryResolverException {
       
        Collection externalGroups = getExternalGroups(sourceNode);
       
        rsQuery.setExternalGroupContexts(new GroupContext(null, externalGroups));
       
    QueryResolver.resolveCommand(rsQuery, planEnv.getGlobalMetadata());
    }
View Full Code Here


        findCommandMetadata(command, metadata.getMetadataStore(), metadata);
       
        //Resolve expressions on input parameters
        StoredProcedure storedProcedureCommand = (StoredProcedure) command;
        GroupContext externalGroups = storedProcedureCommand.getExternalGroupContexts();
        for (SPParameter param : storedProcedureCommand.getParameters()) {
            Expression expr = param.getExpression();
            if(expr == null) {
              continue;
            }
View Full Code Here

      GroupSymbol container, int type, QueryMetadataInterface metadata)
      throws QueryMetadataException, TeiidComponentException {
    //find the childMetadata using a clean metadata store
      TempMetadataStore childMetadata = new TempMetadataStore();
      TempMetadataAdapter tma = new TempMetadataAdapter(metadata, childMetadata);
      GroupContext externalGroups = new GroupContext();

    if (currentCommand instanceof TriggerAction) {
      TriggerAction ta = (TriggerAction)currentCommand;
      ta.setView(container);
        //TODO: it seems easier to just inline the handling here rather than have each of the resolvers check for trigger actions
View Full Code Here

      String groupContext, String shortCanonicalName, String expectedGroupContext)
      throws TeiidComponentException, QueryResolverException {
    boolean isExternal = false;
        boolean groupMatched = false;
       
        GroupContext root = null;
       
        if (groups != null || externalContext != null) {
            if (groups != null) {
                root = new GroupContext(externalContext, groups);
            }
            if (root == null) {
                isExternal = true;
                root = externalContext;
            }
        } else {
            try {
                LinkedList<GroupSymbol> matchedGroups = new LinkedList<GroupSymbol>();
               
                if (groupContext != null) {
                    //assume that this is fully qualified
                    Object groupID = this.metadata.getGroupID(groupContext);
                    // No groups specified, so any group is valid
                    GroupSymbol groupSymbol = new GroupSymbol(groupContext);
                    groupSymbol.setMetadataID(groupID);
                    matchedGroups.add(groupSymbol);
                }
               
                root = new GroupContext(null, matchedGroups);
            } catch(QueryMetadataException e) {
                // ignore
            }
        }
       
        LinkedList<ElementMatch> matches = new LinkedList<ElementMatch>();
        while (root != null) {
            Collection<GroupSymbol> matchedGroups = ResolverUtil.findMatchingGroups(groupContext, root.getGroups(), metadata);
            if (matchedGroups != null && !matchedGroups.isEmpty()) {
                groupMatched = true;
                   
                resolveAgainstGroups(shortCanonicalName, matchedGroups, matches);
               
                if (matches.size() > 1) {
                  if (isExternal && matches.size() == 2) {
                  if ((isScalar(matches.get(0).element, ProcedureReservedWords.INPUTS) && isScalar(matches.get(1).element, ProcedureReservedWords.INPUT))) {
                    matches.removeLast();
                    break;
                  } else if (isScalar(matches.get(1).element, ProcedureReservedWords.INPUTS) && isScalar(matches.get(0).element, ProcedureReservedWords.INPUT)) {
                    matches.removeFirst();
                    break;
                  }
                  }
                  throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.getString("ERR.015.008.0053", elementSymbol)); //$NON-NLS-1$
                }
               
                if (matches.size() == 1) {
                    break;
                }
            }
           
            root = root.getParent();
            isExternal = true;
        }
       
        if (matches.isEmpty()) {
            if (groupMatched) {
View Full Code Here

          };
          DeepPostOrderNavigator.doVisit(currentCommand, emv);
        } else {
            TempMetadataStore rootExternalStore = new TempMetadataStore();
           
            GroupContext externalGroups = new GroupContext();
           
            ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.INPUT, rootExternalStore, externalGroups, elements);
            ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.INPUTS, rootExternalStore, externalGroups, elements);
            QueryResolver.setChildMetadata(currentCommand, rootExternalStore.getData(), externalGroups);
        }
View Full Code Here

        ResolverVisitor.resolveLanguageObject(criteria, metadata);
    }

    public static void setChildMetadata(Command subCommand, Command parent) {
        Map childMetadataMap = parent.getTemporaryMetadata();
        GroupContext parentContext = parent.getExternalGroupContexts();
       
        setChildMetadata(subCommand, childMetadataMap, parentContext);
    }
View Full Code Here

      }

        CreateUpdateProcedureCommand procCommand = (CreateUpdateProcedureCommand) command;

        //by creating a new group context here it means that variables will resolve with a higher precedence than input/changing
        GroupContext externalGroups = command.getExternalGroupContexts();
       
        List<ElementSymbol> symbols = new LinkedList<ElementSymbol>();
       
        // virtual group elements in HAS and TRANSLATE criteria have to be resolved
        if(procCommand.isUpdateProcedure()){
View Full Code Here

        LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving block", block}); //$NON-NLS-1$
       
        //create a new variable and metadata context for this block so that discovered metadata is not visible else where
        TempMetadataStore store = new TempMetadataStore(new HashMap(metadata.getMetadataStore().getData()));
        metadata = new TempMetadataAdapter(metadata.getMetadata(), store);
        externalGroups = new GroupContext(externalGroups, null);
       
        //create a new variables group for this block
        GroupSymbol variables = ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.VARIABLES, store, externalGroups, new LinkedList<SingleElementSymbol>());
       
        for (Statement statement : block.getStatements()) {
View Full Code Here

                List<SingleElementSymbol> symbols = cmd.getProjectedSymbols();
               
                //add the loop cursor group into its own context
                TempMetadataStore store = new TempMetadataStore(new HashMap(metadata.getMetadataStore().getData()));
                metadata = new TempMetadataAdapter(metadata.getMetadata(), store);
                externalGroups = new GroupContext(externalGroups, null);
               
                ProcedureContainerResolver.addScalarGroup(groupName, store, externalGroups, symbols, false);
               
                resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata);
                break;
View Full Code Here

    // get the group on this query
    Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(query, true);
    GroupSymbol group = groups.iterator().next();

    //external groups
        GroupContext externalGroups = query.getExternalGroupContexts();

    // valid elements for select
    List<ElementSymbol> validSelectElems = getElementsInDocument(group, metadata);
    resolveXMLSelect(query, group, validSelectElems, metadata);
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.GroupContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.