Package org.teiid.language

Examples of org.teiid.language.ExpressionValueSource


            List values = insert.getValues();
            List<org.teiid.language.Expression> translatedValues = new ArrayList<org.teiid.language.Expression>();
            for (Iterator i = values.iterator(); i.hasNext();) {
                translatedValues.add(translate((Expression)i.next()));
            }
            valueSource = new ExpressionValueSource(translatedValues);
        }
       
        return new org.teiid.language.Insert(translate(insert.getGroup()),
                              translatedElements,
                              valueSource);
View Full Code Here


         * then pull the Sequence name out of the name in source of the column.
         */
      if (!(insert.getValueSource() instanceof ExpressionValueSource)) {
        return;
      }
      ExpressionValueSource values = (ExpressionValueSource)insert.getValueSource();
      List<Column> allElements = insert.getTable().getMetadataObject().getColumns();
      if (allElements.size() == values.getValues().size()) {
        return;
      }
     
      int index = 0;
      List<ColumnReference> elements = insert.getColumns();
     
      for (Column element : allElements) {
        if (!element.isAutoIncremented()) {
          continue;
        }
        String name = element.getNameInSource();
        int seqIndex = name.indexOf(SEQUENCE);
        if (seqIndex == -1) {
          continue;
        }
        boolean found = false;
        while (index < elements.size()) {
          if (element.equals(elements.get(index).getMetadataObject())) {
            found = true;
            break;
          }
          index++;
        }
        if (found) {
          continue;
        }
       
            String sequence = name.substring(seqIndex + SEQUENCE.length());
           
            int delimiterIndex = sequence.indexOf(Tokens.DOT);
            if (delimiterIndex == -1) {
              throw new TranslatorException("Invalid name in source sequence format.  Expected <element name>" + SEQUENCE + "<sequence name>.<sequence value>, but was " + name); //$NON-NLS-1$ //$NON-NLS-2$
            }
            String sequenceGroupName = sequence.substring(0, delimiterIndex);
            String sequenceElementName = sequence.substring(delimiterIndex + 1);
               
            NamedTable sequenceGroup = this.getLanguageFactory().createNamedTable(sequenceGroupName, null, null);
            ColumnReference sequenceElement = this.getLanguageFactory().createColumnReference(sequenceElementName, sequenceGroup, null, element.getJavaType());
            insert.getColumns().add(index, this.getLanguageFactory().createColumnReference(element.getName(), insert.getTable(), element, element.getJavaType()));
            values.getValues().add(index, sequenceElement);
    }
    }
View Full Code Here

TOP

Related Classes of org.teiid.language.ExpressionValueSource

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.