The 1000 steps program to MDriven Chapter 17
No edit summary
Tag: 2017 source edit
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 13: Line 13:
   </div>
   </div>
   <div class="video__navigation">
   <div class="video__navigation">
  <span data-video="m1oer_jjQh4" data-start="00" tabindex="0"> <strong> Dealing with Model Changes </strong> </span>
  <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="00" tabindex="0"> Introduction </span>
     <span class="navigation-item" data-video="m1oer_jjQh4" data-start="" tabindex="0"> </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="" tabindex="0"> </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="" tabindex="0"> </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="" tabindex="0"> </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="" tabindex="0"> </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="" tabindex="0"> </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>
</div>
</div>
Line 28: Line 29:
== Chapter 17: Default names, Dim Default, Plural Suffix; What Happens When the Model Is Changed - Is Your Data Lost? ==
== Chapter 17: Default names, Dim Default, Plural Suffix; What Happens When the Model Is Changed - Is Your Data Lost? ==
'''In this chapter, we:'''  
'''In this chapter, we:'''  
* '''Create a Modal window - pick a Seller'''
# '''Create a Modal window - pick a Seller'''
* '''Check valid action based on current state with oclIsInState'''
# '''Check valid action based on current state with oclIsInState'''
* '''Make use of GetSystemURL Eco.ExternalLateBound function to make our report work on any server'''
# '''Make use of GetSystemURL Eco.ExternalLateBound function to make our report work on any server'''
531. Change the name of an Association that has data in it - what happens on evolve with the existing data?
 
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.
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.
533. Follow the discussion of where foreign keys are stored in the database.


534. Rename the ''CarFactory.BrandOfCar'' and check with changes what would happen.
534. Rename the '''CarFactory''' to '''BrandOfCar''' association end “0..1 BrandOfCar” to “0..1 BrandOfCar'''x'''” 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.


535. Follow the discussion of Former-Names and understand the benefit of moving data when things change in the DB.
536. Follow the discussion on the Rename function vs. just changing the name.


536. Follow the discussion of the Rename function vs. just changing the name.
537. In the '''CarFactoryView''', amend the action CreateAndAddDocumentForSales according to the video. Wri


537. In the CarFactoryView, amend the action <code>CreateAndAddCodumentForSales</code> according to the video.  
<pre>
Let doc=CarTransferOwnershipDocument.Create in
(
self.DocumentForSales.add(doc);
doc.Seller:=vCurrent_CarFactoryView
)
</pre>
 
* 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.
538. Follow the discussion on ViewModel column names that have an underscore in them.


539. Follow the discussion on why it is unnecessary to set both ends of an association in MDriven.
* Add a column for the Buyer’s name.
* Rename the column from '''Buyer_Name''' to '''Buyer'''.
* Change the name of '''CreateAndAddDocumentForSales''' to '''PrepareSale'''.


540. Amend the expression for <code>CreateAndAddCodumentForSales</code> to set the selected Car.
539. Follow the discussion on why setting both ends of an association in MDriven is unnecessary.


541. Add the Car's registration and State to the DocumentForSales grid.
540. Amend the expression for CreateAndAddDocumentForSales to set the selected Car. Write:
 
<pre>
Let doc=CarTransferOwnershipDocument.Create in
(
self.DocumentForSales.add(doc);
doc.Car:=vCurrent_CurrentlyOwnedCars
)
</pre>
 
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 ('''<nowiki>http://localhost:5001</nowiki>''') to see the changes you’ve made so far.


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


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


544. Set up the rule to stop deletion of the PaperWork as long as it is not in ''InOwnershipTransaction''.
* Delete the  '''PrepareSale''' widget.


545. Create a new ViewModel named CarDealerPicker by using UI Hints. Copy the ValueStore Auto Form.
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:


546. Move the global action into the Views MenuGroup.
<code>vCurrent_DocumentForSales->isnull or (vCurrent_DocumentFor Sales.Car->oclisinstate(#InOwnershipTransaction))</code>


547. Clean up unneeded columns from the DocumentForSales grid.
545. Create a new ViewModel named '''CarDealerPicker''' and set it’s class to CarDealer. It should remain unrooted.


548. Add an action in the DocumentForSales grid - call it PickBuyer.
* 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.


549. Create a new ViewModelAction that brings up the new CarDealerPicker ViewModel - call that also PickBuyer.
546. Move the '''CarDealerPicker''' global action into the Views menu group.


550. Set the PickBuyer ViewModel action as <code>"Is modal"</code>.
547. Go to the '''CarFactoryView''' ViewModel. Clean up unneeded columns from the '''DocumentForSales''' grid.


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 it to  <code>vCurrent_CarDealer->notempty</code>
* Delete the <u>AsString</u>, <u>ChangeTime</u>, <u>CreateTime</u>, and <u>Guid</u> columns.


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>
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 <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.
553. Save the model and upload it to MDrivenServer.


554. Test to assign a Buyer. See that the CarDealer picker shows - but it is empty.
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.
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.
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.
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.
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.
Line 91: Line 143:
560. Follow the discussion on how to get access to the server's own address from within our model.
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.
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>


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.
* 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.
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