Package org.apache.metamodel.schema

Examples of org.apache.metamodel.schema.Column


public class ConvertedDataSetInterceptorTest extends TestCase {

  public void testConvertedQuery() throws Exception {
    UpdateableDataContext dc = new MockUpdateableDataContext();
    Column fooColumn = dc.getColumnByQualifiedLabel("schema.table.foo");
    assertNotNull(fooColumn);

    dc = Converters.addTypeConverter(dc, fooColumn,
        new StringToIntegerConverter());
View Full Code Here


    ds.close();
  }

  public void testNonConvertedQuery() throws Exception {
    MockUpdateableDataContext source = new MockUpdateableDataContext();
    Column fooColumn = source.getColumnByQualifiedLabel("schema.table.foo");
    assertNotNull(fooColumn);

    Map<Column, TypeConverter<?, ?>> converters = new HashMap<Column, TypeConverter<?, ?>>();
    converters.put(fooColumn, new StringToIntegerConverter());
    DataContext converted = Converters.addTypeConverter(source, fooColumn,
View Full Code Here

public class ConvertedRowInsertionInterceptorTest extends TestCase {

  public void testConvertedInsert() throws Exception {
    MockUpdateableDataContext source = new MockUpdateableDataContext();
    Column fooColumn = source.getColumnByQualifiedLabel("schema.table.foo");
    assertNotNull(fooColumn);

    UpdateableDataContext intercepted = Converters.addTypeConverter(source,
        fooColumn, new StringToIntegerConverter());
View Full Code Here

            final String value = SugarCrmXmlHelper.getChildElementText(nameValueItem, "value");
            valueMap.put(name, value);
        }

        for (int i = 0; i < values.length; i++) {
            final Column column = header.getSelectItem(i).getColumn();
            final String fieldName = column.getName();
            final String value = valueMap.get(fieldName);
            final Object parsedValue = convert(value, column.getType());
            values[i] = parsedValue;
        }

        return new DefaultRow(header, values);
    }
View Full Code Here

    private Row update(final Row original) {
        SelectItem[] items = original.getSelectItems();
        Object[] values = new Object[items.length];
        for (int i = 0; i < items.length; i++) {
            final Object value;
            Column column = items[i].getColumn();
            if (isSet(column)) {
                // use update statement's value
                value = getValues()[i];
            } else {
                // use original value
View Full Code Here

      ds.close();
    }

    // do a join
    {
      Column fk = employeeTable
          .getColumnByName("index(/root/organization)");
      assertNotNull(fk);
      Column empName = employeeTable.getColumnByName("/name");
      assertNotNull(empName);
      Column orgId = organizationTable.getColumnByName("row_id");
      assertNotNull(orgId);
      Column orgName = organizationTable.getColumnByName("/name");
      assertNotNull(orgName);

      Query q = dc.query().from(employeeTable)
          .innerJoin(organizationTable).on(fk, orgId).select(empName)
          .as("employee").select(orgName).as("company").toQuery();
View Full Code Here

    private void loadRelations(ResultSet rs, Schema schema) throws SQLException {
        while (rs.next()) {
            String pkTableName = rs.getString(3);
            String pkColumnName = rs.getString(4);

            Column pkColumn = null;
            Table pkTable = schema.getTableByName(pkTableName);
            if (pkTable != null) {
                pkColumn = pkTable.getColumnByName(pkColumnName);
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Found primary key relation: tableName=" + pkTableName + ",columnName=" + pkColumnName
                        + ", matching column: " + pkColumn);
            }

            String fkTableName = rs.getString(7);
            String fkColumnName = rs.getString(8);
            Column fkColumn = null;
            Table fkTable = schema.getTableByName(fkTableName);
            if (fkTable != null) {
                fkColumn = fkTable.getColumnByName(fkColumnName);
            }
            if (logger.isDebugEnabled()) {
View Full Code Here

        if (tokens != null) {
            final Schema schema = getSchemaByToken(tokens[0]);
            if (schema != null) {
                final Table table = schema.getTableByName(tokens[1]);
                if (table != null) {
                    final Column column = table.getColumnByName(tokens[2]);
                    if (column != null) {
                        return column;
                    }
                }
            }
        }

        Schema schema = null;
        final String[] schemaNames = getSchemaNames();
        for (final String schemaName : schemaNames) {
            if (schemaName == null) {
                // search without schema name (some databases have only a single
                // schema with no name)
                schema = getSchemaByName(null);
                if (schema != null) {
                    Column column = getColumn(schema, columnName);
                    if (column != null) {
                        return column;
                    }
                }
            } else {
                // Search case-sensitive
                Column col = searchColumn(schemaName, columnName, columnName);
                if (col != null) {
                    return col;
                }
            }
        }

        final String columnNameInLowerCase = columnName.toLowerCase();
        for (final String schemaName : schemaNames) {
            if (schemaName != null) {
                // search case-insensitive
                String schameNameInLowerCase = schemaName.toLowerCase();
                Column col = searchColumn(schameNameInLowerCase, columnName, columnNameInLowerCase);
                if (col != null) {
                    return col;
                }
            }
        }

        schema = getDefaultSchema();
        if (schema != null) {
            Column column = getColumn(schema, columnName);
            if (column != null) {
                return column;
            }
        }
View Full Code Here

                        + "shipping_address_street_2, shipping_address_street_3, shipping_address_street_4, shipping_address_city, "
                        + "shipping_address_state, shipping_address_postalcode, shipping_address_country, email1, parent_id, sic_code, parent_name, "
                        + "email_opt_out, invalid_email, email, campaign_id, campaign_name]",
                Arrays.toString(columnNames));

        Column nameColumn = table.getColumnByName("name");
        String nativeType = nameColumn.getNativeType();
        String remarks = nameColumn.getRemarks();
        ColumnType type = nameColumn.getType();
        assertEquals("name|Name:|VARCHAR", nativeType + "|" + remarks + "|" + type);

        Column[] columns = table.getColumns();
        for (Column column : columns) {
            type = column.getType();
View Full Code Here

                String tableAndColumnPath = columnNameOriginal.substring(schemaNameSearch.length());

                if (tableAndColumnPath.charAt(0) == '.') {
                    tableAndColumnPath = tableAndColumnPath.substring(1);

                    Column column = getColumn(schema, tableAndColumnPath);
                    if (column != null) {
                        return column;
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.metamodel.schema.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.