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;
11 public class ValidationFacade {
13 private transient String _myicon;
14 private transient String _myname;
15 private transient Name _mypublisher;
16 private transient Name _myreviewer;
17 private transient Name _myapprover;
19 protected static class UserOption implements Name {
20 protected transient String _name;
21 protected transient long _index;
24 * Create a localized named user option.
25 * @param key option label key
26 * @param locale current locale
28 public UserOption(final String key, final Locale locale) {
30 _name = ResourceBundle.getBundle("labels", locale).getString(key);
33 public long getIndex() {
38 public String toString() {
43 protected static class NotRequired extends UserOption {
44 protected NotRequired(final Locale locale) {
45 super("label.skipped", locale);
50 protected static class ByAuthor extends UserOption {
51 protected ByAuthor(final Locale locale) {
52 super("label.bytheauthor", locale);
57 protected static class ByManager extends UserOption {
58 protected ByManager(final User manager, final Locale locale) {
59 super("label.me", locale);
60 _index = manager.getIndex();
64 // ==============================================================================================================================
66 // ==============================================================================================================================
68 public ValidationFacade(final ValidationCycle cycle, final Locale locale) {
69 _myicon = "icon.empty.png";
70 if (cycle.isDefault()) {
73 if (cycle.isAssigned()) {
74 _myicon = "icon.done.png";
76 _myname = cycle.getDocumentType().getName();
78 _mypublisher = cycle.getActor(ValidationStep.PROMOTION);
79 _myreviewer = cycle.getActor(ValidationStep.REVIEW);
80 _myapprover = cycle.getActor(ValidationStep.APPROVAL);
81 if (_mypublisher == null) {
82 _mypublisher = new ByAuthor(locale);
84 if (_myreviewer == null || _myapprover == null) {
85 Name skipped = new NotRequired(locale);
86 if (_myreviewer == null) {
87 _myreviewer = skipped;
89 if (_myapprover == null) {
90 _myapprover = skipped;
95 // ==============================================================================================================================
97 // ==============================================================================================================================
99 public String getDocumentType() {
103 public long getApproverIndex() {
104 return _myapprover.getIndex();
107 public String getApproverName() {
108 return _myapprover.toString();
111 public String getIcon() {
115 public long getPublisherIndex() {
116 return _mypublisher.getIndex();
119 public String getPublisherName() {
120 return _mypublisher.toString();
123 public long getReviewerIndex() {
124 return _myreviewer.getIndex();
127 public String getReviewerName() {
128 return _myreviewer.toString();