Events in the New Object Model

The Anthology object model defines a collection of classes and interfaces through which entities can be manipulated. An entity represents a person, place, or thing such as a course, task, or campaign. Entities only contain the properties associated with itself such as first name, last name, or city. The verbs associated with an entity (e.g. Save, PostFinalGrades, or AddToCampaign) are exposed by a corresponding service or EntityService.

EntityModel

All entities in Anthology inherit from the Cmc.Core.EntityModel.Entity abstract base class. The Entity base class contains all the logic required for maintaining the state of an entity and its children while it is being modified in business logic, on the client, or by an external system. Each entity is defined through its properties and the methods it supports. The exposed (public) properties and methods of an entity can be manipulated through workflows.

The following are examples of properties and methods that can be associated with an entity.

Properties

  • EntityState — gets or sets the state of an entity

    • Added — the entity is new, an INSERT database operation will be performed
    • Removed — the entity has been removed, a DELETE operation will be performed
    • Modified — the entity has been modified, an UPDATE database operation will be performed
    • Unchanged — the entity is unchanged, no database operation will be performed
  • ExtendedProperties — represents a collection of dynamic entity properties such as School Defined Fields.

  • ModifiedProperties — represents a read-only collection of property names that have been modified since the entity was last retrieved.

  • OriginalState — represents the entity’s original state serialized in a byte[]. This property is used to round-trip the entity state from the client to the server and is not intended to be updated directly in code.

  • OriginalValues — represents the original values of an entity as a dictionary.

Methods

  • AcceptChanges — accepts all current changes and sets the entity’s state to Unchanged. This does not perform a database operation.

  • GetOriginalValue — gets the original value of a specified property

  • HasChanged — returns true if an entity (or its children) have changed; else false

Events Raised by EntityState Changes

The EntityState property is exposed in many Anthology entities. This property supports create, retrieve, update, delete (CRUD) operations or commands. The create, update, and delete operations raise events associated with the affected entities. Workflows can be triggered by any create, update, or delete operation. Retrieve or get operations do not trigger events.

The CreateEntity<>, DeleteEntity<>, GetEntity<>, and SaveEntity<> activities in Workflow Composer under Cmc.Core.Workflow.Activities.EntityModel enable you to access the EntityState property of exposed entities and to manipulate and persist the state of an entity in the database.

Event Handlers

The object model provides event handlers for all entities. The event handlers support event services for each entity.

The Event Broker listens for incoming events from clients, determines the name of the event, forwards the event to the configured event handler, and, if required, returns a response to the event.

Event messages contain enough basic information to be handled without the need to retrieve additional data from APIs.

The events that are exposed to the Event Broker can be consumed in custom code (for example, C# event handlers) or workflows that automate tasks and enable data to be exchanged between systems.

Anthology events are grouped in the following categories:  

  • Constructed events enable new objects to be added to the database.
  • Deleting or Deleted events enable objects to be deleted.
  • Saving or Saved events enable objects to be inserted/updated.

Saving events and Deleting events are captured and visible at the UI level. VB .NET code is required to intercept these events. Typically, data validation occurs typically occurs. Saving and Deleting event workflows must be stored on the host that is running the application on which the event is captured, for example, Anthology Student.

Saved events and Deleted events are captured at the database trigger level when a transaction is committed to the database. These events are only visible in the event log of the Windows Service NextGen Nexus Event Workflows. Saved and Deleted event workflows must be stored on a host that has a direct database connection, for example, COM Server.

Constructed events enable new objects to be added. Constructed events are captured and visible at the UI level when the components of a record are assembled. No data validation occurs. VB .NET code is required to intercept these events.

EntityServices

The Anthology object model contains numerous entity services such as the Cmc.Nexus.Academics.Services that support custom commands. The Cmc.Nexus.Academics.Services, for example, raise the Cmc.Nexus.Academics.Events which contain custom commands related to the Academics module. The event handlers of the entities contain business logic applicable to the entities. The event handlers can be extended using workflows, for example workflows that send emails to advisors when a student unregisters from a class.

Selecting Events in Workflow Composer

The 'New Event Driven Workflow' window in Workflow Composer enables you to select the events that will trigger your workflow.

The Entities filter option Only show entity types that have the SupportedEvents attribute is selected by default. The SupportedEvents attribute indicates what type of events are supported by an entity or service. When any one of the supported events is enabled, the entity is visible to Workflow Composer and considered public.

The Events filter option Only show events supported by the selected entity type is also selected by default and makes it easier to find supported events after selecting an Entity.

The Entities pane below shows the entities in the Cmc.Nexus.Academics.Entities namespace. The Events pane shows the events that are available (Constructed, Deleted, Deleting, Saved, Saving events) when Student Course (StudentCourseEntity) is selected in the Cmc.Nexus.Academics.Entities namespace.

New Workflow - Entity selection

EntityServices are typically associated with custom events and business rules that apply to an entity. The events are associated with an EntityService are displayed in the Events pane when you select a service in the Entities pane.

The Entities pane below shows the services in the Cmc.Nexus.Academics.Entities namespace. The Events pane shows the events that are available (Register for Class Event, Transfer Class Section Event, and Unregister From Class Event) when Registration Service (IRegistrationService) is selected in the Cmc.Nexus.Academics.Entities namespace.

New Workflow - Service selection

The public Anthology Student entities and event services are documented in the Anthology Student Object Library. Use to the library to look up details about Anthology entities including classes, properties, event arguments, methods, and fields while building workflows.