Examples of UpdateMapping


Examples of nexj.core.meta.persistence.virtual.UpdateMapping

    */
   public void execute(Work[] workArray, int nStart, int nEnd)
   {
      // All items have the same attributes to update
      VirtualMapping mapping = (VirtualMapping)m_mapping;
      UpdateMapping updateMapping = mapping.getUpdateMapping();
      Metaclass metaclass = mapping.getMetaclass();
      List updateList = updateMapping.getUpdateCases(m_attributeSet);

      // Execute updates
      Attribute lockingAttribute = mapping.getLockingAttribute();
      int nLockingOrdinal = (lockingAttribute == null) ? -1 : lockingAttribute.getOrdinal();
      String sLockingAttributeName = (lockingAttribute == null) ? null : lockingAttribute.getName();
View Full Code Here

Examples of org.teiid.query.validator.UpdateValidator.UpdateMapping

  private Insert rewriteInsert(Insert insert) throws TeiidComponentException, TeiidProcessingException{
    UpdateInfo info = insert.getUpdateInfo();
    if (info != null && info.isInherentInsert()) {
      //TODO: update error messages
      UpdateMapping mapping = info.findInsertUpdateMapping(insert, true);
      if (mapping == null) {
        throw new QueryValidatorException(QueryPlugin.Util.getString("ValidationVisitor.nonUpdatable", insert.getVariables())); //$NON-NLS-1$
      }
      Map<ElementSymbol, ElementSymbol> symbolMap = mapping.getUpdatableViewSymbols();
      List<ElementSymbol> mappedSymbols = new ArrayList<ElementSymbol>(insert.getVariables().size());
      for (ElementSymbol symbol : insert.getVariables()) {
        mappedSymbols.add(symbolMap.get(symbol));
      }
      insert.setVariables(mappedSymbols);
      insert.setGroup(mapping.getGroup().clone());
      insert.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(insert.getGroup(), metadata, Command.TYPE_INSERT));
      return rewriteInsert(insert);
    }

        if ( insert.getQueryExpression() != null ) {
View Full Code Here

Examples of org.teiid.query.validator.UpdateValidator.UpdateMapping

  private Command rewriteInherentUpdate(Update update, UpdateInfo info)
      throws QueryValidatorException, QueryMetadataException,
      TeiidComponentException, QueryResolverException,
      TeiidProcessingException {
    UpdateMapping mapping = info.findUpdateMapping(update.getChangeList().getClauseMap().keySet(), false);
    if (mapping == null) {
      throw new QueryValidatorException(QueryPlugin.Util.getString("ValidationVisitor.nonUpdatable", update.getChangeList().getClauseMap().keySet())); //$NON-NLS-1$
    }
    Map<ElementSymbol, ElementSymbol> symbolMap = mapping.getUpdatableViewSymbols();
    if (info.isSimple()) {
      update.setGroup(mapping.getGroup().clone());
      for (SetClause clause : update.getChangeList().getClauses()) {
        clause.setSymbol(symbolMap.get(clause.getSymbol()));
      }
      //TODO: properly handle correlated references
      DeepPostOrderNavigator.doVisit(update, new ExpressionMappingVisitor(symbolMap, true));
      if (info.getViewDefinition().getCriteria() != null) {
        update.setCriteria(Criteria.combineCriteria(update.getCriteria(), (Criteria)info.getViewDefinition().getCriteria().clone()));
      }
      //resolve
      update.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(update.getGroup(), metadata, Command.TYPE_UPDATE));
      return rewriteUpdate(update);
    }
    Query query = (Query)info.getViewDefinition().clone();
    query.setOrderBy(null);
    SymbolMap expressionMapping = SymbolMap.createSymbolMap(update.getGroup(), query.getProjectedSymbols(), metadata);
   
    ArrayList<SingleElementSymbol> selectSymbols = mapChangeList(update, symbolMap);
    query.setSelect(new Select(selectSymbols));
    ExpressionMappingVisitor emv = new ExpressionMappingVisitor(expressionMapping.asMap(), true);
    PostOrderNavigator.doVisit(query.getSelect(), emv);
   
    Criteria crit = update.getCriteria();
    if (crit != null) {
      PostOrderNavigator.doVisit(crit, emv);
      query.setCriteria(Criteria.combineCriteria(query.getCriteria(), crit));
    }
    GroupSymbol group = mapping.getGroup();
    String correlationName = mapping.getCorrelatedName().getName();
   
    return createUpdateProcedure(update, query, group, correlationName);
  }
View Full Code Here

Examples of org.teiid.query.validator.UpdateValidator.UpdateMapping

  }

  private Command rewriteInherentDelete(Delete delete, UpdateInfo info)
      throws QueryMetadataException, TeiidComponentException,
      QueryResolverException, TeiidProcessingException {
    UpdateMapping mapping = info.getDeleteTarget();
    if (info.isSimple()) {
      delete.setGroup(mapping.getGroup().clone());
      //TODO: properly handle correlated references
      DeepPostOrderNavigator.doVisit(delete, new ExpressionMappingVisitor(mapping.getUpdatableViewSymbols(), true));
      delete.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(delete.getGroup(), metadata, Command.TYPE_DELETE));
      if (info.getViewDefinition().getCriteria() != null) {
        delete.setCriteria(Criteria.combineCriteria(delete.getCriteria(), (Criteria)info.getViewDefinition().getCriteria().clone()));
      }
      return rewriteDelete(delete);
    }
   
    Query query = (Query)info.getViewDefinition().clone();
    query.setOrderBy(null);
    SymbolMap expressionMapping = SymbolMap.createSymbolMap(delete.getGroup(), query.getProjectedSymbols(), metadata);
   
    query.setSelect(new Select());
    ExpressionMappingVisitor emv = new ExpressionMappingVisitor(expressionMapping.asMap(), true);
   
    Criteria crit = delete.getCriteria();
    if (crit != null) {
      PostOrderNavigator.doVisit(crit, emv);
      query.setCriteria(Criteria.combineCriteria(query.getCriteria(), crit));
    }
    GroupSymbol group = mapping.getGroup();
    String correlationName = mapping.getCorrelatedName().getName();
    return createDeleteProcedure(delete, query, group, correlationName);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.