SYNTAX

<Entity>.clone[<Expression1>,<Expression2>…]

Copies the specified Entity and its attribute values to a new Entity where Expressions (in the form attribute=value) override the corresponding cloned attribute values. The new Entity has no associations. Where an Entity specifies an Entity Identity, that identity is not copied to its clone entity. For each Entity in Collection, the operator creates a duplicate of Entity. The implementation is a shallow clone -- associations are not duplicated.
Note: If the cloned entity is database-enabled and contains primary keys, the primary key values must be specified in the qualifier clause or an exception will occur. If an Entity uses a Datastore Identity as its Identity Strategy, a new identifier is created by the database for each clone.

Null values in the attribute set expressions - When there are any null attributes on the right hand side of a clone assignment expression, the assignment does not occur. For example, in A.clone[attr=B.attr] where B.attr is null, it will not override the value of the cloned A.attr. There are cases where the null result is preferred. In a Studio's brms.properties you can add the property com.corticon.reactor.rulebuilder.DisableNullCheckingOnClone=true so that the null checks are removed. In the example, the value of the cloned A.attr will be null. Be aware that using this setting on a Studio machine should be applied on any other machine that will work on a related project.

The Operators row in the table of Summary Table of Vocabulary Usage Restriction does not apply. Special exceptions: clone may only be used in Action Rows (section 5 in Sections of Rulesheet that correlate with usage restrictions).

Nested clone calls are not supported, such as E1.clone[assoc1 += E1.assoc1.clone[…]].

The following Rulesheet uses .clone to create a new Entity2 element when the value of qtyOrdered in Entity1 is greater than the qtyShipped value. An alias is not required by the .clone operator, because it is possible to create a new entity at the root level, without inserting it into a collection. 

A sample Ruletest provides two collections of Entity1. Input, Output, and Expected panels are as follows:

RULESHEET EXAMPLE: COLLECTION

The following Rulesheet uses .clone to create a new Entity2 element in collection1 when Entity1 has a non-zero qtyOrdered value.

A sample Ruletest provides three collections of Entity1. Input and Output panels are illustrated below: