use of org.netbeans.modules.dbschema.ColumnPairElement 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.ColumnPairElement in project Payara by payara.
the class ClassDesc method initializeColumnLists.
private void initializeColumnLists(ForeignFieldDesc ff, MappingRelationshipElementImpl fmdf) {
ArrayList assocPairs = fmdf.getAssociatedColumnObjects();
ArrayList pairs = fmdf.getColumnObjects();
ArrayList localColumns = new ArrayList();
ArrayList foreignColumns = new ArrayList();
// We need to go through each local column and extract the foreign column.
if ((assocPairs == null) || (assocPairs.size() == 0)) {
for (int i = 0; i < pairs.size(); i++) {
ColumnPairElement fce = (ColumnPairElement) pairs.get(i);
localColumns.add(fce.getLocalColumn());
foreignColumns.add(fce.getReferencedColumn());
}
ff.localColumns = localColumns;
ff.foreignColumns = foreignColumns;
} else {
ArrayList assocLocalColumns = new ArrayList();
ArrayList assocForeignColumns = new ArrayList();
for (int i = 0; i < pairs.size(); i++) {
ColumnPairElement alc = (ColumnPairElement) pairs.get(i);
localColumns.add(alc.getLocalColumn());
assocLocalColumns.add(alc.getReferencedColumn());
}
for (int i = 0; i < assocPairs.size(); i++) {
ColumnPairElement afc = (ColumnPairElement) assocPairs.get(i);
assocForeignColumns.add(afc.getLocalColumn());
foreignColumns.add(afc.getReferencedColumn());
}
ff.localColumns = localColumns;
ff.assocLocalColumns = assocLocalColumns;
ff.assocForeignColumns = assocForeignColumns;
ff.foreignColumns = foreignColumns;
}
}
use of org.netbeans.modules.dbschema.ColumnPairElement in project Payara by payara.
the class ClassDesc method createSecondaryTableKey.
private void createSecondaryTableKey(TableDesc table, MappingReferenceKeyElementImpl mappingSecondaryKey) {
ColumnPairElement[] pairs = mappingSecondaryKey.getColumnPairs();
KeyDesc referencingKey = new KeyDesc();
KeyDesc referencedKey = new KeyDesc();
TableDesc secondaryTable = findTableDesc(((MappingTableElementImpl) mappingSecondaryKey.getTable()).getTableObject());
for (int i = 0; i < pairs.length; i++) {
ColumnPairElement pair = pairs[i];
ColumnElement lc = pair.getLocalColumn();
ColumnElement fc = pair.getReferencedColumn();
referencingKey.addColumn(lc);
FieldDesc lf = getLocalFieldDesc(lc);
referencingKey.addField(lf);
// We need to force field for the referencing key to be in the DFG
// so it will always be loaded. This is to facilitate updating
// secondary tables that requires this field to be loaded
// for constraint purposes.
lf.fetchGroup = FieldDesc.GROUP_DEFAULT;
referencedKey.addColumn(fc);
referencedKey.addField(getLocalFieldDesc(fc));
}
table.addSecondaryTableKey(new ReferenceKeyDesc(secondaryTable, referencingKey, referencedKey));
secondaryTable.setPrimaryTableKey(new ReferenceKeyDesc(table, referencedKey, referencingKey));
}
Aggregations