1 package org.splat.simer;
3 import java.util.Locale;
4 import java.util.ResourceBundle;
6 import org.splat.dal.bo.kernel.User;
7 import org.splat.dal.bo.som.ValidationCycle;
8 import org.splat.dal.bo.som.ValidationStep;
9 import org.splat.kernel.Name;
12 * Validation cycle presentation facade.
14 public class ValidationFacade {
19 private transient String _myicon;
23 private transient String _myname;
27 private transient Name _mypublisher;
31 private transient Name _myreviewer;
35 private transient Name _myapprover;
38 * Option presentation in users lists.
40 protected static class UserOption implements Name {
44 protected transient String _name;
48 protected transient long _index;
51 * Create a localized named user option.
58 public UserOption(final String key, final Locale locale) {
60 _name = ResourceBundle.getBundle("labels", locale).getString(key);
66 * @see org.splat.kernel.Name#getIndex()
68 public long getIndex() {
75 * @see java.lang.Object#toString()
78 public String toString() {
83 * Get user's display name.
85 * @return user's display name
87 public String getDisplayName() {
93 * Not applicable user option presentation. For example, if there is no review<BR>
94 * step, then reviewer will be undefined.
96 protected static class NotRequired extends UserOption {
103 protected NotRequired(final Locale locale) {
104 super("label.skipped", locale);
110 * Author presentation.
112 protected static class ByAuthor extends UserOption {
119 protected ByAuthor(final Locale locale) {
120 super("label.bytheauthor", locale);
126 * Current user presentation ("Me").
128 protected static class ByManager extends UserOption {
137 protected ByManager(final User manager, final Locale locale) {
138 super("label.me", locale);
139 _index = manager.getIndex();
143 // ==============================================================================================================================
145 // ==============================================================================================================================
151 * the presented validation cycle
155 public ValidationFacade(final ValidationCycle cycle, final Locale locale) {
156 _myicon = "icon.empty.png";
157 if (cycle.isDefault()) {
160 if (cycle.isAssigned()) {
161 _myicon = "icon.done.png";
163 _myname = cycle.getDocumentType().getName();
165 _mypublisher = cycle.getActor(ValidationStep.PROMOTION);
166 _myreviewer = cycle.getActor(ValidationStep.REVIEW);
167 _myapprover = cycle.getActor(ValidationStep.APPROVAL);
168 if (_mypublisher == null) {
169 _mypublisher = new ByAuthor(locale);
171 if (_myreviewer == null || _myapprover == null) {
172 Name skipped = new NotRequired(locale);
173 if (_myreviewer == null) {
174 _myreviewer = skipped;
176 if (_myapprover == null) {
177 _myapprover = skipped;
182 // ==============================================================================================================================
184 // ==============================================================================================================================
187 * Get the document type of the validation cycle.
189 * @return document type name
191 public String getDocumentType() {
196 * Get the approver id.
200 public long getApproverIndex() {
201 return _myapprover.getIndex();
205 * Get the approver name.
209 public String getApproverName() {
210 return _myapprover.toString();
216 * @return the icon name
218 public String getIcon() {
223 * Get the publisher id.
227 public String getPublisherName() {
228 return _mypublisher.toString();
232 * Get the publisher id.
236 public long getPublisherIndex() {
237 return _mypublisher.getIndex();
241 * Get the reviewer id.
245 public String getReviewerName() {
246 return _myreviewer.toString();
250 * Get the reviewer id.
254 public long getReviewerIndex() {
255 return _myreviewer.getIndex();