Table of Contents

About

Page about Mapping Link

Snippet

Below are some sample java code to generate links connection.

This snippets work with the sample LinkExpression class from the Design API Sdk Sample.

PortLinkContextFactory

By Position

// From the linkFields
Vector<Field> linkFields = getLinkFields();
PortLinkContext portLinkContext = PortLinkContextFactory.getPortLinkContextByPosition( linkFields );
InputSet linkInputSet = new InputSet( dsqRS, portLinkContext );

By Name

// Work only if all ports are present in the two sides (for all port, no filter)
Vector<Field> linkFields = getLinkFields();
PortLinkContext portLinkContext = PortLinkContextFactory.getPortLinkContextByName(linkFields);
InputSet linkInputSet = new InputSet( dsqRS, portLinkContext );

By Map

 
Vector<Field> linkFields = getLinkFields();
Map<Field, Field> linkMap = new LinkedHashMap<Field, Field>();
System.out.println("LinkMap:");
Iterator<Field> myOutPutFieldIterartor = linkFields.iterator();
while (myOutPutFieldIterartor.hasNext()) {
    Field ToField = myOutPutFieldIterartor.next();
    System.out.print("   - ToField:"+ToField.getName());
    Field FromField = dsqRS.getField(ToField.getName());
    System.out.println(" -> FromField:"+FromField.getName());
    linkMap.put(FromField,ToField);
}
PortLinkContext portLinkContext = PortLinkContextFactory.getPortLinkContextByMap(linkMap);
InputSet linkInputSet = new InputSet( dsqRS, portLinkContext );

PortPropagationContextFactory

Exclude Columns

// excluded fields
String[] arrCols = {"BirthDate", "TitelOfCourtesy", "HireDate", "Address", "City", "Region", "PostalCode"};
PortPropagationContext myPortPropagationContext =  
    PortPropagationContextFactory.getContextForExcludeColsFromAll(arrCols);
InputSet linkInputSet = new InputSet( dsqRS, myPortPropagationContext );