1 package com.sri.emo.wizard.creation;
2
3 import com.sri.common.dbobj.ObjectNotFoundException;
4 import com.sri.common.dbobj.RepositoryConversionException;
5 import com.sri.common.dbobj.RepositoryException;
6 import com.sri.emo.wizard.creation.model.CreationBeans;
7 import com.sri.emo.wizard.expressoimpl.ExpressoLink;
8 import com.sri.emo.wizard.selection.EmoSelectionWizardFactory;
9 import com.sri.emo.wizard.branch.EmoBranchingWizardFactory;
10 import com.sri.emo.wizard.expressoimpl.WizardController;
11 import com.jcorporate.expresso.core.controller.Transition;
12 import com.sri.emo.controller.*;
13
14
15 /***
16 * Base class for things that build Completion Wizards. This can either be
17 * Factories or <tt>Memento</tt> converters.
18 *
19 * @author Michael Rimov
20 * @version 1.0
21 */
22 class CreationBuilder extends EmoBranchingWizardFactory {
23
24 /***
25 * Constructs a completion builder.
26 *
27 * @param completionRepository CompletionRepository
28 */
29 public CreationBuilder(final CreationRepository completionRepository) {
30 super();
31 repository = completionRepository;
32 }
33
34 /***
35 * The completion repository to use for querying the wizard.
36 */
37 final protected CreationRepository repository;
38
39 /***
40 * The completion definition.
41 */
42 private CreationBeans myDefinition;
43
44 /***
45 * Finish link.
46 */
47 protected ExpressoLink finish;
48
49 /***
50 * Next page link
51 */
52 protected ExpressoLink next;
53
54 /***
55 // * Summary page link
56 // */
57
58
59 /***
60 * Back Link.
61 */
62 protected ExpressoLink back;
63
64 /***
65 * Cancel link.
66 */
67 protected ExpressoLink cancel;
68
69 /***
70 * To be set by the factory.
71 *
72 * @param newId int
73 */
74 public void setWizardId(int newId) {
75 super.setWizardId(newId);
76 extractDefinition(newId);
77 next = buildNextLink(newId);
78
79 finish = buildFinishLink(newId);
80 cancel = buildCancelLink(newId);
81 back = buildBackLink(newId);
82 }
83
84 /***
85 * Builds the link that corresponds to the 'next' location.
86 *
87 * @param id int the wizard id
88 * @return Link
89 */
90
91
92
93
94
95
96
97
98
99 /***
100 * Queries the repository to grab the wizard id.
101 *
102 * @param wizardId int the id of the wizard to extract.
103 * @throws RepositoryConversionException
104 * @throws RepositoryException
105 * @throws IllegalArgumentException if the wizard id doesn't exist.
106 */
107 private void extractDefinition(int wizardId) throws RepositoryConversionException, RepositoryException,
108 IllegalArgumentException {
109 try {
110 myDefinition = repository.findById(wizardId);
111 } catch (ObjectNotFoundException ex) {
112 ex.printStackTrace();
113 throw new IllegalArgumentException("Unable to locate the wizard definition by id of : " + wizardId);
114 }
115 }
116
117 protected CreationBeans getDefinition() {
118 return myDefinition;
119 }
120
121
122 }