Creating the modifiable adapter

Next you must declare and define the modifiable adapter for the modifiable entity in the new line of business. The modifiable adapter contains methods for a modifiable object, such as methods to add and remove modifiers. The Golf Cart line needs two modifiable entities, GolfCartLine and GOCart. The following steps explain how to define the GOModifiers entity that provides coverage for the GolfCartLine.

Important: To create the modifier adapter that connects the modifier to the modifiable object, see Creating the modifier adapter.

Declare modifiable adapter on the modifiable entity

About this task

Declare the modifiable adapter for the new line of business.

Procedure

  1. In Studio, open the modifiable object.
    For Golf Cart, open GolfCartLine.eti in configuration > config > metadata > entity.
  2. Define the modifier subtype as an array from the modified entity with the following properties:

    Property

    Value

    name

    GOModifiers

    arrayEntity

    GOModifier

    desc

    Rating information for the line

  3. Declare a modifiable delegate. The modifiable delegate connects the modifiable entity with the modifier.
    For the Golf Cart line, use the Studio Entity editor to add an implementsEntity element to the entity definition in GolfCartLine.eti:

    Property

    Value

    name

    Modifiable

  4. Add an implementsInterface element to the modifiable entity. This element references the Gosu class that defines the adapter methods and properties.
    For the Golf Cart line, enter the following values:

    Property

    Value

    name

    gw.api.domain.ModifiableAdapter

    adapter

    gw.lob.go.GOLineModifiableAdapter

What to do next

Create the modifiable adapter

Create the modifiable adapter

Before you begin

Declare modifiable adapter on the modifiable entity

About this task

After you declare the modifiable adapter for the new line of business, you must write the code for the adapter. Auto-complete in Studio helps you write the code. Create modifiable adapters for each modifiable object. For Golf Cart, create modifiable adapters for GolfCartLine and GOCart.

Procedure

  1. In the Project window in Studio, navigate in configuration > gsrc to the gw.lob.package package.
    For Golf Cart, navigate to gw.lob.go.
  2. Right click the package node, and then select New > Gosu Class.
  3. Enter the name of the adapter. You specified the name of the adapter in the implementsEntity element in the preceding procedure.
    For the GolfCartLine entity, the name of the modifiable adapter is GOLineModifiableAdapter.
    Note: Modifier instantiation is usually handled in the same manner as coverages using the gw.web.productmodel.ProductModelSyncIssuesHandler methods.
  4. In the new Gosu class, write a constructor for the modifiable adapter.
    For example, the Golf Cart modifiable adapter, GOLineModifiableAdapter, code is.
    package gw.lob.go
    uses gw.api.domain.ModifiableAdapter
    uses java.util.Date
     
    class GOLineModifiableAdapter implements ModifiableAdapter {
      var _owner : GolfCartLine
      
      construct(owner : GolfCartLine) {
        _owner = owner
      }
    }

    This code produces a Gosu error in the class statement that you fix in the next step.

  5. Place the insertion point at the error (after ModifiableAdapter) and press Alt-Enter. Click the ImplementMethods command that pops up to open the Select Methods to Implement dialog box. With all listed methods selected, click OK to insert the empty methods into your code.
  6. Write code for the new methods and properties. In most cases, the code for each method is a single line. Examine the modifier adapters for other lines of business as an example.

What to do next

Create the coverable modifiable adapter

Create the coverable modifiable adapter

Before you begin

Create the modifiable adapter

About this task

Create the coverable modifiable adapter for the new line of business. If the entity is both and coverable and modifiable, then you must define a class that aggregates the implementations of gw.api.domain.CoverableAdapter and gw.api.domain.ModifiableAdapter. These interfaces have overlapping methods, so you must implement them in a single class.

Procedure

  1. In the coverable and modifiable entity, in implementsInterface for the CoverableAdapter, change impl to gw.lob.go.GOLineCoverableModifiableAdapter.
  2. In implementsInterface for the ModifiableAdapter, change impl to gw.lob.go.GOLineCoverableModifiableAdapter.
  3. Using GLLineCoverableModifiableAdapter.gs as a model, create the adapter for the Golf Cart line.
  4. At this point, you can verify your work. For instructions, see Verify your work.