Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Column


    public Map getConverters(Table table) {
        Map converters = new HashMap();

        Iterator columns = table.getColumn().iterator();
        while (columns.hasNext()) {
            Column c = (Column) columns.next();
            if (c.getConverterClassName() != null) {
                String property = c.getPropertyName();
                if (property == null) {
                    property = c.getColumnName();
                }
                converters.put(property, c.getConverterClassName());
            }
        }
        return converters;
    }
View Full Code Here


        // the PK
        if (t.getColumn().isEmpty()) {
            return true;
        }

        Column c = configWrapper.getColumn(t, getDatabaseColumnName(i));

        if (c == null) {
            return false;
        }

        if (c.isPrimaryKey()) {
            return true;
        }

        return false;
    }
View Full Code Here

        Iterator i = changedFields.iterator();
     
        int idx = 1;
        while (i.hasNext()) {
            Property property = (Property) i.next();
            Column c = tableWrapper.getColumnByPropertyName(property.getName());         
           
            if ((c == null) || !c.isCollision() || !c.isPrimaryKey()) {
                String columnName = c == null ? property.getName() : c.getColumnName();
                appendFieldSet(statement, idx > 1, columnName);
                parameters.add(createParameter(tableWrapper, property, idx++));
            }
        }
       
        Column c = tableWrapper.getManagedColumn();
        if (c != null) {
            appendFieldSet(statement, idx > 1, c.getColumnName());
            String propertyName = c.getPropertyName() == null ? c.getColumnName() : c.getPropertyName();
            parameters.add(createManagedParameter(tableWrapper,
                    changedObject.getInstanceProperty(propertyName), idx++));
        }
       
        statement.append(" where ");

        Iterator pkColumnNames = tableWrapper.getPrimaryKeyNames().iterator();
        Iterator pkPropertyNames = tableWrapper.getPrimaryKeyProperties().iterator();
        while (pkColumnNames.hasNext() && pkPropertyNames.hasNext()) {
            String columnName = (String) pkColumnNames.next();
            String propertyName = (String) pkPropertyNames.next();
            statement.append(columnName);
            statement.append(" = ?");
            if (pkColumnNames.hasNext() && pkPropertyNames.hasNext()) {
                statement.append(" and ");
            }
            parameters.add(createParameter(tableWrapper, type.getProperty(propertyName), idx++));
        }

        if (tableWrapper.getCollisionColumn() == null) {
            Iterator iter = changedFields.iterator();
            while (iter.hasNext()) {
                statement.append(" and ");
                Property changedProperty = (Property) iter.next();
                Column column = tableWrapper.getColumnByPropertyName(changedProperty.getName());
                statement.append(column == null ? changedProperty.getName() : column.getColumnName());
                                
                Object value;
                Setting setting = summary.getOldValue(changedObject, changedProperty);
                // Setting is null if this is a relationship change
                if (setting == null) {
View Full Code Here

        statement.append("(");
        Iterator attrs = attributes.iterator();
        while (attrs.hasNext()) {
            String name = (String) attrs.next();
            statement.append("");
            Column c = config.getColumnByPropertyName(t, name);
            statement.append(c == null ? name : c.getColumnName());
            if (attrs.hasNext()) {
                statement.append(", ");
            } else {
                statement.append(")");
            }
View Full Code Here

          treatAllPKs = true;//can not find table/type, need to consider all columns as PKs
        }
       
        if(columnsForTable != null){
              for(int ii=0; ii<columnsForTable.size(); ii++){
                Column curCol = (Column)columnsForTable.get(ii);
               
                if(curCol.isPrimaryKey() || curCol.getColumnName().equalsIgnoreCase("ID")){//need to compare col name
                  //with ID as that is the one from dbms metadata or resul set shape metadata
                  //but when putting in map, need to put property and if not present then column
                    Collection pks = (Collection) tableToPrimaryKeysMap.get(curTableName);
                    if(pks == null){
                      pks = new HashSet();
                    }
 
                    if(curCol.getPropertyName() != null){
                      pks.add(curCol.getPropertyName());
                    }
                    else{
                        pks.add(curCol.getColumnName());
                        curCol.setPropertyName(curCol.getColumnName());//make config consistent
                        if(!((Collection)tableToPropertyMap.get(curTableName)).contains(curCol.getColumnName())){
                          ((Collection)tableToPropertyMap.get(curTableName)).add(curCol.getColumnName());
                        }
                    }
                    tableToPrimaryKeysMap.put(curTableName, pks);                           
                }
              }           
View Full Code Here

        // the PK
        if (t.getColumn().isEmpty()) {
            return true;
        }

        Column c = configWrapper.getColumn(t, getDatabaseColumnName(i));

        if (c == null) {
            return false;
        }

        if (c.isPrimaryKey()) {
            return true;
        }

        return false;
    }
View Full Code Here

            QualifiedColumn pkColumn = null;
             pkColumn = new QualifiedColumn(columnName, this.config.isDatabaseSchemaNameSupported());
            //Table t = findOrCreateTable(pkColumn.getTableName());
            Table t = findOrCreateTable(pkColumn);
            Column c = findOrCreateColumn(t, pkColumn.getColumnName());
            c.setPrimaryKey(true);
        }
    }
View Full Code Here

        if (t == null) {
            return null;
        }
        Iterator i = t.getColumn().iterator();
        while (i.hasNext()) {
            Column c = (Column) i.next();
            if (c.getColumnName().equals(columnName)) {
                return c;
            }
        }

        if (this.logger.isDebugEnabled()) {
View Full Code Here

            return null;
        }
       
        Iterator i = t.getColumn().iterator();
        while (i.hasNext()) {
            Column c = (Column) i.next();
           
            if (c.getColumnName().equals(propertyName)) {
                return c;
            }
           
            if (c.getPropertyName() != null && c.getPropertyName().equals(propertyName)) {
                return c;
            }
        }

        if (this.logger.isDebugEnabled()) {
View Full Code Here

        return null;
    }

    public String getColumnPropertyName(String tableName, String columnName) {
        Table t = getTable(tableName);
        Column c = getColumn(t, columnName);
        if (c == null) {
            return columnName;
        }

        String propertyName = c.getPropertyName();
        if (propertyName == null) {
            return c.getColumnName();
        }

        return propertyName;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.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.