Bootcamp:Chapter 17

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. Write:

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 84 days ago on 09/30/2024. What links here