Package org.teiid.metadata

Examples of org.teiid.metadata.Column


    addColumn("prorettype", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$

    // Number of input arguments
    addColumn("pronargs", DataTypeManager.DefaultDataTypes.SHORT, t); //$NON-NLS-1$
   
    Column c = addColumn("proargtypes", DataTypeManager.DefaultDataTypes.OBJECT, t); //$NON-NLS-1$
    c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_OIDVECTOR)); //$NON-NLS-1$
   
    c = addColumn("proargnames", DataTypeManager.DefaultDataTypes.OBJECT, t); //$NON-NLS-1$
    c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_TEXTARRAY)); //$NON-NLS-1$
   
    c = addColumn("proargmodes", DataTypeManager.DefaultDataTypes.OBJECT, t); //$NON-NLS-1$
    c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_CHARARRAY)); //$NON-NLS-1$
   
    c = addColumn("proallargtypes", DataTypeManager.DefaultDataTypes.OBJECT, t); //$NON-NLS-1$
    c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_OIDARRAY)); //$NON-NLS-1$
   
    // The OID of the namespace that contains this function
    addColumn("pronamespace", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$
   
    addPrimaryKey("pk_pg_proc", Arrays.asList("oid"), t); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here


        Iterator iter = select.iterator();
        for(int i=0; iter.hasNext(); i++) {
            DerivedColumn symbol = (DerivedColumn) iter.next();
            Expression expr = symbol.getExpression();
            if(expr instanceof ColumnReference) {
                Column element = ((ColumnReference)expr).getMetadataObject();
                cols[i] = element.getPosition();
            } else {
                throw new TranslatorException(YahooPlugin.Util.getString("YahooExecution.Invalid_select_symbol", expr)); //$NON-NLS-1$
            }
        }
       
View Full Code Here

        capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$

        TransformationMetadata metadata = FakeMetadataFactory.exampleBQT();
        FakeMetadataFactory.setCardinality("bqt1.smalla", 1000, metadata); //$NON-NLS-1$
        FakeMetadataFactory.setCardinality("bqt2.smalla", 10000, metadata); //$NON-NLS-1$
        Column fmo = (Column)metadata.getElementID("bqt1.smalla.intnum");
    fmo.setDistinctValues(1000);
        Column floatnum = (Column)metadata.getElementID("bqt1.smalla.floatnum");
        floatnum.setDistinctValues(800);

        ProcessorPlan plan = TestOptimizer.helpPlan(
            "SELECT max(a.stringkey) from bqt1.smalla a, bqt2.smalla a2, bqt1.smalla a1 where a.intnum = a2.intnum and a1.stringnum = a2.stringnum and a.floatnum = a1.floatnum"//$NON-NLS-1$
            metadata,
            null, capFinder,
View Full Code Here

        Expression expr = iter.next();
        if (expr instanceof ColumnReference) {
          boolean dotAll = false;
          boolean useSelector = false;
          ColumnReference cr = (ColumnReference)expr;
          Column c = cr.getMetadataObject();
          if (c != null) {
            if ("\"mode:properties\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
              dotAll = true;
              useSelector = true;
            } else if ("\"jcr:path\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
              useSelector = true;
            }
          }
          if (useSelector) {
            NamedTable nt = ((ColumnReference)expr).getTable();
View Full Code Here

        // Set name in source on each column
        String[] accountNameInSource = new String[] {
           "id", "AccountName", "Stuff", "Industry"             //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
        };
        for(int i=0; i<2; i++) {
            Column obj = acctCols.get(i);
            obj.setNameInSource(accountNameInSource[i]);
        }
       
        // Create Contact group
        Table contactTable = RealMetadataFactory.createPhysicalGroup("Contacts", salesforceModel); //$NON-NLS-1$
        contactTable.setNameInSource("Contact"); //$NON-NLS-1$
        contactTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
        // Create Contact Columns
        String[] elemNames = new String[] {
            "ContactID", "Name", "AccountId", "InitialContact"  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        };
        String[] elemTypes = new String[] { 
            DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.TIMESTAMP
        };
       
        List<Column> contactCols = RealMetadataFactory.createElements(contactTable, elemNames, elemTypes);
        // Set name in source on each column
        String[] contactNameInSource = new String[] {
           "id", "ContactName", "accountid", "InitialContact"  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        };
        for(int i=0; i<2; i++) {
            Column obj = contactCols.get(i);
            obj.setNameInSource(contactNameInSource[i]);
        }

       
        List<ProcedureParameter> params = new LinkedList<ProcedureParameter>();
        params.add(RealMetadataFactory.createParameter("type", SPParameter.IN, TypeFacility.RUNTIME_NAMES.STRING));
View Full Code Here

      columnNames.add(pk.getName());
     
     
      Table child = tableMap.get(NameUtil.normalizeName(relationship.getChildTable()));
     
      Column col = null;
      columns = child.getColumns();
      for (Iterator colIter = columns.iterator(); colIter.hasNext();) {
        Column column = (Column) colIter.next();
        if(column.getName().equals(relationship.getForeignKeyField())) {
          col = column;
        }
      }
      if (null == col) throw new RuntimeException(
                    "ERROR !!foreign key column not found!! " + child.getName() + relationship.getForeignKeyField()); //$NON-NLS-1$
View Full Code Here

      FieldType fieldType = field.getType();
      if(!this.connectorEnv.isModelAuditFields() && isAuditField(field.getName())) {
        continue;
      }
      String sfTypeName = fieldType.value();
      Column column = null;
      if(sfTypeName.equals(FieldType.STRING) || //string
          sfTypeName.equals(FieldType.COMBOBOX) || //"combobox"
          sfTypeName.equals(FieldType.REFERENCE) || //"reference"
          sfTypeName.equals(FieldType.PHONE) || //"phone"
          sfTypeName.equals(FieldType.ID) || //"id"
          sfTypeName.equals(FieldType.URL) || //"url"
          sfTypeName.equals(FieldType.EMAIL) || //"email"
          sfTypeName.equals(FieldType.ENCRYPTEDSTRING) || //"encryptedstring"
          sfTypeName.equals(FieldType.ANY_TYPE)) {  //"anytype"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
        column.setNativeType(sfTypeName);
        if(sfTypeName.equals(FieldType.ID)) {
          column.setNullType(NullType.No_Nulls);
          ArrayList<String> columnNames = new ArrayList<String>();
          columnNames.add(field.getName());
          metadataFactory.addPrimaryKey(field.getName()+"_PK", columnNames, table);
        }
      }
      else if(sfTypeName.equals(FieldType.PICKLIST)) { // "picklist"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
        if(field.isRestrictedPicklist()) {
          column.setNativeType("restrictedpicklist");
        } else {
          column.setNativeType(sfTypeName);
        }
       
        column.setProperty(COLUMN_PICKLIST_VALUES, getPicklistValues(field));
      }
      else if(sfTypeName.equals(FieldType.MULTIPICKLIST)) { //"multipicklist"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
        if(field.isRestrictedPicklist()) {
          column.setNativeType("restrictedmultiselectpicklist");
        } else {
          column.setNativeType(sfTypeName);
        }
        column.setProperty(COLUMN_PICKLIST_VALUES, getPicklistValues(field));
      }
      else if(sfTypeName.equals(FieldType.BASE_64)) { //"base64"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.BLOB, table);
        column.setNativeType(sfTypeName);
      }
      else if(sfTypeName.equals(FieldType.BOOLEAN)) { //"boolean"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.BOOLEAN, table);
        column.setNativeType(sfTypeName);
      }
      else if(sfTypeName.equals(FieldType.CURRENCY)) { //"currency"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DOUBLE, table);
        column.setNativeType(sfTypeName);
        column.setCurrency(true);
        column.setScale(field.getScale());
        column.setPrecision(field.getPrecision());
      }
      else if(sfTypeName.equals(FieldType.TEXTAREA)) { //"textarea"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
        column.setNativeType(sfTypeName);
        column.setSearchType(SearchType.Unsearchable);
      }
      else if(sfTypeName.equals(FieldType.INT)) { //"int"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.INTEGER, table);
        column.setNativeType(sfTypeName);
        column.setPrecision(field.getPrecision());
      }
      else if(sfTypeName.equals(FieldType.DOUBLE) || //"double"
          sfTypeName.equals(FieldType.PERCENT)) { //"percent"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DOUBLE, table);
        column.setNativeType(sfTypeName);
        column.setScale(field.getScale());
        column.setPrecision(field.getPrecision());
      }
      else if(sfTypeName.equals(FieldType.DATE)) { //"date"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DATE, table);
        column.setNativeType(sfTypeName);
      }
      else if(sfTypeName.equals(FieldType.DATETIME)) { //"datetime"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.TIMESTAMP, table);
        column.setNativeType(sfTypeName);
      }
      else if(sfTypeName.equals(FieldType.TIME)) { //"time"
        column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.TIME, table);
        column.setNativeType(sfTypeName);
      }
      if(null == column) {
        LogManager.logError(LogConstants.CTX_CONNECTOR, "Unknown type returned by SalesForce: " + sfTypeName);
        continue;
      } else {
        column.setNameInSource(field.getName());
        column.setLength(field.getLength());
        if(field.isUpdateable()) {
          column.setUpdatable(true);
          hasUpdateableColumn  = true;
        }
        column.setProperty(COLUMN_CALCULATED, String.valueOf(field.isCalculated()));
        column.setProperty(COLUMN_CUSTOM, String.valueOf(field.isCustom()));
        column.setProperty(COLUMN_DEFAULTED, String.valueOf(field.isDefaultedOnCreate()));
      }
     
    }   
  }
View Full Code Here

        }
        BaseColumn record = null;
        int precision = columns.getInt(8);
        String runtimeType = getRuntimeType(sqlType, typeName, precision);
        if (columnType == DatabaseMetaData.procedureColumnResult) {
          Column column = metadataFactory.addProcedureResultSetColumn(columnName, runtimeType, procedure);
          record = column;
          column.setNativeType(typeName);
        } else {
          record = metadataFactory.addProcedureParameter(columnName, runtimeType, Type.values()[columnType], procedure);
        }
        record.setPrecision(columns.getInt(8));
        record.setLength(columns.getInt(9));
View Full Code Here

      int type = columns.getInt(5);
      String typeName = columns.getString(6);
      int columnSize = columns.getInt(7);
      String runtimeType = getRuntimeType(type, typeName, columnSize);
      //note that the resultset is already ordered by position, so we can rely on just adding columns in order
      Column column = metadataFactory.addColumn(columnName, runtimeType, tableInfo.table);
      column.setNameInSource(quoteName(columnName));
      column.setPrecision(columnSize);
      column.setLength(columnSize);
      column.setNativeType(typeName);
      column.setRadix(columns.getInt(10));
      column.setNullType(NullType.values()[columns.getShort(11)]);
      column.setUpdatable(true);
      String remarks = columns.getString(12);
      column.setAnnotation(remarks);
      String defaultValue = columns.getString(13);
      column.setDefaultValue(defaultValue);
      if (defaultValue != null && type == Types.BIT && TypeFacility.RUNTIME_NAMES.BOOLEAN.equals(runtimeType)) {
        //try to determine a usable boolean value
                if(defaultValue.length() == 1) {
                    int charIntVal = defaultValue.charAt(0);
                    // Set boolean FALse for incoming 0, TRUE for 1
                    if(charIntVal==0) {
                        column.setDefaultValue(Boolean.FALSE.toString());
                    } else if(charIntVal==1) {
                        column.setDefaultValue(Boolean.TRUE.toString());
                    }
        } else { //SQLServer quotes bit values
                    String trimedDefault = defaultValue.trim();
                    if (defaultValue.startsWith("(") && defaultValue.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$
                        trimedDefault = defaultValue.substring(1, defaultValue.length() - 1);
                    }
                    column.setDefaultValue(trimedDefault);
                }
      }
      column.setCharOctetLength(columns.getInt(16));
      if (rsColumns >= 23) {
        column.setAutoIncremented("YES".equalsIgnoreCase(columns.getString(23))); //$NON-NLS-1$
      }
    }
    columns.close();
  }
View Full Code Here

        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 10000000);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts '2003-11-01 12:05:02.01'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
    @Test public void testTimestampToString1() throws Exception {
      Column column = new Column();
      column.setNativeType("DATE");
      column.setNameInSource("dt");
        helpTest(LANG_FACTORY.createColumnReference("dt", LANG_FACTORY.createNamedTable("x", null, null), column, Timestamp.class), "string", "to_char(x.dt, 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

TOP

Related Classes of org.teiid.metadata.Column

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.