Package org.netbeans.modules.dbschema

Examples of org.netbeans.modules.dbschema.ColumnElement


        // there is a select statement for each table so we just append this
        // request as a column to the found statement. If none of the tables
        // are being used in this query plan then we create a new statement.
        //
        for (Iterator iter = fieldDesc.getColumnElements(); iter.hasNext(); ) {
            ColumnElement columnElement = (ColumnElement) iter.next();
            QueryTable table = findQueryTable(columnElement.getDeclaringTable());

            if (table == null)
                table = addQueryTable(columnElement.getDeclaringTable(), null);

            SelectStatement statement = (SelectStatement) getStatement(table);

            if (statement == null)
                statement = (SelectStatement) addStatement(table);
View Full Code Here


                // It is important to add the join table here so that this table does not
                // get lost behind the same join table in parentPlan's table list
                // See collection38
                //
                for (int i = 0; i < parentField.assocLocalColumns.size(); i++) {
                    ColumnElement col = (ColumnElement) parentField.assocLocalColumns.get(i);
                    addQueryTable(col.getDeclaringTable(), config);
                }
            }

            // Add the joined tables.
            // This is required for cases where no fields from this plan are selected
            // The side-effect for this is to create statements with no columns.
            for (int i = 0; i < parentField.foreignColumns.size(); i++) {
                ColumnElement col = (ColumnElement) parentField.foreignColumns.get(i);
                addQueryTable(col.getDeclaringTable(), config);
            }
        }
    }
View Full Code Here

     * @param sb String buffer taking the resulting text.
     */
    protected void generateColumnText(LocalFieldDesc desc, QueryPlan thePlan,
                                      StringBuffer sb) {
        QueryTable table = null;
        ColumnElement column = null;
        Iterator iter = desc.getColumnElements();

        while (iter.hasNext() && table == null) {
            column = (ColumnElement) iter.next();

            // For updates, the member variable tableList is complete
            // at this point and includes only the table being updated.
            // For selects, new tables are still added to tableList
            // when join constraints are processed. Take the table list
            // from the query plan to find the table matching the column.
            if (action == QueryPlan.ACT_SELECT) {
                table = thePlan.findQueryTable(column.getDeclaringTable());
            } else {
                table = findQueryTable(column.getDeclaringTable());
            }
        }

        if (table == null) {
            throw new JDOFatalInternalException(I18NHelper.getMessage(messages,
                    "core.configuration.fieldnotable", // NOI18N
                    desc.getName()));
        }

        // Select statements might include columns from several tables.
        // Qualify the column with the table index.
        if (action == QueryPlan.ACT_SELECT) {
            sb.append("t").append(table.getTableIndex()).append("."); // NOI18N
        }

        appendQuotedText(sb, column.getName().getName());
    }
View Full Code Here

     * @return Returns null if the node isn't bound to a field. Otherwise
     * returns ColumnElement for the primary column of the field to which the
     * node is bound.
     */
    private static ColumnElement getColumnElementForValueNode(ConstraintValue node) {
        ColumnElement columnElement = null;
        LocalFieldDesc field = node.getLocalField();
        if(field != null) {
            //For fields mapped to multiple columns, we assume
            //that all the columns have the same value in the database.
            //Hence we only use the primary column in where clause.
View Full Code Here

     * Adds a comparison for local field <CODE>lf</CODE> and value <CODE>val</CODE>
     * to the corresponding statements in UpdateQueryPlan <CODE>plan</CODE>.
     */
    private static void addConstraint(UpdateQueryPlan plan, LocalFieldDesc lf, Object val) {
        for (Iterator iter = lf.getColumnElements(); iter.hasNext(); ) {
            ColumnElement c = (ColumnElement) iter.next();

            for (int i = 0; i < plan.statements.size(); i++) {
                Statement s = (Statement) plan.statements.get(i);

                for (int j = 0; j < s.tableList.size(); j++) {
                    QueryTable t = (QueryTable) s.tableList.get(j);

                    if (t.getTableDesc().getTableElement() == c.getDeclaringTable()) {
                        s.addConstraint(lf, val);
                    }
                }
            }
        }
View Full Code Here

                    for (int i = 0; i < tableList.size(); i++) {
                        QueryTable queryTable = (QueryTable) tableList.get(i);
                        if (isUpdateLockRequired(queryTable)) {
                            TableDesc tableDesc = queryTable.getTableDesc();
                            //Get the first column of primary key
                            ColumnElement ce = (ColumnElement) tableDesc.getKey().getColumns().get(0);
                            forUpdateClause.append("t").append(i).append("."); // NOI18N
                            appendQuotedText(forUpdateClause, ce.getName().getName());
                            forUpdateClause.append(", "); // NOI18N
                        }
                    }
                    // Remove trailing ", "
                    forUpdateClause.delete(forUpdateClause.length() - 2, forUpdateClause.length());
View Full Code Here

    private void generateJoin(ConstraintJoin jnode,
                              StringBuffer whereText,
                              int opCode) {

        for (int i = 0; i < jnode.fromColumns.size(); i++) {
            ColumnElement fromColumn = (ColumnElement)jnode.fromColumns.get(i);
            ColumnElement toColumn = (ColumnElement)jnode.toColumns.get(i);
            QueryTable fromTable = findQueryTable(jnode.fromPlan, fromColumn);
            QueryTable toTable = findQueryTable(jnode.toPlan, toColumn);

            addQueryTable(fromTable);
            addQueryTable(toTable);
View Full Code Here

     * @see #processFromClause
     */
    private void generateAnsiJoin(ConstraintJoin jnode, int opCode) {

        for (int i = 0; i < jnode.fromColumns.size(); i++) {
            ColumnElement fromColumn = (ColumnElement)jnode.fromColumns.get(i);
            ColumnElement toColumn = (ColumnElement)jnode.toColumns.get(i);
            QueryTable fromTable = findQueryTable(jnode.fromPlan, fromColumn);
            QueryTable toTable = findQueryTable(jnode.toPlan, toColumn);

            // Process the from clause
            processFromClause(fromTable, toTable);
View Full Code Here

     * @param columnList List of columns.
     * @param config Class configuration corresponding to columns.
     */
    protected void addQueryTables(ArrayList columnList, ClassDesc config) {
        for (int i = 0; i < columnList.size(); i++) {
            ColumnElement col = (ColumnElement) columnList.get(i);
            addQueryTable(col.getDeclaringTable(), config);
        }
    }
View Full Code Here

          {
            println(tabs+1, "--> columnsObjects ")//NOI18N
            for (int j = 0; j < colCount; j++)
            {
              ColumnPairElement fce = (ColumnPairElement) columnObjects.get(j);
              ColumnElement rce = (fce!=null)?fce.getReferencedColumn():null;
              println(tabs+1, "[" + j + "] " + fce + " -> " + rce)//NOI18N
            }
            println(tabs+1, "<-- columnsObjects ")//NOI18N
          }
         
          println(tabs+1, "associatedColumns = " + mre.getAssociatedColumns())//NOI18N

          ArrayList associatedColumnObjects = mre.getAssociatedColumnObjects();
          colCount = ((associatedColumnObjects != null) ?
            associatedColumnObjects.size() : 0);
          if (colCount > 0)
          {
            println(tabs+1, "--> associatedColumnObjects ")//NOI18N
            for (int j = 0; j < colCount; j++)
            {
              ColumnPairElement fce = (ColumnPairElement) associatedColumnObjects.get(j);
              ColumnElement rce = (fce!=null)?fce.getReferencedColumn():null;
              println(tabs+1, "[" + j + "] " + fce + " -> " + rce)//NOI18N
            }
            println(tabs+1, "<-- associatedColumnObjects ")//NOI18N
          }
        }
View Full Code Here

TOP

Related Classes of org.netbeans.modules.dbschema.ColumnElement

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.