Package com.orchestranetworks.userservice.schema

# Interface UserServiceAssociationRecordFormFactory

public interface UserServiceAssociationRecordFormFactory
This interface defines a factory to create a `UserService` replacing the default record form in the context of an associated object to be created or accessed.

### Definition in the data model

The factory must be declared under the element `<osd:association>`. For example:

>      <xs:annotation>
>        <xs:appinfo>
>          <osd:association>
>            <recordForm osd:class="com.foo.MyFactory"/>
>            ...
>          </osd:association>
>        </xs:appinfo>
>      </xs:annotation>

where `com.foo.MyFactory` is the fully qualified name of a class implementing this interface. The declaration may also use parameters:

>      <recordForm class="com.foo.MyFactory">
>             <param1>...</param1>
>             <param2>...</param2>
>      </recordForm>

where `param1` and `param2` are JavaBean properties of the `com.foo.MyFactory` class.

For more information, see the JavaBean specification.

### Life cycle

1. If the concrete factory is referenced by a data model element, then, when the data model is loaded:
   1. the specified factory class is instantiated through its default constructor and the setters of the JavaBean properties are called (in the example above, `setParam1(...)` and `setParam2(...)`);
   2. then, the method `setup(UserServiceAssociationRecordFormFactoryContext)` is called for the new instance).
2. During the operational phase: the method:
   - `newUserServiceForCreate(UserServiceAssociationRecordFormContext.ForCreate)` is called each time a record view must be displayed for creating a record in the context of an association.
   - `newUserServiceForDefault(UserServiceAssociationRecordFormContext.ForDefault)` is called each time a record view must be displayed for modifying a record in the context of an association.
   - `newUserServiceForDuplicate(UserServiceAssociationRecordFormContext.ForDuplicate)` is called each time a record view must be displayed for duplicating a record in the context of an association.

Since:
  5.9.0
See Also:
  - `UserServiceRecordFormFactory`
  - `AssociationLink.getRecordFormFactoryClass()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `UserService<AssociationEntitySelection>`
  `newUserServiceForCreate(UserServiceAssociationRecordFormContext.ForCreate aContext)`
  Creates and returns a new instance of `UserService` for creating a record in the context of an association.
  `UserService<AssociationRecordEntitySelection>`
  `newUserServiceForDefault(UserServiceAssociationRecordFormContext.ForDefault aContext)`
  Creates and returns a new instance of `UserService` for displaying a record on consultation or on modification in the context of an association.
  `UserService<AssociationRecordEntitySelection>`
  `newUserServiceForDuplicate(UserServiceAssociationRecordFormContext.ForDuplicate aContext)`
  Creates and returns a new instance of `UserService` for duplicating a record in the context of an association.
  `void`
  `setup(UserServiceAssociationRecordFormFactoryContext aContext)`
  This method is called when the data model is loaded.

- ## Method Details

  - ### newUserServiceForCreate

    UserService<AssociationEntitySelection> newUserServiceForCreate(UserServiceAssociationRecordFormContext.ForCreate aContext)
    Creates and returns a new instance of `UserService` for creating a record in the context of an association.

    If this method returns `null` then the default model-driven form will be used for creating a record.

    See Also:
      - `ServiceKey.CREATE`

  - ### newUserServiceForDefault

    UserService<AssociationRecordEntitySelection> newUserServiceForDefault(UserServiceAssociationRecordFormContext.ForDefault aContext)
    Creates and returns a new instance of `UserService` for displaying a record on consultation or on modification in the context of an association.

    If this method returns `null` then the default model-driven form will be used for displaying a record on consultation or on modification.

    See Also:
      - `ServiceKey.DEFAULT_SERVICE`

  - ### newUserServiceForDuplicate

    UserService<AssociationRecordEntitySelection> newUserServiceForDuplicate(UserServiceAssociationRecordFormContext.ForDuplicate aContext)
    Creates and returns a new instance of `UserService` for duplicating a record in the context of an association.

    If this method returns `null` then the default model-driven form will be used for duplicating a record.

    See Also:
      - `ServiceKey.DUPLICATE`

  - ### setup

    void setup(UserServiceAssociationRecordFormFactoryContext aContext)
    This method is called when the data model is loaded. It may be used to check that this factory supports the association that references it.

    Do note that during this step, all models may not be properly loaded. Thus, the repository should not be accessed during this step.