Package com.scooterframework.orm.sqldataexpress.object

Examples of com.scooterframework.orm.sqldataexpress.object.RowInfo


     *
     * @param tableData a TableData object
     * @return RowInfo attribute of the record.
     */
    public static RowInfo rowInfoOf(TableData tableData) {
        return (tableData != null)?tableData.getHeader():(new RowInfo());
    }
View Full Code Here


     *
     * @param tableInfo a TableInfo object
     * @return RowInfo attribute of the record.
     */
    public static RowInfo rowInfoOf(TableInfo tableInfo) {
        return (tableInfo != null)?tableInfo.getHeader():(new RowInfo());
    }
View Full Code Here

        setViewData("database", database);
        String table = getTable();
        setViewData("table", table);
       
        String connName = database;
        RowInfo ri = Record.getRowInfo(connName, table);
        RowData rd = new RowData(ri, null);
        setViewData("record", rd);
       
        return null;
    }
View Full Code Here

      return allowedColumns;
    }
                   
    // add those column names in the outputs to a new string array.
    protected RowInfo getFilteredHeaderInfo(Set<String> allowedColumns, Cursor cursor) {
        RowInfo header = new RowInfo();
        int columnWidth = cursor.getDimension();
        List<ColumnInfo> allowedColumnInfos = new ArrayList<ColumnInfo>();
       
        for (int i = 0; i < columnWidth; i++) {
            ColumnInfo ci = cursor.getColumnInfo(i);
            if (allowedColumns.contains(ci.getColumnName())) {
              allowedColumnInfos.add(ci);
            }
        }
       
        header.setColumnInfoList(allowedColumnInfos);
        return header;
    }
View Full Code Here

        Cursor cursor = jstat.getCursor(stName, rs);
        int cursorWidth = cursor.getDimension();
       
        Set<String> allowedColumns = getAllowedColumns(outputs, cursor);
        TableData rt = new TableData();
        RowInfo newHeader = getFilteredHeaderInfo(allowedColumns, cursor);
        rt.setHeader(newHeader);
        returnTO.addTableData(stName, rt);
       
        while(rs.next()) {
            ArrayList<Object> cellValues = new ArrayList<Object>();
View Full Code Here

        return results;
    }

    //Creates a new RowData based on a retrieved row for an entity.
    private RowData constructRowData(RowData retrievedRow, String tableMappingName, ActiveRecord entityHome) {
        RowInfo ri = entityHome.getRowInfo();
        boolean hasPrimaryKey = ri.hasPrimaryKey();
        boolean hasOnlyNullData = true;
        String[] columnNames = ri.getColumnNames();
        int dimension = columnNames.length;
        Object[] colData = new Object[dimension];
        for (int i=0; i<dimension; i++) {
            String columnName = columnNames[i];
            colData[i] = retrievedRow.getField(tableMappingName + "_" + columnName);
            if (hasPrimaryKey) {
                if ((colData[i] == null) && ri.isPrimaryKeyColumn(columnName)) {
                    return null;
                }
            }

            if (colData[i] != null) {
View Full Code Here

        String mapping = "";
       
        // In belongs-to relation, class A holds FK and is also the owner.
        if (Relation.BELONGS_TO_TYPE.equalsIgnoreCase(type)) {
            ActiveRecord targetHome = (ActiveRecord)ActiveRecordUtil.getHomeInstance(b);
            RowInfo ri = targetHome.getRowInfo();
            if ( ri == null) {
                throw new RelationException("The RowInfo for class " + b.getName() + " cannot be null.");
            }
           
            String[] pkNames = ri.getPrimaryKeyColumnNames();
            if (StringUtil.isStringInArray("ID", pkNames, true)) {
                String fk = target + "_id";
                verifyExistenceOfColumn(a, fk);
                mapping = fk + "=id";
            }
            else {
                int size = pkNames.length;
                for (int i=0; i<size-1; i++) {
                    String fk = pkNames[i];
                    verifyExistenceOfColumn(a, fk);
                    mapping += fk + "=" + fk + ",";
                }
                String fk = pkNames[size-1];
                verifyExistenceOfColumn(a, fk);
                mapping += fk + "=" + fk;
            }
        }
        else
        // In has-one and has-many relation, class B holds FK.
        if (Relation.HAS_ONE_TYPE.equalsIgnoreCase(type) ||
            Relation.HAS_MANY_TYPE.equalsIgnoreCase(type)) {
            ActiveRecord ownerHome = (ActiveRecord)ActiveRecordUtil.getHomeInstance(a);
            RowInfo ri = ownerHome.getRowInfo();
            if ( ri == null) {
                throw new RelationException("The RowInfo for class " + a.getName() + " cannot be null.");
            }
           
            String[] pkNames = ri.getPrimaryKeyColumnNames();
            if (StringUtil.isStringInArray("ID", pkNames, true)) {
                String fk = ActiveRecordUtil.getModelName(a) + "_id";
                verifyExistenceOfColumn(b, fk);
                mapping = "id=" + fk;
            }
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.sqldataexpress.object.RowInfo

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.