How You Use Connectors

You use the connectors that you created in your model structure to make connections, during a runtime configuration session, with items outside the structure of your model.

In this example, users who are ordering a car may want to also order a trailer to use with the car.

Here are the entities used in this example, and the roles they play in adding a trailer to an order for a car:

Entity

Role

Configurator model

The car being ordered. The example model is:

CAR4DRSDN - 4 Door Sedan

Item class

The class of orderable trailers, created in the Product Information Management work area. The example item class is:

Trailers - Trailers

Standard items

The set of orderable trailers, created as items of the Trailers item class, in the Product Information Management work area. The example set of standard items is:

2WHL_BSTL_TRLR_CRT - 2 Wheel Black Steel Trailer Cart

4WHL_BSTL_TRLR_CRT - 4 Wheel Black Steel Trailer Cart

CO_TRLR - Carry-On Trailer

HDHM_CARGO_TRLR - Heavy Duty Hitch Mount Cargo Carrier

WM_UTIL_TRLR - Wire Mesh Utility Trailer with Ramp Gate

Snapshots

The snapshots are the copies of the item class and its standard items, with the same names, imported into the Configurator Models work area.

Connector

The connector provides the basis for connecting the car model to the standard items in the Trailers item class. The example connector is:

Trailer Connector

Option feature and options

In the absence of UI templates for connected items, the option feature and its options represent the imported item class and its items.

The example option feature has the same name as the item class: Trailers

The options have the same names as the items, such as: HDHM_CARGO_TRLR

Text feature

The text feature holds the name of the option feature's option that the user selects at runtime, and represents the connected item. The example text feature is:

Selected Trailer Item

Statement rule

Sets the value of the text feature to be the name of the option feature option (representing the connected item) selected at runtime. The example statement rule is:

Updated Selected Trailer Item

Extension rule

Adds a connectable item to the configuration, using the name of the selected option feature option to connect to the corresponding standard item. The example extension rule is:

Add Trailer

The steps to put these elements of the example together are:

  1. Import the snapshots.

  2. Create the supplemental structure.

  3. Create the statement rule.

  4. Create the connector.

  5. Create the extension rule.

  6. Test the model.

Import the Snapshots

On the Manage Snapshots page of the Configurator Models work area, select Import Items Associated with an Item Class from the Actions menu.

The data shown in this example is hypothetical, for demonstration purposes.

  • Search for and select the item class: Trailers.

  • Don't select the Include items associated with child item classes option. so that the import contains only the items associated with the Trailers item class, and not from its child item classes.

The resulting imported standard items include:

  • HDHM_CARGO_TRLR - Heavy Duty Hitch Mount Cargo Carrier

  • WM_UTIL_TRLR - Wire Mesh Utility Trailer with Ramp Gate

  • And so on

Create the Supplemental Structure

Since there's currently no predefined user interface support for connectors, you can represent the Trailer item class as an option feature, and the associated items as its options. You can modify the default user interface for the options as desired, for instance by using selectable images for the options. At runtime, the end user can select these options in the user interface and an extension rule adds the actual related items to the running summary.

In the CAR4DRSDN model, create an option feature and its options, with these settings:

  • Name: Trailers. For clarity, this is the same name as the item class.

  • Minimum Selections: 0

  • Maximum Selections: 1

  • Create an option that matches the name of each of the standard items in the Trailers item class, such as HDHM_CARGO_TRLR. You can use ADFdi integration to create the options, if there are a large number of them.

In the CAR4DRSDN model, create a text feature with these settings:

  • Name: Selected Trailer Item

  • Maximum Length: 100 (or whatever is long enough to accommodate the names of your standard items).

Create the Statement Rule

In the CAR4DRSDN model, create a statement rule, with these settings:

  • Name: Updated Selected Trailer Item

  • Rule Class: Constraint

  • In the Rule Text, create a series of REQUIRES statements, one for each option of the Trailers option feature.

    • On the left-hand side of the rule, insert an option of the Trailers option feature.

    • On the right-hand side of the rule, insert the text feature, Selected Trailer Item, and assign the name of the Trailers option as its value.

The CDL statements in the Rule Text field should look like this:

Copy'CAR4DRSDN'.'Trailers'.'HDHM_CARGO_TRLR'  REQUIRES 'CAR4DRSDN'.'Selected Trailer Item' = "HDHM_CARGO_TRLR";
'CAR4DRSDN'.'Trailers'.'CO_TRLR' REQUIRES 'CAR4DRSDN'.'Selected Trailer Item' = "CO_TRLR";
'CAR4DRSDN'.'Trailers'.'WM_UTIL_TRLR' REQUIRES 'CAR4DRSDN'.'Selected Trailer Item' = "WM_UTIL_TRLR";
'CAR4DRSDN'.'Trailers'.'2WHL_BSTL_TRLR_CRT' REQUIRES 'CAR4DRSDN'.'Selected Trailer Item' = "2WHL_BSTL_TRLR_CRT";
'CAR4DRSDN'.'Trailers'.'4WHL_BSTL_TRLR_CRT' REQUIRES 'CAR4DRSDN'.'Selected Trailer Item' = "4WHL_BSTL_TRLR_CRT";

When the end user at runtime selects an option of the Trailers option feature (such as 'HDHM_CARGO_TRLR'), the rule sets the value of the text feature Selected Trailer Item to the name of the trailer standard item (which would be "HDHM_CARGO_TRLR"). This name is used to create a connector instance that specifies that standard item.

The rule code shown in the example is designed primarily for clarity.

Create the Connector

In the CAR4DRSDN model, create a connector under the root node, with these settings:

Field

Value

Name

Trailer Connector

Target Type

Item Class

Target

Trailers

Minimum Connections

0

Maximum Connections

1

Minimum Quantities

1

Maximum Quantities

1

The characteristics defined in the connector node govern the behavior of the items related through the connector at runtime:

  • The target type governs which set of related items are connectable to the model. For a connector whose target type is item class, the set of related items is the set of items associated with that item class.

  • The minimum and maximum connections govern how many different standard items from the target item class can be added to this configuration. In this example, that means how many different trailers can be added to the configuration of the car. Because you only want to allow one trailer per car, you set Maximum Connections to 1. To make the addition of a trailer to the configuration optional, you set Minimum Connections to zero.

  • The minimum and maximum quantities govern the sum of all the quantities of standard items in the target item class.

  • In this example, that means how many total trailers can be added to the configuration of the car. Again, because you only want to allow one trailer per car, you set both Minimum Quantities and Maximum Quantities to 1

Create the Extension Rule

In the CAR4DRSDN model, create an extension rule, with these settings:

Field

Value

Name

Add Trailer

Base Node

The text feature Selected Trailer Item.

The statement rule sets the value of this feature to the name of the standard item that's selected at runtime.

Instantiation Scope

Instance

Rule Text

Enter the Groovy code sample that follows this table. You can reuse this code for other connectors, with the substitution of your connector name for the name in this example.

Event

postValueChange

Event Scope

Base node

Class

ScriptClass

Method

run()

Enter this Groovy code in the Rule Text field:

Copyconfig = cxEvent.configuration
root = config.getRootBomModel()
baseNode = cxEvent.baseNode;
// Retrieve the connector definition from the root model
connPort = root.getChildByName("Trailer Connector");
// Check to see if the connector has any connector instances
if (connPort.getInstanceCount() == 0) {
  // If not then add an instance
  instance = connPort.addInstance();
}
// Retrieve the connector instance
instance = connPort.getInstances().get(0)
// Set its quantity to 1
instance.quantity = 1;
// If the connector instance has an existing connected item defined, then remove it
instance.unsetType();
// Set the connector instance to the new connected item
instance.setType(instance.getAvailableLeafType(baseNode.getTextValue()));

The following statement locates the connector you created, by its name:

CopyconnPort = root.getChildByName("Trailer Connector");

When adapting this example to your own scenario, replace the name of the example connector node (Trailer Connector) with your own connector node name.

The following statement sets the type of the new connector instance, by using the name of the option corresponding to an imported standard item snapshot (in other words, to the standard item):

Copyinstance.setType(instance.getAvailableLeafType(baseNode.getTextValue()));