DraftOrganizationHandler: Handler
Item | Value |
---|---|
Briefly | Brief description missing. |
Definition Path | ImprovingApp.OrganizationContext.Organization.DraftOrganization.DraftOrganizationHandler |
View Source Link | organization.riddl(36:21) |
\nerror "Organization already established"
\n
\nset field DraftOrganizationState.info to "OrganizationContext.Info"set field DraftOrganizationState.orgMeta to "OrganizationContext.MetaInfo"send event OrganizationInfoEdited to outlet OrganizationEventsSource.Source
\n
{
"Update the parent field with the value provided in UpdateParent"
//TODO: should adjust this to reflect design pattern to provide children in a projector.
//TODO: The next two AND statements would be handled in the projection handler for ParentUpdated event
"remove organizationId from the list of children in the 'old' parent"
"add organizationId to the list of children in the 'new' parent"
"set MetaInfo to capture change data"
"yield event ParentUpdated"
} else {
if "newParent exists outside the bounds of the root organization that contains organizationId" then
{
error "Organization cannot leave the bounds of the root organization that it belongs to"
}
if "newParent exists below organizationId (child, grandchild, etc.) in the organizational hierarchy" then
{
error "New Parent cannot be a generational child of the organization being modified"
}
if "editingMember is not Authorized" then
{
error "EditingMember is not authorized to make this change."
}
}
```\n
### _OnMessageClause command AddMembersToOrganization_
#### Statements
```\nif "successful" then
{
"Merge new members into the member list. Duplicates not allowed."
"set MetaInfo to capture change data"
"emit MembersAddedToOrganization event"
}
//Restrictions not implemented yet
//example NewMemberDoesNotMeetRestrictions is {
//given "Member does not meet qualifictions to join organization"
//then "Place rejected member in dead letter queue and process remaining members"
//and "Consider how to notify of partial success" // TODO: discuss how this might work
//}
if "organizationId is a private organization and updatingMember is not an admin for organizationId" then
{
error "Only Admins for organizationId can admit new members"
}
if "Member in newMembers list is in state suspended" then
{
"place suspended member in dead letter queue and process remaining members"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "editingMember is not Authorized to add members to this organization" then
{
error "EditingMember is not authorized to make this change."
}
```\n
### _OnMessageClause command RemoveMembersFromOrganization_
#### Statements
```\nif "editingMember is authorized to remove members from this organization" then
{
"membersToRemove are purged from memberList"
"set MetaInfo to capture change data"
"yield MembersRemovedFromOrganization()"
} else {
error "EditingMember is not authorized to make this change."
}
```\n
### _OnMessageClause command AddOwnersToOrganization_
#### Statements
```\nif "successful" then
{
"Merge new owners into the owner list. Duplicates not allowed."
"set MetaInfo to capture change data"
"emit OwnersAddedToOrganization event"
} else {
if "Member in ownersToAdd is not in memberList of organizationId" then
{
"Place non-member owner in dead letter queue and finish processing remaining member owners"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "Member in ownersToAdd is in state Suspended" then
{
"Place suspended owner in dead letter queue and finish processing remaining member owners"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "Member in ownersToAdd is a type that is not allowed to be an owner" then
{
"Place non-compliant owner in dead letter queue and finish processing remaining member owners"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "editingMember is not Authorized" then
{
error "EditingMember is not authorized to make this change."
}
}
```\n
### _OnMessageClause command RemoveOwnersFromOrganization_
#### Statements
```\nif "successful" then
{
"ownersToRemove are purged from memberList"
"set MetaInfo to capture change data"
"yield OwnersRemovedFromOrganization()"
//TODO
} else {
if "editingMember is not Authorized" then
{
error "EditingMember is not authorized to make this change."
}
}
```\n
### _OnMessageClause command UpdateOrganizationContacts_
#### Statements
```\nif "successful" then
{
"Merge new contacts into the contacts list. Duplicates not allowed."
"set MetaInfo to capture change data"
"emit ContactsAddedToOrganization event"
} else {
if "Member in contactsToAdd is not in memberList of organizationId" then
{
"Place non-member contact in dead letter queue and finish processing remaining member contacts"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "Member in contactsToAdd is in state Suspended" then
{
"Place suspended contact in dead letter queue and finish processing remaining member owners"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "Member in contactsToAdd is a type that is not allowed to be a contact" then
{
//Only members of type ________ can be contacts for an organization???
"Place non-compliant contact in dead letter queue and finish processing remaining member contacts"
"Consider how to notify of partial success"
//TODO: discuss how this might work
}
if "editingMember is not Authorized" then
{
error "EditingMember is not authorized to make this change."
}
}
```\n
### _OnMessageClause command ActivateOrganization_
#### Statements
```\nif "all required fields in info are not None or Empty and required non-info fields are present" then
{
send event OrganizationEstablished to outlet OrganizationEvents.Events
morph entity Organization to state EstablishedOrganization with record EstablishedOrganizationState
} else {
if "all required fields in state are not present" then
{
"state is not sufficiently filled out to activate organization"
}
}
```\n
### _OnMessageClause query GetOrganizationInfo_
#### Statements
```\nreply record OrganizationInfo```\n
### _OnMessageClause query GetOrganizationParent_
#### Statements
```\nif "Parent field is present (non-empty)" then
{
reply result OrganizationParent
} else {
if "in Draft state and Parent is not empty in editableInfo" then
{
error "Parent field is not present in current state of Draft"
}
}
```\n
### _OnMessageClause query GetOrganizationMembers_
#### Statements
```\nif "Members field is present (non-empty)" then
{
reply result OrganizationMembers
} else {
if "in Draft state and Members is not empty in editableInfo" then
{
error "Members field is not present in current state of Draft"
}
}
```\n
### _OnMessageClause query GetOrganizationOwners_
#### Statements
```\nif "in Draft state and Owners is not empty in editableInfo" then
{
error "Owners field is not present in current state of Draft"
} else {
if "Owners field is present (non-empty)" then
{
reply record OrganizationOwners
}
}
```\n
### _OnMessageClause query GetOrganizationContacts_
#### Statements
```\nif "in Draft state and contacts is not empty in editableInfo" then
{
error "Contacts field is not present in current state of Draft"
} else {
if "Contacts field is present (non-empty)" then
{
reply result OrganizationContacts
}
}
```\n
### _OnMessageClause query GetOrganizationMeta_
#### Statements
```\nreply result OrganizationMeta```\n
### _OnMessageClause query GetOrganizationState_
#### Statements
```\nif "State field is present (non-empty)" then
{
reply record OrganizationState
}
```\n
### _On Other_
#### Statements
```\nerror "No other commands allowed in Draft state"```\n
## *Used By None*
## *Uses Nothing*