Package Framework

Examples of Framework.ParameterHolder_TextData


                        int t = attrNode.getTableIndex();
                        // ------------------------------------
                        // Parameters for call to GetColumnName
                        // ------------------------------------
                        ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                        ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                        attrNode.getEntity().getColumnName(attrNode.getAttr(), qq_tableIndex, qq_columnName);
                        t = qq_tableIndex.getInt();
                        c = (TextData)qq_columnName.getObject();
                        if (this.getOrderClause().getActualSize() > 0) {
                            oldClause = this.getOrderClause();
                            this.setOrderClause(new TextData());
                        }
                        this.getOrderClause().replaceParameters("t%1.%2", new IntegerData(t), c);
View Full Code Here


                    t1 = i;
                    // ------------------------------------
                    // Parameters for call to GetColumnName
                    // ------------------------------------
                    ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t1);
                    ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                    attrNode.getEntity().getColumnName(attrNode.getAttr(), qq_tableIndex, qq_columnName);
                    t1 = qq_tableIndex.getInt();
                    c = (TextData)qq_columnName.getObject();
                    if (c != null) {
                        //
                        //  Key columns get added for all tables.  Other columns only
                        //  get added for the table to which they apply.
                        //
View Full Code Here

            t = attrNode.getTableIndex();
            // ------------------------------------
            // Parameters for call to GetColumnName
            // ------------------------------------
            ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
            ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
            attrNode.getEntity().getColumnName(attrNode.getAttr(), qq_tableIndex, qq_columnName);
            t = qq_tableIndex.getInt();
            c = (TextData)qq_columnName.getObject();
            if ((c == null || c.getActualSize() == 0) && (attrNode.getAttr() > attrNode.getEntity().getNumDBAttrs())) {
                attrMask.setInt(attrMask.getInt()|SqlQuery.ATTRTYPE_CUSTOM);
            }
            else {
                attrMask.setInt(attrMask.getInt()|SqlQuery.ATTRTYPE_DB);
            }
            if (this.getOperation() == BusinessQuery.OP_SELECT) {
                result.replaceParameters("t%1.%2", new IntegerData(t), c);
            }
            else {
                result.concat(c);
                tableIndex.setInt(t);
            }

        }
        else if (node instanceof ConstraintConstant) {

            result.setValue( ((ConstraintConstant)node).getValue() );

        }
        else if (node instanceof ConstraintOperation) {

            opNodeOp = ((ConstraintOperation)node).getOperation();
            opNodeOpCode = opNodeOp&ConstraintOperation.OPCODE_MASK;

            if (opNodeOpCode == ConstraintOperation.OPCODE_IN) {

                if (stack.size() < 2) {
                    throw new Error(Error.QC_CONSTRAINT_STACK_EMPTY, "GetWhereText", this).getException();
                }

                result.setValue( "(" );

                if (!(stack.get(stack.size()-1) instanceof ConstraintAttr)) {
                    throw new Error(Error.QC_NEED_ATTR_NODE, "GetWhereText", this).getException();
                }
                else {
                    // -----------------------------------
                    // Parameters for call to GetWhereText
                    // -----------------------------------
                    ParameterHolder_integer qq_attrMask = new ParameterHolder_integer(attrMask.getInt());
                    ParameterHolder_integer qq_valueCount = new ParameterHolder_integer(valueCount.getInt());
                    ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(tableIndex.getInt());
                    TextData qq_GetWhereText = this.getWhereText(stack, qq_attrMask, qq_valueCount, qq_tableIndex);
                    attrMask.setInt(qq_attrMask.getInt());
                    valueCount.setInt(qq_valueCount.getInt());
                    tableIndex.setInt(qq_tableIndex.getInt());
                    c = qq_GetWhereText;
                }

                while (stack.size() > 1 && stack.get(stack.size()-1) instanceof ConstraintAttr) {
                    c.replaceRange(", ", 0, 0);
                    // -----------------------------------
                    // Parameters for call to GetWhereText
                    // -----------------------------------
                    ParameterHolder_integer qq_attrMask = new ParameterHolder_integer(attrMask.getInt());
                    ParameterHolder_integer qq_valueCount = new ParameterHolder_integer(valueCount.getInt());
                    ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(tableIndex.getInt());
                    TextData qq_GetWhereText = this.getWhereText(stack, qq_attrMask, qq_valueCount, qq_tableIndex);
                    attrMask.setInt(qq_attrMask.getInt());
                    valueCount.setInt(qq_valueCount.getInt());
                    tableIndex.setInt(qq_tableIndex.getInt());
                    c.replaceRange(qq_GetWhereText, 0, 0);
                }

                result.concat(c);
                result.concat(") in (");

                if (!(stack.get(stack.size()-1) instanceof ConstraintValue)) {
                    throw new Error(Error.QC_NEED_VALUE_NODE, "GetWhereText", this).getException();
                }
                else {
                    result.concat(((ConstraintValue)(stack.get(stack.size()-1))).getValue());
                    stack.deleteRow(stack.size()- 1);
                }
                result.concat(")");

                if (stack.size() > 0 && stack.get(stack.size()-1) instanceof ConstraintSqlData) {
                    Array_Of_DataValue<DataValue> qq_localVector = ((ConstraintSqlData)(stack.get(stack.size()-1))).getData().getValues();
                    if (qq_localVector != null) {
                        for (DataValue d : qq_localVector) {
                            this.getData().get(tableIndex.getInt()-1).getValues().add(d);
                        }
                    }
                    stack.deleteRow(stack.size()- 1);
                }

            }
            else if (opNodeOpCode == ConstraintOperation.OPCODE_LEFTJOIN || opNodeOpCode == ConstraintOperation.OPCODE_RIGHTJOIN || opNodeOpCode == ConstraintOperation.OPCODE_EQUIJOIN) {
                boolean doFancyJoin = opNodeOpCode != ConstraintOperation.OPCODE_EQUIJOIN && this.getDBSession().getDBVendorType() != Constants.DB_VT_ORACLE && this.getDBSession().getDBVendorType() != Constants.DB_VT_SYBASE;
                int oldFromTable = 0, newFromTable = 0, oldToTable = 0, newToTable = 0;
                if (opNodeOpCode == ConstraintOperation.OPCODE_EQUIJOIN) {
                    this.setOptions(this.getOptions()|SqlQuery.OPT_INNER_JOIN);
                }
                else {
                    this.setOptions(this.getOptions()|SqlQuery.OPT_OUTER_JOIN);
                }
                TextData c3 = new TextData();
                if (doFancyJoin) {
                    node = stack.get(stack.size()-1);
                    if (!(node instanceof ConstraintAttr)) {
                        throw new Error(Error.QC_NEED_ATTR_NODE, "GetWhereText", this).getException();
                    }
                    attrNode = (ConstraintAttr)node;
                    if (attrNode.getTableIndex() > this.tableList.size()) {
                        throw new Error(Error.QC_ILLEGAL_TABLE_INDEX, "GetWhereText", this, new IntegerData(attrNode.getTableIndex()), new IntegerData(this.tableList.size())).getException();
                    }
                    node = stack.get(stack.size()-1-1);
                    if (!(node instanceof ConstraintAttr)) {
                        throw new Error(Error.QC_NEED_ATTR_NODE, "GetWhereText", this).getException();
                    }
                    if (((ConstraintAttr)node).getTableIndex() > this.tableList.size()) {
                        throw new Error(Error.QC_ILLEGAL_TABLE_INDEX, "GetWhereText", this, new IntegerData(attrNode.getTableIndex()), new IntegerData(this.tableList.size())).getException();
                    }
                    t = attrNode.getEntity().getTableAliases().get(attrNode.getTableIndex()-1).getValue();
                    int t2 = ((ConstraintAttr)node).getEntity().getTableAliases().get(((ConstraintAttr)node).getTableIndex()-1).getValue();
                    //
                    //  We want to put in a join for attrNode.  We know the table
                    //  aliases t, and t2 to use.  We have to check that these
                    //  tables aren't already participating in a join.  If either of
                    //  them are then we will have to make a new table alias for that
                    //  table and put in an addtional equijoin between the old alias
                    //  and the new based, of course, on the key columns.  The one
                    //  exception is that t can participate in multiple joins if
                    //  the OPT_NO_MULT_OUTER_JOIN option is not set.
                    //
                    int t3 = 0;
                    if (this.tableList.get(t2-1).getPrevTable() != null) {
                        oldToTable = t2;
                        this.addTable(this.tableList.get(t2-1).getTableName());
                        for (int i = 1; i <= attrNode.getEntity().getNumKeyAttrs(); i++) {
                            t3 = attrNode.getTableIndex();
                            // ------------------------------------
                            // Parameters for call to GetColumnName
                            // ------------------------------------
                            ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t3);
                            ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                            attrNode.getEntity().getColumnName(i, qq_tableIndex, qq_columnName);
                            t3 = qq_tableIndex.getInt();
                            c = (TextData)qq_columnName.getObject();
                            if (c == null) {
                                c = new TextData();
                            }
                            this.addConstraint(c3.replaceParameters("t%1.%2 = t%3.%2", new IntegerData(t2), c, this.getNumTables()).toString());
                        }
                        t2 = this.getNumTables().getValue();
                        newToTable = t2;
                    }
                    if (this.tableList.get(t-1).getNextTable() == null) {
                        this.tableList.get(t-1).setNextTable(new Array_Of_SqlQueryTable<SqlQueryTable>());
                        this.tableList.get(t-1).getNextTable().add(this.tableList.get(t2-1));
                        this.tableList.get(t2-1).setPrevTable(this.tableList.get(t-1));
                    }
                    else if ((this.getOptions()&SqlQuery.OPT_NO_MULT_OUTER_JOIN) == 0) {
                        this.tableList.get(t-1).getNextTable().add(this.tableList.get(t2-1));
                        this.tableList.get(t2-1).setPrevTable(this.tableList.get(t-1));
                    }
                    else {
                        oldFromTable = t;
                        this.addTable(this.tableList.get(t-1).getTableName());
                        for (int i = 1; i <= attrNode.getEntity().getNumKeyAttrs(); i++) {
                            t3 = attrNode.getTableIndex();
                            // ------------------------------------
                            // Parameters for call to GetColumnName
                            // ------------------------------------
                            ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t3);
                            ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                            attrNode.getEntity().getColumnName(i, qq_tableIndex, qq_columnName);
                            t3 = qq_tableIndex.getInt();
                            c = (TextData)qq_columnName.getObject();
                            if (c == null) {
                                c = new TextData();
                            }
                            this.addConstraint(c3.replaceParameters("t%1.%2 = t%3.%2", new IntegerData(t), c, this.getNumTables()).toString());
                        }
                        t = this.getNumTables().getValue();
                        newFromTable = t;
                        this.tableList.get(t-1).setNextTable(new Array_Of_SqlQueryTable<SqlQueryTable>());
                        this.tableList.get(t-1).getNextTable().add(this.tableList.get(t2-1));
                        this.tableList.get(t2-1).setPrevTable(this.tableList.get(t-1));
                    }
                    this.tableList.get(t-1).setJoinOp(opNodeOpCode);
                    if (this.getDBSession().getDBVendorType() != Constants.DB_VT_INFORMIX) {
                        this.tableList.get(t2-1).setOnClause(result);
                    }
                }
                //
                //   We've now completed linking the joined tables together in the
                //   table list.  Now we need to create the join condition.  Depending
                //   on the database this may end up in the where clause or in the
                //   join clause.
                //
                int params = (opNodeOp&ConstraintOperation.PCOUNT_MASK)/ConstraintOperation.PCOUNT_INCREMENT;
                if (stack.size() < params*2) {
                    throw new Error(Error.QC_CONSTRAINT_STACK_EMPTY, "GetWhereText", this).getException();
                }
                int format = this.operationFormat(opNodeOp);
                if (doFancyJoin) {
                    c2 = new TextData(" = ");
                }
                else {
                    c2 = this.infixOperator(opNodeOp, 1);
                }
                for (int i = 1; i <= params*2; i++) {
                    if (i > 1) {
                        if ((i&1) > 0) {
                            result.concat(" and ");
                        }
                        else {
                            result.concat(c2);
                        }
                    }
                    node = stack.get(stack.size()-1);
                    if (!(node instanceof ConstraintAttr)) {
                        throw new Error(Error.QC_NEED_ATTR_NODE, "GetWhereText", this).getException();
                    }
                    stack.deleteRow(stack.size()- 1);
                    attrNode = (ConstraintAttr)node;
                    t = attrNode.getTableIndex();
                    // ------------------------------------
                    // Parameters for call to GetColumnName
                    // ------------------------------------
                    ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                    ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                    attrNode.getEntity().getColumnName(attrNode.getAttr(), qq_tableIndex, qq_columnName);
                    t = qq_tableIndex.getInt();
                    c = (TextData)qq_columnName.getObject();
                    if (t == oldFromTable) {
                        t = newFromTable;
                    }
                    else if (t == oldToTable) {
                        t = newToTable;
View Full Code Here

            t = 1;
            // ------------------------------------
            // Parameters for call to GetColumnName
            // ------------------------------------
            ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
            ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
            query.getColumnName(limitAttr, qq_tableIndex, qq_columnName);
            t = qq_tableIndex.getInt();
            c = (TextData)qq_columnName.getObject();
            depQuery.addConstraint(t, c, op, result.get(result.size()-1).getAttr(limitAttr));

            //
            //  Since its a stack we push the last thing first, the input values.
            //
            if (depQuery.getData().get(0).getValues().size() > 0) {
                dep.getConstraint().addSqlData(depQuery.getData().get(0));
            }

            //  Now we need the text of the subselect.  The problem is we don't know
            //  what it is yet since we haven't done our fire drill with the columns
            //  yet.  Since object references are all pointers we can push the
            //  queryText object on now and fill in its value later when we know what
            //  it is.
            //
            dep.getConstraint().addValue(queryText);

            depQuery.clearColumnList();
            depQuery.setOrderClause(new TextData(""));

            //  Now we need to push our attributes on the constraint stack and add
            //  new columns to the subselect query which correspond to them.
            //
            //  attr.local will be the attribute in the independent class.
            //  attr.foreign will be the attribute in the dependent class.
            //
            if (attrMap != null) {
                for (QueryAttrMap attr : attrMap) {

                    //  Translate the attribute index to a tableIndex/columnName pair and
                    //  add it to the query for the subselect.
                    //
                    t = 1;
                    // ------------------------------------
                    // Parameters for call to GetColumnName
                    // ------------------------------------
                    ParameterHolder_integer qq_tableIndex1 = new ParameterHolder_integer(t);
                    ParameterHolder_TextData qq_columnName1 = new ParameterHolder_TextData();
                    query.getColumnName(attr.getLocal(), qq_tableIndex1, qq_columnName1);
                    t = qq_tableIndex1.getInt();
                    c = (TextData)qq_columnName1.getObject();
                    depQuery.addColumn(t, c, (DataValue)null);

                    //  Push our attribute (the myCol1, myCol2, ... thing) on the stack.
                    //
                    dep.getConstraint().addAttr(dep, attr.getForeign(), 1);
View Full Code Here

                        t2 = t1;
                        // ------------------------------------
                        // Parameters for call to GetColumnName
                        // ------------------------------------
                        ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t2);
                        ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                        this.getColumnName(i, qq_tableIndex, qq_columnName);
                        t2 = qq_tableIndex.getInt();
                        c = (TextData)qq_columnName.getObject();
                        sq.addConstraint(t2, c, ConstraintOperation.OP_EQ, this.getKey().getValues().get(i-1));
                    }
                }

                //
                //  Add user specified constraints.
                //
                sq.addConstraint(this.getConstraint());

                break;
            }
            case BusinessQuery.OP_INSERT: {

                //
                //  For inserts the constraints represent the values to be inserted.
                //
                sq.addValue(this.getValues());

                break;
            }
            case BusinessQuery.OP_DELETE: {

                //
                //  For deletes we need only specify the key attributes as constraints.
                //
                for (int i = 1; i <= lNumKeyAttrs; i++) {
                    for (int t1 = 1; t1 <= lNumTables; t1++) {
                        t2 = t1;
                        // ------------------------------------
                        // Parameters for call to GetColumnName
                        // ------------------------------------
                        ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t2);
                        ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                        this.getColumnName(i, qq_tableIndex, qq_columnName);
                        t2 = qq_tableIndex.getInt();
                        c = (TextData)qq_columnName.getObject();
                        sq.addConstraint(t2, c, ConstraintOperation.OP_EQ, this.getKey().getValues().get(i-1));
                    }
                }

                //
                //  Add user specified constraints.
                //
                sq.addConstraint(this.getConstraint());

                break;
            }
            case BusinessQuery.OP_SELECT: {

                //
                // Add attributes to the select list.
                //   
                int attrs = 0;
                int index = 0;
                int baseIndex = 1;
                int lNumDBAttrs = this.getNumDBAttrs();
                // cache virtual attribute

                if (this.getTargetAttrs() != null) {
                    for (IntegerData attr : this.getTargetAttrs()) {
                        if (baseIndex+30 <= lNumKeyAttrs) {
                            //
                            //  All attributes are key attributes -- make sure they're all set.
                            //
                            attr.setValue(2147483647);
                        }
                        else if (baseIndex <= lNumKeyAttrs) {
                            //
                            //  Or in key attributes
                            //
                            attr.setValue(attr.getValue()|((int)(new DoubleData().power(2, lNumKeyAttrs-baseIndex+1).getValue()-1)));
                        }
                        index = baseIndex;
                        attrs = attr.getValue();
                        while ((attrs > 0) && (index <= lNumDBAttrs)) {
                            if ((attrs&1) > 0) {
                                t = 1;
                                // ------------------------------------
                                // Parameters for call to GetColumnName
                                // ------------------------------------
                                ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                                ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                                this.getColumnName(index, qq_tableIndex, qq_columnName);
                                t = qq_tableIndex.getInt();
                                c = (TextData)qq_columnName.getObject();
                                sq.addColumn(t, c, (DataValue)null);
                                if (index <= lNumKeyAttrs && lNumTables > 1) {
                                    for (int tindex = 2; tindex <= lNumTables; tindex++) {
                                        t2 = tindex;
                                        // ------------------------------------
                                        // Parameters for call to GetColumnName
                                        // ------------------------------------
                                        ParameterHolder_integer qq_tableIndex1 = new ParameterHolder_integer(t2);
                                        ParameterHolder_TextData qq_columnName1 = new ParameterHolder_TextData();
                                        this.getColumnName(index, qq_tableIndex1, qq_columnName1);
                                        t2 = qq_tableIndex1.getInt();
                                        c = (TextData)qq_columnName1.getObject();
                                        if (this.getConstraint() == null) {
                                            this.setConstraint(new QueryConstraint());
                                        }
                                        this.getConstraint().addAttr(this, index, 1);
                                        this.getConstraint().addAttr(this, index, tindex);
                                        this.getConstraint().addOperation(ConstraintOperation.OP_EQ);
                                    }
                                }
                            }
                            attrs = attrs/2;
                            index = index+1;
                        }
                        baseIndex = baseIndex+31;
                    }
                }

                //
                // Finally do foreign entities.
                //
                if (this.getForeignClasses() != null) {
                    for (BusinessQuery fe : this.getForeignClasses()) {

                        if ((fe.getExecuteInfo().getStatus()&QueryExecuteInfo.ST_JOINED) > 0) {
                            //
                            //  Check what kind of join we are going to do
                            //
                            int op = 0;
                            if ((fe.getParentMult()&BusinessQuery.ASSOC_MULT_OPTIONAL) == 0) {
                                op = ConstraintOperation.OP_EQUIJOIN;
                                sq.setOptions(sq.getOptions()|SqlQuery.OPT_INNER_JOIN);
                            }
                            else {
                                op = ConstraintOperation.OP_LEFTJOIN;
                                sq.setOptions(sq.getOptions()|SqlQuery.OPT_OUTER_JOIN);
                            }

                            //
                            //  Put in a join to the foreign table
                            //
                            this.addJoinConstraint(op, fe);

                            //
                            //  Now have the foreign entity describe itself as we just did and
                            //  append this to the sqlQuery we are building up.
                            //
                            // ---------------------------------
                            // Parameters for call to BuildQuery
                            // ---------------------------------
                            ParameterHolder_SqlQuery qq_query = new ParameterHolder_SqlQuery(sq);
                            fe.buildQuery(qq_query);
                            sq = (SqlQuery)qq_query.getObject();

                        }
                        else if (fe.getTargetAttrs() == null) {
                            //
                            //  This is the case where we have a 1-to-many association
                            //  which has a constraint on the foreign class which is
                            //  suppossed to limit the primary.  We need an "in" sql
                            //  condition of the form:
                            //    where (<join-column-list>) in
                            //      (select <join-column-list> from <foreignTable> ...)
                            //       
                            TextData queryText = null;
                            SqlQuery subQuery = null;

                            // ---------------------------------
                            // Parameters for call to BuildQuery
                            // ---------------------------------
                            ParameterHolder_SqlQuery qq_query = new ParameterHolder_SqlQuery(subQuery);
                            fe.buildQuery(qq_query);
                            subQuery = (SqlQuery)qq_query.getObject();
                            //
                            //  Don't really want this query to look like its executed.
                            //
                            fe.getExecuteInfo().setStatus(fe.getExecuteInfo().getStatus()&~QueryExecuteInfo.ST_BUILT);

                            //
                            //  First build the sub-query and get its text.  Note:
                            //  this query really has the wrong column list.  We'll
                            //  fix that up and reset the query text in a minute, but
                            //  need to get the text now as input data isn't
                            //  computed until we do and we need to know that now.
                            //
                            queryText = subQuery.getText().get(0);

                            if (subQuery.getData().get(0).getValues().size() > 0) {
                                //
                                //  Push input data for the sub-query, if any.
                                //
                                this.getConstraint().addSqlData(subQuery.getData().get(0));
                            }

                            //  Next push the suq-query, we'll fix this up at the end.
                            //
                            this.getConstraint().addValue(queryText);

                            subQuery.clearColumnList();
                            //
                            //  Now clear the column list and recompute it.  At the
                            //  same time push on the column list for the outer query.
                            //       
                            Array_Of_QueryAttrMap<QueryAttrMap> qq_localVector = this.getForeignAttrMap(fe.getParentAttr());
                            if (qq_localVector != null) {
                                for (QueryAttrMap attr : qq_localVector) {
                                    t = 1;
                                    // ------------------------------------
                                    // Parameters for call to GetColumnName
                                    // ------------------------------------
                                    ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                                    ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                                    fe.getColumnName(attr.getForeign(), qq_tableIndex, qq_columnName);
                                    t = qq_tableIndex.getInt();
                                    c = (TextData)qq_columnName.getObject();
                                    subQuery.addColumn(t, c, (DataValue)null);
                                    this.getConstraint().addAttr(this, attr.getLocal(), 1);
                                }
                            }
View Full Code Here

        for (int i = 1; i <= this.getNumTables(); i++) {
            // -----------------------------------
            // Parameters for call to GetTableName
            // -----------------------------------
            ParameterHolder_TextData qq_tableName = new ParameterHolder_TextData();
            this.getTableName(i, qq_tableName);
            tableName = (TextData)qq_tableName.getObject();
            this.getTableAliases().add(sqlQuery.addTable(tableName));
        }
    }
View Full Code Here

            t = 1;
            // ------------------------------------
            // Parameters for call to GetColumnName
            // ------------------------------------
            ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
            ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
            query.getColumnName(limitAttr, qq_tableIndex, qq_columnName);
            t = qq_tableIndex.getInt();
            c = (TextData)qq_columnName.getObject();
            depQuery.addConstraint(t, c, op, result.get(result.size()-1).getAttr(limitAttr));

            //
            //  Since its a stack we push the last thing first, the input values.
            //
            if (depQuery.getData().get(0).getValues().size() > 0) {
                dep.getConstraint().addSqlData(depQuery.getData().get(0));
            }

            //  Now we need the text of the subselect.  The problem is we don't know
            //  what it is yet since we haven't done our fire drill with the columns
            //  yet.  Since object references are all pointers we can push the
            //  queryText object on now and fill in its value later when we know what
            //  it is.
            //
            dep.getConstraint().addValue(queryText);

            depQuery.clearColumnList();
            depQuery.setOrderClause(new TextData(""));

            //  Now we need to push our attributes on the constraint stack and add
            //  new columns to the subselect query which correspond to them.
            //
            //  attr.local will be the attribute in the independent class.
            //  attr.foreign will be the attribute in the dependent class.
            //
            if (attrMap != null) {
                for (QueryAttrMap attr : attrMap) {

                    //  Translate the attribute index to a tableIndex/columnName pair and
                    //  add it to the query for the subselect.
                    //
                    t = 1;
                    // ------------------------------------
                    // Parameters for call to GetColumnName
                    // ------------------------------------
                    ParameterHolder_integer qq_tableIndex1 = new ParameterHolder_integer(t);
                    ParameterHolder_TextData qq_columnName1 = new ParameterHolder_TextData();
                    query.getColumnName(attr.getLocal(), qq_tableIndex1, qq_columnName1);
                    t = qq_tableIndex1.getInt();
                    c = (TextData)qq_columnName1.getObject();
                    depQuery.addColumn(t, c, (DataValue)null);

                    //  Push our attribute (the myCol1, myCol2, ... thing) on the stack.
                    //
                    dep.getConstraint().addAttr(dep, attr.getForeign(), 1);
View Full Code Here

                        t2 = t1;
                        // ------------------------------------
                        // Parameters for call to GetColumnName
                        // ------------------------------------
                        ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t2);
                        ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                        this.getColumnName(i, qq_tableIndex, qq_columnName);
                        t2 = qq_tableIndex.getInt();
                        c = (TextData)qq_columnName.getObject();
                        sq.addConstraint(t2, c, ConstraintOperation.OP_EQ, this.getKey().getValues().get(i-1));
                    }
                }

                //
                //  Add user specified constraints.
                //
                sq.addConstraint(this.getConstraint());

                break;
            }
            case BusinessQuery.OP_INSERT: {

                //
                //  For inserts the constraints represent the values to be inserted.
                //
                sq.addValue(this.getValues());

                break;
            }
            case BusinessQuery.OP_DELETE: {

                //
                //  For deletes we need only specify the key attributes as constraints.
                //
                for (int i = 1; i <= lNumKeyAttrs; i++) {
                    for (int t1 = 1; t1 <= lNumTables; t1++) {
                        t2 = t1;
                        // ------------------------------------
                        // Parameters for call to GetColumnName
                        // ------------------------------------
                        ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t2);
                        ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                        this.getColumnName(i, qq_tableIndex, qq_columnName);
                        t2 = qq_tableIndex.getInt();
                        c = (TextData)qq_columnName.getObject();
                        sq.addConstraint(t2, c, ConstraintOperation.OP_EQ, this.getKey().getValues().get(i-1));
                    }
                }

                //
                //  Add user specified constraints.
                //
                sq.addConstraint(this.getConstraint());

                break;
            }
            case BusinessQuery.OP_SELECT: {

                //
                // Add attributes to the select list.
                //   
                int attrs = 0;
                int index = 0;
                int baseIndex = 1;
                int lNumDBAttrs = this.getNumDBAttrs();
                // cache virtual attribute

                if (this.getTargetAttrs() != null) {
                    for (IntegerData attr : this.getTargetAttrs()) {
                        if (baseIndex+30 <= lNumKeyAttrs) {
                            //
                            //  All attributes are key attributes -- make sure they're all set.
                            //
                            attr.setValue(2147483647);
                        }
                        else if (baseIndex <= lNumKeyAttrs) {
                            //
                            //  Or in key attributes
                            //
                            attr.setValue(attr.getValue()|((int)(new DoubleData().power(2, lNumKeyAttrs-baseIndex+1).getValue()-1)));
                        }
                        index = baseIndex;
                        attrs = attr.getValue();
                        while ((attrs > 0) && (index <= lNumDBAttrs)) {
                            if ((attrs&1) > 0) {
                                t = 1;
                                // ------------------------------------
                                // Parameters for call to GetColumnName
                                // ------------------------------------
                                ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                                ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                                this.getColumnName(index, qq_tableIndex, qq_columnName);
                                t = qq_tableIndex.getInt();
                                c = (TextData)qq_columnName.getObject();
                                sq.addColumn(t, c, (DataValue)null);
                                if (index <= lNumKeyAttrs && lNumTables > 1) {
                                    for (int tindex = 2; tindex <= lNumTables; tindex++) {
                                        t2 = tindex;
                                        // ------------------------------------
                                        // Parameters for call to GetColumnName
                                        // ------------------------------------
                                        ParameterHolder_integer qq_tableIndex1 = new ParameterHolder_integer(t2);
                                        ParameterHolder_TextData qq_columnName1 = new ParameterHolder_TextData();
                                        this.getColumnName(index, qq_tableIndex1, qq_columnName1);
                                        t2 = qq_tableIndex1.getInt();
                                        c = (TextData)qq_columnName1.getObject();
                                        if (this.getConstraint() == null) {
                                            this.setConstraint(new QueryConstraint());
                                        }
                                        this.getConstraint().addAttr(this, index, 1);
                                        this.getConstraint().addAttr(this, index, tindex);
                                        this.getConstraint().addOperation(ConstraintOperation.OP_EQ);
                                    }
                                }
                            }
                            attrs = attrs/2;
                            index = index+1;
                        }
                        baseIndex = baseIndex+31;
                    }
                }

                //
                // Finally do foreign entities.
                //
                if (this.getForeignClasses() != null) {
                    for (BusinessQuery fe : this.getForeignClasses()) {

                        if ((fe.getExecuteInfo().getStatus()&QueryExecuteInfo.ST_JOINED) > 0) {
                            //
                            //  Check what kind of join we are going to do
                            //
                            int op = 0;
                            if ((fe.getParentMult()&BusinessQuery.ASSOC_MULT_OPTIONAL) == 0) {
                                op = ConstraintOperation.OP_EQUIJOIN;
                                sq.setOptions(sq.getOptions()|SqlQuery.OPT_INNER_JOIN);
                            }
                            else {
                                op = ConstraintOperation.OP_LEFTJOIN;
                                sq.setOptions(sq.getOptions()|SqlQuery.OPT_OUTER_JOIN);
                            }

                            //
                            //  Put in a join to the foreign table
                            //
                            this.addJoinConstraint(op, fe);

                            //
                            //  Now have the foreign entity describe itself as we just did and
                            //  append this to the sqlQuery we are building up.
                            //
                            // ---------------------------------
                            // Parameters for call to BuildQuery
                            // ---------------------------------
                            ParameterHolder_SqlQuery qq_query = new ParameterHolder_SqlQuery(sq);
                            fe.buildQuery(qq_query);
                            sq = (SqlQuery)qq_query.getObject();

                        }
                        else if (fe.getTargetAttrs() == null) {
                            //
                            //  This is the case where we have a 1-to-many association
                            //  which has a constraint on the foreign class which is
                            //  suppossed to limit the primary.  We need an "in" sql
                            //  condition of the form:
                            //    where (<join-column-list>) in
                            //      (select <join-column-list> from <foreignTable> ...)
                            //       
                            TextData queryText = null;
                            SqlQuery subQuery = null;

                            // ---------------------------------
                            // Parameters for call to BuildQuery
                            // ---------------------------------
                            ParameterHolder_SqlQuery qq_query = new ParameterHolder_SqlQuery(subQuery);
                            fe.buildQuery(qq_query);
                            subQuery = (SqlQuery)qq_query.getObject();
                            //
                            //  Don't really want this query to look like its executed.
                            //
                            fe.getExecuteInfo().setStatus(fe.getExecuteInfo().getStatus()&~QueryExecuteInfo.ST_BUILT);

                            //
                            //  First build the sub-query and get its text.  Note:
                            //  this query really has the wrong column list.  We'll
                            //  fix that up and reset the query text in a minute, but
                            //  need to get the text now as input data isn't
                            //  computed until we do and we need to know that now.
                            //
                            queryText = subQuery.getText().get(0);

                            if (subQuery.getData().get(0).getValues().size() > 0) {
                                //
                                //  Push input data for the sub-query, if any.
                                //
                                this.getConstraint().addSqlData(subQuery.getData().get(0));
                            }

                            //  Next push the suq-query, we'll fix this up at the end.
                            //
                            this.getConstraint().addValue(queryText);

                            subQuery.clearColumnList();
                            //
                            //  Now clear the column list and recompute it.  At the
                            //  same time push on the column list for the outer query.
                            //       
                            Array_Of_QueryAttrMap<QueryAttrMap> qq_localVector = this.getForeignAttrMap(fe.getParentAttr());
                            if (qq_localVector != null) {
                                for (QueryAttrMap attr : qq_localVector) {
                                    t = 1;
                                    // ------------------------------------
                                    // Parameters for call to GetColumnName
                                    // ------------------------------------
                                    ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                                    ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                                    fe.getColumnName(attr.getForeign(), qq_tableIndex, qq_columnName);
                                    t = qq_tableIndex.getInt();
                                    c = (TextData)qq_columnName.getObject();
                                    subQuery.addColumn(t, c, (DataValue)null);
                                    this.getConstraint().addAttr(this, attr.getLocal(), 1);
                                }
                            }
View Full Code Here

        for (int i = 1; i <= this.getNumTables(); i++) {
            // -----------------------------------
            // Parameters for call to GetTableName
            // -----------------------------------
            ParameterHolder_TextData qq_tableName = new ParameterHolder_TextData();
            this.getTableName(i, qq_tableName);
            tableName = (TextData)qq_tableName.getObject();
            this.getTableAliases().add(sqlQuery.addTable(tableName));
        }
    }
View Full Code Here

                        int t = attrNode.getTableIndex();
                        // ------------------------------------
                        // Parameters for call to GetColumnName
                        // ------------------------------------
                        ParameterHolder_integer qq_tableIndex = new ParameterHolder_integer(t);
                        ParameterHolder_TextData qq_columnName = new ParameterHolder_TextData();
                        attrNode.getEntity().getColumnName(attrNode.getAttr(), qq_tableIndex, qq_columnName);
                        t = qq_tableIndex.getInt();
                        c = (TextData)qq_columnName.getObject();
                        if (this.getOrderClause().getActualSize() > 0) {
                            oldClause = this.getOrderClause();
                            this.setOrderClause(new TextData());
                        }
                        this.getOrderClause().replaceParameters("t%1.%2", new IntegerData(t), c);
View Full Code Here

TOP

Related Classes of Framework.ParameterHolder_TextData

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.