use of org.netbeans.modules.dbschema.ColumnElement in project Payara by payara.
the class DumpMapping method printMappingFieldElements.
public static void printMappingFieldElements(int tabs, ArrayList fields) {
final int count = ((fields != null) ? fields.size() : 0);
if (count > 0) {
// NOI18N
println(tabs, "--> fields ");
for (int i = 0; i < count; i++) {
MappingFieldElementImpl mfe = (MappingFieldElementImpl) fields.get(i);
// NOI18N
println(tabs, "[" + i + "] " + mfe.getClass());
// NOI18N
println(tabs + 1, "name = " + mfe.getName());
// NOI18N
println(tabs + 1, "fetchGroup = " + mfe.getFetchGroup());
// NOI18N
println(tabs + 1, "columns = " + mfe.getColumns());
if (!(mfe instanceof MappingRelationshipElement)) {
// NOI18N
println(tabs + 1, "columnObjects = " + mfe.getColumnObjects());
} else {
MappingRelationshipElementImpl mre = (MappingRelationshipElementImpl) mfe;
ArrayList columnObjects = mre.getColumnObjects();
int colCount = ((columnObjects != null) ? columnObjects.size() : 0);
if (colCount > 0) {
// NOI18N
println(tabs + 1, "--> columnsObjects ");
for (int j = 0; j < colCount; j++) {
ColumnPairElement fce = (ColumnPairElement) columnObjects.get(j);
ColumnElement rce = (fce != null) ? fce.getReferencedColumn() : null;
// NOI18N
println(tabs + 1, "[" + j + "] " + fce + " -> " + rce);
}
// NOI18N
println(tabs + 1, "<-- columnsObjects ");
}
// NOI18N
println(tabs + 1, "associatedColumns = " + mre.getAssociatedColumns());
ArrayList associatedColumnObjects = mre.getAssociatedColumnObjects();
colCount = ((associatedColumnObjects != null) ? associatedColumnObjects.size() : 0);
if (colCount > 0) {
// NOI18N
println(tabs + 1, "--> associatedColumnObjects ");
for (int j = 0; j < colCount; j++) {
ColumnPairElement fce = (ColumnPairElement) associatedColumnObjects.get(j);
ColumnElement rce = (fce != null) ? fce.getReferencedColumn() : null;
// NOI18N
println(tabs + 1, "[" + j + "] " + fce + " -> " + rce);
}
// NOI18N
println(tabs + 1, "<-- associatedColumnObjects ");
}
}
}
// NOI18N
println(tabs, "<-- fields ");
}
}
use of org.netbeans.modules.dbschema.ColumnElement in project Payara by payara.
the class SelectQueryPlan method processParentField.
/**
* Sets the plan's parent field and adds the tables for the join columns
* to the table list. The parent field is identified by <code>fieldName</code>
* and defined in the model information of the parent class
* <code>parentConfig</code>.
*
* @see ClassDesc
*/
private void processParentField(ClassDesc parentConfig, String fieldName) {
if (parentField == null) {
// The plan has not been processed before
FieldDesc f = parentConfig.getField(fieldName);
if (f == null || !(f instanceof ForeignFieldDesc)) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.constraint.unknownfield", fieldName, parentConfig.getPersistenceCapableClass().getName()));
}
parentField = (ForeignFieldDesc) f;
// Add the join table, if neccessary.
if (parentField.useJoinTable()) {
//
for (int i = 0; i < parentField.assocLocalColumns.size(); i++) {
ColumnElement col = (ColumnElement) parentField.assocLocalColumns.get(i);
addQueryTable(col.getDeclaringTable(), config);
}
}
// 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);
}
}
}
use of org.netbeans.modules.dbschema.ColumnElement in project Payara by payara.
the class SelectStatement method generateAnsiJoin.
/**
* Generates an ANSI compliant join. The columns for the join
* condition end up in the from clause. The joined tables
* are added indirectly to the member variable tableList by
* being added to {@link QueryTable#nextTable} associated with
* the "from-" table.
*
* @param jnode Join constraint.
* @param opCode Join operation.
* @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);
// Process the on clause.
if (toTable.onClause == null) {
toTable.onClause = new StringBuffer();
}
// NOI18N
appendJoinCondition(toTable.onClause, fromTable, toTable, fromColumn, toColumn, "=");
fromTable.joinOp = opCode;
}
}
use of org.netbeans.modules.dbschema.ColumnElement in project Payara by payara.
the class ClassDesc method getLocalFieldDesc.
LocalFieldDesc getLocalFieldDesc(ColumnElement column) {
LocalFieldDesc result;
for (int i = 0; i < 2; i++) {
ArrayList theFields = null;
if (i == 0) {
theFields = fields;
} else {
theFields = hiddenFields;
}
if (theFields != null) {
for (int j = 0; j < theFields.size(); j++) {
FieldDesc f = (FieldDesc) theFields.get(j);
if (f instanceof LocalFieldDesc) {
result = (LocalFieldDesc) f;
for (int k = 0; k < result.columnDescs.size(); k++) {
ColumnElement c = (ColumnElement) result.columnDescs.get(k);
// if (c.equals(column))
if (c.getName().getFullName().compareTo(column.getName().getFullName()) == 0) {
// searching.
if ((f.getTrackedFields() != null) && ((f.sqlProperties & FieldDesc.PROP_PRIMARY_TRACKED_FIELD) == 0)) {
continue;
}
return result;
}
}
}
}
}
}
// If we didn't find the field associated with the column, we need to
// create a hidden field and add it to the hiddenFields list.
result = createLocalHiddenField(column);
return result;
}
use of org.netbeans.modules.dbschema.ColumnElement in project Payara by payara.
the class ClassDesc method initializeJoinTables.
private void initializeJoinTables() {
Iterator iter = foreignFields.iterator();
while (iter.hasNext()) {
ForeignFieldDesc ff = (ForeignFieldDesc) iter.next();
if (ff.useJoinTable()) {
TableElement joinTable = ((ColumnElement) ff.assocLocalColumns.get(0)).getDeclaringTable();
TableDesc joinTableDesc = findTableDesc(joinTable);
if (joinTableDesc == null) {
joinTableDesc = new TableDesc(joinTable);
// Mark this table as a join table
joinTableDesc.setJoinTable(true);
addTableDesc(joinTableDesc);
}
}
}
}
Aggregations