How to get column name from a relationship

Hi,

I am developpign a plugin for VP that focus on ORM diagram.

Given a relation (IDBForeignKey that I got from the IDBTable.toRelationshipIterator function), I would like to get the column to which this relation is connected (on both side of the relation).

I was able to get the phrase, the multiplicity and other things, but not the column name.

Thanks for your help.

Alexandre

Hi Alexandre,

I’m sorry for my late reply. We enhanced to add IDBForeignKey.foreignKeyColumnsIterator() : Iterator in our latest build, so that you can get the column to which this relation is connected.
Please download the latest patch from the following link and refer to the sample code below:

Patch
http://files2.visual-paradigm.com/200810/Patch/sp1_20080920e/VP_Suite_Windows_3_3_sp1_20080920e.exe

 
      IDBForeignKey foreignKey = ...
      Iterator iter = foreignKey.foreignKeyColumnsIterator();
      while (iter.hasNext()) {
        IDBColumn toColumn = (IDBColumn) iter.next();
        Iterator constraints = toColumn.foreignKeyConstraintIterator();
        while (constraints.hasNext()) {
          IDBForeignKeyConstraint constraint = (IDBForeignKeyConstraint) constraints.next();
          if (foreignKey.equals(constraint.getForeignKey())) {
            IDBColumn fromColumn = constraint.getRefColumn();

            PRINT(">> " + fromColumn.getName() + ", " + toColumn.getName());
          }
        }
      }
 

With the above code and the diagram as shown below,
there will be 2 PRINT:

Column, EntityColumn
Column4, EntityColumn4

If there is anything I can do to help, please do not hesitate to contact me.

Best regards,
Lilian Wong

image.png

Hi Lilian,

Thanks for the answer.

I am running Visual Paradigm on Mac OS. Do you have the same patch sor the Mac OS version?

Alexandre

Hi Kryten,

Sorry for your late reply. I’m sorry that I did not know you are using Mac OS X, please download the patch for Mac from the link below:
http://files2.visual-paradigm.com/200810/Patch/sp1_20080920f/VP_Suite_MacOSX_3_3_sp1_20080920f.dmg

If there is anything else I can help, please do not hesitate to ask.

Best regards,
Lilian Wong

I tried your code, it works.

Thanks for your help.

Alexandre

Hi Alexandre,

You are welcome. If you need any help again, please feel free to ask.

Best regards,
Lilian Wong