Package org.apache.turbine.torque.engine.database.model

Examples of org.apache.turbine.torque.engine.database.model.Column


        if (!token.getStr().toUpperCase().equals("("))
            err ("( expected");
        next();

        String colName = token.getStr();
        Column c = tbl.getColumn(colName);
        if (c == null) err ("Invalid column name: "+colName);
        c.setPrimaryKey(true);
        next();
        while (token.getStr().equals(","))
        {
            next();
            colName = token.getStr();
            c = tbl.getColumn(colName);
            if (c == null) err ("Invalid column name: "+colName);
            c.setPrimaryKey(true);
            next();
        }

        if (!token.getStr().toUpperCase().equals(")"))
            err (") expected");
View Full Code Here


        while (!token.getStr().equals(")"))
        {
            if (!token.getStr().equals(","))
            {
                String colName = token.getStr();
                Column c = tbl.getColumn(colName);
                if (c == null) err ("Invalid column name: "+colName);
                    c.setUnique(true);
            }
            next();
        }
        if (!token.getStr().toUpperCase().equals(")"))
            err (") expected got: " + token.getStr());
View Full Code Here

                err (") expected");
            }
            next();
        }

        Column col = new Column (columnName);
        if (columnPrecision != null)
            columnSize = columnSize + columnPrecision;
        col.setTypeFromString (columnType,columnSize);
        tbl.addColumn (col);
       
        if ( inEnum )
        {
            col.setNotNull(true);
            if (columnDefault != null)
            {
                col.setDefaultValue(columnDefault);
            }
        }
        else
        {
            while (!token.getStr().equals(",") && !token.getStr().equals(")"))
            {
                if (token.getStr().toUpperCase().equals("NOT"))
                {
                    next();
                    if (!token.getStr().toUpperCase().equals("NULL"))
                        err ("NULL expected after NOT");
                    col.setNotNull(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("PRIMARY"))
                {
                    next();
                    if (!token.getStr().toUpperCase().equals("KEY"))
                        err ("KEY expected after PRIMARY");
                    col.setPrimaryKey(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("UNIQUE"))
                {
                    col.setUnique(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("NULL"))
                {
                    col.setNotNull(false);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("AUTO_INCREMENT"))
                {
                    col.setAutoIncrement(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("DEFAULT"))
                {
                    next();
                    if (token.getStr().equals("'"))
                    {
                        next();
                    }
                    col.setDefaultValue(token.getStr());
                    next();
                    if (token.getStr().equals("'"))
                    {
                        next();
                    }
View Full Code Here

        if (!token.getStr().toUpperCase().equals("("))
            err ("( expected");
        next();

        String colName = token.getStr();
        Column c = tbl.getColumn(colName);
        if (c == null) err ("Invalid column name: "+colName);
        c.setPrimaryKey(true);
        next();
        while (token.getStr().equals(","))
        {
            next();
            colName = token.getStr();
            c = tbl.getColumn(colName);
            if (c == null) err ("Invalid column name: "+colName);
            c.setPrimaryKey(true);
            next();
        }

        if (!token.getStr().toUpperCase().equals(")"))
            err (") expected");
View Full Code Here

        while (!token.getStr().equals(")"))
        {
            if (!token.getStr().equals(","))
            {
                String colName = token.getStr();
                Column c = tbl.getColumn(colName);
                if (c == null) err ("Invalid column name: "+colName);
                    c.setUnique(true);
            }
            next();
        }
        if (!token.getStr().toUpperCase().equals(")"))
            err (") expected got: " + token.getStr());
View Full Code Here

                err (") expected");
            }
            next();
        }

        Column col = new Column (columnName);
        if (columnPrecision != null)
            columnSize = columnSize + columnPrecision;
        col.setTypeFromString (columnType,columnSize);
        tbl.addColumn (col);
       
        if ( inEnum )
        {
            col.setNotNull(true);
            if (columnDefault != null)
            {
                col.setDefaultValue(columnDefault);
            }
        }
        else
        {
            while (!token.getStr().equals(",") && !token.getStr().equals(")"))
            {
                if (token.getStr().toUpperCase().equals("NOT"))
                {
                    next();
                    if (!token.getStr().toUpperCase().equals("NULL"))
                        err ("NULL expected after NOT");
                    col.setNotNull(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("PRIMARY"))
                {
                    next();
                    if (!token.getStr().toUpperCase().equals("KEY"))
                        err ("KEY expected after PRIMARY");
                    col.setPrimaryKey(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("UNIQUE"))
                {
                    col.setUnique(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("NULL"))
                {
                    col.setNotNull(false);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("AUTO_INCREMENT"))
                {
                    col.setAutoIncrement(true);
                    next();
                }
                else if (token.getStr().toUpperCase().equals("DEFAULT"))
                {
                    next();
                    if (token.getStr().equals("'"))
                    {
                        next();
                    }
                    col.setDefaultValue(token.getStr());
                    next();
                    if (token.getStr().equals("'"))
                    {
                        next();
                    }
View Full Code Here

                    if (referrers == null || !referrers.contains(fk))
                    {
                        foreignTable.addReferrer(fk);
                    }

                    Column local = currTable
                        .getColumn(attributes.getValue("local"));
                    // give notice of a schema inconsistency.
                    // note we do not prevent the npe as there is nothing
                    // that we can do, if it is to occur.
                    if ( local == null )
                    {
                        System.out.println("ERROR!! Attempt to define foreign"
                            + " key with nonexistent column, " +
                            attributes.getValue("local") + ", in table, " +
                            currTable.getName() + "!" );
                    }
                    //check for foreign pk's
                    if (local.isPrimaryKey())
                    {
                        currTable.setContainsForeignPK(true);
                    }

                    Column foreign = foreignTable
                        .getColumn(attributes.getValue("foreign"));
                    // if the foreign column does not exist, we may have an
                    // external reference or a misspelling
                    if ( foreign == null )
                    {
                        System.out.println("ERROR!! Attempt to set foreign"
                            + " key to nonexistent column, " +
                            attributes.getValue("foreign") + ", in table, "
                            + foreignTable.getName() + "!" );
                    }
                    foreign.addReferrer(fk);
                }
            }
            else
            {
                if (rawName.equals("database"))
View Full Code Here

            {
                Table table = database.getTableByJavaName(rawName);
                Vector columnValues = new Vector();
                for (int i=0; i<attributes.getLength(); i++)
                {
                    Column col = table
                        .getColumnByJavaName(attributes.getLocalName(i));
                    String value = attributes.getValue(i);
                    columnValues.add(new ColumnValue(col, value));
                }
                data.add(new DataRow(table, columnValues));
View Full Code Here

        if (!token.getStr().toUpperCase().equals("("))
            err ("( expected");
        next();

        String colName = token.getStr();
        Column c = tbl.getColumn(colName);
        if (c == null) err ("Invalid column name: "+colName);
        c.setPrimaryKey(true);
        next();
        while (token.getStr().equals(","))
        {
            next();
            colName = token.getStr();
            c = tbl.getColumn(colName);
            if (c == null) err ("Invalid column name: "+colName);
            c.setPrimaryKey(true);
            next();
        }

        if (!token.getStr().toUpperCase().equals(")"))
            err (") expected");
View Full Code Here

        while (!token.getStr().equals(")"))
        {
            if (!token.getStr().equals(","))
            {
                String colName = token.getStr();
                Column c = tbl.getColumn(colName);
                if (c == null) err ("Invalid column name: "+colName);
                    c.setUnique(true);
            }
            next();
        }
        if (!token.getStr().toUpperCase().equals(")"))
            err (") expected got: " + token.getStr());
View Full Code Here

TOP

Related Classes of org.apache.turbine.torque.engine.database.model.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.