The 1000 steps program to MDriven Chapter 17
No edit summary
No edit summary
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is Chapter 17. If you want to go back to the beginning, [[The 1000 steps program to MDriven Chapter 1|you can find it here: Chapter 1]]
This is '''Chapter 17'''. If you want to go back to the beginning, [[The 1000 steps program to MDriven Chapter 1|you can find it here: Chapter 1.]] Or go back to [[The_1000_steps_program_to_MDriven_Chapter_16|Chapter 16.]]


Go back to Chapter 16: [[The_1000_steps_program_to_MDriven_Chapter_16]]
== Video 17: Default names, Dim Default, and More ==
<html>


Default names, dim default, plural suffix, what happens when the model is changed - is your data lost?
<p class="video-warn">
  To make your experience smooth, we set the main tags mentioned in the video to the right bar menu of this mini-player. Choose an interesting subtitle on the list and immediately get to the exact theme navigation item place in the video. Now you can pick any topic to be instructed on without watching the whole video.
</p>


Modal window - pick a seller
<div class="video">
  <div class="video__wrapper">
    <iframe src="https://www.youtube.com/embed/m1oer_jjQh4?si=-EoY9bzjTnOfyqWY" title="YouTube video player" frameborder="0" allowfullscreen></iframe>
  </div>
  <div class="video__navigation">
<span data-video="m1oer_jjQh4" data-start="00" tabindex="0"> <strong> Steps 531 - 563 </strong> </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="00" tabindex="0"> Introduction </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="11" tabindex="0"> Discussion on Renaming </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="131" tabindex="0"> Check changes </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="766" tabindex="0"> Amend an action & an expression </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="1718" tabindex="0"> CarDealerPicker ViewModel </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="1940" tabindex="0"> PickBuyer ViewModel action </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="2168" tabindex="0"> Test the PickBuyer button </span>
    <span class="navigation-item" data-video="m1oer_jjQh4" data-start="2258" tabindex="0"> Discussions on model changes </span>
  </div>
</div>


Check valid action based on current state with oclIsInState
</html>


Make use of GetSystemURL Eco.ExternalLateBound function to make our report work on any server
== Chapter 17: Default names, Dim Default, Plural Suffix; What Happens When the Model Is Changed - Is Your Data Lost? ==
'''In this chapter, we:'''
# '''Create a Modal window - pick a Seller'''
# '''Check valid action based on current state with oclIsInState'''
# '''Make use of GetSystemURL Eco.ExternalLateBound function to make our report work on any server'''


Video for chapter 17: https://youtu.be/m1oer_jjQh4
531.  Change the name of the association between '''CarFactory''' and '''BrandOfCar''' that has data in it - what happens on evolve with the existing data?


531. Change the name of a Association that has  data in it - what happens on evolve with exiting data
* Double-click on '''CarFactorys''' and change the name to '''CarFactories'''.


532. Update the versions on MDrivenServer
532. Update the versions on MDrivenServer.


533. Follow the discussion of where foreign keys are stored in the database
* Check the server status – make sure everything runs.


534. Rename the CarFactory.BrandOfCar and check with changes what would happen
* Click on “Changes” to see what changes have occurred. You should see a message: '''No DB changes detected – but checksum differs'''
* Listen to the explanation on downloading the latest servers and checking for changes in the model.


535. Follow the discussion of Former-Names and understand benefit to move data  when things change in the db
533. Follow the discussion of where foreign keys are stored in the database.


536. Follow the discussion of the rename-function vs just changing the name
534. Rename the '''CarFactory''' to '''BrandOfCar''' association end “0..1 BrandOfCar” to “0..1 BrandOfCar'''x'''” and check with changes what would happen.


537. In the CarFactoryView - amend the action CreateAndAddCodumentForSales  according to the video
535. Follow the discussion on FormerNames and understand the benefit of moving data when things change in the DB.


538. Follow the discussion what ViewModel column names that has underscore in  them
* Correct the name of the '''CarFactory''' to '''BrandOfCar''' association end back to “'''0..1 BrandOfCar'''”. Save.
* Note the disappearance of the error messages.


539. Follow the discussion on whay it is unnecessary to set both ends of an  association in MDriven
536. Follow the discussion on the Rename function vs. just changing the name.


540. Amend the expression for CreateAndAddCodumentForSales to set the selected  Car
537. In the '''CarFactoryView''', amend the action CreateAndAddDocumentForSales according to the video. Wri


541. Add the Cars registration and State to the DocumentForSales grid
<pre>
Let doc=CarTransferOwnershipDocument.Create in
(
self.DocumentForSales.add(doc);
doc.Seller:=vCurrent_CarFactoryView
)
</pre>


542. Discover that The we actually use the state machine to create the  paperwork for a sale
* Under '''DocumentForSales''', add a column for the Seller’s name.


543. Clean up the model according to the video
* Rename the column from '''Seller_Name''' to '''Seller'''.


544. Set up the rule to stop deletion of the PaperWork as long as a is not in InOwnershipTransaction
538. Follow the discussion on ViewModel column names that have an underscore in them.


545. Create a new Viewmodel named CarDealerPicker - by using UIHints  CopyValueStore autoForm
* Add a column for the Buyer’s name.
* Rename the column from '''Buyer_Name''' to '''Buyer'''.
* Change the name of '''CreateAndAddDocumentForSales''' to '''PrepareSale'''.


546. Move the global action into the Views manuGroup
539. Follow the discussion on why setting both ends of an association in MDriven is unnecessary.


547. Clean up un needed columns from the DocumentForSales grid
540. Amend the expression for CreateAndAddDocumentForSales to set the selected Car. Write:


548. Add an action in DocumentForSales grid - call it PickBuyer
<pre>
Let doc=CarTransferOwnershipDocument.Create in
(
self.DocumentForSales.add(doc);
doc.Car:=vCurrent_CurrentlyOwnedCars
)
</pre>


549. Create a new ViewModelAction that bring up our the new CarDealerPicker  viewModel - call that also PickBuyer
541. Add columns for the Car's '''RegistrationNumber''' and '''State''' to the '''DocumentForSales''' grid. Save.


550. Set the PickBuyer viewmodel action as "Is modal"
* Go to the Cloud dialog and check server status and changes.
* Upload the model and check server status again.
* Open the webapplication ('''<nowiki>http://localhost:5001</nowiki>''') to see the changes you’ve made so far.


551. When you show a dialog as modal you must give an expression to decide  when the "Ok" button in the modal should show - set it to  vCurrent_CarDealer->notempty
542. Discover that we actually use the Statemachine to create the paperwork for a sale.


552. When you have a dialig as model - you can also perfom something specific  upon the user pressing OK - This is called the Expression after modal ok. In our case we want to  vCurrent_DocumentForSales.Buyer:=vModalResult_vCurrent_CarDealer
543. Clean up the model according to the video. In the '''CarFactoryView''' ViewModel:


553. Save model - and upload it to MDrivenServer
* Delete the  '''PrepareSale''' widget.


554. Test to assign a buyer - see that the CarDealer-picker shows - but it is empty
544. Set up the rule to stop deletion of the PaperWork as long as it is not in InOwnershipTransaction. Click on the '''DeleteDocumentForSales''' widget and in the Disabled Expression box, write:


555. Go to Views/CarDealerPicker - and use the left side actions to create 3  dealers - give them names - save
<code>vCurrent_DocumentForSales->isnull or (vCurrent_DocumentFor Sales.Car->oclisinstate(#InOwnershipTransaction))</code>


556. Navigate back to the CarFactoryView and test the Pick buyer button again
545. Create a new ViewModel named '''CarDealerPicker''' and set it’s class to CarDealer. It should remain unrooted.


557. Verify that the DeleteDocumentForSales readonly rule works as designed -  not allowing delete of paperwork in a Ownership transaction
* Fill in the missing details by using '''UI Hints'''. Find and select <u>Copy ValueStore Auto Form</u>. You’ see a grid for all the Car Dealers and some attributes.
* Delete the <u>Change Time</u>, <u>Create Time</u>, and <u>Guid</u> widgets.
* Move the Name widget up to align with the Car Dealer widget. Save.


558. Initiate sale of a new car. Verify that you cannot do Initiate sale on a  car that already is in a Ownership transaction
546. Move the '''CarDealerPicker''' global action into the Views menu group.


559. Follow the discussion in the video on why the report does not work any  longer.
547. Go to the '''CarFactoryView''' ViewModel. Clean up unneeded columns from the '''DocumentForSales''' grid.


560. Follow the discussion on how to get a access to the servers own adress  from within our model
* Delete the <u>AsString</u>, <u>ChangeTime</u>, <u>CreateTime</u>, and <u>Guid</u> columns.


561. Follow the discussion on methods tagged with Eco.ExternalLateBound tag  value
548. Add a class action in the '''DocumentForSales''' grid - call it '''PickBuyer'''.


562. In the report template viewmodel  TheTemplateForCarTransferOwnersdhipDocumentReport change the TemplateUrl  expression to NOT return a hard coded server address but rather ask the system for the correct server address just in time.
549. Create a new ViewModel Action that brings up the new '''CarDealerPicker''' ViewModel - call that also '''PickBuyer'''.


563. Upload the model and test to produce the document.
* Set Bring Up View Model to the '''CarDealerPicker''' ViewModel.


550. Set the '''PickBuyer''' ViewModel action as "Is modal".
551. When you show a dialog as “modal”, you must give an expression to decide when the "Ok" button in the model should show. Set Enable Expression For Modal Ok to <code>vCurrent_CarDealer->notempty</code>
552. When you have a dialog as modal, you can also perform something specific upon the user pressing OK. This is called the Expression After Modal Ok. In our case, we want to use <code>vCurrent_DocumentForSales.Buyer:=vModalResult_vCurrent_CarDealer</code>
553. Save the model and upload it to MDrivenServer.
554. Test to assign a Buyer. See that the '''CarDealerPicker''' shows - but it is empty.
555. Go to Views/CarDealerPicker and use the left side actions to create 3 dealers. Give them names. Save.
556. Navigate back to the '''CarFactoryView''' and test the '''PickBuyer''' button again.
557. Verify that the '''DeleteDocumentForSales''' read-only rule works as designed - not allowing deletion of paperwork in an Ownership transaction.
558. Initiate the sale of a new car. Verify that you cannot do "Initiate Sale" on a car that is already in an Ownership transaction.
559. Follow the discussion in the video on why the report does not work anymore.
560. Follow the discussion on how to get access to the server's own address from within our model.
561. Follow the discussion on methods tagged with the '''Eco.ExternalLateBound''' tag value.
562. In the report template ViewModel, '''TheTemplateForCarTransferOwnersdhipDocumentReport''''','' change the TemplateUrl expression to NOT return a hard-coded server address but rather ask the system for the correct server address just in time. Write:
<code>SysSingleton.oclSingleton.GetSystemUrl +’/content/ThisWillBeMyTemplate.od’</code>
* Note: the expression shows an error message
* Return to the <u>SysSingleton</u> class and delete “SysSingleton.” from the '''GetSystemUrl''' name and save.
* Check the '''TemplateUrl''' expression again.
563. Upload the model and test to produce the document.


[[File:AfterChapter17.zip|none|thumb]]
[[File:AfterChapter17.zip|none|thumb]]


'''Next Chapter:''' [[The_1000_steps_program_to_MDriven_Chapter_18]]
 
[[Category:1000 Steps Program]]
[[Category:1000 Steps Program]]

Latest revision as of 07:11, 26 April 2024

This is Chapter 17. If you want to go back to the beginning, you can find it here: Chapter 1. Or go back to Chapter 16.

Video 17: Default names, Dim Default, and More

To make your experience smooth, we set the main tags mentioned in the video to the right bar menu of this mini-player. Choose an interesting subtitle on the list and immediately get to the exact theme navigation item place in the video. Now you can pick any topic to be instructed on without watching the whole video.

Steps 531 - 563 Introduction Discussion on Renaming Check changes Amend an action & an expression CarDealerPicker ViewModel PickBuyer ViewModel action Test the PickBuyer button Discussions on model changes

Chapter 17: Default names, Dim Default, Plural Suffix; What Happens When the Model Is Changed - Is Your Data Lost?

In this chapter, we:

  1. Create a Modal window - pick a Seller
  2. Check valid action based on current state with oclIsInState
  3. Make use of GetSystemURL Eco.ExternalLateBound function to make our report work on any server

531.  Change the name of the association between CarFactory and BrandOfCar that has data in it - what happens on evolve with the existing data?

  • Double-click on CarFactorys and change the name to CarFactories.

532. Update the versions on MDrivenServer.

  • Check the server status – make sure everything runs.
  • Click on “Changes” to see what changes have occurred. You should see a message: No DB changes detected – but checksum differs
  • Listen to the explanation on downloading the latest servers and checking for changes in the model.

533. Follow the discussion of where foreign keys are stored in the database.

534. Rename the CarFactory to BrandOfCar association end “0..1 BrandOfCar” to “0..1 BrandOfCarx” and check with changes what would happen.

535. Follow the discussion on FormerNames and understand the benefit of moving data when things change in the DB.

  • Correct the name of the CarFactory to BrandOfCar association end back to “0..1 BrandOfCar”. Save.
  • Note the disappearance of the error messages.

536. Follow the discussion on the Rename function vs. just changing the name.

537. In the CarFactoryView, amend the action CreateAndAddDocumentForSales according to the video. Wri

Let doc=CarTransferOwnershipDocument.Create in
(
self.DocumentForSales.add(doc);
doc.Seller:=vCurrent_CarFactoryView
)
  • Under DocumentForSales, add a column for the Seller’s name.
  • Rename the column from Seller_Name to Seller.

538. Follow the discussion on ViewModel column names that have an underscore in them.

  • Add a column for the Buyer’s name.
  • Rename the column from Buyer_Name to Buyer.
  • Change the name of CreateAndAddDocumentForSales to PrepareSale.

539. Follow the discussion on why setting both ends of an association in MDriven is unnecessary.

540. Amend the expression for CreateAndAddDocumentForSales to set the selected Car. Write:

Let doc=CarTransferOwnershipDocument.Create in
(
self.DocumentForSales.add(doc);
doc.Car:=vCurrent_CurrentlyOwnedCars
)

541. Add columns for the Car's RegistrationNumber and State to the DocumentForSales grid. Save.

  • Go to the Cloud dialog and check server status and changes.
  • Upload the model and check server status again.
  • Open the webapplication (http://localhost:5001) to see the changes you’ve made so far.

542. Discover that we actually use the Statemachine to create the paperwork for a sale.

543. Clean up the model according to the video. In the CarFactoryView ViewModel:

  • Delete the  PrepareSale widget.

544. Set up the rule to stop deletion of the PaperWork as long as it is not in InOwnershipTransaction. Click on the DeleteDocumentForSales widget and in the Disabled Expression box, write:

vCurrent_DocumentForSales->isnull or (vCurrent_DocumentFor Sales.Car->oclisinstate(#InOwnershipTransaction))

545. Create a new ViewModel named CarDealerPicker and set it’s class to CarDealer. It should remain unrooted.

  • Fill in the missing details by using UI Hints. Find and select Copy ValueStore Auto Form. You’ see a grid for all the Car Dealers and some attributes.
  • Delete the Change Time, Create Time, and Guid widgets.
  • Move the Name widget up to align with the Car Dealer widget. Save.

546. Move the CarDealerPicker global action into the Views menu group.

547. Go to the CarFactoryView ViewModel. Clean up unneeded columns from the DocumentForSales grid.

  • Delete the AsString, ChangeTime, CreateTime, and Guid columns.

548. Add a class action in the DocumentForSales grid - call it PickBuyer.

549. Create a new ViewModel Action that brings up the new CarDealerPicker ViewModel - call that also PickBuyer.

  • Set Bring Up View Model to the CarDealerPicker ViewModel.

550. Set the PickBuyer ViewModel action as "Is modal".

551. When you show a dialog as “modal”, you must give an expression to decide when the "Ok" button in the model should show. Set Enable Expression For Modal Ok to vCurrent_CarDealer->notempty

552. When you have a dialog as modal, you can also perform something specific upon the user pressing OK. This is called the Expression After Modal Ok. In our case, we want to use vCurrent_DocumentForSales.Buyer:=vModalResult_vCurrent_CarDealer

553. Save the model and upload it to MDrivenServer.

554. Test to assign a Buyer. See that the CarDealerPicker shows - but it is empty.

555. Go to Views/CarDealerPicker and use the left side actions to create 3 dealers. Give them names. Save.

556. Navigate back to the CarFactoryView and test the PickBuyer button again.

557. Verify that the DeleteDocumentForSales read-only rule works as designed - not allowing deletion of paperwork in an Ownership transaction.

558. Initiate the sale of a new car. Verify that you cannot do "Initiate Sale" on a car that is already in an Ownership transaction.

559. Follow the discussion in the video on why the report does not work anymore.

560. Follow the discussion on how to get access to the server's own address from within our model.

561. Follow the discussion on methods tagged with the Eco.ExternalLateBound tag value.

562. In the report template ViewModel, TheTemplateForCarTransferOwnersdhipDocumentReport, change the TemplateUrl expression to NOT return a hard-coded server address but rather ask the system for the correct server address just in time. Write:

SysSingleton.oclSingleton.GetSystemUrl +’/content/ThisWillBeMyTemplate.od’

  • Note: the expression shows an error message
  • Return to the SysSingleton class and delete “SysSingleton.” from the GetSystemUrl name and save.
  • Check the TemplateUrl expression again.

563. Upload the model and test to produce the document.

File:AfterChapter17.zip

This page was edited 23 days ago on 04/26/2024. What links here