Create and manage domain objects

更新时间:
复制 MD 格式

Domain object design involves defining aggregates, aggregate roots, entity objects, and value objects. A domain object consists of object attributes, object relations, and object behaviors. This topic describes how to create, edit, and delete domain objects in the panel. You can also perform these operations using the domain object designer.

Prerequisites

Create a domain object

  1. Log in to BizWorks, in the select Platform drop-down list selected modeling Platform.

  2. Click the a7.pngicon or the text box in the upper-right corner of the page. From the drop-down list, click the name of the project that you want to view and click the Modeling tab. In the Modeling navigation bar, choose Technical Modeling > Bounding Context.

  3. On the Bounding Context page, click the name of the bounding context.

  4. In the navigation pane for the bounded context, click Domain Object.

  5. On the Domain Object page, create a domain object.

    1. Click Create Domain Object.

    2. In the Create Domain Object panel, configure Basic information.

      Table 1. Basic information

      Parameter

      Description

      Object name

      A custom name for the domain object. The name cannot exceed 100 characters.

      Code

      A combination of letters and digits that is unique within the bounded context. The code must start with an uppercase letter and cannot exceed 80 characters.

      Object type

      Select entity object or value object from the drop-down list.

      Aggregate root

      Select this option to set the current domain object as an aggregate root.

      Note
      • If you set Object type to entity object, Aggregate root is selected by default.

      • If you set Object type to value object, this parameter is not displayed.

      Description

      An optional description of the domain object.

      After you configure the basic information, you can click Create and then click Edit in the Actions column to configure other settings. Alternatively, you can proceed to the next step and save all the configurations at once.

    3. Click the Object attributes tab and then click Add object attribute. The tab displays an empty attribute list. Configure the parameters.

      Table 2. Domain object attributes

      Parameter

      Description

      Field name

      A custom name for the object attribute.

      Code

      A combination of letters and digits that is unique within the domain object. The code must start with a lowercase letter and cannot exceed 80 characters.

      Data type

      Select a data type from the drop-down list:

      • Basic type: For example, String, Integer, and Boolean.

      • Collection type: For example, List , Set , and Map .

        • List and Set collection types support nesting. In the Data Type drop-down list, you can select the nested type from the cascading menu.

        • For Map collection types, you can customize the Key and Value, but Map nesting is not supported. A configuration panel appears where you can select the types and click OK.

      • Object type: A domain object that is already defined in the current bounded context.

      • Create New Domain Object: You can create a new domain object and configure it as the Data Type for an Object Attribute.

      Description

      An optional description of the object attribute.

      After you add an attribute, it appears in the list on the Object attributes tab, where you can edit or delete it.

      Hover over the image icon to view the relationships associated with the object attribute.

    4. Click the Object behaviors tab and then click Add object behavior to configure the parameters.

      Table 3. Object behavior parameters

      Parameter

      Description

      Behavior name

      A custom name for the object behavior.

      Code

      A combination of letters and digits that is unique within the domain object. The code must start with a lowercase letter and cannot exceed 80 characters.

      Description

      An optional description of the object behavior.

      Behavior input parameters

      Click Add to configure input parameters. You can add multiple input parameters. For more information, see Behavior input parameters.

      Behavior output parameter

      Click Add to configure an output parameter. You can add only one output parameter. If you do not configure an output parameter, the return value is void.

      Table 4. Behavior input parameters

      Parameter

      Description

      Parameter name

      A custom name for the behavior input parameter.

      Code

      A combination of letters and digits that is unique within the object behavior. The code must start with a lowercase letter and cannot exceed 80 characters.

      Parameter type

      Select a parameter type from the drop-down list:

      • Basic type: For example, Boolean, Byte, and Short.

      • Collection type: For example, List , Set , and Map .

      • Object type: A domain object that is already defined in the current bounded context.

      • Create Domain Object: You can create a domain object and configure it as a Behavior Input Parameter's Parameter Type.

      Required

      Select this option to make the parameter required.

      Description

      An optional description of the behavior input parameter.

      After you configure a behavior, it appears in the list on the Object behaviors tab, where you can Edit or Delete it.

    5. Click the Object relations tab, and then click Add domain object relationship. In the Domain object relationship dialog box, configure the parameters and click OK.

      Table 5. Domain object relationship

      Parameter

      Description

      Relation type

      From the drop-down list, select association, aggregate, composition, or inheritance. For information about the rules for setting object relations, see Object relationship rules.

      Multiplicity

      Select 1 : 0..*, 1 : 1..*, 1 : 0..1, or 1 : 1 from the drop-down list.

      • 1 : 0..*: A one-to-many relationship where the target can have zero or more instances.

      • 1 : 1..*: A one-to-many relationship where the target must have at least one instance.

      • 1 : 0..1: A one-to-one relationship where the target can have zero or one instance.

      • 1 : 1: A one-to-one relationship where the target must have exactly one instance corresponding to the source.

      Note

      Multiplicity is not supported for inheritance relationships. For detailed configuration logic, see Object relationship multiplicity rules.

      Target object

      A domain object that is already defined in the current bounded context.

      Relation name

      A custom name for the object relation.

      Code

      A combination of letters and digits that is unique within the domain object. The code must start with a lowercase letter and cannot exceed 80 characters.

      Description

      An optional description of the object relation.

      Table 6. Object relationship rules

      Scenario

      Association

      Aggregate

      Composition

      Inheritance

      domain model A -> domain model A

      Allowed. Multiple relationships can be created.

      Not allowed.

      Not allowed.

      Not allowed.

      domain model A -> domain model B

      Allowed. Multiple relationships can be created.

      Allowed. Multiple relationships can be created.

      Allowed. Multiple relationships can be created.

      Allowed. An object can have only one inheritance relationship.

      Note

      Circular inheritance is not allowed. For example, if object B inherits from object A, object A cannot inherit from object B. Similarly, if object B inherits from object A and object C inherits from object B, object A cannot inherit from object C. The same logic applies to other scenarios.

      Table 7. Object relationship multiplicity rules

      Object relation

      1 : 0..*

      1 : 1..*

      1 : 0..1

      1 : 1

      Association

      Applicable

      Applicable

      Applicable

      Applicable

      Aggregate

      Applicable

      Applicable

      Applicable

      Applicable

      Composition

      Applicable

      Applicable

      Applicable

      Applicable

      Inheritance

      Not applicable

      Not applicable

      Not applicable

      Not applicable

      After you configure a relation, it appears in the list on the Object relations tab, where you can Edit or Delete it.

  6. After you complete the configuration, click Create.

Edit a domain object

  1. In the list of domain objects, find the object that you want to edit and click Edit in the Actions column.

  2. In the Edit Domain Object panel, modify the settings and click Save.

Delete a domain object

  1. In the list of domain objects, find the object that you want to delete and click Delete in the Actions column.

  2. In the confirmation dialog box, click Delete.

Copy domain objects to other contexts

  1. In the list of domain objects, find the object that you want to copy and click Copy to Other Bounded Contexts in the Actions column.

  2. In the Copy Object to Target Bounded Context panel, configure the parameters. The panel has two sections: Target bounded context and Duplicate data rule configuration.

    • From the Target bounded context drop-down list, select the target bounded context and then select a version from its version list.

    • Set the rules for handling duplicate data. The supported strategies are skip duplicate data, overwrite existing data, and terminate data generation.

      Parameter

      Description

      Skip duplicate data

      • When generating structural objects and data models, if a code already exists, the system does not modify the names, codes, or any fields of the existing objects and models.

      • When generating application services, if a service code already exists, the system does not modify the service information. The system then checks for a method with the same code. If a match is found, the system does not regenerate the method or check its input and output parameters.

      Overwrite existing data

      • The system overwrites data that has a matching code, including its name and type.

      • Data outside the generation scope is retained.

      Terminate data generation

      If the code of any application service, method, structural object, or data model matches an existing one, the generation process stops immediately and no data is created.

    Note
    • This action copies the selected domain object to the domain model of the specified Target bounded context.

    • The copied information includes the domain object's name, code, and object type.

    • You cannot select the bounded context that contains the current object from the Target bounded context drop-down list.

    • If a duplicate object code is found, the system applies the data handling strategy you selected.

Import business objects

  1. On the Domain Object page, click Import business objects.

  2. In the Batch Import panel, select the names of the target business objects (multiple selections are supported), and then click Next.

    • You can import suitable business objects from the business domain associated with the bounded context. For example, in the Edit Bounded Context panel, set Business Domain to the target business domain. The panel lists business domains on the left and the corresponding business objects on the right.

    • For more information about how to associate business objects with a business domain, see Associate or disassociate business object categories.

  3. Set the import rules. The duplicate data handling strategies include skip duplicate data, overwrite existing data, and delete and create.

    Parameter

    Description

    Skip duplicate data

    During object generation, if an object with the same code already exists, the system skips that object and proceeds to the next.

    Overwrite existing data

    During object generation, if an object with the same code already exists, the system updates its name, attributes, and behaviors. Any new attributes or behaviors from the source are added to the target object. No data is deleted.

    Delete and create

    During object generation, if an object with the same code already exists, the system deletes the existing object and creates a new one.

    Note
    • Object name: The name of the business object.

    • Object code: The code of the business object.

    • Object type: entity object.

    • Object attributes: For the initial import, attributes match those of the business object. For subsequent imports, the system handles attributes according to the selected import rule.

    • Object attribute type: Business object attributes of type Text are imported as String, Number as Integer, and Time as Date.

    • Object behaviors: For the initial import, behaviors match those of the business object. For subsequent imports, the system handles behaviors according to the selected import rule.

  4. Click Import.