Package org.teiid.metadata

Examples of org.teiid.metadata.Table


    }

    public MappingNode getMappingNode(final Object groupID) throws TeiidComponentException, QueryMetadataException {
        ArgCheck.isInstanceOf(Table.class, groupID);

        Table tableRecord = (Table) groupID;
    final String groupName = tableRecord.getFullName();
        if(tableRecord.isVirtual()) {
            // get mappin transform
            String document = tableRecord.getSelectTransformation();           
            InputStream inputStream = new ByteArrayInputStream(document.getBytes());
            MappingLoader reader = new MappingLoader();
            MappingDocument mappingDoc = null;
            try{
                mappingDoc = reader.loadDocument(inputStream);
View Full Code Here


    /**
     * @see org.teiid.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
     */
    public Collection getXMLTempGroups(final Object groupID) throws TeiidComponentException, QueryMetadataException {
        ArgCheck.isInstanceOf(Table.class, groupID);
        Table tableRecord = (Table) groupID;

        if(tableRecord.getTableType() == Table.Type.Document) {
            return this.store.getXMLTempGroups(tableRecord);
        }
        return Collections.EMPTY_SET;
    }
View Full Code Here

    }

    public List<SQLXMLImpl> getXMLSchemas(final Object groupID) throws TeiidComponentException, QueryMetadataException {

        ArgCheck.isInstanceOf(Table.class, groupID);
        Table tableRecord = (Table) groupID;

        // lookup transformation record for the group
        String groupName = tableRecord.getFullName();

        // get the schema Paths
        List<String> schemaPaths = tableRecord.getSchemaPaths();
       
        List<SQLXMLImpl> schemas = new LinkedList<SQLXMLImpl>();
        if (schemaPaths == null) {
          return schemas;
        }
        File f = new File(tableRecord.getResourcePath());
        String path = f.getParent();
        if (File.separatorChar != '/') {
          path = path.replace(File.separatorChar, '/');
        }
        for (String string : schemaPaths) {
View Full Code Here

  }
 
  @Override
  public Object getPrimaryKey(Object metadataID) {
    ArgCheck.isInstanceOf(Table.class, metadataID);
    Table table = (Table)metadataID;
    return table.getPrimaryKey();
  }
View Full Code Here

    int index = fullName.indexOf(TransformationMetadata.DELIMITER_STRING);
    if (index == -1) {
        throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
    }     
    String schema = fullName.substring(0, index);
    Table result = getSchema(schema).getTables().get(fullName.substring(index + 1));
    if (result == null) {
          throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
    }
    return result;
  }
View Full Code Here

     * Create a TableRecord instance from the specified index record
     */
    public Table createTableRecord(final char[] record) {
        final String str = new String(record);
        final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
        final Table table = new Table();

        // Extract the index version information from the record
        int indexVersion = getIndexVersion(record);

        // The tokens are the standard header values
        int tokenIndex = 0;
        setRecordHeaderValues(table, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
                             tokens.get(tokenIndex++), tokens.get(tokenIndex++),
                             tokens.get(tokenIndex++), tokens.get(tokenIndex++));

        // The next token is the cardinality
        table.setCardinality( Integer.parseInt(tokens.get(tokenIndex++)) );

        // The next token is the tableType
        table.setTableType(Table.Type.values()[Integer.parseInt(tokens.get(tokenIndex++))]);

        // The next token are the supports flags
        char[] supportFlags = (tokens.get(tokenIndex++)).toCharArray();
        table.setVirtual(getBooleanValue(supportFlags[0]));
        table.setSystem(getBooleanValue(supportFlags[1]));
        table.setSupportsUpdate(getBooleanValue(supportFlags[2]));
        if(includeMaterializationFlag(indexVersion)) {
            table.setMaterialized(getBooleanValue(supportFlags[3]));
        }

        // The next token are the UUIDs for the column references (no longer stored on the record)
        tokenIndex++;

        // The next token is the UUID of the primary key
        String id = getObjectValue(tokens.get(tokenIndex++));
        if (id != null) {
          KeyRecord pk = new KeyRecord(KeyRecord.Type.Primary);
          pk.setUUID(id);
          table.setPrimaryKey(pk);
        }

        tokenIndex+=4; //skip reading uuids for associated records

        if(includeMaterializationFlag(indexVersion)) {
            // The next token are the UUIDs for the materialized table ID
          Table matTable = new Table();
          matTable.setUUID(tokens.get(tokenIndex++));
            table.setMaterializedTable(matTable);
            // The next token are the UUID for the materialized stage table ID
            matTable = new Table();
          matTable.setUUID(tokens.get(tokenIndex++));
            table.setMaterializedStageTable(matTable);
        }

    // The next tokens are footer values
    setRecordFooterValues(table, tokens, tokenIndex);      
View Full Code Here

      DQPWorkContext workContext = DQPWorkContext.getWorkContext();
     
      @Override
      public void visit(AlterView obj) {
        VDBMetaData vdb = workContext.getVDB();
        Table t = (Table)obj.getTarget().getMetadataID();
        String sql = obj.getDefinition().toString();
      if (pdm.getMetadataRepository() != null) {
        pdm.getMetadataRepository().setViewDefinition(workContext.getVdbName(), workContext.getVdbVersion(), t, sql);
      }
        alterView(vdb, t, sql);
        if (pdm.getEventDistributor() != null) {
          pdm.getEventDistributor().setViewDefinition(workContext.getVdbName(), workContext.getVdbVersion(), t.getParent().getName(), t.getName(), sql);
      }
      }
View Full Code Here

      }

      @Override
      public void visit(AlterTrigger obj) {
        VDBMetaData vdb = workContext.getVDB();
        Table t = (Table)obj.getTarget().getMetadataID();
        String sql = null;
        TriggerEvent event = obj.getEvent();
        if (obj.getEnabled() == null) {
          if (obj.isCreate()) {
              if (getPlanForEvent(t, event) != null) {
                throw new TeiidRuntimeException(new TeiidProcessingException(QueryPlugin.Util.getString("DdlPlan.event_already_exists", t.getName(), obj.getEvent()))); //$NON-NLS-1$
              }
          } else if (getPlanForEvent(t, event) == null) {
            throw new TeiidRuntimeException(new TeiidProcessingException(QueryPlugin.Util.getString("DdlPlan.event_not_exists", t.getName(), obj.getEvent()))); //$NON-NLS-1$
          }
          sql = obj.getDefinition().toString();
        } else if (getPlanForEvent(t, event) == null) {
        throw new TeiidRuntimeException(new TeiidProcessingException(QueryPlugin.Util.getString("DdlPlan.event_not_exists", t.getName(), obj.getEvent()))); //$NON-NLS-1$
        }
      if (pdm.getMetadataRepository() != null) {
        if (sql != null) {
          pdm.getMetadataRepository().setInsteadOfTriggerDefinition(workContext.getVdbName(), workContext.getVdbVersion(), t, obj.getEvent(), sql);
        } else {
          pdm.getMetadataRepository().setInsteadOfTriggerEnabled(workContext.getVdbName(), workContext.getVdbVersion(), t, obj.getEvent(), obj.getEnabled());
        }
      }
        alterInsteadOfTrigger(vdb, t, sql, obj.getEnabled(), event);
        if (pdm.getEventDistributor() != null) {
          pdm.getEventDistributor().setInsteadOfTriggerDefinition(workContext.getVdbName(), workContext.getVdbVersion(), t.getParent().getName(), t.getName(), obj.getEvent(), sql, obj.getEnabled());
      }
      }
View Full Code Here

      String sObjectName = typeElement.getFirstChild().getNodeValue();
      Object[] row = new Object[visitor.getSelectSymbolCount()];
      for (int j = 0; j < visitor.getSelectSymbolCount(); j++) {
        Column element = visitor.getSelectSymbolMetadata(j);
        AbstractMetadataRecord parent = element.getParent();
        Table table;
        if(parent instanceof Table) {
          table = (Table)parent;
        } else {
          parent = parent.getParent();
          if(parent instanceof Table) {
            table = (Table)parent;
          } else {
            throw new TranslatorException("Could not resolve Table for column " + element.getName()); //$NON-NLS-1$
          }
        }
        if(table.getNameInSource().equals(sObjectName)) {
          Integer index = visitor.getSelectSymbolIndex(sObjectName + ':' + element.getNameInSource());
          // id gets dropped from the result if it is not the
          // first field in the querystring. Add it back in.
          if (null == index) {
            if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
View Full Code Here

    private List<Object[]> extractDataFromFields(SObject sObject,
      List<Object> fields, List<Object[]> result) throws TranslatorException {
      Map<String,Integer> fieldToIndexMap = sObjectToResponseField.get(sObject.getType());
      for (int j = 0; j < visitor.getSelectSymbolCount(); j++) {
        Column element = visitor.getSelectSymbolMetadata(j);
        Table table = (Table)element.getParent();
        if(table.getNameInSource().equals(sObject.getType())) {
          Integer index = fieldToIndexMap.get(element.getNameInSource());
          // id gets dropped from the result if it is not the
          // first field in the querystring. Add it back in.
          if (null == index) {
            if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.teiid.metadata.Table

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.