Bootcamp:Chapter 10
(Changing category from Category:1000 Steps Program to Category:Bootcamp)
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
<message>Write the content here to display this box</message>
This is '''Chapter 10'''. If you want to start from the [[The 1000 steps program to MDriven Chapter 1|beginning, you can start here]]. See also: [[The 1000 steps program to MDriven Chapter 9|Chapter 9 (the previous chapter)]].   
This is '''Chapter 10'''. If you want to start from the beginning, [[Training:Bootcamp:Chapter 1|you can start here]]. See also: [[Training:Bootcamp:Chapter 9|Chapter 9 (the previous chapter)]].   


=== '''Video 10: Creating OpenDocument Reports''' ===
=== '''Video 10: Creating OpenDocument Reports''' ===
Line 29: Line 29:


== Chapter 10: Correcting Errors (if you have them), Setting LinkRole Names on Association Classes, and Creating OpenDocument Reports ==
== Chapter 10: Correcting Errors (if you have them), Setting LinkRole Names on Association Classes, and Creating OpenDocument Reports ==
302. Create some intentional errors, for example, by renaming the CartransferOwnershipDocuments to CartransferOwnershipDocument. Save and practice following the error leads from the red dots and fix the error.
302. Create some intentional errors, for example, by renaming the '''CartransferOwnershipDocuments''' to '''CartransferOwnershipDocument'''. Save and practice following the error leads from the red dots and fix the error.


303. Create some intentional errors, for example, by changing the expression of a class action on Car. Save and practice finding the error from the red dots. Fix the errors, save, and ensure you have a clean model with no errors.
303. Create some intentional errors, for example, by changing the expression of a class action on '''Car'''. Save and practice finding the error from the red dots. Fix the errors, save, and ensure you have a clean model with no errors.


304. Find the link class HistoricOwnership. Select the association and change from <Default> to HistoricOwnerships (with a plural '''s''') in the LinkRoleName on both association ends for the associations. Save and check for errors.
304. Find the link class '''HistoricOwnership'''. Select the association and change from ''<Default>'' to '''HistoricOwnerships''' (with a plural '''s''') in the LinkRoleName on both association ends for the associations. Save and check for errors.


305. Fix the errors by clicking on them and updating the expressions to reflect the new name ''HistoricOwnership'' -> '''HistoricOwnerships'''.
305. Fix the errors by clicking on them and updating the expressions to reflect the new name ''HistoricOwnership'' -> '''HistoricOwnerships'''.


306. Drop the ShowCar action that does not have a ViewModel to show.
306. Drop the '''ShowCar''' action that does not have a ViewModel to show.


307. Create a New ViewModel called ProperCarView. Set the Class to Car and set Requires Root.
307. Create a New ViewModel called '''ProperCarView'''. Set the Class to '''Car''' and select '''Requires Root'''.


308. Add a Class Action to bring the ProperCarView up.
308. Add a Class Action to bring the '''ProperCarView''' up.


309. Show the ''RegistrationNumber'' in the ProperCarView by adding a column.  
309. Show the ''RegistrationNumber'' in the '''ProperCarView''' by adding a column.  


310. Also, add the ''State'', ''BrandOfCar'', and ''CarOwner'' - make them static to avoid editing.  
310. Also, add the ''State'', ''BrandOfCar'', and ''CarOwner'' - make them static to avoid editing.  


311. Add the multilink for ''CarTranserOwnershipDocuments'' as a grid.
311. Add the multilink for '''CarTranserOwnershipDocuments''' as a grid.


312. Add columns in this grid, ''Seller'' and ''Buyer'', and remove the AsString default column.  
312. Add columns in this grid, ''Seller'' and ''Buyer'', and remove the AsString default column.  


313. Start the web prototype. Search cars and open the ProperCarView on a Car that has CarTranserOwnershipDocuments.  
313. Start the web prototype. Search cars and open the '''ProperCarView''' on a '''Car''' that has '''CarTranserOwnershipDocuments'''.  


314. Add a Class action: <code>ProduceDocument</code>, and give the ExecuteExpression the value of '''self.opendocumentreportshow(CarTransferOwnershipDocument.ViewModels.TheTemplateForCarTransferOwnershipDocumentReport)'''
314. Add a Class action: '''ProduceDocument''', and give the ''ExecuteExpression'' the value of
* Expect the error due to not having the TheTemplateForCarTransferOwnershipDocumentReport ViewModel yet.
self.opendocumentreportshow(CarTransferOwnershipDocument.ViewModels.TheTemplateForCarTransferOwnershipDocumentReport)
315. Create a ''TheTemplateForCarTransferOwnershipDocumentReport'' ViewModel. Set the class to <code>CarTransferOwnershipDocument</code> and check the Requires Root box.  
* Expect the error due to not having the '''TheTemplateForCarTransferOwnershipDocumentReport''' ViewModel yet.
315. Create a '''TheTemplateForCarTransferOwnershipDocumentReport''' ViewModel. Set the class to '''CarTransferOwnershipDocument''' and check the Requires Root box.  


316. Right-click the menu in the ViewModel tree. Add the columns needed for a report. Expect the TemplateUrl and ReportFileName ViewModelColumns.
316. Right-click the menu in the ViewModel tree. Add the columns needed for a report. Expect the ''TemplateUrl'' and ''ReportFileName'' ViewModelColumns.


317. Verify that the action that was faulty before now finds the TheTemplateForCarTransferOwnershipDocumentReport.
317. Verify that the action that was faulty before now finds the '''TheTemplateForCarTransferOwnershipDocumentReport'''.


318. In the TheTemplateForCarTransferOwnershipDocumentReport ViewModel, click on the UsePlacingHints to hide the UI part of the ViewModel. (also see the Turnkey Live Editor below)  
318. In the '''TheTemplateForCarTransferOwnershipDocumentReport''' ViewModel, click on the ''UsePlacingHints'' to hide the UI part of the ViewModel. (also see the Turnkey Live Editor below)  


319. In the FileMenu ShowCurrentModelDirectory, check the model file name: <code>"Start.modlr"</code>. Create a folder named <code>Start_AssetsTK</code> and read about [[AssetsTK]] on the Wiki.  
319. In the FileMenu ''ShowCurrentModelDirectory'', check the model file name: <code><span class="col-black">"Start.modlr"</span></code>. Create a folder named '''Start_AssetsTK''' and read about [[AssetsTK]] on the Wiki.  


320. Create a folder called <code>Content</code> in Start_AssetsTK.  
320. Create a folder called <code><span class="col-black">Content</span></code> in '''Start_AssetsTK'''.  
* Start Word, click on a new document, and write: <code>this will be my template</code>.  
* Start Word, click on a new document, and write: <code><span class="col-black">this will be my template</span></code>.  
* Save as ODT format in Start_AssetsTK/Content and call the file: <code>ThisWillBeMyTemplate.odt</code><blockquote></blockquote>321. Close Word to avoid file lock while MDriven Designer tries to access it.  
* Save as ODT format in Start_AssetsTK/Content and call the file: <code><span class="col-black">ThisWillBeMyTemplate.odt</span></code>
321. Close Word to avoid file lock while MDriven Designer tries to access it.


322. Check that your app URL is starting with <nowiki>http://localhost</nowiki>:... Test '''<nowiki>http://localhost</nowiki>:<port>/content/ThisWillBeMyTemplate.odt''' - Ensure you can access the template (you must use the port number you often use).
322. Check that your app URL is starting with <nowiki>http://localhost</nowiki>:... Test '''<nowiki>http://localhost</nowiki>:<port>/content/ThisWillBeMyTemplate.odt''' - Ensure you can access the template (you must use the port number you often use).


323. In the ViewModel for the template, in the Template URL, set the string value <code>'<nowiki>http://localhost</nowiki>:<port>/content/ThisWillBeMyTemplate.odt'</code>
323. In the ViewModel for the template, in the Template URL, set the string value <code><span class="col-black">'<nowiki>http://localhost</nowiki>:<port>/content/ThisWillBeMyTemplate.odt'</span></code>


====== <span class="col-blue-dark">Solving issues</span> ======
===== <span class="col-blue-dark">Solving issues</span> =====
If downloading the template doesn't work, doublecheck the model name. The name of the "AssetsTK" folder is based on the model name, ''except'' the ".modlr" part. If the model file is called "MyStart.modlr", then the folder name should be "MyStart_AssetsTK". Avoid additional dots and other special characters in the model name.
If downloading the template doesn't work, doublecheck the model name. The name of the "AssetsTK" folder is based on the model name, ''<u>except</u>'' the ".modlr" part. If the model file is called "MyStart.modlr", then the folder name should be "MyStart_AssetsTK". Avoid additional dots and other special characters in the model name.


Using the Turnkey Live Editor avoids these problems by creating the correct folder name, but the video doesn't use that editor.
Using the Turnkey Live Editor avoids these problems by creating the correct folder name, but the video doesn't use that editor.


====== <span class="col-blue-dark">Turnkey Live Editor</span> ======
===== <span class="col-blue-dark">Turnkey Live Editor</span> =====
====== <span class="col-blue-dark"><span class="col-black">Alternatively, select the Turnkey Live Editor</span></span> [[File:Turnkey_Live_Editor_small_icon.png|frameless|40x40px]]  found in the top menu of the MDriven Designer: ======
'''<span class="col-blue-dark"><span class="col-black">Alternatively, select the Turnkey Live Editor</span></span> [[File:Turnkey_Live_Editor_small_icon.png|frameless|40x40px]]  found in the top menu of the MDriven Designer:'''
# In the pop-up window, look for the purple tab named "AssetsTK Sync" on the right and click on it.
# In the pop-up window, look for the purple tab named "'''AssetsTK Sync'''" on the right and click on it.
# When it unfolds, look to the extreme left to see a "Start_AssetsTK" folder (Or "whatever name your model is_AssetsTK).
# When it unfolds, look to the extreme left to see a "'''Start_AssetsTK'''" folder (Or "whatever name your model is_AssetsTK").
# Right-click on the folder and select "Open".
# Right-click on the folder and select "Open".
# Follow the instructions above to create the Content folder and Word document and retry downloading the template.
# Follow the instructions above to create the Content folder and Word document and retry downloading the template.


324. Set the ''ReportFileName'' expression to<code><span class="col-black">'TheSalesReportForCar'+self.Car.RegistrationNumber+'.odt'</span></code>


325. Test the '''ProduceDocument''' action and ensure you get a document with the name from the RegistrationNumber.


324. Set the ReportFileName expression to<code>'TheSalesReportForCar'+self.Car.RegistrationNumber+'.odt'</code>
326. In the template odt, add <code><span class="col-black">%meta%</span></code>. Save and close. Resave the model to upload.
* Test the '''ProduceDocument''' again and verify that you can see the expanded properties from the '''%meta%''' tag.
327. Head back to ViewModel for the template and add '''Buyer''', '''Seller''', '''RegistrationNumber''', and '''Brand''' (<code><span class="col-black">self.Car.Brand.Name</span></code>).


325. Test the ProduceDocument action and ensure you get a document with the name from the RegistrationNumber.
328. Test the '''ProduceDocument''' action again. Copy the expanded ViewModel data names from the document and paste them into the original document. This will be expanded into data.
 
326. In the template odt, add <code>%meta%</code>. Save and close. Resave the model to upload.
* Test the ProduceDocument again and verify that you can see the expanded properties from the %meta% tag.
327. Head back to ViewModel for the template and add Buyer, Seller, RegistrationNumber, and Brand (<code>self.Car.Brand.Name</code>).
 
328. Test the ProduceDocument action again. Copy the expanded ViewModel data names from the document and paste them into the original document. This will be expanded into data.


329. Write a text in the template and mix in the tags: '''The buyer named %Buyer% has purchased the car %RegistrationNumber% of type %Brand% from %Seller%'''
329. Write a text in the template and mix in the tags: '''The buyer named %Buyer% has purchased the car %RegistrationNumber% of type %Brand% from %Seller%'''
Line 101: Line 101:
330. Turn off spellcheck in the document so that the tags are not distorted in the resulting file. Save and close Word. Save the model.
330. Turn off spellcheck in the document so that the tags are not distorted in the resulting file. Save and close Word. Save the model.


331. Test the ProduceDocument action again. Ensure you get a document with tags expanded to data according to the definition in your template ViewModel.  
331. Test the '''ProduceDocument''' action again. Ensure you get a document with tags expanded to data according to the definition in your template ViewModel.  


[[File:ModelAfterChapter10.zip||ModelAfterChapter10 as zip]]
[[File:ModelAfterChapter10.zip||ModelAfterChapter10 as zip]]


'''Next Chapter:'''  
=== '''Next Chapter''' ===
 
[[Training:Bootcamp:Chapter 11|Bootcamp:Chapter 11]]
[[The_1000_steps_program_to_MDriven_Chapter_11]]


[[Category:Bootcamp]]
[[Category:Bootcamp]]


[[Category:TOC]]
[[Category:TOC]]

Latest revision as of 05:48, 16 September 2024

This is Chapter 10. If you want to start from the beginning, you can start here. See also: Chapter 9 (the previous chapter).

Video 10: Creating OpenDocument Reports

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 302 - 331 Introduction Fixing Errors LinkRoleName ProperCarView Adding a New ViewModel Creating a Report Template Testing the ProduceDocument action

Chapter 10: Correcting Errors (if you have them), Setting LinkRole Names on Association Classes, and Creating OpenDocument Reports

302. Create some intentional errors, for example, by renaming the CartransferOwnershipDocuments to CartransferOwnershipDocument. Save and practice following the error leads from the red dots and fix the error.

303. Create some intentional errors, for example, by changing the expression of a class action on Car. Save and practice finding the error from the red dots. Fix the errors, save, and ensure you have a clean model with no errors.

304. Find the link class HistoricOwnership. Select the association and change from <Default> to HistoricOwnerships (with a plural s) in the LinkRoleName on both association ends for the associations. Save and check for errors.

305. Fix the errors by clicking on them and updating the expressions to reflect the new name HistoricOwnership -> HistoricOwnerships.

306. Drop the ShowCar action that does not have a ViewModel to show.

307. Create a New ViewModel called ProperCarView. Set the Class to Car and select Requires Root.

308. Add a Class Action to bring the ProperCarView up.

309. Show the RegistrationNumber in the ProperCarView by adding a column.

310. Also, add the State, BrandOfCar, and CarOwner - make them static to avoid editing.

311. Add the multilink for CarTranserOwnershipDocuments as a grid.

312. Add columns in this grid, Seller and Buyer, and remove the AsString default column.

313. Start the web prototype. Search cars and open the ProperCarView on a Car that has CarTranserOwnershipDocuments.

314. Add a Class action: ProduceDocument, and give the ExecuteExpression the value of

self.opendocumentreportshow(CarTransferOwnershipDocument.ViewModels.TheTemplateForCarTransferOwnershipDocumentReport)
  • Expect the error due to not having the TheTemplateForCarTransferOwnershipDocumentReport ViewModel yet.

315. Create a TheTemplateForCarTransferOwnershipDocumentReport ViewModel. Set the class to CarTransferOwnershipDocument and check the Requires Root box.

316. Right-click the menu in the ViewModel tree. Add the columns needed for a report. Expect the TemplateUrl and ReportFileName ViewModelColumns.

317. Verify that the action that was faulty before now finds the TheTemplateForCarTransferOwnershipDocumentReport.

318. In the TheTemplateForCarTransferOwnershipDocumentReport ViewModel, click on the UsePlacingHints to hide the UI part of the ViewModel. (also see the Turnkey Live Editor below)

319. In the FileMenu ShowCurrentModelDirectory, check the model file name: "Start.modlr". Create a folder named Start_AssetsTK and read about AssetsTK on the Wiki.

320. Create a folder called Content in Start_AssetsTK.

  • Start Word, click on a new document, and write: this will be my template.
  • Save as ODT format in Start_AssetsTK/Content and call the file: ThisWillBeMyTemplate.odt

321. Close Word to avoid file lock while MDriven Designer tries to access it.

322. Check that your app URL is starting with http://localhost:... Test http://localhost:<port>/content/ThisWillBeMyTemplate.odt - Ensure you can access the template (you must use the port number you often use).

323. In the ViewModel for the template, in the Template URL, set the string value 'http://localhost:<port>/content/ThisWillBeMyTemplate.odt'

Solving issues

If downloading the template doesn't work, doublecheck the model name. The name of the "AssetsTK" folder is based on the model name, except the ".modlr" part. If the model file is called "MyStart.modlr", then the folder name should be "MyStart_AssetsTK". Avoid additional dots and other special characters in the model name.

Using the Turnkey Live Editor avoids these problems by creating the correct folder name, but the video doesn't use that editor.

Turnkey Live Editor

Alternatively, select the Turnkey Live Editor Turnkey Live Editor small icon.png found in the top menu of the MDriven Designer:

  1. In the pop-up window, look for the purple tab named "AssetsTK Sync" on the right and click on it.
  2. When it unfolds, look to the extreme left to see a "Start_AssetsTK" folder (Or "whatever name your model is_AssetsTK").
  3. Right-click on the folder and select "Open".
  4. Follow the instructions above to create the Content folder and Word document and retry downloading the template.

324. Set the ReportFileName expression to'TheSalesReportForCar'+self.Car.RegistrationNumber+'.odt'

325. Test the ProduceDocument action and ensure you get a document with the name from the RegistrationNumber.

326. In the template odt, add %meta%. Save and close. Resave the model to upload.

  • Test the ProduceDocument again and verify that you can see the expanded properties from the %meta% tag.

327. Head back to ViewModel for the template and add Buyer, Seller, RegistrationNumber, and Brand (self.Car.Brand.Name).

328. Test the ProduceDocument action again. Copy the expanded ViewModel data names from the document and paste them into the original document. This will be expanded into data.

329. Write a text in the template and mix in the tags: The buyer named %Buyer% has purchased the car %RegistrationNumber% of type %Brand% from %Seller%

330. Turn off spellcheck in the document so that the tags are not distorted in the resulting file. Save and close Word. Save the model.

331. Test the ProduceDocument action again. Ensure you get a document with tags expanded to data according to the definition in your template ViewModel.

File:ModelAfterChapter10.zip

Next Chapter

Bootcamp:Chapter 11

This page was edited 3 days ago on 09/16/2024. What links here