1   package com.sri.emo.wizard.completion.persistence;
2   
3   import com.sri.emo.controller.CompletionWizardAction;
4   import com.sri.emo.dbobj.WizDefinition;
5   import com.sri.emo.wizard.completion.EmoCompletionFactory;
6   import com.sri.emo.wizard.completion.EmoCompletionWizard;
7   import com.sri.emo.wizard.completion.management.CompletionEditor;
8   import com.sri.emo.wizard.completion.model.CompletionWizardTestBean;
9   import com.sri.emo.wizard.completion.model.FieldCompletion;
10  
11  /***
12   * Test Model for a sample wizard definition.
13   * @author Michael Rimov
14   * @version 1.0
15   */
16  public class CompletionDBObjTestModel {
17  
18      private WizDefinition wizdef;
19  
20      public CompletionDBObjTestModel() {
21          super();
22      }
23  
24      /***
25       * @todo Determine Part ORder.
26       * @throws Exception
27       */
28      public void setUp() throws Exception {
29          //Set up the default wizard definition fields.
30          wizdef = new WizDefinition();
31          wizdef.set(WizDefinition.FLD_NAME, CompletionWizardTestBean.TITLE);
32          wizdef.set(WizDefinition.FLD_SUMMARY, CompletionWizardTestBean.SUMMARY);
33          wizdef.set(WizDefinition.FLD_WIZARD, EmoCompletionWizard.class.getName());
34          wizdef.set(WizDefinition.FLD_EDITOR_CONTROLLER, CompletionEditor.class.getName());
35          wizdef.set(WizDefinition.FLD_FACTORY, EmoCompletionFactory.class.getName());
36          wizdef.set(WizDefinition.FLD_CONTROLLER, CompletionWizardAction.class.getName());
37          wizdef.set(WizDefinition.FLD_ADDITIONAL_INFO, CompletionDefinition.class.getName());
38  
39  
40          CompletionDefinition cd = new CompletionDefinition();
41          cd.setField(CompletionDefinition.FLD_TARGET_NODE, CompletionWizardTestBean.TARGET_NODE);
42  
43          wizdef.setAdditionalInfo(cd);
44  
45          CompletionDetails ratingDetail = new CompletionDetails();
46          ratingDetail.set(CompletionDetails.FLD_COMPLETION, FieldCompletion.FIXED.toString());
47          ratingDetail.setField(CompletionDetails.FLD_PART_ID, CompletionWizardTestBean.PART_RATING);
48          ratingDetail.setField(CompletionDetails.FLD_PART_ORDER,0);
49          cd.addCompletionDetail(ratingDetail);
50  
51          CompletionDetails userReviews = new CompletionDetails();
52          userReviews.set(CompletionDetails.FLD_COMPLETION, FieldCompletion.WIZARD.toString());
53          userReviews.setField(CompletionDetails.FLD_PART_ID, CompletionWizardTestBean.USER_REVIEWS);
54          userReviews.setField(CompletionDetails.FLD_PART_ORDER,1);
55          cd.addCompletionDetail(userReviews);
56  
57          CompletionDetails length = new CompletionDetails();
58          length.set(CompletionDetails.FLD_COMPLETION, FieldCompletion.WIZARD.toString());
59          length.setField(CompletionDetails.FLD_PART_ID, CompletionWizardTestBean.LENGTH);
60          length.setField(CompletionDetails.FLD_DIRECTIVE, CompletionWizardTestBean.LENGTH_DIRECTIVE);
61          length.setField(CompletionDetails.FLD_HELPTEXT, CompletionWizardTestBean.LENGTH_HELPTEXT);
62          length.setField(CompletionDetails.FLD_PART_ORDER,2);
63          cd.addCompletionDetail(length);
64  
65  
66          CompletionDetails actors = new CompletionDetails();
67          actors.setField(CompletionDetails.FLD_PART_ID, CompletionWizardTestBean.ACTORS);
68          actors.setField(CompletionDetails.FLD_PART_ORDER,3);
69          actors.setField(CompletionDetails.FLD_COMPLETION, FieldCompletion.WIZARD.toString());
70          actors.setField(CompletionDetails.FLD_MIN_ENTRIES,1);
71          actors.setField(CompletionDetails.FLD_MAX_ENTRIES,10);
72          cd.addCompletionDetail(actors);
73      }
74  
75      public void tearDown() throws Exception {
76          wizdef = null;
77      }
78  
79      public WizDefinition getBuiltDefinition() {
80          return wizdef;
81      }
82  }