OCLOperators transform
No edit summary
No edit summary
Line 1: Line 1:
object.transform(viewmodelname, <destination object>) uses the viewmodel to transform information from <object> into the <destination object>. Returns True if transform is full.
object.transform(viewmodelname, <destination object>) uses the viewmodel to transform information from <object> into the <destination object>. Returns True if transform is full.
The transform operator takes the object as the root of the viewmodel specified and use the viewmodel as a template to copy and create a new structure of objects.
The transform operator takes the object as the root of the viewmodel specified and use the viewmodel as a template to copy and create a new structure of objects.
=== Example of how to use ===
Often when sending an email you need to "collect" information from many objects to find all the information needed to create an outgoing email.
Using this model of an email queue lets see how objects of the OutgoingEmail and EmailAttachment can be created using transform.


[[File:EmailQueueClassDiagram.png|761x761px]]
[[File:EmailQueueClassDiagram.png|761x761px]]
This viewmodel will fill in the OutgoingEmail and EmailAttachment by name-matching each attribute and link from the "Självfaktura" onto OutgoingEmail.


[[File:TransformViewmodelForEmail.png|768x768px]]
[[File:TransformViewmodelForEmail.png|768x768px]]


(please note the "trick" self->asSet because we need an list, not a link to fill in "EmailAttachments" multi-link.
let oe = OutgoingEmail.create in
(
  if self.transform('TR_SjälvfakturaSkickaPDF', oe) then
    true
  else
    oe.Delete
  endif
)
[[File:ViewmodelForSendingEmail.png|447x447px]]
[[File:ViewmodelForSendingEmail.png|447x447px]]

Revision as of 21:29, 16 February 2019

object.transform(viewmodelname, <destination object>) uses the viewmodel to transform information from <object> into the <destination object>. Returns True if transform is full.

The transform operator takes the object as the root of the viewmodel specified and use the viewmodel as a template to copy and create a new structure of objects.

Example of how to use

Often when sending an email you need to "collect" information from many objects to find all the information needed to create an outgoing email.

Using this model of an email queue lets see how objects of the OutgoingEmail and EmailAttachment can be created using transform.

EmailQueueClassDiagram.png

This viewmodel will fill in the OutgoingEmail and EmailAttachment by name-matching each attribute and link from the "Självfaktura" onto OutgoingEmail.

TransformViewmodelForEmail.png

(please note the "trick" self->asSet because we need an list, not a link to fill in "EmailAttachments" multi-link.

let oe = OutgoingEmail.create in
(
  if self.transform('TR_SjälvfakturaSkickaPDF', oe) then
    true
  else
    oe.Delete
  endif
)

ViewmodelForSendingEmail.png

This page was edited 93 days ago on 02/10/2024. What links here